@@ -10,9 +10,14 @@ const { data: vulnTree, status } = useDependencyAnalysis(
1010)
1111
1212const isExpanded = shallowRef (false )
13- const showAllPackages = shallowRef (false )
1413const showAllVulnerabilities = shallowRef (false )
1514
15+ const {
16+ visibleItems : visiblePackages,
17+ hasMore : hasMorePackages,
18+ expand : expandPackages,
19+ } = useVisibleItems (() => vulnTree .value ?.vulnerablePackages ?? [], 5 )
20+
1621const hasVulnerabilities = computed (
1722 () => vulnTree .value && vulnTree .value .vulnerablePackages .length > 0 ,
1823)
@@ -110,7 +115,7 @@ function getDepthStyle(depth: string | undefined) {
110115 <div v-show =" isExpanded" id =" vuln-tree-details" class =" border-t border-border bg-bg-subtle" >
111116 <ul class =" divide-y divide-border list-none m-0 p-0" >
112117 <li
113- v-for =" pkg in vulnTree!.vulnerablePackages.slice(0, showAllPackages ? undefined : 5) "
118+ v-for =" pkg in visiblePackages "
114119 :key =" `${pkg.name}@${pkg.version}`"
115120 class =" px-4 py-3"
116121 :class =" getDepthStyle(pkg.depth).bg"
@@ -179,10 +184,10 @@ function getDepthStyle(depth: string | undefined) {
179184 </ul >
180185
181186 <button
182- v-if =" vulnTree!.vulnerablePackages.length > 5 && !showAllPackages "
187+ v-if =" hasMorePackages "
183188 type =" button"
184189 class =" w-full px-4 py-2 text-xs font-mono text-fg-muted hover:text-fg border-t border-border transition-colors duration-200"
185- @click =" showAllPackages = true "
190+ @click =" expandPackages "
186191 >
187192 {{
188193 $t('package.vulnerabilities.show_all_packages', {
0 commit comments