From c5497f4e05e0ee1800875395f8f4a7a49ab59421 Mon Sep 17 00:00:00 2001 From: Joshua Jones Date: Tue, 11 Oct 2022 22:43:52 -0700 Subject: [PATCH 1/2] Touch up service accounts ui --- .../service-account-create.tsx | 12 +- .../pages/manager/service-accounts/index.tsx | 144 ++++++++---------- 2 files changed, 70 insertions(+), 86 deletions(-) diff --git a/src/nextapp/components/service-account-create/service-account-create.tsx b/src/nextapp/components/service-account-create/service-account-create.tsx index 7f80f1560..32b83c079 100644 --- a/src/nextapp/components/service-account-create/service-account-create.tsx +++ b/src/nextapp/components/service-account-create/service-account-create.tsx @@ -86,12 +86,10 @@ const ServiceAccountCreate: React.FC = ({ return ( <> = ({ - Assign scopes for the new service account + Create New Service Account {isLoading && ( @@ -114,9 +112,9 @@ const ServiceAccountCreate: React.FC = ({
- Permissions + Assign scopes - + {data.currentNamespace?.scopes?.map((s) => ( @@ -124,7 +122,7 @@ const ServiceAccountCreate: React.FC = ({ ))} - + diff --git a/src/nextapp/pages/manager/service-accounts/index.tsx b/src/nextapp/pages/manager/service-accounts/index.tsx index 93c8f1c1e..b97257d31 100644 --- a/src/nextapp/pages/manager/service-accounts/index.tsx +++ b/src/nextapp/pages/manager/service-accounts/index.tsx @@ -2,32 +2,40 @@ import * as React from 'react'; import api, { useApi } from '@/shared/services/api'; import { Box, + Button, Container, Text, Divider, Heading, - Table, - Thead, + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalFooter, + ModalBody, + ModalCloseButton, Tr, - Th, - Tbody, Td, - Center, Icon, + Alert, + AlertDescription, + AlertIcon, } from '@chakra-ui/react'; +import Card from '@/components/card'; import { GetServerSideProps, InferGetServerSidePropsType } from 'next'; import { gql } from 'graphql-request'; import Head from 'next/head'; import PageHeader from '@/components/page-header'; import { QueryClient, useQueryClient } from 'react-query'; -import { Query } from '@/shared/types/query.types'; +import { Query, ServiceAccess } from '@/shared/types/query.types'; import ViewSecret from '@/components/view-secret'; import { dehydrate } from 'react-query/hydration'; import ServiceAccountDelete from '@/components/service-account-delete/service-account-delete'; +import Table from '@/components/table'; import { format } from 'date-fns'; -import { FaKey } from 'react-icons/fa'; +import { FaCheckCircle, FaKey } from 'react-icons/fa'; import ServiceAccountCreate from '@/components/service-account-create'; -import breadcrumbs from '@/components/ns-breadcrumb'; +import { useNamespaceBreadcrumbs } from '@/shared/hooks'; export const getServerSideProps: GetServerSideProps = async (context) => { const queryKey = 'getServiceAccounts'; @@ -52,6 +60,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => { const ServiceAccountsPage: React.FC< InferGetServerSidePropsType > = ({ queryKey }) => { + const breadcrumbs = useNamespaceBreadcrumbs([{ text: 'Service Accounts' }]); const client = useQueryClient(); const [credentials, setCredentials] = React.useState>( null @@ -83,86 +92,63 @@ const ServiceAccountsPage: React.FC< } title="Service Accounts" > - - Service Accounts allow you to access BC Government APIs via the - Gateway API or the Gateway CLI. + + + Service Accounts allow you to access BC Government APIs via the Gateway API or the Gateway CLI + + setCredentials(null)}> + + + New Service Account Created + + + {credentials && ( + <> + + + + + Please store your new service account tokens somewhere safe because as soon as you navigate away from this dialog, we will not be able to retrieve these tokens. + + + + )} + + + + + + - {credentials && ( - - - - New Service Account Tokens - - - - - These are your tokens. Copy and paste them somewhere safe like a - text file. - - - - - - - )} - - + - All Service Accounts - - -
- - - - - + {(d: ServiceAccess) => ( + + + + - - - {data.allNamespaceServiceAccounts?.length === 0 && ( - - - - )} - - {data.allNamespaceServiceAccounts?.map((d) => ( - - - - - - ))} - + )}
IDCreated AtAction
{d.name}{format(new Date(d.createdAt), 'MMM do, yyyy')} + +
-
- - - Create your first Service Account - - - Service Accounts can be used to access our API for - functions like publish gateway configuration. - - - - - -
-
{d.name}{format(new Date(d.createdAt), 'MMM do, yyyy')} - -
-
+
); From 617d7985ed3898483115b09da1022d98d61ff9b5 Mon Sep 17 00:00:00 2001 From: Joshua Jones Date: Mon, 21 Nov 2022 11:43:57 -0800 Subject: [PATCH 2/2] Fix bad formatting --- .../pages/manager/service-accounts/index.tsx | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/nextapp/pages/manager/service-accounts/index.tsx b/src/nextapp/pages/manager/service-accounts/index.tsx index b97257d31..ed6801214 100644 --- a/src/nextapp/pages/manager/service-accounts/index.tsx +++ b/src/nextapp/pages/manager/service-accounts/index.tsx @@ -33,7 +33,7 @@ import { dehydrate } from 'react-query/hydration'; import ServiceAccountDelete from '@/components/service-account-delete/service-account-delete'; import Table from '@/components/table'; import { format } from 'date-fns'; -import { FaCheckCircle, FaKey } from 'react-icons/fa'; +import { FaCheckCircle } from 'react-icons/fa'; import ServiceAccountCreate from '@/components/service-account-create'; import { useNamespaceBreadcrumbs } from '@/shared/hooks'; @@ -44,9 +44,13 @@ export const getServerSideProps: GetServerSideProps = async (context) => { await queryClient.prefetchQuery( queryKey, async () => - await api(query, {}, { - headers: context.req.headers as HeadersInit, - }) + await api( + query, + {}, + { + headers: context.req.headers as HeadersInit, + } + ) ); return { @@ -98,14 +102,22 @@ const ServiceAccountsPage: React.FC< > - Service Accounts allow you to access BC Government APIs via the Gateway API or the Gateway CLI - + Service Accounts allow you to access BC Government APIs via the + Gateway API or the Gateway CLI + - setCredentials(null)}> + setCredentials(null)} + > - New Service Account Created + + New Service Account Created{' '} + + {credentials && ( @@ -114,16 +126,18 @@ const ServiceAccountsPage: React.FC< - Please store your new service account tokens somewhere safe because as soon as you navigate away from this dialog, we will not be able to retrieve these tokens. + Please store your new service account tokens somewhere + safe because as soon as you navigate away from this + dialog, we will not be able to retrieve these tokens. )} - +