-
Notifications
You must be signed in to change notification settings - Fork 22
[codex] Embed internal OS update checks on Tools page #2020
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -15,18 +15,19 @@ else | |
| echo "Third party plugins found - PLEASE CHECK YOUR UNRAID NOTIFICATIONS AND WAIT FOR THE MESSAGE THAT IT IS SAFE TO REBOOT!" | ||
| fi | ||
| */ | ||
| import { computed, onBeforeMount } from 'vue'; | ||
| import { computed, onBeforeMount, onMounted } from 'vue'; | ||
| import { useI18n } from 'vue-i18n'; | ||
| import { storeToRefs } from 'pinia'; | ||
|
|
||
| import { ArrowTopRightOnSquareIcon } from '@heroicons/vue/24/solid'; | ||
| import { BrandButton, PageContainer } from '@unraid/ui'; | ||
| import { PageContainer } from '@unraid/ui'; | ||
| import { WEBGUI_TOOLS_UPDATE } from '~/helpers/urls'; | ||
|
|
||
| import UpdateOsChangelogModal from '~/components/UpdateOs/ChangelogModal.vue'; | ||
| import UpdateOsCheckUpdateResponseModal from '~/components/UpdateOs/CheckUpdateResponseModal.vue'; | ||
| import UpdateOsStatus from '~/components/UpdateOs/Status.vue'; | ||
| import UpdateOsThirdPartyDrivers from '~/components/UpdateOs/ThirdPartyDrivers.vue'; | ||
| import { useAccountStore } from '~/store/account'; | ||
| import { useServerStore } from '~/store/server'; | ||
| import { useUpdateOsStore } from '~/store/updateOs'; | ||
|
|
||
| const { t } = useI18n(); | ||
|
|
||
|
|
@@ -37,9 +38,14 @@ const props = withDefaults(defineProps<Props>(), { | |
| rebootVersion: '', | ||
| }); | ||
|
|
||
| const accountStore = useAccountStore(); | ||
| const serverStore = useServerStore(); | ||
| const updateOsStore = useUpdateOsStore(); | ||
| const { rebootType } = storeToRefs(serverStore); | ||
| const updateOsModalVisible = computed(() => updateOsStore.updateOsModalVisible); | ||
|
|
||
| const isToolsUpdatePage = computed( | ||
| () => typeof window !== 'undefined' && window.location.pathname === WEBGUI_TOOLS_UPDATE | ||
| ); | ||
|
|
||
| const subtitle = computed(() => { | ||
| if (rebootType.value === 'downgrade') { | ||
|
|
@@ -48,48 +54,43 @@ const subtitle = computed(() => { | |
| return ''; | ||
| }); | ||
|
|
||
| // Show a prompt to continue in the Account app when no reboot is pending. | ||
| const showRedirectPrompt = computed( | ||
| () => | ||
| typeof window !== 'undefined' && | ||
| window.location.pathname === WEBGUI_TOOLS_UPDATE && | ||
| rebootType.value === '' | ||
| ); | ||
|
|
||
| const openAccountUpdate = () => { | ||
| accountStore.updateOs(true); | ||
| }; | ||
|
|
||
| onBeforeMount(() => { | ||
| serverStore.setRebootVersion(props.rebootVersion); | ||
| }); | ||
|
|
||
| onMounted(() => { | ||
| if ( | ||
| typeof window === 'undefined' || | ||
| window.location.pathname !== WEBGUI_TOOLS_UPDATE || | ||
| rebootType.value !== '' | ||
| ) { | ||
| return; | ||
| } | ||
|
|
||
| if (updateOsStore.available || updateOsStore.availableWithRenewal) { | ||
| updateOsStore.setModalOpen(true); | ||
| return; | ||
| } | ||
|
|
||
| void updateOsStore.localCheckForUpdate().catch((error: unknown) => { | ||
| console.error(error); | ||
| }); | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <PageContainer> | ||
| <div | ||
| v-if="showRedirectPrompt" | ||
| class="mx-auto flex max-w-[720px] flex-col items-center gap-4 py-8 text-center" | ||
| > | ||
| <h1 class="text-2xl font-semibold">{{ t('updateOs.updateUnraidOs') }}</h1> | ||
| <p class="text-base leading-relaxed opacity-75"> | ||
| {{ t('updateOs.update.receiveTheLatestAndGreatestFor') }} | ||
| </p> | ||
| <BrandButton | ||
| data-testid="update-os-account-button" | ||
| :icon-right="ArrowTopRightOnSquareIcon" | ||
| @click="openAccountUpdate" | ||
| > | ||
| {{ t('updateOs.update.viewAvailableUpdates') }} | ||
| </BrandButton> | ||
| </div> | ||
| <div v-else> | ||
| <UpdateOsStatus | ||
| :show-update-check="true" | ||
| :title="t('updateOs.updateUnraidOs')" | ||
| :subtitle="subtitle" | ||
| /> | ||
| <UpdateOsThirdPartyDrivers v-if="rebootType === 'thirdPartyDriversDownloading'" /> | ||
| </div> | ||
| <UpdateOsStatus | ||
| :show-update-check="true" | ||
| :title="t('updateOs.updateUnraidOs')" | ||
| :subtitle="subtitle" | ||
| /> | ||
| <UpdateOsCheckUpdateResponseModal | ||
| v-if="isToolsUpdatePage && rebootType === ''" | ||
| :open="updateOsModalVisible" | ||
| embedded | ||
| /> | ||
| <UpdateOsChangelogModal v-if="isToolsUpdatePage" /> | ||
| <UpdateOsThirdPartyDrivers v-if="rebootType === 'thirdPartyDriversDownloading'" /> | ||
|
Comment on lines
+83
to
+94
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
# Confirm UpdateOsStatus declares and uses a showUpdateCheck prop
fd -i 'Status.vue' -p 'UpdateOs'
rg -nP -C3 '(showUpdateCheck|show-update-check)' -g '*Status.vue'
# Inspect the defineProps block for the component
ast-grep --pattern 'defineProps<$_>()'Repository: unraid/api Length of output: 150 🏁 Script executed: #!/bin/bash
set -euo pipefail
# 1) Find where UpdateOsStatus is defined/implemented
rg -n "UpdateOsStatus" web/src/components/UpdateOs.standalone.vue web/src/components -S
# 2) Locate any Status component that corresponds to UpdateOsStatus
fd -e vue -a -t f . web/src/components -S | head -n 200
# 3) Search for the prop name variants across the repo
rg -n "(showUpdateCheck|show-update-check)" web/src/components -S
rg -n "(showUpdateCheck|show-update-check)" web/src -S
# 4) Find the component file that likely declares showUpdateCheck
# If UpdateOsStatus is imported from another file, inspect that.
imports=$(rg -n "import\s+.*UpdateOsStatus.*from" web/src/components/UpdateOs.standalone.vue -S || true)
echo "$imports"
# 5) If we can locate the file, inspect defineProps/props usage for showUpdateCheck
# (we'll re-run with the discovered file if needed)Repository: unraid/api Length of output: 715 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="web/src/components/UpdateOs/Status.vue"
if [ ! -f "$FILE" ]; then
echo "Missing file: $FILE"
exit 1
fi
echo "== wc -l =="
wc -l "$FILE"
echo "== occurrences of showUpdateCheck/show-update-check =="
rg -n "(showUpdateCheck|show-update-check)" "$FILE" -S || true
echo "== defineProps/props block context =="
# Show likely prop declaration area (covers both defineProps and classic props:)
rg -n -C5 "(defineProps|props\s*:)" "$FILE" -S || true
echo "== template usage around any showUpdateCheck reference =="
# If occurrences exist, show a bit more context for each match
rg -n -C8 "(showUpdateCheck|show-update-check)" "$FILE" -S || trueRepository: unraid/api Length of output: 566 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="web/src/components/UpdateOs/Status.vue"
rg -n "(\$attrs|useAttrs|attrs\s*\.|attrs\s*\[|inheritAttrs)" "$FILE" -S || true
rg -n "show-update-check|showUpdateCheck" "$FILE" -S || trueRepository: unraid/api Length of output: 36 🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n "(showUpdateCheck|show-update-check)" web/src/components/UpdateOs -S || true
rg -n "(showUpdateCheck|show-update-check)" web/src -S || trueRepository: unraid/api Length of output: 132 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="web/src/components/UpdateOs/Status.vue"
echo "== occurrences: showRefreshButton =="
rg -n "showRefreshButton" "$FILE" -S || true
echo "== occurrences: updateCheck / update-check =="
rg -n "(updateCheck|update-check|checkFor|check for|updates)" "$FILE" -S || true
echo "== template region around any refresh-related UI =="
rg -n "refresh" "$FILE" -S || true
# show a small window around the first few refresh/update occurrences (if any)
FIRST=$(rg -n "(refresh|update|updates|check)" "$FILE" -S | head -n 1 | cut -d: -f1 || true)
if [ -n "${FIRST:-}" ]; then
START=$((FIRST-15))
END=$((FIRST+60))
[ $START -lt 1 ] && START=1
echo "== showing lines $START-$END around first match line $FIRST =="
sed -n "${START},${END}p" "$FILE" | nl -ba -w2 -s':'
fiRepository: unraid/api Length of output: 771 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="web/src/components/UpdateOs/Status.vue"
echo "=== Props area (lines 1-60) ==="
sed -n '1,80p' "$FILE"
echo
echo "=== showRefreshButton computed area (lines 70-130) ==="
sed -n '70,140p' "$FILE"
echo
echo "=== Template refresh/update UI (lines 200-270) ==="
sed -n '200,280p' "$FILE"Repository: unraid/api Length of output: 7665
<UpdateOsStatus
:show-update-check="true"
:title="t('updateOs.updateUnraidOs')"
:subtitle="subtitle"
/>
🤖 Prompt for AI Agents |
||
| </PageContainer> | ||
| </template> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid asserting a stub-only prop that the real component doesn’t define.
This assertion can pass even if production behavior is wrong, because it only verifies data passed into a test stub, not
UpdateOsStatusruntime behavior.Suggested change
As per coding guidelines, “Test what the code does, not implementation details like exact error message wording.”
📝 Committable suggestion
🤖 Prompt for AI Agents