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>
| 
		 Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB  | 
| 
		 Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB  | 
| 
		 Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB  | 
| 
		 Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB  | 
| 
		 Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB  | 
| 
		 Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB  | 
| 
		 Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB  | 
| 
		 Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB  | 
| 
		 Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB  | 
| 
		 Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB  | 
| 
		 Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB  | 
| 
		 Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 67 KiB  | 
| 
		 Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB  | 
| 
		 Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB  | 
| 
		 Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB  | 
@ -1,7 +1,7 @@
 | 
			
		||||
import type { StatusBarItemType } from '@src/components/StatusBar/statusBarTypes'
 | 
			
		||||
import type { Location } from 'react-router-dom'
 | 
			
		||||
import { PATHS } from '@src/lib/paths'
 | 
			
		||||
import { APP_VERSION } from '@src/routes/utils'
 | 
			
		||||
import { APP_VERSION, getReleaseUrl } from '@src/routes/utils'
 | 
			
		||||
import {
 | 
			
		||||
  BillingRemaining,
 | 
			
		||||
  BillingRemainingMode,
 | 
			
		||||
@ -28,7 +28,7 @@ export const defaultGlobalStatusBarItems = ({
 | 
			
		||||
        id: 'version',
 | 
			
		||||
        element: 'externalLink',
 | 
			
		||||
        label: `v${APP_VERSION}`,
 | 
			
		||||
        href: `https://github.com/KittyCAD/modeling-app/releases/tag/v${APP_VERSION}`,
 | 
			
		||||
        href: getReleaseUrl(),
 | 
			
		||||
        toolTip: {
 | 
			
		||||
          children: 'View the release notes on GitHub',
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								src/routes/utils.test.ts
									
									
									
									
									
										Normal 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()
 | 
			
		||||
    })
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
@ -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 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) {
 | 
			
		||||
  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}`
 | 
			
		||||
 | 
			
		||||