Skip to content

Commit

Permalink
fix: The git repository creates components without English names (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
RainBondsongyg committed Mar 22, 2023
1 parent ed1b262 commit 0d60fda
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/GitRepostory/index.js
Expand Up @@ -114,6 +114,7 @@ export default class Index extends PureComponent {
team_name: teamName,
open_webhook: value.open_webhook, // 是否开启webhook
full_name: value.project_full_name,
k8s_component_name: value.k8s_component_name
};
dispatch({
type: 'createApp/createThirtAppByCode',
Expand Down
41 changes: 37 additions & 4 deletions src/components/ThirdList/form.js
Expand Up @@ -30,10 +30,10 @@ const { TabPane } = Tabs;

const formItemLayout = {
labelCol: {
span: 5
span: 7
},
wrapperCol: {
span: 19
span: 17
}
};

Expand Down Expand Up @@ -144,6 +144,25 @@ class Index extends React.Component {
showSubdirectories: checkedValues.includes('subdirectories')
});
};
handleValiateNameSpace = (_, value, callback) => {
if (!value) {
return callback(new Error(`${formatMessage({id:'componentOverview.EditName.input_en_name'})}` ));
}
if (value && value.length <= 32) {
const Reg = /^[a-z]([-a-z0-9]*[a-z0-9])?$/;
if (!Reg.test(value)) {
return callback(
new Error(
`${formatMessage({id:'componentOverview.EditName.only'})}`
)
);
}
callback();
}
if (value.length > 32) {
return callback(new Error( `${formatMessage({id:'componentOverview.EditName.Cannot'})}` ));
}
};
render() {
const {
groups,
Expand Down Expand Up @@ -192,7 +211,7 @@ class Index extends React.Component {
placeholder="请选择要所属应用"
style={{
display: 'inline-block',
width: ServiceComponent ? '' : 292,
width: ServiceComponent ? '' : 251,
marginRight: 15
}}
disabled={!!ServiceComponent}
Expand Down Expand Up @@ -229,7 +248,21 @@ class Index extends React.Component {
rules: [{ required: true, message: '要创建的组件还没有名字' }]
})(<Input placeholder="请为创建的组件起个名字吧" />)}
</Form.Item>

<Form.Item
className={styles.clearConform}
{...formItemLayout}
label={
<div className={styles.clearConformMinTitle}>
<img src={Component} alt="" />
组件英文名称&nbsp;:
</div>
}
>
{getFieldDecorator('k8s_component_name', {
initialValue: '',
rules: [{ required: true, validator: this.handleValiateNameSpace}]
})(<Input placeholder="请为创建的组件起个英文名字吧" />)}
</Form.Item>
<Form.Item
className={styles.clearConform}
{...formItemLayout}
Expand Down
3 changes: 2 additions & 1 deletion src/services/createApp.js
Expand Up @@ -46,7 +46,8 @@ export async function createThirtAppByCodes(body = {}) {
check_uuid: body.check_uuid || '',
event_id: body.event_id || '',
open_webhook: body.open_webhook,
full_name: body.full_name
full_name: body.full_name,
k8s_component_name: body.k8s_component_name
}
}
);
Expand Down

0 comments on commit 0d60fda

Please sign in to comment.