chore: fixes various warnings (#2554)
This commit is contained in:
parent
03028bca50
commit
6e44c65a07
@ -160,9 +160,9 @@ class Editable extends Component {
|
||||
)}
|
||||
>
|
||||
<span
|
||||
onClick={!useLongClick && this._openEdition}
|
||||
onMouseDown={useLongClick && this.__startTimer}
|
||||
onMouseUp={useLongClick && this.__stopTimer}
|
||||
onClick={useLongClick ? undefined : this._openEdition}
|
||||
onMouseDown={useLongClick ? this.__startTimer : undefined}
|
||||
onMouseUp={useLongClick ? this.__stopTimer : undefined}
|
||||
>
|
||||
{this._renderDisplay()}
|
||||
</span>
|
||||
|
@ -114,8 +114,8 @@ export default class Select extends Component {
|
||||
return (
|
||||
<div
|
||||
className={className}
|
||||
onClick={!disabled && (() => selectValue(option))}
|
||||
onMouseOver={!disabled && (() => focusOption(option))}
|
||||
onClick={disabled ? undefined : () => selectValue(option)}
|
||||
onMouseOver={disabled ? undefined : () => focusOption(option)}
|
||||
style={style}
|
||||
key={key}
|
||||
>
|
||||
|
@ -9,12 +9,12 @@ import propTypes from '../prop-types-decorator'
|
||||
@uncontrollableInput()
|
||||
@propTypes({
|
||||
className: propTypes.string,
|
||||
onChange: propTypes.func,
|
||||
onChange: propTypes.func.isRequired,
|
||||
icon: propTypes.string,
|
||||
iconOn: propTypes.string,
|
||||
iconOff: propTypes.string,
|
||||
iconSize: propTypes.number,
|
||||
value: propTypes.bool,
|
||||
value: propTypes.bool.isRequired,
|
||||
})
|
||||
export default class Toggle extends Component {
|
||||
static defaultProps = {
|
||||
|
@ -13,19 +13,29 @@ import propTypes from './prop-types-decorator'
|
||||
// {children}
|
||||
// </NoObjects>
|
||||
// ````
|
||||
const NoObjects = ({ children, collection, emptyMessage }) =>
|
||||
collection == null ? (
|
||||
<img src='assets/loading.svg' alt='loading' />
|
||||
) : isEmpty(collection) ? (
|
||||
<p>{emptyMessage}</p>
|
||||
const NoObjects = props => {
|
||||
const { collection } = props
|
||||
|
||||
if (collection == null) {
|
||||
return <img src='assets/loading.svg' alt='loading' />
|
||||
}
|
||||
|
||||
if (isEmpty(collection)) {
|
||||
return <p>{props.emptyMessage}</p>
|
||||
}
|
||||
|
||||
const { children, component: Component, ...otherProps } = props
|
||||
return children !== undefined ? (
|
||||
children(otherProps)
|
||||
) : (
|
||||
<div>{children}</div>
|
||||
<Component {...otherProps} />
|
||||
)
|
||||
}
|
||||
|
||||
propTypes(NoObjects)({
|
||||
children: propTypes.node.isRequired,
|
||||
collection: propTypes.oneOfType([propTypes.array, propTypes.object])
|
||||
.isRequired,
|
||||
children: propTypes.func,
|
||||
collection: propTypes.oneOfType([propTypes.array, propTypes.object]),
|
||||
component: propTypes.func,
|
||||
emptyMessage: propTypes.node.isRequired,
|
||||
})
|
||||
export default NoObjects
|
||||
|
@ -173,7 +173,7 @@ export const CpuLineChart = injectIntl(
|
||||
export const PoolCpuLineChart = injectIntl(
|
||||
propTypes({
|
||||
addSumSeries: propTypes.bool,
|
||||
data: propTypes.object.isRequired,
|
||||
data: propTypes.array.isRequired,
|
||||
options: propTypes.object,
|
||||
})(({ addSumSeries, data, options = {}, intl }) => {
|
||||
const firstHostData = data[0]
|
||||
@ -261,7 +261,7 @@ export const MemoryLineChart = injectIntl(
|
||||
export const PoolMemoryLineChart = injectIntl(
|
||||
propTypes({
|
||||
addSumSeries: propTypes.bool,
|
||||
data: propTypes.object.isRequired,
|
||||
data: propTypes.array.isRequired,
|
||||
options: propTypes.object,
|
||||
})(({ addSumSeries, data, options = {}, intl }) => {
|
||||
const firstHostData = data[0]
|
||||
@ -384,7 +384,7 @@ export const VifLineChart = injectIntl(
|
||||
export const PifLineChart = injectIntl(
|
||||
propTypes({
|
||||
addSumSeries: propTypes.bool,
|
||||
data: propTypes.object.isRequired,
|
||||
data: propTypes.array.isRequired,
|
||||
options: propTypes.object,
|
||||
})(({ addSumSeries, data, options = {}, intl }) => {
|
||||
const stats = data.stats.pifs
|
||||
@ -419,7 +419,7 @@ const ios = ['rx', 'tx']
|
||||
export const PoolPifLineChart = injectIntl(
|
||||
propTypes({
|
||||
addSumSeries: propTypes.bool,
|
||||
data: propTypes.object.isRequired,
|
||||
data: propTypes.array.isRequired,
|
||||
options: propTypes.object,
|
||||
})(({ addSumSeries, data, options = {}, intl }) => {
|
||||
const firstHostData = data[0]
|
||||
@ -508,7 +508,7 @@ export const LoadLineChart = injectIntl(
|
||||
export const PoolLoadLineChart = injectIntl(
|
||||
propTypes({
|
||||
addSumSeries: propTypes.bool,
|
||||
data: propTypes.object.isRequired,
|
||||
data: propTypes.array.isRequired,
|
||||
options: propTypes.object,
|
||||
})(({ addSumSeries, data, options = {}, intl }) => {
|
||||
const firstHostData = data[0]
|
||||
|
@ -226,11 +226,13 @@ export default class Overview extends Component {
|
||||
collection={schedules}
|
||||
emptyMessage={_('noScheduledJobs')}
|
||||
>
|
||||
{() => (
|
||||
<SortedTable
|
||||
columns={JOB_COLUMNS}
|
||||
collection={this._getScheduleCollection()}
|
||||
userData={isScheduleUserMissing}
|
||||
/>
|
||||
)}
|
||||
</NoObjects>
|
||||
</CardBlock>
|
||||
</Card>
|
||||
|
@ -461,6 +461,7 @@ export default class Health extends Component {
|
||||
collection={props.areObjectsFetched ? props.userSrs : null}
|
||||
emptyMessage={_('noSrs')}
|
||||
>
|
||||
{() => (
|
||||
<Row>
|
||||
<Col>
|
||||
<SortedTable
|
||||
@ -471,6 +472,7 @@ export default class Health extends Component {
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
)}
|
||||
</NoObjects>
|
||||
</CardBlock>
|
||||
</Card>
|
||||
@ -489,6 +491,7 @@ export default class Health extends Component {
|
||||
}
|
||||
emptyMessage={_('noOrphanedObject')}
|
||||
>
|
||||
{() => (
|
||||
<div>
|
||||
<Row>
|
||||
<Col className='text-xs-right'>
|
||||
@ -509,6 +512,7 @@ export default class Health extends Component {
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
)}
|
||||
</NoObjects>
|
||||
</CardBlock>
|
||||
</Card>
|
||||
@ -525,13 +529,10 @@ export default class Health extends Component {
|
||||
collection={
|
||||
props.areObjectsFetched ? props.controlDomainVdis : null
|
||||
}
|
||||
emptyMessage={_('noControlDomainVdis')}
|
||||
>
|
||||
<SortedTable
|
||||
collection={props.controlDomainVdis}
|
||||
columns={CONTROL_DOMAIN_VDI_COLUMNS}
|
||||
component={SortedTable}
|
||||
emptyMessage={_('noControlDomainVdis')}
|
||||
/>
|
||||
</NoObjects>
|
||||
</CardBlock>
|
||||
</Card>
|
||||
</Col>
|
||||
@ -545,14 +546,11 @@ export default class Health extends Component {
|
||||
<CardBlock>
|
||||
<NoObjects
|
||||
collection={props.areObjectsFetched ? props.vmOrphaned : null}
|
||||
emptyMessage={_('noOrphanedObject')}
|
||||
>
|
||||
<SortedTable
|
||||
collection={props.vmOrphaned}
|
||||
columns={VM_COLUMNS}
|
||||
component={SortedTable}
|
||||
emptyMessage={_('noOrphanedObject')}
|
||||
shortcutsTarget='.orphaned-vms'
|
||||
/>
|
||||
</NoObjects>
|
||||
</CardBlock>
|
||||
</Card>
|
||||
</Col>
|
||||
@ -570,6 +568,7 @@ export default class Health extends Component {
|
||||
}
|
||||
emptyMessage={_('noAlarms')}
|
||||
>
|
||||
{() => (
|
||||
<div>
|
||||
<Row>
|
||||
<Col className='text-xs-right'>
|
||||
@ -590,6 +589,7 @@ export default class Health extends Component {
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
)}
|
||||
</NoObjects>
|
||||
</CardBlock>
|
||||
</Card>
|
||||
|
@ -1083,7 +1083,9 @@ export default class Home extends Component {
|
||||
map(visibleItems, (item, index) => (
|
||||
<div
|
||||
key={item.id}
|
||||
className={highlighted === index && styles.highlight}
|
||||
className={
|
||||
highlighted === index ? styles.highlight : undefined
|
||||
}
|
||||
>
|
||||
<Item
|
||||
expandAll={expandAll}
|
||||
|
@ -17,14 +17,14 @@ import {
|
||||
import { FormattedRelative, FormattedTime } from 'react-intl'
|
||||
import { Container, Row, Col } from 'grid'
|
||||
import { createGetObjectsOfType, createSelector } from 'selectors'
|
||||
import { map } from 'lodash'
|
||||
import { map, noop } from 'lodash'
|
||||
|
||||
const ALLOW_INSTALL_SUPP_PACK = process.env.XOA_PLAN > 1
|
||||
|
||||
const forceReboot = host => restartHost(host, true)
|
||||
|
||||
const formatPack = ({ name, author, description, version }) => (
|
||||
<tr>
|
||||
const formatPack = ({ name, author, description, version }, key) => (
|
||||
<tr key={key}>
|
||||
<th>{_('supplementalPackTitle', { author, name })}</th>
|
||||
<td>{description}</td>
|
||||
<td>{version}</td>
|
||||
@ -116,7 +116,11 @@ export default connectStore(() => {
|
||||
<tr>
|
||||
<th>{_('hostPowerOnMode')}</th>
|
||||
<td>
|
||||
<Toggle value={host.powerOnMode} disabled />
|
||||
<Toggle
|
||||
disabled
|
||||
onChange={noop}
|
||||
value={Boolean(host.powerOnMode)}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -413,13 +413,13 @@ export default class LogList extends Component {
|
||||
</span>
|
||||
</CardHeader>
|
||||
<CardBlock>
|
||||
<NoObjects collection={logs} emptyMessage={_('noLogs')}>
|
||||
<SortedTable
|
||||
<NoObjects
|
||||
collection={logs}
|
||||
columns={LOG_COLUMNS}
|
||||
component={SortedTable}
|
||||
emptyMessage={_('noLogs')}
|
||||
filters={this.filters}
|
||||
/>
|
||||
</NoObjects>
|
||||
</CardBlock>
|
||||
</Card>
|
||||
)
|
||||
|
@ -76,7 +76,9 @@ export default connectStore({
|
||||
<Col size={9}>
|
||||
<ul className='list-group'>
|
||||
{map(gpuGroups, gpuGroup => (
|
||||
<li className='list-group-item'>{renderXoItem(gpuGroup)}</li>
|
||||
<li key={gpuGroup.id} className='list-group-item'>
|
||||
{renderXoItem(gpuGroup)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Col>
|
||||
|
@ -834,8 +834,11 @@ export default class Self extends Component {
|
||||
</ActionButton>
|
||||
</div>
|
||||
{showNewResourceSetForm && [
|
||||
<Edit onSave={this.toggleState('showNewResourceSetForm')} />,
|
||||
<hr />,
|
||||
<Edit
|
||||
key={0}
|
||||
onSave={this.toggleState('showNewResourceSetForm')}
|
||||
/>,
|
||||
<hr key={1} />,
|
||||
]}
|
||||
{resourceSets
|
||||
? isEmpty(resourceSets)
|
||||
|
@ -161,6 +161,7 @@ export default class Logs extends BaseComponent {
|
||||
message={_('noLogs')}
|
||||
predicate={this._getPredicate}
|
||||
>
|
||||
{() => (
|
||||
<div>
|
||||
<span className='pull-right'>
|
||||
<TabButton
|
||||
@ -176,6 +177,7 @@ export default class Logs extends BaseComponent {
|
||||
userData={this._getData()}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</NoObjects>
|
||||
)
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ const COLUMNS = [
|
||||
{
|
||||
itemRenderer: server => (
|
||||
<Toggle
|
||||
value={server.allowUnauthorized}
|
||||
value={Boolean(server.allowUnauthorized)}
|
||||
onChange={allowUnauthorized =>
|
||||
editServer(server, { allowUnauthorized })
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ export default class Tasks extends Component {
|
||||
props.pools,
|
||||
pool =>
|
||||
this._showPoolTasks(pool) && (
|
||||
<Row>
|
||||
<Row key={pool.id}>
|
||||
<Card>
|
||||
<CardHeader key={pool.id}>
|
||||
<Link to={`/pools/${pool.id}`}>{pool.name_label}</Link>
|
||||
|
@ -209,26 +209,28 @@ class CoresPerSocket extends Component {
|
||||
onChange={this._onChange}
|
||||
value={selectedCoresPerSocket || ''}
|
||||
>
|
||||
{_('vmChooseCoresPerSocket', message => (
|
||||
<option key='none' value=''>
|
||||
{message}
|
||||
</option>
|
||||
{_({ key: 'none' }, 'vmChooseCoresPerSocket', message => (
|
||||
<option value=''>{message}</option>
|
||||
))}
|
||||
{this._selectedValueIsNotInOptions() &&
|
||||
_('vmCoresPerSocketIncorrectValue', message => (
|
||||
<option key='incorrect' value={selectedCoresPerSocket}>
|
||||
{' '}
|
||||
{message}
|
||||
</option>
|
||||
))}
|
||||
{map(options, coresPerSocket => (
|
||||
<option key={coresPerSocket} value={coresPerSocket}>
|
||||
{_('vmCoresPerSocket', {
|
||||
_(
|
||||
{ key: 'incorrect' },
|
||||
'vmCoresPerSocketIncorrectValue',
|
||||
message => (
|
||||
<option value={selectedCoresPerSocket}> {message}</option>
|
||||
)
|
||||
)}
|
||||
{map(options, coresPerSocket =>
|
||||
_(
|
||||
{ key: coresPerSocket },
|
||||
'vmCoresPerSocket',
|
||||
{
|
||||
nSockets: vm.CPUs.number / coresPerSocket,
|
||||
nCores: coresPerSocket,
|
||||
})}
|
||||
</option>
|
||||
))}
|
||||
},
|
||||
message => <option value={coresPerSocket}>{message}</option>
|
||||
)
|
||||
)}
|
||||
</select>{' '}
|
||||
{this._selectedValueIsNotInOptions() && (
|
||||
<Tooltip content={_('vmCoresPerSocketIncorrectValueSolution')}>
|
||||
@ -398,7 +400,7 @@ export default connectStore(() => {
|
||||
<th>{_('autoPowerOn')}</th>
|
||||
<td>
|
||||
<Toggle
|
||||
value={vm.auto_poweron}
|
||||
value={Boolean(vm.auto_poweron)}
|
||||
onChange={value => editVm(vm, { auto_poweron: value })}
|
||||
/>
|
||||
</td>
|
||||
|
Loading…
Reference in New Issue
Block a user