Skip to content

Commit df56eaa

Browse files
committed
add warning message if discover will overwrite existing model data
1 parent 44888c4 commit df56eaa

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

electron/app/locales/en/webui.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,8 @@
772772
"discover-dialog-admin-password-label": "Administration Server Password",
773773
"discover-dialog-admin-password-help": "The login password for the Administration Server.",
774774

775+
"wdt-discoverer-replace-title": "Replace Existing Model Content",
776+
"wdt-discoverer-replace-message": "This will replace the project's existing model content, continue?",
775777
"wdt-discoverer-online-aborted-error-title": "Discover Domain Online Aborted",
776778
"wdt-discoverer-offline-aborted-error-title": "Discover Domain Offline Aborted",
777779
"wdt-discoverer-invalid-java-home-error-prefix": "Unable to discover domain due to the Java Home being invalid",

webui/src/js/utils/wdt-discoverer.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,17 @@ function (WdtActionsBase, ko, project, wktConsole, dialogHelper, projectIO, i18n
2020
// save the current project (electron will select a new file if needed).
2121
// open the discover configuration dialog.
2222
async startDiscoverDomain(online) {
23-
const discoverConfig = {'online': online};
24-
dialogHelper.openDialog('discover-dialog', discoverConfig);
23+
let proceed = true;
24+
if (this.hasModelContext()) {
25+
const title = i18n.t('wdt-discoverer-replace-title');
26+
const message = i18n.t('wdt-discoverer-replace-message');
27+
proceed = await window.api.ipc.invoke('ok-or-cancel-prompt', title, message);
28+
}
29+
30+
if (proceed) {
31+
const discoverConfig = {'online': online};
32+
dialogHelper.openDialog('discover-dialog', discoverConfig);
33+
}
2534
}
2635

2736
// the dialog will call this when the OK button is clicked.
@@ -143,6 +152,11 @@ function (WdtActionsBase, ko, project, wktConsole, dialogHelper, projectIO, i18n
143152
}
144153
return validationObject;
145154
}
155+
156+
hasModelContext() {
157+
return !!project.wdtModel.modelContent() ||
158+
project.wdtModel.internal.propertiesContent.value.length || project.wdtModel.archiveRoots().length;
159+
}
146160
}
147161

148162
return new WdtDiscoverer();

0 commit comments

Comments
 (0)