Skip to content

Commit 8bb363a

Browse files
committed
Policy List Scroller
Signed-off-by: Frank Jogeleit <[email protected]>
1 parent be0a874 commit 8bb363a

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

frontend/modules/core/components/policy/Item.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ const props = defineProps({
4141
4242
const status = useStatusInjection()
4343
44-
const showSkipped = computed(() => console.log(status.value.includes(Status.SKIP) && !!props.item?.results[Status.SKIP]) || status.value.includes(Status.SKIP) && !!props.item?.results[Status.SKIP])
44+
const showSkipped = computed(() => status.value.includes(Status.SKIP) && !!props.item?.results[Status.SKIP])
4545
const showed = computed(() => status.value.filter((s) => s !== Status.SKIP))
4646
</script>

frontend/modules/core/components/policy/List.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
</v-list>
1414
<template v-else>
1515
<v-list v-if="list.length && open" lines="two" class="mt-0 pt-0 pb-0 mb-0">
16-
<PolicyItem v-for="item in list" :key="item.name" :item="item" :details="false" />
16+
<policy-list-scroller :list="list" :default-loadings="3" key-prop="name">
17+
<template #default="{ item }">
18+
<PolicyItem :item="item" :details="false" />
19+
</template>
20+
</policy-list-scroller>
1721
</v-list>
1822
<template v-if="!list.length">
1923
<v-divider />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template>
2+
<v-infinite-scroll :onLoad="load" class="no-scrollbar pb-0 mb-0" v-if="loaded.length">
3+
<template v-for="item in loaded" :key="keyProp ? item[keyProp] : item">
4+
<slot :item="item" />
5+
</template>
6+
<template #empty></template>
7+
</v-infinite-scroll>
8+
</template>
9+
10+
<script setup lang="ts">
11+
const props = defineProps<{ list: any[]; defaultLoadings: number; keyProp?: string }>()
12+
13+
const max = props.list.length
14+
15+
const loaded = ref<any[]>(max ? props.list.slice(0, Math.min(max, props.defaultLoadings)) : [])
16+
17+
const load = ({ done }: any) => {
18+
const current = loaded.value.length
19+
20+
loaded.value = [...loaded.value, ...props.list.slice(current, Math.min(max, current + props.defaultLoadings))]
21+
22+
if (loaded.value.length === props.list.length) {
23+
done('empty')
24+
} else {
25+
done('ok')
26+
}
27+
}
28+
29+
</script>

frontend/modules/core/provider/dashboard.ts

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ export const ShowedStatus = Symbol('show status chip')
33
export const NamespacedKinds = Symbol('namespaced kind filters')
44
export const ClusterKinds = Symbol('cluster kind filters')
55
export const SourceContext = Symbol('source context')
6-

0 commit comments

Comments
 (0)