Show delete button if no more contexts available

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev committed 2021-09-08 13:38:22 +03:00
1 parent 45a78d2df7
commit a9d68d29a2
1 file changed
+10 -2
@@ -123,7 +123,15 @@ export class DeleteClusterDialog extends React.Component {
}
@computed get disableDelete() {
return this.showContextSwitch && (this.newCurrentContext === "");
const { cluster, config } = dialogState;
const noContextsAvailable = config.contexts.filter(context => context.name !== cluster.contextName).length == 0;
const newContextNotSelected = this.newCurrentContext === "";
if (noContextsAvailable) {
return false;
}
return this.showContextSwitch && newContextNotSelected;
}
isCurrentContext() {
@@ -172,7 +180,7 @@ export class DeleteClusterDialog extends React.Component {
</div>
);
}
getWarningMessage() {
const { cluster, config } = dialogState;
const contexts = config.contexts.filter(context => context.name !== cluster.contextName);