From 5538f932cfb1aaf0f6830b017f8c42e49d9e2ee2 Mon Sep 17 00:00:00 2001 From: Oleksii Orel Date: Sat, 17 Jun 2017 18:37:20 +0300 Subject: [PATCH] moved showIDE logic into the routeChange listener Signed-off-by: Oleksii Orel --- .../administration/administration-config.ts | 11 ++----- .../administration.controller.ts | 30 ------------------ .../src/app/dashboard/dashboard-config.ts | 14 +++------ .../dashboard/dashboard.controller.spec.ts | 30 ------------------ .../src/app/dashboard/dashboard.controller.ts | 31 ------------------- .../list-factories.controller.ts | 4 +-- dashboard/src/app/ide/ide.controller.ts | 1 - dashboard/src/app/index.module.ts | 15 +++++---- .../create-project.controller.ts | 2 -- .../list-workspaces.controller.ts | 4 +-- .../widget/input/che-input-box.html | 2 +- 11 files changed, 20 insertions(+), 124 deletions(-) delete mode 100644 dashboard/src/app/administration/administration.controller.ts delete mode 100644 dashboard/src/app/dashboard/dashboard.controller.spec.ts delete mode 100644 dashboard/src/app/dashboard/dashboard.controller.ts diff --git a/dashboard/src/app/administration/administration-config.ts b/dashboard/src/app/administration/administration-config.ts index a4fbcfeff40..0e5c20e2c5d 100644 --- a/dashboard/src/app/administration/administration-config.ts +++ b/dashboard/src/app/administration/administration-config.ts @@ -11,7 +11,6 @@ 'use strict'; -import {AdministrationController} from './administration.controller'; import {DockerRegistryList} from './docker-registry/docker-registry-list/docker-registry-list.directive'; import {DockerRegistryListController} from './docker-registry/docker-registry-list/docker-registry-list.controller'; import {EditRegistryController} from './docker-registry/docker-registry-list/edit-registry/edit-registry.controller'; @@ -19,21 +18,17 @@ import {EditRegistryController} from './docker-registry/docker-registry-list/edi export class AdministrationConfig { - constructor(register) { - register.controller('AdministrationController', AdministrationController); - + constructor(register: che.IRegisterService) { register.directive('dockerRegistryList', DockerRegistryList); register.controller('DockerRegistryListController', DockerRegistryListController); register.controller('EditRegistryController', EditRegistryController); // config routes - register.app.config(($routeProvider) => { + register.app.config(($routeProvider: ng.route.IRouteProvider) => { $routeProvider.accessWhen('/administration', { title: 'Administration', - templateUrl: 'app/administration/administration.html', - controller: 'AdministrationController', - controllerAs: 'administrationController' + templateUrl: 'app/administration/administration.html' }); }); diff --git a/dashboard/src/app/administration/administration.controller.ts b/dashboard/src/app/administration/administration.controller.ts deleted file mode 100644 index 0c0b39b2746..00000000000 --- a/dashboard/src/app/administration/administration.controller.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2015-2017 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - */ -'use strict'; - -/** - * @ngdoc controller - * @name administration.controller:AdministrationController - * @description This class is handling the controller of the administration - * @author Oleksii Orel - */ -export class AdministrationController { - - - /** - * Default constructor - * @ngInject for Dependency injection - */ - constructor($rootScope) { - 'ngInject'; - $rootScope.showIDE = false; - } -} diff --git a/dashboard/src/app/dashboard/dashboard-config.ts b/dashboard/src/app/dashboard/dashboard-config.ts index 208ecd5eab2..c970afbae81 100644 --- a/dashboard/src/app/dashboard/dashboard-config.ts +++ b/dashboard/src/app/dashboard/dashboard-config.ts @@ -10,34 +10,30 @@ */ 'use strict'; -import {DashboardController} from './dashboard.controller'; import {DashboardLastWorkspacesController} from './last-workspaces/last-workspaces.controller'; import {DashboardLastWorkspaces} from './last-workspaces/last-workspaces.directive'; import {DashboardPanel} from './dashboard-panel/dashboard-panel.directive'; +import {CheService} from '../../components/api/che-service.factory'; +import {CheWorkspace} from '../../components/api/che-workspace.factory'; export class DashboardConfig { - constructor(register) { + constructor(register: che.IRegisterService) { // last workspaces register.controller('DashboardLastWorkspacesController', DashboardLastWorkspacesController); register.directive('dashboardLastWorkspaces', DashboardLastWorkspaces); - // controller - register.controller('DashboardController', DashboardController); - // panel of last used entries register.directive('dashboardPanel', DashboardPanel); // config routes - register.app.config(($routeProvider) => { + register.app.config(($routeProvider: ng.route.IRouteProvider) => { $routeProvider.accessWhen('/', { title: 'Dashboard', templateUrl: 'app/dashboard/dashboard.html', - controller: 'DashboardController', - controllerAs: 'dashboardController', resolve: { - check: ['$q', '$location', 'cheWorkspace', 'cheService', ($q, $location, cheWorkspace, cheService) => { + check: ['$q', '$location', 'cheWorkspace', 'cheService', ($q: ng.IQService, $location: ng.ILocationService, cheWorkspace: CheWorkspace, cheService: CheService) => { cheWorkspace.fetchWorkspaces().then(() => { if (cheWorkspace.getWorkspaces().length === 0) { $location.path('/create-project'); diff --git a/dashboard/src/app/dashboard/dashboard.controller.spec.ts b/dashboard/src/app/dashboard/dashboard.controller.spec.ts deleted file mode 100644 index f8ecb57ad02..00000000000 --- a/dashboard/src/app/dashboard/dashboard.controller.spec.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2015-2017 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - */ -'use strict'; - -describe('controllers', function(){ - var scope; - - beforeEach(angular.mock.module('userDashboard')); - - beforeEach(inject(function($rootScope) { - scope = $rootScope.$new(); - })); - - it('empty', inject(function($controller) { - expect(scope.awesomeThings).toBeUndefined(); - - $controller('DashboardController', { - $scope: scope - }); - - })); -}); diff --git a/dashboard/src/app/dashboard/dashboard.controller.ts b/dashboard/src/app/dashboard/dashboard.controller.ts deleted file mode 100644 index e0ff9980231..00000000000 --- a/dashboard/src/app/dashboard/dashboard.controller.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2015-2017 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - */ -'use strict'; - -/** - * @ngdoc controller - * @name dashboard.controller:DashboardController - * @description This class is handling the controller of the dashboard - * @author Florent Benoit - */ -export class DashboardController { - - - /** - * Default constructor - * @ngInject for Dependency injection - */ - constructor($rootScope) { - 'ngInject'; - $rootScope.showIDE = false; - - } -} diff --git a/dashboard/src/app/factories/list-factories/list-factories.controller.ts b/dashboard/src/app/factories/list-factories/list-factories.controller.ts index ce02a1677b3..473069b6d12 100644 --- a/dashboard/src/app/factories/list-factories/list-factories.controller.ts +++ b/dashboard/src/app/factories/list-factories/list-factories.controller.ts @@ -40,7 +40,7 @@ export class ListFactoriesController { * Default constructor that is using resource injection * @ngInject for Dependency injection */ - constructor($q: ng.IQService, $log: ng.ILogService, cheAPI: CheAPI, cheNotification: CheNotification, $rootScope: che.IRootScopeService, + constructor($q: ng.IQService, $log: ng.ILogService, cheAPI: CheAPI, cheNotification: CheNotification, confirmDialogService: ConfirmDialogService, $scope: ng.IScope, cheListHelperFactory: che.widget.ICheListHelperFactory) { this.$q = $q; this.$log = $log; @@ -72,8 +72,6 @@ export class ListFactoriesController { }); this.pagesInfo = cheAPI.getFactory().getPagesInfo(); - - $rootScope.showIDE = false; } /** diff --git a/dashboard/src/app/ide/ide.controller.ts b/dashboard/src/app/ide/ide.controller.ts index 0ee2aae762e..f9c4b0d4217 100644 --- a/dashboard/src/app/ide/ide.controller.ts +++ b/dashboard/src/app/ide/ide.controller.ts @@ -46,7 +46,6 @@ class IdeCtrl { this.cheWorkspace = cheWorkspace; this.$timeout = $timeout; - this.$rootScope.showIDE = false; this.$rootScope.wantTokeepLoader = true; this.selectedWorkspaceExists = true; diff --git a/dashboard/src/app/index.module.ts b/dashboard/src/app/index.module.ts index be870a482d8..2a273798a72 100644 --- a/dashboard/src/app/index.module.ts +++ b/dashboard/src/app/index.module.ts @@ -143,14 +143,17 @@ initModule.run(['$rootScope', '$location', '$routeParams', 'routingRedirect', '$ } }); - - $rootScope.$on('$routeChangeSuccess', (event, next) => { - if (next.$$route.title && angular.isFunction(next.$$route.title)) { - $rootScope.currentPage = next.$$route.title($routeParams); + $rootScope.$on('$routeChangeSuccess', (event: ng.IAngularEvent, next: ng.route.IRoute) => { + const route = (next).$$route; + if (angular.isFunction(route.title)) { + $rootScope.currentPage = route.title($routeParams); } else { - $rootScope.currentPage = next.$$route.title || 'Dashboard'; + $rootScope.currentPage = route.title || 'Dashboard'; + } + const originalPath: string = route.originalPath; + if (originalPath && originalPath.indexOf('/ide/') === -1) { + $rootScope.showIDE = false; } - // when a route is about to change, notify the routing redirect node if (next.resolve) { if (DEV) { diff --git a/dashboard/src/app/projects/create-project/create-project.controller.ts b/dashboard/src/app/projects/create-project/create-project.controller.ts index 579789ddff2..903b8784eff 100755 --- a/dashboard/src/app/projects/create-project/create-project.controller.ts +++ b/dashboard/src/app/projects/create-project/create-project.controller.ts @@ -221,8 +221,6 @@ export class CreateProjectController { cheAPI.getWorkspace().getWorkspaces(); - $rootScope.showIDE = false; - this.isHandleClose = true; this.connectionClosed = () => { if (!this.isHandleClose) { diff --git a/dashboard/src/app/workspaces/list-workspaces/list-workspaces.controller.ts b/dashboard/src/app/workspaces/list-workspaces/list-workspaces.controller.ts index 6b1a217d17e..01eb600f533 100644 --- a/dashboard/src/app/workspaces/list-workspaces/list-workspaces.controller.ts +++ b/dashboard/src/app/workspaces/list-workspaces/list-workspaces.controller.ts @@ -56,7 +56,7 @@ export class ListWorkspacesCtrl { * @ngInject for Dependency injection */ constructor($log: ng.ILogService, $mdDialog: ng.material.IDialogService, $q: ng.IQService, lodash: any, - $rootScope: che.IRootScopeService, cheAPI: CheAPI, cheNotification: CheNotification, cheBranding: CheBranding, + cheAPI: CheAPI, cheNotification: CheNotification, cheBranding: CheBranding, cheWorkspace: CheWorkspace, cheNamespaceRegistry: CheNamespaceRegistry, confirmDialogService: ConfirmDialogService, $scope: ng.IScope, cheListHelperFactory: che.widget.ICheListHelperFactor) { this.cheAPI = cheAPI; @@ -90,8 +90,6 @@ export class ListWorkspacesCtrl { this.getUserWorkspaces(); - $rootScope.showIDE = false; - this.cheNamespaceRegistry.fetchNamespaces().then(() => { this.namespaceLabels = this.getNamespaceLabelsList(); }); diff --git a/dashboard/src/components/widget/input/che-input-box.html b/dashboard/src/components/widget/input/che-input-box.html index ba20fe937a0..02140aa3c78 100644 --- a/dashboard/src/components/widget/input/che-input-box.html +++ b/dashboard/src/components/widget/input/che-input-box.html @@ -9,7 +9,7 @@