feat: add regex support for account item (#2714)

* feat: add regex support for account item

* feat: use reflect to process user field

* fix: fix lint problem

* feat: improve code format and fix reflect error
This commit is contained in:
DacongDA
2024-02-17 15:24:36 +08:00
committed by GitHub
parent 4a68dd65cd
commit d731c3c934
52 changed files with 336 additions and 39 deletions

View File

@ -13,7 +13,7 @@
// limitations under the License.
import React from "react";
import {Button, Card, Col, Input, InputNumber, List, Result, Row, Select, Space, Spin, Switch, Tag} from "antd";
import {Button, Card, Col, Form, Input, InputNumber, List, Result, Row, Select, Space, Spin, Switch, Tag} from "antd";
import {withRouter} from "react-router-dom";
import {TotpMfaType} from "./auth/MfaSetupPage";
import * as GroupBackend from "./backend/GroupBackend";
@ -1016,17 +1016,27 @@ class UserEditPage extends React.Component {
</div>
)
} style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner">
{
this.getUserOrganization()?.accountItems?.map(accountItem => {
return (
<React.Fragment key={accountItem.name}>
{
this.renderAccountItem(accountItem)
}
</React.Fragment>
);
})
}
<Form>
{
this.getUserOrganization()?.accountItems?.map(accountItem => {
return (
<React.Fragment key={accountItem.name}>
<Form.Item name={accountItem.name}
validateTrigger="onChange"
rules={[
{
pattern: accountItem.regex ? new RegExp(accountItem.regex, "g") : null,
message: i18next.t("user:This field value doesn't match the pattern rule"),
},
]}
style={{margin: 0}}>
{this.renderAccountItem(accountItem)}
</Form.Item>
</React.Fragment>
);
})
}
</Form>
</Card>
);
}

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Titel",
"Title - Tooltip": "Position in der Zugehörigkeit",
"Two passwords you typed do not match.": "Zwei von Ihnen eingegebene Passwörter stimmen nicht überein.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Título",
"Title - Tooltip": "Posición en la afiliación",
"Two passwords you typed do not match.": "Dos contraseñas que has escrito no coinciden.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "Le mot de passe doit contenir moins 6 caractères",
"The password must have at least 8 characters": "Le mot de passe doit contenir moins 8 caractères",
"The password must not contain any repeated characters": "Le mot de passe ne doit pas contenir de caractères répétés",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Poste",
"Title - Tooltip": "Fonction dans l'affiliation",
"Two passwords you typed do not match.": "Le mot de passe et la confirmation du mot de passe ne correspondent pas.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Judul",
"Title - Tooltip": "Posisi dalam afiliasi",
"Two passwords you typed do not match.": "Dua password yang Anda ketikkan tidak cocok.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "タイトル",
"Title - Tooltip": "所属のポジション",
"Two passwords you typed do not match.": "2つのパスワードが一致しません。",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "제목",
"Title - Tooltip": "소속 내 직위",
"Two passwords you typed do not match.": "두 개의 비밀번호가 일치하지 않습니다.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Título",
"Title - Tooltip": "Cargo na afiliação",
"Two passwords you typed do not match.": "As duas senhas digitadas não coincidem.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Заголовок",
"Title - Tooltip": "Положение в аффилиации",
"Two passwords you typed do not match.": "Два введенных вами пароля не совпадают.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "Şifreniz en az 6 karakterden oluşmalıdır",
"The password must have at least 8 characters": "Şifreniz en az 8 karakterden oluşmalıdır",
"The password must not contain any repeated characters": "Şifreniz tekrar eden karakterler içermemelidir",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "İki şifre birbiri ile eşleşmiyor.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Title",
"Title - Tooltip": "Position in the affiliation",
"Two passwords you typed do not match.": "Two passwords you typed do not match.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "The password must have at least 6 characters",
"The password must have at least 8 characters": "The password must have at least 8 characters",
"The password must not contain any repeated characters": "The password must not contain any repeated characters",
"This field value doesn't match the pattern rule": "This field value doesn't match the pattern rule",
"Title": "Tiêu đề",
"Title - Tooltip": "Vị trí trong tổ chức",
"Two passwords you typed do not match.": "Hai mật khẩu mà bạn đã nhập không khớp.",

View File

@ -1098,6 +1098,7 @@
"The password must have at least 6 characters": "密码长度必须至少为6个字符",
"The password must have at least 8 characters": "密码长度必须至少为8个字符",
"The password must not contain any repeated characters": "密码不得包含任何重复字符",
"This field value doesn't match the pattern rule": "此字段值与模式规则不匹配",
"Title": "职务",
"Title - Tooltip": "在工作单位担任的职务",
"Two passwords you typed do not match.": "两次输入的密码不匹配。",

View File

@ -14,7 +14,7 @@
import React from "react";
import {DeleteOutlined, DownOutlined, UpOutlined} from "@ant-design/icons";
import {Button, Col, Row, Select, Switch, Table, Tooltip} from "antd";
import {Button, Col, Input, Row, Select, Switch, Table, Tooltip} from "antd";
import * as Setting from "../Setting";
import i18next from "i18next";
@ -140,6 +140,26 @@ class AccountTable extends React.Component {
);
},
},
{
title: i18next.t("signup:Regex"),
dataIndex: "regex",
key: "regex",
width: "200px",
render: (text, record, index) => {
const regexIncludeList = ["Display name", "Password", "Email", "Phone", "Location",
"Title", "Homepage", "Bio", "Gender", "Birthday", "Education", "ID card",
"ID card type"];
if (!regexIncludeList.includes(record.name)) {
return null;
}
return (
<Input value={text} onChange={e => {
this.updateField(table, index, "regex", e.target.value);
}} />
);
},
},
{
title: i18next.t("organization:View rule"),
dataIndex: "viewRule",