From 133468c36e7d202fac41e83fecd315a6cc3abd75 Mon Sep 17 00:00:00 2001 From: dongfang <1136005348@qq.com> Date: Fri, 14 Feb 2025 02:45:24 +0000 Subject: [PATCH] refactor some constants and change descriptions --- Client/src/Pages/Uptime/Configure/index.jsx | 30 ++++++++++++--------- Client/src/Pages/Uptime/Create/index.jsx | 30 ++++++++++++--------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Client/src/Pages/Uptime/Configure/index.jsx b/Client/src/Pages/Uptime/Configure/index.jsx index 85c43902f..b1121cabf 100644 --- a/Client/src/Pages/Uptime/Configure/index.jsx +++ b/Client/src/Pages/Uptime/Configure/index.jsx @@ -62,6 +62,18 @@ const Configure = () => { "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(() => { const fetchMonitor = async () => { try { @@ -443,11 +455,7 @@ const Configure = () => { label="Match Method" value={monitor.matchMethod || "equal"} onChange={(event) => handleChange(event, "matchMethod")} - items={[ - { _id: "equal", name: "Equal" }, - { _id: "include", name: "Include" }, - { _id: "regex", name: "Regex" }, - ]} + items={matchMethodOptions} /> { id="expected-value" label="Expected value" isOptional={true} - placeholder={{ - regex: "^[\w.-]+@gmail.com$", - equal: "janet@gmail.com", - include: "@gmail.com" - }[monitor.matchMethod || "equal"]} + placeholder={expectedValuePlaceholders[monitor.matchMethod || "equal"]} value={monitor.expectedValue} onChange={(event) => handleChange(event, "expectedValue")} error={errors["expectedValue"] ? true : false} @@ -470,7 +474,7 @@ const Configure = () => { color={theme.palette.primary.contrastTextTertiary} 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. @@ -490,11 +494,11 @@ const Configure = () => { color={theme.palette.primary.contrastTextTertiary} 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  jmespath.org -  for the documentation about the query language. +  for query language documentation. diff --git a/Client/src/Pages/Uptime/Create/index.jsx b/Client/src/Pages/Uptime/Create/index.jsx index 354dfef29..2d2904291 100644 --- a/Client/src/Pages/Uptime/Create/index.jsx +++ b/Client/src/Pages/Uptime/Create/index.jsx @@ -34,6 +34,18 @@ const CreateMonitor = () => { { _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 = { http: { label: "URL to monitor", @@ -412,11 +424,7 @@ const CreateMonitor = () => { label="Match Method" value={monitor.matchMethod || "equal"} onChange={(event) => handleChange(event, "matchMethod")} - items={[ - { _id: "equal", name: "Equal" }, - { _id: "include", name: "Include" }, - { _id: "regex", name: "Regex" }, - ]} + items={matchMethodOptions} /> { id="expected-value" label="Expected value" isOptional={true} - placeholder={{ - regex: "^[\w.-]+@gmail.com$", - equal: "janet@gmail.com", - include: "@gmail.com" - }[monitor.matchMethod || "equal"]} + placeholder={expectedValuePlaceholders[monitor.matchMethod || "equal"]} value={monitor.expectedValue} onChange={(event) => handleChange(event, "expectedValue")} error={errors["expectedValue"] ? true : false} @@ -439,7 +443,7 @@ const CreateMonitor = () => { color={theme.palette.primary.contrastTextTertiary} 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. @@ -459,11 +463,11 @@ const CreateMonitor = () => { color={theme.palette.primary.contrastTextTertiary} 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  jmespath.org -  for the documentation about the query language. +  for query language documentation.