Commit 69be03ed authored by benjaminParisel's avatar benjaminParisel Committed by abirembaut

feat(help): stop display help popup (#2540)

parent d6dfa90a
......@@ -19,7 +19,7 @@
.module('bonitasoft.designer.custom-widget')
.controller('CustomWidgetEditorCtrl', CustomWidgetEditorCtrl);
function CustomWidgetEditorCtrl($scope, artifact, artifactRepo, alerts, $uibModal, $window, $localStorage, keyBindingService, gettextCatalog, $stateParams, $state, BONDS, browserHistoryService) {
function CustomWidgetEditorCtrl($scope, artifact, artifactRepo, alerts, $uibModal, $window, keyBindingService, gettextCatalog, $stateParams, $state, BONDS, browserHistoryService) {
$scope.widget = artifact;
$scope.bonds = BONDS;
......@@ -151,7 +151,7 @@
return section;
}
},
controller: function($scope, $uibModalInstance, $localStorage, helpSection) {
controller: function($scope, $uibModalInstance, helpSection) {
if (helpSection) {
$scope.tabContainer = {
activeTab: helpSection
......@@ -159,22 +159,12 @@
}
$scope.cancel = function() {
if (!$localStorage.bonitaUIDesigner) {
$localStorage.bonitaUIDesigner = {};
}
$localStorage.bonitaUIDesigner.doNotShowMigrationNotesAgain = true;
$uibModalInstance.dismiss('cancel');
};
}
});
};
//Handle migration notes
let storage = $localStorage.bonitaUIDesigner;
if (!storage || !storage.doNotShowMigrationNotesAgain) {
$scope.openHelp('migration');
}
$scope.$on('$destroy', function() {
keyBindingService.unbind(['ctrl+s', 'command+s']);
});
......
......@@ -15,7 +15,7 @@
(function() {
'use strict';
angular.module('bonitasoft.designer.editor.header.help').directive('openHelp', ['$uibModal', '$localStorage', function($uibModal, $localStorage) {
angular.module('bonitasoft.designer.editor.header.help').directive('openHelp', ['$uibModal', function($uibModal) {
return {
restrict: 'A',
scope: {
......@@ -35,7 +35,7 @@
return $scope.helpSection;
}
},
controller: function($scope, $uibModalInstance, $localStorage, pageEdition, helpSection) {
controller: function($scope, $uibModalInstance, pageEdition, helpSection) {
'ngInject';
$scope.pageEdition = pageEdition;
if (helpSection) {
......@@ -43,25 +43,13 @@
activeTab: helpSection
};
}
$scope.cancel = function() {
if (!$localStorage.bonitaUIDesigner) {
$localStorage.bonitaUIDesigner = {};
}
$localStorage.bonitaUIDesigner.doNotShowMigrationNotesAgain = true;
$uibModalInstance.dismiss('cancel');
};
}
});
}
elem.on('click', onClick);
//Handle migration notes
let storage = $localStorage.bonitaUIDesigner;
if (!storage || !storage.doNotShowMigrationNotesAgain) {
$scope.helpSection = 'migration';
onClick();
}
}
};
}]);
......
describe('CustomWidgetEditorCtrl', function() {
var $scope, alerts, $q, widgetRepo, $uibModal, modalInstance, $state, $localStorage, browserHistoryService;
var $scope, alerts, $q, widgetRepo, $uibModal, modalInstance, $state, browserHistoryService;
var awesomeWidget = {
template: '<div>hello</div>',
properties: [],
......@@ -10,7 +10,7 @@ describe('CustomWidgetEditorCtrl', function() {
beforeEach(angular.mock.module('bonitasoft.designer.custom-widget', 'mock.modal'));
beforeEach(inject(function($rootScope, $controller, $timeout, _$q_, _widgetRepo_, _alerts_, _$uibModal_, $uibModalInstance, _$localStorage_, _$state_, _browserHistoryService_) {
beforeEach(inject(function($rootScope, $controller, $timeout, _$q_, _widgetRepo_, _alerts_, _$uibModal_, $uibModalInstance, _$state_, _browserHistoryService_) {
$scope = $rootScope.$new();
$state = _$state_;
browserHistoryService = _browserHistoryService_;
......@@ -18,20 +18,17 @@ describe('CustomWidgetEditorCtrl', function() {
widgetRepo = _widgetRepo_;
alerts = _alerts_;
$uibModal = _$uibModal_;
$localStorage = _$localStorage_;
modalInstance = $uibModalInstance.create();
spyOn($state, 'go');
spyOn(browserHistoryService, 'back');
$localStorage.bonitaUIDesigner = { doNotShowMigrationNotesAgain: true };
$controller('CustomWidgetEditorCtrl', {
$scope,
$uibModal,
artifact: awesomeWidget,
artifactRepo: widgetRepo,
$localStorage : $localStorage,
$timeout
});
......
describe('open help directive', function() {
var $compile, element, scope, directiveScope, $uibModal, modalInstance, $localStorage;
var $compile, element, scope, directiveScope, $uibModal, modalInstance;
beforeEach(angular.mock.module('bonitasoft.designer.editor.header', 'mock.modal'));
beforeEach(inject(function(_$compile_, $rootScope, _$uibModal_, $uibModalInstance, _$localStorage_) {
beforeEach(inject(function(_$compile_, $rootScope, _$uibModal_, $uibModalInstance) {
$compile = _$compile_;
scope = $rootScope.$new();
$uibModal = _$uibModal_;
modalInstance = $uibModalInstance.fake();
$localStorage = _$localStorage_;
spyOn($uibModal, 'open');
}));
it('should open help popup on click', function() {
$localStorage.bonitaUIDesigner = { doNotShowMigrationNotesAgain: true };
element = $compile('<button open-help="filters" editor-mode="page"></button>')(scope);
scope.$digest();
directiveScope = element.isolateScope();
......@@ -32,18 +29,4 @@ describe('open help directive', function() {
expect(directiveScope.editorMode).toBe('page');
});
it('should open help popup automatically', function() {
$localStorage.bonitaUIDesigner = {};
element = $compile('<button open-help="filters" editor-mode="page"></button>')(scope);
scope.$digest();
directiveScope = element.isolateScope();
expect($uibModal.open).toHaveBeenCalled();
expect($uibModal.open.calls.mostRecent().args[0].templateUrl).toEqual('js/editor/header/help/help-popup.html');
expect($uibModal.open.calls.mostRecent().args[0].size).toEqual('lg');
expect(directiveScope.helpSection).toBe('filters');
expect(directiveScope.editorMode).toBe('page');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment