displayed the conditions of the KeyOverwrite feature

master
Tudor Stanciu 2022-09-21 11:55:25 +03:00
parent f836fd3da0
commit 61dfb727db
9 changed files with 46 additions and 19 deletions

View File

@ -1,3 +1,6 @@
****************************************************************
Material UI v4: https://v4.mui.com/components/lists/
****************************************************************
withTranslation()(LegacyComponentClass) withTranslation()(LegacyComponentClass)
const { t } = this.props; const { t } = this.props;

View File

@ -71,7 +71,8 @@
"Details": "Keys", "Details": "Keys",
"Tooltip": "KeyOverwrite can be used to replace any key from all http responses of a forward.", "Tooltip": "KeyOverwrite can be used to replace any key from all http responses of a forward.",
"Origin": "Origin", "Origin": "Origin",
"Substitute": "Substitute" "Substitute": "Substitute",
"Conditions": "Conditions"
}, },
"Exceptions": { "Exceptions": {
"Label": "Exceptions", "Label": "Exceptions",

View File

@ -62,7 +62,8 @@
"Details": "Chei", "Details": "Chei",
"Tooltip": "KeyOverwrite poate fi utilizat pentru a înlocui orice cheie din toate răspunsurile http ale unei redirecționări.", "Tooltip": "KeyOverwrite poate fi utilizat pentru a înlocui orice cheie din toate răspunsurile http ale unei redirecționări.",
"Origin": "Înlocuit", "Origin": "Înlocuit",
"Substitute": "Înlocuitor" "Substitute": "Înlocuitor",
"Conditions": "Condiții"
}, },
"Exceptions": { "Exceptions": {
"Label": "Excepții", "Label": "Excepții",

View File

@ -2,18 +2,18 @@ import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { Chip } from "@material-ui/core"; import { Chip } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
import styles from "../../../../components/common/styles/elementStyles"; import styles from "./styles";
const useStyles = makeStyles(styles); const useStyles = makeStyles(styles);
const ForwardProtocols = ({ protocols }) => { const SlimChips = ({ elements }) => {
const classes = useStyles(); const classes = useStyles();
return ( return (
<> <>
{protocols.map(protocol => ( {elements.map(protocol => (
<Chip <Chip
key={protocols.indexOf(protocol)} key={elements.indexOf(protocol)}
size="small" size="small"
label={protocol} label={protocol}
className={classes.smallChip} className={classes.smallChip}
@ -23,8 +23,8 @@ const ForwardProtocols = ({ protocols }) => {
); );
}; };
ForwardProtocols.propTypes = { SlimChips.propTypes = {
protocols: PropTypes.array.isRequired elements: PropTypes.arrayOf(PropTypes.string).isRequired
}; };
export default ForwardProtocols; export default SlimChips;

View File

@ -3,7 +3,7 @@ import PropTypes from "prop-types";
import { Grid, Link } from "@material-ui/core"; import { Grid, Link } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import ForwardProtocols from "./ForwardProtocols"; import SlimChips from "../../../../components/common/chips/SlimChips";
import styles from "../../../../components/common/styles/gridStyles"; import styles from "../../../../components/common/styles/gridStyles";
const useStyles = makeStyles(styles); const useStyles = makeStyles(styles);
@ -14,7 +14,7 @@ const ForwardSummary = ({ forward, handleForwardClick }) => {
return ( return (
<Grid container> <Grid container>
<Grid item xs={4} sm={3}> <Grid item xs={12} sm={6} md={3}>
{`${t("Forward.From")}: `} {`${t("Forward.From")}: `}
<span className={classes.value}> <span className={classes.value}>
<Link href="#" onClick={handleForwardClick(forward)}> <Link href="#" onClick={handleForwardClick(forward)}>
@ -23,14 +23,14 @@ const ForwardSummary = ({ forward, handleForwardClick }) => {
</span> </span>
</Grid> </Grid>
<Grid item xs={4}> <Grid item xs={12} sm={6} md={3}>
{`${t("Forward.To")}: `} {`${t("Forward.To")}: `}
<span className={classes.value}>{forward.to}</span> <span className={classes.value}>{forward.to}</span>
</Grid> </Grid>
{forward.protocols && ( {forward.protocols && (
<Grid item xs={4}> <Grid item xs={12} sm={6} md={3}>
{`${t("Forward.Protocols")}: `} {`${t("Forward.Protocols")}: `}
<ForwardProtocols protocols={forward.protocols} /> <SlimChips elements={forward.protocols} />
</Grid> </Grid>
)} )}
</Grid> </Grid>

View File

@ -17,6 +17,7 @@ import {
StyledTableCell, StyledTableCell,
StyledTableRow StyledTableRow
} from "../../../../../../components/common/MaterialTable"; } from "../../../../../../components/common/MaterialTable";
import SlimChips from "../../../../../../components/common/chips/SlimChips";
const useStyles = makeStyles(styles); const useStyles = makeStyles(styles);
@ -24,6 +25,8 @@ const KeyOverwriteDetailsComponent = ({ details }) => {
const classes = useStyles(); const classes = useStyles();
const { t } = useTranslation(); const { t } = useTranslation();
const displayConditions = details.some(z => z.conditions);
return ( return (
<ExpandableCard <ExpandableCard
Icon={<List />} Icon={<List />}
@ -45,6 +48,11 @@ const KeyOverwriteDetailsComponent = ({ details }) => {
<StyledTableCell> <StyledTableCell>
{t("Forward.Options.KeyOverwrite.Substitute")} {t("Forward.Options.KeyOverwrite.Substitute")}
</StyledTableCell> </StyledTableCell>
{displayConditions && (
<StyledTableCell>
{t("Forward.Options.KeyOverwrite.Conditions")}
</StyledTableCell>
)}
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
@ -54,6 +62,13 @@ const KeyOverwriteDetailsComponent = ({ details }) => {
<StyledTableRow key={details.indexOf(detail)}> <StyledTableRow key={details.indexOf(detail)}>
<StyledTableCell>{detail.origin}</StyledTableCell> <StyledTableCell>{detail.origin}</StyledTableCell>
<StyledTableCell>{detail.substitute}</StyledTableCell> <StyledTableCell>{detail.substitute}</StyledTableCell>
{displayConditions && (
<StyledTableCell>
{detail.conditions && (
<SlimChips elements={detail.conditions} />
)}
</StyledTableCell>
)}
</StyledTableRow> </StyledTableRow>
); );
})} })}

View File

@ -1,11 +1,12 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; 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 { makeStyles } from "@material-ui/core/styles";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import styles from "../../../../../../components/common/styles/gridStyles"; import styles from "../../../../../../components/common/styles/gridStyles";
import ActiveIcon from "../../../../../../components/common/ActiveIcon"; import ActiveIcon from "../../../../../../components/common/ActiveIcon";
import KeyOverwriteDetailsComponent from "./KeyOverwriteDetailsComponent"; import KeyOverwriteDetailsComponent from "./KeyOverwriteDetailsComponent";
import SlimChips from "../../../../../../components/common/chips/SlimChips";
const useStyles = makeStyles(styles); const useStyles = makeStyles(styles);
@ -23,17 +24,23 @@ const KeyOverwriteSummary = ({ data }) => {
</Grid> </Grid>
{singleKey && ( {singleKey && (
<> <>
<Grid item xs={6} sm={3} md={3}> <Grid item xs={12} sm={6} md={3}>
{`${t("Forward.Options.KeyOverwrite.Origin")}: `} {`${t("Forward.Options.KeyOverwrite.Origin")}: `}
<span className={classes.value}>{data.details[0].origin}</span> <span className={classes.value}>{data.details[0].origin}</span>
</Grid> </Grid>
<Grid item xs={6} sm={3} md={3}> <Grid item xs={12} sm={6} md={3}>
{`${t("Forward.Options.KeyOverwrite.Substitute")}: `} {`${t("Forward.Options.KeyOverwrite.Substitute")}: `}
<span className={classes.value}> <span className={classes.value}>
{data.details[0].substitute} {data.details[0].substitute}
</span> </span>
</Grid> </Grid>
{data.details[0].conditions && (
<Grid item xs={12} sm={6} md={3}>
{`${t("Forward.Options.KeyOverwrite.Conditions")}: `}
<SlimChips elements={data.details[0].conditions} />
</Grid>
)}
</> </>
)} )}
</Grid> </Grid>

View File

@ -17,7 +17,7 @@ import {
import Spinner from "../../../components/common/Spinner"; import Spinner from "../../../components/common/Spinner";
import DonutLargeRoundedIcon from "@material-ui/icons/DonutLargeRounded"; import DonutLargeRoundedIcon from "@material-ui/icons/DonutLargeRounded";
import SessionForwardsHeaderComponent from "./SessionForwardsHeaderComponent"; import SessionForwardsHeaderComponent from "./SessionForwardsHeaderComponent";
import ForwardProtocols from "../../forwards/core/components/ForwardProtocols"; import SlimChips from "../../../components/common/chips/SlimChips";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import styles from "../../../components/common/styles/tableStyles"; import styles from "../../../components/common/styles/tableStyles";
import { import {
@ -82,7 +82,7 @@ const SessionForwardsComponent = ({
<StyledTableCell>{row.to}</StyledTableCell> <StyledTableCell>{row.to}</StyledTableCell>
<StyledTableCell> <StyledTableCell>
{row.protocols ? ( {row.protocols ? (
<ForwardProtocols protocols={row.protocols} /> <SlimChips elements={row.protocols} />
) : ( ) : (
"" ""
)} )}