feat: downgradeOs callback for non stable osCurrentBranch

This commit is contained in:
Zack Spear
2024-05-22 17:36:16 -07:00
committed by Zack Spear
parent a62f60a436
commit e9ff33d263
4 changed files with 25 additions and 4 deletions

View File

@@ -39,7 +39,7 @@ const props = withDefaults(defineProps<Props>(), {
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"
/>
<UpdateOsDowngrade

View File

@@ -24,6 +24,7 @@ import BrandLoadingWhite from '~/components/Brand/LoadingWhite.vue';
export interface Props {
downgradeNotAvailable?: boolean;
restoreVersion?: string | undefined;
showExternalDowngrade?: boolean;
t: ComposerTranslation;
title?: string;
subtitle?: string;
@@ -31,6 +32,7 @@ export interface Props {
const props = withDefaults(defineProps<Props>(), {
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'),

View File

@@ -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,

View File

@@ -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;