Skip to content

Commit

Permalink
fix: Fix workspace nav with ks module
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Jun 28, 2020
1 parent ace561d commit 4b3b683
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
3 changes: 1 addition & 2 deletions server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ client:
name: devops,
title: DevOps Projects,
icon: strategy-group,
# only work on single cluster mode.
singleClusterModule: devops,
ksModule: devops,
}
- name: apps
title: Apps Management
Expand Down
4 changes: 0 additions & 4 deletions src/core/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ export default class GlobalValue {
return false
}

if (item.singleClusterModule && !globals.app.isMultiCluster) {
item.clusterModule = item.singleClusterModule
}

if (
item.clusterModule &&
!this.hasClusterModule(item.cluster, item.clusterModule)
Expand Down
9 changes: 9 additions & 0 deletions src/pages/workspaces/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import React, { Component } from 'react'
import { inject, observer, Provider } from 'mobx-react'
import { get, set } from 'lodash'
import { Loading } from '@pitrix/lego-ui'

import { renderRoutes } from 'utils/router.config'
Expand Down Expand Up @@ -52,6 +53,14 @@ class WorkspaceLayout extends Component {
this.props.rootStore.getRules(params),
])

if (globals.app.isMultiCluster) {
set(
globals.ksConfig,
'devops',
this.store.clusters.data.some(cluster => get(cluster, 'configz.devops'))
)
}

globals.app.cacheHistory(this.props.match.url, {
type: 'Workspace',
name: this.store.detail.name,
Expand Down
13 changes: 9 additions & 4 deletions src/pages/workspaces/containers/Projects/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ export default class Projects extends React.Component {
}
}

get showFederated() {
const { workspace } = this.props.match.params
return (
globals.app.isMultiCluster &&
globals.app.hasPermission({ workspace, module: 'federatedprojects' })
)
}

@computed
get clusters() {
return this.workspaceStore.clusters.data.map(item => ({
Expand Down Expand Up @@ -214,10 +222,7 @@ export default class Projects extends React.Component {
getData={this.getData}
module="namespaces"
>
<Banner
{...bannerProps}
tabs={globals.app.isMultiCluster ? this.tabs : {}}
/>
<Banner {...bannerProps} tabs={this.showFederated ? this.tabs : {}} />
<Table
{...tableProps}
itemActions={this.itemActions}
Expand Down

0 comments on commit 4b3b683

Please sign in to comment.