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/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 diff --git a/src/pages/Off-Chain/views/Groups.tsx b/src/pages/Off-Chain/views/Groups.tsx index 82d9b30..fc18f8a 100644 --- a/src/pages/Off-Chain/views/Groups.tsx +++ b/src/pages/Off-Chain/views/Groups.tsx @@ -93,8 +93,13 @@ export const OffChainGroups: () => JSX.Element = () => { ) .then((groupRes: IPagedGroupResponse) => { if (isMounted) { - setGroups(groupRes.items); - setGroupTotal(groupRes.total); + if (groupRes !== undefined) { + setGroups(groupRes.items); + setGroupTotal(groupRes.total); + } else { + setGroups([]); + setGroupTotal(0); + } } }) .catch((err) => {