});
expect(tableAction.disable(component.selection)).toBeTruthy();
expect(component.getEditDisableDesc(component.selection)).toBe(
- 'Host editing is disabled because the host is not managed by Orchestrator.'
+ 'Host editing is disabled because the selected host is not managed by Orchestrator.'
);
});
expect(component.getEditDisableDesc(component.selection)).toBeUndefined();
});
});
+
+ describe('getDeleteDisableDesc', () => {
+ it('should return message (not managed by Orchestrator)', () => {
+ component.selection.add({
+ sources: {
+ ceph: false,
+ orchestrator: true
+ }
+ });
+ component.selection.add({
+ sources: {
+ ceph: true,
+ orchestrator: false
+ }
+ });
+ expect(component.getDeleteDisableDesc(component.selection)).toBe(
+ 'Host deletion is disabled because a selected host is not managed by Orchestrator.'
+ );
+ });
+
+ it('should return undefined (no selection)', () => {
+ expect(component.getDeleteDisableDesc(component.selection)).toBeUndefined();
+ });
+
+ it('should return undefined (managed by Orchestrator)', () => {
+ component.selection.add({
+ sources: {
+ ceph: false,
+ orchestrator: true
+ }
+ });
+ component.selection.add({
+ sources: {
+ ceph: false,
+ orchestrator: true
+ }
+ });
+ expect(component.getDeleteDisableDesc(component.selection)).toBeUndefined();
+ });
+ });
});
() => this.deleteAction()
);
},
- disable: () => !this.selection.hasSelection
+ disable: (selection: CdTableSelection) =>
+ !selection.hasSelection ||
+ !selection.selected.every((selected) => selected.sources.orchestrator),
+ disableDesc: this.getDeleteDisableDesc.bind(this)
}
];
}
getEditDisableDesc(selection: CdTableSelection): string | undefined {
if (selection && selection.hasSingleSelection && !selection.first().sources.orchestrator) {
- return this.i18n('Host editing is disabled because the host is not managed by Orchestrator.');
+ return this.i18n(
+ 'Host editing is disabled because the selected host is not managed by Orchestrator.'
+ );
}
return undefined;
}
});
}
+ getDeleteDisableDesc(selection: CdTableSelection): string | undefined {
+ if (
+ selection &&
+ selection.hasSelection &&
+ !selection.selected.every((selected) => selected.sources.orchestrator)
+ ) {
+ return this.i18n(
+ 'Host deletion is disabled because a selected host is not managed by Orchestrator.'
+ );
+ }
+ return undefined;
+ }
+
getHosts(context: CdTableFetchDataContext) {
if (this.isLoadingHosts) {
return;