Skip to content

Commit

Permalink
fix: Fix project create validation
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Jul 6, 2020
1 parent 73bf73c commit 6fae8d5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/Inputs/ProjectSelect/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class ProjectSelect extends Component {
isFedManaged: item.isFedManaged,
}))

if (defaultValue && !data.includes(defaultValue)) {
if (defaultValue && !data.find(item => item.name === defaultValue)) {
result.unshift({
label: defaultValue,
value: defaultValue,
Expand Down
19 changes: 18 additions & 1 deletion src/components/Modals/ProjectCreate/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export default class ProjectCreateModal extends React.Component {

this.store = props.store
this.workspaceStore = new WorkspaceStore()

this.clusterRef = React.createRef()
}

componentDidMount() {
Expand Down Expand Up @@ -175,6 +177,15 @@ export default class ProjectCreateModal extends React.Component {
)
}

handleNameChange = () => {
if (this.clusterRef.current && this.clusterRef.current.state.error) {
const name = 'spec.placement.clusters'
this.clusterRef.current.validate({
[name]: get(this.props.formTemplate, name),
})
}
}

renderClusters() {
const { multiCluster } = this.props

Expand All @@ -185,6 +196,7 @@ export default class ProjectCreateModal extends React.Component {
desc={t('Select the cluster to create the project.')}
>
<Form.Item
ref={this.clusterRef}
rules={[
{ required: true, message: t('Please select a cluster') },
{ validator: this.singleClusterValidator },
Expand All @@ -208,6 +220,7 @@ export default class ProjectCreateModal extends React.Component {
desc={t('PROJECT_CLUSTER_SETTINGS_DESC')}
>
<Form.Item
ref={this.clusterRef}
rules={[
{ required: true, message: t('Please select a cluster') },
{ validator: this.multiClusterValidator },
Expand Down Expand Up @@ -281,7 +294,11 @@ export default class ProjectCreateModal extends React.Component {
},
]}
>
<Input name="metadata.name" autoFocus={true} />
<Input
name="metadata.name"
autoFocus={true}
onChange={this.handleNameChange}
/>
</Form.Item>
</Column>
<Column>
Expand Down
4 changes: 4 additions & 0 deletions src/pages/clusters/containers/Nodes/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ export default class NodeDetail extends React.Component {
name: t('Kube-Proxy Version'),
value: nodeInfo.kubeProxyVersion,
},
{
name: t('Architecture'),
value: nodeInfo.architecture,
},
{
name: t('Created Time'),
value: getLocalTime(detail.createTime).format('YYYY-MM-DD HH:mm:ss'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ export default class Deployments extends React.Component {
title: t('Project'),
dataIndex: 'namespace',
isHideable: true,
search: true,
width: '22%',
render: namespace => (
<Link to={`/clusters/${cluster}/projects/${namespace}`}>
Expand Down
8 changes: 0 additions & 8 deletions src/pages/clusters/containers/Workload/Pods/index.jsx

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

5 changes: 5 additions & 0 deletions src/pages/projects/containers/Volumes/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ export default class VolumeDetail extends React.Component {
text: t('Volume Clone'),
icon: 'copy',
action: 'create',
disabled: !get(
this.storageclasscapabilities,
'detail.volumeFeature.clone',
false
),
onClick: () => {
this.trigger('volume.clone', {
store: this.store,
Expand Down

0 comments on commit 6fae8d5

Please sign in to comment.