refactor: targeting keyType strings for Starter / Unleashed

This commit is contained in:
Zack Spear
2024-01-31 10:51:16 -08:00
committed by Zack Spear
parent 26841aa10d
commit 58f9eec8b1
3 changed files with 17 additions and 9 deletions

View File

@@ -92,7 +92,7 @@ const devicesAvailable = computed((): number => {
});
const showTrialExpiration = computed((): boolean => state.value === 'TRIAL' || state.value === 'EEXPIRED');
const showUpdateEligibility = computed((): boolean => !!(regExp.value && (state.value === 'STARTER' || state.value === 'UNLEASHED')));
const showUpdateEligibility = computed((): boolean => !!(regExp.value));
const keyInstalled = computed((): boolean => !!(!stateDataError.value && state.value !== 'ENOKEYFILE'));
const showTransferStatus = computed((): boolean => !!(keyInstalled.value && guid.value && !showTrialExpiration.value));
// filter out renew action and only display other key actions…renew is displayed in RegistrationUpdateExpirationAction

View File

@@ -199,6 +199,16 @@ const accountActionStatusCopy = computed((): { text: string; } => {
});
const { copy, copied, isSupported } = useClipboard({ source: keyUrl.value });
/**
* Ideally we'd show this based off of regExp.value, but we will not have that value yet.
* So we'll use the keyType.value that we get from the keyInstall store.
*/
const showUpdateEligibility = computed(() => {
// rather than specifically targeting 'Starter' and 'Unleashed' we'll target all keys that are not 'Basic', 'Plus', 'Pro', 'Lifetime', or 'Trial'
if (!keyType.value) { return false; }
return !['Basic', 'Plus', 'Pro', 'Lifetime', 'Trial'].includes(keyType.value);
});
</script>
<template>
@@ -236,7 +246,7 @@ const { copy, copied, isSupported } = useClipboard({ source: keyUrl.value });
{{ t('Calculating trial expiration') }}
</p>
</div>
<div v-if="keyType === 'Starter' || keyType === 'Unleashed'" class="opacity-75 italic mt-4px">
<div v-if="showUpdateEligibility" class="opacity-75 italic mt-4px">
<RegistrationUpdateExpiration
v-if="refreshServerStateStatus === 'done'"
:t="t"

View File

@@ -104,7 +104,7 @@ export const useServerStore = defineStore('server', () => {
const regExp = ref<number>(0);
const parsedRegExp = computed(() => regExp.value ? dayjs(regExp.value).format('YYYY-MM-DD') : null);
const regUpdatesExpired = computed(() => {
if (!regExp.value || (state.value !== 'STARTER' && state.value !== 'UNLEASHED')) { return false; }
if (!regExp.value) { return false; }
const today = dayjs();
const parsedUpdateExpirationDate = dayjs(regExp.value);
@@ -452,11 +452,11 @@ export const useServerStore = defineStore('server', () => {
return {
actions: [
...(!registered.value && connectPluginInstalled.value ? [signInAction.value] : []),
...(state.value === 'STARTER' && regUpdatesExpired.value ? [renewAction.value] : []),
...(regUpdatesExpired.value ? [renewAction.value] : []),
...([upgradeAction.value]),
...(registered.value && connectPluginInstalled.value ? [signOutAction.value] : []),
],
humanReadable: state.value === 'BASIC' ? 'Basic' : 'Starter',
humanReadable: 'Starter',
heading: 'Thank you for choosing Unraid OS!',
message: !registered.value && connectPluginInstalled.value
? '<p>Register for Connect by signing in to your Unraid.net account</p>'
@@ -485,12 +485,10 @@ export const useServerStore = defineStore('server', () => {
return {
actions: [
...(!registered.value && connectPluginInstalled.value ? [signInAction.value] : []),
...(state.value === 'UNLEASHED' && regUpdatesExpired.value ? [renewAction.value] : []),
...(regUpdatesExpired.value ? [renewAction.value] : []),
...(registered.value && connectPluginInstalled.value ? [signOutAction.value] : []),
],
humanReadable: state.value === 'PRO'
? 'Pro'
: (state.value === 'LIFETIME' ? 'Lifetime' : 'Unleashed'),
humanReadable: 'Unleashed',
heading: 'Thank you for choosing Unraid OS!',
message: !registered.value && connectPluginInstalled.value
? '<p>Register for Connect by signing in to your Unraid.net account</p>'