Skip to content

Commit

Permalink
fix: Fix issues
Browse files Browse the repository at this point in the history
1. service actions callback
2. fix pods link
  • Loading branch information
leoliu committed Jun 14, 2020
1 parent 13f500c commit c256291
Show file tree
Hide file tree
Showing 21 changed files with 62 additions and 52 deletions.
6 changes: 4 additions & 2 deletions src/actions/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ export default {
},
},
'service.edit': {
on({ store, detail, ...props }) {
on({ store, detail, success, ...props }) {
const modal = Modal.open({
onOk: newObject => {
store.update(detail, newObject).then(() => {
Modal.close(modal)
Notify.success({ content: `${t('Updated Successfully')}!` })
success && success()
})
},
modal: EditServiceModal,
Expand All @@ -118,12 +119,13 @@ export default {
},
},
'service.gateway.edit': {
on({ store, detail, ...props }) {
on({ store, detail, success, ...props }) {
const modal = Modal.open({
onOk: newObject => {
store.update(detail, newObject).then(() => {
Modal.close(modal)
Notify.success({ content: `${t('Updated Successfully')}!` })
success && success()
})
},
modal: EditGatewayModal,
Expand Down
9 changes: 6 additions & 3 deletions src/components/Cards/Monitoring/Controller/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,14 @@ export default class MonitoringController extends React.Component {

fetchData = (params = {}) => {
const { cluster } = this.state
this.props.onFetch({
const query = {
...this.params,
...params,
cluster,
})
}
if (cluster) {
query.cluster = cluster
}
this.props.onFetch(query)
}

handleChange = data => {
Expand Down
17 changes: 10 additions & 7 deletions src/components/Cards/Pods/index.jsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/components/Forms/Route/RouteRules/RuleList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ export default class RuleList extends React.Component {
}

renderContent() {
const { value, isFederated, projectDetail } = this.props
const clusters = keyBy(projectDetail.clusters, 'name')
const { value, isFederated } = this.props

let rules = [...value]
let tls = get(this.context.formData, 'spec.tls[0]')

if (isFederated) {
const { projectDetail } = this.props
const clusters = keyBy(projectDetail.clusters, 'name')
const result = ObjectMapper.federated(ObjectMapper.ingresses)(
this.context.formData
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Forms/Route/RouteRules/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class RouteRules extends React.Component {
get services() {
return this.serviceStore.list.data.map(item => ({
...item,
ports: item.resource.ports,
ports: item.resource ? item.resource.ports : item.ports,
}))
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Forms/Workload/ContainerSettings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class ContainerSetting extends React.Component {
this.imageRegistryStore.fetchListByK8s({
cluster,
namespace,
fieldSelector: `spec.template.type=kubernetes.io/dockerconfigjson`,
fieldSelector: `type=kubernetes.io/dockerconfigjson`,
}),
]).then(([configMaps, secrets, quota, limitRanges, imageRegistries]) => {
this.setState({
Expand Down
6 changes: 5 additions & 1 deletion src/components/HOCs/withList.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ export class ListPage extends React.Component {
const kind = MODULE_KIND_MAP[this.props.module]
if (message.object.kind === kind) {
if (message.type === 'MODIFIED') {
this.store.list.updateItem(this.store.mapper(message.object))
const data = {
...this.props.match.params,
...this.store.mapper(message.object),
}
this.store.list.updateItem(data)
} else if (message.type === 'DELETED' || message.type === 'ADDED') {
_getData()
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class GlobalValue {
const defaultActions = get(
globals.user,
`projectRules[${cluster}][${project}]._`,
[]
this.getActions({ cluster, module })
)
return adapter(
get(
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ export default {
CLUSTER_VISIBILITY_Q2: 'What is a public cluster?',
CLUSTER_VISIBILITY_A2:
'A public cluster means all platform users can access the cluster, in which they are able to create and schedule resources.',

CLUSTER_AGENT_TITLE:
'Please add the cluster based on the Agent provided in the cluster.',
CLUSTER_AGENT_DESC: 'A corresponding Agent needs to be set in the cluster.',
}
3 changes: 3 additions & 0 deletions src/locales/zh/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,7 @@ export default {
'KubeSphere 控制平面通过代理方式连接待导入集群,控制平面启动一个公开的代理服务,待导入集群创建相应的客户端组件连接代理服务,与控制平面之间建立一个反向代理。此种方式不需要待导入集群和控制平面在同一网络,也不要求待导入集群暴露集群的 apiserver 地址,但会有一定的网络性能损耗</br></br>通常适用于:</br>1. 当前集群和待导入集群不在同一网络中<br/>2. 当前集群和待导入集群无法通过vpn或隧道等其它技术连通所在网络<br/>3. 对集群间网络性能损耗能容忍',

HOW_TO_GET_KUBECONFIG: '如何获取KubeConfig?',

CLUSTER_AGENT_TITLE: '请根据集群中提供的代理连接设置加入集群',
CLUSTER_AGENT_DESC: '需要在集群中设置下相应的代理Agent',
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ export default class BaseInfo extends React.Component {
) : (
<div className={styles.tip}>
<Text
title={t('请根据集群中提供的代理连接设置加入集群')}
description={t('需要在集群中设置下相应的代理Agent')}
title={t('CLUSTER_AGENT_TITLE')}
description={t('CLUSTER_AGENT_DESC')}
/>
<div className="margin-t12">
{t.html('CLUSTER_AGENT_IMPORT_TIP')}
Expand Down
13 changes: 8 additions & 5 deletions src/pages/clusters/containers/Projects/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,21 @@ export default class ProjectDetail extends React.Component {
}

getOperations = () => {
const { workspace, cluster, name } = this.store.detail
const { workspace, cluster, name, isFedManaged } = this.store.detail

let url = `/${workspace}/clusters/${cluster}/projects/${name}`
if (isFedManaged) {
url = `/${workspace}/federatedprojects/${name}`
}

return [
{
key: 'enter',
text: t('Enter the project'),
action: 'view',
type: 'control',
show: globals.app.workspaces.includes(workspace),
onClick: () =>
this.routing.push(
`/${workspace}/clusters/${cluster}/projects/${name}`
),
onClick: () => this.routing.push(url),
},
{
key: 'edit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class ResourceStatus extends React.Component {
detail={detail}
clusters={clusters}
onUpdate={this.handlePodUpdate}
isFederated
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default class ResourceStatus extends React.Component {
clusters={clusters}
onUpdate={this.handlePodUpdate}
isLoading={isResourcesLoading}
isFederated
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,13 @@ export default class RuleList extends React.Component {
}

renderContent() {
const {
data,
onAdd,
onDelete,
isFederated,
projectDetail,
gateway,
} = this.props
const clusters = keyBy(projectDetail.clusters, 'name')
const { data, onAdd, onDelete, isFederated, gateway } = this.props
let rules = get(data, 'spec.rules', [])
let tls = get(data, 'spec.tls[0]', {})

if (isFederated) {
const { projectDetail } = this.props
const clusters = keyBy(projectDetail.clusters, 'name')
const result = ObjectMapper.federated(ObjectMapper.ingresses)(data)
if (result && result.clusterTemplates) {
rules = Object.keys(result.clusterTemplates).map(cluster => ({
Expand Down
11 changes: 0 additions & 11 deletions src/pages/projects/containers/CronJobs/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,6 @@ export default class JobDetail extends React.Component {
detail: this.store.detail,
}),
},
{
key: 'redeploy',
icon: 'restart',
text: t('Redeploy'),
action: 'edit',
onClick: () =>
this.trigger('workload.redeploy', {
module: this.module,
detail: this.store.detail,
}),
},
{
key: 'delete',
icon: 'trash',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/projects/containers/Jobs/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default class JobDetail extends React.Component {
onClick: () =>
this.trigger('resource.yaml.edit', {
detail: this.store.detail,
readonly: true,
readOnly: true,
}),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Card = ({ gateway, rule, tls = {}, prefix }) => {
<Icon name="earth" size={40} />
<div className={styles.title}>
{host}
<p>
<div>
<span>
{t('Protocol')}: {protocol}
</span>
Expand All @@ -61,7 +61,7 @@ const Card = ({ gateway, rule, tls = {}, prefix }) => {
<Icon name="question" />
</Tooltip>
</span>
</p>
</div>
</div>
</div>
{rule.http.paths.map(path => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
color: $text-color;
vertical-align: middle;

p {
& > div {
font-size: $body-size;
color: #79879c;
font-weight: $font-normal;
Expand Down
6 changes: 3 additions & 3 deletions src/pages/projects/containers/Routes/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class RouteDetail extends React.Component {
action: 'edit',
onClick: () =>
this.trigger('resource.yaml.edit', {
detail: this.store.detail,
detail: toJS(this.store.detail),
success: this.fetchData,
}),
},
Expand All @@ -97,7 +97,7 @@ export default class RouteDetail extends React.Component {
action: 'edit',
onClick: () =>
this.trigger('router.rules.edit', {
detail: this.store.detail,
detail: toJS(this.store.detail),
success: this.fetchData,
}),
},
Expand All @@ -108,7 +108,7 @@ export default class RouteDetail extends React.Component {
action: 'edit',
onClick: () =>
this.trigger('router.annotations.edit', {
detail: this.store.detail,
detail: toJS(this.store.detail),
success: this.fetchData,
}),
},
Expand Down
2 changes: 2 additions & 0 deletions src/pages/projects/containers/Services/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default class ServiceDetail extends React.Component {
onClick: () =>
this.trigger('service.edit', {
detail: this.store.detail,
success: this.fetchData,
}),
},
{
Expand All @@ -107,6 +108,7 @@ export default class ServiceDetail extends React.Component {
onClick: () =>
this.trigger('service.gateway.edit', {
detail: this.store.detail,
success: this.fetchData,
}),
},
{
Expand Down

0 comments on commit c256291

Please sign in to comment.