refactor some constants and change descriptions
This commit is contained in:
1 parent
105b471cc6
commit
133468c36e
2 files changed
+34
-26
No files matched your search
@@ -62,6 +62,18 @@ const Configure = () => {
|
|||||||
"notify-email-default": "notification-email",
|
"notify-email-default": "notification-email",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const matchMethodOptions = [
|
||||||
|
{ _id: "equal", name: "Equal" },
|
||||||
|
{ _id: "include", name: "Include" },
|
||||||
|
{ _id: "regex", name: "Regex" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const expectedValuePlaceholders = {
|
||||||
|
regex: "^[\w.-]+@gmail.com$",
|
||||||
|
equal: "janet@gmail.com",
|
||||||
|
include: "@gmail.com"
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitor = async () => {
|
const fetchMonitor = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -443,11 +455,7 @@ const Configure = () => {
|
|||||||
label="Match Method"
|
label="Match Method"
|
||||||
value={monitor.matchMethod || "equal"}
|
value={monitor.matchMethod || "equal"}
|
||||||
onChange={(event) => handleChange(event, "matchMethod")}
|
onChange={(event) => handleChange(event, "matchMethod")}
|
||||||
items={[
|
items={matchMethodOptions}
|
||||||
{ _id: "equal", name: "Equal" },
|
|
||||||
{ _id: "include", name: "Include" },
|
|
||||||
{ _id: "regex", name: "Regex" },
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
<Stack>
|
<Stack>
|
||||||
<TextInput
|
<TextInput
|
||||||
@@ -455,11 +463,7 @@ const Configure = () => {
|
|||||||
id="expected-value"
|
id="expected-value"
|
||||||
label="Expected value"
|
label="Expected value"
|
||||||
isOptional={true}
|
isOptional={true}
|
||||||
placeholder={{
|
placeholder={expectedValuePlaceholders[monitor.matchMethod || "equal"]}
|
||||||
regex: "^[\w.-]+@gmail.com$",
|
|
||||||
equal: "janet@gmail.com",
|
|
||||||
include: "@gmail.com"
|
|
||||||
}[monitor.matchMethod || "equal"]}
|
|
||||||
value={monitor.expectedValue}
|
value={monitor.expectedValue}
|
||||||
onChange={(event) => handleChange(event, "expectedValue")}
|
onChange={(event) => handleChange(event, "expectedValue")}
|
||||||
error={errors["expectedValue"] ? true : false}
|
error={errors["expectedValue"] ? true : false}
|
||||||
@@ -470,7 +474,7 @@ const Configure = () => {
|
|||||||
color={theme.palette.primary.contrastTextTertiary}
|
color={theme.palette.primary.contrastTextTertiary}
|
||||||
opacity={0.8}
|
opacity={0.8}
|
||||||
>
|
>
|
||||||
The expected value is used to match the response result, and the result determines the status.
|
The expected value is used to match against response result, and the match determines the status.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -490,11 +494,11 @@ const Configure = () => {
|
|||||||
color={theme.palette.primary.contrastTextTertiary}
|
color={theme.palette.primary.contrastTextTertiary}
|
||||||
opacity={0.8}
|
opacity={0.8}
|
||||||
>
|
>
|
||||||
The expression is evaluated against the reponse JSON data and the result will get used to match with expected value. Check out
|
This expression will be evaluated against the reponse JSON data and the result will be used to match against the expected value. See
|
||||||
<Typography component="a" href="https://jmespath.org/" target="_blank" color="info">
|
<Typography component="a" href="https://jmespath.org/" target="_blank" color="info">
|
||||||
jmespath.org
|
jmespath.org
|
||||||
</Typography>
|
</Typography>
|
||||||
for the documentation about the query language.
|
for query language documentation.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -34,6 +34,18 @@ const CreateMonitor = () => {
|
|||||||
{ _id: 5, name: "5 minutes" },
|
{ _id: 5, name: "5 minutes" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const matchMethodOptions = [
|
||||||
|
{ _id: "equal", name: "Equal" },
|
||||||
|
{ _id: "include", name: "Include" },
|
||||||
|
{ _id: "regex", name: "Regex" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const expectedValuePlaceholders = {
|
||||||
|
regex: "^[\w.-]+@gmail.com$",
|
||||||
|
equal: "janet@gmail.com",
|
||||||
|
include: "@gmail.com"
|
||||||
|
};
|
||||||
|
|
||||||
const monitorTypeMaps = {
|
const monitorTypeMaps = {
|
||||||
http: {
|
http: {
|
||||||
label: "URL to monitor",
|
label: "URL to monitor",
|
||||||
@@ -412,11 +424,7 @@ const CreateMonitor = () => {
|
|||||||
label="Match Method"
|
label="Match Method"
|
||||||
value={monitor.matchMethod || "equal"}
|
value={monitor.matchMethod || "equal"}
|
||||||
onChange={(event) => handleChange(event, "matchMethod")}
|
onChange={(event) => handleChange(event, "matchMethod")}
|
||||||
items={[
|
items={matchMethodOptions}
|
||||||
{ _id: "equal", name: "Equal" },
|
|
||||||
{ _id: "include", name: "Include" },
|
|
||||||
{ _id: "regex", name: "Regex" },
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
<Stack>
|
<Stack>
|
||||||
<TextInput
|
<TextInput
|
||||||
@@ -424,11 +432,7 @@ const CreateMonitor = () => {
|
|||||||
id="expected-value"
|
id="expected-value"
|
||||||
label="Expected value"
|
label="Expected value"
|
||||||
isOptional={true}
|
isOptional={true}
|
||||||
placeholder={{
|
placeholder={expectedValuePlaceholders[monitor.matchMethod || "equal"]}
|
||||||
regex: "^[\w.-]+@gmail.com$",
|
|
||||||
equal: "janet@gmail.com",
|
|
||||||
include: "@gmail.com"
|
|
||||||
}[monitor.matchMethod || "equal"]}
|
|
||||||
value={monitor.expectedValue}
|
value={monitor.expectedValue}
|
||||||
onChange={(event) => handleChange(event, "expectedValue")}
|
onChange={(event) => handleChange(event, "expectedValue")}
|
||||||
error={errors["expectedValue"] ? true : false}
|
error={errors["expectedValue"] ? true : false}
|
||||||
@@ -439,7 +443,7 @@ const CreateMonitor = () => {
|
|||||||
color={theme.palette.primary.contrastTextTertiary}
|
color={theme.palette.primary.contrastTextTertiary}
|
||||||
opacity={0.8}
|
opacity={0.8}
|
||||||
>
|
>
|
||||||
The expected value is used to match the response result, and the result determines the status.
|
The expected value is used to match against response result, and the match determines the status.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -459,11 +463,11 @@ const CreateMonitor = () => {
|
|||||||
color={theme.palette.primary.contrastTextTertiary}
|
color={theme.palette.primary.contrastTextTertiary}
|
||||||
opacity={0.8}
|
opacity={0.8}
|
||||||
>
|
>
|
||||||
The expression is evaluated against the reponse JSON data and the result will get used to match with expected value. Check out
|
This expression will be evaluated against the reponse JSON data and the result will be used to match against the expected value. See
|
||||||
<Typography component="a" href="https://jmespath.org/" target="_blank" color="info">
|
<Typography component="a" href="https://jmespath.org/" target="_blank" color="info">
|
||||||
jmespath.org
|
jmespath.org
|
||||||
</Typography>
|
</Typography>
|
||||||
for the documentation about the query language.
|
for query language documentation.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in new issue
Block a user