Skip to content

Commit

Permalink
fix: Fix federated workload edit permission
Browse files Browse the repository at this point in the history
Signed-off-by: leoliu <leoliu@yunify.com>
  • Loading branch information
leoliu committed Aug 14, 2020
1 parent 03c063a commit 77a8f2d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
36 changes: 19 additions & 17 deletions src/pages/fedprojects/components/ClusterWorkloadStatus/Cluster.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default class Cluster extends Component {
}

render() {
const { cluster, workload = {}, store } = this.props
const { cluster, workload = {}, store, onReplicasChange } = this.props
const { replicas } = this.state
const { podNums = 0, readyPodNums = 0 } = workload
const unReadyNums = podNums - readyPodNums
Expand Down Expand Up @@ -151,22 +151,24 @@ export default class Cluster extends Component {
/>
)}
</div>
<div className={styles.control}>
<Icon
name="add"
type="light"
size={24}
clickable
onClick={this.handleAdd}
/>
<Icon
name="substract"
type="light"
size={24}
clickable
onClick={this.handleSubStract}
/>
</div>
{onReplicasChange && (
<div className={styles.control}>
<Icon
name="add"
type="light"
size={24}
clickable
onClick={this.handleAdd}
/>
<Icon
name="substract"
type="light"
size={24}
clickable
onClick={this.handleSubStract}
/>
</div>
)}
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class ClusterWorkloadStatus extends Component {
}

render() {
const { store, resources, clusters, clustersDetail } = this.props
const { store, resources, clusters, clustersDetail, canEdit } = this.props

if (!clusters) {
return null
Expand All @@ -80,8 +80,7 @@ export default class ClusterWorkloadStatus extends Component {
key={cluster.name}
cluster={clustersDetail[cluster.name]}
workload={resources[cluster.name]}
onReplicasChange={this.handleReplicasChange}
onEdit={this.handleEdit}
onReplicasChange={canEdit ? this.handleReplicasChange : null}
store={store}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ResourceStatus extends React.Component {
clustersDetail={clustersDetail}
clusters={detail.clusters}
isLoading={isResourcesLoading}
canEdit={this.enabledActions.includes('edit')}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ export default class ResourceStatus extends React.Component {
this.fetchData()
}

get enabledActions() {
return globals.app.getActions({
module: this.store.module,
project: this.props.match.params.namespace,
})
}

get prefix() {
const { workspace } = this.props.match.params
return workspace ? `/${workspace}` : ''
Expand Down Expand Up @@ -95,6 +102,7 @@ export default class ResourceStatus extends React.Component {
clusters={clusters}
clustersDetail={clustersDetail}
isLoading={isResourcesLoading}
canEdit={this.enabledActions.includes('edit')}
/>
)
}
Expand Down

0 comments on commit 77a8f2d

Please sign in to comment.