|
69 | 69 | :errors="[resourcesError, globalInsightError, meshInsightError]" |
70 | 70 | v-slot="{ data: [resources, globalInsight, meshInsight] }" |
71 | 71 | > |
72 | | - <template |
73 | | - v-for="hasLegacyPolicies of [resources.resources.some(resource => !resource.policy?.isTargetRef && (meshInsight.policies[resource.name]?.total ?? 0) > 0)]" |
74 | | - :key="typeof hasLegacyPolicies" |
| 72 | + <XLayout |
| 73 | + v-for="filtered in [resources.resources.filter((item) => |
| 74 | + (route.params.category === 'all' || item.categories.includes(route.params.category)) && item.shortName.length > 0, |
| 75 | + )]" |
| 76 | + :key="typeof filtered" |
| 77 | + variant="y-stack" |
75 | 78 | > |
76 | | - <XLayout |
77 | | - v-for="filtered in [resources.resources.filter((item) => |
78 | | - (route.params.category === 'all' || item.categories.includes(route.params.category)) && |
79 | | - (!item.policy || item.policy?.isTargetRef || hasLegacyPolicies) && |
80 | | - (item.name !== 'ExternalService' || meshInsight.services.external > 0)), |
81 | | - ]" |
82 | | - :key="typeof filtered" |
83 | | - variant="y-stack" |
| 79 | + <template |
| 80 | + v-for="([key, group], i) in Object.entries(Object.groupBy(filtered, (resource) => resource.group)).toSorted((a, b) => a[0] > b[0] ? -1 : 1)" |
| 81 | + :key="key" |
84 | 82 | > |
85 | | - <template |
86 | | - v-for="([key, group], i) in Object.entries(Object.groupBy(filtered, (resource) => resource.group)).toSorted((a, b) => a[0] > b[0] ? -1 : 1)" |
87 | | - :key="key" |
88 | | - > |
89 | | - <ul v-if="group?.length"> |
90 | | - <li> |
91 | | - <XLayout |
92 | | - variant="y-stack" |
| 83 | + <ul v-if="group?.length"> |
| 84 | + <li> |
| 85 | + <XLayout |
| 86 | + variant="y-stack" |
| 87 | + > |
| 88 | + <header> |
| 89 | + <h3>{{ t(`resources.routes.items.types.${key}.title`) }}</h3> |
| 90 | + </header> |
| 91 | + <DataCollection |
| 92 | + :items="group" |
93 | 93 | > |
94 | | - <header> |
95 | | - <h3>{{ t(`resources.routes.items.types.${key}.title`) }}</h3> |
96 | | - </header> |
97 | | - <DataCollection |
98 | | - :items="group" |
99 | | - > |
100 | | - <template #default="{ items }"> |
101 | | - <ul> |
102 | | - <li |
103 | | - v-for="(item, j) in items" |
104 | | - :key="item.name" |
105 | | - :class="{ |
106 | | - 'active': item.path === route.params.resourcePath, |
| 94 | + <template #default="{ items }"> |
| 95 | + <ul> |
| 96 | + <li |
| 97 | + v-for="(item, j) in items" |
| 98 | + :key="item.name" |
| 99 | + :class="{ |
| 100 | + 'active': item.path === route.params.resourcePath, |
| 101 | + }" |
| 102 | + > |
| 103 | + <XAction |
| 104 | + :to="{ |
| 105 | + name: 'resource-list-view', |
| 106 | + params: { |
| 107 | + mesh: route.params.mesh, |
| 108 | + resourcePath: item.path, |
| 109 | + }, |
| 110 | + query: { |
| 111 | + category: route.params.category, |
| 112 | + }, |
| 113 | + }" |
| 114 | + :data-testid="`resource-type-link-${item.name}`" |
| 115 | + @vue:mounted="(vNode) => { |
| 116 | + if((route.params.resourcePath.length === 0 || !resources.resources.find((resource) => resource.path === route.params.resourcePath)) && i === 0 && j === 0 && vNode.props?.to) { |
| 117 | + $nextTick(() => { |
| 118 | + route.replace(vNode.props!.to) |
| 119 | + }) |
| 120 | + } |
107 | 121 | }" |
108 | 122 | > |
109 | | - <XAction |
110 | | - :to="{ |
111 | | - name: 'resource-list-view', |
112 | | - params: { |
113 | | - mesh: route.params.mesh, |
114 | | - resourcePath: item.path, |
115 | | - }, |
116 | | - query: { |
117 | | - category: route.params.category, |
118 | | - }, |
119 | | - }" |
120 | | - :data-testid="`resource-type-link-${item.name}`" |
121 | | - @vue:mounted="(vNode) => { |
122 | | - if((route.params.resourcePath.length === 0 || !resources.resources.find((resource) => resource.path === route.params.resourcePath)) && i === 0 && j === 0 && vNode.props?.to) { |
123 | | - $nextTick(() => { |
124 | | - route.replace(vNode.props!.to) |
125 | | - }) |
126 | | - } |
127 | | - }" |
| 123 | + <XLayout |
| 124 | + variant="x-stack" |
| 125 | + justify="between" |
128 | 126 | > |
129 | | - <XLayout |
130 | | - variant="x-stack" |
131 | | - justify="between" |
132 | | - > |
133 | | - <span> |
134 | | - {{ item.name }} |
135 | | - </span> |
136 | | - <span v-if="item.group === 'global'"> |
137 | | - {{ globalInsight.resources[item.name]?.total ?? 0 }} |
138 | | - </span> |
139 | | - <span v-else> |
140 | | - {{ meshInsight.resources[item.name]?.total ?? 0 }} |
141 | | - </span> |
142 | | - </XLayout> |
143 | | - </XAction> |
144 | | - </li> |
145 | | - </ul> |
146 | | - </template> |
147 | | - </DataCollection> |
148 | | - </XLayout> |
149 | | - </li> |
150 | | - </ul> |
151 | | - </template> |
152 | | - </XLayout> |
153 | | - </template> |
| 127 | + <span> |
| 128 | + {{ item.name }} |
| 129 | + </span> |
| 130 | + <span v-if="item.group === 'global'"> |
| 131 | + {{ globalInsight.resources[item.name]?.total ?? 0 }} |
| 132 | + </span> |
| 133 | + <span v-else> |
| 134 | + {{ meshInsight.resources[item.name]?.total ?? 0 }} |
| 135 | + </span> |
| 136 | + </XLayout> |
| 137 | + </XAction> |
| 138 | + </li> |
| 139 | + </ul> |
| 140 | + </template> |
| 141 | + </DataCollection> |
| 142 | + </XLayout> |
| 143 | + </li> |
| 144 | + </ul> |
| 145 | + </template> |
| 146 | + </XLayout> |
154 | 147 | </DataLoader> |
155 | 148 | </XCard> |
156 | 149 | <div v-if="route.params.resourcePath.length > 0"> |
|
0 commit comments