refactor(web): upc check for updates callback link

This commit is contained in:
Zack Spear
2023-10-11 13:42:55 -05:00
committed by Zack Spear
parent 207ae12522
commit c387a28dbd
2 changed files with 38 additions and 37 deletions
+35 -27
View File
@@ -1,10 +1,18 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { ArrowTopRightOnSquareIcon, CogIcon } from '@heroicons/vue/24/solid';
import {
ArrowTopRightOnSquareIcon,
CogIcon,
KeyIcon,
} from '@heroicons/vue/24/solid';
import { ACCOUNT, CONNECT_DASHBOARD, WEBGUI_CONNECT_SETTINGS } from '~/helpers/urls';
import {
ACCOUNT,
CONNECT_DASHBOARD,
WEBGUI_CONNECT_SETTINGS,
WEBGUI_TOOLS_REGISTRATION,
} from '~/helpers/urls';
import { useErrorsStore } from '~/store/errors';
// import { usePromoStore } from '~/store/promo';
import { useServerStore } from '~/store/server';
import { useUpdateOsStore, useUpdateOsActionsStore } from '~/store/updateOsActions';
import type { UserProfileLink } from '~/types/userProfile';
@@ -12,19 +20,38 @@ import type { UserProfileLink } from '~/types/userProfile';
const props = defineProps<{ t: any; }>();
const errorsStore = useErrorsStore();
// const promoStore = usePromoStore();
const updateOsActionsStore = useUpdateOsActionsStore();
const { errors } = storeToRefs(errorsStore);
const { keyActions, connectPluginInstalled, registered, stateData } = storeToRefs(useServerStore());
const {
keyActions,
connectPluginInstalled,
registered,
regUpdatesExpired,
stateData,
} = storeToRefs(useServerStore());
const { available: osUpdateAvailable } = storeToRefs(useUpdateOsStore());
const { rebootType, toolsRegistrationAction } = storeToRefs(updateOsActionsStore);
const { rebootType } = storeToRefs(updateOsActionsStore);
const signInAction = computed(() => stateData.value.actions?.filter((act: { name: string; }) => act.name === 'signIn') ?? []);
const signOutAction = computed(() => stateData.value.actions?.filter((act: { name: string; }) => act.name === 'signOut') ?? []);
/**
* Filter out the renew action from the key actions so we can display it separately and link to the Tools > Registration page
*/
const filteredKeyActions = computed(() => keyActions.value?.filter(action => !['renew'].includes(action.name)));
const links = computed(():UserProfileLink[] => {
return [
...(regUpdatesExpired.value ? [{
href: WEBGUI_TOOLS_REGISTRATION.toString(),
icon: KeyIcon,
text: props.t('OS Update Eligibility Expired'),
title: props.t('Go to Tools > Registration to Learn More'),
}] : []),
// callback to account.unraid.net/server/update-os
updateOsActionsStore.initUpdateOsCallback(),
// connect plugin links
...(registered.value && connectPluginInstalled.value
? [
{
@@ -58,19 +85,6 @@ const links = computed(():UserProfileLink[] => {
]
: []
),
// ...(!connectPluginInstalled.value
// ? [
// {
// click: () => {
// promoStore.promoShow();
// },
// icon: InformationCircleIcon,
// text: props.t('Enhance your Unraid experience with Connect'),
// title: props.t('Enhance your Unraid experience with Connect'),
// },
// ]
// : []
// ),
];
});
@@ -95,14 +109,8 @@ const showKeyline = computed(() => showConnectStatus.value && (keyActions.value?
<UpcKeyline />
</li>
<template v-if="osUpdateAvailable && !rebootType">
<li>
<UpcDropdownItem :item="toolsRegistrationAction" :t="t" />
</li>
</template>
<template v-if="keyActions">
<li v-for="action in keyActions" :key="action.name">
<template v-if="filteredKeyActions">
<li v-for="action in filteredKeyActions" :key="action.name">
<UpcDropdownItem :item="action" :t="t" />
</li>
</template>
+3 -10
View File
@@ -1,4 +1,4 @@
import { BellAlertIcon } from '@heroicons/vue/24/solid';
import { ArrowPathIcon, BellAlertIcon } from '@heroicons/vue/24/solid';
import { defineStore, createPinia, setActivePinia } from 'pinia';
import useInstallPlugin from '~/composables/installPlugin';
@@ -93,12 +93,6 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
[{
server: {
...serverStore.serverAccountPayload,
/**
* @todo - for the time being we'll always include next releases
* Prefer the param in the event for when a user is on stable and wants to see Next releases.
* Otherwise if the os version is NOT stable, we'll include next releases
*/
includeNext: true ?? includeNext ?? !updateOsStore.isOsVersionStable,
},
type: 'updateOs',
}],
@@ -107,10 +101,9 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
},
emphasize: true,
external: true,
icon: BellAlertIcon,
icon: ArrowPathIcon,
name: 'updateOs',
text: 'Unraid OS {0} Update Available',
textParams: [updateOsStore.available],
text: 'Check for OS Updates',
}
};