import React from "react";
|
import {
|
Edit,
|
SimpleForm,
|
TextInput,
|
NumberInput,
|
SaveButton,
|
SelectInput,
|
Toolbar,
|
required,
|
DeleteButton,
|
useTranslate,
|
} from 'react-admin';
|
import { Grid, Stack } from '@mui/material';
|
import { EDIT_MODE } from '@/config/setting';
|
import EditBaseAside from "@/page/components/EditBaseAside";
|
import CustomerTopToolBar from "@/page/components/EditTopToolBar";
|
|
const FormToolbar = () => (
|
<Toolbar sx={{ justifyContent: 'space-between' }}>
|
<SaveButton />
|
<DeleteButton mutationMode="optimistic" />
|
</Toolbar>
|
);
|
|
const HttpAuditRuleEdit = () => {
|
const translate = useTranslate();
|
const ruleTypeChoices = [
|
{ id: 'URI', name: translate('table.field.httpAuditRule.ruleType.URI') },
|
{ id: 'IP', name: translate('table.field.httpAuditRule.ruleType.IP') },
|
{ id: 'REQUEST_BODY', name: translate('table.field.httpAuditRule.ruleType.REQUEST_BODY') },
|
];
|
const matchModeChoices = [
|
{ id: 'EQUAL', name: translate('table.field.httpAuditRule.matchMode.EQUAL') },
|
{ id: 'PREFIX', name: translate('table.field.httpAuditRule.matchMode.PREFIX') },
|
{ id: 'CONTAINS', name: translate('table.field.httpAuditRule.matchMode.CONTAINS') },
|
{ id: 'REGEX', name: translate('table.field.httpAuditRule.matchMode.REGEX') },
|
];
|
const directionChoices = [
|
{ id: 'IN', name: translate('table.field.httpAuditRule.direction.IN') },
|
{ id: 'OUT', name: translate('table.field.httpAuditRule.direction.OUT') },
|
{ id: 'BOTH', name: translate('table.field.httpAuditRule.direction.BOTH') },
|
];
|
|
return (
|
<Edit
|
resource="httpAuditRule"
|
redirect="list"
|
mutationMode={EDIT_MODE}
|
actions={<CustomerTopToolBar />}
|
aside={<EditBaseAside />}
|
>
|
<SimpleForm
|
toolbar={<FormToolbar />}
|
defaultValues={{ enabled: 1, sortOrder: 0, direction: 'IN', recordAll: 0 }}
|
>
|
<Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}>
|
<Grid item xs={12} md={8}>
|
<Stack spacing={2}>
|
<TextInput source="id" label="common.field.id" disabled />
|
<SelectInput
|
source="ruleType"
|
label="table.field.httpAuditRule.ruleTypeLabel"
|
choices={ruleTypeChoices}
|
validate={required()}
|
fullWidth
|
/>
|
<SelectInput
|
source="matchMode"
|
label="table.field.httpAuditRule.matchModeLabel"
|
choices={matchModeChoices}
|
validate={required()}
|
fullWidth
|
/>
|
<TextInput
|
source="pattern"
|
label="table.field.httpAuditRule.pattern"
|
validate={required()}
|
fullWidth
|
multiline
|
minRows={3}
|
/>
|
<SelectInput
|
source="direction"
|
label="table.field.httpAuditRule.directionLabel"
|
choices={directionChoices}
|
fullWidth
|
/>
|
<SelectInput
|
source="recordAll"
|
label="table.field.httpAuditRule.recordAll"
|
choices={[
|
{ id: 1, name: translate('table.field.httpAuditRule.recordAllOn') },
|
{ id: 0, name: translate('table.field.httpAuditRule.recordAllOff') },
|
]}
|
fullWidth
|
/>
|
<NumberInput source="requestMaxChars" label="table.field.httpAuditRule.requestMaxChars" fullWidth />
|
<NumberInput source="responseMaxChars" label="table.field.httpAuditRule.responseMaxChars" fullWidth />
|
<SelectInput
|
source="enabled"
|
label="table.field.httpAuditRule.enabled"
|
choices={[
|
{ id: 1, name: translate('table.field.httpAuditRule.enabledOn') },
|
{ id: 0, name: translate('table.field.httpAuditRule.enabledOff') },
|
]}
|
fullWidth
|
/>
|
<NumberInput source="sortOrder" label="table.field.httpAuditRule.sortOrder" fullWidth />
|
<TextInput source="remark" label="table.field.httpAuditRule.remark" fullWidth multiline minRows={2} />
|
</Stack>
|
</Grid>
|
</Grid>
|
</SimpleForm>
|
</Edit>
|
);
|
};
|
|
export default HttpAuditRuleEdit;
|