Skip to content

Commit

Permalink
fix: Fix multi-cluster projects in project select modal
Browse files Browse the repository at this point in the history
Signed-off-by: leoliu <leoliu@yunify.com>
  • Loading branch information
leoliu committed Jul 27, 2020
1 parent 099e0e4 commit 1474a2c
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/components/Modals/ProjectSelect/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Button, Modal, Search, RadioGroup, ScrollLoad } from 'components/Base'

import WorkspaceStore from 'stores/workspace'
import ProjectStore from 'stores/project'
import FederatedStore from 'stores/federated'
import FederatedStore from 'stores/project.federated'
import DevOpsStore from 'stores/devops'

import Card from './Card'
Expand Down Expand Up @@ -91,29 +91,21 @@ export default class ProjectSelectModal extends React.Component {
}

get types() {
const types = []
if (this.enabledActions.projects.includes('view')) {
types.push({
const types = [
{
label: t('Projects'),
value: 'projects',
})
}
},
]

if (
globals.app.isMultiCluster &&
this.enabledActions.federatedprojects.includes('view')
) {
if (globals.app.isMultiCluster) {
types.push({
label: t('Multi-cluster Projects'),
value: 'federatedprojects',
})
}

// TODO: ADD CLUSTER
if (
this.enabledActions.devops.includes('view') &&
globals.app.hasKSModule('devops')
) {
if (globals.app.hasKSModule('devops')) {
types.push({
label: t('DevOps Projects'),
value: 'devops',
Expand All @@ -130,14 +122,19 @@ export default class ProjectSelectModal extends React.Component {
fetchData = query => {
const { workspace } = this.props
const { cluster, search } = this.state
const params = { cluster, workspace, name: search, ...query }
const params = { workspace, ...query }

if (this.state.type === 'federatedprojects') {
params.labelSelector = `kubesphere.io/workspace=${workspace}`
} else {
params.cluster = cluster
params.labelSelector = 'kubefed.io/managed!=true'
}

if (search) {
params.name = search
}

this.stores[this.state.type].fetchList(params)
}

Expand Down

0 comments on commit 1474a2c

Please sign in to comment.