diff --git a/web/components/DowngradeOs.ce.vue b/web/components/DowngradeOs.ce.vue index 9e4c0cda2..e9d8692d2 100644 --- a/web/components/DowngradeOs.ce.vue +++ b/web/components/DowngradeOs.ce.vue @@ -39,7 +39,7 @@ const props = withDefaults(defineProps(), { const serverStore = useServerStore(); -const { rebootType } = storeToRefs(serverStore); +const { rebootType, osVersionBranch } = storeToRefs(serverStore); const subtitle = computed(() => { if (rebootType.value === 'update') { @@ -48,6 +48,8 @@ const subtitle = computed(() => { return ''; }); +const showExternalDowngrade = computed(() => osVersionBranch.value !== 'stable'); + onBeforeMount(() => { serverStore.setRebootVersion(props.rebootVersion); }); @@ -59,6 +61,7 @@ onBeforeMount(() => { :title="t('Downgrade Unraid OS')" :subtitle="subtitle" :downgrade-not-available="restoreVersion === '' && rebootType === ''" + :show-external-downgrade="showExternalDowngrade" :t="t" /> (), { downgradeNotAvailable: false, restoreVersion: undefined, + showExternalDowngrade: false, title: undefined, subtitle: undefined, }); @@ -68,11 +70,13 @@ const regExpOutput = computed(() => { const showRebootButton = computed(() => rebootType.value === 'downgrade' || rebootType.value === 'update'); const checkButton = computed((): ButtonProps => { - if (showRebootButton.value) { + if (showRebootButton.value || props.showExternalDowngrade) { return { btnStyle: 'outline', click: () => { - accountStore.updateOs(); + props.showExternalDowngrade + ? accountStore.downgradeOs() + : accountStore.updateOs(); }, icon: ArrowTopRightOnSquareIcon, text: props.t('More options'), diff --git a/web/store/account.ts b/web/store/account.ts index a26b40654..54cb72b50 100644 --- a/web/store/account.ts +++ b/web/store/account.ts @@ -74,6 +74,19 @@ export const useAccountStore = defineStore('account', () => { const accountActionType = computed(() => accountAction.value?.type); // Actions + const downgradeOs = async (autoRedirectReplace?: boolean) => { + await callbackStore.send( + ACCOUNT_CALLBACK.toString(), + [{ + server: { + ...serverAccountPayload.value, + }, + type: 'downgradeOs', + }], + inIframe.value ? 'newTab' : (autoRedirectReplace ? 'replace' : undefined), + ); + }; + const manage = () => { callbackStore.send( ACCOUNT_CALLBACK.toString(), @@ -303,6 +316,7 @@ export const useAccountStore = defineStore('account', () => { // Getters accountActionType, // Actions + downgradeOs, manage, myKeys, linkKey, diff --git a/web/store/callback.ts b/web/store/callback.ts index 19f3492b9..f1e5f2cf1 100644 --- a/web/store/callback.ts +++ b/web/store/callback.ts @@ -28,7 +28,7 @@ export type Manage = 'manage'; export type MyKeys = 'myKeys'; export type LinkKey = 'linkKey'; export type AccountActionTypes = Troubleshoot | SignIn | SignOut | OemSignOut | Manage | MyKeys | LinkKey; -export type AccountKeyActionTypes = Recover | Replace | TrialExtend | TrialStart | UpdateOs; +export type AccountKeyActionTypes = Recover | Replace | TrialExtend | TrialStart | UpdateOs | DowngradeOs; export type PurchaseActionTypes = Purchase | Redeem | Renew | Upgrade; export type ServerActionTypes = AccountActionTypes | AccountKeyActionTypes | PurchaseActionTypes;