Skip to main content

rumtk_web/components/widgets/
youtrack.rs

1/*
2 *     rumtk attempts to implement HL7 and medical protocols for interoperability in medicine.
3 *     This toolkit aims to be reliable, simple, performant, and standards compliant.
4 *     Copyright (C) 2026  Luis M. Santos, M.D. <lsantos@medicalmasses.com>
5 *     Copyright (C) 2026  MedicalMasses L.L.C. <contact@medicalmasses.com>
6 *
7 *     This program is free software: you can redistribute it and/or modify
8 *     it under the terms of the GNU General Public License as published by
9 *     the Free Software Foundation, either version 3 of the License, or
10 *     (at your option) any later version.
11 *
12 *     This program is distributed in the hope that it will be useful,
13 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *     GNU General Public License for more details.
16 *
17 *     You should have received a copy of the GNU General Public License
18 *     along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 */
20use crate::utils::types::{SharedAppState, URLParams, URLPath};
21use crate::{rumtk_web_get_config, ComponentResult, RUMWebTemplate, RUMWebTemplateSafe, DEFAULT_TEXTMAP};
22use rumtk_core::strings::RUMString;
23
24pub const YOUTRACK_SANITIZER_TAGS: &str = "script";
25pub const YOUTRACK_SANITIZER_ATTRIBUTES: &[&str] = &[
26    "data-yt-url",
27    "data-theme",
28    "data-lang",
29];
30
31#[derive(RUMWebTemplate, Debug, Clone)]
32#[template(
33    source = "
34        <script
35            id='2cf86344-cf91-4511-a292-de40ae00fc19'
36            data-yt-url='https://{{portal}}.youtrack.cloud'
37            src='https://{{portal}}.youtrack.cloud/static/simplified/form/form-entry.js'
38            data-theme='{{theme}}'
39            data-lang='{{lang}}'
40            async
41            defer
42            >
43        </script>
44    ",
45    ext = "html"
46)]
47pub struct YouTrack {
48    portal: RUMString,
49    uuid: RUMString,
50    theme: RUMString,
51    lang: RUMString,
52}
53
54impl RUMWebTemplateSafe for YouTrack {}
55
56pub fn youtrack<'a>(_path_components: URLPath<'a, 'a>, params: URLParams<'a>, state: SharedAppState) -> ComponentResult<YouTrack> {
57    let route_info = match rumtk_web_get_config!(state).router.get_service_route(&"youtrack".to_string()){
58        Some(portal) => portal.clone(),
59        None => DEFAULT_TEXTMAP.clone(),
60    };
61    let portal = route_info.get("portal").unwrap().clone();
62    let uuid = route_info.get("uuid").unwrap().clone();
63    let theme = rumtk_web_get_config!(state).theme.clone();
64    let lang = rumtk_web_get_config!(state).lang.clone();
65
66    Ok(YouTrack {
67        portal,
68        uuid,
69        theme,
70        lang,
71    })
72}
73