ExceptionsCard

master
Tudor Stanciu 2021-05-16 15:04:06 +03:00
parent eb4a76270e
commit 2c2903e8d3
7 changed files with 57 additions and 7 deletions

View File

@ -67,7 +67,8 @@
"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"
} },
"Exceptions": "Exceptions"
} }
}, },
"ReleaseNotes": { "ReleaseNotes": {

View File

@ -58,7 +58,8 @@
"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"
} },
"Exceptions": "Excepții"
} }
}, },
"ReleaseNotes": { "ReleaseNotes": {

View File

@ -15,7 +15,15 @@ import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
const useStyles = makeStyles(styles); const useStyles = makeStyles(styles);
const ExpandableCard = ({ Icon, title, subtitle, Summary, Content }) => { const ExpandableCard = ({
Icon,
iconVariant,
title,
subtitle,
smallHeader,
Summary,
Content
}) => {
const [expanded, setExpanded] = useState(false); const [expanded, setExpanded] = useState(false);
const classes = useStyles(); const classes = useStyles();
@ -28,7 +36,11 @@ const ExpandableCard = ({ Icon, title, subtitle, Summary, Content }) => {
<Card> <Card>
<CardHeader <CardHeader
avatar={ avatar={
<Avatar aria-label="recipe" className={classes.avatar}> <Avatar
aria-label="recipe"
className={smallHeader ? classes.avatarSmall : classes.avatar}
variant={iconVariant || "circle"}
>
{Icon} {Icon}
</Avatar> </Avatar>
} }
@ -40,6 +52,7 @@ const ExpandableCard = ({ Icon, title, subtitle, Summary, Content }) => {
onClick={handleExpandClick} onClick={handleExpandClick}
aria-expanded={expanded} aria-expanded={expanded}
aria-label="show more" aria-label="show more"
size={smallHeader ? "small" : "medium"}
> >
<ExpandMoreIcon /> <ExpandMoreIcon />
</IconButton> </IconButton>
@ -57,8 +70,10 @@ const ExpandableCard = ({ Icon, title, subtitle, Summary, Content }) => {
ExpandableCard.propTypes = { ExpandableCard.propTypes = {
Icon: PropTypes.node.isRequired, Icon: PropTypes.node.isRequired,
iconVariant: PropTypes.oneOf("circle", "circular", "rounded", "square"),
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
subtitle: PropTypes.string, subtitle: PropTypes.string,
smallHeader: PropTypes.bool,
Summary: PropTypes.node, Summary: PropTypes.node,
Content: PropTypes.node.isRequired Content: PropTypes.node.isRequired
}; };

View File

@ -1,4 +1,4 @@
const styles = (theme) => ({ const styles = theme => ({
expand: { expand: {
transform: "rotate(0deg)", transform: "rotate(0deg)",
marginLeft: "auto", marginLeft: "auto",
@ -11,6 +11,11 @@ const styles = (theme) => ({
}, },
avatar: { avatar: {
backgroundColor: theme.palette.primary.main backgroundColor: theme.palette.primary.main
},
avatarSmall: {
backgroundColor: theme.palette.primary.main,
width: theme.spacing(3),
height: theme.spacing(3)
} }
}); });

View File

@ -5,14 +5,22 @@ import PropTypes from "prop-types";
import { loadForwardOptions } from "../../actionCreators"; import { loadForwardOptions } from "../../actionCreators";
import ForwardOptionsAdvancedComponent from "./ForwardOptionsAdvancedComponent"; import ForwardOptionsAdvancedComponent from "./ForwardOptionsAdvancedComponent";
import Spinner from "../../../../../components/common/Spinner"; import Spinner from "../../../../../components/common/Spinner";
import { useTranslation } from "react-i18next";
const ForwardOptionsAdvancedContainer = ({ actions, optionsId, options }) => { const ForwardOptionsAdvancedContainer = ({ actions, optionsId, options }) => {
const { t } = useTranslation();
if (!options) { if (!options) {
actions.loadForwardOptions(optionsId); actions.loadForwardOptions(optionsId);
return <Spinner />; return <Spinner />;
} }
return <ForwardOptionsAdvancedComponent options={options} />; return (
<>
<h4>{t("Forward.Options.Title")}</h4>
<ForwardOptionsAdvancedComponent options={options} />
</>
);
}; };
ForwardOptionsAdvancedContainer.propTypes = { ForwardOptionsAdvancedContainer.propTypes = {

View File

@ -0,0 +1,19 @@
import React from "react";
import PropTypes from "prop-types";
import ExceptionsCard from "../exceptions/ExceptionsCard";
const AdvancedSettingsComponent = ({ data }) => {
return (
<>
{data && data.exceptions && (
<ExceptionsCard exceptions={data.exceptions} />
)}
</>
);
};
AdvancedSettingsComponent.propTypes = {
data: PropTypes.object
};
export default AdvancedSettingsComponent;

View File

@ -4,6 +4,7 @@ import ExpandableCard from "../../../../../../components/common/ExpandableCard";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import InputIcon from "@material-ui/icons/Input"; import InputIcon from "@material-ui/icons/Input";
import PathInjectionSummary from "./PathInjectionSummary"; import PathInjectionSummary from "./PathInjectionSummary";
import AdvancedSettingsComponent from "../advancedSettings/AdvancedSettingsComponent";
const PathInjectionCard = ({ data }) => { const PathInjectionCard = ({ data }) => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -14,7 +15,7 @@ const PathInjectionCard = ({ data }) => {
title={t("Forward.Options.PathInjection.Label")} title={t("Forward.Options.PathInjection.Label")}
subtitle={t("Forward.Options.PathInjection.Tooltip")} subtitle={t("Forward.Options.PathInjection.Tooltip")}
Summary={<PathInjectionSummary data={data} />} Summary={<PathInjectionSummary data={data} />}
Content={<div>CONTENT...</div>} Content={<AdvancedSettingsComponent data={data.advancedSettings} />}
/> />
); );
}; };