-
Notifications
You must be signed in to change notification settings - Fork 18
fix: hide onboarding wizard when tracker state is unavailable #1906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a0b373f
69e372d
3307e4b
7dd4ecf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,3 +37,9 @@ cp usr/local/unraid-api/.env.production usr/local/unraid-api/.env | |
| ( cd usr/local/bin ; ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm ) | ||
| ( cd usr/local/bin ; rm -rf npx ) | ||
| ( cd usr/local/bin ; ln -sf ../lib/node_modules/npm/bin/npx-cli.js npx ) | ||
| ( cd usr/local/bin ; rm -rf corepack ) | ||
| ( cd usr/local/bin ; ln -sf ../lib/node_modules/corepack/dist/corepack.js corepack ) | ||
| ( cd usr/local/bin ; rm -rf npm ) | ||
| ( cd usr/local/bin ; ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm ) | ||
| ( cd usr/local/bin ; rm -rf npx ) | ||
| ( cd usr/local/bin ; ln -sf ../lib/node_modules/npm/bin/npx-cli.js npx ) | ||
|
Comment on lines
+40
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="plugin/source/dynamix.unraid.net/install/doinst.sh"
echo "Pattern occurrences:"
rg -n '^\( cd usr/local/bin ; (rm -rf|ln -sf) ' "$FILE"
echo
python - <<'PY'
from pathlib import Path
p = Path("plugin/source/dynamix.unraid.net/install/doinst.sh")
lines = p.read_text().splitlines()
b1 = lines[27:33] # Line 28-33
b2 = lines[33:39] # Line 34-39
b3 = lines[39:45] # Line 40-45
print("28-33 equals 34-39:", b1 == b2)
print("34-39 equals 40-45:", b2 == b3)
PYRepository: unraid/api Length of output: 1193 Remove duplicate relink blocks and use direct paths to prevent unsafe Lines 40–45 duplicate the exact same relink commands from lines 28–39 and 34–39. Additionally, the Suggested fix-( cd usr/local/bin ; rm -rf corepack )
-( cd usr/local/bin ; ln -sf ../lib/node_modules/corepack/dist/corepack.js corepack )
-( cd usr/local/bin ; rm -rf npm )
-( cd usr/local/bin ; ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm )
-( cd usr/local/bin ; rm -rf npx )
-( cd usr/local/bin ; ln -sf ../lib/node_modules/npm/bin/npx-cli.js npx )
-( cd usr/local/bin ; rm -rf corepack )
-( cd usr/local/bin ; ln -sf ../lib/node_modules/corepack/dist/corepack.js corepack )
-( cd usr/local/bin ; rm -rf npm )
-( cd usr/local/bin ; ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm )
-( cd usr/local/bin ; rm -rf npx )
-( cd usr/local/bin ; ln -sf ../lib/node_modules/npm/bin/npx-cli.js npx )
-( cd usr/local/bin ; rm -rf corepack )
-( cd usr/local/bin ; ln -sf ../lib/node_modules/corepack/dist/corepack.js corepack )
-( cd usr/local/bin ; rm -rf npm )
-( cd usr/local/bin ; ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm )
-( cd usr/local/bin ; rm -rf npx )
-( cd usr/local/bin ; ln -sf ../lib/node_modules/npm/bin/npx-cli.js npx )
+rm -rf usr/local/bin/corepack
+ln -sf ../lib/node_modules/corepack/dist/corepack.js usr/local/bin/corepack
+rm -rf usr/local/bin/npm
+ln -sf ../lib/node_modules/npm/bin/npm-cli.js usr/local/bin/npm
+rm -rf usr/local/bin/npx
+ln -sf ../lib/node_modules/npm/bin/npx-cli.js usr/local/bin/npx🧰 Tools🪛 Shellcheck (0.11.0)[warning] 40-40: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164) [warning] 41-41: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164) [warning] 42-42: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164) [warning] 43-43: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164) [warning] 44-44: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164) [warning] 45-45: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164) 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import { ref } from 'vue'; | ||
| import { createPinia, setActivePinia } from 'pinia'; | ||
|
|
||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { useOnboardingStore } from '~/components/Onboarding/store/onboardingStatus'; | ||
| import { useServerStore } from '~/store/server'; | ||
|
|
||
| type OnboardingQueryResult = { | ||
| customization?: { | ||
| onboarding?: { | ||
| status?: 'INCOMPLETE' | 'UPGRADE' | 'DOWNGRADE' | 'COMPLETED'; | ||
| isPartnerBuild?: boolean; | ||
| completed?: boolean; | ||
| completedAtVersion?: string | null; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| const { state, refetchMock, useQueryMock } = vi.hoisted(() => ({ | ||
| state: { | ||
| onboardingResult: null as unknown as ReturnType<typeof ref<OnboardingQueryResult | null>>, | ||
| onboardingLoading: null as unknown as ReturnType<typeof ref<boolean>>, | ||
| onboardingError: null as unknown as ReturnType<typeof ref<unknown>>, | ||
| osVersionRef: null as unknown as ReturnType<typeof ref<string>>, | ||
| }, | ||
| refetchMock: vi.fn(), | ||
| useQueryMock: vi.fn(), | ||
| })); | ||
|
|
||
| const createOnboardingResult = (): OnboardingQueryResult => ({ | ||
| customization: { | ||
| onboarding: { | ||
| status: 'INCOMPLETE', | ||
| isPartnerBuild: false, | ||
| completed: false, | ||
| completedAtVersion: null, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| describe('onboardingStatus store', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| setActivePinia(createPinia()); | ||
|
|
||
| state.onboardingResult = ref<OnboardingQueryResult | null>(createOnboardingResult()); | ||
| state.onboardingLoading = ref(false); | ||
| state.onboardingError = ref(null); | ||
| state.osVersionRef = ref('7.3.0'); | ||
| refetchMock.mockResolvedValue(undefined); | ||
|
|
||
| useQueryMock.mockReturnValue({ | ||
| result: state.onboardingResult, | ||
| loading: state.onboardingLoading, | ||
| error: state.onboardingError, | ||
| refetch: refetchMock, | ||
| }); | ||
|
|
||
| vi.mocked(useServerStore).mockReturnValue({ | ||
| osVersion: state.osVersionRef, | ||
| } as unknown as ReturnType<typeof useServerStore>); | ||
| }); | ||
|
|
||
| it('blocks onboarding modal while the onboarding query is still loading', () => { | ||
| state.onboardingResult.value = null; | ||
| state.onboardingLoading.value = true; | ||
|
|
||
| const store = useOnboardingStore(); | ||
|
|
||
| expect(store.hasOnboardingState).toBe(false); | ||
| expect(store.canDisplayOnboardingModal).toBe(false); | ||
| expect(store.shouldShowOnboarding).toBe(false); | ||
| }); | ||
|
|
||
| it('blocks onboarding modal when the onboarding query errors', () => { | ||
| state.onboardingResult.value = null; | ||
| state.onboardingError.value = new Error('Network error'); | ||
|
|
||
| const store = useOnboardingStore(); | ||
|
|
||
| expect(store.hasOnboardingState).toBe(false); | ||
| expect(store.hasOnboardingQueryError).toBe(true); | ||
| expect(store.canDisplayOnboardingModal).toBe(false); | ||
| expect(store.shouldShowOnboarding).toBe(false); | ||
| }); | ||
|
|
||
| it('allows onboarding modal when the onboarding query succeeds', () => { | ||
| const store = useOnboardingStore(); | ||
|
|
||
| expect(store.hasOnboardingQueryError).toBe(false); | ||
| expect(store.hasOnboardingState).toBe(true); | ||
| expect(store.canDisplayOnboardingModal).toBe(true); | ||
| expect(store.shouldShowOnboarding).toBe(true); | ||
| }); | ||
|
|
||
| it('keeps onboarding modal display enabled during refetch when onboarding data already exists', () => { | ||
| state.onboardingLoading.value = true; | ||
|
|
||
| const store = useOnboardingStore(); | ||
|
|
||
| expect(store.hasOnboardingState).toBe(true); | ||
| expect(store.canDisplayOnboardingModal).toBe(true); | ||
| expect(store.shouldShowOnboarding).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| vi.mock('@vue/apollo-composable', () => ({ | ||
| useQuery: () => useQueryMock(), | ||
| })); | ||
|
|
||
| vi.mock('~/store/server', () => ({ | ||
| useServerStore: vi.fn(), | ||
| })); |
Uh oh!
There was an error while loading. Please reload this page.