Repository: ignite Updated Branches: refs/heads/master 58150f8fe -> dd290c972
IGNITE-9368 Web Console: Fixed double confirmation for unsaved changes on state change. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dd290c97 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dd290c97 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dd290c97 Branch: refs/heads/master Commit: dd290c9724a83a55af5b92ce0850233586f51721 Parents: 58150f8 Author: Vasiliy Sisko <vsi...@gridgain.com> Authored: Thu Sep 20 10:20:29 2018 +0700 Committer: Alexey Kuznetsov <akuznet...@apache.org> Committed: Thu Sep 20 10:20:29 2018 +0700 ---------------------------------------------------------------------- modules/web-console/frontend/app/app.js | 2 -- .../page-configure-basic/controller.js | 4 ++- .../components/formUICanExitGuard.js | 4 ++- .../components/modal-import-models/component.js | 15 +++++--- .../frontend/app/services/FormUtils.service.js | 8 ----- .../app/services/UnsavedChangesGuard.service.js | 38 -------------------- 6 files changed, 17 insertions(+), 54 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/dd290c97/modules/web-console/frontend/app/app.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js index 20bcbff..3fb6ae0 100644 --- a/modules/web-console/frontend/app/app.js +++ b/modules/web-console/frontend/app/app.js @@ -89,7 +89,6 @@ import LegacyUtils from './services/LegacyUtils.service'; import Messages from './services/Messages.service'; import ErrorParser from './services/ErrorParser.service'; import ModelNormalizer from './services/ModelNormalizer.service.js'; -import UnsavedChangesGuard from './services/UnsavedChangesGuard.service'; import Caches from './services/Caches'; import {CSV} from './services/CSV'; import {$exceptionHandler} from './services/exceptionHandler.js'; @@ -302,7 +301,6 @@ export default angular.module('ignite-console', [ .service(...LegacyTable) .service(...FormUtils) .service(...LegacyUtils) -.service(...UnsavedChangesGuard) .service('IgniteActivitiesUserDialog', IgniteActivitiesUserDialog) .service('Caches', Caches) .service('CSV', CSV) http://git-wip-us.apache.org/repos/asf/ignite/blob/dd290c97/modules/web-console/frontend/app/components/page-configure-basic/controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/components/page-configure-basic/controller.js b/modules/web-console/frontend/app/components/page-configure-basic/controller.js index 6d116e8..88c6163 100644 --- a/modules/web-console/frontend/app/components/page-configure-basic/controller.js +++ b/modules/web-console/frontend/app/components/page-configure-basic/controller.js @@ -81,7 +81,9 @@ export default class PageConfigureBasicController { } _uiCanExit($transition$) { - if ($transition$.options().custom.justIDUpdate) + const options = $transition$.options(); + + if (options.custom.justIDUpdate || options.redirectedFrom) return true; $transition$.onSuccess({}, () => this.reset()); http://git-wip-us.apache.org/repos/asf/ignite/blob/dd290c97/modules/web-console/frontend/app/components/page-configure/components/formUICanExitGuard.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/components/page-configure/components/formUICanExitGuard.js b/modules/web-console/frontend/app/components/page-configure/components/formUICanExitGuard.js index ce1f73d..7875546 100644 --- a/modules/web-console/frontend/app/components/page-configure/components/formUICanExitGuard.js +++ b/modules/web-console/frontend/app/components/page-configure/components/formUICanExitGuard.js @@ -43,7 +43,9 @@ class FormUICanExitGuardController { return; controller.uiCanExit = ($transition$) => { - if ($transition$.options().custom.justIDUpdate) + const options = $transition$.options(); + + if (options.custom.justIDUpdate || options.redirectedFrom) return true; $transition$.onSuccess({}, controller.reset); http://git-wip-us.apache.org/repos/asf/ignite/blob/dd290c97/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js b/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js index 3c302ff..e4b8253 100644 --- a/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js +++ b/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js @@ -155,16 +155,20 @@ export class ModalImportModels { }) .take(1); } + saveBatch(batch) { if (!batch.length) return; + this.$scope.importDomain.loadingOptions = SAVING_DOMAINS; this.Loading.start('importDomainFromDb'); + this.ConfigureState.dispatchAction({ type: 'ADVANCED_SAVE_COMPLETE_CONFIGURATION', changedItems: this.batchActionsToRequestBody(batch), prevActions: [] }); + this.saveSubscription = Observable.race( this.ConfigureState.actions$.filter((a) => a.type === 'ADVANCED_SAVE_COMPLETE_CONFIGURATION_OK') .do(() => this.onHide()), @@ -176,6 +180,7 @@ export class ModalImportModels { }) .subscribe(); } + batchActionsToRequestBody(batch) { const result = batch.reduce((req, action) => { return { @@ -200,21 +205,25 @@ export class ModalImportModels { result.cluster.caches = [...new Set(result.cluster.caches)]; return result; } + onTableSelectionChange(selected) { this.$scope.$applyAsync(() => { this.$scope.importDomain.tablesToUse = selected; this.selectedTablesIDs = selected.map((t) => t.id); }); } + onSchemaSelectionChange(selected) { this.$scope.$applyAsync(() => { this.$scope.importDomain.schemasToUse = selected; this.selectedSchemasIDs = selected.map((i) => i.name); }); } + onVisibleRowsChange(rows) { return this.visibleTables = rows.map((r) => r.entity); } + onCacheSelect(cacheID) { if (cacheID < 0) return; @@ -237,11 +246,13 @@ export class ModalImportModels { ) .subscribe(); } + $onDestroy() { this.subscription.unsubscribe(); if (this.onCacheSelectSubcription) this.onCacheSelectSubcription.unsubscribe(); if (this.saveSubscription) this.saveSubscription.unsubscribe(); } + $onInit() { // Restores old behavior const {$http, Confirm, ConfirmBatch, Focus, SqlTypes, JavaTypes, Messages, $scope, $root, agentMgr, ActivitiesData, Loading, FormUtils, LegacyUtils} = this; @@ -1026,13 +1037,9 @@ export class ModalImportModels { $scope.ui.selectedJdbcDriverJar = $scope.jdbcDriverJars[0].value; - // FormUtils.confirmUnsavedChanges(dirty, () => { $scope.importDomain.action = 'connect'; $scope.importDomain.tables = []; this.selectedTables = []; - - // Focus.move('jdbcUrl'); - // }); } else { $scope.importDomain.jdbcDriversNotFound = true; http://git-wip-us.apache.org/repos/asf/ignite/blob/dd290c97/modules/web-console/frontend/app/services/FormUtils.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/services/FormUtils.service.js b/modules/web-console/frontend/app/services/FormUtils.service.js index 00b399b..cda68f7 100644 --- a/modules/web-console/frontend/app/services/FormUtils.service.js +++ b/modules/web-console/frontend/app/services/FormUtils.service.js @@ -427,14 +427,6 @@ export default ['IgniteFormUtils', ['$window', 'IgniteFocus', '$rootScope', func ensureActivePanel(panels, id, focusId) { ensureActivePanel(panels, id, focusId); }, - confirmUnsavedChanges(dirty, selectFunc) { - if (dirty) { - if ($window.confirm('You have unsaved changes.\n\nAre you sure you want to discard them?')) - selectFunc(); - } - else - selectFunc(); - }, saveBtnTipText(dirty, objectName) { if (dirty) return 'Save ' + objectName; http://git-wip-us.apache.org/repos/asf/ignite/blob/dd290c97/modules/web-console/frontend/app/services/UnsavedChangesGuard.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/services/UnsavedChangesGuard.service.js b/modules/web-console/frontend/app/services/UnsavedChangesGuard.service.js deleted file mode 100644 index 1f7dea6..0000000 --- a/modules/web-console/frontend/app/services/UnsavedChangesGuard.service.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const MSG = 'You have unsaved changes.\n\nAre you sure you want to discard them?'; - -// Service that show confirmation about unsaved changes on user change location. -export default ['IgniteUnsavedChangesGuard', ['$rootScope', function($root) { - return { - install(scope, customDirtyCheck = () => scope.ui.inputForm.$dirty) { - scope.$on('$destroy', () => window.onbeforeunload = null); - - const unbind = $root.$on('$stateChangeStart', (event) => { - if (_.get(scope, 'ui.inputForm', false) && customDirtyCheck()) { - if (!confirm(MSG)) // eslint-disable-line no-alert - event.preventDefault(); - else - unbind(); - } - }); - - window.onbeforeunload = () => _.get(scope, 'ui.inputForm.$dirty', false) ? MSG : null; - } - }; -}]];