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: Private image warehouse optimization #1324

Merged
merged 1 commit into from
Jan 18, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/components/AddOrEditImageRegistry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class ConfirmModal extends PureComponent {
const { form, onOk } = this.props;
form.validateFields((err, values) => {
if (!err && onOk) {
if (values.domain.endsWith('/')) {
// 如果是,删除末尾的斜杠
values.domain = values.domain.slice(0, -1);
}
onOk(values);
}
});
Expand All @@ -42,17 +46,20 @@ class ConfirmModal extends PureComponent {
currentRolesLoading: false
});
};
//不能输入非汉字效验 效验不能输入非空字符串
//不能输入非汉字效验 效验不能输入非空字符串
validateNoChinese = (rule, value, callback) => {
let reg = /^[^\u4e00-\u9fa5]+$/g;
let regEmpty = /^\s*$/g;
let regNoHttp = /^(?!.*(?:https?)).*$/;
if (value && !reg.test(value)) {
callback(formatMessage({id:'placeholder.reg_Chinese'}));
} else if (value && regEmpty.test(value)) {
callback(formatMessage({id:'placeholder.regEmpty'}));
} else if (value && !regNoHttp.test(value)) {
callback(formatMessage({id: 'placeholder.warehouse_address.ban'}));
} else {
callback();
}
}
}
validateSecret = (rule, value, callback) => {
const { imageList } = this.props
Expand Down Expand Up @@ -140,7 +147,6 @@ class ConfirmModal extends PureComponent {
message: formatMessage({id:'placeholder.git_url_domain'}),
},
{
message: formatMessage({id:'placeholder.not_Chinese'}),
validator: this.validateNoChinese
},
{
Expand Down
36 changes: 23 additions & 13 deletions src/components/ImageNameForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class Index extends PureComponent {
fieldsValue.docker_cmd = fieldsValue.docker_cmd
} else {
const cleanedUrl = warehouseInfo.domain.replace(/^(https?:\/\/)/, '');
fieldsValue.docker_cmd = `${cleanedUrl}/${imageNameInfo}:${checkedValues}`
fieldsValue.docker_cmd = `${cleanedUrl}/${fieldsValue.docker_cmd}`
fieldsValue.user_name = warehouseInfo.username
fieldsValue.password = warehouseInfo.password
}
Expand Down Expand Up @@ -402,7 +402,6 @@ export default class Index extends PureComponent {
onChangeRegistry = (value) =>{
const { warehouseList } = this.state
const { setFieldsValue } = this.props.form
setFieldsValue({ docker_cmd: '' });
if(value == 'DockerHub'){
this.setState({
warehouseImageTags: [],
Expand All @@ -424,7 +423,7 @@ export default class Index extends PureComponent {
this.setState({
warehouseInfo: item
})
this.handleGetWarehouseImage(item)
// this.handleGetWarehouseImage(item)
}
})
})
Expand Down Expand Up @@ -560,7 +559,11 @@ export default class Index extends PureComponent {
)}
</Form.Item>
{radioKey === 'address' &&
<Form.Item {...is_language} label={formatMessage({ id: 'teamAdd.create.image.mirrorAddress' })}>
<Form.Item
{...is_language}
label={formatMessage({ id: 'teamAdd.create.image.mirrorAddress' })}
extra={<div style={{ fontSize: '12px' }}>私有仓库需要管理员在“平台管理-设置-镜像仓库”进行添加。</div>}
>
{getFieldDecorator('docker_cmd', {
initialValue: '',
rules: [{ required: true, message: formatMessage({ id: 'placeholder.warehouse_not_empty' }) }]
Expand All @@ -570,24 +573,31 @@ export default class Index extends PureComponent {
{warehouseList.length > 0 ? (
<Select defaultValue="DockerHub" onChange={this.onChangeRegistry}>
<Option value='DockerHub'>
Docker Hub
公开仓库
</Option>
{warehouseList.map(item => {
return (
<Option value={item.secret_id}>
{item.secret_id}
</Option>
<Option value={item.secret_id}>
<Tooltip placement="right" title={item.domain}>
<div style={{ width: '100%' }}>
{item.secret_id}
</div>
</Tooltip>
</Option>
)
})}
</Select>
) : (
<div className={styles.registry}>
Docker Hub
公开仓库
</div>
)
}
</div>
{isHub ? (
<div className={styles.imageName}>
<Input placeholder={formatMessage({ id: 'placeholder.docker_cmd' })} />
</div>
{/* {isHub ? (
<div className={styles.imageName}>
<Input placeholder={formatMessage({ id: 'placeholder.docker_cmd' })} />
</div>
Expand All @@ -611,12 +621,12 @@ export default class Index extends PureComponent {
})}
</Select>
</div>
)}
)} */}
</div>
)}
</Form.Item>
}
{radioKey === 'address' && !isHub && imageNameInfo &&
{/* {radioKey === 'address' && !isHub && imageNameInfo &&
<Form.Item
label=''
wrapperCol={{
Expand Down Expand Up @@ -662,7 +672,7 @@ export default class Index extends PureComponent {
</div>
)}
</Form.Item>
}
} */}
{radioKey === 'cmd' &&
<Form.Item {...is_language} label={formatMessage({ id: 'teamAdd.create.image.docker_cmd' })}>
{getFieldDecorator('docker_cmd', {
Expand Down
8 changes: 4 additions & 4 deletions src/components/ImageNameForm/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@
padding: 4px 8px;
.registryAddress{
height: 28px;
max-width: 125px;
min-width: 100px;
:global {
.ant-select-focused{
width: 200px;
// width: 200px;
}
.ant-select-selection{
border: 1px solid #E9EAEC;
Expand All @@ -101,9 +103,7 @@
outline: none;
}
.ant-select-selection, .ant-select{
width: 125px;
font-size: 12px;
// min-width: 64px;
height: 28px;
text-overflow: ellipsis;
white-space: nowrap;
Expand All @@ -115,7 +115,7 @@
border: 1px solid #E9EAEC;
max-width: 125px;
font-size: 12px;
min-width: 64px;
min-width: 100px;
height: 28px;
padding: 0px 11px;
line-height: 28px;
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@
'placeholder.lowercase':'The warehouse name can only be lowercase letters',
'placeholder.warehouse_not_empty':'The mirror repository address cannot be empty',
'placeholder.warehouse_address':'Please select a mirror or enter a mirror name filter',
'placeholder.warehouse_address.ban':'Do not enter http or https'
}
const tooltip = {
'tooltip.visit':'Go to the domain address corresponding to the component external access port',
Expand Down
3 changes: 2 additions & 1 deletion src/locales/zh-CN/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@
'placeholder.k8s_component_name':'请输入组件的英文名称',
'placeholder.appEngName':'请输入应用的英文名称',
'placeholder.git_url':'请输入仓库地址',
'placeholder.git_url_domain':'请输入仓库地址',
'placeholder.git_url_domain':'请输入仓库地址,如:docker.io',
'placeholder.code_version':'请输入代码版本',
'placeholder.notGit_url':'仓库地址不合法',
'placeholder.subdirectories':'请输入子目录路径',
Expand Down Expand Up @@ -866,6 +866,7 @@
'placeholder.lowercase':'仓库名称只能输入小写字母',
'placeholder.warehouse_not_empty':'镜像仓库地址不能为空',
'placeholder.warehouse_address':'请选择镜像或输入镜像名称筛选',
'placeholder.warehouse_address.ban':'禁止输入http或https'
}
const tooltip = {
'tooltip.visit':'跳转到组件对外访问端口对应的域名地址',
Expand Down
Loading