mirror of
https://github.com/unraid/api.git
synced 2026-04-27 18:51:05 -05:00
126 lines
4.3 KiB
Vue
126 lines
4.3 KiB
Vue
<script setup lang="ts">
|
|
import { storeToRefs } from 'pinia';
|
|
import {
|
|
ArrowTopRightOnSquareIcon,
|
|
CogIcon,
|
|
KeyIcon,
|
|
} from '@heroicons/vue/24/solid';
|
|
|
|
import {
|
|
ACCOUNT,
|
|
CONNECT_DASHBOARD,
|
|
WEBGUI_CONNECT_SETTINGS,
|
|
WEBGUI_TOOLS_REGISTRATION,
|
|
} from '~/helpers/urls';
|
|
import { useErrorsStore } from '~/store/errors';
|
|
import { useServerStore } from '~/store/server';
|
|
import { useUpdateOsStore, useUpdateOsActionsStore } from '~/store/updateOsActions';
|
|
import type { UserProfileLink } from '~/types/userProfile';
|
|
|
|
const props = defineProps<{ t: any; }>();
|
|
|
|
const errorsStore = useErrorsStore();
|
|
const updateOsActionsStore = useUpdateOsActionsStore();
|
|
|
|
const { errors } = storeToRefs(errorsStore);
|
|
const {
|
|
keyActions,
|
|
connectPluginInstalled,
|
|
registered,
|
|
regUpdatesExpired,
|
|
stateData,
|
|
} = storeToRefs(useServerStore());
|
|
const { available: osUpdateAvailable } = storeToRefs(useUpdateOsStore());
|
|
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
|
|
? [
|
|
{
|
|
emphasize: !osUpdateAvailable.value, // only emphasize when we don't have an update available
|
|
external: true,
|
|
href: CONNECT_DASHBOARD.toString(),
|
|
icon: ArrowTopRightOnSquareIcon,
|
|
text: props.t('Go to Connect'),
|
|
title: props.t('Opens Connect in new tab'),
|
|
},
|
|
{
|
|
external: true,
|
|
href: ACCOUNT.toString(),
|
|
icon: ArrowTopRightOnSquareIcon,
|
|
text: props.t('Manage Unraid.net Account'),
|
|
title: props.t('Manage Unraid.net Account in new tab'),
|
|
},
|
|
{
|
|
href: WEBGUI_CONNECT_SETTINGS.toString(),
|
|
icon: CogIcon,
|
|
text: props.t('Settings'),
|
|
title: props.t('Go to Connect plugin settings'),
|
|
},
|
|
...(signOutAction.value),
|
|
]
|
|
: []
|
|
),
|
|
...(!registered.value && connectPluginInstalled.value
|
|
? [
|
|
...(signInAction.value),
|
|
]
|
|
: []
|
|
),
|
|
];
|
|
});
|
|
|
|
const showErrors = computed(() => errors.value.length);
|
|
const showConnectStatus = computed(() => !showErrors.value && !stateData.value.error && registered.value && connectPluginInstalled.value);
|
|
const showKeyline = computed(() => showConnectStatus.value && (keyActions.value?.length || links.value.length));
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex flex-col gap-y-8px min-w-300px max-w-350px">
|
|
<header v-if="connectPluginInstalled" class="flex flex-row items-center justify-between mt-8px mx-8px">
|
|
<h2 class="text-18px leading-none flex flex-row gap-x-4px items-center justify-between">
|
|
<BrandLogoConnect gradient-start="currentcolor" gradient-stop="currentcolor" class="text-beta w-[120px]" />
|
|
<UpcBeta />
|
|
</h2>
|
|
</header>
|
|
<ul class="list-reset flex flex-col gap-y-4px p-0">
|
|
<UpcDropdownConnectStatus v-if="showConnectStatus" :t="t" />
|
|
<UpcDropdownError v-if="showErrors" :t="t" />
|
|
|
|
<li v-if="showKeyline" class="my-8px">
|
|
<UpcKeyline />
|
|
</li>
|
|
|
|
<template v-if="filteredKeyActions">
|
|
<li v-for="action in filteredKeyActions" :key="action.name">
|
|
<UpcDropdownItem :item="action" :t="t" />
|
|
</li>
|
|
</template>
|
|
|
|
<template v-if="links.length">
|
|
<li v-for="(link, index) in links" :key="`link_${index}`">
|
|
<UpcDropdownItem :item="link" :t="t" />
|
|
</li>
|
|
</template>
|
|
</ul>
|
|
</div>
|
|
</template>
|