Skip to content

Commit 32bf8bb

Browse files
43081jautofix-ci[bot]ghostdevvalexdln
authored
feat: add timeline tab to package page (#2245)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Willow (GHOST) <git@willow.sh> Co-authored-by: Alex Savelyev <91429106+alexdln@users.noreply.github.com>
1 parent 609a391 commit 32bf8bb

File tree

11 files changed

+1112
-2
lines changed

11 files changed

+1112
-2
lines changed

app/components/AppFooter.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ const closeModal = () => modalRef.value?.close?.()
120120
<kbd class="kbd">f</kbd>
121121
<span>{{ $t('shortcuts.open_diff') }}</span>
122122
</li>
123+
<li class="flex gap-2 items-center">
124+
<kbd class="kbd">t</kbd>
125+
<span>{{ $t('shortcuts.open_timeline') }}</span>
126+
</li>
123127
<li class="flex gap-2 items-center">
124128
<kbd class="kbd">c</kbd>
125129
<span>{{ $t('shortcuts.compare_from_package') }}</span>

app/components/Package/Header.vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const props = defineProps<{
1010
latestVersion?: SlimVersion | null
1111
provenanceData?: ProvenanceDetails | null
1212
provenanceStatus?: string | null
13-
page: 'main' | 'docs' | 'code' | 'diff'
13+
page: 'main' | 'docs' | 'code' | 'diff' | 'timeline'
1414
versionUrlPattern: string
1515
}>()
1616
@@ -162,12 +162,26 @@ const diffLink = computed((): RouteLocationRaw | null => {
162162
return diffRoute(props.pkg.name, props.resolvedVersion, props.latestVersion.version)
163163
})
164164
165+
const timelineLink = computed((): RouteLocationRaw | null => {
166+
if (props.pkg == null || props.resolvedVersion == null) return null
167+
const split = props.pkg.name.split('/')
168+
return {
169+
name: 'timeline',
170+
params: {
171+
org: split.length === 2 ? split[0] : undefined,
172+
packageName: split.length === 2 ? split[1]! : split[0]!,
173+
version: props.resolvedVersion,
174+
},
175+
}
176+
})
177+
165178
useShortcuts({
166179
'.': () => codeLink.value,
167180
'm': () => mainLink.value,
168181
'd': () => docsLink.value,
169182
'c': () => props.pkg && { name: 'compare' as const, query: { packages: props.pkg.name } },
170183
'f': () => diffLink.value,
184+
't': () => timelineLink.value,
171185
})
172186
</script>
173187

@@ -330,6 +344,15 @@ useShortcuts({
330344
>
331345
{{ $t('compare.compare_versions') }}
332346
</LinkBase>
347+
<LinkBase
348+
v-if="timelineLink"
349+
:to="timelineLink"
350+
aria-keyshortcuts="t"
351+
class="decoration-none border-b-2 p-1 hover:border-accent/50 focus-visible:[outline-offset:-2px]!"
352+
:class="page === 'timeline' ? 'border-accent text-accent!' : 'border-transparent'"
353+
>
354+
{{ $t('package.links.timeline') }}
355+
</LinkBase>
333356
</nav>
334357
</div>
335358
</div>

app/composables/npm/usePackage.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,20 @@ export function transformPackument(
8686
const trustLevel = getTrustLevel(version)
8787
const hasProvenance = trustLevel !== 'none'
8888

89+
// Normalize license: some versions use { type: "MIT" } instead of "MIT"
90+
let versionLicense = version.license
91+
if (versionLicense && typeof versionLicense === 'object' && 'type' in versionLicense) {
92+
versionLicense = (versionLicense as { type: string }).type
93+
}
94+
8995
filteredVersions[v] = {
9096
hasProvenance,
9197
trustLevel,
9298
version: version.version,
9399
deprecated: version.deprecated,
94100
tags: version.tags as string[],
101+
license: typeof versionLicense === 'string' ? versionLicense : undefined,
102+
type: typeof version.type === 'string' ? version.type : undefined,
95103
}
96104
}
97105
}

0 commit comments

Comments
 (0)