Skip to content

Commit

Permalink
Merge pull request #482 from leoendless/hotfix/clusters
Browse files Browse the repository at this point in the history
fix: Fix some multi clusters issues.
  • Loading branch information
leoendless authored Jun 23, 2020
2 parents 14a46f4 + b5bcc43 commit 5c15e8b
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 13 deletions.
10 changes: 7 additions & 3 deletions src/actions/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ export default {
const modal = Modal.open({
onOk: async data => {
set(data, 'metadata.labels["kubesphere.io/workspace"]', workspace)
await store.create(data, { cluster, workspace })

const federatedStore = new FederatedStore(store)
const clusters = get(data, 'spec.placement.clusters', [])

if (clusters.length > 1) {
const federatedStore = new FederatedStore(store)
await store.create(data, { workspace })
await federatedStore.create(FED_TEMPLATES.namespaces(data), {
namespace: get(data, 'metadata.name'),
})
} else {
await store.create(data, {
cluster: get(clusters, '[0].name'),
workspace,
})
}

Modal.close(modal)
Expand Down
21 changes: 17 additions & 4 deletions src/components/Forms/Workload/VolumeSettings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { findVolume, isNotPersistentVolume } from 'utils/volume'
import { Alert, Form } from 'components/Base'
import VolumeStore from 'stores/volume'
import FederatedStore from 'stores/federated'
import ProjectStore from 'stores/project'

import VolumeList from './VolumeList'
import AddVolume from './AddVolume'
Expand All @@ -49,8 +50,13 @@ class VolumeSettings extends React.Component {

this.store = new VolumeStore()

this.projectStore = new ProjectStore()

if (props.isFederated) {
this.store = new FederatedStore(this.store)
this.projectStore = new FederatedStore({
module: this.projectStore.module,
})
}

this.store.fetchList({
Expand All @@ -64,6 +70,15 @@ class VolumeSettings extends React.Component {
this.handleLogToggle = this.handleLogToggle.bind(this)
}

componentDidMount() {
if (this.namespace) {
this.projectStore.fetchDetail({
namespace: this.namespace,
cluster: this.cluster,
})
}
}

get prefix() {
return this.props.prefix || 'spec.template.'
}
Expand Down Expand Up @@ -91,7 +106,7 @@ class VolumeSettings extends React.Component {
get projectEnableCollectingFileLog() {
return (
get(
this.props.projectDetail,
this.projectStore.detail,
'labels["logging.kubesphere.io/logsidecar-injection"]'
) === 'enabled'
)
Expand Down Expand Up @@ -463,9 +478,7 @@ class VolumeSettings extends React.Component {
renderToolTipContent() {
return (
<div>
<div className="tooltip-title">
{t('What is Disk Log Collection?')}
</div>
<div className="tooltip-title">{t('What is Disk Log Collection?')}</div>
<p>{t('COLLECT_FILE_LOG_TIP')}</p>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@
*/

import React, { Component } from 'react'
import { inject } from 'mobx-react'
import { Panel, Text } from 'components/Base'

import styles from './index.scss'

@inject('rootStore')
export default class ClusterInfo extends Component {
handleClick = () => {
const { cluster, rootStore } = this.props
rootStore.routing.push(`/clusters/${cluster.name}/visibility`)
}

render() {
const { cluster, version } = this.props
return (
Expand All @@ -32,6 +39,15 @@ export default class ClusterInfo extends Component {
title={cluster.kubernetesVersion || version}
description={t('Kubernetes Version')}
/>
<Text
title={
cluster.visibility === 'public'
? t('VISIBILITY_PUBLIC')
: t('VISIBILITY_PART')
}
description={t('Cluster Visibility')}
onClick={this.handleClick}
/>
</div>
</Panel>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ResourceStatus extends React.Component {
renderRules() {
const detail = toJS(this.store.detail)
const gateway = toJS(this.store.gateway.data)

const tls = detail.tls[0] || {}

if (isEmpty(detail.rules)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export default class ClusterSettings extends Component {
onChange(newValue)
}

handleCheckboxClick = e => {
e.stopPropagation()
}

render() {
const { value = [] } = this.props
const { data, isLoading } = toJS(this.clusterStore.list)
Expand All @@ -95,6 +99,7 @@ export default class ClusterSettings extends Component {
<Checkbox
checked={value.some(item => item.name === cluster.name)}
disabled={!globals.app.isMultiCluster}
onClick={this.handleCheckboxClick}
/>
<ClusterTitle
className={styles.cluster}
Expand Down
12 changes: 9 additions & 3 deletions src/pages/workspaces/components/ResourceTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ import ClusterSelect from './ClusterSelect'

class ResourceTable extends BaseTable {
renderNormalTitle() {
const { hideCustom, clusters, cluster, onClusterChange } = this.props
const {
hideCustom,
showClusterSelect,
clusters,
cluster,
onClusterChange,
} = this.props

return (
<Level>
{globals.app.isMultiCluster && (
{showClusterSelect && (
<LevelLeft>
<LevelItem>
<ClusterSelect
Expand Down Expand Up @@ -77,7 +83,7 @@ class ResourceTable extends BaseTable {

render() {
const { clusters } = this.props
if (globals.isMultiCluster && isEmpty(clusters)) {
if (globals.app.isMultiCluster && isEmpty(clusters)) {
return (
<EmptyList
icon="cluster"
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspaces/containers/DevOps/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default class DevOps extends React.Component {
clusters: this.clusters,
cluster: this.workspaceStore.cluster,
onClusterChange: this.handleClusterChange,
showClusterSelect: globals.app.isMultiCluster,
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/pages/workspaces/containers/FedProjects/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react'
import { computed } from 'mobx'
import { Avatar } from 'components/Base'
import Banner from 'components/Cards/Banner'
import Table from 'components/Tables/List'
import Table from 'workspaces/components/ResourceTable'
import withList, { ListPage } from 'components/HOCs/withList'
import ClusterWrapper from 'components/Clusters/ClusterWrapper'

Expand Down Expand Up @@ -149,6 +149,7 @@ export default class Projects extends React.Component {

render() {
const { bannerProps, tableProps } = this.props

return (
<ListPage {...this.props} getData={this.getData}>
<Banner
Expand All @@ -164,6 +165,7 @@ export default class Projects extends React.Component {
columns={this.getColumns()}
onCreate={this.showCreate}
searchType="name"
clusters={this.clusters}
/>
</ListPage>
)
Expand Down
2 changes: 2 additions & 0 deletions src/pages/workspaces/containers/Projects/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default class Projects extends React.Component {
clusters: this.clusters,
cluster: this.workspaceStore.cluster,
onClusterChange: this.handleClusterChange,
showClusterSelect: globals.app.isMultiCluster,
}
}

Expand All @@ -93,6 +94,7 @@ export default class Projects extends React.Component {
cluster: this.workspaceStore.cluster,
...this.props.match.params,
...params,
labelSelector: 'kubefed.io/managed!=true',
})
store.list.silent = false
}
Expand Down
4 changes: 2 additions & 2 deletions src/stores/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ const getTypeSelectParams = type => {

if (type === 'system') {
params = {
label: 'kubesphere.io/workspace=system-workspace',
labelSelector: 'kubesphere.io/workspace=system-workspace',
}
} else if (type === 'user') {
params = {
label: 'kubesphere.io/workspace!=system-workspace',
labelSelector: 'kubesphere.io/workspace!=system-workspace',
}
}
return params
Expand Down

0 comments on commit 5c15e8b

Please sign in to comment.