fix(xo-web/xosan): install packs button condition (#2950)

This commit is contained in:
Pierre Donias 2018-05-15 17:40:40 +02:00 committed by Julien Fontanet
parent 2b95eb4e4d
commit ecc62e4f54
2 changed files with 8 additions and 14 deletions

View File

@ -4,12 +4,7 @@ import Component from 'base-component'
import { createGetObjectsOfType, createSelector } from 'selectors'
import { map } from 'lodash'
import { subscribeResourceCatalog } from 'xo'
import {
addSubscriptions,
isLatestXosanPackInstalled,
connectStore,
findLatestPack,
} from 'utils'
import { isLatestXosanPackInstalled, connectStore, findLatestPack } from 'utils'
@connectStore(
{
@ -19,20 +14,19 @@ import {
},
{ withRef: true }
)
@addSubscriptions(() => ({
catalog: subscribeResourceCatalog,
}))
export default class UpdateXosanPacksModal extends Component {
state = {
status: 'checking',
componentDidMount () {
this.componentWillUnmount = subscribeResourceCatalog(catalog =>
this.setState({ catalog })
)
}
get value () {
return this.state.pack
return this._getStatus().pack
}
_getStatus = createSelector(
() => this.props.catalog,
() => this.state.catalog,
() => this.props.hosts,
(catalog, hosts) => {
if (catalog === undefined) {

View File

@ -92,7 +92,7 @@ export default class NewXosan extends Component {
const hosts = filter(this.props.hosts, { $pool: pool.id })
const pack = findLatestPack(catalog.xosan, map(hosts, 'version'))
if (isLatestXosanPackInstalled(pack, hosts)) {
if (!isLatestXosanPackInstalled(pack, hosts)) {
this.setState({
needsUpdate: true,
})