From 7c79d2f049b9d816d08aab5d84e5937b3ee7e3f5 Mon Sep 17 00:00:00 2001 From: Alex Shorsher Date: Mon, 15 Aug 2022 14:33:08 -0400 Subject: [PATCH 1/3] fix namespace slide - no longer re-slides on close Signed-off-by: Alex Shorsher --- src/pages/Network/views/Namespaces.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/pages/Network/views/Namespaces.tsx b/src/pages/Network/views/Namespaces.tsx index 13cf341..535a1a2 100644 --- a/src/pages/Network/views/Namespaces.tsx +++ b/src/pages/Network/views/Namespaces.tsx @@ -61,14 +61,16 @@ export const NetworkNamespaces: () => JSX.Element = () => { }, []); useEffect(() => { - isMounted && slideID; - fetchCatcher(`${FF_Paths.nsPrefix}?id=${slideID}`) - .then((nsRes: INamespace[]) => { - isMounted && nsRes.length === 1 && setViewNs(nsRes[0]); - }) - .catch((err) => { - reportFetchError(err); - }); + if (isMounted && slideID) { + fetchCatcher(`${FF_Paths.nsPrefix}?id=${slideID}`) + .then((nsRes: INamespace[]) => { + console.log(nsRes); + isMounted && nsRes.length === 1 && setViewNs(nsRes[0]); + }) + .catch((err) => { + reportFetchError(err); + }); + } }, [slideID, isMounted]); // Namespaces From 5e9ad75ad426e9f105729337a1b9c95ba11f4f69 Mon Sep 17 00:00:00 2001 From: Alex Shorsher Date: Mon, 15 Aug 2022 14:47:01 -0400 Subject: [PATCH 2/3] fix group useEffect in gateway mode - correctly catch if the query fails Signed-off-by: Alex Shorsher --- src/pages/Off-Chain/views/Groups.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/Off-Chain/views/Groups.tsx b/src/pages/Off-Chain/views/Groups.tsx index 82d9b30..3fa3a42 100644 --- a/src/pages/Off-Chain/views/Groups.tsx +++ b/src/pages/Off-Chain/views/Groups.tsx @@ -92,9 +92,12 @@ export const OffChainGroups: () => JSX.Element = () => { }` ) .then((groupRes: IPagedGroupResponse) => { - if (isMounted) { + if (groupRes !== undefined) { setGroups(groupRes.items); setGroupTotal(groupRes.total); + } else { + setGroups([]); + setGroupTotal(0); } }) .catch((err) => { From 489811963ae37f8c685c8be1d6c93d52c5e9eef0 Mon Sep 17 00:00:00 2001 From: Alex Shorsher Date: Mon, 15 Aug 2022 14:55:26 -0400 Subject: [PATCH 3/3] status fixes for gateway mode - conditonal checks around `node` status and info - add `multiparty` context - responsiveness update for home dashboard Signed-off-by: Alex Shorsher --- src/App.tsx | 12 +++++++---- src/components/Charts/MyNodeDiagram.tsx | 6 +++++- src/components/Header.tsx | 2 +- src/contexts/ApplicationContext.tsx | 5 +++-- src/interfaces/api.ts | 5 ++++- src/pages/Home/views/Dashboard.tsx | 28 +++++++++++++++++-------- src/pages/Off-Chain/views/Groups.tsx | 14 +++++++------ 7 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 94c09c3..9c541cb 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -59,6 +59,7 @@ const App: React.FC = () => { const [messageType, setMessageType] = useState('error'); const [nodeID, setNodeID] = useState(''); const [nodeName, setNodeName] = useState(''); + const [multiparty, setMultiparty] = useState(true); const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws'; const [poolCache, setPoolCache] = useState>( new Map() @@ -87,8 +88,11 @@ const App: React.FC = () => { .then(async ([namespaceResponse, statusResponse]) => { if (namespaceResponse.ok && statusResponse.ok) { const status: IStatus = await statusResponse.json(); - setNodeID(status.node.id); - setNodeName(status.node.name); + setMultiparty(status.multiparty.enabled); + if (status.multiparty.enabled && status.node !== undefined) { + setNodeID(status.node.id); + setNodeName(status.node.name); + } setSelectedNamespace(status.namespace.name); const ns: INamespace[] = await namespaceResponse.json(); setNamespaces(ns); @@ -163,7 +167,6 @@ const App: React.FC = () => { if (initialized) { if (initError) { - // figure out what to display return ( <> @@ -177,11 +180,12 @@ const App: React.FC = () => { return ( = ({ useEffect(() => { const { nodes, edges } = getLayoutedElements( - makeInitialNodes(plugins, plugins, nodeName), + makeInitialNodes( + plugins, + plugins, + nodeName !== undefined ? nodeName : '' + ), makeInitialEdges(plugins, plugins, isSmall), isSmall ); diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 2c32787..c6dfec1 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -109,7 +109,7 @@ export const Header: React.FC = ({ {!noNsFilter && } - {nodeName} + {nodeName !== undefined ? nodeName : ''} diff --git a/src/contexts/ApplicationContext.tsx b/src/contexts/ApplicationContext.tsx index 3ace670..0ba33c0 100644 --- a/src/contexts/ApplicationContext.tsx +++ b/src/contexts/ApplicationContext.tsx @@ -18,9 +18,10 @@ import { createContext, Dispatch, SetStateAction } from 'react'; import { INamespace, INewEventSet } from '../interfaces'; export interface IApplicationContext { - nodeID: string; - nodeName: string; + nodeID?: string; + nodeName?: string; selectedNamespace: string; + multiparty: boolean; setSelectedNamespace: Dispatch>; namespaces: INamespace[]; newEvents: INewEventSet; diff --git a/src/interfaces/api.ts b/src/interfaces/api.ts index ce0f342..23ad617 100644 --- a/src/interfaces/api.ts +++ b/src/interfaces/api.ts @@ -436,7 +436,7 @@ export interface IPagedTransactionResponse { } export interface IStatus { - node: { + node?: { name: string; registered: boolean; id: string; @@ -451,6 +451,9 @@ export interface IStatus { name: string; description: string; }; + multiparty: { + enabled: boolean; + }; plugins: { blockchain: IStatusPluginDetails[]; database: IStatusPluginDetails[]; diff --git a/src/pages/Home/views/Dashboard.tsx b/src/pages/Home/views/Dashboard.tsx index a14df40..118f5da 100644 --- a/src/pages/Home/views/Dashboard.tsx +++ b/src/pages/Home/views/Dashboard.tsx @@ -54,8 +54,13 @@ import { hasAnyEvent } from '../../../utils/wsEvents'; export const HomeDashboard: () => JSX.Element = () => { const { t } = useTranslation(); - const { newEvents, lastRefreshTime, clearNewEvents, selectedNamespace } = - useContext(ApplicationContext); + const { + newEvents, + lastRefreshTime, + clearNewEvents, + selectedNamespace, + multiparty, + } = useContext(ApplicationContext); const { dateFilter } = useContext(DateFilterContext); const { poolCache, setPoolCache } = useContext(PoolContext); const { slideID, setSlideSearchParam } = useContext(SlideContext); @@ -294,11 +299,6 @@ export const HomeDashboard: () => JSX.Element = () => { /> ), }, - { - clickPath: FF_NAV_PATHS.networkPath(selectedNamespace), - headerText: t('networkMap'), - component: , - }, { clickPath: FF_NAV_PATHS.myNodePath(selectedNamespace), headerText: t('myNode'), @@ -314,6 +314,14 @@ export const HomeDashboard: () => JSX.Element = () => { }, ]; + if (multiparty) { + mediumCards.push({ + clickPath: FF_NAV_PATHS.networkPath(selectedNamespace), + headerText: t('networkMap'), + component: , + }); + } + // Medium Card UseEffect useEffect(() => { setIsHistLoading(true); @@ -347,7 +355,9 @@ export const HomeDashboard: () => JSX.Element = () => { `${FF_Paths.nsPrefix}/${selectedNamespace}${FF_Paths.status}` ) .then((statusRes: IStatus) => { - isMounted && setPlugins(statusRes.plugins); + if (isMounted) { + setPlugins(statusRes.plugins); + } }) .catch((err) => { reportFetchError(err); @@ -508,7 +518,7 @@ export const HomeDashboard: () => JSX.Element = () => { {mediumCards.map((cardData) => { return ( diff --git a/src/pages/Off-Chain/views/Groups.tsx b/src/pages/Off-Chain/views/Groups.tsx index 3fa3a42..fc18f8a 100644 --- a/src/pages/Off-Chain/views/Groups.tsx +++ b/src/pages/Off-Chain/views/Groups.tsx @@ -92,12 +92,14 @@ export const OffChainGroups: () => JSX.Element = () => { }` ) .then((groupRes: IPagedGroupResponse) => { - if (groupRes !== undefined) { - setGroups(groupRes.items); - setGroupTotal(groupRes.total); - } else { - setGroups([]); - setGroupTotal(0); + if (isMounted) { + if (groupRes !== undefined) { + setGroups(groupRes.items); + setGroupTotal(groupRes.total); + } else { + setGroups([]); + setGroupTotal(0); + } } }) .catch((err) => {