--- /dev/null
+export const RBDActionHelpers = {
+ moveToTrash: $localize`Move an image to the trash. Images, even ones actively in-use by clones, can be moved to the trash and deleted at a later time.`,
+ delete: $localize`Delete an rbd image (including all data blocks). If the image has snapshots, this fails and nothing is deleted.`,
+ copy: $localize`Copy the content of a source image into the newly created destination image`,
+ flatten: $localize`If the image is a clone, copy all shared blocks from the parent snapshot and make the child independent of the parent, severing the link between parent snap and child. `,
+ enableMirroring: $localize`Mirroring needs to be enabled on the image to perform this action`,
+ clonedSnapshot: $localize`This RBD has cloned snapshots. Please delete related RBDs before deleting this RBD`,
+ secondayImageDelete: $localize`The image cannot be deleted as it is secondary`,
+ primaryImageResync: $localize`Primary RBD images cannot be resynced`,
+ invalidNameDisable: $localize`This RBD image has an invalid name and can't be managed by ceph.`,
+ removingStatus: $localize`Action not possible for an RBD in status 'Removing'`,
+ journalTooltipText: $localize`'Ensures reliable replication by logging changes before updating the image, but doubles write time, impacting performance. Not recommended for high-speed data processing tasks.`,
+ snapshotTooltipText: $localize`This mode replicates RBD images between clusters using snapshots, efficiently copying data changes but requiring complete delta syncing during failover. Ideal for less demanding tasks due to its less granular approach compared to journaling.`
+};
import { DimlessPipe } from '~/app/shared/pipes/dimless.pipe';
import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
import { CdTableServerSideService } from '~/app/shared/services/cd-table-server-side.service';
-// import { ModalService } from '~/app/shared/services/modal.service';
import { TaskListService } from '~/app/shared/services/task-list.service';
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
import { URLBuilderService } from '~/app/shared/services/url-builder.service';
import { RbdTrashMoveModalComponent } from '../rbd-trash-move-modal/rbd-trash-move-modal.component';
import { RBDImageFormat, RbdModel } from './rbd-model';
import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
-
+import { RBDActionHelpers } from '../rbd-contants';
const BASE_URL = 'block/rbd';
@Component({
count = 0;
private tableContext: CdTableFetchDataContext = null;
errorMessage: string;
-
builders = {
'rbd/create': (metadata: object) =>
this.createRbdFromTask(metadata['pool_name'], metadata['namespace'], metadata['image_name']),
icon: Icons.destroy,
click: () => this.deleteRbdModal(),
name: this.actionLabels.DELETE,
+ title: RBDActionHelpers.delete,
disable: (selection: CdTableSelection) => this.getDeleteDisableDesc(selection)
};
+ const moveAction: CdTableAction = {
+ permission: 'delete',
+ icon: Icons.trash,
+ title: RBDActionHelpers.moveToTrash,
+ click: () => this.trashRbdModal(),
+ name: this.actionLabels.TRASH,
+ disable: (selection: CdTableSelection) =>
+ this.getRemovingStatusDesc(selection) ||
+ this.getInvalidNameDisable(selection) ||
+ selection.first().image_format === RBDImageFormat.V1
+ };
const resyncAction: CdTableAction = {
permission: 'update',
icon: Icons.refresh,
!!selection.first().cdExecuting,
icon: Icons.copy,
routerLink: () => `/block/rbd/copy/${getImageUri()}`,
- name: this.actionLabels.COPY
+ name: this.actionLabels.COPY,
+ title: RBDActionHelpers.copy
};
const flattenAction: CdTableAction = {
permission: 'update',
!selection.first().parent,
icon: Icons.flatten,
click: () => this.flattenRbdModal(),
- name: this.actionLabels.FLATTEN
- };
- const moveAction: CdTableAction = {
- permission: 'delete',
- icon: Icons.trash,
- click: () => this.trashRbdModal(),
- name: this.actionLabels.TRASH,
- disable: (selection: CdTableSelection) =>
- this.getRemovingStatusDesc(selection) ||
- this.getInvalidNameDisable(selection) ||
- selection.first().image_format === RBDImageFormat.V1
+ name: this.actionLabels.FLATTEN,
+ title: RBDActionHelpers.flatten
};
+
const removeSchedulingAction: CdTableAction = {
permission: 'update',
icon: Icons.edit,
name: this.actionLabels.PROMOTE,
visible: () => this.selection.first() != null && !this.selection.first().primary,
disable: () =>
- this.selection.first().mirror_mode === 'Disabled'
- ? 'Mirroring needs to be enabled on the image to perform this action'
- : ''
+ this.selection.first().mirror_mode === 'Disabled' ? RBDActionHelpers.enableMirroring : ''
};
const demoteAction: CdTableAction = {
permission: 'update',
name: this.actionLabels.DEMOTE,
visible: () => this.selection.first() != null && this.selection.first().primary,
disable: () =>
- this.selection.first().mirror_mode === 'Disabled'
- ? 'Mirroring needs to be enabled on the image to perform this action'
- : ''
+ this.selection.first().mirror_mode === 'Disabled' ? RBDActionHelpers.enableMirroring : ''
};
this.tableActions = [
addAction,
copyAction,
flattenAction,
resyncAction,
- deleteAction,
- moveAction,
removeSchedulingAction,
promoteAction,
- demoteAction
+ demoteAction,
+ moveAction,
+ deleteAction
];
}
const first = selection.first();
if (first && this.hasClonedSnapshots(first)) {
- return $localize`This RBD has cloned snapshots. Please delete related RBDs before deleting this RBD.`;
+ return RBDActionHelpers.clonedSnapshot;
}
-
- return this.getInvalidNameDisable(selection) || this.hasClonedSnapshots(selection.first());
+ if (first && first.primary === false) {
+ return RBDActionHelpers.secondayImageDelete;
+ }
+ return (
+ this.getInvalidNameDisable(selection) ||
+ this.hasClonedSnapshots(selection.first()) ||
+ first.primary === false
+ );
}
getResyncDisableDesc(selection: CdTableSelection): string | boolean {
const first = selection.first();
if (first && this.imageIsPrimary(first)) {
- return $localize`Primary RBD images cannot be resynced`;
+ return RBDActionHelpers.primaryImageResync;
}
return this.getInvalidNameDisable(selection);
const first = selection.first();
if (first?.name?.match(/[@/]/)) {
- return $localize`This RBD image has an invalid name and can't be managed by ceph.`;
+ return RBDActionHelpers.invalidNameDisable;
}
return !selection.first() || !selection.hasSingleSelection;
getRemovingStatusDesc(selection: CdTableSelection): string | boolean {
const first = selection.first();
if (first?.source === 'REMOVING') {
- return $localize`Action not possible for an RBD in status 'Removing'`;
+ return RBDActionHelpers.removingStatus;
}
return false;
}