chore: reformat code with Prettier
This commit is contained in:
parent
3524886d5d
commit
f18e98a63e
@ -31,10 +31,7 @@ export default class MountHandler extends LocalHandler {
|
||||
}
|
||||
this._realPath = join(
|
||||
mountsDir,
|
||||
remote.id ||
|
||||
Math.random()
|
||||
.toString(36)
|
||||
.slice(2)
|
||||
remote.id || Math.random().toString(36).slice(2)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,7 @@ export const evalTemplate = (tpl, data) => {
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
const compileGlobPatternFragment = pattern =>
|
||||
pattern
|
||||
.split('*')
|
||||
.map(escapeRegExp)
|
||||
.join('.*')
|
||||
pattern.split('*').map(escapeRegExp).join('.*')
|
||||
|
||||
export const compileGlobPattern = pattern => {
|
||||
const no = []
|
||||
|
@ -173,9 +173,9 @@ const handleHook = data => {
|
||||
|
||||
// Log it
|
||||
console.log(
|
||||
`${new Date(
|
||||
timestamp
|
||||
).toISOString()} [${method}|${type}] ${params} → ${result || error}`
|
||||
`${new Date(timestamp).toISOString()} [${method}|${type}] ${params} → ${
|
||||
result || error
|
||||
}`
|
||||
)
|
||||
|
||||
// Run scripts
|
||||
|
@ -221,13 +221,7 @@ export class GlobPattern extends Node {
|
||||
Object.defineProperty(this, 'match', {
|
||||
value: this.match.bind(
|
||||
this,
|
||||
new RegExp(
|
||||
value
|
||||
.split('*')
|
||||
.map(escapeRegExp)
|
||||
.join('.*'),
|
||||
'i'
|
||||
)
|
||||
new RegExp(value.split('*').map(escapeRegExp).join('.*'), 'i')
|
||||
),
|
||||
})
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ Installation of the [npm package](https://npmjs.org/package/value-matcher):
|
||||
|
||||
```js
|
||||
import { createPredicate } from 'value-matcher'
|
||||
|
||||
;[
|
||||
{ user: 'sam', age: 65, active: false },
|
||||
{ user: 'barney', age: 36, active: true },
|
||||
|
@ -11,10 +11,10 @@ export default async function main(args) {
|
||||
const handler = getHandler({ url: 'file:///' })
|
||||
const stream = await createSyntheticStream(handler, path.resolve(args[0]))
|
||||
return new Promise((resolve, reject) => {
|
||||
stream.on('error', reject).pipe(
|
||||
createWriteStream(args[1])
|
||||
stream
|
||||
.on('error', reject)
|
||||
.on('finish', resolve)
|
||||
.pipe(
|
||||
createWriteStream(args[1]).on('error', reject).on('finish', resolve)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
@ -517,9 +517,7 @@ export class Xapi extends EventEmitter {
|
||||
throw new Error('Xapi#barrier() requires events watching')
|
||||
}
|
||||
|
||||
const key = `xo:barrier:${Math.random()
|
||||
.toString(36)
|
||||
.slice(2)}`
|
||||
const key = `xo:barrier:${Math.random().toString(36).slice(2)}`
|
||||
const poolRef = this._pool.$ref
|
||||
|
||||
const { promise, resolve } = defer()
|
||||
|
@ -22,9 +22,7 @@ async function main([url]) {
|
||||
while (loop) {
|
||||
await pool.update_other_config(
|
||||
'xo:injectEvents',
|
||||
Math.random()
|
||||
.toString(36)
|
||||
.slice(2)
|
||||
Math.random().toString(36).slice(2)
|
||||
)
|
||||
await pDelay(1e2)
|
||||
}
|
||||
|
@ -69,10 +69,7 @@ const STATUS_ICON = {
|
||||
const DATE_FORMAT = 'dddd, MMMM Do YYYY, h:mm:ss a'
|
||||
const createDateFormatter = timezone =>
|
||||
timezone !== undefined
|
||||
? timestamp =>
|
||||
moment(timestamp)
|
||||
.tz(timezone)
|
||||
.format(DATE_FORMAT)
|
||||
? timestamp => moment(timestamp).tz(timezone).format(DATE_FORMAT)
|
||||
: timestamp => moment(timestamp).format(DATE_FORMAT)
|
||||
|
||||
const formatDuration = milliseconds => moment.duration(milliseconds).humanize()
|
||||
|
@ -1,6 +1,3 @@
|
||||
const randomId = () =>
|
||||
Math.random()
|
||||
.toString(36)
|
||||
.slice(2)
|
||||
const randomId = () => Math.random().toString(36).slice(2)
|
||||
|
||||
export { randomId as default }
|
||||
|
@ -669,11 +669,7 @@ export const createSR = defer(async function(
|
||||
$defer.onFailure(() => this.unbindXosanLicense({ srId: tmpBoundObjectId }))
|
||||
|
||||
// '172.31.100.0' -> '172.31.100.'
|
||||
const networkPrefix =
|
||||
ipRange
|
||||
.split('.')
|
||||
.slice(0, 3)
|
||||
.join('.') + '.'
|
||||
const networkPrefix = ipRange.split('.').slice(0, 3).join('.') + '.'
|
||||
let vmIpLastNumber = VM_FIRST_NUMBER
|
||||
|
||||
try {
|
||||
|
@ -250,9 +250,7 @@ export default class Api {
|
||||
const userName = context.user ? context.user.email : '(unknown user)'
|
||||
|
||||
const data = {
|
||||
callId: Math.random()
|
||||
.toString(36)
|
||||
.slice(2),
|
||||
callId: Math.random().toString(36).slice(2),
|
||||
userId,
|
||||
userName,
|
||||
userIp: session.get('user_ip', undefined),
|
||||
|
@ -139,10 +139,7 @@ export default class Proxy {
|
||||
)
|
||||
|
||||
patch(proxy, { address, authenticationToken, name, vmUuid })
|
||||
return this._db
|
||||
.update(proxy)
|
||||
.then(extractProperties)
|
||||
.then(omitToken)
|
||||
return this._db.update(proxy).then(extractProperties).then(omitToken)
|
||||
}
|
||||
|
||||
async upgradeProxyAppliance(id) {
|
||||
|
@ -93,11 +93,7 @@ export class FormattedDuration extends Component {
|
||||
_humanizeDuration = createSelector(
|
||||
() => this.props.duration,
|
||||
() => this.props.lang,
|
||||
(duration, lang) =>
|
||||
moment
|
||||
.duration(duration)
|
||||
.locale(lang)
|
||||
.humanize()
|
||||
(duration, lang) => moment.duration(duration).locale(lang).humanize()
|
||||
)
|
||||
|
||||
render() {
|
||||
|
@ -43,8 +43,9 @@ function* range(ip1, ip2) {
|
||||
}
|
||||
|
||||
for (let i = hex; i <= hex2; i++) {
|
||||
yield `${(i >> 24) & 0xff}.${(i >> 16) & 0xff}.${(i >> 8) & 0xff}.${i &
|
||||
0xff}`
|
||||
yield `${(i >> 24) & 0xff}.${(i >> 16) & 0xff}.${(i >> 8) & 0xff}.${
|
||||
i & 0xff
|
||||
}`
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
// this computed can be used to generate a random id for the lifetime of the
|
||||
// component
|
||||
export const generateId = () =>
|
||||
`i${Math.random()
|
||||
.toString(36)
|
||||
.slice(2)}`
|
||||
export const generateId = () => `i${Math.random().toString(36).slice(2)}`
|
||||
|
||||
// TODO: remove these functions once the PR: https://github.com/JsCommunity/reaclette/pull/5 has been merged
|
||||
// It only supports native inputs
|
||||
|
@ -413,9 +413,7 @@ export const SelectHost = makeStoreSelect(
|
||||
|
||||
export const SelectPool = makeStoreSelect(
|
||||
() => ({
|
||||
xoObjects: createGetObjectsOfType('pool')
|
||||
.filter(getPredicate)
|
||||
.sort(),
|
||||
xoObjects: createGetObjectsOfType('pool').filter(getPredicate).sort(),
|
||||
}),
|
||||
{ placeholder: _('selectPools') }
|
||||
)
|
||||
@ -463,12 +461,8 @@ export const SelectVm = makeStoreSelect(
|
||||
keys(vmsByContainer)
|
||||
)
|
||||
|
||||
const getPools = createGetObjectsOfType('pool')
|
||||
.pick(getContainerIds)
|
||||
.sort()
|
||||
const getHosts = createGetObjectsOfType('host')
|
||||
.pick(getContainerIds)
|
||||
.sort()
|
||||
const getPools = createGetObjectsOfType('pool').pick(getContainerIds).sort()
|
||||
const getHosts = createGetObjectsOfType('host').pick(getContainerIds).sort()
|
||||
|
||||
const getContainers = createSelector(getPools, getHosts, (pools, hosts) =>
|
||||
pools.concat(hosts)
|
||||
@ -507,12 +501,8 @@ export const SelectVmSnapshot = makeStoreSelect(
|
||||
|
||||
export const SelectHostVm = makeStoreSelect(
|
||||
() => {
|
||||
const getHosts = createGetObjectsOfType('host')
|
||||
.filter(getPredicate)
|
||||
.sort()
|
||||
const getVms = createGetObjectsOfType('VM')
|
||||
.filter(getPredicate)
|
||||
.sort()
|
||||
const getHosts = createGetObjectsOfType('host').filter(getPredicate).sort()
|
||||
const getVms = createGetObjectsOfType('VM').filter(getPredicate).sort()
|
||||
|
||||
const getObjects = createSelector(getHosts, getVms, (hosts, vms) =>
|
||||
hosts.concat(vms)
|
||||
|
@ -599,9 +599,9 @@ class SortedTable extends Component {
|
||||
selectedItemsIds.delete(item.id)
|
||||
})
|
||||
} else {
|
||||
const method = (selected === undefined
|
||||
? !selectedItemsIds.has(item.id)
|
||||
: selected)
|
||||
const method = (
|
||||
selected === undefined ? !selectedItemsIds.has(item.id) : selected
|
||||
)
|
||||
? 'add'
|
||||
: 'delete'
|
||||
|
||||
|
@ -547,10 +547,7 @@ export const getMemoryUsedMetric = ({ memory, memoryFree = memory }) =>
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export const generateRandomId = () =>
|
||||
Math.random()
|
||||
.toString(36)
|
||||
.slice(2)
|
||||
export const generateRandomId = () => Math.random().toString(36).slice(2)
|
||||
|
||||
// ===================================================================
|
||||
|
||||
|
@ -210,10 +210,7 @@ export default class XoParallelChart extends Component {
|
||||
forEach(columnsIds, (columnId, index) => {
|
||||
const max = d3.max(dataSet, elem => elem.data[columnId])
|
||||
|
||||
y[columnId] = d3
|
||||
.scaleLinear()
|
||||
.domain([0, max])
|
||||
.range([CHART_HEIGHT, 0])
|
||||
y[columnId] = d3.scaleLinear().domain([0, max]).range([CHART_HEIGHT, 0])
|
||||
})
|
||||
|
||||
// 3. Build columns.
|
||||
|
@ -144,10 +144,7 @@ class XoWeekChart extends Component {
|
||||
|
||||
const svg = this._svg
|
||||
|
||||
svg
|
||||
.select('.horizon-area')
|
||||
.selectAll('path')
|
||||
.remove()
|
||||
svg.select('.horizon-area').selectAll('path').remove()
|
||||
forEach(splittedData, data => {
|
||||
svg
|
||||
.select('.horizon-area')
|
||||
@ -195,11 +192,7 @@ class XoWeekChart extends Component {
|
||||
::setStyles(X_AXIS_TEXT_STYLE)
|
||||
|
||||
// 4. Update label.
|
||||
svg
|
||||
.select('.label')
|
||||
.attr('dx', 5)
|
||||
.attr('dy', 20)
|
||||
.text(props.label)
|
||||
svg.select('.label').attr('dx', 5).attr('dy', 20).text(props.label)
|
||||
}
|
||||
|
||||
_handleMouseMove = () => {
|
||||
@ -228,10 +221,7 @@ class XoWeekChart extends Component {
|
||||
const { props } = this
|
||||
const hover = this._svg.select('.hover-container')
|
||||
|
||||
hover
|
||||
.select('.hover-line')
|
||||
.attr('x1', x)
|
||||
.attr('x2', x)
|
||||
hover.select('.hover-line').attr('x1', x).attr('x2', x)
|
||||
|
||||
hover
|
||||
.select('.hover-text')
|
||||
@ -247,16 +237,10 @@ class XoWeekChart extends Component {
|
||||
.select(this.refs.chart)
|
||||
.append('svg')
|
||||
.attr('transform', `translate(${HORIZON_AREA_MARGIN}, 0)`))
|
||||
svg
|
||||
.append('g')
|
||||
.attr('class', 'x-axis')
|
||||
::setStyles(X_AXIS_STYLE)
|
||||
svg.append('g').attr('class', 'x-axis')::setStyles(X_AXIS_STYLE)
|
||||
|
||||
svg.append('g').attr('class', 'horizon-area')
|
||||
svg
|
||||
.append('text')
|
||||
.attr('class', 'label')
|
||||
::setStyles(LABEL_STYLE)
|
||||
svg.append('text').attr('class', 'label')::setStyles(LABEL_STYLE)
|
||||
|
||||
// Tooltip ---------------------------------------------
|
||||
svg
|
||||
|
@ -62,9 +62,7 @@ import TabXosan from './tab-xosan'
|
||||
|
||||
const getVdiIds = (state, props) => getSr(state, props).VDIs
|
||||
|
||||
const getVdis = createGetObjectsOfType('VDI')
|
||||
.pick(getVdiIds)
|
||||
.sort()
|
||||
const getVdis = createGetObjectsOfType('VDI').pick(getVdiIds).sort()
|
||||
const getVdiSnapshots = createGetObjectsOfType('VDI-snapshot')
|
||||
.pick(getVdiIds)
|
||||
.sort()
|
||||
|
@ -268,7 +268,10 @@ const SshKeys = addSubscriptions({
|
||||
})(({ user }) => {
|
||||
const sshKeys = user && user.preferences && user.preferences.sshKeys
|
||||
|
||||
const sshKeysWithIds = map(sshKeys, sshKey => ({ ...sshKey, id: sshKey.key }))
|
||||
const sshKeysWithIds = map(sshKeys, sshKey => ({
|
||||
...sshKey,
|
||||
id: sshKey.key,
|
||||
}))
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
Loading…
Reference in New Issue
Block a user