From b4ac4db452bf87c4ec13b7900f0077274d8e1ef2 Mon Sep 17 00:00:00 2001 From: Lucas Phang Date: Fri, 14 May 2021 16:48:18 +1000 Subject: [PATCH] Change path node colors depending on status --- stylesheets/_modal.scss | 11 ++++++++--- ts/components/OnionStatusDialog.tsx | 19 ++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/stylesheets/_modal.scss b/stylesheets/_modal.scss index 85da952a3..62587b5b5 100644 --- a/stylesheets/_modal.scss +++ b/stylesheets/_modal.scss @@ -355,18 +355,23 @@ .dot { height: 15px; width: 15px; - background-color: $color-loki-green; border-radius: 50%; display: inline-block; } + // TODO: Use colors defined in UI constants + .green { + background-color: $color-loki-green; + } + .red { + background-color: #FF453A; + } } } .lineContainer { - height: 50px - + height: 50px; } // .line { diff --git a/ts/components/OnionStatusDialog.tsx b/ts/components/OnionStatusDialog.tsx index 4f50c7ce5..fed95d18a 100644 --- a/ts/components/OnionStatusDialog.tsx +++ b/ts/components/OnionStatusDialog.tsx @@ -4,11 +4,12 @@ import { SessionModal } from './session/SessionModal'; import { DefaultTheme } from 'styled-components'; import { getPathNodesIPAddresses } from '../session/onions/onionSend'; import { useInterval } from '../hooks/useInterval'; +import classNames from 'classnames'; import electron from 'electron'; const { shell } = electron; -interface Props { +interface OnionStatusDialogProps { theme: DefaultTheme; nodes?: Array; onClose: any; @@ -19,8 +20,8 @@ interface IPathNode { label: string; } -const OnionPath = (props: { nodes: IPathNode[] }) => { - const { nodes } = props; +const OnionPath = (props: { nodes: IPathNode[], hasPath: boolean }) => { + const { nodes, hasPath } = props; return (
@@ -28,7 +29,7 @@ const OnionPath = (props: { nodes: IPathNode[] }) => { nodes.map((node) => { return (
-
+

{node.label} {node.ip && ( @@ -46,11 +47,12 @@ const OnionPath = (props: { nodes: IPathNode[] }) => { ) } -export const OnionStatusDialog = (props: Props) => { +export const OnionStatusDialog = (props: OnionStatusDialogProps) => { const { theme, onClose } = props; const [onionPathAddresses, setOnionPathAddresses] = useState([]) const [pathNodes, setPathNodes] = useState([]) + const [hasPath, setHasPath] = useState(false) const getOnionPathAddresses = () => { const onionPathAddresses = getPathNodesIPAddresses(); @@ -81,6 +83,9 @@ export const OnionStatusDialog = (props: Props) => { }, ] + // FIXME call function to check if an onion path exists + setHasPath(onionPathAddresses.length !== 0); + // if there is a onion path, update the addresses if (onionPathAddresses.length) { onionPathAddresses.forEach((ipAddress, index) => { @@ -103,7 +108,7 @@ export const OnionStatusDialog = (props: Props) => { console.log("Opening FAQ Page") shell.openExternal('https://getsession.org/faq/#onion-routing'); } - + return ( {

{window.i18n('onionPathIndicatorDescription')}

- +