Mercurial > hg > thermostat-ng > web-client
changeset 145:d84aa90787cc
Make error-msg directive dismissibility optional
Reviewed-by: aazores
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-July/024169.html
author | Chris Lessard <clessard@redhat.com> |
---|---|
date | Tue, 01 Aug 2017 15:40:08 -0400 |
parents | 4fffcaa3b8cc |
children | e3ef516af2f4 |
files | CONTRIBUTING.md src/app/components/jvm-info/jvm-info.html src/app/components/jvm-list/jvm-list.html src/app/components/multichart/multichart.html src/app/components/system-info/system-info.html src/app/shared/directives/customizableErrorMessageDirective/customizable-error-message.directive.js src/app/shared/directives/customizableErrorMessageDirective/customizable-error-message.directive.spec.js src/app/shared/directives/customizableErrorMessageDirective/customizable-error-message.html src/app/shared/directives/customizableErrorMessageDirective/customizable-error-message.module.js |
diffstat | 9 files changed, 183 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/CONTRIBUTING.md Tue Aug 01 14:42:31 2017 -0400 +++ b/CONTRIBUTING.md Tue Aug 01 15:40:08 2017 -0400 @@ -50,7 +50,7 @@ Directives * lowerCamelCase -* e.g., dismissibleErrorMessageDirective +* e.g., customizableErrorMessageDirective Factories * lowerCamelCase
--- a/src/app/components/jvm-info/jvm-info.html Tue Aug 01 14:42:31 2017 -0400 +++ b/src/app/components/jvm-info/jvm-info.html Tue Aug 01 15:40:08 2017 -0400 @@ -6,7 +6,7 @@ <li><a ui-sref="jvmInfo({ systemId: ctrl.systemId, jvmId: ctrl.jvmId })">{{ctrl.jvmInfo.mainClass | extractClass}}</a></li> </ol> - <dismissible-error-message ng-show="ctrl.showErr" err-title="'Unable to kill JVM.'" err-message="ctrl.errMessage"></dismissible-error-message> + <customizable-error-message ng-show="ctrl.showErr" dismissible="true" err-title="'Unable to kill JVM.'" err-message="ctrl.errMessage"></customizable-error-message> <div class="row"> <div class="col-xs-12 col-lg-8">
--- a/src/app/components/jvm-list/jvm-list.html Tue Aug 01 14:42:31 2017 -0400 +++ b/src/app/components/jvm-list/jvm-list.html Tue Aug 01 15:40:08 2017 -0400 @@ -4,7 +4,7 @@ <li><a ui-sref="jvmList">JVM List</a></li> </ol> - <dismissible-error-message ng-show="ctrl.showErr" err-message="errMessage" err-title="errTitle"></dismissible-error-message> + <customizable-error-message ng-show="ctrl.showErr" dismissible="true" err-message="errMessage" err-title="errTitle"></customizable-error-message> <div ng-show="!ctrl.showErr" > <div class="text-right">
--- a/src/app/components/multichart/multichart.html Tue Aug 01 14:42:31 2017 -0400 +++ b/src/app/components/multichart/multichart.html Tue Aug 01 15:40:08 2017 -0400 @@ -4,7 +4,7 @@ <li><a ui-serf="multichart">Multichart</a></li> </ol> - <dismissible-error-message ng-show="ctrl.showErr" err-title="'Invalid chart name.'" + <customizable-error-message ng-show="ctrl.showErr" dismissible="true" err-title="'Invalid chart name.'" err-message="'Chart names may contain alphanumeric characters, underscores, and hyphens.'"/> <div class="row">
--- a/src/app/components/system-info/system-info.html Tue Aug 01 14:42:31 2017 -0400 +++ b/src/app/components/system-info/system-info.html Tue Aug 01 15:40:08 2017 -0400 @@ -5,7 +5,7 @@ <li><a ui-sref="systemInfo({ systemId: ctrl.systemId })">{{ctrl.systemId}}</a></li> </ol> - <dismissible-error-message ng-show="ctrl.showErr" err-message="errMessage" err-title="errTitle"></dismissible-error-message> + <customizable-error-message ng-show="ctrl.showErr" dismissible="true" err-message="errMessage" err-title="errTitle"></customizable-error-message> <div ng-show="!ctrl.showErr"> <div class="row">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/app/shared/directives/customizableErrorMessageDirective/customizable-error-message.directive.js Tue Aug 01 15:40:08 2017 -0400 @@ -0,0 +1,45 @@ +/** + * Copyright 2012-2017 Red Hat, Inc. + * + * Thermostat is distributed under the GNU General Public License, + * version 2 or any later version (with a special exception described + * below, commonly known as the "Classpath Exception"). + * + * A copy of GNU General Public License (GPL) is included in this + * distribution, in the file COPYING. + * + * Linking Thermostat code with other modules is making a combined work + * based on Thermostat. Thus, the terms and conditions of the GPL + * cover the whole combination. + * + * As a special exception, the copyright holders of Thermostat give you + * permission to link this code with independent modules to produce an + * executable, regardless of the license terms of these independent + * modules, and to copy and distribute the resulting executable under + * terms of your choice, provided that you also meet, for each linked + * independent module, the terms and conditions of the license of that + * module. An independent module is a module which is not derived from + * or based on Thermostat code. If you modify Thermostat, you may + * extend this exception to your version of the software, but you are + * not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + */ + +import customizableErrorMessageTemplate from './customizable-error-message.html'; + +export let customizableErrorMessageFunc = () => { + return { + restrict: 'E', + scope: { + errTitle: '<', + errMessage: '<', + dismissible: '<' + }, + template: customizableErrorMessageTemplate + }; +}; + +export default angular + .module('customizableErrorMessage.directive', []) + .directive('customizableErrorMessage', customizableErrorMessageFunc) + .name;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/app/shared/directives/customizableErrorMessageDirective/customizable-error-message.directive.spec.js Tue Aug 01 15:40:08 2017 -0400 @@ -0,0 +1,93 @@ +/** + * Copyright 2012-2017 Red Hat, Inc. + * + * Thermostat is distributed under the GNU General Public License, + * version 2 or any later version (with a special exception described + * below, commonly known as the "Classpath Exception"). + * + * A copy of GNU General Public License (GPL) is included in this + * distribution, in the file COPYING. + * + * Linking Thermostat code with other modules is making a combined work + * based on Thermostat. Thus, the terms and conditions of the GPL + * cover the whole combination. + * + * As a special exception, the copyright holders of Thermostat give you + * permission to link this code with independent modules to produce an + * executable, regardless of the license terms of these independent + * modules, and to copy and distribute the resulting executable under + * terms of your choice, provided that you also meet, for each linked + * independent module, the terms and conditions of the license of that + * module. An independent module is a module which is not derived from + * or based on Thermostat code. If you modify Thermostat, you may + * extend this exception to your version of the software, but you are + * not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + */ + +import directiveModule from './customizable-error-message.directive.js'; +import {customizableErrorMessageFunc} from './customizable-error-message.directive.js'; + +describe('customizableErrorMessage Directive', () => { + let compiledDirectiveElement; + let element = '<customizable-error-message err-title=errTitle err-message=errMessage> </customizable-error-message>'; + + beforeEach(angular.mock.module(directiveModule)); + + let initDummyModule = () => { + let compile, rootScope; + angular.mock.inject(($compile, $rootScope) => { + 'ngInject'; + compile = $compile; + rootScope = $rootScope; + }); + + rootScope.errTitle = 'foo'; + rootScope.errMessage = 'bar'; + + compiledDirectiveElement = compile(element)(rootScope); + rootScope.$digest(); + }; + + describe('customizableErrorMessage Directive.function', () => { + it('should return a valid object', () => { + let fnResult = customizableErrorMessageFunc(); + fnResult.should.have.ownProperty('template'); + fnResult.should.have.ownProperty('restrict'); + fnResult.should.have.ownProperty('scope'); + }); + }); + + describe('customizableErrorMessage Directive.content', () => { + beforeEach(initDummyModule); + + it('should be a valid object', () => { + should.exist(compiledDirectiveElement); + }); + + it('should insert the correct error title', () => { + compiledDirectiveElement.html().should.containEql('foo'); + }); + + it('should insert the correct error message', () => { + compiledDirectiveElement.html().should.containEql('bar'); + }); + }); + + describe('customizableErrorMessage Directive.content', () => { + + beforeEach(initDummyModule); + + it('should be a valid object', () => { + should.exist(compiledDirectiveElement); + }); + + it('should insert the correct error title', () => { + compiledDirectiveElement.html().should.containEql('foo'); + }); + + it('should insert the correct error message', () => { + compiledDirectiveElement.html().should.containEql('bar'); + }); + }); +});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/app/shared/directives/customizableErrorMessageDirective/customizable-error-message.html Tue Aug 01 15:40:08 2017 -0400 @@ -0,0 +1,8 @@ +<div ng-hide="showElement" class="alert alert-warning alert-dismissable" > + <button ng-show="{{dismissible}}" type="button" class="close" data-dismiss="alert" aria-hidden="true" ng-click="showElement=true"> + <span class="pficon pficon-close"></span> + </button> + + <span class="pficon pficon-warning-triangle-o"></span> + <strong>{{errTitle}}</strong> {{errMessage}} +</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/app/shared/directives/customizableErrorMessageDirective/customizable-error-message.module.js Tue Aug 01 15:40:08 2017 -0400 @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2017 Red Hat, Inc. + * + * Thermostat is distributed under the GNU General Public License, + * version 2 or any later version (with a special exception described + * below, commonly known as the "Classpath Exception"). + * + * A copy of GNU General Public License (GPL) is included in this + * distribution, in the file COPYING. + * + * Linking Thermostat code with other modules is making a combined work + * based on Thermostat. Thus, the terms and conditions of the GPL + * cover the whole combination. + * + * As a special exception, the copyright holders of Thermostat give you + * permission to link this code with independent modules to produce an + * executable, regardless of the license terms of these independent + * modules, and to copy and distribute the resulting executable under + * terms of your choice, provided that you also meet, for each linked + * independent module, the terms and conditions of the license of that + * module. An independent module is a module which is not derived from + * or based on Thermostat code. If you modify Thermostat, you may + * extend this exception to your version of the software, but you are + * not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + */ + +import directive from './customizable-error-message.directive.js'; + +export default angular + .module('customizableErrorMessageDirective', [directive]) + .name;