mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-11-26 08:47:19 -06:00
Compare commits
18 Commits
rest-api/p
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07722cd4f3 | ||
|
|
b6d1387425 | ||
|
|
8f8c8ca405 | ||
|
|
424f970cf9 | ||
|
|
dfc298e40b | ||
|
|
750c74beb1 | ||
|
|
050c47079a | ||
|
|
dca9d63799 | ||
|
|
c42b46b833 | ||
|
|
77c24dacd7 | ||
|
|
9bee5dc5b1 | ||
|
|
2313809c11 | ||
|
|
21d458cdd1 | ||
|
|
fa675eead1 | ||
|
|
31c3f5bb20 | ||
|
|
7e850aedaf | ||
|
|
069cb2816a | ||
|
|
7c63be3aaf |
@@ -822,3 +822,16 @@ export type RPU_RECOVERY_STEP_NAME = (typeof RPU_RECOVERY_STEP_NAMES)[number]
|
||||
export const COMMON_TAG = {
|
||||
NOBAK: 'xo:no-bak',
|
||||
} as const
|
||||
|
||||
/**
|
||||
* a package of the XO appliance with another version available
|
||||
*
|
||||
* Returned by `xoa-updater` as `upgradablePackages` at the end of an update check.
|
||||
*/
|
||||
export type XoaPackageUpdate = {
|
||||
name: string
|
||||
/** version which will be installed */
|
||||
version: string
|
||||
/** undefined: the package is not installed yet */
|
||||
installedVersion?: string
|
||||
}
|
||||
|
||||
@@ -760,8 +760,6 @@ export type XoApp = EventEmitter & {
|
||||
url?: string
|
||||
}
|
||||
): Promise<XoBackupRepository>
|
||||
/** Throw if backup jobs are running on the proxy, unless ignored; `force` reboots the proxy VM */
|
||||
upgradeProxyAppliance(id: XoProxy['id'], opts: { force?: boolean; ignoreRunningJobs?: boolean }): Promise<void>
|
||||
getAllXapis(): Record<string, Xapi>
|
||||
getObjects(opts?: { filter?: Record<string, unknown>; limit?: number }): Record<string, XapiXoRecord>
|
||||
getLicenses(params?: { productType?: LicenseProductType }): Promise<License[]>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export default {
|
||||
read: true,
|
||||
upgrade: true,
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
## **next**
|
||||
|
||||
- [VDIs] The used space of a VDI now includes its whole snapshot chain instead of only its last layer, which showed almost 0% for disks with snapshots. It is shown as a size, without usage bar or free space (PR [#10116](https://github.com/vatesfr/xen-orchestra/pull/10116))
|
||||
- [Web-Core/UiCircleProgressBar] Add a brand accent and an option to hide the value (PR [#10849](https://github.com/vatesfr/xen-orchestra/pull/10849))
|
||||
- [Tables] Cells fit on one line: long names are cut in the middle, extra tags go under "+N" and long texts end with "…" (PR [#10850](https://github.com/vatesfr/xen-orchestra/pull/10850))
|
||||
- [Pages] The page header and tabs now stay in place on every page: dashboards, System tabs, consoles, tasks, settings and creation forms scroll under them instead of scrolling with them (PR [#10822](https://github.com/vatesfr/xen-orchestra/pull/10822))
|
||||
@@ -16,6 +17,8 @@
|
||||
- [Side panels] Fix the double scrollbar when the side panel content is taller than the screen: the page header now stays in place, and the list and the side panel each scroll on their own. All scrollbars are now thin, like the side panel one (PR [#10807](https://github.com/vatesfr/xen-orchestra/pull/10807))
|
||||
- [Mobile] Searchable dropdown lists no longer overflow the screen (PR [#10854](https://github.com/vatesfr/xen-orchestra/pull/10854))
|
||||
- [New/VM] Fix the storage table overflowing horizontally, which hid part of the delete button (PR [#10851](https://github.com/vatesfr/xen-orchestra/pull/10851))
|
||||
- [New/VM] Fix template disk settings being applied to every disk of the new VM: each disk now keeps its own name, description and SR (PR [#10898](https://github.com/vatesfr/xen-orchestra/pull/10898))
|
||||
- [VM/System] Display the default 4 MiB video RAM for HVM VMs that don't define it, as XO 6 does (PR [#10901](https://github.com/vatesfr/xen-orchestra/pull/10901))
|
||||
|
||||
## **0.27.0** (2026-10-29)
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ const progress = computed(() => {
|
||||
.progress-circle-fill {
|
||||
animation: progress 1s ease-out forwards;
|
||||
fill: none;
|
||||
stroke: var(--color-success-item-base);
|
||||
stroke: var(--color-success-data);
|
||||
stroke-width: 1.2;
|
||||
stroke-linecap: round;
|
||||
stroke-dasharray: v-bind(progress), 100;
|
||||
|
||||
@@ -68,11 +68,11 @@ const hasError = computed(() => hostStoreHasError.value || vmStoreHasError.value
|
||||
<style lang="postcss" scoped>
|
||||
.progress-item {
|
||||
--progress-bar-height: 1.2rem;
|
||||
--progress-bar-color: var(--color-brand-item-base);
|
||||
--progress-bar-color: var(--color-brand-data);
|
||||
--progress-bar-background-color: var(--color-neutral-background-disabled);
|
||||
|
||||
&.warning {
|
||||
--progress-bar-color: var(--color-warning-item-base);
|
||||
--progress-bar-color: var(--color-warning-data);
|
||||
--footer-value-color: var(--color-warning-item-base);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ const inactive = computed(() => props.total - props.active)
|
||||
width: 1.3rem;
|
||||
height: 1.3rem;
|
||||
border-radius: 0.65rem;
|
||||
background-color: var(--color-success-item-base);
|
||||
background-color: var(--color-success-data);
|
||||
|
||||
&.inactive {
|
||||
background-color: var(--color-neutral-background-disabled);
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
import type { XenApiVm } from '@/libs/xen-api/xen-api.types.ts'
|
||||
import { getHostIcon } from '@/modules/host/utils/host.util.ts'
|
||||
import { useVmUtils } from '@/modules/vm/composables/vm-utils.composable.ts'
|
||||
import { getVmDomainType } from '@/modules/vm/utils/vm.util.ts'
|
||||
import { useHostMetricsStore } from '@/stores/xen-api/host-metrics.store.ts'
|
||||
import { usePoolStore } from '@/stores/xen-api/pool.store.ts'
|
||||
import { useVmGuestMetricsStore } from '@/stores/xen-api/vm-guest-metrics.store.ts'
|
||||
@@ -133,16 +134,7 @@ const ram = computed(() => formatSizeRaw(vm.memory_dynamic_max, 0))
|
||||
|
||||
const osVersion = computed(() => guestMetrics.value?.os_version.name)
|
||||
|
||||
const domainType = computed(() => {
|
||||
if (
|
||||
vm.domain_type !== undefined && // XS < 7.5
|
||||
vm.domain_type !== 'unspecified' // detection failed
|
||||
) {
|
||||
return vm.domain_type
|
||||
}
|
||||
|
||||
return vm.HVM_boot_policy === '' ? 'pv' : 'hvm'
|
||||
})
|
||||
const domainType = computed(() => getVmDomainType(vm))
|
||||
|
||||
const virtualizationType = computed(() =>
|
||||
domainType.value === 'hvm' && guestMetrics.value?.PV_drivers_detected ? 'pvhvm' : domainType.value
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
</template>
|
||||
</VtsTabularKeyValueRow>
|
||||
<VtsTabularKeyValueRow :label="t('video-ram')">
|
||||
<template v-if="vm.platform.videoram" #value>
|
||||
{{ `${vm.platform.videoram} ${t('bytes:mi')}` }}
|
||||
<template v-if="videoRam" #value>
|
||||
{{ `${videoRam} ${t('bytes:mi')}` }}
|
||||
</template>
|
||||
</VtsTabularKeyValueRow>
|
||||
</VtsTabularKeyValueList>
|
||||
@@ -20,14 +20,18 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { XenApiVm } from '@/libs/xen-api/xen-api.types.ts'
|
||||
import { getVmDomainType } from '@/modules/vm/utils/vm.util.ts'
|
||||
import VtsStatus from '@core/components/status/VtsStatus.vue'
|
||||
import VtsTabularKeyValueList from '@core/components/tabular-key-value-list/VtsTabularKeyValueList.vue'
|
||||
import VtsTabularKeyValueRow from '@core/components/tabular-key-value-row/VtsTabularKeyValueRow.vue'
|
||||
import UiCard from '@core/components/ui/card/UiCard.vue'
|
||||
import UiTitle from '@core/components/ui/title/UiTitle.vue'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineProps<{ vm: XenApiVm }>()
|
||||
const { vm } = defineProps<{ vm: XenApiVm }>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const videoRam = computed(() => (getVmDomainType(vm) === 'hvm' ? Number(vm.platform.videoram ?? 4) : undefined))
|
||||
</script>
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { XenApiVm } from '@/libs/xen-api/xen-api.types.ts'
|
||||
import { getVmDomainType } from '@/modules/vm/utils/vm.util.ts'
|
||||
import { useHostStore } from '@/stores/xen-api/host.store.ts'
|
||||
import { usePoolStore } from '@/stores/xen-api/pool.store.ts'
|
||||
import { useVtpmStore } from '@/stores/xen-api/vtpm.store.ts'
|
||||
@@ -55,16 +56,7 @@ const { pool } = usePoolStore().subscribe()
|
||||
const { getByOpaqueRef: getHostOpaqueRef } = useHostStore().subscribe()
|
||||
const { getByOpaqueRef: getVtpmOpaqueRef } = useVtpmStore().subscribe()
|
||||
|
||||
/**
|
||||
* @see `packages/xo-server/src/xapi/utils.mjs`:57
|
||||
**/
|
||||
const virtualizationMode = computed(() =>
|
||||
vm.domain_type !== undefined && vm.domain_type !== 'unspecified'
|
||||
? vm.domain_type
|
||||
: vm.HVM_boot_policy === ''
|
||||
? 'pv'
|
||||
: 'hvm'
|
||||
)
|
||||
const virtualizationMode = computed(() => getVmDomainType(vm))
|
||||
|
||||
const isNestedVirtualizationEnabled = computed(() => {
|
||||
const poolMaster = pool.value !== undefined ? getHostOpaqueRef(pool.value.master) : undefined
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { XenApiVbd, XenApiVdi } from '@/libs/xen-api/xen-api.types.ts'
|
||||
import { getVdiFormat, getVdiIcon } from '@/modules/vdi/utils/vdi.util.ts'
|
||||
import { useVdiStore } from '@/stores/xen-api/vdi.store.ts'
|
||||
import VtsRow from '@core/components/table/VtsRow.vue'
|
||||
import VtsTable from '@core/components/table/VtsTable.vue'
|
||||
import UiQuerySearchBar from '@core/components/ui/query-search-bar/UiQuerySearchBar.vue'
|
||||
@@ -43,6 +44,7 @@ const { vdis, vbds, busy, error } = defineProps<{
|
||||
error?: boolean
|
||||
}>()
|
||||
const { t } = useI18n()
|
||||
const { getChainPhysicalUsage } = useVdiStore().subscribe()
|
||||
const selectedVdiId = useRouteQuery('id')
|
||||
const { items: filteredVdis, searchBindings } = useSearchFilter(() => vdis)
|
||||
const state = useTableState({
|
||||
@@ -56,6 +58,7 @@ const { HeadCells, BodyCells } = useVdiColumns({
|
||||
exclude: ['actions'],
|
||||
body: (vdi: XenApiVdi) => {
|
||||
const vdiVbds = computed(() => vbds.filter(vbd => vbd.VDI === vdi.$ref))
|
||||
const usedSpace = computed(() => formatSizeRaw(getChainPhysicalUsage(vdi), 2))
|
||||
const size = computed(() => formatSizeRaw(vdi.virtual_size, 2))
|
||||
const format = computed(() => getVdiFormat(vdi.sm_config['image-format']))
|
||||
return {
|
||||
@@ -65,7 +68,7 @@ const { HeadCells, BodyCells } = useVdiColumns({
|
||||
icon: getVdiIcon(vdiVbds.value),
|
||||
}),
|
||||
description: r => r(vdi.name_description),
|
||||
usedSpace: r => r(vdi.physical_utilisation, vdi.virtual_size),
|
||||
usedSpace: r => r(usedSpace.value.value, usedSpace.value.prefix),
|
||||
size: r => r(size.value.value, size.value.prefix),
|
||||
format: r => r(format.value),
|
||||
selectItem: r => r(() => (selectedVdiId.value = vdi.uuid)),
|
||||
|
||||
@@ -1,12 +1,48 @@
|
||||
<template>
|
||||
<VtsSpaceCard :used="vdi.physical_utilisation" :total="vdi.virtual_size" :label="vdi.name_label" />
|
||||
<UiPanelCard>
|
||||
<UiPanelCardTitle size="medium" :label="t('space')" />
|
||||
<VtsCardRowList>
|
||||
<VtsCardRowKeyValue>
|
||||
<template #key>{{ t('used-space') }}</template>
|
||||
<template #value>{{ usedSpace }}</template>
|
||||
<template v-if="chainPhysicalUsage > 0" #addons>
|
||||
<VtsCopyButton :value="usedSpace" />
|
||||
</template>
|
||||
</VtsCardRowKeyValue>
|
||||
<VtsCardRowKeyValue>
|
||||
<template #key>{{ t('size') }}</template>
|
||||
<template #value>{{ size }}</template>
|
||||
<template v-if="vdi.virtual_size > 0" #addons>
|
||||
<VtsCopyButton :value="size" />
|
||||
</template>
|
||||
</VtsCardRowKeyValue>
|
||||
</VtsCardRowList>
|
||||
</UiPanelCard>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { XenApiVdi } from '@/libs/xen-api/xen-api.types.ts'
|
||||
import VtsSpaceCard from '@core/components/space-card/VtsSpaceCard.vue'
|
||||
import { useVdiStore } from '@/stores/xen-api/vdi.store.ts'
|
||||
import VtsCardRowKeyValue from '@core/components/card/VtsCardRowKeyValue.vue'
|
||||
import VtsCardRowList from '@core/components/card/VtsCardRowList.vue'
|
||||
import VtsCopyButton from '@core/components/copy-button/VtsCopyButton.vue'
|
||||
import UiPanelCard from '@core/components/ui/panel-card/UiPanelCard.vue'
|
||||
import UiPanelCardTitle from '@core/components/ui/panel-card-title/UiPanelCardTitle.vue'
|
||||
import { formatSize } from '@core/utils/size.util.ts'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineProps<{
|
||||
const { vdi } = defineProps<{
|
||||
vdi: XenApiVdi
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const { getChainPhysicalUsage } = useVdiStore().subscribe()
|
||||
|
||||
const chainPhysicalUsage = computed(() => getChainPhysicalUsage(vdi))
|
||||
|
||||
const usedSpace = computed(() => formatSize(chainPhysicalUsage.value, 2))
|
||||
|
||||
const size = computed(() => formatSize(vdi.virtual_size, 2))
|
||||
</script>
|
||||
|
||||
@@ -43,6 +43,20 @@ export function areVmToolsDetected(guestMetrics: XenApiVmGuestMetrics | undefine
|
||||
return managementAgentDetected && pvDriversDetected
|
||||
}
|
||||
|
||||
/**
|
||||
* @see `packages/xo-server/src/xapi/utils.mjs`:57
|
||||
**/
|
||||
export function getVmDomainType(vm: XenApiVm) {
|
||||
if (
|
||||
vm.domain_type !== undefined && // XS < 7.5
|
||||
vm.domain_type !== 'unspecified' // detection failed
|
||||
) {
|
||||
return vm.domain_type
|
||||
}
|
||||
|
||||
return vm.HVM_boot_policy === '' ? 'pv' : 'hvm'
|
||||
}
|
||||
|
||||
export type VmPowerStateAction =
|
||||
| 'start'
|
||||
| 'pause'
|
||||
|
||||
@@ -512,6 +512,7 @@ const getExistingVdis = (template: XenApiVm) => {
|
||||
|
||||
acc.push({
|
||||
id: vdi.$ref,
|
||||
userdevice: vbd.userdevice,
|
||||
name_label: vdi.name_label,
|
||||
name_description: vdi.name_description,
|
||||
size: bytesToGiB(vdi.virtual_size),
|
||||
@@ -698,6 +699,7 @@ const _createVm = defer(async ($defer: Defer) => {
|
||||
const vdiRef = await xapi.getField<XenApiVdi['$ref']>('VBD', vbdRef, 'VDI')
|
||||
const type = await xapi.getField<VBD_TYPE>('VBD', vbdRef, 'type')
|
||||
const bootable = await xapi.getField<boolean>('VBD', vbdRef, 'bootable')
|
||||
const userdevice = await xapi.getField<XenApiVbd['userdevice']>('VBD', vbdRef, 'userdevice')
|
||||
|
||||
if (!hasBootableDisk) {
|
||||
hasBootableDisk = bootable
|
||||
@@ -707,45 +709,49 @@ const _createVm = defer(async ($defer: Defer) => {
|
||||
continue
|
||||
}
|
||||
|
||||
for (const vdi of existingVdis) {
|
||||
const srRef = await xapi.getField<XenApiSr['$ref']>('VDI', vdiRef, 'SR')
|
||||
const vbdRefs = await xapi.getField<XenApiVbd['$ref'][]>('VDI', vdiRef, 'VBDs')
|
||||
const vdi = existingVdis.find(vdi => vdi.userdevice === userdevice)
|
||||
|
||||
await xapi.vdi.setNameLabel(vdiRef, vdi.name_label)
|
||||
await xapi.vdi.setNameDescription(vdiRef, vdi.name_description)
|
||||
if (vdi === undefined) {
|
||||
continue
|
||||
}
|
||||
|
||||
// EDIT SR: Migrate VDI or create new one
|
||||
if (vdi.SR !== srRef) {
|
||||
try {
|
||||
await xapi.vdi.poolMigrate(vdiRef, vdi.SR)
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error)) {
|
||||
throw error
|
||||
}
|
||||
const srRef = await xapi.getField<XenApiSr['$ref']>('VDI', vdiRef, 'SR')
|
||||
const vbdRefs = await xapi.getField<XenApiVbd['$ref'][]>('VDI', vdiRef, 'VBDs')
|
||||
|
||||
const { message } = error
|
||||
await xapi.vdi.setNameLabel(vdiRef, vdi.name_label)
|
||||
await xapi.vdi.setNameDescription(vdiRef, vdi.name_description)
|
||||
|
||||
if (
|
||||
message !== 'NO_HOSTS_AVAILABLE' &&
|
||||
message !== 'LICENCE_RESTRICTION' &&
|
||||
message !== 'VDI_NEEDS_VM_FOR_MIGRATE'
|
||||
) {
|
||||
throw error
|
||||
}
|
||||
|
||||
const newVdiRef = await xapi.vdi.copy(vdiRef, vdi.SR)
|
||||
|
||||
if (vbdRefs) {
|
||||
for (const vbdRef of vbdRefs) {
|
||||
const vbd = await xapi.getField<XenApiVbd>('VBD', vbdRef, 'record')
|
||||
|
||||
await xapi.vbd.delete(vbdRef)
|
||||
await xapi.vbd.create({ ...vbd, vmRefs, vdiRef: newVdiRef[0] })
|
||||
}
|
||||
}
|
||||
|
||||
await xapi.vdi.delete(vdiRef)
|
||||
// EDIT SR: Migrate VDI or create new one
|
||||
if (vdi.SR !== srRef) {
|
||||
try {
|
||||
await xapi.vdi.poolMigrate(vdiRef, vdi.SR)
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error)) {
|
||||
throw error
|
||||
}
|
||||
|
||||
const { message } = error
|
||||
|
||||
if (
|
||||
message !== 'NO_HOSTS_AVAILABLE' &&
|
||||
message !== 'LICENCE_RESTRICTION' &&
|
||||
message !== 'VDI_NEEDS_VM_FOR_MIGRATE'
|
||||
) {
|
||||
throw error
|
||||
}
|
||||
|
||||
const newVdiRef = await xapi.vdi.copy(vdiRef, vdi.SR)
|
||||
|
||||
if (vbdRefs) {
|
||||
for (const vbdRef of vbdRefs) {
|
||||
const vbd = await xapi.getField<XenApiVbd>('VBD', vbdRef, 'record')
|
||||
|
||||
await xapi.vbd.delete(vbdRef)
|
||||
await xapi.vbd.create({ ...vbd, vmRefs, vdiRef: newVdiRef[0] })
|
||||
}
|
||||
}
|
||||
|
||||
await xapi.vdi.delete(vdiRef)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
91
@xen-orchestra/lite/src/route-map.d.ts
vendored
91
@xen-orchestra/lite/src/route-map.d.ts
vendored
@@ -891,6 +891,13 @@ declare module 'vue-router/auto-routes' {
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/group-subcategory/ui-group-subcategory': RouteRecordInfo<
|
||||
'/story/web-core/ui/group-subcategory/ui-group-subcategory',
|
||||
'/story/web-core/ui/group-subcategory/ui-group-subcategory',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/head-bar/ui-head-bar': RouteRecordInfo<
|
||||
'/story/web-core/ui/head-bar/ui-head-bar',
|
||||
'/story/web-core/ui/head-bar/ui-head-bar',
|
||||
@@ -898,6 +905,13 @@ declare module 'vue-router/auto-routes' {
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/image-radio-button/ui-image-radio-button': RouteRecordInfo<
|
||||
'/story/web-core/ui/image-radio-button/ui-image-radio-button',
|
||||
'/story/web-core/ui/image-radio-button/ui-image-radio-button',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/info/ui-info': RouteRecordInfo<
|
||||
'/story/web-core/ui/info/ui-info',
|
||||
'/story/web-core/ui/info/ui-info',
|
||||
@@ -1052,6 +1066,20 @@ declare module 'vue-router/auto-routes' {
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/rich-checkbox/ui-rich-checkbox': RouteRecordInfo<
|
||||
'/story/web-core/ui/rich-checkbox/ui-rich-checkbox',
|
||||
'/story/web-core/ui/rich-checkbox/ui-rich-checkbox',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/rich-checkbox-group/ui-rich-checkbox-group': RouteRecordInfo<
|
||||
'/story/web-core/ui/rich-checkbox-group/ui-rich-checkbox-group',
|
||||
'/story/web-core/ui/rich-checkbox-group/ui-rich-checkbox-group',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/rich-radio-button/ui-rich-radio-button': RouteRecordInfo<
|
||||
'/story/web-core/ui/rich-radio-button/ui-rich-radio-button',
|
||||
'/story/web-core/ui/rich-radio-button/ui-rich-radio-button',
|
||||
@@ -1059,6 +1087,13 @@ declare module 'vue-router/auto-routes' {
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/rich-radio-button-group/ui-rich-radio-button-group': RouteRecordInfo<
|
||||
'/story/web-core/ui/rich-radio-button-group/ui-rich-radio-button-group',
|
||||
'/story/web-core/ui/rich-radio-button-group/ui-rich-radio-button-group',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/stacked-bar/ui-stacked-bar': RouteRecordInfo<
|
||||
'/story/web-core/ui/stacked-bar/ui-stacked-bar',
|
||||
'/story/web-core/ui/stacked-bar/ui-stacked-bar',
|
||||
@@ -1115,6 +1150,13 @@ declare module 'vue-router/auto-routes' {
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/tag/ui-label-value-tag': RouteRecordInfo<
|
||||
'/story/web-core/ui/tag/ui-label-value-tag',
|
||||
'/story/web-core/ui/tag/ui-label-value-tag',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/tag/ui-tag': RouteRecordInfo<
|
||||
'/story/web-core/ui/tag/ui-tag',
|
||||
'/story/web-core/ui/tag/ui-tag',
|
||||
@@ -1129,13 +1171,6 @@ declare module 'vue-router/auto-routes' {
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/tag/ui-tertiary-tag': RouteRecordInfo<
|
||||
'/story/web-core/ui/tag/ui-tertiary-tag',
|
||||
'/story/web-core/ui/tag/ui-tertiary-tag',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/story/web-core/ui/task-item/ui-task-item': RouteRecordInfo<
|
||||
'/story/web-core/ui/task-item/ui-task-item',
|
||||
'/story/web-core/ui/task-item/ui-task-item',
|
||||
@@ -2038,12 +2073,24 @@ declare module 'vue-router/auto-routes' {
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/group-subcategory/ui-group-subcategory.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/group-subcategory/ui-group-subcategory'
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/head-bar/ui-head-bar.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/head-bar/ui-head-bar'
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/image-radio-button/ui-image-radio-button.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/image-radio-button/ui-image-radio-button'
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/info/ui-info.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/info/ui-info'
|
||||
@@ -2176,12 +2223,30 @@ declare module 'vue-router/auto-routes' {
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/rich-checkbox/ui-rich-checkbox.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/rich-checkbox/ui-rich-checkbox'
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/rich-checkbox-group/ui-rich-checkbox-group.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/rich-checkbox-group/ui-rich-checkbox-group'
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/rich-radio-button/ui-rich-radio-button.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/rich-radio-button/ui-rich-radio-button'
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/rich-radio-button-group/ui-rich-radio-button-group.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/rich-radio-button-group/ui-rich-radio-button-group'
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/stacked-bar/ui-stacked-bar.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/stacked-bar/ui-stacked-bar'
|
||||
@@ -2230,6 +2295,12 @@ declare module 'vue-router/auto-routes' {
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/tag/ui-label-value-tag.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/tag/ui-label-value-tag'
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/tag/ui-tag.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/tag/ui-tag'
|
||||
@@ -2242,12 +2313,6 @@ declare module 'vue-router/auto-routes' {
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/tag/ui-tertiary-tag.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/tag/ui-tertiary-tag'
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/stories/web-core/ui/task-item/ui-task-item.story.vue': {
|
||||
routes:
|
||||
| '/story/web-core/ui/task-item/ui-task-item'
|
||||
|
||||
@@ -1,9 +1,37 @@
|
||||
import type { XenApiVdi } from '@/libs/xen-api/xen-api.types.ts'
|
||||
import { createXapiStoreConfig } from '@/stores/xen-api/create-xapi-store-config.ts'
|
||||
import { createSubscribableStoreContext } from '@core/utils/create-subscribable-store-context.util.ts'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useVdiStore = defineStore('xen-api-vdi', () => {
|
||||
const config = createXapiStoreConfig('vdi')
|
||||
const { context: baseContext, ...configRest } = createXapiStoreConfig('vdi')
|
||||
|
||||
return createSubscribableStoreContext(config, {})
|
||||
const getChainPhysicalUsage = (vdi: XenApiVdi) => {
|
||||
if (vdi.is_a_snapshot || !vdi.managed) {
|
||||
return vdi.physical_utilisation
|
||||
}
|
||||
|
||||
let total = vdi.physical_utilisation
|
||||
let parentUuid = vdi.sm_config['vhd-parent'] as XenApiVdi['uuid'] | undefined
|
||||
|
||||
while (parentUuid !== undefined) {
|
||||
const parent = baseContext.getByUuid(parentUuid)
|
||||
|
||||
if (parent === undefined) {
|
||||
break
|
||||
}
|
||||
|
||||
total += parent.physical_utilisation
|
||||
parentUuid = parent.sm_config['vhd-parent'] as XenApiVdi['uuid'] | undefined
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
|
||||
const context = {
|
||||
...baseContext,
|
||||
getChainPhysicalUsage,
|
||||
}
|
||||
|
||||
return createSubscribableStoreContext({ context, ...configRest }, {})
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
v-slot="{ properties, settings }"
|
||||
:params="[
|
||||
prop('accent').type('CheckboxAccent').required().enum('brand', 'warning', 'danger').preset('brand').widget(),
|
||||
prop('value').str().help('Used when the model is an array'),
|
||||
prop('disabled').bool().widget(),
|
||||
slot(),
|
||||
slot('info'),
|
||||
@@ -10,7 +11,7 @@
|
||||
setting('defaultSlot').widget(text()).preset('Label'),
|
||||
setting('info').widget(text()).preset('Lorem ipsum dolor sit amet, consectetur adipiscing elit.'),
|
||||
setting('message').widget(text()).preset('Lorem ipsum dolor sit amet, consectetur adipiscing elit.'),
|
||||
model().type('boolean').preset(undefined),
|
||||
model().type('boolean | undefined | string[]').preset(undefined).help('undefined means partly checked'),
|
||||
]"
|
||||
>
|
||||
<UiCheckbox v-bind="properties">
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<template>
|
||||
<ComponentStory
|
||||
v-slot="{ settings }"
|
||||
:params="[
|
||||
slot().help('Meant to receive the subcategory title'),
|
||||
slot('info').help('Meant to receive a short text displayed on the right'),
|
||||
setting('defaultSlot').widget(text()).preset('Into a pool'),
|
||||
setting('info').widget(text()).preset('Writes to a pool'),
|
||||
]"
|
||||
>
|
||||
<UiGroupSubcategory>
|
||||
{{ settings.defaultSlot }}
|
||||
<template v-if="settings.info" #info>{{ settings.info }}</template>
|
||||
</UiGroupSubcategory>
|
||||
</ComponentStory>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import { setting, slot } from '@/libs/story/story-param.ts'
|
||||
import { text } from '@/libs/story/story-widget.ts'
|
||||
import UiGroupSubcategory from '@core/components/ui/group-subcategory/UiGroupSubcategory.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,39 @@
|
||||
<template>
|
||||
<ComponentStory
|
||||
v-slot="{ properties, settings }"
|
||||
:params="[
|
||||
prop('accent').required().enum('brand', 'warning', 'danger').preset('brand').widget(),
|
||||
prop('size').required().enum('small', 'medium').preset('medium').widget(),
|
||||
prop('disabled').bool().widget(),
|
||||
prop('src').required().str().help('Image URL for rich mode'),
|
||||
prop('alt').required().str().help('Alt text for image'),
|
||||
model().type('string').preset(''),
|
||||
setting('defaultSlot').widget(text()).preset('Label'),
|
||||
]"
|
||||
>
|
||||
<div class="radio">
|
||||
<UiImageRadioButton v-model="selectedRadio" value="1" v-bind="properties" :src="imageUrl" :alt="properties.alt">
|
||||
{{ settings.defaultSlot }}
|
||||
</UiImageRadioButton>
|
||||
</div>
|
||||
</ComponentStory>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import { model, prop, setting } from '@/libs/story/story-param.ts'
|
||||
import { text } from '@/libs/story/story-widget.ts'
|
||||
import UiImageRadioButton from '@core/components/ui/image-radio-button/UiImageRadioButton.vue'
|
||||
import { ref } from 'vue'
|
||||
import imageUrl from '../../../../assets/color-mode-dark.svg'
|
||||
|
||||
const selectedRadio = ref('')
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.radio {
|
||||
display: flex;
|
||||
gap: 1.6rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
</style>
|
||||
@@ -10,16 +10,16 @@
|
||||
slot().help('Meant to receive a list of radio button components'),
|
||||
slot('label').help('Meant to receive a label UiLabel component or another component'),
|
||||
slot('info').help('Meant to receive a message info or UiInfo component or another component'),
|
||||
setting('richRadioButton').widget(boolean()),
|
||||
setting('imageRadioButton').widget(boolean()),
|
||||
]"
|
||||
>
|
||||
<UiRadioButtonGroup v-bind="properties">
|
||||
<component
|
||||
:is="settings.richRadioButton === true ? UiRichRadioButton : UiRadioButton"
|
||||
:is="settings.imageRadioButton === true ? UiImageRadioButton : UiRadioButton"
|
||||
v-for="(label, index) in labels"
|
||||
:key="index"
|
||||
v-model="selectedRadio"
|
||||
v-bind="richButtonProps(properties, settings.richRadioButton)"
|
||||
v-bind="imageButtonProps(properties, settings.imageRadioButton)"
|
||||
:value="`radio-${index}`"
|
||||
>
|
||||
{{ label }}
|
||||
@@ -32,9 +32,9 @@
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import { prop, setting, slot } from '@/libs/story/story-param.ts'
|
||||
import { boolean } from '@/libs/story/story-widget.ts'
|
||||
import UiImageRadioButton from '@core/components/ui/image-radio-button/UiImageRadioButton.vue'
|
||||
import UiRadioButton from '@core/components/ui/radio-button/UiRadioButton.vue'
|
||||
import UiRadioButtonGroup from '@core/components/ui/radio-button-group/UiRadioButtonGroup.vue'
|
||||
import UiRichRadioButton from '@core/components/ui/rich-radio-button/UiRichRadioButton.vue'
|
||||
import { ref } from 'vue'
|
||||
import imageUrl from '../../../../assets/color-mode-dark.svg'
|
||||
|
||||
@@ -42,8 +42,8 @@ const selectedRadio = ref('')
|
||||
|
||||
const labels = ref(['Label 1', 'Label 2', 'Label 3'])
|
||||
|
||||
const richButtonProps = (properties: any, richRadioButton: boolean) => {
|
||||
if (richRadioButton) {
|
||||
const imageButtonProps = (properties: any, imageRadioButton: boolean) => {
|
||||
if (imageRadioButton) {
|
||||
return {
|
||||
...properties,
|
||||
src: imageUrl,
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<ComponentStory
|
||||
v-slot="{ properties }"
|
||||
:params="[
|
||||
prop('accent').type('RichCheckboxAccent').required().enum('brand', 'warning', 'danger').preset('brand').widget(),
|
||||
prop('label').str().widget().preset('Backup repositories'),
|
||||
prop('info').str().widget(),
|
||||
prop('message').str().widget().help('Only displayed when the accent is not brand'),
|
||||
prop('vertical').bool().widget().preset(true),
|
||||
slot().help('Meant to receive UiRichCheckbox components, and UiGroupSubcategory components in vertical mode'),
|
||||
slot('label').help('Meant to receive a UiLabel component or another component'),
|
||||
slot('info').help('Meant to receive a UiInfo component or another component'),
|
||||
slot('message').help('Meant to receive a UiInfo component or another component'),
|
||||
]"
|
||||
>
|
||||
<UiRichCheckboxGroup v-bind="properties">
|
||||
<template v-for="category of properties.vertical ? categories : horizontalCategories" :key="category.title">
|
||||
<UiGroupSubcategory v-if="properties.vertical">
|
||||
{{ category.title }}
|
||||
<template v-if="category.info" #info>{{ category.info }}</template>
|
||||
</UiGroupSubcategory>
|
||||
<UiRichCheckbox
|
||||
v-for="option of category.options"
|
||||
:key="option.value"
|
||||
v-model="selectedRepositories"
|
||||
:accent="properties.accent"
|
||||
:value="option.value"
|
||||
:tag="option.tag"
|
||||
:description="option.description"
|
||||
:disabled="option.disabled"
|
||||
icon="fa:server"
|
||||
>
|
||||
{{ option.label }}
|
||||
</UiRichCheckbox>
|
||||
</template>
|
||||
</UiRichCheckboxGroup>
|
||||
</ComponentStory>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import { prop, slot } from '@/libs/story/story-param.ts'
|
||||
import UiGroupSubcategory from '@core/components/ui/group-subcategory/UiGroupSubcategory.vue'
|
||||
import UiRichCheckbox from '@core/components/ui/rich-checkbox/UiRichCheckbox.vue'
|
||||
import UiRichCheckboxGroup from '@core/components/ui/rich-checkbox-group/UiRichCheckboxGroup.vue'
|
||||
import { ref } from 'vue'
|
||||
|
||||
type StoryOption = {
|
||||
value: string
|
||||
label: string
|
||||
description: string
|
||||
tag?: string
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
const selectedRepositories = ref(['nfs-backups', 'smb-archive'])
|
||||
|
||||
const categories: { title: string; info?: string; options: StoryOption[] }[] = [
|
||||
{
|
||||
title: 'Category 1',
|
||||
options: [
|
||||
{ value: 'rd-s3', label: 'RD - S3', description: '3.1 TiB free', tag: 'Source' },
|
||||
{ value: 'nfs-backups', label: 'NFS backups', description: '4.2 TiB free' },
|
||||
{ value: 'local-backups', label: 'Local backups', description: '120 GiB free', disabled: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Category 2',
|
||||
info: 'Info',
|
||||
options: [{ value: 'smb-archive', label: 'SMB archive', description: '900 GiB free' }],
|
||||
},
|
||||
]
|
||||
|
||||
const horizontalCategories = categories.slice(0, 1)
|
||||
</script>
|
||||
@@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<ComponentStory
|
||||
v-slot="{ properties, settings }"
|
||||
:params="[
|
||||
prop('accent').type('RichCheckboxAccent').required().enum('brand', 'warning', 'danger').preset('brand').widget(),
|
||||
prop('value').str().help('Used when the model is an array'),
|
||||
iconProp(),
|
||||
prop('tag').str().widget().preset('Label'),
|
||||
prop('description').str().widget().preset('Description'),
|
||||
prop('info').str().widget(),
|
||||
prop('message').str().widget().help('Only displayed when the accent is not brand'),
|
||||
prop('disabled').bool().widget(),
|
||||
model().type('boolean | undefined | string[]').preset(undefined).help('undefined means partly checked'),
|
||||
slot().help('Meant to receive the label'),
|
||||
slot('tag').help('Meant to receive a UiTag component, to use another accent than the default info one'),
|
||||
slot('description'),
|
||||
slot('info'),
|
||||
slot('message'),
|
||||
setting('defaultSlot').widget(text()).preset('Label'),
|
||||
]"
|
||||
>
|
||||
<div class="checkbox">
|
||||
<UiRichCheckbox v-bind="properties">
|
||||
{{ settings.defaultSlot }}
|
||||
</UiRichCheckbox>
|
||||
</div>
|
||||
</ComponentStory>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import { iconProp, model, prop, setting, slot } from '@/libs/story/story-param.ts'
|
||||
import { text } from '@/libs/story/story-widget.ts'
|
||||
import UiRichCheckbox from '@core/components/ui/rich-checkbox/UiRichCheckbox.vue'
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.checkbox {
|
||||
max-width: 40rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<ComponentStory
|
||||
v-slot="{ properties }"
|
||||
:params="[
|
||||
prop('accent')
|
||||
.type('RichRadioButtonAccent')
|
||||
.required()
|
||||
.enum('brand', 'warning', 'danger')
|
||||
.preset('brand')
|
||||
.widget(),
|
||||
prop('label').str().widget().preset('Restore type'),
|
||||
prop('info').str().widget(),
|
||||
prop('message').str().widget().help('Only displayed when the accent is not brand'),
|
||||
prop('vertical').bool().widget().preset(true),
|
||||
slot().help('Meant to receive UiRichRadioButton components, and UiGroupSubcategory components in vertical mode'),
|
||||
slot('label').help('Meant to receive a UiLabel component or another component'),
|
||||
slot('info').help('Meant to receive a UiInfo component or another component'),
|
||||
slot('message').help('Meant to receive a UiInfo component or another component'),
|
||||
]"
|
||||
>
|
||||
<UiRichRadioButtonGroup v-bind="properties">
|
||||
<template v-for="category of properties.vertical ? categories : horizontalCategories" :key="category.title">
|
||||
<UiGroupSubcategory v-if="properties.vertical">
|
||||
{{ category.title }}
|
||||
<template #info>{{ category.info }}</template>
|
||||
</UiGroupSubcategory>
|
||||
<UiRichRadioButton
|
||||
v-for="option of category.options"
|
||||
:key="option.value"
|
||||
v-model="selectedRadio"
|
||||
:accent="properties.accent"
|
||||
:value="option.value"
|
||||
:icon="option.icon"
|
||||
:description="option.description"
|
||||
:disabled="option.disabled"
|
||||
>
|
||||
{{ option.label }}
|
||||
<template v-if="option.tag" #tag>
|
||||
<UiTag :accent="option.tag.accent" variant="secondary">{{ option.tag.label }}</UiTag>
|
||||
</template>
|
||||
</UiRichRadioButton>
|
||||
</template>
|
||||
</UiRichRadioButtonGroup>
|
||||
</ComponentStory>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import { prop, slot } from '@/libs/story/story-param.ts'
|
||||
import type { IconName } from '@core/icons'
|
||||
import UiGroupSubcategory from '@core/components/ui/group-subcategory/UiGroupSubcategory.vue'
|
||||
import UiRichRadioButton from '@core/components/ui/rich-radio-button/UiRichRadioButton.vue'
|
||||
import UiRichRadioButtonGroup from '@core/components/ui/rich-radio-button-group/UiRichRadioButtonGroup.vue'
|
||||
import UiTag, { type TagAccent } from '@core/components/ui/tag/UiTag.vue'
|
||||
import { ref } from 'vue'
|
||||
|
||||
type StoryOption = {
|
||||
value: string
|
||||
label: string
|
||||
description: string
|
||||
icon: IconName
|
||||
tag?: { label: string; accent: TagAccent }
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
const selectedRadio = ref('copy-then-start')
|
||||
|
||||
const categories: { title: string; info: string; options: StoryOption[] }[] = [
|
||||
{
|
||||
title: 'Into a pool',
|
||||
info: 'Writes to a pool',
|
||||
options: [
|
||||
{
|
||||
value: 'copy-then-start',
|
||||
label: 'Copy, then start',
|
||||
description:
|
||||
'Copy the disks to a storage of the pool, then start the VM. When a snapshot of the VM is still in the pool, only the blocks that differ are transferred, if possible.',
|
||||
icon: 'action:copy',
|
||||
tag: { label: 'Default', accent: 'info' },
|
||||
},
|
||||
{
|
||||
value: 'start-now',
|
||||
label: 'Start now',
|
||||
description: 'Start the VM right away from the backup. What it writes goes to a cache storage.',
|
||||
icon: 'status:running',
|
||||
tag: { label: 'Live restore', accent: 'neutral' },
|
||||
},
|
||||
{
|
||||
value: 'attach-disk',
|
||||
label: 'Attach a disk to a running VM',
|
||||
description: 'Serve a disk of the backup, read-only, to an existing VM. Nothing is copied.',
|
||||
icon: 'action:attach',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Out of the backup',
|
||||
info: 'Nothing written to a pool',
|
||||
options: [
|
||||
{
|
||||
value: 'download-files',
|
||||
label: 'Download files',
|
||||
description:
|
||||
'Browse a partition of a disk and download individual files or folders. Best for a small amount of data.',
|
||||
icon: 'action:download',
|
||||
},
|
||||
{
|
||||
value: 'export-disk',
|
||||
label: 'Export a disk',
|
||||
description: 'Convert one disk to qcow2, vmdk, vhd or raw, then download it.',
|
||||
icon: 'action:download',
|
||||
},
|
||||
{
|
||||
value: 'export-vm',
|
||||
label: 'Export the VM',
|
||||
description: 'Build an XVA from the backup, to import into XCP-ng or XenServer.',
|
||||
icon: 'action:download',
|
||||
disabled: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const horizontalCategories = categories.slice(0, 1)
|
||||
</script>
|
||||
@@ -2,17 +2,30 @@
|
||||
<ComponentStory
|
||||
v-slot="{ properties, settings }"
|
||||
:params="[
|
||||
prop('accent').required().enum('brand', 'warning', 'danger').preset('brand').widget(),
|
||||
prop('size').required().enum('small', 'medium').preset('medium').widget(),
|
||||
prop('accent')
|
||||
.type('RichRadioButtonAccent')
|
||||
.required()
|
||||
.enum('brand', 'warning', 'danger')
|
||||
.preset('brand')
|
||||
.widget(),
|
||||
iconProp(),
|
||||
prop('tag').str().widget().preset('Label'),
|
||||
prop('description').str().widget().preset('Description'),
|
||||
prop('info').str().widget(),
|
||||
prop('disabled').bool().widget(),
|
||||
prop('src').required().str().help('Image URL for rich mode'),
|
||||
prop('alt').required().str().help('Alt text for image'),
|
||||
model().type('string').preset(''),
|
||||
model().type('string'),
|
||||
slot().help('Meant to receive the label'),
|
||||
slot('tag').help('Meant to receive a UiTag component, to use another accent than the default info one'),
|
||||
slot('description'),
|
||||
slot('info'),
|
||||
setting('defaultSlot').widget(text()).preset('Label'),
|
||||
]"
|
||||
>
|
||||
<div class="radio">
|
||||
<UiRichRadioButton v-model="selectedRadio" value="1" v-bind="properties" :src="imageUrl" :alt="properties.alt">
|
||||
<div class="radios">
|
||||
<UiRichRadioButton v-model="selectedRadio" v-bind="properties" value="1">
|
||||
{{ settings.defaultSlot }}
|
||||
</UiRichRadioButton>
|
||||
<UiRichRadioButton v-model="selectedRadio" v-bind="properties" value="2">
|
||||
{{ settings.defaultSlot }}
|
||||
</UiRichRadioButton>
|
||||
</div>
|
||||
@@ -21,19 +34,19 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import { model, prop, setting } from '@/libs/story/story-param.ts'
|
||||
import { iconProp, model, prop, setting, slot } from '@/libs/story/story-param.ts'
|
||||
import { text } from '@/libs/story/story-widget.ts'
|
||||
import UiRichRadioButton from '@core/components/ui/rich-radio-button/UiRichRadioButton.vue'
|
||||
import { ref } from 'vue'
|
||||
import imageUrl from '../../../../assets/color-mode-dark.svg'
|
||||
|
||||
const selectedRadio = ref('')
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.radio {
|
||||
.radios {
|
||||
display: flex;
|
||||
gap: 1.6rem;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: column;
|
||||
gap: 0.8rem;
|
||||
max-width: 40rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -20,12 +20,15 @@
|
||||
setting('maxWidth').widget(number()).help('Maximum width, in rem'),
|
||||
]"
|
||||
>
|
||||
<UiTertiaryTag v-bind="properties" :style="{ maxWidth: settings.maxWidth ? `${settings.maxWidth}rem` : undefined }">
|
||||
<UiLabelValueTag
|
||||
v-bind="properties"
|
||||
:style="{ maxWidth: settings.maxWidth ? `${settings.maxWidth}rem` : undefined }"
|
||||
>
|
||||
{{ settings.slot }}
|
||||
<template #term>
|
||||
{{ settings.term }}
|
||||
</template>
|
||||
</UiTertiaryTag>
|
||||
</UiLabelValueTag>
|
||||
</ComponentStory>
|
||||
</template>
|
||||
|
||||
@@ -33,5 +36,5 @@
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import { prop, setting, slot } from '@/libs/story/story-param.ts'
|
||||
import { number } from '@/libs/story/story-widget.ts'
|
||||
import UiTertiaryTag from '@core/components/ui/tag/UiTertiaryTag.vue'
|
||||
import UiLabelValueTag from '@core/components/ui/tag/UiLabelValueTag.vue'
|
||||
</script>
|
||||
@@ -9,6 +9,7 @@
|
||||
.enum('brand', 'info', 'neutral', 'success', 'warning', 'danger', 'muted')
|
||||
.widget(),
|
||||
prop('variant').type('TagVariant').required().preset('primary').enum('primary', 'secondary').widget(),
|
||||
iconProp(),
|
||||
slot(),
|
||||
setting('slot').preset('Label').widget(),
|
||||
]"
|
||||
@@ -21,6 +22,6 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import { prop, setting, slot } from '@/libs/story/story-param.ts'
|
||||
import { iconProp, prop, setting, slot } from '@/libs/story/story-param.ts'
|
||||
import UiTag from '@core/components/ui/tag/UiTag.vue'
|
||||
</script>
|
||||
|
||||
@@ -8,18 +8,18 @@
|
||||
<UiTag accent="success" variant="primary">{{ settings.slot }}</UiTag>
|
||||
<UiTag accent="warning" variant="secondary">{{ settings.slot }}</UiTag>
|
||||
<UiTag accent="danger" variant="secondary">{{ settings.slot }}</UiTag>
|
||||
<UiTertiaryTag accent="info">
|
||||
<UiLabelValueTag accent="info">
|
||||
{{ settings.slot }}
|
||||
<template #term>
|
||||
{{ settings.slot }}
|
||||
</template>
|
||||
</UiTertiaryTag>
|
||||
<UiTertiaryTag accent="success">
|
||||
</UiLabelValueTag>
|
||||
<UiLabelValueTag accent="success">
|
||||
{{ settings.slot }}
|
||||
<template #term>
|
||||
{{ settings.slot }}
|
||||
</template>
|
||||
</UiTertiaryTag>
|
||||
</UiLabelValueTag>
|
||||
</UiTagsList>
|
||||
</ComponentStory>
|
||||
</template>
|
||||
@@ -27,7 +27,7 @@
|
||||
<script lang="ts" setup>
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import { setting, slot } from '@/libs/story/story-param.ts'
|
||||
import UiLabelValueTag from '@core/components/ui/tag/UiLabelValueTag.vue'
|
||||
import UiTag from '@core/components/ui/tag/UiTag.vue'
|
||||
import UiTagsList from '@core/components/ui/tag/UiTagsList.vue'
|
||||
import UiTertiaryTag from '@core/components/ui/tag/UiTertiaryTag.vue'
|
||||
</script>
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
import type { XenApiHost, XenApiNetwork, XenApiSr, XenApiVdi, XenApiVm } from '@/libs/xen-api/xen-api.types.ts'
|
||||
import type {
|
||||
XenApiHost,
|
||||
XenApiNetwork,
|
||||
XenApiSr,
|
||||
XenApiVbd,
|
||||
XenApiVdi,
|
||||
XenApiVm,
|
||||
} from '@/libs/xen-api/xen-api.types.ts'
|
||||
import { type OPAQUE_REF_NULL, type VDI_TYPE } from '@vates/types/common'
|
||||
|
||||
export interface Vdi {
|
||||
id?: XenApiVdi['$ref'] | undefined
|
||||
userdevice?: XenApiVbd['userdevice']
|
||||
name_label: string
|
||||
name_description: string
|
||||
size: number
|
||||
|
||||
@@ -37,12 +37,38 @@ function getBranchName() {
|
||||
}
|
||||
}
|
||||
|
||||
function getCommitHash() {
|
||||
try {
|
||||
return execSync('git rev-parse --short HEAD', { encoding: 'utf8', cwd: ROOT }).trim()
|
||||
} catch {
|
||||
return 'unknown'
|
||||
}
|
||||
}
|
||||
|
||||
function formatDatetime(date) {
|
||||
// "2026-05-20 08:42 UTC"
|
||||
return date
|
||||
.toISOString()
|
||||
.replace('T', ' ')
|
||||
.replace(/:\d{2}\.\d+Z$/, ' UTC')
|
||||
// "19/11/2026 13:43 (Paris)"
|
||||
return `${date.toLocaleString('fr-FR', {
|
||||
timeZone: 'Europe/Paris',
|
||||
dateStyle: 'short',
|
||||
timeStyle: 'short',
|
||||
})} (Paris)`
|
||||
}
|
||||
|
||||
function formatDuration(ms) {
|
||||
const hours = Math.floor(ms / 3600000)
|
||||
const minutes = Math.floor((ms / 60000) % 60)
|
||||
.toString()
|
||||
.padStart(2, '0')
|
||||
return `${hours}h${minutes}`
|
||||
}
|
||||
|
||||
function getCount(output, label) {
|
||||
const match = output.match(new RegExp(`ℹ ${label} (\\d+)`))
|
||||
if (match === null) {
|
||||
return '?'
|
||||
} else {
|
||||
return match[1]
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -123,14 +149,27 @@ if (process.argv.includes('--smtp-test')) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const branch = getBranchName()
|
||||
const commitHash = getCommitHash()
|
||||
const startedAt = new Date()
|
||||
|
||||
process.stderr.write(`[run-and-report] branch=${branch}\n`)
|
||||
|
||||
const { success, output, logFilePath } = await runTests()
|
||||
const runtimeInMs = Date.now() - startedAt.getTime()
|
||||
|
||||
const emoji = success ? '✅' : '❌'
|
||||
const status = success ? 'success' : 'failure'
|
||||
const subject = `test run ${formatDatetime(startedAt)} ${branch} ${status}`
|
||||
const successTests = getCount(output, 'pass')
|
||||
const totalTests = getCount(output, 'tests')
|
||||
const failedTests = getCount(output, 'fail')
|
||||
const cancelledTests = getCount(output, 'cancelled')
|
||||
const skippedTests = getCount(output, 'skipped')
|
||||
|
||||
const subject = `${emoji} ${status} ${successTests}/${totalTests} passed ${formatDatetime(startedAt)} on ${branch}@${commitHash}`
|
||||
const summary = `Result: ${emoji} ${status}
|
||||
Commit: ${branch}@${commitHash}
|
||||
Tests: ${successTests}/${totalTests} passed, ${failedTests} failed, ${cancelledTests} cancelled, ${skippedTests} skipped
|
||||
Duration: ${formatDuration(runtimeInMs)}`
|
||||
|
||||
// Attach the full structured debug log if we found its path
|
||||
const attachments = []
|
||||
@@ -149,7 +188,9 @@ await transport.sendMail({
|
||||
from: process.env.SMTP_FROM ?? process.env.SMTP_USER,
|
||||
to: process.env.SMTP_TO,
|
||||
subject,
|
||||
text: output,
|
||||
text: `${summary}
|
||||
----------------------------------------
|
||||
${output}`,
|
||||
attachments,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import {
|
||||
Body,
|
||||
Example,
|
||||
Extension,
|
||||
Get,
|
||||
Middlewares,
|
||||
Path,
|
||||
Post,
|
||||
Query,
|
||||
Request,
|
||||
Response,
|
||||
@@ -15,7 +13,6 @@ import {
|
||||
Tags,
|
||||
} from 'tsoa'
|
||||
import { inject } from 'inversify'
|
||||
import { json } from 'express'
|
||||
import { provide } from 'inversify-binding-decorators'
|
||||
import type { Request as ExRequest } from 'express'
|
||||
import type { XoApp, XoProxy } from '@vates/types'
|
||||
@@ -23,19 +20,14 @@ import type { XoApp, XoProxy } from '@vates/types'
|
||||
import { acl } from '../middlewares/acl.middleware.mjs'
|
||||
import { ApiError } from '../helpers/error.helper.mjs'
|
||||
import {
|
||||
asynchronousActionResp,
|
||||
badRequestResp,
|
||||
forbiddenOperationResp,
|
||||
incorrectStateResp,
|
||||
internalServerErrorResp,
|
||||
noContentResp,
|
||||
notFoundResp,
|
||||
proxyUnreachableResp,
|
||||
unauthorizedResp,
|
||||
type Unbrand,
|
||||
} from '../open-api/common/response.common.mjs'
|
||||
import type { CreateActionReturnType } from '../abstract-classes/base-controller.mjs'
|
||||
import { taskLocation } from '../open-api/oa-examples/task.oa-example.mjs'
|
||||
import {
|
||||
partialProxies,
|
||||
proxy,
|
||||
@@ -191,68 +183,4 @@ export class ProxyController extends XoController<XoProxy> {
|
||||
getProxyApplianceUpdaterState(@Path() id: string): ReturnType<XoApp['getProxyApplianceUpdaterState']> {
|
||||
return callProxy(this.restApi.xoApp.getProxyApplianceUpdaterState(id as XoProxy['id']))
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrades the proxy appliance
|
||||
*
|
||||
* By default, the upgrade is refused with an `incorrect state` error if backup jobs are running on the proxy.
|
||||
*
|
||||
* Set `force` to `true` to upgrade by rebooting the proxy VM, which also ignores running jobs. Only available if the
|
||||
* proxy VM is known. No privilege on the VM is checked: the `upgrade` action is enough to reboot it.
|
||||
*
|
||||
* Required privilege:
|
||||
* - resource: proxy, action: upgrade
|
||||
*
|
||||
* @example id "e625ea0c-a876-405a-b838-109d762efe88"
|
||||
* @example body { "force": false, "ignoreRunningJobs": false }
|
||||
*/
|
||||
@Example(taskLocation)
|
||||
@Extension('x-mcp-exposure', 'confirm')
|
||||
@Post('{id}/actions/upgrade')
|
||||
@Middlewares([
|
||||
json(),
|
||||
acl({
|
||||
resource: 'proxy',
|
||||
action: 'upgrade',
|
||||
objectId: 'params.id',
|
||||
getObject: ({ restApi }) => restApi.xoApp.getProxy,
|
||||
}),
|
||||
])
|
||||
@SuccessResponse(asynchronousActionResp.status, asynchronousActionResp.description)
|
||||
@Response(noContentResp.status, noContentResp.description)
|
||||
@Response(forbiddenOperationResp.status, forbiddenOperationResp.description)
|
||||
@Response(notFoundResp.status, notFoundResp.description)
|
||||
@Response(incorrectStateResp.status, incorrectStateResp.description)
|
||||
@Response(internalServerErrorResp.status, internalServerErrorResp.description)
|
||||
@Response(proxyUnreachableResp.status, proxyUnreachableResp.description)
|
||||
upgradeProxy(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
body?: {
|
||||
force?: boolean
|
||||
ignoreRunningJobs?: boolean
|
||||
},
|
||||
@Query() sync?: boolean
|
||||
): CreateActionReturnType<void> {
|
||||
const proxyId = id as XoProxy['id']
|
||||
const force = body?.force ?? false
|
||||
const opts = {
|
||||
force,
|
||||
ignoreRunningJobs: body?.ignoreRunningJobs ?? force,
|
||||
}
|
||||
|
||||
const action = async () => {
|
||||
await callProxy(this.restApi.xoApp.upgradeProxyAppliance(proxyId, opts))
|
||||
}
|
||||
|
||||
return this.createAction<void>(action, {
|
||||
sync,
|
||||
statusCode: noContentResp.status,
|
||||
taskProperties: {
|
||||
name: 'upgrade proxy appliance',
|
||||
objectId: proxyId,
|
||||
params: body,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ const unreachableErrors = [
|
||||
|
||||
function createController(result: () => Promise<unknown>) {
|
||||
const calls: unknown[] = []
|
||||
const tasks: unknown[] = []
|
||||
const record =
|
||||
(method: string) =>
|
||||
async (...args: unknown[]) => {
|
||||
@@ -24,20 +23,13 @@ function createController(result: () => Promise<unknown>) {
|
||||
return result()
|
||||
}
|
||||
const restApi = {
|
||||
tasks: {
|
||||
create: (properties: unknown) => {
|
||||
tasks.push(properties)
|
||||
return { id: 'task-1', properties, run: (fn: () => unknown) => fn() }
|
||||
},
|
||||
},
|
||||
xoApp: {
|
||||
checkProxyHealth: record('checkProxyHealth'),
|
||||
getProxyApplianceUpdaterState: record('getProxyApplianceUpdaterState'),
|
||||
upgradeProxyAppliance: record('upgradeProxyAppliance'),
|
||||
},
|
||||
} as unknown as RestApi
|
||||
const controller = new ProxyController(restApi)
|
||||
return { calls, controller, tasks }
|
||||
return { calls, controller }
|
||||
}
|
||||
|
||||
for (const [method, xoAppMethod, xoAppResult, expected] of [
|
||||
@@ -75,59 +67,3 @@ for (const [method, xoAppMethod, xoAppResult, expected] of [
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
describe('ProxyController.upgradeProxy', () => {
|
||||
it('upgrades in a task without force by default', async () => {
|
||||
const { calls, controller, tasks } = createController(async () => undefined)
|
||||
|
||||
await controller.upgradeProxy(proxyId, undefined, true)
|
||||
|
||||
assert.deepEqual(calls, [['upgradeProxyAppliance', proxyId, { force: false, ignoreRunningJobs: false }]])
|
||||
assert.deepEqual(tasks, [
|
||||
{
|
||||
name: 'REST API: upgrade proxy appliance',
|
||||
objectId: proxyId,
|
||||
objectType: 'proxy',
|
||||
params: undefined,
|
||||
type: 'xo:rest-api:action',
|
||||
},
|
||||
])
|
||||
assert.equal(controller.getStatus(), 204)
|
||||
})
|
||||
|
||||
it('ignores running jobs by default when forced', async () => {
|
||||
const { calls, controller } = createController(async () => undefined)
|
||||
|
||||
await controller.upgradeProxy(proxyId, { force: true }, true)
|
||||
|
||||
assert.deepEqual(calls, [['upgradeProxyAppliance', proxyId, { force: true, ignoreRunningJobs: true }]])
|
||||
})
|
||||
|
||||
it('forwards an explicit ignoreRunningJobs', async () => {
|
||||
const { calls, controller } = createController(async () => undefined)
|
||||
|
||||
await controller.upgradeProxy(proxyId, { force: true, ignoreRunningJobs: false }, true)
|
||||
|
||||
assert.deepEqual(calls, [['upgradeProxyAppliance', proxyId, { force: true, ignoreRunningJobs: false }]])
|
||||
})
|
||||
|
||||
it('returns the task id when not synchronous', async () => {
|
||||
const { controller } = createController(async () => undefined)
|
||||
|
||||
assert.deepEqual(await controller.upgradeProxy(proxyId), { taskId: 'task-1' })
|
||||
assert.equal(controller.getStatus(), 202)
|
||||
})
|
||||
|
||||
for (const unreachableError of unreachableErrors) {
|
||||
it(`throws a 502 ApiError on "${unreachableError.message}"`, async () => {
|
||||
const { controller } = createController(async () => {
|
||||
throw unreachableError
|
||||
})
|
||||
|
||||
await assert.rejects(
|
||||
controller.upgradeProxy(proxyId, undefined, true),
|
||||
error => error instanceof ApiError && error.status === 502 && error.message === 'Proxy unreachable'
|
||||
)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
:root {
|
||||
--color-logo: #282467;
|
||||
|
||||
/* NEUTRALS */
|
||||
|
||||
--color-neutral-txt-primary: #1a1b38;
|
||||
@@ -31,6 +29,7 @@
|
||||
--color-brand-item-hover: color-mix(in srgb, #ffffff 20%, var(--color-brand-item-base));
|
||||
--color-brand-item-active: color-mix(in srgb, #ffffff 40%, var(--color-brand-item-base));
|
||||
--color-brand-item-disabled: #d2ceff;
|
||||
--color-brand-data: #8a80ff;
|
||||
|
||||
/* INFO */
|
||||
|
||||
@@ -47,6 +46,7 @@
|
||||
--color-info-item-hover: color-mix(in srgb, #ffffff 20%, var(--color-info-item-base));
|
||||
--color-info-item-active: color-mix(in srgb, #ffffff 40%, var(--color-info-item-base));
|
||||
--color-info-item-disabled: #abdafa;
|
||||
--color-info-data: #1498f0;
|
||||
|
||||
/* SUCCESS */
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
--color-success-item-hover: color-mix(in srgb, #ffffff 20%, var(--color-success-item-base));
|
||||
--color-success-item-active: color-mix(in srgb, #ffffff 40%, var(--color-success-item-base));
|
||||
--color-success-item-disabled: #abdcc9;
|
||||
--color-success-data: #2ca577;
|
||||
|
||||
/* WARNING */
|
||||
|
||||
@@ -79,6 +80,7 @@
|
||||
--color-warning-item-hover: color-mix(in srgb, #ffffff 20%, var(--color-warning-item-base));
|
||||
--color-warning-item-active: color-mix(in srgb, #ffffff 40%, var(--color-warning-item-base));
|
||||
--color-warning-item-disabled: #f9cca3;
|
||||
--color-warning-data: #e07410;
|
||||
|
||||
/* DANGER */
|
||||
|
||||
@@ -86,20 +88,20 @@
|
||||
--color-danger-txt-hover: color-mix(in srgb, #000000 20%, var(--color-danger-txt-base));
|
||||
--color-danger-txt-active: color-mix(in srgb, #000000 40%, var(--color-danger-txt-base));
|
||||
|
||||
--color-danger-background-selected: color-mix(in srgb, #ffffff 90%, var(--color-danger-item-base));
|
||||
--color-danger-background-hover: color-mix(in srgb, #ffffff 80%, var(--color-danger-item-base));
|
||||
--color-danger-background-active: color-mix(in srgb, #ffffff 70%, var(--color-danger-item-base));
|
||||
--color-danger-background-base: #e73642;
|
||||
--color-danger-background-selected: color-mix(in srgb, #ffffff 90%, var(--color-danger-background-base));
|
||||
--color-danger-background-hover: color-mix(in srgb, #ffffff 80%, var(--color-danger-background-base));
|
||||
--color-danger-background-active: color-mix(in srgb, #ffffff 70%, var(--color-danger-background-base));
|
||||
|
||||
--color-danger-txt-item: #fff0f1;
|
||||
--color-danger-item-base: #be1621;
|
||||
--color-danger-item-hover: color-mix(in srgb, #000000 20%, var(--color-danger-item-base));
|
||||
--color-danger-item-active: color-mix(in srgb, #000000 40%, var(--color-danger-item-base));
|
||||
--color-danger-item-disabled: #e5a2a6;
|
||||
--color-danger-data: #be1621;
|
||||
}
|
||||
|
||||
:root.dark {
|
||||
--color-logo: #e5e5e7;
|
||||
|
||||
/* NEUTRALS */
|
||||
|
||||
--color-neutral-txt-primary: #f8f8f8;
|
||||
@@ -130,6 +132,7 @@
|
||||
--color-brand-item-hover: color-mix(in srgb, #ffffff 20%, var(--color-brand-item-base));
|
||||
--color-brand-item-active: color-mix(in srgb, #ffffff 40%, var(--color-brand-item-base));
|
||||
--color-brand-item-disabled: #393566;
|
||||
--color-brand-data: #8f84ff;
|
||||
|
||||
/* INFO */
|
||||
|
||||
@@ -146,6 +149,7 @@
|
||||
--color-info-item-hover: color-mix(in srgb, #ffffff 20%, var(--color-info-item-base));
|
||||
--color-info-item-active: color-mix(in srgb, #ffffff 40%, var(--color-info-item-base));
|
||||
--color-info-item-disabled: #124161;
|
||||
--color-info-data: #2ca3f2;
|
||||
|
||||
/* SUCCESS */
|
||||
|
||||
@@ -153,15 +157,16 @@
|
||||
--color-success-txt-hover: color-mix(in srgb, #ffffff 20%, var(--color-success-txt-base));
|
||||
--color-success-txt-active: color-mix(in srgb, #ffffff 40%, var(--color-success-txt-base));
|
||||
|
||||
--color-success-background-selected: color-mix(in srgb, #000000 70%, var(--color-success-txt-base));
|
||||
--color-success-background-hover: color-mix(in srgb, #000000 60%, var(--color-success-txt-base));
|
||||
--color-success-background-active: color-mix(in srgb, #000000 50%, var(--color-success-txt-base));
|
||||
--color-success-background-selected: color-mix(in srgb, #000000 70%, var(--color-success-item-base));
|
||||
--color-success-background-hover: color-mix(in srgb, #000000 60%, var(--color-success-item-base));
|
||||
--color-success-background-active: color-mix(in srgb, #000000 50%, var(--color-success-item-base));
|
||||
|
||||
--color-success-txt-item: #092017;
|
||||
--color-success-item-base: #2ca878;
|
||||
--color-success-item-hover: color-mix(in srgb, #ffffff 20%, var(--color-success-item-base));
|
||||
--color-success-item-active: color-mix(in srgb, #ffffff 40%, var(--color-success-item-base));
|
||||
--color-success-item-disabled: #124330;
|
||||
--color-success-data: #2ca878;
|
||||
|
||||
/* WARNING */
|
||||
|
||||
@@ -169,15 +174,16 @@
|
||||
--color-warning-txt-hover: color-mix(in srgb, #ffffff 20%, var(--color-warning-txt-base));
|
||||
--color-warning-txt-active: color-mix(in srgb, #ffffff 40%, var(--color-warning-txt-base));
|
||||
|
||||
--color-warning-background-selected: color-mix(in srgb, #000000 70%, var(--color-warning-txt-base));
|
||||
--color-warning-background-hover: color-mix(in srgb, #000000 60%, var(--color-warning-txt-base));
|
||||
--color-warning-background-active: color-mix(in srgb, #000000 50%, var(--color-warning-txt-base));
|
||||
--color-warning-background-selected: color-mix(in srgb, #000000 70%, var(--color-warning-item-base));
|
||||
--color-warning-background-hover: color-mix(in srgb, #000000 60%, var(--color-warning-item-base));
|
||||
--color-warning-background-active: color-mix(in srgb, #000000 50%, var(--color-warning-item-base));
|
||||
|
||||
--color-warning-txt-item: #261403;
|
||||
--color-warning-item-base: #ef7f18;
|
||||
--color-warning-item-hover: color-mix(in srgb, #ffffff 20%, var(--color-warning-item-base));
|
||||
--color-warning-item-active: color-mix(in srgb, #ffffff 40%, var(--color-warning-item-base));
|
||||
--color-warning-item-disabled: #60330a;
|
||||
--color-warning-data: #ef7f18;
|
||||
|
||||
/* DANGER */
|
||||
|
||||
@@ -185,13 +191,15 @@
|
||||
--color-danger-txt-hover: color-mix(in srgb, #ffffff 20%, var(--color-danger-txt-base));
|
||||
--color-danger-txt-active: color-mix(in srgb, #ffffff 40%, var(--color-danger-txt-base));
|
||||
|
||||
--color-danger-background-selected: color-mix(in srgb, #000000 70%, var(--color-danger-txt-base));
|
||||
--color-danger-background-hover: color-mix(in srgb, #000000 60%, var(--color-danger-txt-base));
|
||||
--color-danger-background-active: color-mix(in srgb, #000000 50%, var(--color-danger-txt-base));
|
||||
--color-danger-background-base: #e73642;
|
||||
--color-danger-background-selected: color-mix(in srgb, #000000 70%, var(--color-danger-background-base));
|
||||
--color-danger-background-hover: color-mix(in srgb, #000000 60%, var(--color-danger-background-base));
|
||||
--color-danger-background-active: color-mix(in srgb, #000000 50%, var(--color-danger-background-base));
|
||||
|
||||
--color-danger-txt-item: #fff0f1;
|
||||
--color-danger-item-base: #be1621;
|
||||
--color-danger-item-hover: color-mix(in srgb, #000000 20%, var(--color-danger-item-base));
|
||||
--color-danger-item-active: color-mix(in srgb, #000000 40%, var(--color-danger-item-base));
|
||||
--color-danger-item-disabled: #4c090d;
|
||||
--color-danger-data: #c41723;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
* Default theme is defined in web-core/_colors.pcss
|
||||
*/
|
||||
|
||||
/* Data colors are tuned for the default theme only: themed charts keep each theme's own accent colors */
|
||||
:root:is(.theme-nord, .theme-solarized, .theme-dracula, .theme-monokai) {
|
||||
--color-brand-data: var(--color-brand-item-base);
|
||||
--color-info-data: var(--color-info-item-base);
|
||||
--color-success-data: var(--color-success-item-base);
|
||||
--color-warning-data: var(--color-warning-item-base);
|
||||
--color-danger-data: var(--color-danger-item-base);
|
||||
}
|
||||
|
||||
/*
|
||||
* Nord Theme - Light Mode
|
||||
* An arctic, north-bluish color palette
|
||||
@@ -14,8 +23,6 @@
|
||||
* Aurora: #bf616a (red), #d08770 (orange), #ebcb8b (yellow), #a3be8c (green), #b48ead (purple)
|
||||
*/
|
||||
:root.theme-nord {
|
||||
--color-logo: #5e81ac;
|
||||
|
||||
/* NEUTRALS */
|
||||
--color-neutral-txt-primary: #2e3440;
|
||||
--color-neutral-txt-secondary: #4c566a;
|
||||
@@ -109,8 +116,6 @@
|
||||
* Nord Theme - Dark Mode
|
||||
*/
|
||||
:root.dark.theme-nord {
|
||||
--color-logo: #88c0d0;
|
||||
|
||||
/* NEUTRALS */
|
||||
--color-neutral-txt-primary: #eceff4;
|
||||
--color-neutral-txt-secondary: #d8dee9;
|
||||
@@ -210,8 +215,6 @@
|
||||
* violet #6c71c4, blue #268bd2, cyan #2aa198, green #859900
|
||||
*/
|
||||
:root.theme-solarized {
|
||||
--color-logo: #268bd2;
|
||||
|
||||
/* NEUTRALS */
|
||||
--color-neutral-txt-primary: #657b83;
|
||||
--color-neutral-txt-secondary: #93a1a1;
|
||||
@@ -305,8 +308,6 @@
|
||||
* Solarized Theme - Dark Mode
|
||||
*/
|
||||
:root.dark.theme-solarized {
|
||||
--color-logo: #268bd2;
|
||||
|
||||
/* NEUTRALS */
|
||||
--color-neutral-txt-primary: #839496;
|
||||
--color-neutral-txt-secondary: #586e75;
|
||||
@@ -406,8 +407,6 @@
|
||||
* Purple: #bd93f9, Red: #ff5555, Yellow: #f1fa8c
|
||||
*/
|
||||
:root.theme-dracula {
|
||||
--color-logo: #bd93f9;
|
||||
|
||||
/* NEUTRALS */
|
||||
--color-neutral-txt-primary: #282a36;
|
||||
--color-neutral-txt-secondary: #44475a;
|
||||
@@ -501,8 +500,6 @@
|
||||
* Dracula Theme - Dark Mode
|
||||
*/
|
||||
:root.dark.theme-dracula {
|
||||
--color-logo: #bd93f9;
|
||||
|
||||
/* NEUTRALS */
|
||||
--color-neutral-txt-primary: #f8f8f2;
|
||||
--color-neutral-txt-secondary: #6272a4;
|
||||
@@ -601,8 +598,6 @@
|
||||
* Pink: #f92672, Green: #a6e22e, Blue: #66d9ef, Orange: #fd971f, Purple: #ae81ff
|
||||
*/
|
||||
:root.theme-monokai {
|
||||
--color-logo: #f92672;
|
||||
|
||||
/* NEUTRALS */
|
||||
--color-neutral-txt-primary: #272822;
|
||||
--color-neutral-txt-secondary: #75715e;
|
||||
@@ -696,8 +691,6 @@
|
||||
* Monokai Theme - Dark Mode
|
||||
*/
|
||||
:root.dark.theme-monokai {
|
||||
--color-logo: #f92672;
|
||||
|
||||
/* NEUTRALS */
|
||||
--color-neutral-txt-primary: #f8f8f2;
|
||||
--color-neutral-txt-secondary: #a8a8a0;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<UiTertiaryTag
|
||||
<UiLabelValueTag
|
||||
v-if="parsedTag"
|
||||
ref="tertiaryTag"
|
||||
v-tooltip="isTertiaryTagTruncated && value"
|
||||
ref="labelValueTag"
|
||||
v-tooltip="isLabelValueTagTruncated && value"
|
||||
:accent
|
||||
:removable
|
||||
:truncate="!wrap"
|
||||
@@ -11,7 +11,7 @@
|
||||
>
|
||||
<template #term>{{ parsedTag.term }}</template>
|
||||
{{ parsedTag.label }}
|
||||
</UiTertiaryTag>
|
||||
</UiLabelValueTag>
|
||||
<UiTag
|
||||
v-else
|
||||
v-tooltip
|
||||
@@ -28,8 +28,8 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import UiLabelValueTag from '@core/components/ui/tag/UiLabelValueTag.vue'
|
||||
import UiTag, { type TagAccent } from '@core/components/ui/tag/UiTag.vue'
|
||||
import UiTertiaryTag from '@core/components/ui/tag/UiTertiaryTag.vue'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive.ts'
|
||||
import { hasEllipsis } from '@core/utils/has-ellipsis.util.ts'
|
||||
import { parseTag } from '@core/utils/parse-tag.util.ts'
|
||||
@@ -61,23 +61,23 @@ const parsedTag = computed(() => parseTag(value))
|
||||
|
||||
const isEmpty = computed(() => value.trim() === '')
|
||||
|
||||
const tertiaryTag = useTemplateRef('tertiaryTag')
|
||||
const labelValueTag = useTemplateRef('labelValueTag')
|
||||
|
||||
const tertiaryTagElement = computed(() => tertiaryTag.value?.$el as HTMLElement | undefined)
|
||||
const labelValueTagElement = computed(() => labelValueTag.value?.$el as HTMLElement | undefined)
|
||||
|
||||
const isTertiaryTagTruncated = ref(false)
|
||||
const isLabelValueTagTruncated = ref(false)
|
||||
|
||||
function updateTertiaryTagTruncation() {
|
||||
const element = tertiaryTagElement.value
|
||||
function updateLabelValueTagTruncation() {
|
||||
const element = labelValueTagElement.value
|
||||
|
||||
isTertiaryTagTruncated.value = element !== undefined && [...element.children].some(part => hasEllipsis(part))
|
||||
isLabelValueTagTruncated.value = element !== undefined && [...element.children].some(part => hasEllipsis(part))
|
||||
}
|
||||
|
||||
useResizeObserver(tertiaryTagElement, () => updateTertiaryTagTruncation())
|
||||
useResizeObserver(labelValueTagElement, () => updateLabelValueTagTruncation())
|
||||
|
||||
watch(
|
||||
() => value,
|
||||
() => updateTertiaryTagTruncation(),
|
||||
() => updateLabelValueTagTruncation(),
|
||||
{ flush: 'post' }
|
||||
)
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import VtsIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import UiCheckbox from '@core/components/ui/checkbox/UiCheckbox.vue'
|
||||
import type { CheckboxModel } from '@core/composables/checkbox-state.composable.ts'
|
||||
import { createGlobalTestConfig } from '@core-test/create-global-test-config.ts'
|
||||
import { mount } from '@vue/test-utils'
|
||||
|
||||
type CheckboxProps = {
|
||||
accent?: 'brand' | 'warning' | 'danger'
|
||||
modelValue?: CheckboxModel
|
||||
value?: string
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
function mountCheckbox(props: CheckboxProps = {}) {
|
||||
return mount(UiCheckbox, {
|
||||
global: createGlobalTestConfig(),
|
||||
props: { accent: 'brand', modelValue: false, ...props },
|
||||
slots: { default: 'Auto power on' },
|
||||
})
|
||||
}
|
||||
|
||||
it('shows a partly checked model on the checkbox and the input', () => {
|
||||
const wrapper = mountCheckbox({ modelValue: undefined })
|
||||
|
||||
expect(wrapper.getComponent(VtsIcon).props('name')).toBe('status:checkbox-partially-checked')
|
||||
expect(wrapper.get('input').element.indeterminate).toBe(true)
|
||||
})
|
||||
|
||||
it('adds its value to an array model', async () => {
|
||||
const wrapper = mountCheckbox({ modelValue: ['s3'], value: 'nfs' })
|
||||
|
||||
await wrapper.get('input').setValue(true)
|
||||
|
||||
expect(wrapper.emitted('update:modelValue')).toEqual([[['s3', 'nfs']]])
|
||||
})
|
||||
|
||||
it('reads its value in an array model', () => {
|
||||
const icon = mountCheckbox({ modelValue: ['nfs'], value: 'nfs' }).getComponent(VtsIcon)
|
||||
|
||||
expect(icon.props('name')).toBe('status:checkbox-checked')
|
||||
})
|
||||
|
||||
it('applies the disabled variant to the label and disables the input', () => {
|
||||
const wrapper = mountCheckbox({ disabled: true })
|
||||
|
||||
expect(wrapper.get('.checkbox-label').classes()).toContain('disabled')
|
||||
expect(wrapper.get('input').attributes()).toHaveProperty('disabled')
|
||||
})
|
||||
@@ -1,17 +1,18 @@
|
||||
<!-- v8 -->
|
||||
<!-- v9 -->
|
||||
<template>
|
||||
<div class="ui-checkbox">
|
||||
<label :class="classNames" class="checkbox-label" v-bind="wrapperAttrs">
|
||||
<input
|
||||
v-model="checkboxModel"
|
||||
:class="{ indeterminate: isIndeterminate }"
|
||||
:disabled="isDisabled"
|
||||
:indeterminate="isIndeterminate"
|
||||
:value
|
||||
class="input"
|
||||
type="checkbox"
|
||||
v-bind="attrs"
|
||||
/>
|
||||
<span class="fake-checkbox">
|
||||
<VtsIcon :name="icon" size="medium" class="icon" />
|
||||
<VtsIcon :name="icon" size="medium" />
|
||||
</span>
|
||||
<span v-if="slots.default" class="typo-body-regular">
|
||||
<slot />
|
||||
@@ -29,6 +30,7 @@
|
||||
<script lang="ts" setup>
|
||||
import VtsIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import UiInfo from '@core/components/ui/info/UiInfo.vue'
|
||||
import { type CheckboxModel, useCheckboxState } from '@core/composables/checkbox-state.composable.ts'
|
||||
import { useDisabled } from '@core/composables/disabled.composable.ts'
|
||||
import { toVariants } from '@core/utils/to-variants.util.ts'
|
||||
import { computed, type LabelHTMLAttributes, useAttrs } from 'vue'
|
||||
@@ -37,13 +39,14 @@ type CheckboxAccent = 'brand' | 'warning' | 'danger'
|
||||
|
||||
defineOptions({ inheritAttrs: false })
|
||||
|
||||
const { accent, disabled } = defineProps<{
|
||||
const { accent, value, disabled } = defineProps<{
|
||||
accent: CheckboxAccent
|
||||
value?: string
|
||||
disabled?: boolean
|
||||
wrapperAttrs?: LabelHTMLAttributes
|
||||
}>()
|
||||
|
||||
const checkboxModel = defineModel<boolean | undefined | string[]>({ default: undefined })
|
||||
const checkboxModel = defineModel<CheckboxModel>({ default: undefined })
|
||||
|
||||
const slots = defineSlots<{
|
||||
default?(): any
|
||||
@@ -60,9 +63,7 @@ const classNames = computed(() => [
|
||||
}),
|
||||
])
|
||||
|
||||
const isIndeterminate = computed(() => checkboxModel.value === undefined)
|
||||
|
||||
const icon = computed(() => (isIndeterminate.value ? 'fa:minus' : 'fa:check'))
|
||||
const { isIndeterminate, icon } = useCheckboxState(checkboxModel, () => value)
|
||||
|
||||
const attrs = useAttrs()
|
||||
</script>
|
||||
@@ -79,23 +80,11 @@ const attrs = useAttrs()
|
||||
gap: 0.4rem;
|
||||
|
||||
.fake-checkbox {
|
||||
--checkbox-mark-color: var(--color-neutral-background-primary);
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 1.6rem;
|
||||
width: 1.6rem;
|
||||
transition:
|
||||
background-color 0.125s ease-in-out,
|
||||
border-color 0.125s ease-in-out;
|
||||
border: 0.2rem solid transparent;
|
||||
border-radius: 0.2rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
.icon {
|
||||
font-size: 0.75rem;
|
||||
color: var(--color-neutral-background-primary);
|
||||
transition: opacity 0.125s ease-in-out;
|
||||
}
|
||||
transition: color 0.125s ease-in-out;
|
||||
}
|
||||
|
||||
.input {
|
||||
@@ -104,19 +93,6 @@ const attrs = useAttrs()
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
|
||||
&.indeterminate + .fake-checkbox > .icon {
|
||||
opacity: 1;
|
||||
color: var(--color-neutral-background-primary);
|
||||
}
|
||||
|
||||
& + .fake-checkbox > .icon {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
&:checked + .fake-checkbox > .icon {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
&:focus-visible + .fake-checkbox {
|
||||
outline: none;
|
||||
|
||||
@@ -124,9 +100,8 @@ const attrs = useAttrs()
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -0.5rem;
|
||||
border: 0.2rem solid var(--color-brand-txt-base);
|
||||
border-radius: 0.4rem;
|
||||
border-width: 0.2rem;
|
||||
border-style: solid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,50 +109,15 @@ const attrs = useAttrs()
|
||||
&.accent--brand {
|
||||
.input:not(:disabled) {
|
||||
& + .fake-checkbox {
|
||||
border-color: var(--color-brand-txt-base);
|
||||
}
|
||||
|
||||
&.indeterminate + .fake-checkbox {
|
||||
background-color: var(--color-brand-txt-base);
|
||||
|
||||
&:hover {
|
||||
border-color: transparent;
|
||||
background-color: var(--color-brand-txt-hover);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background-color: var(--color-brand-txt-active);
|
||||
}
|
||||
}
|
||||
|
||||
&.indeterminate:hover + .fake-checkbox {
|
||||
border-color: transparent;
|
||||
background-color: var(--color-brand-txt-hover);
|
||||
color: var(--color-brand-txt-base);
|
||||
}
|
||||
|
||||
&:hover + .fake-checkbox {
|
||||
border-color: var(--color-brand-txt-hover);
|
||||
}
|
||||
|
||||
&:focus-visible + .fake-checkbox::before {
|
||||
border: 0.2rem solid var(--color-brand-txt-base);
|
||||
color: var(--color-brand-txt-hover);
|
||||
}
|
||||
|
||||
&:active + .fake-checkbox {
|
||||
border-color: var(--color-brand-txt-active);
|
||||
}
|
||||
|
||||
&:checked + .fake-checkbox {
|
||||
border-color: transparent;
|
||||
background-color: var(--color-brand-txt-base);
|
||||
}
|
||||
|
||||
&:checked:hover + .fake-checkbox {
|
||||
background-color: var(--color-brand-txt-hover);
|
||||
}
|
||||
|
||||
&:checked:active + .fake-checkbox {
|
||||
background-color: var(--color-brand-txt-active);
|
||||
color: var(--color-brand-txt-active);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,50 +125,15 @@ const attrs = useAttrs()
|
||||
&.accent--warning {
|
||||
.input:not(:disabled) {
|
||||
& + .fake-checkbox {
|
||||
border-color: var(--color-warning-txt-base);
|
||||
}
|
||||
|
||||
&.indeterminate + .fake-checkbox {
|
||||
background-color: var(--color-warning-txt-base);
|
||||
|
||||
&:hover {
|
||||
border-color: transparent;
|
||||
background-color: var(--color-warning-txt-hover);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background-color: var(--color-warning-txt-active);
|
||||
}
|
||||
}
|
||||
|
||||
&.indeterminate:hover + .fake-checkbox {
|
||||
border-color: transparent;
|
||||
background-color: var(--color-warning-txt-hover);
|
||||
color: var(--color-warning-txt-base);
|
||||
}
|
||||
|
||||
&:hover + .fake-checkbox {
|
||||
border-color: var(--color-warning-txt-hover);
|
||||
}
|
||||
|
||||
&:focus-visible + .fake-checkbox::before {
|
||||
border: 0.2rem solid var(--color-brand-txt-base);
|
||||
color: var(--color-warning-txt-hover);
|
||||
}
|
||||
|
||||
&:active + .fake-checkbox {
|
||||
border-color: var(--color-warning-txt-active);
|
||||
}
|
||||
|
||||
&:checked + .fake-checkbox {
|
||||
border-color: transparent;
|
||||
background-color: var(--color-warning-txt-base);
|
||||
}
|
||||
|
||||
&:checked:hover + .fake-checkbox {
|
||||
background-color: var(--color-warning-txt-hover);
|
||||
}
|
||||
|
||||
&:checked:active + .fake-checkbox {
|
||||
background-color: var(--color-warning-txt-active);
|
||||
color: var(--color-warning-txt-active);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,73 +141,27 @@ const attrs = useAttrs()
|
||||
&.accent--danger {
|
||||
.input:not(:disabled) {
|
||||
& + .fake-checkbox {
|
||||
border-color: var(--color-danger-txt-base);
|
||||
|
||||
> .icon {
|
||||
color: var(--color-danger-txt-item);
|
||||
}
|
||||
}
|
||||
|
||||
&.indeterminate + .fake-checkbox {
|
||||
background-color: var(--color-danger-txt-base);
|
||||
|
||||
&:hover {
|
||||
border-color: transparent;
|
||||
background-color: var(--color-danger-txt-hover);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background-color: var(--color-danger-txt-active);
|
||||
}
|
||||
}
|
||||
|
||||
&.indeterminate:hover + .fake-checkbox {
|
||||
border-color: transparent;
|
||||
background-color: var(--color-danger-txt-hover);
|
||||
color: var(--color-danger-txt-base);
|
||||
}
|
||||
|
||||
&:hover + .fake-checkbox {
|
||||
border-color: var(--color-danger-txt-hover);
|
||||
}
|
||||
|
||||
&:focus-visible + .fake-checkbox::before {
|
||||
border: 0.2rem solid var(--color-brand-txt-base);
|
||||
color: var(--color-danger-txt-hover);
|
||||
}
|
||||
|
||||
&:active + .fake-checkbox {
|
||||
border-color: var(--color-danger-txt-active);
|
||||
}
|
||||
|
||||
&:checked + .fake-checkbox {
|
||||
border-color: transparent;
|
||||
background-color: var(--color-danger-txt-base);
|
||||
}
|
||||
|
||||
&:checked:hover + .fake-checkbox {
|
||||
background-color: var(--color-danger-txt-hover);
|
||||
}
|
||||
|
||||
&:checked:active + .fake-checkbox {
|
||||
background-color: var(--color-danger-txt-active);
|
||||
color: var(--color-danger-txt-active);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.input:disabled {
|
||||
& + .fake-checkbox {
|
||||
cursor: not-allowed;
|
||||
border-color: var(--color-neutral-txt-secondary);
|
||||
&.disabled {
|
||||
color: var(--color-neutral-txt-secondary);
|
||||
}
|
||||
|
||||
> .icon {
|
||||
color: var(--color-neutral-background-disabled);
|
||||
}
|
||||
}
|
||||
|
||||
&:checked + .fake-checkbox,
|
||||
&.indeterminate + .fake-checkbox {
|
||||
border-color: transparent;
|
||||
background-color: var(--color-neutral-txt-secondary);
|
||||
}
|
||||
.input:disabled + .fake-checkbox {
|
||||
--checkbox-mark-color: var(--color-neutral-background-disabled);
|
||||
color: var(--color-neutral-txt-secondary);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ const className = computed(() => [
|
||||
color: var(--color-brand-item-base);
|
||||
|
||||
.fill {
|
||||
stroke: var(--color-brand-item-base);
|
||||
stroke: var(--color-brand-data);
|
||||
}
|
||||
|
||||
.background {
|
||||
@@ -129,7 +129,7 @@ const className = computed(() => [
|
||||
color: var(--color-info-item-base);
|
||||
|
||||
.fill {
|
||||
stroke: var(--color-info-item-base);
|
||||
stroke: var(--color-info-data);
|
||||
}
|
||||
|
||||
.background {
|
||||
@@ -137,7 +137,7 @@ const className = computed(() => [
|
||||
}
|
||||
|
||||
.success {
|
||||
stroke: var(--color-success-item-base);
|
||||
stroke: var(--color-success-data);
|
||||
}
|
||||
|
||||
.icon {
|
||||
@@ -149,7 +149,7 @@ const className = computed(() => [
|
||||
color: var(--color-warning-item-base);
|
||||
|
||||
.fill {
|
||||
stroke: var(--color-warning-item-base);
|
||||
stroke: var(--color-warning-data);
|
||||
}
|
||||
|
||||
.background {
|
||||
@@ -161,7 +161,7 @@ const className = computed(() => [
|
||||
color: var(--color-danger-item-base);
|
||||
|
||||
.fill {
|
||||
stroke: var(--color-danger-item-base);
|
||||
stroke: var(--color-danger-data);
|
||||
}
|
||||
|
||||
.background {
|
||||
|
||||
@@ -80,7 +80,7 @@ const computedSegments = computed(() => {
|
||||
fill: transparent;
|
||||
|
||||
&.accent--info {
|
||||
stroke: var(--color-info-item-base);
|
||||
stroke: var(--color-info-data);
|
||||
}
|
||||
|
||||
&.accent--secondary {
|
||||
@@ -88,15 +88,15 @@ const computedSegments = computed(() => {
|
||||
}
|
||||
|
||||
&.accent--success {
|
||||
stroke: var(--color-success-item-base);
|
||||
stroke: var(--color-success-data);
|
||||
}
|
||||
|
||||
&.accent--warning {
|
||||
stroke: var(--color-warning-item-base);
|
||||
stroke: var(--color-warning-data);
|
||||
}
|
||||
|
||||
&.accent--danger {
|
||||
stroke: var(--color-danger-item-base);
|
||||
stroke: var(--color-danger-data);
|
||||
}
|
||||
|
||||
&.accent--muted {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import UiGroupSubcategory from '@core/components/ui/group-subcategory/UiGroupSubcategory.vue'
|
||||
import { createGlobalTestConfig } from '@core-test/create-global-test-config.ts'
|
||||
import { mount } from '@vue/test-utils'
|
||||
|
||||
function mountGroupSubcategory(slots: Record<string, string> = {}) {
|
||||
return mount(UiGroupSubcategory, {
|
||||
global: createGlobalTestConfig(),
|
||||
slots: { default: 'Into a pool', ...slots },
|
||||
})
|
||||
}
|
||||
|
||||
it('renders the title', () => {
|
||||
expect(mountGroupSubcategory().get('.title').text()).toBe('Into a pool')
|
||||
})
|
||||
|
||||
it('renders the info only when it is given', () => {
|
||||
expect(mountGroupSubcategory({ info: 'Writes to a pool' }).get('.info').text()).toBe('Writes to a pool')
|
||||
expect(mountGroupSubcategory().find('.info').exists()).toBe(false)
|
||||
})
|
||||
@@ -0,0 +1,33 @@
|
||||
<!-- v1 -->
|
||||
<template>
|
||||
<div class="ui-group-subcategory">
|
||||
<span class="title typo-caption-small"><slot /></span>
|
||||
<span v-if="slots.info" class="info typo-body-regular-small"><slot name="info" /></span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const slots = defineSlots<{
|
||||
default(): any
|
||||
info?(): any
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.ui-group-subcategory {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.8rem;
|
||||
color: var(--color-neutral-txt-secondary);
|
||||
overflow-wrap: break-word;
|
||||
|
||||
.title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.info {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,216 @@
|
||||
<!-- v1 -->
|
||||
<template>
|
||||
<label :class="variants" class="ui-image-radio-button typo-body-regular">
|
||||
<span class="image">
|
||||
<img :src :alt />
|
||||
</span>
|
||||
<span class="radio-wrapper typo-body-regular">
|
||||
<span class="radio">
|
||||
<input v-model="model" :disabled="isDisabled" :value class="input" type="radio" />
|
||||
<VtsIcon name="status:radio-button" size="medium" />
|
||||
</span>
|
||||
<slot />
|
||||
</span>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import VtsIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import { useDisabled } from '@core/composables/disabled.composable.ts'
|
||||
import { toVariants } from '@core/utils/to-variants.util.ts'
|
||||
import { computed } from 'vue'
|
||||
|
||||
const { accent, value, disabled, size } = defineProps<{
|
||||
accent: 'brand' | 'warning' | 'danger'
|
||||
size: 'small' | 'medium'
|
||||
value: unknown
|
||||
src: string
|
||||
alt: string
|
||||
disabled?: boolean
|
||||
}>()
|
||||
|
||||
const model = defineModel<string>()
|
||||
|
||||
defineSlots<{
|
||||
default(): any
|
||||
}>()
|
||||
|
||||
const variants = computed(() => toVariants({ accent, size }))
|
||||
const isDisabled = useDisabled(() => disabled)
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.ui-image-radio-button {
|
||||
--radio-color: var(--accent-color);
|
||||
--radio-dot-color: var(--color-neutral-background-primary);
|
||||
cursor: pointer;
|
||||
border: 0.1rem solid var(--color-neutral-border);
|
||||
border-radius: 0.4rem;
|
||||
overflow: hidden;
|
||||
|
||||
.image {
|
||||
border-bottom: 0.1rem solid;
|
||||
border-color: inherit;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
.radio {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
flex-shrink: 0;
|
||||
border-radius: 50%;
|
||||
color: var(--radio-color);
|
||||
transition:
|
||||
color 0.125s ease-in-out,
|
||||
background-color 0.125s ease-in-out;
|
||||
|
||||
&:has(.input:checked) {
|
||||
background-color: var(--radio-color);
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 0.6rem;
|
||||
height: 0.6rem;
|
||||
margin: auto;
|
||||
border-radius: 50%;
|
||||
background-color: var(--radio-dot-color);
|
||||
}
|
||||
}
|
||||
|
||||
&:has(.input:focus-visible)::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -0.4rem;
|
||||
border: 0.2rem solid var(--color-brand-txt-base);
|
||||
border-radius: 0.4rem;
|
||||
}
|
||||
|
||||
.input {
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* ACCENT */
|
||||
|
||||
&.accent--brand {
|
||||
--accent-color: var(--color-brand-txt-base);
|
||||
--accent-hover-color: var(--color-brand-txt-hover);
|
||||
--accent-checked-color: var(--color-brand-item-base);
|
||||
--accent-active-color: var(--color-brand-txt-active);
|
||||
}
|
||||
|
||||
&.accent--warning {
|
||||
--accent-color: var(--color-warning-txt-base);
|
||||
--accent-hover-color: var(--color-warning-txt-hover);
|
||||
--accent-checked-color: var(--color-warning-item-base);
|
||||
--accent-active-color: var(--color-warning-txt-active);
|
||||
}
|
||||
|
||||
&.accent--danger {
|
||||
--accent-color: var(--color-danger-txt-base);
|
||||
--accent-hover-color: var(--color-danger-txt-hover);
|
||||
--accent-checked-color: var(--color-danger-item-base);
|
||||
--accent-active-color: var(--color-danger-txt-active);
|
||||
}
|
||||
|
||||
/* DISABLED */
|
||||
|
||||
&:has(.input:disabled) {
|
||||
cursor: not-allowed;
|
||||
--accent-color: var(--color-neutral-txt-secondary);
|
||||
--radio-dot-color: var(--color-neutral-background-disabled);
|
||||
}
|
||||
.radio-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.8rem;
|
||||
padding: 1.6rem;
|
||||
background-color: var(--color-neutral-background-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* INITIAL BORDER EXCEPT BRAND */
|
||||
|
||||
&.accent--warning,
|
||||
&.accent--danger {
|
||||
border-color: var(--accent-color);
|
||||
}
|
||||
|
||||
/* CHECKED STATE */
|
||||
|
||||
&:has(input:checked:not(:disabled)) {
|
||||
border-color: var(--accent-checked-color);
|
||||
}
|
||||
|
||||
/* HOVER STATE */
|
||||
|
||||
&:hover:not(:has(input:disabled)) {
|
||||
--radio-color: var(--accent-hover-color);
|
||||
border-color: var(--accent-hover-color);
|
||||
}
|
||||
|
||||
/* ACTIVE STATE */
|
||||
|
||||
&:active:not(:has(input:disabled)) {
|
||||
--radio-color: var(--accent-active-color);
|
||||
border-color: var(--accent-active-color);
|
||||
}
|
||||
|
||||
/* DISABLED STATE */
|
||||
|
||||
&:has(input:disabled) {
|
||||
border-color: var(--color-neutral-border);
|
||||
|
||||
.image {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.radio-wrapper {
|
||||
background-color: var(--color-neutral-background-disabled);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
/* SIZES */
|
||||
|
||||
&.size--small {
|
||||
height: 16.4rem;
|
||||
width: 12.8rem;
|
||||
|
||||
.image {
|
||||
height: 10.8rem;
|
||||
}
|
||||
|
||||
.radio-wrapper {
|
||||
height: 5.6rem;
|
||||
}
|
||||
}
|
||||
|
||||
&.size--medium {
|
||||
height: 25.6rem;
|
||||
width: 20rem;
|
||||
|
||||
.image {
|
||||
height: 20rem;
|
||||
}
|
||||
|
||||
.radio-wrapper {
|
||||
height: 5.6rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -72,7 +72,7 @@ const classNames = computed(() => toVariants({ accent }))
|
||||
|
||||
&.accent--info {
|
||||
.circle-icon {
|
||||
color: var(--color-info-item-base);
|
||||
color: var(--color-info-data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,19 +84,19 @@ const classNames = computed(() => toVariants({ accent }))
|
||||
|
||||
&.accent--success {
|
||||
.circle-icon {
|
||||
color: var(--color-success-item-base);
|
||||
color: var(--color-success-data);
|
||||
}
|
||||
}
|
||||
|
||||
&.accent--warning {
|
||||
.circle-icon {
|
||||
color: var(--color-warning-item-base);
|
||||
color: var(--color-warning-data);
|
||||
}
|
||||
}
|
||||
|
||||
&.accent--danger {
|
||||
.circle-icon {
|
||||
color: var(--color-danger-item-base);
|
||||
color: var(--color-danger-data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,19 +57,19 @@ const className = computed(() => toVariants({ accent }))
|
||||
/* ACCENT */
|
||||
&.accent--info {
|
||||
.fill {
|
||||
background-color: var(--color-info-item-base);
|
||||
background-color: var(--color-info-data);
|
||||
}
|
||||
}
|
||||
|
||||
&.accent--warning {
|
||||
.fill {
|
||||
background-color: var(--color-warning-item-base);
|
||||
background-color: var(--color-warning-data);
|
||||
}
|
||||
}
|
||||
|
||||
&.accent--danger {
|
||||
.fill {
|
||||
background-color: var(--color-danger-item-base);
|
||||
background-color: var(--color-danger-data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<!-- v4 -->
|
||||
<!-- v7 -->
|
||||
<template>
|
||||
<label :class="variant" class="ui-radio-button typo-body-regular">
|
||||
<span class="radio-container">
|
||||
<span class="radio">
|
||||
<input v-model="model" :disabled="isDisabled" :value class="input" type="radio" />
|
||||
<VtsIcon name="fa:circle" size="medium" class="radio-icon" />
|
||||
<VtsIcon name="status:radio-button" size="medium" />
|
||||
</span>
|
||||
<slot />
|
||||
</label>
|
||||
@@ -34,120 +34,86 @@ const isDisabled = useDisabled(() => disabled)
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.ui-radio-button {
|
||||
--radio-dot-color: var(--color-neutral-background-primary);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.8rem;
|
||||
|
||||
.radio-container {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
justify-content: center;
|
||||
border: 0.2rem solid var(--accent-color);
|
||||
background-color: transparent;
|
||||
border-radius: 0.8rem;
|
||||
width: 1.6rem;
|
||||
height: 1.6rem;
|
||||
.radio {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
flex-shrink: 0;
|
||||
border-radius: 50%;
|
||||
color: var(--radio-color);
|
||||
transition:
|
||||
border-color 0.125s ease-in-out,
|
||||
color 0.125s ease-in-out,
|
||||
background-color 0.125s ease-in-out;
|
||||
|
||||
&:has(input:focus-visible) {
|
||||
outline: none;
|
||||
&:has(.input:checked) {
|
||||
background-color: var(--radio-color);
|
||||
|
||||
&::after {
|
||||
position: absolute;
|
||||
content: '';
|
||||
inset: -0.5rem;
|
||||
border: 0.2rem solid var(--color-brand-txt-base);
|
||||
border-radius: 0.4rem;
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 0.6rem;
|
||||
height: 0.6rem;
|
||||
margin: auto;
|
||||
border-radius: 50%;
|
||||
background-color: var(--radio-dot-color);
|
||||
}
|
||||
}
|
||||
|
||||
&:has(.input:checked) {
|
||||
background-color: var(--accent-color);
|
||||
&:has(.input:focus-visible)::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -0.4rem;
|
||||
border: 0.2rem solid var(--color-brand-txt-base);
|
||||
border-radius: 0.4rem;
|
||||
}
|
||||
|
||||
/* INPUT */
|
||||
|
||||
.input {
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* ICON */
|
||||
|
||||
.radio-icon {
|
||||
font-size: 0.8rem;
|
||||
transition: font-size 0.125s ease-in-out;
|
||||
color: var(--radio-icon-color);
|
||||
--radio-icon-color: var(--color-neutral-background-primary);
|
||||
}
|
||||
|
||||
.input:not(:checked) + .radio-icon {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.input:disabled + .radio-icon {
|
||||
--radio-icon-color: var(--color-neutral-background-disabled);
|
||||
}
|
||||
}
|
||||
|
||||
/* ACCENT */
|
||||
|
||||
&.accent--brand {
|
||||
--accent-color: var(--color-brand-item-base);
|
||||
--radio-color: var(--color-brand-txt-base);
|
||||
|
||||
&:hover {
|
||||
--accent-color: var(--color-brand-item-hover);
|
||||
--radio-color: var(--color-brand-txt-hover);
|
||||
}
|
||||
|
||||
&:active {
|
||||
--accent-color: var(--color-brand-item-active);
|
||||
}
|
||||
|
||||
&:has(.input:checked:not(:disabled)) {
|
||||
.radio-icon {
|
||||
--radio-icon-color: var(--color-brand-txt-item);
|
||||
}
|
||||
--radio-color: var(--color-brand-txt-active);
|
||||
}
|
||||
}
|
||||
|
||||
&.accent--warning {
|
||||
--accent-color: var(--color-warning-item-base);
|
||||
--radio-color: var(--color-warning-txt-base);
|
||||
|
||||
&:hover {
|
||||
--accent-color: var(--color-warning-item-hover);
|
||||
--radio-color: var(--color-warning-txt-hover);
|
||||
}
|
||||
|
||||
&:active {
|
||||
--accent-color: var(--color-warning-item-active);
|
||||
}
|
||||
|
||||
&:has(.input:checked:not(:disabled)) {
|
||||
.radio-icon {
|
||||
--radio-icon-color: var(--color-warning-txt-item);
|
||||
}
|
||||
--radio-color: var(--color-warning-txt-active);
|
||||
}
|
||||
}
|
||||
|
||||
&.accent--danger {
|
||||
--accent-color: var(--color-danger-item-base);
|
||||
--radio-color: var(--color-danger-txt-base);
|
||||
|
||||
&:hover {
|
||||
--accent-color: var(--color-danger-item-hover);
|
||||
--radio-color: var(--color-danger-txt-hover);
|
||||
}
|
||||
|
||||
&:active {
|
||||
--accent-color: var(--color-danger-item-active);
|
||||
}
|
||||
|
||||
&:has(.input:checked:not(:disabled)) {
|
||||
.radio-icon {
|
||||
--radio-icon-color: var(--color-danger-txt-item);
|
||||
}
|
||||
--radio-color: var(--color-danger-txt-active);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +121,9 @@ const isDisabled = useDisabled(() => disabled)
|
||||
|
||||
&:has(.input:disabled) {
|
||||
cursor: not-allowed;
|
||||
--accent-color: var(--color-neutral-txt-secondary);
|
||||
color: var(--color-neutral-txt-secondary);
|
||||
--radio-color: var(--color-neutral-txt-secondary);
|
||||
--radio-dot-color: var(--color-neutral-background-disabled);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import UiInfo from '@core/components/ui/info/UiInfo.vue'
|
||||
import UiLabel from '@core/components/ui/label/UiLabel.vue'
|
||||
import type { RichCheckboxAccent } from '@core/components/ui/rich-checkbox/UiRichCheckbox.vue'
|
||||
import UiRichCheckboxGroup from '@core/components/ui/rich-checkbox-group/UiRichCheckboxGroup.vue'
|
||||
import { createGlobalTestConfig } from '@core-test/create-global-test-config.ts'
|
||||
import { mount } from '@vue/test-utils'
|
||||
|
||||
type RichCheckboxGroupProps = {
|
||||
accent?: RichCheckboxAccent
|
||||
label?: string
|
||||
info?: string
|
||||
message?: string
|
||||
vertical?: boolean
|
||||
}
|
||||
|
||||
function mountRichCheckboxGroup(props: RichCheckboxGroupProps = {}, slots: Record<string, string> = {}) {
|
||||
return mount(UiRichCheckboxGroup, {
|
||||
global: createGlobalTestConfig(),
|
||||
props: { accent: 'brand', ...props },
|
||||
slots: { default: '<span class="option">NFS backups</span>', ...slots },
|
||||
})
|
||||
}
|
||||
|
||||
it('renders its options in a group', () => {
|
||||
expect(mountRichCheckboxGroup().get('[role="group"]').find('.option').text()).toBe('NFS backups')
|
||||
})
|
||||
|
||||
it('names the group after its label', () => {
|
||||
const wrapper = mountRichCheckboxGroup({ label: 'Backup repositories' })
|
||||
const labelId = wrapper.get('[role="group"]').attributes('aria-labelledby')
|
||||
|
||||
expect(wrapper.get(`[id="${labelId}"]`).text()).toBe('Backup repositories')
|
||||
})
|
||||
|
||||
it('names the group after the label slot', () => {
|
||||
const wrapper = mountRichCheckboxGroup({}, { label: 'Custom label' })
|
||||
const labelId = wrapper.get('[role="group"]').attributes('aria-labelledby')
|
||||
|
||||
expect(wrapper.get(`[id="${labelId}"]`).text()).toBe('Custom label')
|
||||
})
|
||||
|
||||
it('leaves the group unnamed without a label', () => {
|
||||
const wrapper = mountRichCheckboxGroup()
|
||||
|
||||
expect(wrapper.findComponent(UiLabel).exists()).toBe(false)
|
||||
expect(wrapper.get('[role="group"]').attributes('aria-labelledby')).toBeUndefined()
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ accent: 'brand', labelAccent: 'neutral' },
|
||||
{ accent: 'warning', labelAccent: 'warning' },
|
||||
{ accent: 'danger', labelAccent: 'danger' },
|
||||
] as const)('gives the label a $labelAccent accent with a $accent accent', ({ accent, labelAccent }) => {
|
||||
expect(mountRichCheckboxGroup({ accent, label: 'Label' }).getComponent(UiLabel).props('accent')).toBe(labelAccent)
|
||||
})
|
||||
|
||||
it('applies the vertical variant only when set', () => {
|
||||
expect(mountRichCheckboxGroup({ vertical: true }).get('.group').classes()).toContain('vertical')
|
||||
expect(mountRichCheckboxGroup().get('.group').classes()).not.toContain('vertical')
|
||||
})
|
||||
|
||||
it('shows the info with an info accent', () => {
|
||||
const info = mountRichCheckboxGroup({ info: 'Pick at least one' }).getComponent(UiInfo)
|
||||
|
||||
expect(info.props('accent')).toBe('info')
|
||||
expect(info.text()).toBe('Pick at least one')
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ accent: 'brand', infos: [] },
|
||||
{ accent: 'warning', infos: ['warning'] },
|
||||
{ accent: 'danger', infos: ['danger'] },
|
||||
] as const)('shows the message only with a $accent accent other than brand', ({ accent, infos }) => {
|
||||
const wrapper = mountRichCheckboxGroup({ accent, message: 'Pick at least one' })
|
||||
|
||||
expect(wrapper.findAllComponents(UiInfo).map(info => info.props('accent'))).toEqual(infos)
|
||||
})
|
||||
@@ -0,0 +1,71 @@
|
||||
<!-- v1 -->
|
||||
<template>
|
||||
<div class="ui-rich-checkbox-group">
|
||||
<div v-if="hasLabel" :id="labelId">
|
||||
<slot name="label">
|
||||
<UiLabel :accent="labelAccent">
|
||||
{{ label }}
|
||||
</UiLabel>
|
||||
</slot>
|
||||
</div>
|
||||
<div :aria-labelledby="hasLabel ? labelId : undefined" :class="{ vertical }" class="group" role="group">
|
||||
<slot />
|
||||
</div>
|
||||
<slot v-if="slots.info || info !== undefined" name="info">
|
||||
<UiInfo accent="info">
|
||||
{{ info }}
|
||||
</UiInfo>
|
||||
</slot>
|
||||
<slot v-if="accent !== 'brand' && (slots.message || message !== undefined)" name="message">
|
||||
<UiInfo :accent>
|
||||
{{ message }}
|
||||
</UiInfo>
|
||||
</slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import UiInfo from '@core/components/ui/info/UiInfo.vue'
|
||||
import UiLabel from '@core/components/ui/label/UiLabel.vue'
|
||||
import type { RichCheckboxAccent } from '@core/components/ui/rich-checkbox/UiRichCheckbox.vue'
|
||||
import { computed, useId } from 'vue'
|
||||
|
||||
const { accent, label } = defineProps<{
|
||||
accent: RichCheckboxAccent
|
||||
label?: string
|
||||
info?: string
|
||||
message?: string
|
||||
vertical?: boolean
|
||||
}>()
|
||||
|
||||
const slots = defineSlots<{
|
||||
default(): any
|
||||
label?(): any
|
||||
info?(): any
|
||||
message?(): any
|
||||
}>()
|
||||
|
||||
const labelId = useId()
|
||||
|
||||
const hasLabel = computed(() => slots.label !== undefined || label !== undefined)
|
||||
|
||||
const labelAccent = computed(() => (accent === 'brand' ? 'neutral' : accent))
|
||||
</script>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
.ui-rich-checkbox-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.8rem;
|
||||
|
||||
.group {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.8rem;
|
||||
|
||||
&.vertical {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,109 @@
|
||||
import VtsIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import UiInfo from '@core/components/ui/info/UiInfo.vue'
|
||||
import UiRichCheckbox, { type RichCheckboxAccent } from '@core/components/ui/rich-checkbox/UiRichCheckbox.vue'
|
||||
import UiTag from '@core/components/ui/tag/UiTag.vue'
|
||||
import type { CheckboxModel } from '@core/composables/checkbox-state.composable.ts'
|
||||
import type { IconName } from '@core/icons'
|
||||
import { createGlobalTestConfig } from '@core-test/create-global-test-config.ts'
|
||||
import { mount, type VueWrapper } from '@vue/test-utils'
|
||||
|
||||
type RichCheckboxProps = {
|
||||
accent?: RichCheckboxAccent
|
||||
modelValue?: CheckboxModel
|
||||
value?: string
|
||||
icon?: IconName
|
||||
tag?: string
|
||||
description?: string
|
||||
message?: string
|
||||
disabled?: boolean
|
||||
'onUpdate:modelValue'?: (model: CheckboxModel) => void
|
||||
}
|
||||
|
||||
function mountRichCheckbox(props: RichCheckboxProps = {}) {
|
||||
return mount(UiRichCheckbox, {
|
||||
global: createGlobalTestConfig(),
|
||||
props: { accent: 'brand', modelValue: false, ...props },
|
||||
slots: { default: 'NFS backups' },
|
||||
})
|
||||
}
|
||||
|
||||
function readIconNames(wrapper: VueWrapper) {
|
||||
return wrapper.findAllComponents(VtsIcon).map(icon => icon.props('name'))
|
||||
}
|
||||
|
||||
it.each([
|
||||
{ model: true, classes: ['checked'], icon: 'status:checkbox-checked' },
|
||||
{ model: undefined, classes: ['indeterminate'], icon: 'status:checkbox-partially-checked' },
|
||||
{ model: false, classes: [], icon: 'status:checkbox' },
|
||||
])('shows the $model model on the card and the checkbox', ({ model, classes, icon }) => {
|
||||
const wrapper = mountRichCheckbox({ modelValue: model })
|
||||
|
||||
expect(wrapper.classes().filter(className => ['checked', 'indeterminate'].includes(className))).toEqual(classes)
|
||||
expect(readIconNames(wrapper)).toEqual([icon])
|
||||
expect(wrapper.get('input').element.indeterminate).toBe(model === undefined)
|
||||
})
|
||||
|
||||
it('keeps showing the model when the parent rejects the change', async () => {
|
||||
const wrapper = mountRichCheckbox({ modelValue: false, 'onUpdate:modelValue': () => undefined })
|
||||
|
||||
await wrapper.get('input').setValue(true)
|
||||
|
||||
expect(wrapper.emitted('update:modelValue')).toEqual([[true]])
|
||||
expect(wrapper.classes()).not.toContain('checked')
|
||||
expect(readIconNames(wrapper)).toEqual(['status:checkbox'])
|
||||
})
|
||||
|
||||
it('adds its value to an array model', async () => {
|
||||
const wrapper = mountRichCheckbox({ modelValue: ['s3'], value: 'nfs' })
|
||||
|
||||
await wrapper.get('input').setValue(true)
|
||||
|
||||
expect(wrapper.emitted('update:modelValue')).toEqual([[['s3', 'nfs']]])
|
||||
})
|
||||
|
||||
it('applies the accent and the disabled variant', () => {
|
||||
const wrapper = mountRichCheckbox({ accent: 'warning', disabled: true })
|
||||
|
||||
expect(wrapper.classes()).toEqual(expect.arrayContaining(['accent--warning', 'disabled']))
|
||||
expect(wrapper.get('input').attributes()).toHaveProperty('disabled')
|
||||
})
|
||||
|
||||
it('names the checkbox after its heading', () => {
|
||||
const wrapper = mountRichCheckbox({ tag: 'Source' })
|
||||
const heading = wrapper.get('.heading')
|
||||
|
||||
expect(wrapper.get('input').attributes('aria-labelledby')).toBe(heading.attributes('id'))
|
||||
expect(heading.text()).toContain('NFS backups')
|
||||
expect(wrapper.getComponent(UiTag).props('accent')).toBe('info')
|
||||
expect(wrapper.getComponent(UiTag).text()).toBe('Source')
|
||||
})
|
||||
|
||||
it('describes the checkbox with its description', () => {
|
||||
const wrapper = mountRichCheckbox({ description: '4.2 TiB free' })
|
||||
const description = wrapper.get('.description')
|
||||
|
||||
expect(description.text()).toBe('4.2 TiB free')
|
||||
expect(wrapper.get('input').attributes('aria-describedby')).toBe(description.attributes('id'))
|
||||
})
|
||||
|
||||
it('renders no tag and no description when none is given', () => {
|
||||
const wrapper = mountRichCheckbox()
|
||||
|
||||
expect(wrapper.findComponent(UiTag).exists()).toBe(false)
|
||||
expect(wrapper.find('.description').exists()).toBe(false)
|
||||
expect(wrapper.get('input').attributes('aria-describedby')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('renders the icon it is given after the checkbox', () => {
|
||||
expect(readIconNames(mountRichCheckbox({ icon: 'fa:server' }))).toEqual(['status:checkbox', 'fa:server'])
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ accent: 'brand', infos: [] },
|
||||
{ accent: 'warning', infos: ['warning'] },
|
||||
{ accent: 'danger', infos: ['danger'] },
|
||||
] as const)('shows the message only with a $accent accent other than brand', ({ accent, infos }) => {
|
||||
const wrapper = mountRichCheckbox({ accent, message: 'Not enough space' })
|
||||
|
||||
expect(wrapper.findAllComponents(UiInfo).map(info => info.props('accent'))).toEqual(infos)
|
||||
})
|
||||
@@ -0,0 +1,254 @@
|
||||
<!-- v1 -->
|
||||
<template>
|
||||
<div :class="className" class="ui-rich-checkbox">
|
||||
<label class="box typo-body-bold">
|
||||
<span class="controls">
|
||||
<span class="checkbox">
|
||||
<input
|
||||
v-model="model"
|
||||
:aria-labelledby="headingId"
|
||||
:aria-describedby="hasDescription ? descriptionId : undefined"
|
||||
:disabled="isDisabled"
|
||||
:indeterminate="isIndeterminate"
|
||||
:value
|
||||
class="input"
|
||||
type="checkbox"
|
||||
/>
|
||||
<VtsIcon :name="checkboxIcon" size="medium" />
|
||||
</span>
|
||||
<VtsIcon v-if="icon" :name="icon" size="medium" />
|
||||
</span>
|
||||
<span class="content">
|
||||
<span :id="headingId" class="heading">
|
||||
<span class="label">
|
||||
<slot />
|
||||
</span>
|
||||
<slot v-if="slots.tag || tag !== undefined" name="tag">
|
||||
<UiTag accent="info" variant="secondary">{{ tag }}</UiTag>
|
||||
</slot>
|
||||
</span>
|
||||
<span v-if="hasDescription" :id="descriptionId" class="description typo-body-regular">
|
||||
<slot name="description">{{ description }}</slot>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<slot v-if="slots.info || info !== undefined" name="info">
|
||||
<UiInfo accent="info">{{ info }}</UiInfo>
|
||||
</slot>
|
||||
<slot v-if="accent !== 'brand' && (slots.message || message !== undefined)" name="message">
|
||||
<UiInfo :accent>{{ message }}</UiInfo>
|
||||
</slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import VtsIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import UiInfo from '@core/components/ui/info/UiInfo.vue'
|
||||
import UiTag from '@core/components/ui/tag/UiTag.vue'
|
||||
import { type CheckboxModel, useCheckboxState } from '@core/composables/checkbox-state.composable.ts'
|
||||
import { useDisabled } from '@core/composables/disabled.composable.ts'
|
||||
import type { IconName } from '@core/icons'
|
||||
import { toVariants } from '@core/utils/to-variants.util.ts'
|
||||
import { computed, useId } from 'vue'
|
||||
|
||||
export type RichCheckboxAccent = 'brand' | 'warning' | 'danger'
|
||||
|
||||
const { accent, value, description, disabled } = defineProps<{
|
||||
accent: RichCheckboxAccent
|
||||
value?: string
|
||||
icon?: IconName
|
||||
tag?: string
|
||||
description?: string
|
||||
info?: string
|
||||
message?: string
|
||||
disabled?: boolean
|
||||
}>()
|
||||
|
||||
const model = defineModel<CheckboxModel>({ default: undefined })
|
||||
|
||||
const slots = defineSlots<{
|
||||
default(): any
|
||||
tag?(): any
|
||||
description?(): any
|
||||
info?(): any
|
||||
message?(): any
|
||||
}>()
|
||||
|
||||
const headingId = useId()
|
||||
|
||||
const descriptionId = useId()
|
||||
|
||||
const hasDescription = computed(() => slots.description !== undefined || description !== undefined)
|
||||
|
||||
const isDisabled = useDisabled(() => disabled)
|
||||
|
||||
const { isIndeterminate, isChecked, icon: checkboxIcon } = useCheckboxState(model, () => value)
|
||||
|
||||
const className = computed(() =>
|
||||
toVariants({
|
||||
accent,
|
||||
checked: isChecked.value,
|
||||
indeterminate: isIndeterminate.value,
|
||||
disabled: isDisabled.value,
|
||||
})
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.ui-rich-checkbox {
|
||||
--box-border-color: var(--accent-color);
|
||||
--box-background-color: var(--color-neutral-background-primary);
|
||||
--border-hover-color: var(--accent-hover-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
|
||||
.box {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
align-items: flex-start;
|
||||
gap: 1.2rem;
|
||||
padding: 1.2rem 1.6rem;
|
||||
border: 0.1rem solid var(--box-border-color);
|
||||
border-radius: 0.4rem;
|
||||
background-color: var(--box-background-color);
|
||||
color: var(--color-neutral-txt-primary);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
border-color 0.125s ease-in-out,
|
||||
background-color 0.125s ease-in-out;
|
||||
|
||||
&:has(.input:focus-visible)::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -0.4rem;
|
||||
border: 0.2rem solid var(--color-brand-txt-base);
|
||||
border-radius: 0.4rem;
|
||||
}
|
||||
}
|
||||
|
||||
.controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
gap: 1.2rem;
|
||||
height: 1lh;
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
color: var(--checkbox-color);
|
||||
transition: color 0.125s ease-in-out;
|
||||
|
||||
.input {
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
gap: 0.2rem;
|
||||
min-width: 0;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.heading {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.label {
|
||||
flex: auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.description {
|
||||
color: var(--color-neutral-txt-secondary);
|
||||
}
|
||||
|
||||
/* ACCENT */
|
||||
|
||||
&.accent--brand {
|
||||
--box-border-color: var(--color-neutral-txt-secondary);
|
||||
--accent-color: var(--color-brand-txt-base);
|
||||
--accent-hover-color: var(--color-brand-txt-hover);
|
||||
--accent-active-color: var(--color-brand-txt-active);
|
||||
--background-checked-color: var(--color-brand-background-selected);
|
||||
--background-hover-color: var(--color-brand-background-hover);
|
||||
--background-active-color: var(--color-brand-background-active);
|
||||
--background-checked-active-color: var(--color-brand-background-hover);
|
||||
}
|
||||
|
||||
&.accent--warning {
|
||||
--accent-color: var(--color-warning-txt-base);
|
||||
--accent-hover-color: var(--color-warning-txt-hover);
|
||||
--accent-active-color: var(--color-warning-txt-active);
|
||||
--background-checked-color: var(--color-warning-background-selected);
|
||||
--background-hover-color: var(--color-warning-background-hover);
|
||||
--background-active-color: var(--color-warning-background-hover);
|
||||
--background-checked-active-color: var(--color-warning-background-hover);
|
||||
}
|
||||
|
||||
&.accent--danger {
|
||||
--border-hover-color: var(--color-danger-txt-base);
|
||||
--accent-color: var(--color-danger-txt-base);
|
||||
--accent-hover-color: var(--color-danger-txt-hover);
|
||||
--accent-active-color: var(--color-danger-txt-active);
|
||||
--background-checked-color: var(--color-danger-background-selected);
|
||||
--background-hover-color: var(--color-danger-background-hover);
|
||||
--background-active-color: var(--color-danger-background-active);
|
||||
--background-checked-active-color: var(--color-danger-background-active);
|
||||
}
|
||||
|
||||
/* INTERACTIONS */
|
||||
|
||||
&:not(.disabled) {
|
||||
&:is(.checked, .indeterminate) .box {
|
||||
--box-border-color: var(--accent-color);
|
||||
--box-background-color: var(--background-checked-color);
|
||||
}
|
||||
|
||||
&.checked .box {
|
||||
--background-active-color: var(--background-checked-active-color);
|
||||
}
|
||||
|
||||
.box {
|
||||
--checkbox-color: var(--accent-color);
|
||||
--checkbox-mark-color: var(--box-background-color);
|
||||
|
||||
&:hover {
|
||||
--checkbox-color: var(--accent-hover-color);
|
||||
--checkbox-mark-color: var(--background-hover-color);
|
||||
border-color: var(--border-hover-color);
|
||||
background-color: var(--background-hover-color);
|
||||
}
|
||||
|
||||
&:active {
|
||||
--checkbox-color: var(--accent-active-color);
|
||||
--checkbox-mark-color: var(--background-active-color);
|
||||
border-color: var(--accent-active-color);
|
||||
background-color: var(--background-active-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* DISABLED */
|
||||
|
||||
&.disabled .box {
|
||||
--checkbox-color: var(--color-neutral-txt-secondary);
|
||||
--checkbox-mark-color: var(--color-neutral-background-disabled);
|
||||
border-color: var(--color-neutral-border);
|
||||
background-color: var(--color-neutral-background-disabled);
|
||||
color: var(--color-neutral-txt-secondary);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,75 @@
|
||||
<!-- v1 -->
|
||||
<template>
|
||||
<div class="ui-rich-radio-button-group">
|
||||
<div v-if="slots.label || label !== undefined" :id="labelId">
|
||||
<slot name="label">
|
||||
<UiLabel :accent="labelAccent">
|
||||
{{ label }}
|
||||
</UiLabel>
|
||||
</slot>
|
||||
</div>
|
||||
<div
|
||||
:aria-labelledby="slots.label || label !== undefined ? labelId : undefined"
|
||||
:class="{ vertical }"
|
||||
class="group"
|
||||
role="radiogroup"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
<slot v-if="slots.info || info !== undefined" name="info">
|
||||
<UiInfo accent="info">
|
||||
{{ info }}
|
||||
</UiInfo>
|
||||
</slot>
|
||||
<slot v-if="accent !== 'brand' && (slots.message || message !== undefined)" name="message">
|
||||
<UiInfo :accent>
|
||||
{{ message }}
|
||||
</UiInfo>
|
||||
</slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import UiInfo from '@core/components/ui/info/UiInfo.vue'
|
||||
import UiLabel from '@core/components/ui/label/UiLabel.vue'
|
||||
import type { RichRadioButtonAccent } from '@core/components/ui/rich-radio-button/UiRichRadioButton.vue'
|
||||
import { computed, useId } from 'vue'
|
||||
|
||||
const { accent } = defineProps<{
|
||||
accent: RichRadioButtonAccent
|
||||
label?: string
|
||||
info?: string
|
||||
message?: string
|
||||
vertical?: boolean
|
||||
}>()
|
||||
|
||||
const slots = defineSlots<{
|
||||
default(): any
|
||||
label?(): any
|
||||
info?(): any
|
||||
message?(): any
|
||||
}>()
|
||||
|
||||
const labelId = useId()
|
||||
|
||||
const labelAccent = computed(() => (accent === 'brand' ? 'neutral' : accent))
|
||||
</script>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
.ui-rich-radio-button-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.8rem;
|
||||
|
||||
.group {
|
||||
display: grid;
|
||||
grid-auto-flow: column;
|
||||
grid-auto-columns: minmax(0, 1fr);
|
||||
gap: 0.8rem;
|
||||
|
||||
&.vertical {
|
||||
grid-auto-flow: row;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,101 +1,149 @@
|
||||
<!-- v1 -->
|
||||
<template>
|
||||
<label :class="variants" class="ui-rich-radio-button typo-body-regular">
|
||||
<span class="rich-image">
|
||||
<img :src :alt />
|
||||
</span>
|
||||
<span class="radio-wrapper typo-body-regular">
|
||||
<span class="radio-container">
|
||||
<input v-model="model" :disabled="isDisabled" :value class="input" type="radio" />
|
||||
<VtsIcon name="fa:circle" size="small" class="radio-icon" />
|
||||
<div :class="className" class="ui-rich-radio-button">
|
||||
<label class="box">
|
||||
<span class="controls">
|
||||
<span class="radio">
|
||||
<input
|
||||
v-model="model"
|
||||
:aria-labelledby="headingId"
|
||||
:aria-describedby="slots.description || description !== undefined ? descriptionId : undefined"
|
||||
:disabled="isDisabled"
|
||||
:value
|
||||
class="input"
|
||||
type="radio"
|
||||
/>
|
||||
<VtsIcon name="status:radio-button" size="medium" />
|
||||
</span>
|
||||
<VtsIcon v-if="icon" :name="icon" size="medium" class="icon" />
|
||||
</span>
|
||||
<slot />
|
||||
</span>
|
||||
</label>
|
||||
<span class="content">
|
||||
<span :id="headingId" class="heading">
|
||||
<span class="label typo-body-bold">
|
||||
<slot />
|
||||
</span>
|
||||
<slot v-if="slots.tag || tag !== undefined" name="tag">
|
||||
<UiTag accent="info" variant="secondary">{{ tag }}</UiTag>
|
||||
</slot>
|
||||
</span>
|
||||
<span
|
||||
v-if="slots.description || description !== undefined"
|
||||
:id="descriptionId"
|
||||
class="description typo-body-regular"
|
||||
>
|
||||
<slot name="description">{{ description }}</slot>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<slot v-if="slots.info || info !== undefined" name="info">
|
||||
<UiInfo accent="info">{{ info }}</UiInfo>
|
||||
</slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
<script lang="ts" setup generic="TValue">
|
||||
import VtsIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import UiInfo from '@core/components/ui/info/UiInfo.vue'
|
||||
import UiTag from '@core/components/ui/tag/UiTag.vue'
|
||||
import { useDisabled } from '@core/composables/disabled.composable.ts'
|
||||
import type { IconName } from '@core/icons'
|
||||
import { toVariants } from '@core/utils/to-variants.util.ts'
|
||||
import { computed } from 'vue'
|
||||
import { computed, useId } from 'vue'
|
||||
|
||||
const { accent, value, disabled, size } = defineProps<{
|
||||
accent: 'brand' | 'warning' | 'danger'
|
||||
size: 'small' | 'medium'
|
||||
value: unknown
|
||||
src: string
|
||||
alt: string
|
||||
export type RichRadioButtonAccent = 'brand' | 'warning' | 'danger'
|
||||
|
||||
const { accent, disabled } = defineProps<{
|
||||
accent: RichRadioButtonAccent
|
||||
value: TValue
|
||||
icon?: IconName
|
||||
tag?: string
|
||||
description?: string
|
||||
info?: string
|
||||
disabled?: boolean
|
||||
}>()
|
||||
|
||||
const model = defineModel<string>()
|
||||
const model = defineModel<TValue>()
|
||||
|
||||
defineSlots<{
|
||||
const slots = defineSlots<{
|
||||
default(): any
|
||||
tag?(): any
|
||||
description?(): any
|
||||
info?(): any
|
||||
}>()
|
||||
|
||||
const variants = computed(() => toVariants({ accent, size }))
|
||||
const headingId = useId()
|
||||
|
||||
const descriptionId = useId()
|
||||
|
||||
const isDisabled = useDisabled(() => disabled)
|
||||
|
||||
const className = computed(() => toVariants({ accent, disabled: isDisabled.value }))
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.ui-rich-radio-button {
|
||||
cursor: pointer;
|
||||
border: 0.1rem solid var(--color-neutral-border);
|
||||
border-radius: 0.4rem;
|
||||
overflow: hidden;
|
||||
--radio-dot-color: var(--color-neutral-background-primary);
|
||||
--box-border-color: var(--accent-color);
|
||||
--box-background-color: var(--color-neutral-background-primary);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
|
||||
.rich-image {
|
||||
border-bottom: 0.1rem solid;
|
||||
border-color: inherit;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
.radio-container {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0.2rem solid var(--accent-color);
|
||||
background-color: transparent;
|
||||
border-radius: 0.8rem;
|
||||
width: 1.6rem;
|
||||
height: 1.6rem;
|
||||
.box {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
align-items: flex-start;
|
||||
gap: 1.2rem;
|
||||
padding: 1.2rem 1.6rem;
|
||||
border: 0.1rem solid var(--box-border-color);
|
||||
border-radius: 0.4rem;
|
||||
background-color: var(--box-background-color);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
border-color 0.125s ease-in-out,
|
||||
background-color 0.125s ease-in-out;
|
||||
|
||||
&:has(input:focus-visible) {
|
||||
outline: none;
|
||||
|
||||
&::after {
|
||||
position: absolute;
|
||||
content: '';
|
||||
inset: -0.5rem;
|
||||
border: 0.2rem solid var(--color-brand-txt-base);
|
||||
border-radius: 0.4rem;
|
||||
}
|
||||
&:has(.input:focus-visible)::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -0.4rem;
|
||||
border: 0.2rem solid var(--color-brand-txt-base);
|
||||
border-radius: 0.4rem;
|
||||
}
|
||||
}
|
||||
|
||||
.controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
gap: 1.2rem;
|
||||
height: 2.4rem;
|
||||
}
|
||||
|
||||
.radio {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
flex-shrink: 0;
|
||||
border-radius: 50%;
|
||||
color: var(--radio-color);
|
||||
transition:
|
||||
color 0.125s ease-in-out,
|
||||
background-color 0.125s ease-in-out;
|
||||
|
||||
&:has(.input:checked) {
|
||||
border-color: var(--accent-checked-color);
|
||||
background-color: var(--accent-checked-color);
|
||||
}
|
||||
background-color: var(--radio-color);
|
||||
|
||||
&:has(.input:checked:disabled) {
|
||||
border-color: var(--color-neutral-txt-secondary);
|
||||
background-color: var(--color-neutral-txt-secondary);
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 0.6rem;
|
||||
height: 0.6rem;
|
||||
margin: auto;
|
||||
border-radius: 50%;
|
||||
background-color: var(--radio-dot-color);
|
||||
}
|
||||
}
|
||||
|
||||
.input {
|
||||
@@ -103,144 +151,108 @@ const isDisabled = useDisabled(() => disabled)
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.radio-icon {
|
||||
font-size: 0.8rem;
|
||||
position: absolute;
|
||||
transition: font-size 0.125s ease-in-out;
|
||||
color: var(--radio-icon-color);
|
||||
--radio-icon-color: var(--color-neutral-background-primary);
|
||||
}
|
||||
.icon {
|
||||
color: var(--color-neutral-txt-primary);
|
||||
}
|
||||
|
||||
.input:not(:checked) + .radio-icon {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
gap: 0.2rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.input:disabled + .radio-icon {
|
||||
--radio-icon-color: var(--color-neutral-background-disabled);
|
||||
}
|
||||
.heading {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.label {
|
||||
flex: auto;
|
||||
min-width: 0;
|
||||
overflow-wrap: break-word;
|
||||
color: var(--color-neutral-txt-primary);
|
||||
}
|
||||
|
||||
.description {
|
||||
overflow-wrap: break-word;
|
||||
color: var(--color-neutral-txt-secondary);
|
||||
}
|
||||
|
||||
/* ACCENT */
|
||||
|
||||
&.accent--brand {
|
||||
--box-border-color: var(--color-neutral-txt-secondary);
|
||||
--accent-color: var(--color-brand-txt-base);
|
||||
--accent-hover-color: var(--color-brand-txt-hover);
|
||||
--accent-checked-color: var(--color-brand-item-base);
|
||||
--accent-active-color: var(--color-brand-txt-active);
|
||||
--background-checked-color: var(--color-brand-background-selected);
|
||||
--background-hover-color: var(--color-brand-background-hover);
|
||||
--background-active-color: var(--color-brand-background-active);
|
||||
--background-checked-active-color: var(--color-brand-background-hover);
|
||||
}
|
||||
|
||||
&.accent--warning {
|
||||
--accent-color: var(--color-warning-txt-base);
|
||||
--accent-hover-color: var(--color-warning-txt-hover);
|
||||
--accent-checked-color: var(--color-warning-item-base);
|
||||
--accent-active-color: var(--color-warning-txt-active);
|
||||
--background-checked-color: var(--color-warning-background-selected);
|
||||
--background-hover-color: var(--color-warning-background-hover);
|
||||
--background-active-color: var(--color-warning-background-hover);
|
||||
--background-checked-active-color: var(--color-warning-background-hover);
|
||||
}
|
||||
|
||||
&.accent--danger {
|
||||
--accent-color: var(--color-danger-txt-base);
|
||||
--accent-hover-color: var(--color-danger-txt-hover);
|
||||
--accent-checked-color: var(--color-danger-item-base);
|
||||
--accent-active-color: var(--color-danger-txt-active);
|
||||
--background-checked-color: var(--color-danger-background-selected);
|
||||
--background-hover-color: var(--color-danger-background-hover);
|
||||
--background-active-color: var(--color-danger-background-active);
|
||||
--background-checked-active-color: var(--color-danger-background-active);
|
||||
}
|
||||
|
||||
/* INTERACTIONS */
|
||||
|
||||
&:not(.disabled) .box {
|
||||
--radio-color: var(--accent-color);
|
||||
|
||||
&:has(.input:checked) {
|
||||
--box-border-color: var(--accent-color);
|
||||
--box-background-color: var(--background-checked-color);
|
||||
--background-active-color: var(--background-checked-active-color);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
--radio-color: var(--accent-hover-color);
|
||||
border-color: var(--color-brand-txt-hover);
|
||||
background-color: var(--background-hover-color);
|
||||
}
|
||||
|
||||
&:active {
|
||||
--radio-color: var(--accent-active-color);
|
||||
border-color: var(--color-brand-txt-active);
|
||||
background-color: var(--background-active-color);
|
||||
}
|
||||
}
|
||||
|
||||
/* DISABLED */
|
||||
|
||||
&:has(.input:disabled) {
|
||||
cursor: not-allowed;
|
||||
--accent-color: var(--color-neutral-txt-secondary);
|
||||
}
|
||||
.radio-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.8rem;
|
||||
padding: 1.6rem;
|
||||
background-color: var(--color-neutral-background-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* INITIAL BORDER EXCEPT BRAND */
|
||||
|
||||
&.accent--warning,
|
||||
&.accent--danger {
|
||||
border-color: var(--accent-color);
|
||||
}
|
||||
|
||||
/* CHECKED STATE */
|
||||
|
||||
&:has(input:checked:not(:disabled)) {
|
||||
border-color: var(--accent-checked-color);
|
||||
|
||||
.radio-container {
|
||||
border-color: var(--accent-checked-color);
|
||||
background-color: var(--accent-checked-color);
|
||||
}
|
||||
}
|
||||
|
||||
/* HOVER STATE */
|
||||
|
||||
&:hover:not(:has(input:disabled)) {
|
||||
border-color: var(--accent-hover-color);
|
||||
|
||||
.radio-container {
|
||||
border-color: var(--accent-hover-color);
|
||||
}
|
||||
.radio-container:has(.input:checked) {
|
||||
background-color: var(--accent-hover-color);
|
||||
}
|
||||
}
|
||||
|
||||
/* ACTIVE STATE */
|
||||
|
||||
&:active:not(:has(input:disabled)) {
|
||||
.radio-container {
|
||||
border-color: var(--accent-active-color);
|
||||
}
|
||||
.radio-container:has(.input:checked) {
|
||||
background-color: var(--accent-active-color);
|
||||
}
|
||||
}
|
||||
|
||||
/* DISABLED STATE */
|
||||
|
||||
&:has(input:disabled) {
|
||||
&.disabled .box {
|
||||
--radio-color: var(--color-neutral-txt-secondary);
|
||||
--radio-dot-color: var(--color-neutral-background-disabled);
|
||||
border-color: var(--color-neutral-border);
|
||||
background-color: var(--color-neutral-background-disabled);
|
||||
cursor: not-allowed;
|
||||
|
||||
.rich-image {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.radio-wrapper {
|
||||
background-color: var(--color-neutral-background-disabled);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
/* SIZES */
|
||||
|
||||
&.size--small {
|
||||
height: 16.4rem;
|
||||
width: 12.8rem;
|
||||
|
||||
.rich-image {
|
||||
height: 10.8rem;
|
||||
}
|
||||
|
||||
.radio-wrapper {
|
||||
height: 5.6rem;
|
||||
}
|
||||
}
|
||||
|
||||
&.size--medium {
|
||||
height: 25.6rem;
|
||||
width: 20rem;
|
||||
|
||||
.rich-image {
|
||||
height: 20rem;
|
||||
}
|
||||
|
||||
.radio-wrapper {
|
||||
height: 5.6rem;
|
||||
.label,
|
||||
.icon {
|
||||
color: var(--color-neutral-txt-secondary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,19 +54,19 @@ useResizeObserver(ellipsisElement, ([entry]) => {
|
||||
/* ACCENT VARIANTS */
|
||||
|
||||
&.accent--info {
|
||||
background-color: var(--color-info-item-base);
|
||||
background-color: var(--color-info-data);
|
||||
}
|
||||
|
||||
&.accent--success {
|
||||
background-color: var(--color-success-item-base);
|
||||
background-color: var(--color-success-data);
|
||||
}
|
||||
|
||||
&.accent--warning {
|
||||
background-color: var(--color-warning-item-base);
|
||||
background-color: var(--color-warning-data);
|
||||
}
|
||||
|
||||
&.accent--danger {
|
||||
background-color: var(--color-danger-item-base);
|
||||
background-color: var(--color-danger-data);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!-- v1 -->
|
||||
<template>
|
||||
<span class="ui-tertiary-tag" :class="className">
|
||||
<span class="ui-label-value-tag" :class="className">
|
||||
<UiTag :accent variant="primary" class="term">
|
||||
<slot name="term" />
|
||||
</UiTag>
|
||||
@@ -35,7 +35,7 @@ const className = computed(() => toVariants({ truncate, wrap }))
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.ui-tertiary-tag {
|
||||
.ui-label-value-tag {
|
||||
display: inline-grid;
|
||||
grid-template-columns: auto auto;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!-- v5 -->
|
||||
<!-- v7 -->
|
||||
<template>
|
||||
<span :class="className" class="ui-tag typo-body-regular-small">
|
||||
<VtsIcon :name="icon" size="current" />
|
||||
<slot />
|
||||
<button v-if="removable" :aria-label="t('action:remove')" class="remove" type="button" @click.stop="emit('remove')">
|
||||
<VtsIcon name="action:close-cancel-clear" size="medium" />
|
||||
@@ -10,6 +11,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import VtsIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import type { IconName } from '@core/icons'
|
||||
import { toVariants } from '@core/utils/to-variants.util.ts'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
@@ -20,6 +22,7 @@ type TagVariant = 'primary' | 'secondary'
|
||||
const { accent, variant } = defineProps<{
|
||||
accent: TagAccent
|
||||
variant: TagVariant
|
||||
icon?: IconName
|
||||
removable?: boolean
|
||||
}>()
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ export const useChartTheme = (pinia?: Pinia) => {
|
||||
background: style.getPropertyValue('--color-neutral-background-primary'),
|
||||
text: style.getPropertyValue('--color-neutral-txt-secondary'),
|
||||
splitLine: style.getPropertyValue('--color-neutral-border'),
|
||||
primary: style.getPropertyValue('--color-brand-item-base'),
|
||||
secondary: style.getPropertyValue('--color-warning-item-base'),
|
||||
primary: style.getPropertyValue('--color-brand-data'),
|
||||
secondary: style.getPropertyValue('--color-warning-data'),
|
||||
})
|
||||
|
||||
const colors = ref(getColors())
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import type { IconName } from '@core/icons'
|
||||
import { computed, type MaybeRefOrGetter, toValue } from 'vue'
|
||||
|
||||
export type CheckboxModel = boolean | undefined | string[]
|
||||
|
||||
export function useCheckboxState(model: MaybeRefOrGetter<CheckboxModel>, value: MaybeRefOrGetter<string | undefined>) {
|
||||
const isIndeterminate = computed(() => toValue(model) === undefined)
|
||||
|
||||
const isChecked = computed(() => {
|
||||
const modelValue = toValue(model)
|
||||
|
||||
return Array.isArray(modelValue) ? modelValue.some(item => item === toValue(value)) : modelValue === true
|
||||
})
|
||||
|
||||
const icon = computed<IconName>(() => {
|
||||
if (isIndeterminate.value) {
|
||||
return 'status:checkbox-partially-checked'
|
||||
}
|
||||
|
||||
return isChecked.value ? 'status:checkbox-checked' : 'status:checkbox'
|
||||
})
|
||||
|
||||
return { isIndeterminate, isChecked, icon }
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { type CheckboxModel, useCheckboxState } from '@core/composables/checkbox-state.composable.ts'
|
||||
import { ref } from 'vue'
|
||||
|
||||
describe('useCheckboxState', () => {
|
||||
it('is partly checked when the model is undefined', () => {
|
||||
const { isIndeterminate, isChecked, icon } = useCheckboxState(undefined, undefined)
|
||||
|
||||
expect(isIndeterminate.value).toBe(true)
|
||||
expect(isChecked.value).toBe(false)
|
||||
expect(icon.value).toBe('status:checkbox-partially-checked')
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ model: true, checked: true, icon: 'status:checkbox-checked' },
|
||||
{ model: false, checked: false, icon: 'status:checkbox' },
|
||||
])('reads a $model boolean model', ({ model, checked, icon }) => {
|
||||
const state = useCheckboxState(model, undefined)
|
||||
|
||||
expect(state.isIndeterminate.value).toBe(false)
|
||||
expect(state.isChecked.value).toBe(checked)
|
||||
expect(state.icon.value).toBe(icon)
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ value: 'nfs', checked: true, icon: 'status:checkbox-checked' },
|
||||
{ value: 'smb', checked: false, icon: 'status:checkbox' },
|
||||
])('checks an array model only when it contains the $value value', ({ value, checked, icon }) => {
|
||||
const state = useCheckboxState(['s3', 'nfs'], value)
|
||||
|
||||
expect(state.isIndeterminate.value).toBe(false)
|
||||
expect(state.isChecked.value).toBe(checked)
|
||||
expect(state.icon.value).toBe(icon)
|
||||
})
|
||||
|
||||
it('follows the model and the value', () => {
|
||||
const model = ref<CheckboxModel>(['s3'])
|
||||
const value = ref('nfs')
|
||||
const state = useCheckboxState(model, value)
|
||||
|
||||
expect(state.isChecked.value).toBe(false)
|
||||
|
||||
value.value = 's3'
|
||||
|
||||
expect(state.isChecked.value).toBe(true)
|
||||
|
||||
model.value = undefined
|
||||
|
||||
expect(state.icon.value).toBe('status:checkbox-partially-checked')
|
||||
})
|
||||
})
|
||||
@@ -160,24 +160,18 @@ export const statusIcons = defineIconPack({
|
||||
'checkbox-checked': [
|
||||
{
|
||||
icon: faSquare,
|
||||
color: 'var(--color-brand-txt-item)',
|
||||
color: 'var(--checkbox-mark-color, var(--color-neutral-background-primary))',
|
||||
size: 10,
|
||||
},
|
||||
{
|
||||
icon: faSquareCheck,
|
||||
color: 'var(--color-brand-item-base)',
|
||||
},
|
||||
constructIcon(faSquareCheck),
|
||||
],
|
||||
'checkbox-partially-checked': [
|
||||
{
|
||||
icon: faSquare,
|
||||
color: 'var(--color-brand-txt-item)',
|
||||
color: 'var(--checkbox-mark-color, var(--color-neutral-background-primary))',
|
||||
size: 10,
|
||||
},
|
||||
{
|
||||
icon: faSquareMinus,
|
||||
color: 'var(--color-brand-item-base)',
|
||||
},
|
||||
constructIcon(faSquareMinus),
|
||||
],
|
||||
'radio-button': constructIcon(circleEmpty),
|
||||
'radio-button-checked': [
|
||||
|
||||
@@ -803,6 +803,7 @@
|
||||
"job:pif-management-reconfigure:bad-power-state": "@:host-not-running",
|
||||
"job:pif-management-reconfigure:current-pif": "Current PIF",
|
||||
"job:pif-management-reconfigure:in-progress": "Management interface reconfiguration in progress…",
|
||||
"job:pif-management-reconfigure:invalid-mtu": "MTU must be {mtu}",
|
||||
"job:pif-management-reconfigure:missing-ip": "IP address missing",
|
||||
"job:plugin-autoload:missing-plugin": "@:plugin-missing",
|
||||
"job:plugin-change-state:already-loaded": "Plugin already loaded",
|
||||
|
||||
@@ -803,6 +803,7 @@
|
||||
"job:pif-management-reconfigure:bad-power-state": "L'hôte n'est pas lancé",
|
||||
"job:pif-management-reconfigure:current-pif": "PIF actuel",
|
||||
"job:pif-management-reconfigure:in-progress": "Reconfiguration de l'interface de gestion en cours…",
|
||||
"job:pif-management-reconfigure:invalid-mtu": "Le MTU doit être de {mtu}",
|
||||
"job:pif-management-reconfigure:missing-ip": "Le PIF cible n'a pas d'adresse IP configurée",
|
||||
"job:plugin-autoload:missing-plugin": "@:plugin-missing",
|
||||
"job:plugin-change-state:already-loaded": "Plugin déjà chargé",
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useActionColumn } from '@core/tables/column-definitions/action-column.t
|
||||
import { useLinkColumn } from '@core/tables/column-definitions/link-column.ts'
|
||||
import { useLiteralColumn } from '@core/tables/column-definitions/literal-column.ts'
|
||||
import { useNumberColumn } from '@core/tables/column-definitions/number-column.ts'
|
||||
import { useProgressBarColumn } from '@core/tables/column-definitions/progress-bar-column.ts'
|
||||
import { useSelectItemColumn } from '@core/tables/column-definitions/select-item-column.ts'
|
||||
import { useTruncatedTextColumn } from '@core/tables/column-definitions/truncated-text-column.ts'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
@@ -14,7 +13,7 @@ export const useVdiColumns = defineColumns(() => {
|
||||
return {
|
||||
vdi: useLinkColumn({ headerLabel: () => t('vdis'), flexible: true }),
|
||||
description: useTruncatedTextColumn({ headerLabel: () => t('description') }),
|
||||
usedSpace: useProgressBarColumn({ headerLabel: () => t('used-space') }),
|
||||
usedSpace: useNumberColumn({ headerLabel: () => t('used-space') }),
|
||||
size: useNumberColumn({ headerLabel: () => t('size') }),
|
||||
format: useLiteralColumn({ headerLabel: () => t('format') }),
|
||||
actions: useActionColumn({}),
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<template v-if="form.hasBackupRepositorySection.value">
|
||||
<UiSubtitle>{{ t('backup-repositories') }}</UiSubtitle>
|
||||
<VtsTabularKeyValueList>
|
||||
<VtsTabularKeyValueRow :label="t('target-proxy')" :value="targetProxy?.name" />
|
||||
<VtsTabularKeyValueRow v-if="form.hasTargetProxy.value" :label="t('target-proxy')" :value="targetProxy?.name" />
|
||||
<VtsTabularKeyValueRow :label="t('scope-type')" :value="backupRepositoryScopeTypeLabel" />
|
||||
<VtsTabularKeyValueRow
|
||||
v-if="backupRepository.formData.backupRepositoryScopeType === 'manual'"
|
||||
|
||||
@@ -98,7 +98,7 @@ function mountTargetStep(dataSource: BackupJobDataSource, storageTargets: Backup
|
||||
|
||||
return mount(
|
||||
defineComponent(() => {
|
||||
const form = useBackupJobTargetForm(data, ref(dataSource), ref(undefined))
|
||||
const form = useBackupJobTargetForm(data, ref(dataSource), ref(undefined), ref(undefined))
|
||||
|
||||
return () => h(BackupJobTargetStep, { form })
|
||||
}),
|
||||
@@ -171,3 +171,15 @@ it('offers no retention strategy to a metadata backup', () => {
|
||||
|
||||
expect(section.props()).toMatchObject({ hasRetentionStrategy: false, hasStrictGfs: false })
|
||||
})
|
||||
|
||||
it('lets a VM backup choose its target proxy', () => {
|
||||
const section = mountTargetStep('vm', ['backup-repository']).getComponent(BackupJobTargetBackupRepositorySection)
|
||||
|
||||
expect(section.props('hasTargetProxy')).toBe(true)
|
||||
})
|
||||
|
||||
it('offers no target proxy to a mirror backup, which uses its source proxy', () => {
|
||||
const section = mountTargetStep('mirror').getComponent(BackupJobTargetBackupRepositorySection)
|
||||
|
||||
expect(section.props('hasTargetProxy')).toBe(false)
|
||||
})
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
:busy="!backupRepository.areBackupRepositoriesReady.value"
|
||||
:has-retention-strategy
|
||||
:has-strict-gfs
|
||||
:has-target-proxy
|
||||
/>
|
||||
<BackupJobTargetStorageRepositorySection
|
||||
v-if="hasStorageRepositorySection"
|
||||
@@ -43,6 +44,7 @@ const {
|
||||
hasBackupRepositorySection,
|
||||
hasRetentionStrategy,
|
||||
hasStrictGfs,
|
||||
hasTargetProxy,
|
||||
hasHealthCheckSection,
|
||||
hasStorageRepositorySection,
|
||||
} = form
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="backup-job-target-backup-repository-section">
|
||||
<UiTitle>{{ t('backup-repositories') }}</UiTitle>
|
||||
|
||||
<div class="block">
|
||||
<div v-if="hasTargetProxy" class="block">
|
||||
<span class="typo-body-bold">{{ t('general-information') }}</span>
|
||||
<BackupJobFormSelect v-bind="bindings.targetProxy" />
|
||||
</div>
|
||||
@@ -77,6 +77,7 @@ const { bindings } = defineProps<{
|
||||
busy: boolean
|
||||
hasRetentionStrategy: boolean
|
||||
hasStrictGfs: boolean
|
||||
hasTargetProxy: boolean
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -142,7 +142,8 @@ export function useNewBackupJobForm() {
|
||||
const target = useBackupJobTargetForm(
|
||||
reactive(createTargetFormData()),
|
||||
() => source.formData.dataSource,
|
||||
() => source.formData.sourceBackupRepository
|
||||
() => source.formData.sourceBackupRepository,
|
||||
() => source.formData.proxy
|
||||
)
|
||||
|
||||
const planning = useBackupJobPlanningForm(reactive(createPlanningFormData()))
|
||||
|
||||
@@ -50,7 +50,8 @@ export function useBackupJobTargetBackupRepositoryForm(
|
||||
formData: BackupJobTargetBackupRepositoryFormData,
|
||||
rawIsActive: MaybeRefOrGetter<boolean>,
|
||||
rawHasRetentionStrategy: MaybeRefOrGetter<boolean>,
|
||||
rawSourceBackupRepositoryId: MaybeRefOrGetter<FrontXoBackupRepository['id'] | undefined>
|
||||
rawSourceBackupRepositoryId: MaybeRefOrGetter<FrontXoBackupRepository['id'] | undefined>,
|
||||
rawProxy: MaybeRefOrGetter<FrontXoProxy['id'] | undefined>
|
||||
) {
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -60,6 +61,8 @@ export function useBackupJobTargetBackupRepositoryForm(
|
||||
|
||||
const sourceBackupRepositoryId = toComputed(rawSourceBackupRepositoryId)
|
||||
|
||||
const proxy = toComputed(rawProxy)
|
||||
|
||||
const { proxies } = useXoProxyCollection()
|
||||
|
||||
const { backupRepositories, areBackupRepositoriesReady } = useXoBackupRepositoryCollection()
|
||||
@@ -69,7 +72,7 @@ export function useBackupJobTargetBackupRepositoryForm(
|
||||
)
|
||||
|
||||
const compatibleBackupRepositories = computed(() =>
|
||||
availableBackupRepositories.value.filter(br => br.proxy === formData.targetProxy)
|
||||
availableBackupRepositories.value.filter(br => br.proxy === proxy.value)
|
||||
)
|
||||
|
||||
const matchedBackupRepositories = computed(() =>
|
||||
|
||||
@@ -11,7 +11,7 @@ import { createBr } from '@/test/create-br.ts'
|
||||
import { mountComposable } from '@/test/mount-composable.ts'
|
||||
import { mockModule } from '@/test/spy-on-module.ts'
|
||||
import { flushPromises } from '@vue/test-utils'
|
||||
import { reactive, ref } from 'vue'
|
||||
import { reactive, type Ref, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const PROXY_ID = 'proxy-1' as FrontXoProxy['id']
|
||||
@@ -60,10 +60,12 @@ function mountBackupRepositoryForm(
|
||||
isActive = true,
|
||||
hasRetentionStrategy = true,
|
||||
sourceBackupRepositoryId = undefined,
|
||||
proxy = ref(undefined),
|
||||
}: {
|
||||
isActive?: boolean
|
||||
hasRetentionStrategy?: boolean
|
||||
sourceBackupRepositoryId?: FrontXoBackupRepository['id']
|
||||
proxy?: Ref<FrontXoProxy['id'] | undefined>
|
||||
} = {}
|
||||
) {
|
||||
return mountComposable(() => {
|
||||
@@ -74,7 +76,8 @@ function mountBackupRepositoryForm(
|
||||
reactive({ ...createBackupRepositoryFormData(), ...formData }),
|
||||
ref(isActive),
|
||||
ref(hasRetentionStrategy),
|
||||
ref(sourceBackupRepositoryId)
|
||||
ref(sourceBackupRepositoryId),
|
||||
proxy
|
||||
),
|
||||
t,
|
||||
}
|
||||
@@ -96,14 +99,14 @@ describe('availableBackupRepositories', () => {
|
||||
})
|
||||
|
||||
describe('compatibleBackupRepositories', () => {
|
||||
it('keeps the backup repositories without proxy when no target proxy is selected', () => {
|
||||
it('keeps the backup repositories without proxy when no proxy is given', () => {
|
||||
const form = mountBackupRepositoryForm()
|
||||
|
||||
expect(form.compatibleBackupRepositories.map(br => br.id)).toEqual([NFS_BR.id, LOCAL_BR.id])
|
||||
})
|
||||
|
||||
it('keeps the backup repositories using the target proxy', () => {
|
||||
const form = mountBackupRepositoryForm({ targetProxy: PROXY_ID })
|
||||
it('keeps the backup repositories using the given proxy', () => {
|
||||
const form = mountBackupRepositoryForm({}, { proxy: ref(PROXY_ID) })
|
||||
|
||||
expect(form.compatibleBackupRepositories.map(br => br.id)).toEqual([PROXY_BR.id])
|
||||
})
|
||||
@@ -118,10 +121,11 @@ describe('matchedBackupRepositories', () => {
|
||||
})
|
||||
|
||||
describe('formData', () => {
|
||||
it('drops the selected backup repositories which do not use the new target proxy', async () => {
|
||||
const form = mountBackupRepositoryForm({ backupRepositoryIds: [NFS_BR.id] })
|
||||
it('drops the selected backup repositories which do not use the new proxy', async () => {
|
||||
const proxy = ref<FrontXoProxy['id']>()
|
||||
const form = mountBackupRepositoryForm({ backupRepositoryIds: [NFS_BR.id] }, { proxy })
|
||||
|
||||
form.formData.targetProxy = PROXY_ID
|
||||
proxy.value = PROXY_ID
|
||||
await flushPromises()
|
||||
|
||||
expect(form.formData.backupRepositoryIds).toEqual([])
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import type { BackupJobDataSource } from '@/modules/backup-job/form/use-backup-job-source-form.ts'
|
||||
import type { BackupJobFormOption } from '@/modules/backup-job/types/backup-job-form.type.ts'
|
||||
import type { FrontXoBackupRepository } from '@/modules/backup-repository/remote-resources/use-xo-backup-repository-collection.ts'
|
||||
import type { FrontXoProxy } from '@/modules/proxy/remote-resources/use-xo-proxy-collection.ts'
|
||||
import { requiredIf, withMessage } from '@core/packages/form-validation'
|
||||
import { useValidatedForm } from '@core/packages/validated-form'
|
||||
import { toComputed } from '@core/utils/to-computed.util.ts'
|
||||
@@ -33,12 +34,15 @@ export type BackupJobTargetForm = ReturnType<typeof useBackupJobTargetForm>
|
||||
export function useBackupJobTargetForm(
|
||||
formData: BackupJobTargetFormData,
|
||||
rawDataSource: MaybeRefOrGetter<BackupJobDataSource>,
|
||||
rawSourceBackupRepositoryId: MaybeRefOrGetter<FrontXoBackupRepository['id'] | undefined>
|
||||
rawSourceBackupRepositoryId: MaybeRefOrGetter<FrontXoBackupRepository['id'] | undefined>,
|
||||
rawSourceProxy: MaybeRefOrGetter<FrontXoProxy['id'] | undefined>
|
||||
) {
|
||||
const { t } = useI18n()
|
||||
|
||||
const dataSource = toComputed(rawDataSource)
|
||||
|
||||
const sourceProxy = toComputed(rawSourceProxy)
|
||||
|
||||
const hasStorageTargetChoice = computed(() => dataSource.value === 'vm')
|
||||
|
||||
const hasBackupRepositorySection = computed(
|
||||
@@ -49,6 +53,12 @@ export function useBackupJobTargetForm(
|
||||
|
||||
const hasStrictGfs = computed(() => hasRetentionStrategy.value && dataSource.value !== 'mirror')
|
||||
|
||||
const hasTargetProxy = computed(() => dataSource.value !== 'mirror')
|
||||
|
||||
const backupRepositoryProxy = computed(() =>
|
||||
hasTargetProxy.value ? formData.backupRepository.targetProxy : sourceProxy.value
|
||||
)
|
||||
|
||||
const hasHealthCheckSection = computed(() => dataSource.value !== 'metadata')
|
||||
|
||||
const hasStorageRepositorySection = computed(
|
||||
@@ -59,7 +69,8 @@ export function useBackupJobTargetForm(
|
||||
formData.backupRepository,
|
||||
hasBackupRepositorySection,
|
||||
hasRetentionStrategy,
|
||||
rawSourceBackupRepositoryId
|
||||
rawSourceBackupRepositoryId,
|
||||
backupRepositoryProxy
|
||||
)
|
||||
|
||||
const storageRepository = useBackupJobTargetStorageRepositoryForm(
|
||||
@@ -135,6 +146,7 @@ export function useBackupJobTargetForm(
|
||||
hasBackupRepositorySection,
|
||||
hasRetentionStrategy,
|
||||
hasStrictGfs,
|
||||
hasTargetProxy,
|
||||
hasHealthCheckSection,
|
||||
hasStorageRepositorySection,
|
||||
getStorageTargetLabel,
|
||||
|
||||
@@ -4,25 +4,34 @@ import {
|
||||
type BackupJobTargetFormData,
|
||||
useBackupJobTargetForm,
|
||||
} from '@/modules/backup-job/form/use-backup-job-target-form.ts'
|
||||
import type { useXoBackupRepositoryCollection } from '@/modules/backup-repository/remote-resources/use-xo-backup-repository-collection.ts'
|
||||
import type {
|
||||
FrontXoBackupRepository,
|
||||
useXoBackupRepositoryCollection,
|
||||
} from '@/modules/backup-repository/remote-resources/use-xo-backup-repository-collection.ts'
|
||||
import type { useXoHostCollection } from '@/modules/host/remote-resources/use-xo-host-collection.ts'
|
||||
import type { useXoPbdCollection } from '@/modules/pbd/remote-resources/use-xo-pbd-collection.ts'
|
||||
import type { useXoPoolCollection } from '@/modules/pool/remote-resources/use-xo-pool-collection.ts'
|
||||
import type { useXoProxyCollection } from '@/modules/proxy/remote-resources/use-xo-proxy-collection.ts'
|
||||
import type { FrontXoProxy, useXoProxyCollection } from '@/modules/proxy/remote-resources/use-xo-proxy-collection.ts'
|
||||
import type { useXoSrCollection } from '@/modules/storage-repository/remote-resources/use-xo-sr-collection.ts'
|
||||
import type { useXoVmCollection } from '@/modules/vm/remote-resources/use-xo-vm-collection.ts'
|
||||
import { createBr } from '@/test/create-br.ts'
|
||||
import { mountComposable } from '@/test/mount-composable.ts'
|
||||
import { mockModule } from '@/test/spy-on-module.ts'
|
||||
import { reactive, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const PROXY_ID = 'proxy-1' as FrontXoProxy['id']
|
||||
|
||||
const NO_PROXY_BR = createBr({ id: 'br-no-proxy' as FrontXoBackupRepository['id'] })
|
||||
const PROXY_BR = createBr({ id: 'br-proxy' as FrontXoBackupRepository['id'], proxy: PROXY_ID })
|
||||
|
||||
mockModule(import('@/modules/proxy/remote-resources/use-xo-proxy-collection.ts'), () => ({
|
||||
useXoProxyCollection: (() => ({ proxies: ref([]) })) as unknown as typeof useXoProxyCollection,
|
||||
}))
|
||||
|
||||
mockModule(import('@/modules/backup-repository/remote-resources/use-xo-backup-repository-collection.ts'), () => ({
|
||||
useXoBackupRepositoryCollection: (() => ({
|
||||
backupRepositories: ref([]),
|
||||
backupRepositories: ref([NO_PROXY_BR, PROXY_BR]),
|
||||
areBackupRepositoriesReady: ref(true),
|
||||
})) as unknown as typeof useXoBackupRepositoryCollection,
|
||||
}))
|
||||
@@ -96,8 +105,10 @@ function mountTargetForm(
|
||||
{
|
||||
storageTargets,
|
||||
backupRepository,
|
||||
sourceProxy,
|
||||
}: Partial<Pick<BackupJobTargetFormData, 'storageTargets'>> & {
|
||||
backupRepository?: Partial<BackupJobTargetBackupRepositoryFormData>
|
||||
sourceProxy?: FrontXoProxy['id']
|
||||
} = {}
|
||||
) {
|
||||
const formData = createTargetFormData()
|
||||
@@ -113,7 +124,8 @@ function mountTargetForm(
|
||||
backupRepository: { ...formData.backupRepository, ...backupRepository },
|
||||
}),
|
||||
ref(dataSource),
|
||||
ref(undefined)
|
||||
ref(undefined),
|
||||
ref(sourceProxy)
|
||||
),
|
||||
t,
|
||||
}
|
||||
@@ -126,6 +138,7 @@ function getSections(form: ReturnType<typeof mountTargetForm>) {
|
||||
hasBackupRepositorySection: form.hasBackupRepositorySection,
|
||||
hasRetentionStrategy: form.hasRetentionStrategy,
|
||||
hasStrictGfs: form.hasStrictGfs,
|
||||
hasTargetProxy: form.hasTargetProxy,
|
||||
hasStorageRepositorySection: form.hasStorageRepositorySection,
|
||||
hasHealthCheckSection: form.hasHealthCheckSection,
|
||||
}
|
||||
@@ -138,6 +151,7 @@ describe('sections', () => {
|
||||
hasBackupRepositorySection: true,
|
||||
hasRetentionStrategy: true,
|
||||
hasStrictGfs: true,
|
||||
hasTargetProxy: true,
|
||||
hasStorageRepositorySection: false,
|
||||
hasHealthCheckSection: true,
|
||||
})
|
||||
@@ -149,17 +163,19 @@ describe('sections', () => {
|
||||
hasBackupRepositorySection: false,
|
||||
hasRetentionStrategy: false,
|
||||
hasStrictGfs: false,
|
||||
hasTargetProxy: true,
|
||||
hasStorageRepositorySection: true,
|
||||
hasHealthCheckSection: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('stores a mirror backup on backup repositories, without strict GFS hierarchy', () => {
|
||||
it('stores a mirror backup on backup repositories, without strict GFS hierarchy nor target proxy', () => {
|
||||
expect(getSections(mountTargetForm('mirror', { storageTargets: [] }))).toEqual({
|
||||
hasStorageTargetChoice: false,
|
||||
hasBackupRepositorySection: true,
|
||||
hasRetentionStrategy: true,
|
||||
hasStrictGfs: false,
|
||||
hasTargetProxy: false,
|
||||
hasStorageRepositorySection: false,
|
||||
hasHealthCheckSection: true,
|
||||
})
|
||||
@@ -171,12 +187,27 @@ describe('sections', () => {
|
||||
hasBackupRepositorySection: true,
|
||||
hasRetentionStrategy: false,
|
||||
hasStrictGfs: false,
|
||||
hasTargetProxy: true,
|
||||
hasStorageRepositorySection: false,
|
||||
hasHealthCheckSection: false,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('backupRepository', () => {
|
||||
it('offers a mirror backup the backup repositories using its source proxy', () => {
|
||||
const form = mountTargetForm('mirror', { storageTargets: [], sourceProxy: PROXY_ID })
|
||||
|
||||
expect(form.backupRepository.compatibleBackupRepositories.value.map(br => br.id)).toEqual([PROXY_BR.id])
|
||||
})
|
||||
|
||||
it('offers a VM backup the backup repositories using its target proxy, whatever the source proxy', () => {
|
||||
const form = mountTargetForm('vm', { sourceProxy: PROXY_ID })
|
||||
|
||||
expect(form.backupRepository.compatibleBackupRepositories.value.map(br => br.id)).toEqual([NO_PROXY_BR.id])
|
||||
})
|
||||
})
|
||||
|
||||
describe('validate', () => {
|
||||
it('accepts a VM backup on every backup repository', async () => {
|
||||
const form = mountTargetForm('vm')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useXoHostCollection } from '@/modules/host/remote-resources/use-xo-host-collection.ts'
|
||||
import { useXoNetworkCollection } from '@/modules/network/remote-resources/use-xo-network-collection.ts'
|
||||
import { xoPifArg } from '@/modules/pif/jobs/xo-pif-args.ts'
|
||||
import type { FrontXoPif } from '@/modules/pif/remote-resources/use-xo-pif-collection.ts'
|
||||
import { useXoTaskUtils } from '@/shared/composables/xo-task-utils.composable.ts'
|
||||
@@ -13,6 +14,8 @@ import {
|
||||
} from '@vates/types'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const MANAGEMENT_MTU = 1500
|
||||
|
||||
function hasIpConfiguration(pif: FrontXoPif) {
|
||||
return pif.primaryAddressType === PRIMARY_ADDRESS_TYPE.IPV6
|
||||
? pif.ipv6Mode !== IPV6_CONFIGURATION_MODE.NONE
|
||||
@@ -23,6 +26,7 @@ export const useXoPifManagementReconfigureJob = defineJob('pif.management-reconf
|
||||
const { t } = useI18n()
|
||||
const { monitorTask } = useXoTaskUtils()
|
||||
const { getHostById } = useXoHostCollection()
|
||||
const { getNetworkById } = useXoNetworkCollection()
|
||||
|
||||
return {
|
||||
async run(pif: FrontXoPif) {
|
||||
@@ -53,6 +57,12 @@ export const useXoPifManagementReconfigureJob = defineJob('pif.management-reconf
|
||||
throw new JobError(t('job:pif-management-reconfigure:current-pif'))
|
||||
}
|
||||
|
||||
const network = getNetworkById(pif.$network)
|
||||
|
||||
if (network?.MTU !== MANAGEMENT_MTU) {
|
||||
throw new JobError(t('job:pif-management-reconfigure:invalid-mtu', { mtu: MANAGEMENT_MTU }))
|
||||
}
|
||||
|
||||
if (!hasIpConfiguration(pif)) {
|
||||
throw new JobError(t('job:pif-management-reconfigure:missing-ip'))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
import { useXoPifManagementReconfigureJob } from '@/modules/pif/jobs/xo-pif-management-reconfigure.job.ts'
|
||||
import type { FrontXoPif } from '@/modules/pif/remote-resources/use-xo-pif-collection.ts'
|
||||
import { fetchPost } from '@/shared/utils/fetch.util.ts'
|
||||
import { createHost } from '@/test/create-host.ts'
|
||||
import { createNetwork } from '@/test/create-network.ts'
|
||||
import { createPif } from '@/test/create-pif.ts'
|
||||
import { t } from '@/test/i18n.ts'
|
||||
import { itCannotRun, itCanRun, itRejectsWithRequestError } from '@/test/job-cases.ts'
|
||||
import { expectJobRunning } from '@/test/job-running.ts'
|
||||
import { mockXoCollections, xoCollectionsMock } from '@/test/mock-xo-collections.ts'
|
||||
import { answerPostsWithTask, mockXoTaskUtils, taskUtilsMock } from '@/test/mock-xo-task-utils.ts'
|
||||
import { mountComposable } from '@/test/mount-composable.ts'
|
||||
import { mockedExport } from '@/test/spy-on-module.ts'
|
||||
import { HOST_POWER_STATE, IP_CONFIGURATION_MODE, IPV6_CONFIGURATION_MODE, PRIMARY_ADDRESS_TYPE } from '@vates/types'
|
||||
|
||||
const post = mockedExport(fetchPost)
|
||||
|
||||
const { monitorTask } = taskUtilsMock
|
||||
|
||||
// The task collection would open an SSE subscription
|
||||
mockXoTaskUtils()
|
||||
|
||||
mockXoCollections('host', 'network')
|
||||
|
||||
const PIF = createPif()
|
||||
|
||||
const PIF_WITHOUT_IP = createPif({ mode: IP_CONFIGURATION_MODE.NONE })
|
||||
|
||||
const MANAGEMENT_MTU = 1500
|
||||
|
||||
const JUMBO_FRAMES_MTU = 9000
|
||||
|
||||
const INVALID_MTU_MESSAGE = t('job:pif-management-reconfigure:invalid-mtu', { mtu: MANAGEMENT_MTU })
|
||||
|
||||
beforeEach(() => {
|
||||
taskUtilsMock.reset()
|
||||
xoCollectionsMock.reset()
|
||||
xoCollectionsMock.hosts.value = [createHost({ id: PIF.$host })]
|
||||
setNetworkMtu(MANAGEMENT_MTU)
|
||||
|
||||
answerPostsWithTask(post)
|
||||
})
|
||||
|
||||
function mountManagementReconfigureJob(pif: FrontXoPif) {
|
||||
return mountComposable(() => useXoPifManagementReconfigureJob(() => pif)).wrapper.vm
|
||||
}
|
||||
|
||||
function setNetworkMtu(mtu: number) {
|
||||
xoCollectionsMock.networks.value = [createNetwork({ id: PIF.$network, MTU: mtu })]
|
||||
}
|
||||
|
||||
describe('validate', () => {
|
||||
itCanRun([
|
||||
{
|
||||
name: 'can run for a PIF with an IP on a network with a 1500 MTU',
|
||||
mountJob: () => mountManagementReconfigureJob(PIF),
|
||||
},
|
||||
{
|
||||
name: 'can run for an IPv6 PIF with an IPv6 configuration',
|
||||
mountJob: () =>
|
||||
mountManagementReconfigureJob(
|
||||
createPif({
|
||||
primaryAddressType: PRIMARY_ADDRESS_TYPE.IPV6,
|
||||
mode: IP_CONFIGURATION_MODE.NONE,
|
||||
ipv6Mode: IPV6_CONFIGURATION_MODE.STATIC,
|
||||
})
|
||||
),
|
||||
},
|
||||
])
|
||||
|
||||
itCannotRun([
|
||||
{
|
||||
name: 'cannot run when the host of the PIF is halted',
|
||||
mountJob: () => {
|
||||
xoCollectionsMock.hosts.value = [createHost({ id: PIF.$host, power_state: HOST_POWER_STATE.HALTED })]
|
||||
|
||||
return mountManagementReconfigureJob(PIF)
|
||||
},
|
||||
errorMessage: t('job:pif-management-reconfigure:bad-power-state'),
|
||||
},
|
||||
{
|
||||
name: 'cannot run when the host of the PIF is not in the collection',
|
||||
mountJob: () => {
|
||||
xoCollectionsMock.hosts.value = []
|
||||
|
||||
return mountManagementReconfigureJob(PIF)
|
||||
},
|
||||
errorMessage: t('job:pif-management-reconfigure:bad-power-state'),
|
||||
},
|
||||
{
|
||||
name: 'cannot run for the current management PIF',
|
||||
mountJob: () => mountManagementReconfigureJob(createPif({ management: true })),
|
||||
errorMessage: t('job:pif-management-reconfigure:current-pif'),
|
||||
},
|
||||
{
|
||||
name: 'cannot run when the network of the PIF has an MTU other than 1500',
|
||||
mountJob: () => {
|
||||
setNetworkMtu(JUMBO_FRAMES_MTU)
|
||||
|
||||
return mountManagementReconfigureJob(PIF)
|
||||
},
|
||||
errorMessage: INVALID_MTU_MESSAGE,
|
||||
},
|
||||
{
|
||||
name: 'cannot run when the network of the PIF is not in the collection',
|
||||
mountJob: () => {
|
||||
xoCollectionsMock.networks.value = []
|
||||
|
||||
return mountManagementReconfigureJob(PIF)
|
||||
},
|
||||
errorMessage: INVALID_MTU_MESSAGE,
|
||||
},
|
||||
{
|
||||
name: 'reports the MTU of the network before the missing IP of the PIF',
|
||||
mountJob: () => {
|
||||
setNetworkMtu(JUMBO_FRAMES_MTU)
|
||||
|
||||
return mountManagementReconfigureJob(PIF_WITHOUT_IP)
|
||||
},
|
||||
errorMessage: INVALID_MTU_MESSAGE,
|
||||
},
|
||||
{
|
||||
name: 'cannot run for an IPv4 PIF without IP configuration',
|
||||
mountJob: () => mountManagementReconfigureJob(PIF_WITHOUT_IP),
|
||||
errorMessage: t('job:pif-management-reconfigure:missing-ip'),
|
||||
},
|
||||
{
|
||||
name: 'cannot run for an IPv6 PIF without IPv6 configuration',
|
||||
mountJob: () =>
|
||||
mountManagementReconfigureJob(
|
||||
createPif({ primaryAddressType: PRIMARY_ADDRESS_TYPE.IPV6, ipv6Mode: IPV6_CONFIGURATION_MODE.NONE })
|
||||
),
|
||||
errorMessage: t('job:pif-management-reconfigure:missing-ip'),
|
||||
},
|
||||
])
|
||||
|
||||
it('cannot run while the management interface is being reconfigured', () => {
|
||||
monitorTask.mockReturnValue(new Promise(() => {}))
|
||||
|
||||
expectJobRunning(mountManagementReconfigureJob(PIF), t('job:pif-management-reconfigure:in-progress'))
|
||||
})
|
||||
})
|
||||
|
||||
describe('run', () => {
|
||||
it('posts the PIF to the management reconfigure action of its host and waits for the task', async () => {
|
||||
await mountManagementReconfigureJob(PIF).run()
|
||||
|
||||
const url = `hosts/${PIF.$host}/actions/management_reconfigure`
|
||||
|
||||
expect(post).toHaveBeenCalledWith(url, { pif: PIF.id })
|
||||
expect(monitorTask).toHaveBeenCalledWith(`task-of-${url}`)
|
||||
})
|
||||
|
||||
itRejectsWithRequestError('rejects when the task fails', {
|
||||
request: monitorTask,
|
||||
errorMessage: 'PIF_HAS_NO_NETWORK_CONFIGURATION()',
|
||||
run: () => mountManagementReconfigureJob(PIF).run(),
|
||||
})
|
||||
})
|
||||
@@ -4,11 +4,7 @@
|
||||
{{ t('space') }}
|
||||
</UiTitle>
|
||||
<VtsTabularKeyValueList v-if="displayedVdi">
|
||||
<VtsTabularKeyValueRow :label="t('used-space-on-sr')" :value="formatSizeSpace(displayedVdi.usage)" />
|
||||
<VtsTabularKeyValueRow
|
||||
:label="t('free-space-on-sr')"
|
||||
:value="formatSizeSpace(displayedVdi.size - displayedVdi.usage)"
|
||||
/>
|
||||
<VtsTabularKeyValueRow :label="t('used-space-on-sr')" :value="formatSizeSpace(usedSpace)" />
|
||||
<VtsTabularKeyValueRow :label="t('allocated-space')" :value="formatSizeSpace(displayedVdi.size)" />
|
||||
</VtsTabularKeyValueList>
|
||||
</UiCard>
|
||||
@@ -31,5 +27,7 @@ const { t } = useI18n()
|
||||
|
||||
const displayedVdi = computed(() => vdi ?? vdiSnapshot)
|
||||
|
||||
const usedSpace = computed(() => vdi?.chainPhysicalUsage ?? vdiSnapshot?.usage ?? 0)
|
||||
|
||||
const formatSizeSpace = (bytes: number) => formatSize(bytes, 2)
|
||||
</script>
|
||||
|
||||
@@ -86,6 +86,7 @@ const { HeadCells, BodyCells } = useVdiColumns({
|
||||
|
||||
const vbd = computed(() => vbds.value.find(vbd => vbd.VM === vm.id))
|
||||
|
||||
const usedSpace = computed(() => formatSizeRaw(vdi.chainPhysicalUsage, 2))
|
||||
const size = computed(() => formatSizeRaw(vdi.size, 2))
|
||||
const format = computed(() => getVdiFormat(vdi.image_format))
|
||||
|
||||
@@ -182,7 +183,7 @@ const { HeadCells, BodyCells } = useVdiColumns({
|
||||
busyTooltip: busyMessage.value,
|
||||
}),
|
||||
description: r => r(vdi.name_description),
|
||||
usedSpace: r => r(vdi.usage, vdi.size),
|
||||
usedSpace: r => r(usedSpace.value.value, usedSpace.value.prefix),
|
||||
size: r => r(size.value.value, size.value.prefix),
|
||||
format: r => r(format.value),
|
||||
actions: r =>
|
||||
|
||||
@@ -1,12 +1,43 @@
|
||||
<template>
|
||||
<VtsSpaceCard :used="vdi.usage" :total="vdi.size" :label="vdi.name_label" />
|
||||
<UiPanelCard>
|
||||
<UiPanelCardTitle size="medium" :label="t('space')" />
|
||||
<VtsCardRowList>
|
||||
<VtsCardRowKeyValue>
|
||||
<template #key>{{ t('used-space') }}</template>
|
||||
<template #value>{{ usedSpace }}</template>
|
||||
<template v-if="vdi.chainPhysicalUsage > 0" #addons>
|
||||
<VtsCopyButton :value="usedSpace" />
|
||||
</template>
|
||||
</VtsCardRowKeyValue>
|
||||
<VtsCardRowKeyValue>
|
||||
<template #key>{{ t('size') }}</template>
|
||||
<template #value>{{ size }}</template>
|
||||
<template v-if="vdi.size > 0" #addons>
|
||||
<VtsCopyButton :value="size" />
|
||||
</template>
|
||||
</VtsCardRowKeyValue>
|
||||
</VtsCardRowList>
|
||||
</UiPanelCard>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { FrontXoVdi } from '@/modules/vdi/remote-resources/use-xo-vdi-collection.ts'
|
||||
import VtsSpaceCard from '@core/components/space-card/VtsSpaceCard.vue'
|
||||
import VtsCardRowKeyValue from '@core/components/card/VtsCardRowKeyValue.vue'
|
||||
import VtsCardRowList from '@core/components/card/VtsCardRowList.vue'
|
||||
import VtsCopyButton from '@core/components/copy-button/VtsCopyButton.vue'
|
||||
import UiPanelCard from '@core/components/ui/panel-card/UiPanelCard.vue'
|
||||
import UiPanelCardTitle from '@core/components/ui/panel-card-title/UiPanelCardTitle.vue'
|
||||
import { formatSize } from '@core/utils/size.util.ts'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineProps<{
|
||||
const { vdi } = defineProps<{
|
||||
vdi: FrontXoVdi
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const usedSpace = computed(() => formatSize(vdi.chainPhysicalUsage, 2))
|
||||
|
||||
const size = computed(() => formatSize(vdi.size, 2))
|
||||
</script>
|
||||
|
||||
@@ -16,6 +16,7 @@ export const vdiFields = [
|
||||
'$pool',
|
||||
'type',
|
||||
'usage',
|
||||
'chainPhysicalUsage',
|
||||
'tags',
|
||||
'uuid',
|
||||
'cbt_enabled',
|
||||
|
||||
@@ -82,7 +82,7 @@ const { HeadCells, BodyCells } = useVmMigrateVdiColumns({
|
||||
},
|
||||
})
|
||||
|
||||
const usedSpace = formatSizeRaw(row.vdi.usage, 2)
|
||||
const usedSpace = formatSizeRaw(row.vdi.chainPhysicalUsage, 2)
|
||||
const sourceSrName = row.sourceSr?.name_label ?? ''
|
||||
|
||||
return {
|
||||
|
||||
@@ -15,6 +15,7 @@ export function createVdi(overrides: Partial<FrontXoVdi> = {}): FrontXoVdi {
|
||||
$pool: 'pool-789' as FrontXoVdi['$pool'],
|
||||
type: 'VDI',
|
||||
usage: 5368709120,
|
||||
chainPhysicalUsage: 5368709120,
|
||||
tags: [],
|
||||
uuid: 'vdi-uuid-1',
|
||||
cbt_enabled: false,
|
||||
|
||||
@@ -10,14 +10,19 @@
|
||||
> Users must be able to say: "Nice enhancement, I'm eager to test it"
|
||||
|
||||
- [REST API] Get the state of a proxy appliance updater: `GET /rest/v0/proxies/:id/appliance_updater_state` (PR [#10773](https://github.com/vatesfr/xen-orchestra/pull/10773))
|
||||
- [REST API] Upgrade a proxy appliance: `POST /rest/v0/proxies/:id/actions/upgrade` (PR [#10872](https://github.com/vatesfr/xen-orchestra/pull/10872))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
> Users must be able to say: "I had this issue, happy to know it's fixed"
|
||||
|
||||
- [Light theme] Danger backgrounds (selected, hover and active) use the lighter red tints of the design system (PR [#10891](https://github.com/vatesfr/xen-orchestra/pull/10891))
|
||||
- [Dark mode] Selected, hovered and pressed backgrounds of danger elements (buttons, tags, chips, toasters…) are darker, as designed, so their text is easier to read (PR [#10888](https://github.com/vatesfr/xen-orchestra/pull/10888))
|
||||
- [Backups/Merge] The background merge no longer crashes with `ENAMETOOLONG` when a VM's backups are locked by another job: it waits 5 minutes before trying again instead of retrying in a loop (PR [#10866](https://github.com/vatesfr/xen-orchestra/pull/10866))
|
||||
- [V2V] When the import of a disk fails before its transfer starts, the task shows the reason given by the migration engine (e.g. `could not connect: timed out`) instead of `stream has ended without data, was looking for 8 bytes` (PR [#10842](https://github.com/vatesfr/xen-orchestra/pull/10842))
|
||||
- [XO6] A PIF can no longer be set as the management PIF when its network MTU is not 1500, which XCP-ng does not support on management interfaces (PR [#10905](https://github.com/vatesfr/xen-orchestra/pull/10905))
|
||||
- [XO6] A VM converted into a template no longer stays in the VM list and treeview, contribution by [@pcbeingused333](https://github.com/pcbeingused333), fixes issue [#10717](https://github.com/vatesfr/xen-orchestra/issues/10717) (PR [#10884](https://github.com/vatesfr/xen-orchestra/pull/10884))
|
||||
- [VDIs] The used space of a VDI now includes its whole snapshot chain instead of only its last layer, which was almost 0 for disks with snapshots (e.g. after backups). As it can exceed the disk size, it is shown as a size, without usage bar or free space (PR [#10902](https://github.com/vatesfr/xen-orchestra/pull/10902))
|
||||
- [XO6/Backup jobs] Remove the Target proxy field from the mirror backup job form (PR [#10914](https://github.com/vatesfr/xen-orchestra/pull/10914))
|
||||
|
||||
### Packages to release
|
||||
|
||||
@@ -37,8 +42,11 @@
|
||||
|
||||
- @vates/nbd-client patch
|
||||
- @vates/types minor
|
||||
- @xen-orchestra/acl minor
|
||||
- @xen-orchestra/backups patch
|
||||
- @xen-orchestra/rest-api minor
|
||||
- @xen-orchestra/web patch
|
||||
- @xen-orchestra/web-core patch
|
||||
- xo-collection patch
|
||||
- xo-server patch
|
||||
|
||||
<!--packages-end-->
|
||||
|
||||
@@ -190,7 +190,7 @@ This action makes the XO server send a GET request to the given URL, so the hold
|
||||
| | `reclaim-space`, |
|
||||
| `schedule` | `read`, `run` |
|
||||
| `restore-log` | `read` |
|
||||
| `proxy` | `read`, `upgrade` |
|
||||
| `proxy` | `read` |
|
||||
| `server` | `read`, `create`, `delete`, `connect`, `disconnect` |
|
||||
| `task` | `read`, `abort`, `delete` |
|
||||
| `alarm` | `read` |
|
||||
|
||||
@@ -107,7 +107,14 @@ export class Index {
|
||||
const type = getIndexType(value)
|
||||
|
||||
// Removes item from the previous type's list if any.
|
||||
if (prevType != null) delete itemsByType[prevType][key]
|
||||
if (prevType != null) {
|
||||
delete itemsByType[prevType][key]
|
||||
|
||||
// The item left this type: let the listeners of the previous type know.
|
||||
if (prevType !== type) {
|
||||
this.getEventEmitterByType(prevType)?.emit('remove', undefined, previousObj)
|
||||
}
|
||||
}
|
||||
|
||||
// Inserts item into the new type's list if any.
|
||||
if (type != null) {
|
||||
|
||||
@@ -135,6 +135,55 @@ describe('Index', function () {
|
||||
})
|
||||
})
|
||||
|
||||
it('emits remove on the previous type when an item changes type', function () {
|
||||
const removed = []
|
||||
const updated = []
|
||||
byGroup.getEventEmitterByType('foo').on('remove', (_, prev) => removed.push(prev))
|
||||
byGroup.getEventEmitterByType('foo').on('update', value => updated.push(value))
|
||||
|
||||
const item1bis = {
|
||||
id: item1.id,
|
||||
group: 'bar',
|
||||
}
|
||||
col.update(item1bis)
|
||||
|
||||
return waitTicks().then(() => {
|
||||
assert.deepEqual(removed, [item1])
|
||||
assert.deepEqual(updated, [])
|
||||
})
|
||||
})
|
||||
|
||||
it('emits remove on the previous type when an item no longer has a type', function () {
|
||||
const removed = []
|
||||
byGroup.getEventEmitterByType('foo').on('remove', (_, prev) => removed.push(prev))
|
||||
|
||||
col.update({ id: item1.id })
|
||||
|
||||
return waitTicks().then(() => {
|
||||
assert.deepEqual(removed, [item1])
|
||||
})
|
||||
})
|
||||
|
||||
it('emits update, not remove, when an item keeps the same type', function () {
|
||||
const removed = []
|
||||
const updated = []
|
||||
const ee = byGroup.getEventEmitterByType('foo')
|
||||
ee.on('remove', (_, prev) => removed.push(prev))
|
||||
ee.on('update', (value, prev) => updated.push([value, prev]))
|
||||
|
||||
const item1bis = {
|
||||
id: item1.id,
|
||||
group: 'foo',
|
||||
newProp: true,
|
||||
}
|
||||
col.update(item1bis)
|
||||
|
||||
return waitTicks().then(() => {
|
||||
assert.deepEqual(removed, [])
|
||||
assert.deepEqual(updated, [[item1bis, item1]])
|
||||
})
|
||||
})
|
||||
|
||||
it('correctly updates the value even if the same object has the same hash', function () {
|
||||
const item1bis = {
|
||||
id: item1.id,
|
||||
|
||||
Reference in New Issue
Block a user