mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-15 15:26:31 +00:00
Remove manifest-bind
Change-type: patch
This commit is contained in:
parent
fe230e7d30
commit
67eb593164
@ -95,10 +95,7 @@ const app = angular.module('Etcher', [
|
|||||||
require('./components/settings/index.ts').MODULE_NAME,
|
require('./components/settings/index.ts').MODULE_NAME,
|
||||||
|
|
||||||
// OS
|
// OS
|
||||||
require('./os/open-external/open-external'),
|
require('./os/open-external/open-external')
|
||||||
|
|
||||||
// Utils
|
|
||||||
require('./utils/manifest-bind/manifest-bind')
|
|
||||||
])
|
])
|
||||||
|
|
||||||
app.run(() => {
|
app.run(() => {
|
||||||
|
@ -111,13 +111,6 @@ function FinishPage({ $state }: any) {
|
|||||||
height="20px"
|
height="20px"
|
||||||
></SVGIcon>
|
></SVGIcon>
|
||||||
</span>
|
</span>
|
||||||
<div className="section-footer">
|
|
||||||
<span
|
|
||||||
className="caption caption-small footer-right"
|
|
||||||
manifest-bind="version"
|
|
||||||
os-open-external="https://github.com/balena-io/etcher/blob/master/CHANGELOG.md"
|
|
||||||
></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -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
|
|
||||||
* <span manifest-bind="version"></button>
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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
|
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
@ -33,7 +33,6 @@ angularValidate.validate(
|
|||||||
// Internal
|
// Internal
|
||||||
'os-open-external',
|
'os-open-external',
|
||||||
'os-dropzone',
|
'os-dropzone',
|
||||||
'manifest-bind',
|
|
||||||
|
|
||||||
// External
|
// External
|
||||||
'hide-if-state',
|
'hide-if-state',
|
||||||
|
@ -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('<span manifest-bind="version"></span>')($rootScope)
|
|
||||||
$rootScope.$digest()
|
|
||||||
m.chai.expect(element.html()).to.equal(packageJSON.version)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should bind to nested properties', function () {
|
|
||||||
const element = $compile('<span manifest-bind="repository.type"></span>')($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('<span manifest-bind="foo.bar"></span>')($rootScope)
|
|
||||||
}).to.throw('ManifestBind: Unknown property `foo.bar`')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
Loading…
x
Reference in New Issue
Block a user