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        </script>
41    ",
42    ext = "html"
43)]
44pub struct YouTrack {
45    portal: RUMString,
46    uuid: RUMString,
47    theme: RUMString,
48    lang: RUMString,
49}
50
51impl RUMWebTemplateSafe for YouTrack {}
52
53pub fn youtrack<'a>(_path_components: URLPath<'a, 'a>, params: URLParams<'a>, state: SharedAppState) -> ComponentResult<YouTrack> {
54    let route_info = match rumtk_web_get_config!(state).router.get_service_route(&"youtrack".to_string()){
55        Some(portal) => portal.clone(),
56        None => DEFAULT_TEXTMAP.clone(),
57    };
58    let portal = route_info.get("portal").unwrap().clone();
59    let uuid = route_info.get("uuid").unwrap().clone();
60    let theme = rumtk_web_get_config!(state).theme.clone();
61    let lang = rumtk_web_get_config!(state).lang.clone();
62
63    Ok(YouTrack {
64        portal,
65        uuid,
66        theme,
67        lang,
68    })
69}
70