From 61dfb727db53563427a0fe677757d6f3a6fbbe9a Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Wed, 21 Sep 2022 11:55:25 +0300 Subject: [PATCH] displayed the conditions of the KeyOverwrite feature --- private/Notes.txt | 3 +++ public/locales/en/translations.json | 3 ++- public/locales/ro/translations.json | 3 ++- .../common/chips/SlimChips.js} | 14 +++++++------- .../{styles/elementStyles.js => chips/styles.js} | 0 .../forwards/core/components/ForwardSummary.js | 10 +++++----- .../keyOverwrite/KeyOverwriteDetailsComponent.js | 15 +++++++++++++++ .../advanced/keyOverwrite/KeyOverwriteSummary.js | 13 ++++++++++--- .../components/SessionForwardsComponent.js | 4 ++-- 9 files changed, 46 insertions(+), 19 deletions(-) rename src/{features/forwards/core/components/ForwardProtocols.js => components/common/chips/SlimChips.js} (56%) rename src/components/common/{styles/elementStyles.js => chips/styles.js} (100%) diff --git a/private/Notes.txt b/private/Notes.txt index e9d1d84..bb732e8 100644 --- a/private/Notes.txt +++ b/private/Notes.txt @@ -1,3 +1,6 @@ +**************************************************************** +Material UI v4: https://v4.mui.com/components/lists/ +**************************************************************** withTranslation()(LegacyComponentClass) const { t } = this.props; diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index 9f4fffd..8721993 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -71,7 +71,8 @@ "Details": "Keys", "Tooltip": "KeyOverwrite can be used to replace any key from all http responses of a forward.", "Origin": "Origin", - "Substitute": "Substitute" + "Substitute": "Substitute", + "Conditions": "Conditions" }, "Exceptions": { "Label": "Exceptions", diff --git a/public/locales/ro/translations.json b/public/locales/ro/translations.json index c75b809..8792253 100644 --- a/public/locales/ro/translations.json +++ b/public/locales/ro/translations.json @@ -62,7 +62,8 @@ "Details": "Chei", "Tooltip": "KeyOverwrite poate fi utilizat pentru a înlocui orice cheie din toate răspunsurile http ale unei redirecționări.", "Origin": "Înlocuit", - "Substitute": "Înlocuitor" + "Substitute": "Înlocuitor", + "Conditions": "Condiții" }, "Exceptions": { "Label": "Excepții", diff --git a/src/features/forwards/core/components/ForwardProtocols.js b/src/components/common/chips/SlimChips.js similarity index 56% rename from src/features/forwards/core/components/ForwardProtocols.js rename to src/components/common/chips/SlimChips.js index ed577eb..1091316 100644 --- a/src/features/forwards/core/components/ForwardProtocols.js +++ b/src/components/common/chips/SlimChips.js @@ -2,18 +2,18 @@ import React from "react"; import PropTypes from "prop-types"; import { Chip } from "@material-ui/core"; import { makeStyles } from "@material-ui/core/styles"; -import styles from "../../../../components/common/styles/elementStyles"; +import styles from "./styles"; const useStyles = makeStyles(styles); -const ForwardProtocols = ({ protocols }) => { +const SlimChips = ({ elements }) => { const classes = useStyles(); return ( <> - {protocols.map(protocol => ( + {elements.map(protocol => ( { ); }; -ForwardProtocols.propTypes = { - protocols: PropTypes.array.isRequired +SlimChips.propTypes = { + elements: PropTypes.arrayOf(PropTypes.string).isRequired }; -export default ForwardProtocols; +export default SlimChips; diff --git a/src/components/common/styles/elementStyles.js b/src/components/common/chips/styles.js similarity index 100% rename from src/components/common/styles/elementStyles.js rename to src/components/common/chips/styles.js diff --git a/src/features/forwards/core/components/ForwardSummary.js b/src/features/forwards/core/components/ForwardSummary.js index e9d50aa..c90eceb 100644 --- a/src/features/forwards/core/components/ForwardSummary.js +++ b/src/features/forwards/core/components/ForwardSummary.js @@ -3,7 +3,7 @@ import PropTypes from "prop-types"; import { Grid, Link } from "@material-ui/core"; import { makeStyles } from "@material-ui/core/styles"; import { useTranslation } from "react-i18next"; -import ForwardProtocols from "./ForwardProtocols"; +import SlimChips from "../../../../components/common/chips/SlimChips"; import styles from "../../../../components/common/styles/gridStyles"; const useStyles = makeStyles(styles); @@ -14,7 +14,7 @@ const ForwardSummary = ({ forward, handleForwardClick }) => { return ( - + {`${t("Forward.From")}: `} @@ -23,14 +23,14 @@ const ForwardSummary = ({ forward, handleForwardClick }) => { - + {`${t("Forward.To")}: `} {forward.to} {forward.protocols && ( - + {`${t("Forward.Protocols")}: `} - + )} diff --git a/src/features/forwards/options/components/advanced/keyOverwrite/KeyOverwriteDetailsComponent.js b/src/features/forwards/options/components/advanced/keyOverwrite/KeyOverwriteDetailsComponent.js index 85315fe..66a91b9 100644 --- a/src/features/forwards/options/components/advanced/keyOverwrite/KeyOverwriteDetailsComponent.js +++ b/src/features/forwards/options/components/advanced/keyOverwrite/KeyOverwriteDetailsComponent.js @@ -17,6 +17,7 @@ import { StyledTableCell, StyledTableRow } from "../../../../../../components/common/MaterialTable"; +import SlimChips from "../../../../../../components/common/chips/SlimChips"; const useStyles = makeStyles(styles); @@ -24,6 +25,8 @@ const KeyOverwriteDetailsComponent = ({ details }) => { const classes = useStyles(); const { t } = useTranslation(); + const displayConditions = details.some(z => z.conditions); + return ( } @@ -45,6 +48,11 @@ const KeyOverwriteDetailsComponent = ({ details }) => { {t("Forward.Options.KeyOverwrite.Substitute")} + {displayConditions && ( + + {t("Forward.Options.KeyOverwrite.Conditions")} + + )} @@ -54,6 +62,13 @@ const KeyOverwriteDetailsComponent = ({ details }) => { {detail.origin} {detail.substitute} + {displayConditions && ( + + {detail.conditions && ( + + )} + + )} ); })} diff --git a/src/features/forwards/options/components/advanced/keyOverwrite/KeyOverwriteSummary.js b/src/features/forwards/options/components/advanced/keyOverwrite/KeyOverwriteSummary.js index e26a5c3..e6a3e7f 100644 --- a/src/features/forwards/options/components/advanced/keyOverwrite/KeyOverwriteSummary.js +++ b/src/features/forwards/options/components/advanced/keyOverwrite/KeyOverwriteSummary.js @@ -1,11 +1,12 @@ import React from "react"; import PropTypes from "prop-types"; -import { Grid } from "@material-ui/core"; +import { Grid, Box } from "@material-ui/core"; import { makeStyles } from "@material-ui/core/styles"; import { useTranslation } from "react-i18next"; import styles from "../../../../../../components/common/styles/gridStyles"; import ActiveIcon from "../../../../../../components/common/ActiveIcon"; import KeyOverwriteDetailsComponent from "./KeyOverwriteDetailsComponent"; +import SlimChips from "../../../../../../components/common/chips/SlimChips"; const useStyles = makeStyles(styles); @@ -23,17 +24,23 @@ const KeyOverwriteSummary = ({ data }) => { {singleKey && ( <> - + {`${t("Forward.Options.KeyOverwrite.Origin")}: `} {data.details[0].origin} - + {`${t("Forward.Options.KeyOverwrite.Substitute")}: `} {data.details[0].substitute} + {data.details[0].conditions && ( + + {`${t("Forward.Options.KeyOverwrite.Conditions")}: `} + + + )} )} diff --git a/src/features/session/components/SessionForwardsComponent.js b/src/features/session/components/SessionForwardsComponent.js index 6205af8..6e32d57 100644 --- a/src/features/session/components/SessionForwardsComponent.js +++ b/src/features/session/components/SessionForwardsComponent.js @@ -17,7 +17,7 @@ import { import Spinner from "../../../components/common/Spinner"; import DonutLargeRoundedIcon from "@material-ui/icons/DonutLargeRounded"; import SessionForwardsHeaderComponent from "./SessionForwardsHeaderComponent"; -import ForwardProtocols from "../../forwards/core/components/ForwardProtocols"; +import SlimChips from "../../../components/common/chips/SlimChips"; import { useTranslation } from "react-i18next"; import styles from "../../../components/common/styles/tableStyles"; import { @@ -82,7 +82,7 @@ const SessionForwardsComponent = ({ {row.to} {row.protocols ? ( - + ) : ( "" )}