changeset 188:62fa62ee6512

Convert dismissible-error-message directive to component Reviewed-by: jkang Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-August/024757.html Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-September/024914.html
author Andrew Azores <aazores@redhat.com>
date Fri, 08 Sep 2017 11:22:40 -0400
parents a7a83b92b855
children 8dfeba19cd14
files src/app/shared/components/dismissible-error-message/dismissible-error-message.component.js src/app/shared/components/dismissible-error-message/dismissible-error-message.directive.js src/app/shared/components/dismissible-error-message/dismissible-error-message.directive.spec.js src/app/shared/components/dismissible-error-message/dismissible-error-message.html src/app/shared/components/dismissible-error-message/dismissible-error-message.module.js
diffstat 5 files changed, 38 insertions(+), 153 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/shared/components/dismissible-error-message/dismissible-error-message.component.js	Fri Sep 08 11:22:40 2017 -0400
@@ -0,0 +1,37 @@
+/**
+ * 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.
+ */
+
+export default angular
+  .module('dismissibleErrorMessage.component', [])
+  .component('dismissibleErrorMessage', {
+    bindings: {
+      errTitle: '<',
+      errMessage: '<'
+    },
+    template: require('./dismissible-error-message.html')
+  })
+  .name;
--- a/src/app/shared/components/dismissible-error-message/dismissible-error-message.directive.js	Fri Sep 08 11:18:34 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/**
- * 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 dismissibleErrorMessageTemplate from './dismissible-error-message.html';
-
-export let dismissibleErrorMessageFunc = () => {
-  return {
-    restrict: 'E',
-    scope: {
-      errTitle: '<',
-      errMessage: '<'
-    },
-    template: dismissibleErrorMessageTemplate
-  };
-};
-
-export default angular
-    .module('dismissibleErrorMessage.directive', [])
-    .directive('dismissibleErrorMessage', dismissibleErrorMessageFunc)
-    .name;
--- a/src/app/shared/components/dismissible-error-message/dismissible-error-message.directive.spec.js	Fri Sep 08 11:18:34 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/**
- * 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 './dismissible-error-message.directive.js';
-import {dismissibleErrorMessageFunc} from './dismissible-error-message.directive.js';
-
-describe('dismissibleErrorMessage Directive', () => {
-  let compiledDirectiveElement;
-  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';
-    let element = '<dismissible-error-message err-title=errTitle ' +
-      'err-message=errMessage> </dismissible-error-message>';
-
-    compiledDirectiveElement = compile(element)(rootScope);
-    rootScope.$digest();
-  };
-
-  describe('dismissibleErrorMessage Directive.function', () => {
-    it('should return a valid object', () => {
-      let fnResult = dismissibleErrorMessageFunc();
-      fnResult.should.have.ownProperty('template');
-      fnResult.should.have.ownProperty('restrict');
-      fnResult.should.have.ownProperty('scope');
-    });
-  });
-
-  describe('dismissibleErrorMessage 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');
-    });
-  });
-});
--- a/src/app/shared/components/dismissible-error-message/dismissible-error-message.html	Fri Sep 08 11:18:34 2017 -0400
+++ b/src/app/shared/components/dismissible-error-message/dismissible-error-message.html	Fri Sep 08 11:22:40 2017 -0400
@@ -4,5 +4,5 @@
   </button>
 
   <span class="pficon pficon-warning-triangle-o"></span>
-  <strong>{{errTitle}}</strong> {{errMessage}}
+  <strong>{{$ctrl.errTitle}}</strong> {{$ctrl.errMessage}}
 </div>
--- a/src/app/shared/components/dismissible-error-message/dismissible-error-message.module.js	Fri Sep 08 11:18:34 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/**
- * 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 './dismissible-error-message.directive.js';
-
-export default angular
-  .module('dismissibleErrorMessage', [directive])
-  .name;