Skip to content

Commit

Permalink
fix: Fix devops page when devops not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Jun 16, 2020
1 parent 04ce3da commit b5dc731
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
8 changes: 7 additions & 1 deletion server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ client:
tabs:
- { name: projects, title: Projects }
- { name: federatedprojects, title: Multi-cluster Projects }
- { name: devops, title: DevOps Projects, icon: strategy-group }
- {
name: devops,
title: DevOps Projects,
icon: strategy-group,
# only work on single cluster mode.
singleClusterMoudle: devops,
}
- name: apps
title: Apps Management
icon: appcenter
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tables/Base/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class WorkloadTable extends React.Component {
selectActions: PropTypes.array,
extraProps: PropTypes.object,
alwaysUpdate: PropTypes.bool,
emptyText: PropTypes.oneOfType([PropTypes.string || PropTypes.func]),
emptyText: PropTypes.any,
}

static defaultProps = {
Expand Down
4 changes: 4 additions & 0 deletions src/core/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export default class GlobalValue {
return false
}

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

if (
item.clusterModule &&
!this.hasClusterModule(item.cluster, item.clusterModule)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspaces/components/ResourceTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ResourceTable extends BaseTable {

render() {
const { clusters } = this.props
if (isEmpty(clusters)) {
if (globals.isMultiCluster && isEmpty(clusters)) {
return (
<EmptyList
icon="cluster"
Expand Down
2 changes: 0 additions & 2 deletions src/pages/workspaces/containers/DevOps/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import Table from 'workspaces/components/ResourceTable'
import withList, { ListPage } from 'components/HOCs/withList'

import { getLocalTime } from 'utils'
import { get } from 'lodash'

import DevOpsStore from 'stores/devops'

Expand Down Expand Up @@ -92,7 +91,6 @@ export default class DevOps extends React.Component {
return this.workspaceStore.clusters.data.map(item => ({
label: item.name,
value: item.name,
disabled: !get(item, 'configz.devops', false),
}))
}

Expand Down
16 changes: 7 additions & 9 deletions src/stores/devops.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,12 @@ export default class DevOpsStore extends Base {
params.reverse = true
}

let result = {}

try {
result = await request.get(
this.getDevOpsUrl({ cluster, workspace }),
params
)
} catch {}
const result = await request.get(
this.getDevOpsUrl({ cluster, workspace }),
params,
null,
() => {}
)

const items = Array.isArray(get(result, 'items'))
? get(result, 'items')
Expand All @@ -152,7 +150,7 @@ export default class DevOpsStore extends Base {

this.list.update({
data,
total: result.total_count || data.length || 0,
total: get(result, 'total_count') || data.length || 0,
limit: Number(limit) || 10,
page: Number(page) || 1,
order,
Expand Down

0 comments on commit b5dc731

Please sign in to comment.