edc_web_components/components/
show_policy.rs1mod policy_properties;
2
3use edc_connector_client::types::policy::{Policy, PolicyKind};
4use patternfly_yew::prelude::*;
5pub use policy_properties::PolicyProperties;
6use yew::prelude::*;
7
8#[derive(Clone, Debug, PartialEq, Properties)]
9pub struct ShowPolicyProps {
10 pub policy: Policy,
11 #[prop_or_default]
12 pub name: Option<String>,
13 #[prop_or_default]
14 pub hide_kind: bool,
15 #[prop_or_default]
16 pub hide_id: bool,
17 #[prop_or_default]
18 pub hide_name: bool,
19 #[prop_or_default]
20 pub hide_profiles: bool,
21 #[prop_or_default]
22 pub hide_extensible_properties: bool,
23}
24
25#[component]
26pub fn ShowPolicy(props: &ShowPolicyProps) -> Html {
27 let id = if props.hide_id {
28 html!()
29 } else {
30 html!(<DescriptionGroup term="Id">{ props.policy.id() }</DescriptionGroup>)
31 };
32
33 let name = if props.hide_name {
34 html!()
35 } else {
36 html!(<DescriptionGroup term="Name">{ props.name.clone() }</DescriptionGroup>)
37 };
38
39 let kind = if props.hide_kind {
40 html!()
41 } else {
42 let kind = match props.policy.kind() {
43 PolicyKind::Set => "Set",
44 PolicyKind::Offer => "Offer",
45 PolicyKind::Agreement => "Agreement",
46 };
47
48 html!(<DescriptionGroup term="Kind">{ kind }</DescriptionGroup>)
49 };
50
51 html!(
52 <DescriptionList mode={[DescriptionListMode::Horizontal]}>
53 { id }
54 { name }
55 { kind }
56 <PolicyProperties
57 permissions={props.policy.permissions().to_vec()}
58 obligations={props.policy.obligations().to_vec()}
59 prohibitions={props.policy.prohibitions().to_vec()}
60 extensible_properties={props.policy.extensible_properties().clone()}
61 assigner={props.policy.assigner().cloned()}
62 assignee={props.policy.assignee().cloned()}
63 />
64 </DescriptionList>
65 )
66}