feat: can restore default rule in editor
This commit is contained in:
@@ -147,6 +147,14 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
|
|||||||
setFormValues(initFormValues);
|
setFormValues(initFormValues);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleRestore = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setFormValues(({ pattern }) => ({
|
||||||
|
...(pattern === "*" ? GLOBLA_RULE : DEFAULT_RULE),
|
||||||
|
pattern,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
const handleSubmit = (e) => {
|
const handleSubmit = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const errors = {};
|
const errors = {};
|
||||||
@@ -665,6 +673,13 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
|
|||||||
>
|
>
|
||||||
{i18n("cancel")}
|
{i18n("cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
onClick={handleRestore}
|
||||||
|
>
|
||||||
|
{i18n("restore_default")}
|
||||||
|
</Button>
|
||||||
{ShowMoreButton}
|
{ShowMoreButton}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user