Skip to content

Commit

Permalink
fix: Fix federated application create and version
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Jul 10, 2020
1 parent 1d18e4b commit 2d0b7c7
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/locales/zh/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export default {
'Application Route': '应用路由',
'Traffic Management': '流量治理',

'No Components': '暂无组件',
'Cluster Select': '集群选择',

'Application governance is not enabled': '应用治理未启用',

'Build an app by services': '通过服务构建应用',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import React, { Component } from 'react'

import { keyBy } from 'lodash'
import { keyBy, isEmpty } from 'lodash'
import { inject, observer } from 'mobx-react'
import { joinSelector } from 'utils'
import { Loading } from '@pitrix/lego-ui'
Expand Down Expand Up @@ -59,9 +59,24 @@ export default class Components extends Component {
}
}

renderServices() {
const { data } = this.serviceStore.list
if (isEmpty(data)) {
return <div className={styles.empty}>{t('No Components')}</div>
}

return (
<div>
{data.map(item => (
<ServiceCard key={item.name} data={item} prefix={this.prefix} />
))}
</div>
)
}

render() {
const { cluster } = this.props
const { data, isLoading } = this.serviceStore.list
const { isLoading } = this.serviceStore.list
const clusters = keyBy(this.props.projectStore.detail.clusters, 'name')

return (
Expand All @@ -76,13 +91,7 @@ export default class Components extends Component {
</div>
</div>
<div className={styles.content}>
<Loading spinning={isLoading}>
<>
{data.map(item => (
<ServiceCard key={item.name} data={item} prefix={this.prefix} />
))}
</>
</Loading>
<Loading spinning={isLoading}>{this.renderServices()}</Loading>
</div>
</Panel>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import '~scss/variables';
@import '~scss/mixins';

.cluster {
position: relative;
Expand All @@ -14,3 +15,8 @@
padding: 12px;
background-color: $light-color01;
}


.empty {
@include TypographyTitleH5($light-color08);
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class AppDetail extends React.Component {
},
{
name: t('Version'),
value: detail.version,
value: get(detail, 'resource.version'),
},
{
name: t('Created Time'),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/fedprojects/containers/Applications/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default class CRDApps extends React.Component {
},
{
title: t('Version'),
dataIndex: 'version',
dataIndex: 'resource.version',
isHideable: true,
width: '20%',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react'
import { PropTypes } from 'prop-types'
import { Input, Select, TextArea } from '@pitrix/lego-ui'
import { PATTERN_NAME, PATTERN_LENGTH_63 } from 'utils/constants'
import { updateFederatedAnnotations } from 'utils'
import { updateFederatedAnnotations, generateId } from 'utils'
import { Form } from 'components/Base'

import styles from './index.scss'
Expand Down Expand Up @@ -87,6 +87,12 @@ export default class BaseInfo extends React.Component {
get(this.fedFormTemplate, 'spec.selector.matchLabels')
)

set(
this.props.formData,
'ingress.metadata.name',
`${value}-ingress-${generateId()}`
)

if (this.props.isFederated) {
updateFederatedAnnotations(this.formTemplate)
}
Expand Down

0 comments on commit 2d0b7c7

Please sign in to comment.