Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajaa-BARHTAOUI committed Feb 23, 2022
1 parent e038335 commit c643d5d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ const messages = {
metricsLoading: 'Loading…',

// ----- Health -----
length: 'Length {length}',
length: 'Length: {length}',
deleteBackups: 'Delete backup{nBackups, plural, one {} other {s}}',
deleteBackupsMessage:
'Are you sure you want to delete {nBackups, number} backup{nBackups, plural, one {} other {s}}?',
Expand Down
35 changes: 19 additions & 16 deletions packages/xo-web/src/xo-app/dashboard/health/vdisToCoalesce.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from 'intl'
import decorate from 'apply-decorators'
import Icon from 'icon'
import React from 'react'
import SingleLineRow from 'single-line-row'
import SortedTable from 'sorted-table'
import Tooltip from 'tooltip'
import { Card, CardHeader, CardBlock } from 'card'
Expand All @@ -13,18 +14,18 @@ import { Sr, Vdi } from 'render-xo-item'

const VDIS_TO_COALESCE_LIMIT = 10

const UNHEALTHY_VDI_CHAINS = [
const COLUMNS = [
{
itemRenderer: (srId, { unhealthyVdiChainsLengthBySr }) => (
<div>
<Sr id={srId} link />{' '}
{size(unhealthyVdiChainsLengthBySr[srId]) >= VDIS_TO_COALESCE_LIMIT && (
<Tooltip content={_('srVdisToCoalesceWarning', { limitVdis: VDIS_TO_COALESCE_LIMIT })}>
<span className='text-warning'>
<Icon icon='alarm' />{' '}
<Icon icon='alarm' />
</span>
</Tooltip>
)}
<Sr id={srId} link />
</div>
),
name: _('sr'),
Expand All @@ -34,14 +35,14 @@ const UNHEALTHY_VDI_CHAINS = [
itemRenderer: (srId, { unhealthyVdiChainsLengthBySr }) => (
<div>
{map(unhealthyVdiChainsLengthBySr[srId], (chainLength, vdiId) => (
<Row key={vdiId}>
<SingleLineRow key={vdiId}>
<Col>
<Vdi id={vdiId} />
</Col>
<Col>
<span>{_('length', { length: chainLength })}</span>
</Col>
</Row>
</SingleLineRow>
))}
</div>
),
Expand All @@ -51,32 +52,33 @@ const UNHEALTHY_VDI_CHAINS = [

const VdisToCoalesce = decorate([
provideState({
initialize({ fetchUnhealthyVdiChainsLength }) {
return fetchUnhealthyVdiChainsLength(this.props.srs.map(({ id }) => id))
},
initialState: () => ({
unhealthyVdiChainsLengthBySr: {},
}),
effects: {
initialState: () => ({
unhealthyVdiChainsLengthBySr: {},
}),
async fetchUnhealthyVdiChainsLength(effects, srs) {
initialize({ fetchUnhealthyVdiChainsLength }) {
return fetchUnhealthyVdiChainsLength(map(this.props.srs, 'id'))
},
async fetchUnhealthyVdiChainsLength(effects, srIds) {
const unhealthyVdiChainsLengthBySr = { ...this.state.unhealthyVdiChainsLengthBySr }
await Promise.all(
srs.map(async srId => {
srIds.map(async srId => {
const unhealthyVdiChainsLength = await getUnhealthyVdiChainsLength(srId)
if (size(unhealthyVdiChainsLength) > 0) {
unhealthyVdiChainsLengthBySr[srId] = unhealthyVdiChainsLength
}
})
)

this.state.unhealthyVdiChainsLengthBySr = unhealthyVdiChainsLengthBySr
},
},
computed: {
srIds: ({ unhealthyVdiChainsLengthBySr }) => Object.keys(unhealthyVdiChainsLengthBySr),
srIds: ({ unhealthyVdiChainsLengthBySr = {} }) => Object.keys(unhealthyVdiChainsLengthBySr),
},
}),
injectState,
({ state: { srIds, unhealthyVdiChainsLengthBySr } }) => (
({ state: { srIds, unhealthyVdiChainsLengthBySr }, srs }) => (
<Row>
<Col>
<Card>
Expand All @@ -89,7 +91,8 @@ const VdisToCoalesce = decorate([
<SortedTable
data-unhealthyVdiChainsLengthBySr={unhealthyVdiChainsLengthBySr}
collection={srIds}
columns={UNHEALTHY_VDI_CHAINS}
columns={COLUMNS}
stateUrlParam='s_vdis_to_coalesce'
/>
</Col>
</Row>
Expand Down

0 comments on commit c643d5d

Please sign in to comment.