Skip to content

Commit

Permalink
fix: Fix federated svc resource status
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Jun 14, 2020
1 parent cdf1be9 commit 351ef4f
Showing 1 changed file with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import React from 'react'
import { observer, inject } from 'mobx-react'
import { get, keyBy } from 'lodash'
import { get, isEmpty, keyBy } from 'lodash'

import WorkloadStore from 'stores/workload'
import FedStore from 'stores/federated'
Expand All @@ -36,6 +36,11 @@ export default class ResourceStatus extends React.Component {

this.store = props.detailStore

this.workloadName = get(
this.store.detail.annotations,
'["kubesphere.io/workloadName"]'
)

const workloadModule = get(
this.store.detail.annotations,
'["kubesphere.io/workloadModule"]',
Expand All @@ -55,10 +60,7 @@ export default class ResourceStatus extends React.Component {

fetchData = async () => {
const { namespace } = this.props.match.params
const name = get(
this.store.detail.annotations,
'["kubesphere.io/workloadName"]'
)
const name = this.workloadName

const clusters = this.props.projectStore.detail.clusters.map(
item => item.name
Expand All @@ -83,15 +85,6 @@ export default class ResourceStatus extends React.Component {
}

renderReplicaInfo() {
const name = get(
this.store.detail.annotations,
'["kubesphere.io/workloadName"]'
)

if (!name) {
return null
}

const { detail, resources, isResourcesLoading } = this.workloadStore
const clusters = keyBy(this.props.projectStore.detail.clusters, 'name')

Expand All @@ -107,6 +100,26 @@ export default class ResourceStatus extends React.Component {
)
}

renderWorkloadPods() {
const { resources } = this.workloadStore
const clusters = Object.keys(resources)
const detail = Object.values(resources)[0]

if (isEmpty(clusters) || isEmpty(detail)) {
return null
}

return (
<PodsCard
prefix={this.prefix}
detail={detail}
clusters={clusters}
onUpdate={this.handlePodUpdate}
isFederated
/>
)
}

renderPods() {
const { resources, isResourcesLoading } = this.store

Expand All @@ -128,10 +141,14 @@ export default class ResourceStatus extends React.Component {
}

renderContent() {
if (!this.workloadName) {
return this.renderPods()
}

return (
<div>
{this.renderReplicaInfo()}
{this.renderPods()}
{this.renderWorkloadPods()}
</div>
)
}
Expand Down

0 comments on commit 351ef4f

Please sign in to comment.