Skip to content

Commit

Permalink
Add longhorn support message in Volumes Export,Snapshot,Clone dialogs
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Torchia <[email protected]>
  • Loading branch information
torchiaf committed Nov 14, 2024
1 parent bea1b35 commit d6d1bcb
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 46 deletions.
50 changes: 29 additions & 21 deletions pkg/harvester/dialog/HarvesterExportImageDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,34 @@ export default {
</template>
<template #body>
<LabeledSelect
v-model="namespace"
:label="t('harvester.modal.exportImage.namespace')"
:options="namespaces"
class="mb-20"
required
/>
<LabeledInput
v-model="name"
:label="t('harvester.modal.exportImage.name')"
required
/>
<LabeledSelect
v-model="storageClassName"
:options="storageClassOptions"
:label="t('harvester.storage.storageClass.label')"
class="mt-20"
required
/>
<template v-if="actionResource?.isLonghornV2">
<Banner color="warning">
<t k="harvester.modal.exportImage.message.support.longhorn" :raw="true" />
</Banner>
</template>
<template v-else>
<LabeledSelect
v-model="namespace"
:label="t('harvester.modal.exportImage.namespace')"
:options="namespaces"
class="mb-20"
required
/>
<LabeledInput
v-model="name"
:label="t('harvester.modal.exportImage.name')"
required
/>
<LabeledSelect
v-model="storageClassName"
:options="storageClassOptions"
:label="t('harvester.storage.storageClass.label')"
class="mt-20"
required
/>
</template>
</template>
<div slot="actions" class="actions">
Expand All @@ -171,6 +178,7 @@ export default {
</button>
<AsyncButton
v-if="!actionResource?.isLonghornV2"
mode="create"
:disabled="disableSave"
@click="save"
Expand Down
6 changes: 5 additions & 1 deletion pkg/harvester/dialog/SnapshotDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export default {
{{ t('harvester.modal.snapshot.title') }}
</template>
<template #body>
<LabeledInput
<Banner v-if="actionResource?.isLonghornV2" color="warning">
<t k="harvester.modal.snapshot.message.support.longhorn" :raw="true" />
</Banner>
<LabeledInput v-else

Check warning on line 76 in pkg/harvester/dialog/SnapshotDialog.vue

View workflow job for this annotation

GitHub Actions / lint

Expected a linebreak before this attribute
v-model="name"

Check warning on line 77 in pkg/harvester/dialog/SnapshotDialog.vue

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 20 spaces but found 8 spaces
:label="t('harvester.modal.snapshot.name')"

Check warning on line 78 in pkg/harvester/dialog/SnapshotDialog.vue

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 20 spaces but found 8 spaces
required

Check warning on line 79 in pkg/harvester/dialog/SnapshotDialog.vue

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 20 spaces but found 8 spaces
Expand All @@ -82,6 +85,7 @@ export default {
{{ t('generic.cancel') }}
</button>
<AsyncButton
v-if="!actionResource?.isLonghornV2"
mode="create"
:disabled="disableSave"
@click="save"
Expand Down
24 changes: 16 additions & 8 deletions pkg/harvester/dialog/VolumeCloneDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,30 @@ export default {
{{ t('harvester.modal.volumeClone.title') }}
</template>
<template #body>
<Checkbox v-model="cloneData" class="mb-10" label-key="harvester.modal.cloneVM.type" />
<template v-if="!actionResource?.isLonghornV2">
<Checkbox v-model="cloneData" class="mb-10" label-key="harvester.modal.cloneVM.type" />
<LabeledInput
v-show="cloneData"
v-model="name"
class="mb-20"
:label="t('harvester.modal.volumeClone.name')"
required
/>
<LabeledInput
v-show="cloneData"
v-model="name"
class="mb-20"
:label="t('harvester.modal.volumeClone.name')"
required
/>
</template>
<template v-else>
<Banner color="warning">
<t k="harvester.modal.volumeClone.message.support.longhorn" :raw="true" />
</Banner>
</template>
</template>
<div slot="actions" class="actions">
<div class="buttons">
<button class="btn role-secondary mr-10" @click="close">
{{ t('generic.cancel') }}
</button>
<AsyncButton
v-if="!actionResource?.isLonghornV2"
mode="create"
:disabled="disableSave"
@click="save"
Expand Down
7 changes: 7 additions & 0 deletions pkg/harvester/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ harvester:
namespace: Namespace
message:
success: 'Image { name } created successfully.'
support:
longhorn: The volume uses Longhorn V2 engine, which does not <a href="https://docs.harvesterhci.io/v1.4/advanced/longhorn-v2/#limitations" target="_blank">support</a> the Export Image action.
migration:
failedMessage: Latest migration failed!
title: Migration
Expand Down Expand Up @@ -110,11 +112,16 @@ harvester:
name: Name
message:
success: 'Take Snapshot { name } successfully.'
support:
longhorn: The volume uses Longhorn V2 engine, which does not <a href="https://docs.harvesterhci.io/v1.4/advanced/longhorn-v2/#limitations" target="_blank">support</a> the Take Snapshot action.

volumeClone:
title: Clone Volume
name: Name
message:
success: 'New Volume { name } cloned successfully.'
support:
longhorn: The volume uses Longhorn V2 engine, which does not <a href="https://docs.harvesterhci.io/v1.4/advanced/longhorn-v2/#limitations" target="_blank">support</a> the clone action.
restoreSnapshot:
title: Restore Snapshot
name: 'New Volume Name'
Expand Down
21 changes: 5 additions & 16 deletions pkg/harvester/models/harvester/persistentvolumeclaim.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,13 @@ export default class HciPv extends HarvesterResource {
get availableActions() {
let out = super._availableActions;

Check failure on line 38 in pkg/harvester/models/harvester/persistentvolumeclaim.js

View workflow job for this annotation

GitHub Actions / lint

'out' is never reassigned. Use 'const' instead

// Longhorn V2 provisioner do not support volume clone feature yet
if (this.isLonghornV2) {
out = out.filter(action => action.action !== 'goToClone');
} else {
const clone = out.find(action => action.action === 'goToClone');
const clone = out.find(action => action.action === 'goToClone');

if (clone) {
clone.action = 'goToCloneVolume';
}
if (clone) {
clone.action = 'goToCloneVolume';
}

if (!this.isLonghorn || !this.isLonghornV2) {
out = [
return [
{

Check warning on line 47 in pkg/harvester/models/harvester/persistentvolumeclaim.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8
action: 'exportImage',

Check warning on line 48 in pkg/harvester/models/harvester/persistentvolumeclaim.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 8 spaces but found 10
enabled: this.hasAction('export') && !this.isEncrypted,

Check warning on line 49 in pkg/harvester/models/harvester/persistentvolumeclaim.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 8 spaces but found 10
Expand All @@ -62,12 +56,7 @@ export default class HciPv extends HarvesterResource {
icon: 'icon icon-backup',
label: this.t('harvester.action.snapshot'),
},
...out
];
}

return [
{
{
action: 'cancelExpand',
enabled: this.hasAction('cancelExpand'),
icon: 'icon icon-backup',
Expand Down

0 comments on commit d6d1bcb

Please sign in to comment.