mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-19 01:06:36 +00:00
Convert available-drives.js to typescript
Change-type: patch
This commit is contained in:
parent
a8728336ca
commit
fd127da342
@ -43,6 +43,7 @@ const settings = require('./models/settings')
|
||||
const windowProgress = require('./os/window-progress')
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const analytics = require('./modules/analytics')
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const availableDrives = require('./models/available-drives')
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const { scanner: driveScanner } = require('./modules/drive-scanner')
|
||||
|
@ -1,71 +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')
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const { Actions, store } = require('./store')
|
||||
|
||||
/**
|
||||
* @summary Check if there are available drives
|
||||
* @function
|
||||
* @public
|
||||
*
|
||||
* @returns {Boolean} whether there are available drives
|
||||
*
|
||||
* @example
|
||||
* if (availableDrives.hasAvailableDrives()) {
|
||||
* console.log('There are available drives!');
|
||||
* }
|
||||
*/
|
||||
exports.hasAvailableDrives = () => {
|
||||
return !_.isEmpty(exports.getDrives())
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Set a list of drives
|
||||
* @function
|
||||
* @private
|
||||
*
|
||||
* @param {Object[]} drives - drives
|
||||
*
|
||||
* @throws Will throw if no drives
|
||||
* @throws Will throw if drives is not an array of objects
|
||||
*
|
||||
* @example
|
||||
* availableDrives.setDrives([ ... ]);
|
||||
*/
|
||||
exports.setDrives = (drives) => {
|
||||
store.dispatch({
|
||||
type: Actions.SET_AVAILABLE_DRIVES,
|
||||
data: drives
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Get detected drives
|
||||
* @function
|
||||
* @private
|
||||
*
|
||||
* @returns {Object[]} drives
|
||||
*
|
||||
* @example
|
||||
* const drives = availableDrives.getDrives();
|
||||
*/
|
||||
exports.getDrives = () => {
|
||||
return store.getState().toJS().availableDrives
|
||||
}
|
34
lib/gui/app/models/available-drives.ts
Normal file
34
lib/gui/app/models/available-drives.ts
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { Actions, store } from './store';
|
||||
|
||||
export function hasAvailableDrives() {
|
||||
return !_.isEmpty(getDrives());
|
||||
}
|
||||
|
||||
export function setDrives(drives: any[]) {
|
||||
store.dispatch({
|
||||
type: Actions.SET_AVAILABLE_DRIVES,
|
||||
data: drives,
|
||||
});
|
||||
}
|
||||
|
||||
export function getDrives() {
|
||||
return store.getState().toJS().availableDrives;
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
const _ = require('lodash')
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const { Actions, store } = require('./store')
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const availableDrives = require('./available-drives')
|
||||
|
||||
/**
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
const m = require('mochainon')
|
||||
const path = require('path')
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const availableDrives = require('../../../lib/gui/app/models/available-drives')
|
||||
const selectionState = require('../../../lib/gui/app/models/selection-state')
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
|
@ -19,6 +19,7 @@
|
||||
const m = require('mochainon')
|
||||
const _ = require('lodash')
|
||||
const path = require('path')
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const availableDrives = require('../../../lib/gui/app/models/available-drives')
|
||||
const selectionState = require('../../../lib/gui/app/models/selection-state')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user