mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-24 03:36:36 +00:00
Remove no longer used ModalService
Change-type: patch
This commit is contained in:
parent
05c2f5bebd
commit
65293ea5e4
@ -1,31 +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'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @module Etcher.Components.Modal
|
|
||||||
*/
|
|
||||||
|
|
||||||
const angular = require('angular')
|
|
||||||
const MODULE_NAME = 'Etcher.Components.Modal'
|
|
||||||
const Modal = angular.module(MODULE_NAME, [
|
|
||||||
require('angular-ui-bootstrap')
|
|
||||||
])
|
|
||||||
|
|
||||||
Modal.service('ModalService', require('./services/modal'))
|
|
||||||
|
|
||||||
module.exports = MODULE_NAME
|
|
@ -1,100 +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 store = require('../../../models/store')
|
|
||||||
const analytics = require('../../../modules/analytics')
|
|
||||||
|
|
||||||
module.exports = function ($uibModal, $q) {
|
|
||||||
/**
|
|
||||||
* @summary Open a modal
|
|
||||||
* @function
|
|
||||||
* @public
|
|
||||||
*
|
|
||||||
* @param {Object} options - options
|
|
||||||
* @param {String} options.template - template contents
|
|
||||||
* @param {String} options.controller - controller
|
|
||||||
* @param {String} [options.size='sm'] - modal size
|
|
||||||
* @param {Object} options.resolve - modal resolves
|
|
||||||
* @returns {Object} modal
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ModalService.open({
|
|
||||||
* name: 'my modal',
|
|
||||||
* template: require('./path/to/modal.tpl.html'),
|
|
||||||
* controller: 'DriveSelectorController as modal',
|
|
||||||
* });
|
|
||||||
*/
|
|
||||||
this.open = (options = {}) => {
|
|
||||||
_.defaults(options, {
|
|
||||||
size: 'sm'
|
|
||||||
})
|
|
||||||
|
|
||||||
analytics.logEvent('Open modal', {
|
|
||||||
name: options.name,
|
|
||||||
applicationSessionUuid: store.getState().toJS().applicationSessionUuid,
|
|
||||||
flashingWorkflowUuid: store.getState().toJS().flashingWorkflowUuid
|
|
||||||
})
|
|
||||||
|
|
||||||
const modal = $uibModal.open({
|
|
||||||
animation: true,
|
|
||||||
template: options.template,
|
|
||||||
controller: options.controller,
|
|
||||||
size: options.size,
|
|
||||||
resolve: options.resolve,
|
|
||||||
backdrop: 'static'
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
|
||||||
close: modal.close,
|
|
||||||
result: $q((resolve, reject) => {
|
|
||||||
modal.result.then((value) => {
|
|
||||||
analytics.logEvent('Modal accepted', {
|
|
||||||
name: options.name,
|
|
||||||
value,
|
|
||||||
applicationSessionUuid: store.getState().toJS().applicationSessionUuid,
|
|
||||||
flashingWorkflowUuid: store.getState().toJS().flashingWorkflowUuid
|
|
||||||
})
|
|
||||||
|
|
||||||
resolve(value)
|
|
||||||
}).catch((error) => {
|
|
||||||
// Bootstrap doesn't 'resolve' these but cancels the dialog
|
|
||||||
if (error === 'escape key press') {
|
|
||||||
analytics.logEvent('Modal rejected', {
|
|
||||||
name: options.name,
|
|
||||||
method: error,
|
|
||||||
applicationSessionUuid: store.getState().toJS().applicationSessionUuid,
|
|
||||||
flashingWorkflowUuid: store.getState().toJS().flashingWorkflowUuid
|
|
||||||
})
|
|
||||||
|
|
||||||
return resolve()
|
|
||||||
}
|
|
||||||
|
|
||||||
analytics.logEvent('Modal rejected', {
|
|
||||||
name: options.name,
|
|
||||||
value: error,
|
|
||||||
applicationSessionUuid: store.getState().toJS().applicationSessionUuid,
|
|
||||||
flashingWorkflowUuid: store.getState().toJS().flashingWorkflowUuid
|
|
||||||
})
|
|
||||||
|
|
||||||
return reject(error)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,106 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
.modal-content {
|
|
||||||
background-color: $palette-theme-light-background;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
margin: 0 auto;
|
|
||||||
height: auto;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: baseline;
|
|
||||||
font-size: 12px;
|
|
||||||
color: $palette-theme-light-soft-foreground;
|
|
||||||
padding: 11px 20px;
|
|
||||||
flex-grow: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-title {
|
|
||||||
font-size: inherit;
|
|
||||||
flex-grow: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-body {
|
|
||||||
flex-grow: 1;
|
|
||||||
color: $palette-theme-light-foreground;
|
|
||||||
padding: 20px;
|
|
||||||
max-height: 250px;
|
|
||||||
overflow: auto;
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: $palette-theme-primary-background;
|
|
||||||
}
|
|
||||||
|
|
||||||
> p {
|
|
||||||
white-space: pre-line;
|
|
||||||
}
|
|
||||||
|
|
||||||
> p:last-child {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-menu {
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
> * {
|
|
||||||
flex-basis: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// UI Bootstrap adds the `.modal-open` class to the <body>
|
|
||||||
// element and sets its right padding to the width of the
|
|
||||||
// window, causing the window content to overflow and get
|
|
||||||
// pushed to the bottom.
|
|
||||||
// The `!important` flag is needed since UI Bootstrap inlines
|
|
||||||
// the styles programmatically to the element.
|
|
||||||
.modal-open {
|
|
||||||
padding-right: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable modal opacity
|
|
||||||
.modal-backdrop.in {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-footer {
|
|
||||||
flex-grow: 0;
|
|
||||||
border: 0;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal {
|
|
||||||
|
|
||||||
// Center the modal using Flexbox so we can
|
|
||||||
// freely use any height.
|
|
||||||
display: flex !important;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.button[disabled] {
|
|
||||||
background-color: $palette-theme-light-disabled-background;
|
|
||||||
color: $palette-theme-light-disabled-foreground;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-dialog {
|
|
||||||
margin: 0;
|
|
||||||
position: initial;
|
|
||||||
}
|
|
@ -31,7 +31,6 @@ $disabled-opacity: 0.2;
|
|||||||
@import "./components/caption";
|
@import "./components/caption";
|
||||||
@import "./components/button";
|
@import "./components/button";
|
||||||
@import "./components/tick";
|
@import "./components/tick";
|
||||||
@import "../components/modal/styles/modal";
|
|
||||||
@import "../components/drive-selector/styles/drive-selector";
|
@import "../components/drive-selector/styles/drive-selector";
|
||||||
@import "../components/svg-icon/styles/svg-icon";
|
@import "../components/svg-icon/styles/svg-icon";
|
||||||
@import "../pages/main/styles/main";
|
@import "../pages/main/styles/main";
|
||||||
|
@ -6125,82 +6125,6 @@ body {
|
|||||||
background-color: #d9534f;
|
background-color: #d9534f;
|
||||||
border-color: #d9534f; }
|
border-color: #d9534f; }
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
.modal-content {
|
|
||||||
background-color: #fff;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
margin: 0 auto;
|
|
||||||
height: auto;
|
|
||||||
overflow: hidden; }
|
|
||||||
|
|
||||||
.modal-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: baseline;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #b3b3b3;
|
|
||||||
padding: 11px 20px;
|
|
||||||
flex-grow: 0; }
|
|
||||||
|
|
||||||
.modal-title {
|
|
||||||
font-size: inherit;
|
|
||||||
flex-grow: 1; }
|
|
||||||
|
|
||||||
.modal-body {
|
|
||||||
flex-grow: 1;
|
|
||||||
color: #666;
|
|
||||||
padding: 20px;
|
|
||||||
max-height: 250px;
|
|
||||||
overflow: auto; }
|
|
||||||
.modal-body a {
|
|
||||||
color: #2297de; }
|
|
||||||
.modal-body > p {
|
|
||||||
white-space: pre-line; }
|
|
||||||
.modal-body > p:last-child {
|
|
||||||
margin-bottom: 0; }
|
|
||||||
|
|
||||||
.modal-menu {
|
|
||||||
display: flex; }
|
|
||||||
.modal-menu > * {
|
|
||||||
flex-basis: auto; }
|
|
||||||
|
|
||||||
.modal-open {
|
|
||||||
padding-right: 0 !important; }
|
|
||||||
|
|
||||||
.modal-backdrop.in {
|
|
||||||
opacity: 0; }
|
|
||||||
|
|
||||||
.modal-footer {
|
|
||||||
flex-grow: 0;
|
|
||||||
border: 0;
|
|
||||||
text-align: center; }
|
|
||||||
|
|
||||||
.modal {
|
|
||||||
display: flex !important;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center; }
|
|
||||||
.modal .button[disabled] {
|
|
||||||
background-color: #d5d5d5;
|
|
||||||
color: #787c7f; }
|
|
||||||
|
|
||||||
.modal-dialog {
|
|
||||||
margin: 0;
|
|
||||||
position: initial; }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2016 balena.io
|
* Copyright 2016 balena.io
|
||||||
*
|
*
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 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')
|
|
||||||
require('angular-mocks')
|
|
||||||
|
|
||||||
describe('Browser: Modal', function () {
|
|
||||||
beforeEach(angular.mock.module(
|
|
||||||
require('../../../lib/gui/app/components/modal/modal')
|
|
||||||
))
|
|
||||||
|
|
||||||
describe('ModalService', function () {
|
|
||||||
let ModalService
|
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(function (_ModalService_) {
|
|
||||||
ModalService = _ModalService_
|
|
||||||
}))
|
|
||||||
|
|
||||||
describe('.open()', function () {
|
|
||||||
it('should not emit any errors when the template is a non-empty string', function () {
|
|
||||||
m.chai.expect(function () {
|
|
||||||
ModalService.open({
|
|
||||||
template: '<div>{{ \'Hello\' }}, World!</div>'
|
|
||||||
})
|
|
||||||
}).to.not.throw()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should emit error on no template field', function () {
|
|
||||||
m.chai.expect(function () {
|
|
||||||
ModalService.open({})
|
|
||||||
}).to.throw('One of component or template or templateUrl options is required.')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should emit error on empty string template', function () {
|
|
||||||
m.chai.expect(function () {
|
|
||||||
ModalService.open({
|
|
||||||
template: ''
|
|
||||||
})
|
|
||||||
}).to.throw('One of component or template or templateUrl options is required.')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
Loading…
x
Reference in New Issue
Block a user