From 1c4580beaef310c8dd1464f12ac5178685a45927 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Tue, 19 May 2020 03:25:42 +0300 Subject: [PATCH] active session forwards update --- .../components/ActiveSessionComponent.js | 7 +++- .../components/ActiveSessionContainer.js | 15 +++++-- .../server/components/ServerContainer.js | 3 +- .../server/components/ServerSummary.js | 2 +- .../components/SessionForwardsComponent.js | 39 ++++++++++++------- 5 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/features/server/components/ActiveSessionComponent.js b/src/features/server/components/ActiveSessionComponent.js index edc81a8..bdc588e 100644 --- a/src/features/server/components/ActiveSessionComponent.js +++ b/src/features/server/components/ActiveSessionComponent.js @@ -24,7 +24,8 @@ const ActiveSessionComponent = ({ expanded, handleExpandClick, forwards, - openOptionsDialog + openOptionsDialog, + handleForwardClick }) => { const classes = useStyles(); const { t } = useTranslation(); @@ -67,6 +68,7 @@ const ActiveSessionComponent = ({ forwards={forwards} openOptionsDialog={openOptionsDialog} showSessionInfo={false} + handleForwardClick={handleForwardClick} /> ) )} @@ -81,7 +83,8 @@ ActiveSessionComponent.propTypes = { expanded: PropTypes.bool.isRequired, handleExpandClick: PropTypes.func.isRequired, forwards: PropTypes.array, - openOptionsDialog: PropTypes.func.isRequired + openOptionsDialog: PropTypes.func.isRequired, + handleForwardClick: PropTypes.func.isRequired }; export default ActiveSessionComponent; diff --git a/src/features/server/components/ActiveSessionContainer.js b/src/features/server/components/ActiveSessionContainer.js index fcd3060..cd4ebe6 100644 --- a/src/features/server/components/ActiveSessionContainer.js +++ b/src/features/server/components/ActiveSessionContainer.js @@ -8,7 +8,7 @@ import { getActiveForwards } from "../selectors"; import ActiveSessionComponent from "./ActiveSessionComponent"; import ForwardOptionsDialog from "../../session/components/ForwardOptionsDialog"; -const ActiveSessionContainer = ({ actions, session, forwards }) => { +const ActiveSessionContainer = ({ actions, session, forwards, domain }) => { const [expanded, setExpanded] = useState(false); const [optionsDialogOpen, setOptionsDialogOpen] = useState(false); const [forwardOptions, setForwardOptions] = useState(null); @@ -33,6 +33,12 @@ const ActiveSessionContainer = ({ actions, session, forwards }) => { setForwardOptions(null); }; + const handleForwardClick = (link) => (event) => { + window.open(`${domain.scheme}://${domain.name}${link}`, "_blank"); + + event.preventDefault(); + }; + return ( <> { handleExpandClick={handleExpandClick} forwards={forwards} openOptionsDialog={handleOptionsDialogOpen} + handleForwardClick={handleForwardClick} /> { ActiveSessionContainer.propTypes = { actions: PropTypes.object.isRequired, session: PropTypes.object.isRequired, - forwards: PropTypes.array + forwards: PropTypes.array, + domain: PropTypes.object }; function mapStateToProps(state) { return { session: state.server.activeSession, - forwards: getActiveForwards(state) + forwards: getActiveForwards(state), + domain: state.server.data.domain }; } diff --git a/src/features/server/components/ServerContainer.js b/src/features/server/components/ServerContainer.js index 56bd939..b0fb6e2 100644 --- a/src/features/server/components/ServerContainer.js +++ b/src/features/server/components/ServerContainer.js @@ -22,7 +22,8 @@ const ServerContainer = ({ actions, data, history }) => { ServerContainer.propTypes = { actions: PropTypes.object.isRequired, - data: PropTypes.object.isRequired + data: PropTypes.object.isRequired, + history: PropTypes.object.isRequired }; function mapStateToProps(state) { diff --git a/src/features/server/components/ServerSummary.js b/src/features/server/components/ServerSummary.js index f5f8c93..54e8658 100644 --- a/src/features/server/components/ServerSummary.js +++ b/src/features/server/components/ServerSummary.js @@ -17,7 +17,7 @@ const ServerSummary = ({ data, openAbout }) => { {`${t("Server.Domain")}: `} - {data.domain} + {data.domain.name} diff --git a/src/features/session/components/SessionForwardsComponent.js b/src/features/session/components/SessionForwardsComponent.js index 42c6dd7..d830d54 100644 --- a/src/features/session/components/SessionForwardsComponent.js +++ b/src/features/session/components/SessionForwardsComponent.js @@ -1,19 +1,22 @@ import React from "react"; import PropTypes from "prop-types"; import { makeStyles } from "@material-ui/core/styles"; -import Table from "@material-ui/core/Table"; -import TableBody from "@material-ui/core/TableBody"; -import TableContainer from "@material-ui/core/TableContainer"; -import TableHead from "@material-ui/core/TableHead"; -import TableRow from "@material-ui/core/TableRow"; -import Paper from "@material-ui/core/Paper"; +import { + Table, + TableBody, + TableContainer, + TableHead, + TableRow, + Tooltip, + Link, + Grid, + Paper, + IconButton, + Typography +} from "@material-ui/core"; import Spinner from "../../../components/common/Spinner"; import DonutLargeRoundedIcon from "@material-ui/icons/DonutLargeRounded"; -import IconButton from "@material-ui/core/IconButton"; -import Tooltip from "@material-ui/core/Tooltip"; import SessionForwardsHeaderComponent from "./SessionForwardsHeaderComponent"; -import Typography from "@material-ui/core/Typography"; -import { Grid } from "@material-ui/core"; import { useTranslation } from "react-i18next"; import styles from "../../../components/common/styles/tableStyles"; import { @@ -27,7 +30,8 @@ const SessionForwardsComponent = ({ session, forwards, openOptionsDialog, - showSessionInfo + showSessionInfo, + handleForwardClick }) => { const classes = useStyles(); const { t } = useTranslation(); @@ -68,7 +72,15 @@ const SessionForwardsComponent = ({ {forwards.indexOf(row) + 1} - {row.from} + + {handleForwardClick ? ( + + {row.from} + + ) : ( + row.from + )} + {row.to} {row.options ? ( @@ -114,7 +126,8 @@ SessionForwardsComponent.propTypes = { session: PropTypes.object.isRequired, forwards: PropTypes.array, openOptionsDialog: PropTypes.func.isRequired, - showSessionInfo: PropTypes.bool.isRequired + showSessionInfo: PropTypes.bool.isRequired, + handleForwardClick: PropTypes.func }; export default SessionForwardsComponent;