mirror of
https://github.com/unraid/api.git
synced 2026-02-23 09:39:40 -06:00
feat: downgradeOs callback
This commit is contained in:
@@ -62,6 +62,7 @@ const {
|
||||
} = storeToRefs(serverStore);
|
||||
const {
|
||||
status: updateOsStatus,
|
||||
callbackTypeDowngrade,
|
||||
callbackUpdateRelease,
|
||||
} = storeToRefs(updateOsActionStore);
|
||||
/**
|
||||
@@ -78,7 +79,7 @@ const isSettingsPage = ref<boolean>(document.location.pathname === '/Settings/Ma
|
||||
|
||||
const heading = computed(() => {
|
||||
if (updateOsStatus.value === 'confirming') {
|
||||
return props.t('Update Unraid OS confirmation required');
|
||||
return callbackTypeDowngrade.value ? props.t('Downgrade Unraid OS confirmation required') : props.t('Update Unraid OS confirmation required');
|
||||
}
|
||||
switch (callbackStatus.value) {
|
||||
case 'error':
|
||||
@@ -91,7 +92,7 @@ const heading = computed(() => {
|
||||
});
|
||||
const subheading = computed(() => {
|
||||
if (updateOsStatus.value === 'confirming') {
|
||||
return props.t('Please confirm the update details below');
|
||||
return callbackTypeDowngrade.value ? props.t('Please confirm the downgrade details below') : props.t('Please confirm the update details below');
|
||||
}
|
||||
if (callbackStatus.value === 'error') {
|
||||
return props.t('Something went wrong'); /** @todo show actual error messages */
|
||||
@@ -317,7 +318,7 @@ const showUpdateEligibility = computed(() => {
|
||||
</p>
|
||||
|
||||
<p class="text-14px italic opacity-75">
|
||||
{{ t('This update will require a reboot') }}
|
||||
{{ callbackTypeDowngrade ? t('This downgrade will require a reboot') : t('This update will require a reboot') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -367,7 +368,7 @@ const showUpdateEligibility = computed(() => {
|
||||
/>
|
||||
<BrandButton
|
||||
:icon="CheckIcon"
|
||||
:text="t('Confirm and start update')"
|
||||
:text="callbackTypeDowngrade ? t('Confirm and start downgrade') : t('Confirm and start update')"
|
||||
@click="confirmUpdateOs"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -23,6 +23,7 @@ export type Redeem = 'redeem';
|
||||
export type Renew = 'renew';
|
||||
export type Upgrade = 'upgrade';
|
||||
export type UpdateOs = 'updateOs';
|
||||
export type DowngradeOs = 'downgradeOs';
|
||||
export type Manage = 'manage';
|
||||
export type MyKeys = 'myKeys';
|
||||
export type LinkKey = 'linkKey';
|
||||
@@ -119,7 +120,7 @@ export interface ExternalKeyActions {
|
||||
}
|
||||
|
||||
export interface ExternalUpdateOsAction {
|
||||
type: UpdateOs;
|
||||
type: DowngradeOs | UpdateOs;
|
||||
sha256: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,9 +86,9 @@ export const useCallbackActionsStore = defineStore('callbackActions', () => {
|
||||
await accountStore.setQueueConnectSignOut(true);
|
||||
}
|
||||
|
||||
if (action.type === 'updateOs') {
|
||||
if (action.type === 'updateOs' || action.type === 'downgradeOs') {
|
||||
updateOsActionsStore.setUpdateOsAction(action as ExternalUpdateOsAction);
|
||||
await updateOsActionsStore.actOnUpdateOsAction();
|
||||
await updateOsActionsStore.actOnUpdateOsAction(action.type === 'downgradeOs');
|
||||
|
||||
if (array.length === 1) { // only 1 action, skip refresh server state
|
||||
console.debug('[redirectToCallbackType] updateOs done');
|
||||
|
||||
@@ -57,6 +57,7 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
|
||||
const updateOsAvailable = computed(() => updateOsStore.available);
|
||||
/** used when coming back from callback, this will be the release to install */
|
||||
const status = ref<'confirming' | 'checking' | 'ineligible' | 'failed' | 'ready' | 'success' | 'updating' | 'downgrading'>('ready');
|
||||
const callbackTypeDowngrade = ref<boolean>(false);
|
||||
const callbackUpdateRelease = ref<Release | null>(null);
|
||||
const rebootType = computed(() => serverStore.rebootType);
|
||||
const rebootTypeText = computed(() => {
|
||||
@@ -150,11 +151,14 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
|
||||
setStatus('confirming');
|
||||
};
|
||||
|
||||
const actOnUpdateOsAction = async () => {
|
||||
const actOnUpdateOsAction = async (downgrade: boolean = false) => {
|
||||
const foundRelease = await getReleaseFromKeyServer({
|
||||
keyfile: keyfile.value,
|
||||
sha256: updateAction.value?.sha256 ?? '',
|
||||
});
|
||||
if (downgrade) {
|
||||
callbackTypeDowngrade.value = true;
|
||||
}
|
||||
console.debug('[redirectToCallbackType] updateOs foundRelease', foundRelease);
|
||||
if (!foundRelease) {
|
||||
throw new Error('Release not found');
|
||||
@@ -172,7 +176,7 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
|
||||
|
||||
setStatus('updating');
|
||||
installPlugin({
|
||||
modalTitle: `${callbackUpdateRelease.value.name} Update`,
|
||||
modalTitle: callbackTypeDowngrade.value ? `${callbackUpdateRelease.value.name} Downgrade` : `${callbackUpdateRelease.value.name} Update`,
|
||||
pluginUrl: callbackUpdateRelease.value.plugin_url,
|
||||
update: false,
|
||||
});
|
||||
@@ -211,6 +215,7 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
|
||||
|
||||
return {
|
||||
// State
|
||||
callbackTypeDowngrade,
|
||||
callbackUpdateRelease,
|
||||
osVersion,
|
||||
osVersionBranch,
|
||||
|
||||
Reference in New Issue
Block a user