Files
api/web/components/UserProfile/DropdownContent.vue
Eli Bosley 2c62e0ad09 feat: tailwind v4 (#1522)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Streamlined Tailwind CSS integration using Vite plugin, eliminating
the need for separate Tailwind config files.
* Updated theme and color variables for improved consistency and
maintainability.

* **Style**
* Standardized spacing, sizing, and font classes across all components
using Tailwind’s default scale.
* Reduced excessive gaps, padding, and font sizes for a more compact and
cohesive UI.
* Updated gradient, border, and shadow classes to match Tailwind v4
conventions.
* Replaced custom pixel-based classes with Tailwind’s bracketed
arbitrary value syntax where needed.
* Replaced focus outline styles from `outline-none` to `outline-hidden`
for consistent focus handling.
* Updated flex shrink/grow utility classes to use newer shorthand forms.
* Converted several component templates to use self-closing tags for
cleaner markup.
  * Adjusted icon sizes and spacing for improved visual balance.

* **Chores**
* Removed legacy Tailwind/PostCSS configuration files and related
scripts.
* Updated and cleaned up package dependencies for Tailwind v4 and
related plugins.
  * Removed unused or redundant build scripts and configuration exports.
  * Updated documentation to reflect new Tailwind v4 usage.
  * Removed Prettier Tailwind plugin from formatting configurations.
* Removed Nuxt Tailwind module in favor of direct Vite plugin
integration.
  * Cleaned up ESLint config by removing Prettier integration.

* **Bug Fixes**
  * Corrected invalid or outdated Tailwind class names and syntax.
* Fixed issues with max-width and other utility classes for improved
layout consistency.

* **Tests**
* Updated test assertions to match new class names and styling
conventions.

* **Documentation**
* Revised README and internal notes to clarify Tailwind v4 adoption and
configuration changes.
* Added new development notes emphasizing Tailwind v4 usage and
documentation references.

* **UI Components**
* Enhanced BrandButton stories with detailed variant, size, and padding
showcases for better visual testing.
* Improved theme store to apply dark mode class on both `<html>` and
`<body>` elements for compatibility.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-21 09:58:02 -04:00

247 lines
7.1 KiB
Vue

<script setup lang="ts">
import { computed } from 'vue';
import { storeToRefs } from 'pinia';
import {
ArrowPathIcon,
ArrowTopRightOnSquareIcon,
BellAlertIcon,
CogIcon,
ExclamationTriangleIcon,
KeyIcon,
UserIcon,
} from '@heroicons/vue/24/solid';
import { BrandLogoConnect } from '@unraid/ui';
import {
CONNECT_DASHBOARD,
WEBGUI_CONNECT_SETTINGS,
WEBGUI_TOOLS_DOWNGRADE,
WEBGUI_TOOLS_REGISTRATION,
WEBGUI_TOOLS_UPDATE,
} from '~/helpers/urls';
import type { UserProfileLink } from '~/types/userProfile';
import type { ComposerTranslation } from 'vue-i18n';
import { useAccountStore } from '~/store/account';
import { useErrorsStore } from '~/store/errors';
import { useServerStore } from '~/store/server';
import { useUpdateOsStore } from '~/store/updateOs';
import Beta from './Beta.vue';
import DropdownConnectStatus from './DropdownConnectStatus.vue';
import DropdownError from './DropdownError.vue';
import DropdownItem from './DropdownItem.vue';
import Keyline from './Keyline.vue';
const props = defineProps<{ t: ComposerTranslation }>();
const accountStore = useAccountStore();
const errorsStore = useErrorsStore();
const updateOsStore = useUpdateOsStore();
const { errors } = storeToRefs(errorsStore);
const {
keyActions,
connectPluginInstalled,
rebootType,
registered,
regUpdatesExpired,
stateData,
stateDataError,
} = storeToRefs(useServerStore());
const { available: osUpdateAvailable, availableWithRenewal: osUpdateAvailableWithRenewal } =
storeToRefs(updateOsStore);
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 manageUnraidNetAccount = computed((): UserProfileLink => {
return {
external: true,
click: () => {
accountStore.manage();
},
icon: UserIcon,
text: props.t('Manage Unraid.net Account'),
title: props.t('Manage Unraid.net Account in new tab'),
};
});
const updateOsCheckForUpdatesButton = computed((): UserProfileLink => {
return {
click: () => {
updateOsStore.localCheckForUpdate();
},
icon: ArrowPathIcon,
text: props.t('Check for Update'),
};
});
const updateOsResponseModalOpenButton = computed((): UserProfileLink => {
return {
click: () => {
updateOsStore.setModalOpen(true);
},
emphasize: true,
icon: BellAlertIcon,
text: osUpdateAvailableWithRenewal.value
? props.t('Unraid OS {0} Released', [osUpdateAvailableWithRenewal.value])
: props.t('Unraid OS {0} Update Available', [osUpdateAvailable.value]),
};
});
const rebootDetectedButton = computed((): UserProfileLink => {
return {
href:
rebootType.value === 'downgrade'
? WEBGUI_TOOLS_DOWNGRADE.toString()
: WEBGUI_TOOLS_UPDATE.toString(),
icon: ExclamationTriangleIcon,
text:
rebootType.value === 'downgrade'
? props.t('Reboot Required for Downgrade')
: props.t('Reboot Required for Update'),
};
});
const updateOsButton = computed((): UserProfileLink[] => {
const btns = [];
if (rebootType.value === 'downgrade' || rebootType.value === 'update') {
btns.push(rebootDetectedButton.value);
return btns;
}
if (osUpdateAvailable.value) {
btns.push(updateOsResponseModalOpenButton.value);
} else {
btns.push(updateOsCheckForUpdatesButton.value);
}
return btns;
});
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'),
},
]
: []),
// ensure we only show the update button when we don't have an error
...(!stateDataError.value ? [...updateOsButton.value] : []),
// 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'),
},
...[manageUnraidNetAccount.value],
...signOutAction.value,
]
: [...[manageUnraidNetAccount.value]]),
{
href: WEBGUI_CONNECT_SETTINGS.toString(),
icon: CogIcon,
text: props.t('Settings'),
title: props.t('Go to API Settings'),
},
];
});
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)) ||
unraidConnectWelcome.value
);
const unraidConnectWelcome = computed(() => {
if (
connectPluginInstalled.value &&
!registered.value &&
!errors.value.length &&
!stateDataError.value
) {
return {
heading: props.t('Thank you for installing Connect!'),
message: props.t('Sign In to your Unraid.net account to get started'),
};
}
return undefined;
});
</script>
<template>
<div class="flex flex-col grow gap-y-2">
<header
v-if="connectPluginInstalled"
class="flex flex-col items-start justify-between mt-2 mx-2"
>
<h2 class="text-lg leading-none flex flex-row gap-x-1 items-center justify-between">
<BrandLogoConnect
gradient-start="currentcolor"
gradient-stop="currentcolor"
class="text-foreground w-[120px]"
/>
<Beta />
</h2>
<template v-if="unraidConnectWelcome">
<h3 class="text-base font-semibold mt-2">
{{ unraidConnectWelcome.heading }}
</h3>
<p class="text-sm">
{{ unraidConnectWelcome.message }}
</p>
</template>
</header>
<ul class="list-reset flex flex-col gap-y-1 p-0">
<DropdownConnectStatus v-if="showConnectStatus" :t="t" />
<DropdownError v-if="showErrors" :t="t" />
<li v-if="showKeyline" class="my-2">
<Keyline />
</li>
<li v-if="!registered && connectPluginInstalled">
<DropdownItem :item="signInAction[0]" :t="t" />
</li>
<template v-if="filteredKeyActions">
<li v-for="action in filteredKeyActions" :key="action.name">
<DropdownItem :item="action" :t="t" />
</li>
</template>
<template v-if="links.length">
<li v-for="(link, index) in links" :key="`link_${index}`">
<DropdownItem :item="link" :t="t" />
</li>
</template>
</ul>
</div>
</template>