feat(xo-web/health/alarms): use SortedTable actions (#3271)

See #3179
This commit is contained in:
Rajaa.BARHTAOUI 2018-08-07 17:20:59 +02:00 committed by Pierre Donias
parent 4c20e89a8b
commit eea52b5166
2 changed files with 16 additions and 46 deletions

View File

@ -9,6 +9,7 @@
- Move the copy clipboard of the VM's UUID to the header [#3221](https://github.com/vatesfr/xen-orchestra/issues/3221) (PR [#3248](https://github.com/vatesfr/xen-orchestra/pull/3248)) - Move the copy clipboard of the VM's UUID to the header [#3221](https://github.com/vatesfr/xen-orchestra/issues/3221) (PR [#3248](https://github.com/vatesfr/xen-orchestra/pull/3248))
- [Health / Orphaned VMs] Homogenize action buttons in table and enable bulk deletion [#3179](https://github.com/vatesfr/xen-orchestra/issues/3179) (PR [#3274](https://github.com/vatesfr/xen-orchestra/pull/3274)) - [Health / Orphaned VMs] Homogenize action buttons in table and enable bulk deletion [#3179](https://github.com/vatesfr/xen-orchestra/issues/3179) (PR [#3274](https://github.com/vatesfr/xen-orchestra/pull/3274))
- [Health / Orphaned snapshot VDIs] Homogenize action buttons in table and enable bulk deletion [#3179](https://github.com/vatesfr/xen-orchestra/issues/3179) (PR [#3270](https://github.com/vatesfr/xen-orchestra/pull/3270)) - [Health / Orphaned snapshot VDIs] Homogenize action buttons in table and enable bulk deletion [#3179](https://github.com/vatesfr/xen-orchestra/issues/3179) (PR [#3270](https://github.com/vatesfr/xen-orchestra/pull/3270))
- [Health / Alarms] Homogenize action buttons in table and enable bulk deletion [#3179](https://github.com/vatesfr/xen-orchestra/issues/3179) (PR [#3271](https://github.com/vatesfr/xen-orchestra/pull/3271))
### Bug fixes ### Bug fixes

View File

@ -1,16 +1,13 @@
import _ from 'intl' import _ from 'intl'
import ActionRowButton from 'action-row-button'
import Component from 'base-component' import Component from 'base-component'
import Icon from 'icon' import Icon from 'icon'
import Link from 'link' import Link from 'link'
import NoObjects from 'no-objects' import NoObjects from 'no-objects'
import React from 'react' import React from 'react'
import SortedTable from 'sorted-table' import SortedTable from 'sorted-table'
import TabButton from 'tab-button'
import Tooltip from 'tooltip' import Tooltip from 'tooltip'
import Upgrade from 'xoa-upgrade' import Upgrade from 'xoa-upgrade'
import xml2js from 'xml2js' import xml2js from 'xml2js'
import { confirm } from 'modal'
import { SelectPool } from 'select-objects' import { SelectPool } from 'select-objects'
import { fromCallback } from 'promise-toolbox' import { fromCallback } from 'promise-toolbox'
import { Container, Row, Col } from 'grid' import { Container, Row, Col } from 'grid'
@ -20,6 +17,7 @@ import { flatten, get, includes, isEmpty, map, mapValues } from 'lodash'
import { connectStore, formatSize, noop, resolveIds } from 'utils' import { connectStore, formatSize, noop, resolveIds } from 'utils'
import { import {
deleteMessage, deleteMessage,
deleteMessages,
deleteOrphanedVdis, deleteOrphanedVdis,
deleteVbd, deleteVbd,
deleteVbds, deleteVbds,
@ -371,16 +369,16 @@ const ALARM_COLUMNS = [
name: _('alarmPool'), name: _('alarmPool'),
itemRenderer: message => <AlarmColPool id={message.$pool} />, itemRenderer: message => <AlarmColPool id={message.$pool} />,
}, },
]
const ALARM_ACTIONS = [
{ {
name: _('logAction'), handler: deleteMessages,
itemRenderer: message => ( individualHandler: deleteMessage,
<ActionRowButton individualLabel: _('logDelete'),
btnStyle='danger' icon: 'delete',
handler={deleteMessage} label: _('logsDelete'),
handlerParam={message} level: 'danger',
icon='delete'
/>
),
}, },
] ]
@ -455,20 +453,6 @@ export default class Health extends Component {
}, noop) }, noop)
} }
_deleteAllLogs = () =>
confirm({
title: _('removeAllLogsModalTitle'),
body: (
<div>
<p>{_('removeAllLogsModalWarning')}</p>
<p>{_('definitiveMessageModal')}</p>
</div>
),
}).then(
() => Promise.all(map(this.props.alertMessages, deleteMessage)),
noop
)
_getSrUrl = sr => `srs/${sr.id}` _getSrUrl = sr => `srs/${sr.id}`
_getPoolPredicate = createSelector( _getPoolPredicate = createSelector(
@ -609,26 +593,11 @@ export default class Health extends Component {
emptyMessage={_('noAlarms')} emptyMessage={_('noAlarms')}
> >
{() => ( {() => (
<div> <SortedTable
<Row> actions={ALARM_ACTIONS}
<Col className='text-xs-right'> collection={this._getMessages()}
<TabButton columns={ALARM_COLUMNS}
btnStyle='danger' />
handler={this._deleteAllLogs}
icon='delete'
labelId='logRemoveAll'
/>
</Col>
</Row>
<Row>
<Col>
<SortedTable
collection={this._getMessages()}
columns={ALARM_COLUMNS}
/>
</Col>
</Row>
</div>
)} )}
</NoObjects> </NoObjects>
</CardBlock> </CardBlock>