From 8ab49923718c22b1b67ff49e63ca70aa258262cb Mon Sep 17 00:00:00 2001 From: James Elson Date: Thu, 6 Jun 2024 08:43:49 -0700 Subject: [PATCH] Rest of page w/o filter and search functionality --- .../namespace-manager/namespace-manager.tsx | 10 +- src/nextapp/pages/manager/gateways/index.tsx | 139 +++++++++++++++++- 2 files changed, 140 insertions(+), 9 deletions(-) diff --git a/src/nextapp/components/namespace-manager/namespace-manager.tsx b/src/nextapp/components/namespace-manager/namespace-manager.tsx index c846ebd93..a1ad8c5ed 100644 --- a/src/nextapp/components/namespace-manager/namespace-manager.tsx +++ b/src/nextapp/components/namespace-manager/namespace-manager.tsx @@ -90,10 +90,10 @@ const NamespaceManager: React.FC = ({ - Export Namespace Report + Export Gateway Report - Export a detailed report of your namespace metrics and + Export a detailed report of your gateway metrics and activities = ({ size="sm" data-testid="export-report-empty-text" > - You have no namespaces + You have no gateways - Create a namespace to manage. + Create a gateway to manage. )} @@ -181,7 +181,7 @@ const NamespaceManager: React.FC = ({ {isInvalid && ( - *Please select a namespace + *Please select a gateway )} diff --git a/src/nextapp/pages/manager/gateways/index.tsx b/src/nextapp/pages/manager/gateways/index.tsx index 29b3814b7..2cb9e035f 100644 --- a/src/nextapp/pages/manager/gateways/index.tsx +++ b/src/nextapp/pages/manager/gateways/index.tsx @@ -8,16 +8,35 @@ import { Link, useDisclosure, Button, + Flex, + Spacer, + Center, + useToast, + Select, + Input, + InputGroup, + InputRightElement, } from '@chakra-ui/react'; import Head from 'next/head'; import { gql } from 'graphql-request'; -import { FaPlus, FaLaptopCode, FaRocket } from 'react-icons/fa'; +import { + FaPlus, + FaLaptopCode, + FaRocket, + FaServer, + FaClock, + FaMinusCircle, + FaCheckCircle, + FaSearch, +} from 'react-icons/fa'; +import { useQueryClient } from 'react-query'; import PageHeader from '@/components/page-header'; import GridLayout from '@/layouts/grid'; import Card from '@/components/card'; -import { useApi } from '@/shared/services/api'; +import { restApi, useApi } from '@/shared/services/api'; import NamespaceManager from '@/components/namespace-manager/namespace-manager'; +import { Namespace } from '@/shared/types/query.types'; type GatewayActions = { title: string; @@ -62,6 +81,36 @@ const MyGatewaysPage: React.FC = () => { const managerDisclosure = useDisclosure(); const { data } = useApi('allNamespaces', { query }, { suspense: false }); + const client = useQueryClient(); + const toast = useToast(); + const handleNamespaceChange = React.useCallback( + (namespace: Namespace) => async () => { + toast({ + title: `Switching to ${namespace.name} namespace`, + status: 'info', + isClosable: true, + }); + try { + await restApi(`/admin/switch/${namespace.id}`, { method: 'PUT' }); + toast.closeAll(); + client.invalidateQueries(); + toast({ + title: `Switched to ${namespace.name} namespace`, + status: 'success', + isClosable: true, + }); + } catch (err) { + toast.closeAll(); + toast({ + title: 'Unable to switch namespaces', + status: 'error', + isClosable: true, + }); + } + }, + [client, toast] + ); + return ( <> @@ -86,10 +135,10 @@ const MyGatewaysPage: React.FC = () => { -
+ {action.title} -
+
{action.description}{' '} @@ -107,6 +156,88 @@ const MyGatewaysPage: React.FC = () => {
))} + + + + + + } /> + + + {data && {data.allNamespaces.length} gateways } + {data && + data.allNamespaces.map((namespace) => ( + + + + + Display Name + + + {namespace.name} + + + + {namespace.orgEnabled === false && !namespace.orgUpdatedAt && ( +
+ + + Publishing disabled + +
+ )} + {namespace.orgEnabled === false && namespace.orgUpdatedAt && ( +
+ + + Pending publishing permission + +
+ )} + {namespace.orgEnabled === true && ( +
+ + + Publishing enabled + +
+ )} +
+ ))} +
{data && (