Skip to content

Commit 90f716f

Browse files
committed
improve result expand UX
Signed-off-by: Frank Jogeleit <[email protected]>
1 parent 94d5d21 commit 90f716f

File tree

8 files changed

+36
-16
lines changed

8 files changed

+36
-16
lines changed

backend/pkg/service/model.go

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ type Source struct {
8888
Status []string `json:"status"`
8989
Chart *Chart `json:"chart"`
9090
Exceptions bool `json:"exceptions"`
91+
Plugin bool `json:"plugin"`
9192
}
9293

9394
type PolicyCharts struct {

backend/pkg/service/service.go

+6
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,18 @@ func (s *Service) ResourceDetails(ctx context.Context, cluster, id string, query
344344
severityMap[r] = true
345345
}
346346

347+
var plugin bool
348+
if _, ok := s.plugin(cluster, source.Name); ok {
349+
plugin = true
350+
}
351+
347352
list = append(list, Source{
348353
Name: source.Name,
349354
Title: title,
350355
Categories: categories,
351356
Status: status,
352357
Exceptions: config.Exceptions,
358+
Plugin: plugin,
353359
Chart: MapCategoryStatusToChart(title, source.Categories, config.EnabledResults()),
354360
})
355361
}

frontend/modules/core/components/Search.vue

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
variant="outlined"
99
density="compact"
1010
v-bind="$attrs"
11+
clearable
1112
/>
1213
</template>
1314

frontend/modules/core/components/chip/Severity.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
<script lang="ts" setup>
88
import type { Severity } from "~/modules/core/types";
99
10-
const props = defineProps<{ severity: Severity }>()
10+
defineProps<{ severity: Severity }>()
1111
</script>

frontend/modules/core/components/resource/CategoryTables.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
<div v-show="open">
1111
<v-divider />
1212
<v-card-text>
13-
<GraphStatusPerCategory :source="source.chart" />
13+
<GraphBarPerCategory :source="source.chart" />
1414
</v-card-text>
1515
<scroller :list="source.categories">
1616
<template #default="{ item }">
17-
<resource-results :source="source.name" :resource="resource.id" :category="item" :exceptions="source.exceptions" />
17+
<resource-results :source="source.name" :resource="resource.id" :category="item" :exceptions="source.exceptions" :plugin="source.plugin" />
1818
</template>
1919
</scroller>
2020
</div>
@@ -28,7 +28,7 @@ import CollapseBtn from "../../../../components/CollapseBtn.vue";
2828
2929
const open = ref(true)
3030
31-
const props = defineProps<{
31+
defineProps<{
3232
source: SourceDetails;
3333
resource: Resource;
3434
}>();

frontend/modules/core/components/resource/Results.vue

+19-11
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,25 @@
2121
show-expand
2222
v-model:items-per-page="options.itemsPerPage"
2323
v-model:page="options.page"
24+
hover
2425
>
25-
<template #item.policy="{ value }">
26-
<nuxt-link :to="{ name: 'policies-source-info-policy', params: { source, policy: value }}" class="text-decoration-none text-primary" target="_blank">{{ value }}</nuxt-link>
27-
</template>
28-
<template #item.status="{ value }">
29-
<chip-status @click="searchText = value" :status="value" />
30-
</template>
31-
<template #item.severity="{ value }">
32-
<chip-severity v-if="value" @click="searchText = value" :severity="value" />
33-
</template>
34-
<template #item.exception="{ item }" v-if="props.exceptions">
35-
<resource-exception-dialog :resource="props.resource" :source="props.source" :policies="[{ name: item.policy, rules: [{ name: item.rule, props: item.properties }]}]" />
26+
<template #item="{ item, ...props }">
27+
<tr @click="() => props.toggleExpand(props.internalItem)" class="cursor-pointer">
28+
<td>
29+
<nuxt-link v-if="plugin" :to="{ name: 'policies-source-info-policy', params: { source, policy: item.policy }}" class="text-decoration-none text-primary" target="_blank">{{ item.policy }}</nuxt-link>
30+
<template v-else>{{ item.policy }}</template>
31+
</td>
32+
<td>{{ item.rule }}</td>
33+
<td>
34+
<chip-severity v-if="item.severity" @click.prevent.stop="searchText = item.severity" :severity="item.severity" />
35+
</td>
36+
<td>
37+
<chip-status @click.prevent.stop="searchText = item.status" :status="item.status" />
38+
</td>
39+
<td>
40+
<resource-exception-dialog v-if="exceptions" :resource="resource" :source="source" :policies="[{ name: item.policy, rules: [{ name: item.rule, props: item.properties }]}]" />
41+
</td>
42+
</tr>
3643
</template>
3744
<template #expanded-row="{ columns, item }">
3845
<tr :class="bg">
@@ -70,6 +77,7 @@ import { capilize } from "~/modules/core/layouthHelper";
7077
import { mapResults } from "~/modules/core/mapper";
7178
7279
const props = defineProps<{
80+
plugin?: boolean;
7381
source: string;
7482
category?: string;
7583
exceptions?: boolean;

frontend/modules/core/mapper.ts

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const priorityToColor: { [key in Priority]: string } = {
1111
}
1212

1313
const statusToColor: { [status in Status]: string } = {
14+
[Status.SUMMARY]: '#E0E0E0',
1415
[Status.SKIP]: '#E0E0E0',
1516
[Status.PASS]: '#43A047',
1617
[Status.WARN]: '#FB8C00',
@@ -19,6 +20,7 @@ const statusToColor: { [status in Status]: string } = {
1920
}
2021

2122
const statusToDarkColor: { [status in Status]: string } = {
23+
[Status.SUMMARY]: '#424242',
2224
[Status.SKIP]: '#424242',
2325
[Status.PASS]: '#1B5E20',
2426
[Status.WARN]: '#FF6F00',

frontend/modules/core/types.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export type SourceDetails = {
200200
categories: string[];
201201
chart: Chart;
202202
exceptions: boolean;
203+
plugin: boolean;
203204
}
204205

205206
export type ResourceDetails = {
@@ -273,7 +274,8 @@ export type ListResult = {
273274
policy: string;
274275
rule: string;
275276
status: Status;
276-
timestamp: number
277+
severity: Severity;
278+
timestamp: number;
277279
properties: { [key: string]: string };
278280
}
279281

0 commit comments

Comments
 (0)