Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: The git repository creates components without English names #1194

Merged
merged 1 commit into from Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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