Skip to content

Commit 47966e4

Browse files
committed
switching undeploy domain to use the same prompting style as uninstall actions
1 parent 4b8cd38 commit 47966e4

File tree

6 files changed

+26
-82
lines changed

6 files changed

+26
-82
lines changed

electron/app/js/ipcRendererPreload.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ contextBridge.exposeInMainWorld(
192192
'k8s-delete-object',
193193
'openssl-generate-certs',
194194
'validate-k8s-namespaces-exist',
195-
'validate-wko-domain-exist',
196-
'domain-undeploy-scope-prompt'
195+
'validate-wko-domain-exist'
197196
];
198197
return new Promise((resolve, reject) => {
199198
if (validChannels.includes(channel)) {

electron/app/js/wktWindow.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,36 +1032,6 @@ async function promptUserForYesNoOrCancelAnswer(targetWindow, title, question, d
10321032
});
10331033
}
10341034

1035-
async function promptUserForK8sDomainRemovalScope(targetWindow, title, question, details) {
1036-
return new Promise(resolve => {
1037-
dialog.showMessageBox(targetWindow, {
1038-
title: title,
1039-
message: question,
1040-
detail: details,
1041-
type: 'question',
1042-
buttons: [ i18n.t('button-cancel'), i18n.t('button-domain-only'), i18n.t('button-domain-namespace') ],
1043-
defaultId: 1,
1044-
cancelId: 0
1045-
}).then(dialogResponse => {
1046-
let response;
1047-
switch (dialogResponse.response) {
1048-
case 2:
1049-
response = 'namespace';
1050-
break;
1051-
1052-
case 1:
1053-
response = 'domain';
1054-
break;
1055-
1056-
case 0:
1057-
response = 'cancel';
1058-
break;
1059-
}
1060-
resolve(response);
1061-
});
1062-
});
1063-
}
1064-
10651035
async function promptUserForOkOrCancelAnswer(targetWindow, title, message) {
10661036
return new Promise(resolve => {
10671037
dialog.showMessageBox(targetWindow, {
@@ -1118,7 +1088,6 @@ module.exports = {
11181088
setHasOpenDialog,
11191089
setTargetType,
11201090
showErrorMessage,
1121-
promptUserForK8sDomainRemovalScope,
11221091
promptUserForOkOrCancelAnswer,
11231092
promptUserForYesOrNoAnswer,
11241093
promptUserForYesNoOrCancelAnswer

electron/app/locales/en/electron.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@
187187
"button-useExistingLocation": "Use Existing Location",
188188
"button-update-now": "Update and Restart Now",
189189
"button-update-on-exit": "Update when Application Exits",
190-
"button-domain-only": "Remove Domain Only",
191-
"button-domain-namespace": "Remove Entire Namespace",
192190

193191
"tools-docker-hub": "Docker Hub",
194192

electron/app/locales/en/webui.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,10 +1045,9 @@
10451045
"k8s-domain-script-generator-invalid-target-domain-location": "Unknown value for target domain location {{targetDomainLocation}}",
10461046

10471047
"k8s-domain-undeployer-aborted-error-title": "Undeploying WebLogic Domain from Kubernetes Aborted",
1048-
"k8s-domain-undeployer-scope-prompt-title": "Undeploy WebLogic Domain from Kubernetes Scope",
1049-
"k8s-domain-undeployer-scope-prompt-question": "Would you like to undeploy the just WebLogic domain {{domainUid}} or the entire WebLogic domain's namespace {{domainNamespace}} (and all of its data) from Kubernetes?",
1050-
"k8s-domain-undeployer-scope-prompt-details": "Removing the WebLogic domain will remove the WebLogic Kubernetes Operator's domain custom resource {{domainUid}} and will cause any running pods associated with the domain to be shut down and removed. Removing the WebLogic domain's namespace {{domainNamespace}} will, in addition to removing the WebLogic domain {{domainUid}}, remove all secrets, config maps, ingress routes, and other Kubernetes objects that exist in the Kubernetes namespace.",
1051-
"k8s-domain-undeployer-prompt-result-assertion-error-message": "Unexpected prompt action 'cancel' while undeploying the Kubernetes WebLogic domain. Please report an issue on GitHub.",
1048+
"k8s-domain-undeployer-remove-namespace-prompt-title": "Undeploy WebLogic Domain from Kubernetes Scope",
1049+
"k8s-domain-undeployer-remove-namespace-prompt-question": "After undeploying the WebLogic domain {{name}}, would you like to also delete the Kubernetes namespace {{namespace}} (and all of its data)?",
1050+
"k8s-domain-undeployer-remove-namespace-prompt-details": "UUndeploying the WebLogic domain will remove the WebLogic Kubernetes Operator's domain custom resource {{domainUid}} and will cause any running pods associated with the domain to be shut down and removed. Removing the WebLogic domain's namespace {{domainNamespace}} will remove all secrets, config maps, ingress routes, and other Kubernetes objects that exist in the Kubernetes namespace.",
10521051
"k8s-domain-undeployer-kubectl-exe-invalid-error-message": "Unable to undeploy the domain because the Kubernetes client executable is invalid: {{error}}.",
10531052
"k8s-domain-undeployer-project-not-saved-error-prefix": "Unable to undeploy the domain because project save failed",
10541053
"k8s-domain-undeployer-set-context-error-message": "Unable to undeploy the domain because setting the Kubernetes client content failed: {{error}}.",

electron/app/main.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const i18n = require('./js/i18next.config');
1414
const { initializeLoggingSystem, logRendererMessage } = require('./js/wktLogging');
1515
const userSettings = require('./js/userSettings');
1616
const { chooseFromFileSystem, createNetworkWindow, createWindow, initialize, setHasOpenDialog, setTargetType,
17-
showErrorMessage, promptUserForOkOrCancelAnswer, promptUserForYesOrNoAnswer, promptUserForK8sDomainRemovalScope,
18-
promptUserForYesNoOrCancelAnswer } = require('./js/wktWindow');
17+
showErrorMessage, promptUserForOkOrCancelAnswer, promptUserForYesOrNoAnswer, promptUserForYesNoOrCancelAnswer } =
18+
require('./js/wktWindow');
1919
const project = require('./js/project');
2020
const wktTools = require('./js/wktTools');
2121
const wdtArchive = require('./js/wdtArchive');
@@ -754,10 +754,6 @@ class Main {
754754
return kubectlUtils.deleteObjectIfExists(kubectlExe, namespace, object, kind, kubectlOptions);
755755
});
756756

757-
ipcMain.handle('domain-undeploy-scope-prompt', async (event, title, question, details) => {
758-
return promptUserForK8sDomainRemovalScope(event.sender.getOwnerBrowserWindow(), title, question, details);
759-
});
760-
761757
ipcMain.handle('helm-add-wko-chart', async (event, helmExe, helmOptions) => {
762758
return helmUtils.addOrUpdateWkoHelmChart(helmExe, helmOptions);
763759
});

webui/src/js/utils/k8s-domain-undeployer.js

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,27 @@ function (K8sDomainActionsBase, project, wktConsole, i18n, projectIo, dialogHelp
2727
let errTitle = i18n.t('k8s-domain-undeployer-aborted-error-title');
2828
const errPrefix = 'k8s-domain-undeployer';
2929

30-
// Prompt user to remove just the domain or the entire domain namespace.
31-
const domainUid = this.project.k8sDomain.uid.value;
32-
const domainNamespace = this.project.k8sDomain.kubernetesNamespace.value;
33-
34-
// Only prompt if the UID and namespace are provided.
35-
// Otherwise, let it fall through for validation to detect
36-
// and alert the user to all missing required fields.
37-
//
38-
let promptResult = 'cancel';
39-
if (domainUid && domainNamespace) {
40-
const promptTitle = i18n.t('k8s-domain-undeployer-scope-prompt-title');
41-
const promptQuestion = i18n.t('k8s-domain-undeployer-scope-prompt-question',
42-
{ domainUid: domainUid, domainNamespace: domainNamespace });
43-
const promptDetails = i18n.t('k8s-domain-undeployer-scope-prompt-details',
44-
{ domainUid: domainUid, domainNamespace: domainNamespace });
45-
46-
promptResult = await window.api.ipc.invoke('domain-undeploy-scope-prompt',
47-
promptTitle, promptQuestion, promptDetails);
48-
49-
// If the user chose to cancel, then simply return.
50-
if (promptResult === 'cancel') {
51-
return Promise.resolve('false');
52-
}
53-
}
54-
5530
const validatableObject = this.getValidatableObject('flow-undeploy-domain-name');
5631
if (validatableObject.hasValidationErrors()) {
5732
const validationErrorDialogConfig = validatableObject.getValidationErrorDialogConfig(errTitle);
5833
dialogHelper.openDialog('validation-error-dialog', validationErrorDialogConfig);
5934
return Promise.resolve(false);
6035
}
6136

62-
// This is a sanity check. It should never be true!
63-
if (promptResult === 'cancel') {
64-
const errMessage = i18n.t('k8s-domain-undeployer-prompt-result-assertion-error-message');
65-
await window.api.ipc.invoke('show-error-message', errTitle, errMessage);
37+
// Prompt user to remove just the domain or the entire domain namespace.
38+
const domainUid = this.project.k8sDomain.uid.value;
39+
const domainNamespace = this.project.k8sDomain.kubernetesNamespace.value;
40+
41+
const promptTitle = i18n.t('k8s-domain-undeployer-remove-namespace-prompt-title');
42+
const promptQuestion = i18n.t('k8s-domain-undeployer-remove-namespace-prompt-question',
43+
{ name: domainUid, namespace: domainNamespace });
44+
const promptDetails = i18n.t('k8s-domain-undeployer-remove-namespace-prompt-details',
45+
{ name: domainUid, namespace: domainNamespace });
46+
const removeNamespacePromptResult = await this.removeNamespacePrompt(promptTitle, promptQuestion, promptDetails);
47+
if (removeNamespacePromptResult === 'cancel') {
6648
return Promise.resolve(false);
6749
}
50+
const removeNamespace = removeNamespacePromptResult === 'yes';
6851

6952
const totalSteps = 4.0;
7053
try {
@@ -101,28 +84,28 @@ function (K8sDomainActionsBase, project, wktConsole, i18n, projectIo, dialogHelp
10184
}
10285

10386
let deleteResult;
104-
if (promptResult === 'domain') {
105-
busyDialogMessage = i18n.t('flow-undeploy-domain-in-progress', { domainUid: domainUid });
87+
if (removeNamespace) {
88+
busyDialogMessage = i18n.t('flow-undeploy-namespace-in-progress', { domainNamespace: domainNamespace });
10689
dialogHelper.updateBusyDialog(busyDialogMessage, 2 / totalSteps);
10790
deleteResult = await this.deleteKubernetesObjectIfExists(kubectlExe, kubectlOptions,
108-
domainNamespace, 'domain', domainUid, errTitle, errPrefix);
91+
null, 'namespace', domainNamespace, errTitle, errPrefix);
10992
} else {
110-
busyDialogMessage = i18n.t('flow-undeploy-namespace-in-progress', { domainNamespace: domainNamespace });
93+
busyDialogMessage = i18n.t('flow-undeploy-domain-in-progress', { domainUid: domainUid });
11194
dialogHelper.updateBusyDialog(busyDialogMessage, 2 / totalSteps);
11295
deleteResult = await this.deleteKubernetesObjectIfExists(kubectlExe, kubectlOptions,
113-
null, 'namespace', domainNamespace, errTitle, errPrefix);
96+
domainNamespace, 'domain', domainUid, errTitle, errPrefix);
11497
}
11598

11699
wktLogger.debug('deleteResult = %s', deleteResult);
117100
if (deleteResult) {
118101
dialogHelper.closeBusyDialog();
119102
const title = i18n.t('k8s-domain-undeployer-undeploy-complete-title');
120103
let message;
121-
if (promptResult === 'domain') {
122-
message = i18n.t('k8s-domain-undeployer-undeploy-domain-complete-message',
104+
if (removeNamespace) {
105+
message = i18n.t('k8s-domain-undeployer-undeploy-namespace-complete-message',
123106
{domainName: domainUid, domainNamespace: domainNamespace});
124107
} else {
125-
message = i18n.t('k8s-domain-undeployer-undeploy-namespace-complete-message',
108+
message = i18n.t('k8s-domain-undeployer-undeploy-domain-complete-message',
126109
{domainName: domainUid, domainNamespace: domainNamespace});
127110
}
128111
await window.api.ipc.invoke('show-info-message', title, message);

0 commit comments

Comments
 (0)