diff --git a/lib/gui/app/app.js b/lib/gui/app/app.js index 67ca496a..70658c9b 100644 --- a/lib/gui/app/app.js +++ b/lib/gui/app/app.js @@ -95,10 +95,7 @@ const app = angular.module('Etcher', [ require('./components/settings/index.ts').MODULE_NAME, // OS - require('./os/open-external/open-external'), - - // Utils - require('./utils/manifest-bind/manifest-bind') + require('./os/open-external/open-external') ]) app.run(() => { diff --git a/lib/gui/app/components/finish/finish.tsx b/lib/gui/app/components/finish/finish.tsx index ad9ba1af..e444b863 100644 --- a/lib/gui/app/components/finish/finish.tsx +++ b/lib/gui/app/components/finish/finish.tsx @@ -111,13 +111,6 @@ function FinishPage({ $state }: any) { height="20px" > -
- -
diff --git a/lib/gui/app/utils/manifest-bind/directives/manifest-bind.js b/lib/gui/app/utils/manifest-bind/directives/manifest-bind.js deleted file mode 100644 index d570d3bc..00000000 --- a/lib/gui/app/utils/manifest-bind/directives/manifest-bind.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2016 balena.io - * - * Licensed 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. - */ - -'use strict' - -const errors = require('../../../../../shared/errors') - -/** - * @summary ManifestBind directive - * @function - * @public - * - * @description - * This directive provides an attribute to bind the current - * element value to a property in `package.json`. - * - * @param {Object} ManifestBindService - ManifestBindService - * @returns {Object} directive - * - * @example - * - */ -module.exports = (ManifestBindService) => { - return { - restrict: 'A', - scope: false, - link: (scope, element, attributes) => { - const value = ManifestBindService.get(attributes.manifestBind) - - if (!value) { - throw errors.createError({ - title: `ManifestBind: Unknown property \`${attributes.manifestBind}\`` - }) - } - - element.html(value) - } - } -} diff --git a/lib/gui/app/utils/manifest-bind/manifest-bind.js b/lib/gui/app/utils/manifest-bind/manifest-bind.js deleted file mode 100644 index 6ff1cd8f..00000000 --- a/lib/gui/app/utils/manifest-bind/manifest-bind.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2016 balena.io - * - * Licensed 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. - */ - -'use strict' - -/** - * The purpose of this module is to provide an attribute - * directive to bind the current element to a property - * in the application's `package.json` manifest. - * - * @module Etcher.Utils.ManifestBind - */ - -const angular = require('angular') -const MODULE_NAME = 'Etcher.Utils.ManifestBind' -const ManifestBind = angular.module(MODULE_NAME, []) -ManifestBind.service('ManifestBindService', require('./services/manifest-bind')) -ManifestBind.directive('manifestBind', require('./directives/manifest-bind')) - -module.exports = MODULE_NAME diff --git a/lib/gui/app/utils/manifest-bind/services/manifest-bind.js b/lib/gui/app/utils/manifest-bind/services/manifest-bind.js deleted file mode 100644 index 93878e0f..00000000 --- a/lib/gui/app/utils/manifest-bind/services/manifest-bind.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2016 balena.io - * - * Licensed 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. - */ - -'use strict' - -const _ = require('lodash') -const packageJSON = require('../../../../../../package.json') - -module.exports = function () { - /** - * @summary Get a package.json property - * @function - * @public - * - * @param {String} attribute - attribute - * @returns {*} property value - * - * @example - * const version = ManifestBindService.get('version'); - */ - this.get = (attribute) => { - return _.get(packageJSON, attribute) - } -} diff --git a/scripts/html-lint.js b/scripts/html-lint.js index 67b96a68..3caa710e 100644 --- a/scripts/html-lint.js +++ b/scripts/html-lint.js @@ -33,7 +33,6 @@ angularValidate.validate( // Internal 'os-open-external', 'os-dropzone', - 'manifest-bind', // External 'hide-if-state', diff --git a/tests/gui/utils/manifest-bind.spec.js b/tests/gui/utils/manifest-bind.spec.js deleted file mode 100644 index 1549eca3..00000000 --- a/tests/gui/utils/manifest-bind.spec.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2016 balena.io - * - * Licensed 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. - */ - -'use strict' - -const m = require('mochainon') -const angular = require('angular') -const packageJSON = require('../../../package.json') - -describe('Browser: ManifestBind', function () { - beforeEach(angular.mock.module( - require('../../../lib/gui/app/utils/manifest-bind/manifest-bind') - )) - - let $compile - let $rootScope - - beforeEach(angular.mock.inject(function (_$compile_, _$rootScope_) { - $compile = _$compile_ - $rootScope = _$rootScope_ - })) - - describe('ManifestBindService', function () { - let ManifestBindService - - beforeEach(angular.mock.inject(function (_ManifestBindService_) { - ManifestBindService = _ManifestBindService_ - })) - - it('should be able to fetch top level properties', function () { - const value = ManifestBindService.get('version') - m.chai.expect(value).to.equal(packageJSON.version) - }) - - it('should be able to fetch nested properties', function () { - const value = ManifestBindService.get('repository.type') - m.chai.expect(value).to.equal(packageJSON.repository.type) - }) - - it('should return undefined if the property does not exist', function () { - const value = ManifestBindService.get('foo.bar') - m.chai.expect(value).to.be.undefined - }) - }) - - describe('manifestBind', function () { - it('should bind to top level properties', function () { - const element = $compile('')($rootScope) - $rootScope.$digest() - m.chai.expect(element.html()).to.equal(packageJSON.version) - }) - - it('should bind to nested properties', function () { - const element = $compile('')($rootScope) - $rootScope.$digest() - m.chai.expect(element.html()).to.equal(packageJSON.repository.type) - }) - - it('should throw if the property does not exist', function () { - m.chai.expect(function () { - $compile('')($rootScope) - }).to.throw('ManifestBind: Unknown property `foo.bar`') - }) - }) -})