mirror of
https://github.com/unraid/api.git
synced 2026-01-10 18:50:11 -06:00
refactor: updateOs callback button action
This commit is contained in:
@@ -117,9 +117,9 @@ const disableCallbackButton = computed(() => !acknowledgeBackup.value || flashBa
|
||||
|
||||
watchEffect(() => {
|
||||
if (available.value) {
|
||||
updateButton.value = updateOsActionsStore.initUpdateOsCallback();
|
||||
updateButton.value = updateOsActionsStore.updateCallbackButton();
|
||||
} else {
|
||||
updateButton.value = updateOsActionsStore.initUpdateOsCallback();
|
||||
updateButton.value = updateOsActionsStore.updateCallbackButton();
|
||||
}
|
||||
if (flashBackupBasicStatus.value === 'complete') {
|
||||
acknowledgeBackup.value = true; // auto check the box
|
||||
|
||||
@@ -47,9 +47,9 @@ const updateButton = ref<UserProfileLink | undefined>();
|
||||
|
||||
watchEffect(() => {
|
||||
if (availableWithRenewal.value) {
|
||||
updateButton.value = updateOsActionsStore.initUpdateOsCallback();
|
||||
updateButton.value = updateOsActionsStore.updateCallbackButton();
|
||||
} else {
|
||||
updateButton.value = updateOsActionsStore.initUpdateOsCallback();
|
||||
updateButton.value = updateOsActionsStore.updateCallbackButton();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -4,9 +4,9 @@ import { defineStore, createPinia, setActivePinia } from 'pinia';
|
||||
import useInstallPlugin from '~/composables/installPlugin';
|
||||
import { getOsReleaseBySha256 } from '~/composables/services/keyServer';
|
||||
|
||||
import { ACCOUNT_CALLBACK, WEBGUI_TOOLS_UPDATE } from '~/helpers/urls';
|
||||
import { WEBGUI_TOOLS_UPDATE } from '~/helpers/urls';
|
||||
|
||||
import { useCallbackStore } from '~/store/callbackActions';
|
||||
import { useAccountStore } from '~/store/account';
|
||||
// import { useErrorsStore } from '~/store/errors';
|
||||
import { useServerStore } from '~/store/server';
|
||||
import { useUpdateOsStore } from '~/store/updateOs';
|
||||
@@ -37,7 +37,7 @@ export interface Release {
|
||||
}
|
||||
|
||||
export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
|
||||
const callbackStore = useCallbackStore();
|
||||
const accountStore = useAccountStore();
|
||||
// const errorsStore = useErrorsStore();
|
||||
const serverStore = useServerStore();
|
||||
// in this instance we don't need to pass a payload because we're already in the store that would be passed to it
|
||||
@@ -49,12 +49,10 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
|
||||
const updateAction = ref<ExternalUpdateOsAction | undefined>();
|
||||
|
||||
const guid = computed(() => serverStore.guid);
|
||||
const inIframe = computed(() => serverStore.inIframe);
|
||||
const keyfile = computed(() => serverStore.keyfile);
|
||||
const osVersion = computed(() => serverStore.osVersion);
|
||||
const osVersionBranch = computed(() => serverStore.osVersionBranch);
|
||||
const regUpdatesExpired = computed(() => serverStore.regUpdatesExpired);
|
||||
const serverAccountPayload = computed(() => serverStore.serverAccountPayload);
|
||||
|
||||
const updateOsAvailable = computed(() => updateOsStore.available);
|
||||
/** used when coming back from callback, this will be the release to install */
|
||||
@@ -106,43 +104,23 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
|
||||
});
|
||||
|
||||
// Actions
|
||||
const initUpdateOsCallback = (): UserProfileLink => {
|
||||
|
||||
|
||||
const updateCallbackButton = (): UserProfileLink => {
|
||||
return {
|
||||
click: () => {
|
||||
callbackStore.send(
|
||||
ACCOUNT_CALLBACK.toString(),
|
||||
[{
|
||||
server: {
|
||||
...serverAccountPayload.value,
|
||||
},
|
||||
type: 'updateOs',
|
||||
}],
|
||||
inIframe.value ? 'newTab' : undefined,
|
||||
);
|
||||
accountStore.updateOs();
|
||||
},
|
||||
disabled: rebootType.value !== '',
|
||||
external: true,
|
||||
icon: updateOsAvailable.value ? BellAlertIcon : ArrowPathIcon,
|
||||
name: 'updateOs',
|
||||
text: updateOsAvailable.value ? 'Unraid OS {0} Update Available' : 'Check for OS Updates',
|
||||
text: updateOsAvailable.value ? 'Unraid OS {0} Update Available' : 'View Available Updates',
|
||||
textParams: [updateOsAvailable.value ?? ''],
|
||||
title: rebootType.value !== '' ? rebootTypeText.value : '',
|
||||
};
|
||||
};
|
||||
|
||||
const executeUpdateOsCallback = async (autoRedirectReplace?: boolean) => {
|
||||
await callbackStore.send(
|
||||
ACCOUNT_CALLBACK.toString(),
|
||||
[{
|
||||
server: {
|
||||
...serverAccountPayload.value,
|
||||
},
|
||||
type: 'updateOs',
|
||||
}],
|
||||
inIframe.value ? 'newTab' : (autoRedirectReplace ? 'replace' : undefined),
|
||||
);
|
||||
};
|
||||
|
||||
const setUpdateOsAction = (payload: ExternalUpdateOsAction | undefined) => (updateAction.value = payload);
|
||||
/**
|
||||
* @description When receiving the callback the Account update page we'll use the provided sha256 of the release to get the release from the keyserver
|
||||
@@ -238,8 +216,7 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
|
||||
actOnUpdateOsAction,
|
||||
confirmUpdateOs,
|
||||
installOsUpdate,
|
||||
initUpdateOsCallback,
|
||||
executeUpdateOsCallback,
|
||||
updateCallbackButton,
|
||||
rebootServer,
|
||||
setStatus,
|
||||
setUpdateOsAction,
|
||||
|
||||
Reference in New Issue
Block a user