Skip to content

Commit 8c1a7bd

Browse files
authored
fix(dataplanes/dataplane-policy-config-summary): multiple app-titles (#5106) (#5108)
Backport of #5106 to release-2.14 >The schema of dataplane policies doesn't include a `name` or `id` (or similar), but only `kind`. There could be multiple policies with the same `kind`. Due to the `DataCollection` and loop in `DataplenPolicyConfigSummaryView` this could lead to multiple titles being rendered. I've changed it so we first group all the policies by `kind`, render the title and then all the configs related to that `kind`. > >--- > >There is also the case that we found a kri without a shortName and I think this is only related to our mocks, see above ☝️ > >Closes #5085 Signed-off-by: schogges <moritz.fleck@konghq.com>
1 parent cbb093e commit 8c1a7bd

1 file changed

Lines changed: 65 additions & 59 deletions

File tree

packages/kuma-gui/src/app/data-planes/views/DataplanePolicyConfigSummaryView.vue

Lines changed: 65 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@
1111
>
1212
<DataSource
1313
:src="uri(policySources, '/policy-types', {})"
14-
v-slot="{ data: policyTypesData }"
14+
v-slot="{ data: sourcePolicyTypesData }"
1515
>
1616
<DataLoader
17-
:data="[props.policies, policyTypesData]"
17+
:data="[props.policies, sourcePolicyTypesData]"
18+
v-slot="{ data: [policiesData, policyTypesData]}"
1819
>
1920
<DataCollection
20-
:items="props.policies!"
21-
:predicate="item => item.kind.toLocaleLowerCase() === route.params.policy"
21+
:items="Object.entries(Object.groupBy(policiesData, ({ kind }) => kind ))"
22+
:predicate="([item]) => item.toLocaleLowerCase() === route.params.policy"
2223
v-slot="{ items }"
2324
>
2425
<template
25-
v-for="{ kind, conf, origins } of items"
26+
v-for="[kind, configs] of items"
2627
:key="kind"
2728
>
2829
<AppView>
@@ -39,66 +40,71 @@
3940
</XLayout>
4041
</template>
4142
<template
42-
v-for="policyTypes in [Object.groupBy((policyTypesData?.policyTypes ?? []), ({ name }) => name)]"
43-
:key="`${typeof policyTypes}`"
43+
v-for="(config, index) in configs"
44+
:key="index"
4445
>
45-
<XTable
46-
v-if="origins.length > 0"
47-
variant="kv"
46+
<template
47+
v-for="policyTypes in [Object.groupBy(policyTypesData.policyTypes, ({ name }) => name)]"
48+
:key="`${typeof policyTypes}`"
4849
>
49-
<tr>
50-
<th scope="row">
51-
Origin policies
52-
</th>
53-
<td>
54-
<ul>
55-
<li
56-
v-for="origin in origins"
57-
:key="origin.kri"
58-
>
59-
<template
60-
v-for="kri in [Kri.fromString(origin.kri)]"
61-
:key="typeof kri"
50+
<XTable
51+
v-if="config.origins.length > 0"
52+
variant="kv"
53+
>
54+
<tr>
55+
<th scope="row">
56+
Origin policies
57+
</th>
58+
<td>
59+
<ul>
60+
<li
61+
v-for="origin in config.origins"
62+
:key="origin.kri"
6263
>
63-
<XAction
64-
v-if="policyTypes[kind]"
65-
:to="{
66-
name: 'policy-detail-view',
67-
params: {
68-
mesh: kri.mesh,
69-
policyPath: policyTypes[kind]![0].path,
70-
policy: kri.name,
71-
},
72-
}"
73-
>
74-
{{ origin.kri }}
75-
</XAction>
7664
<template
77-
v-else
65+
v-for="kri in [Kri.fromString(origin.kri)]"
66+
:key="typeof kri"
7867
>
79-
{{ origin.kri }}
68+
<XAction
69+
v-if="policyTypes[kind]"
70+
:to="{
71+
name: 'policy-detail-view',
72+
params: {
73+
mesh: kri.mesh,
74+
policyPath: policyTypes[kind]![0].path,
75+
policy: kri.name,
76+
},
77+
}"
78+
>
79+
{{ origin.kri }}
80+
</XAction>
81+
<template
82+
v-else
83+
>
84+
{{ origin.kri }}
85+
</template>
8086
</template>
81-
</template>
82-
</li>
83-
</ul>
84-
</td>
85-
</tr>
86-
<tr>
87-
<td colspan="2">
88-
<XLayout
89-
variant="y-stack"
90-
size="small"
91-
>
92-
<span>Config</span>
93-
<XCodeBlock
94-
:code="YAML.stringify(conf)"
95-
language="yaml"
96-
:show-copy-button="false"
97-
/>
98-
</XLayout>
99-
</td>
100-
</tr>
101-
</XTable>
87+
</li>
88+
</ul>
89+
</td>
90+
</tr>
91+
<tr>
92+
<td colspan="2">
93+
<XLayout
94+
variant="y-stack"
95+
size="small"
96+
>
97+
<span>Config</span>
98+
<XCodeBlock
99+
:code="YAML.stringify(config.conf)"
100+
language="yaml"
101+
:show-copy-button="false"
102+
/>
103+
</XLayout>
104+
</td>
105+
</tr>
106+
</XTable>
107+
</template>
102108
</template>
103109
</AppView>
104110
</template>

0 commit comments

Comments
 (0)