Skip to content

Commit

Permalink
Merge pull request #1180 from bcgov/dev
Browse files Browse the repository at this point in the history
ns-to-gw final touches dev to test
  • Loading branch information
Elson9 authored Sep 19, 2024
2 parents b95e4f5 + 73f309d commit 26f32c4
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 147 deletions.
9 changes: 4 additions & 5 deletions src/nextapp/components/nav-bar/nav-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import NextLink from 'next/link';
import type { NavLink } from '@/shared/data/links';
import NamespaceMenu from '../namespace-menu';
import { useAuth } from '@/shared/services/auth';
import { gatewayPages } from '@/shared/data/links';

const linkProps = {
px: 4,
Expand Down Expand Up @@ -48,6 +49,8 @@ const NavBar: React.FC<NavBarProps> = ({ site, links, pathname }) => {
return '';
}, [pathname]);

const requiresNamespace = gatewayPages.includes(pathname);

return (
<Flex>
<Box
Expand Down Expand Up @@ -100,11 +103,7 @@ const NavBar: React.FC<NavBarProps> = ({ site, links, pathname }) => {
))}
</Container>
</Box>
{((pathname.startsWith('/manager/') &&
pathname !== '/manager/gateways' &&
pathname !== '/manager/gateways/get-started' &&
pathname !== '/manager/gateways/list') ||
pathname === '/devportal/api-directory/your-products') && (
{requiresNamespace && (
<Box
as="nav"
role="banner"
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/nextapp/components/no-gateway-redirect/index.ts

This file was deleted.

45 changes: 0 additions & 45 deletions src/nextapp/components/no-gateway-redirect/no-gateway-redirect.tsx

This file was deleted.

18 changes: 4 additions & 14 deletions src/nextapp/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Header from '@/components/header';
import NavBar from '@/components/nav-bar';
import MaintenanceBanner from '@/components/maintenance-banner';
import theme from '@/shared/theme';
import links from '@/shared/data/links';
import links, { gatewayPages } from '@/shared/data/links';
import AuthAction from '@/components/auth-action';
import { ReactQueryDevtools } from 'react-query/devtools';
import type { AppProps } from 'next/app';
Expand All @@ -31,7 +31,6 @@ import '@/shared/styles/global.css';
import { AppWrapper } from './context';
import '../../mocks';
import CompleteProfile from '@/components/complete-profile';
import GatewayToastHandler from '@/components/no-gateway-redirect/gateway-toast-handler';

const footerItems = [
{ href: 'http://www2.gov.bc.ca/gov/content/home', text: 'Home' },
Expand All @@ -57,9 +56,6 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
const router = useRouter();
const queryClientRef = React.useRef<QueryClient>();
const site: string = React.useMemo(() => {
//if (router?.pathname.startsWith('/manager')) {
// return 'manager';
//}
if (router?.pathname.startsWith('/platform')) {
return 'platform';
}
Expand All @@ -71,12 +67,7 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
}, [router]);

// Temp solution for handing spacing around new gateways dropdown menu
const gatewaysMenu =
(router?.pathname.startsWith('/manager/') &&
router?.pathname !== '/manager/gateways' &&
router?.pathname !== '/manager/gateways/get-started' &&
router?.pathname !== '/manager/gateways/list') ||
router?.pathname === '/devportal/api-directory/your-products';
const requiresNamespace = gatewayPages.includes(router?.pathname);

if (!queryClientRef.current) {
queryClientRef.current = new QueryClient({
Expand Down Expand Up @@ -118,12 +109,11 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
as="main"
flex={1}
mt={{
base: gatewaysMenu ? '303px' : '65px',
sm: gatewaysMenu ? '163px' : '115px',
base: requiresNamespace ? '303px' : '65px',
sm: requiresNamespace ? '163px' : '115px',
}}
>
<AppWrapper router={router}>
<GatewayToastHandler />
<Component {...pageProps} />
</AppWrapper>
</Box>
Expand Down
3 changes: 0 additions & 3 deletions src/nextapp/pages/manager/activity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import ActivityFilters from '@/components/activity-filters';
import { FaTimesCircle } from 'react-icons/fa';
import EmptyPane from '@/components/empty-pane';
import ActivityItem from '@/components/activity-item';
import NoGatewayRedirect from '@/components/no-gateway-redirect';

const timeZone = 'America/Vancouver';

Expand All @@ -51,8 +50,6 @@ interface FilterState {
}

const ActivityPage: React.FC = () => {
// Redirect to My Gateways page if no gateway selected
NoGatewayRedirect();

const breadcrumbs = useNamespaceBreadcrumbs([
{
Expand Down
4 changes: 0 additions & 4 deletions src/nextapp/pages/manager/admin-access/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ import {
} from '@/components/namespace-access';
import { useAuth } from '@/shared/services/auth';
import { useNamespaceBreadcrumbs } from '@/shared/hooks';
import NoGatewayRedirect from '@/components/no-gateway-redirect';

const AccessRedirectPage: React.FC = () => {
// Redirect to My Gateways page if no gateway selected
NoGatewayRedirect();

const { user } = useAuth();
const breadcrumbs = useNamespaceBreadcrumbs([
{ href: '/manager/admin-access', text: 'Administration Access' },
Expand Down
3 changes: 0 additions & 3 deletions src/nextapp/pages/manager/authorization-profiles/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import type {
Mutation,
Query,
} from '@/shared/types/query.types';
import NoGatewayRedirect from '@/components/no-gateway-redirect';

export const getServerSideProps: GetServerSideProps = async (context) => {
const queryKey = 'authorizationProfiles';
Expand Down Expand Up @@ -70,8 +69,6 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
const AuthorizationProfiles: React.FC<
InferGetServerSidePropsType<typeof getServerSideProps>
> = ({ queryKey }) => {
// Redirect to My Gateways page if no gateway selected
NoGatewayRedirect();

const breadcrumbs = useNamespaceBreadcrumbs([
{
Expand Down
3 changes: 0 additions & 3 deletions src/nextapp/pages/manager/consumers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import GrantAccessDialog from '@/components/access-request/grant-access-dialog';
import ConsumerFilters from '@/components/consumer-filters';
import AccessRequestsList from '@/components/access-request/access-requests-list';
import { useNamespaceBreadcrumbs } from '@/shared/hooks';
import NoGatewayRedirect from '@/components/no-gateway-redirect';

const sortDate = new Intl.DateTimeFormat('en-ca', { dateStyle: 'short' });

Expand Down Expand Up @@ -77,8 +76,6 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
const ConsumersPage: React.FC<
InferGetServerSidePropsType<typeof getServerSideProps>
> = ({ queryKey }) => {
// Redirect to My Gateways page if no gateway selected
NoGatewayRedirect();

const toast = useToast();
const breadcrumbs = useNamespaceBreadcrumbs([{ text: 'Consumers' }]);
Expand Down
4 changes: 0 additions & 4 deletions src/nextapp/pages/manager/gateways/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ import useCurrentNamespace from '@/shared/hooks/use-current-namespace';
import { useGlobal } from '@/shared/services/global';
import EditNamespaceDisplayName from '@/components/edit-display-name';
import { useNamespaceBreadcrumbs } from '@/shared/hooks';
import NoGatewayRedirect from '@/components/no-gateway-redirect';

const actions = [
{
Expand Down Expand Up @@ -120,9 +119,6 @@ const secondaryActions = [
];

const NamespacesPage: React.FC = () => {
// Redirect to My Gateways page if no gateway selected
NoGatewayRedirect();

const { user } = useAuth();
const breadcrumbs = useNamespaceBreadcrumbs();
const hasNamespace = !!user?.namespace;
Expand Down
11 changes: 7 additions & 4 deletions src/nextapp/pages/manager/gateways/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ const MyGatewaysPage: React.FC = () => {
py={2}
mb={4}
data-testid={`ns-list-item-${namespace.name}`}
onClick={handleNamespaceChange(namespace)}
cursor="pointer"
transition="background-color 0.2s"
_hover={{ backgroundColor: "#f0f0f0" }}
>
<Box>
<Flex alignItems="center">
Expand All @@ -298,16 +302,15 @@ const MyGatewaysPage: React.FC = () => {
mr={4}
boxSize={4}
/>
<Link
<Text
fontSize="md"
as="b"
fontWeight="bold"
color="bc-blue"
mr={2}
onClick={handleNamespaceChange(namespace)}
data-testid={`ns-list-activate-link-${namespace.name}`}
>
{namespace.displayName}
</Link>
</Text>
</Flex>
<Text fontSize="md" pl="33px">
{namespace.name}
Expand Down
3 changes: 0 additions & 3 deletions src/nextapp/pages/manager/products/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ import useCurrentNamespace, {
import { useRestMutationApi } from '@/shared/services/api';
import { gql } from 'graphql-request';
import { useAuth } from '@/shared/services/auth';
import NoGatewayRedirect from '@/components/no-gateway-redirect';

const ProductsPage: React.FC = () => {
// Redirect to My Gateways page if no gateway selected
NoGatewayRedirect();

const { user } = useAuth();
const breadcrumbs = useNamespaceBreadcrumbs([{ text: 'Products' }]);
Expand Down
3 changes: 0 additions & 3 deletions src/nextapp/pages/manager/service-accounts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { FaCheckCircle } from 'react-icons/fa';
import ServiceAccountCreate from '@/components/service-account-create';
import { useNamespaceBreadcrumbs } from '@/shared/hooks';
import EmptyPane from '@/components/empty-pane';
import NoGatewayRedirect from '@/components/no-gateway-redirect';

export const getServerSideProps: GetServerSideProps = async (context) => {
const queryKey = 'getServiceAccounts';
Expand Down Expand Up @@ -64,8 +63,6 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
const ServiceAccountsPage: React.FC<
InferGetServerSidePropsType<typeof getServerSideProps>
> = ({ queryKey }) => {
// Redirect to My Gateways page if no gateway selected
NoGatewayRedirect();

const breadcrumbs = useNamespaceBreadcrumbs([{ text: 'Service Accounts' }]);
const client = useQueryClient();
Expand Down
3 changes: 0 additions & 3 deletions src/nextapp/pages/manager/services/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import ServicesFilters from '@/components/services-list/services-filters';
import { useAuth } from '@/shared/services/auth';
import { useNamespaceBreadcrumbs } from '@/shared/hooks';
import { GetServerSideProps, InferGetServerSidePropsType } from 'next';
import NoGatewayRedirect from '@/components/no-gateway-redirect';

import { FilterState } from '@/components/services-list/types';

Expand All @@ -27,8 +26,6 @@ export const getServerSideProps: GetServerSideProps = async () => {
const ServicesPage: React.FC<
InferGetServerSidePropsType<typeof getServerSideProps>
> = ({ metricsUrl }) => {
// Redirect to My Gateways page if no gateway selected
NoGatewayRedirect();

const title = 'Gateway Services';
const breadcrumb = useNamespaceBreadcrumbs([{ text: title }]);
Expand Down
32 changes: 19 additions & 13 deletions src/nextapp/shared/data/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ export interface NavLink {
access: string[];
}

export const gatewayPages = [
'/manager/gateways/detail',
'/manager/services',
'/manager/services/[id]',
'/manager/products',
'/manager/products/[id]',
'/manager/consumers',
'/manager/consumers/[id]',
'/manager/requests/[id]',
'/manager/authorization-profiles',
'/manager/authorization-profiles/new',
'/manager/authorization-profiles/[id]',
'/manager/admin-access',
'/manager/service-accounts',
'/manager/activity',
'/devportal/api-directory/your-products',
];

const links: NavLink[] = [
// { name: 'Home', url: '/manager', access: [], sites: ['manager'] },
// { name: 'Home', url: '/devportal', access: [], sites: ['devportal'] },
Expand Down Expand Up @@ -52,20 +70,8 @@ const links: NavLink[] = [
access: ['idir-user'],
altUrls: [
'/manager/gateways/get-started',
'/manager/gateways/detail',
'/manager/gateways/list',
'/manager/services',
'/manager/services/[id]',
'/manager/products',
'/manager/products/[id]',
'/manager/consumers',
'/manager/consumers/[id]',
'/manager/requests/[id]',
'/manager/authorization-profiles',
'/manager/authorization-profiles/new',
'/manager/authorization-profiles/[id]',
'/manager/admin-access',
'/manager/service-accounts',
...gatewayPages.filter(page => !page.startsWith('/devportal')),
],
sites: ['devportal'],
},
Expand Down
Loading

0 comments on commit 26f32c4

Please sign in to comment.