Point staging version link to corresponding commit on GitHub (#7529)

* Add the 'Download the app' button back on web
Fixes #7527

* Fix staging release link in desktop app
Fixes #7513

* Update snapshots

* Update snapshots

* Update snapshots

* Add ref parsing logic and unit test

* Oops

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Pierre Jacquier
2025-06-19 11:30:28 -04:00
committed by GitHub
parent 23a01e86e6
commit d510e58ebc
18 changed files with 28 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

View File

@ -1,7 +1,7 @@
import type { StatusBarItemType } from '@src/components/StatusBar/statusBarTypes' import type { StatusBarItemType } from '@src/components/StatusBar/statusBarTypes'
import type { Location } from 'react-router-dom' import type { Location } from 'react-router-dom'
import { PATHS } from '@src/lib/paths' import { PATHS } from '@src/lib/paths'
import { APP_VERSION } from '@src/routes/utils' import { APP_VERSION, getReleaseUrl } from '@src/routes/utils'
import { import {
BillingRemaining, BillingRemaining,
BillingRemainingMode, BillingRemainingMode,
@ -28,7 +28,7 @@ export const defaultGlobalStatusBarItems = ({
id: 'version', id: 'version',
element: 'externalLink', element: 'externalLink',
label: `v${APP_VERSION}`, label: `v${APP_VERSION}`,
href: `https://github.com/KittyCAD/modeling-app/releases/tag/v${APP_VERSION}`, href: getReleaseUrl(),
toolTip: { toolTip: {
children: 'View the release notes on GitHub', children: 'View the release notes on GitHub',
}, },

15
src/routes/utils.test.ts Normal file
View File

@ -0,0 +1,15 @@
import { getRefFromVersion } from '@src/routes/utils'
describe('Routes utility functions', () => {
describe('getRefFromVersion', () => {
it('returns the short commit sha on staging version', () => {
expect(getRefFromVersion('25.6.17-main.fe581ff')).toBe('fe581ff')
})
it('returns undefined on non-staging version', () => {
expect(getRefFromVersion('1.0.5')).toBeUndefined()
})
it('returns undefined on debug version', () => {
expect(getRefFromVersion('main')).toBeUndefined()
})
})
})

View File

@ -24,9 +24,19 @@ export const IS_STAGING = PACKAGE_NAME.indexOf('-staging') > -1
export const IS_STAGING_OR_DEBUG = IS_STAGING || APP_VERSION === '0.0.0' export const IS_STAGING_OR_DEBUG = IS_STAGING || APP_VERSION === '0.0.0'
export function getRefFromVersion(version: string) {
const hash = version.split('.').pop()
if (hash && hash.length === 7) {
return hash
}
return undefined
}
export function getReleaseUrl(version: string = APP_VERSION) { export function getReleaseUrl(version: string = APP_VERSION) {
if (IS_STAGING_OR_DEBUG || version === 'main') { if (IS_STAGING_OR_DEBUG || version === 'main') {
return 'https://github.com/KittyCAD/modeling-app/commits/main' const ref = getRefFromVersion(version) ?? 'main'
return `https://github.com/KittyCAD/modeling-app/commit/${ref}`
} }
return `https://github.com/KittyCAD/modeling-app/releases/tag/v${version}` return `https://github.com/KittyCAD/modeling-app/releases/tag/v${version}`