Files
api/web/components/KeyActions.vue
Michael Datelle 741e8532ab refactor: unraid-ui-web-migration (#1106)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced enhanced stepper components for smoother multi-step
interactions.
- Added new loading indicators and improved the loading experience with
customizable variants.
  
- **UI Improvements**
- Refreshed the global color palette and updated styling across buttons,
badges, and loading indicators for a more modern, consistent experience.
- Improved the organization and readability of templates and styles
across various components.

- **Code & Dependency Updates**
- Updated key dependencies and revised the theme and configuration
settings to improve performance and maintainability.
- Introduced new environment variables for better configuration
management.

- **Legacy Cleanup**
- Removed deprecated components and streamlined registrations to
simplify the codebase without affecting end-user functionality.
- Eliminated unused utility functions and legacy code to enhance overall
code quality.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mdatelle <mike@datelle.net>
Co-authored-by: Eli Bosley <ekbosley@gmail.com>
2025-02-12 18:00:06 -05:00

65 lines
1.8 KiB
Vue

<script lang="ts" setup>
import { storeToRefs } from 'pinia';
import { ArrowTopRightOnSquareIcon } from '@heroicons/vue/24/solid';
import { BrandButton, cn } from '@unraid/ui';
import type { ServerStateDataAction } from '~/types/server';
import type { ComposerTranslation } from 'vue-i18n';
import { useServerStore } from '~/store/server';
const props = withDefaults(
defineProps<{
actions?: ServerStateDataAction[];
filterBy?: string[] | undefined;
filterOut?: string[] | undefined;
maxWidth?: boolean;
t: ComposerTranslation;
}>(),
{
actions: undefined,
filterBy: undefined,
filterOut: undefined,
maxWidth: false,
}
);
const { keyActions } = storeToRefs(useServerStore());
const computedActions = computed((): ServerStateDataAction[] | undefined =>
props.actions ? props.actions : keyActions.value
);
const filteredKeyActions = computed((): ServerStateDataAction[] | undefined => {
if (!computedActions.value || (!props.filterOut && !props.filterBy)) {
return computedActions.value;
}
return computedActions.value.filter((action: { name: string }) => {
return props.filterOut
? !props.filterOut?.includes(action.name)
: props.filterBy?.includes(action.name);
});
});
</script>
<template>
<ul v-if="filteredKeyActions" class="flex flex-col gap-y-8px">
<li v-for="action in filteredKeyActions" :key="action.name">
<BrandButton
:class="cn('w-full', props.maxWidth ? 'sm:max-w-300px' : '')"
:disabled="action?.disabled"
:external="action?.external"
:href="action?.href"
:icon="action.icon"
:icon-right="ArrowTopRightOnSquareIcon"
:icon-right-hover-display="true"
:text="t(action.text)"
:title="action.title ? t(action.title) : undefined"
@click="action.click?.()"
/>
</li>
</ul>
</template>