Skip to content

Commit

Permalink
Nick/neos 622 navigating to home page results in no redirect2 (#1086)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzelei authored Jan 10, 2024
1 parent 11c533a commit b7f4b5b
Show file tree
Hide file tree
Showing 174 changed files with 120 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import { checkMysqlConnection } from '@/app/[account]/new/connection/mysql/MysqlForm';
import { checkMysqlConnection } from '@/app/(mgmt)/[account]/new/connection/mysql/MysqlForm';
import ButtonText from '@/components/ButtonText';
import FormError from '@/components/FormError';
import Spinner from '@/components/Spinner';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import JobRunStatus from '@/app/[account]/runs/components/JobRunStatus';
import JobRunStatus from '@/app/(mgmt)/[account]/runs/components/JobRunStatus';
import { useAccount } from '@/components/providers/account-provider';
import { Alert, AlertTitle } from '@/components/ui/alert';
import { Badge } from '@/components/ui/badge';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {
SINGLE_TABLE_SCHEMA_FORM_SCHEMA,
SingleTableSchemaFormValues,
} from '@/app/[account]/new/job/schema';
} from '@/app/(mgmt)/[account]/new/job/schema';
import { SchemaTable } from '@/components/jobs/SchemaTable/schema-table';
import { useAccount } from '@/components/providers/account-provider';
import SkeletonTable from '@/components/skeleton/SkeletonTable';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
SUBSET_FORM_SCHEMA,
SubsetFormValues,
} from '@/app/[account]/new/job/schema';
} from '@/app/(mgmt)/[account]/new/job/schema';
import EditItem from '@/components/jobs/subsets/EditItem';
import SubsetTable from '@/components/jobs/subsets/subset-table/SubsetTable';
import { TableRow } from '@/components/jobs/subsets/subset-table/column';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import { getConnectionIdFromSource } from '@/app/[account]/jobs/[id]/source/components/util';
import { getConnectionIdFromSource } from '@/app/(mgmt)/[account]/jobs/[id]/source/components/util';
import PageHeader from '@/components/headers/PageHeader';
import DestinationOptionsForm from '@/components/jobs/Form/DestinationOptionsForm';
import { useAccount } from '@/components/providers/account-provider';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { ReactElement, useEffect, useState } from 'react';
import { useFieldArray, useForm } from 'react-hook-form';
import useFormPersist from 'react-hook-form-persist';
import { useSessionStorage } from 'usehooks-ts';
import DestinationOptionsForm from '../../../../../components/jobs/Form/DestinationOptionsForm';
import DestinationOptionsForm from '../../../../../../components/jobs/Form/DestinationOptionsForm';
import JobsProgressSteps, { DATA_SYNC_STEPS } from '../JobsProgressSteps';
import { CONNECT_FORM_SCHEMA, ConnectFormValues } from '../schema';

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import { ApiKeyValueSessionStore } from '@/app/[account]/new/api-key/NewApiKeyForm';
import { ApiKeyValueSessionStore } from '@/app/(mgmt)/[account]/new/api-key/NewApiKeyForm';
import ButtonText from '@/components/ButtonText';
import { CopyButton } from '@/components/CopyButton';
import { useAccount } from '@/components/providers/account-provider';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import { ApiKeyValueSessionStore } from '@/app/[account]/new/api-key/NewApiKeyForm';
import { ApiKeyValueSessionStore } from '@/app/(mgmt)/[account]/new/api-key/NewApiKeyForm';
import OverviewContainer from '@/components/containers/OverviewContainer';
import PageHeader from '@/components/headers/PageHeader';
import RequiredLabel from '@/components/labels/RequiredLabel';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use client';
import { handleUserDefinedTransformerForm } from '@/app/[account]/new/transformer/UserDefinedTransformerForms/HandleUserDefinedTransformersForm';
import { handleUserDefinedTransformerForm } from '@/app/(mgmt)/[account]/new/transformer/UserDefinedTransformerForms/HandleUserDefinedTransformersForm';
import {
UPDATE_USER_DEFINED_TRANSFORMER,
UpdateUserDefinedTransformer,
} from '@/app/[account]/new/transformer/schema';
} from '@/app/(mgmt)/[account]/new/transformer/schema';
import { useAccount } from '@/components/providers/account-provider';
import { Button } from '@/components/ui/button';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use client';
import { handleUserDefinedTransformerForm } from '@/app/[account]/new/transformer/UserDefinedTransformerForms/HandleUserDefinedTransformersForm';
import { handleUserDefinedTransformerForm } from '@/app/(mgmt)/[account]/new/transformer/UserDefinedTransformerForms/HandleUserDefinedTransformersForm';
import {
SYSTEM_TRANSFORMER_SCHEMA,
SystemTransformersSchema,
} from '@/app/[account]/new/transformer/schema';
} from '@/app/(mgmt)/[account]/new/transformer/schema';
import ButtonText from '@/components/ButtonText';
import OverviewContainer from '@/components/containers/OverviewContainer';
import PageHeader from '@/components/headers/PageHeader';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { fontSans } from '@/libs/fonts';
import { cn } from '@/libs/utils';
import { Metadata } from 'next';
import { ReactElement, Suspense } from 'react';
import { getSystemAppConfig } from './api/config/config';
import BaseLayout from '../BaseLayout';
import { getSystemAppConfig } from '../api/config/config';

export const metadata: Metadata = {
title: 'Neosync',
Expand Down Expand Up @@ -41,7 +42,9 @@ export default async function RootLayout({
<Suspense>
<PostHogPageview config={appConfig.posthog} />
</Suspense>
<PHProvider>{children}</PHProvider>
<PHProvider>
<BaseLayout>{children}</BaseLayout>
</PHProvider>
</>
</ThemeProvider>
</body>
Expand Down
23 changes: 23 additions & 0 deletions frontend/apps/web/app/(mgmt)/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';

export default function NotFound() {
return (
<div className="flex flex-col items-center justify-center h-screen bg-background">
<Card className="w-full max-w-md p-8 dark:bg-background">
<CardHeader>
<CardTitle className="text-center text-gray-900 dark:text-gray-200 text-2xl">
404 Error
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="text-center">
<div className="text-gray-600 dark:text-gray-400">
The page you are looking for does not exist or may have been
moved.
</div>
</div>
</CardContent>
</Card>
</div>
);
}
20 changes: 20 additions & 0 deletions frontend/apps/web/app/(mgmt)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import AccountPageRedirect from '@/components/AccountPageRedirect';
import OverviewContainer from '@/components/containers/OverviewContainer';
import PageHeader from '@/components/headers/PageHeader';
import SkeletonTable from '@/components/skeleton/SkeletonTable';
import { ReactElement } from 'react';

export default function Home(): ReactElement {
return (
<AccountPageRedirect>
<OverviewContainer
Header={<PageHeader header={`Home`} />}
containerClassName="home-page"
>
<div className="flex flex-col gap-4">
<SkeletonTable />
</div>
</OverviewContainer>
</AccountPageRedirect>
);
}
10 changes: 0 additions & 10 deletions frontend/apps/web/app/[account]/layout.tsx

This file was deleted.

1 change: 0 additions & 1 deletion frontend/apps/web/app/api/auth/[...nextauth]/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ async function getTokenUrl(issuer: string): Promise<string> {
}
return oidcConfig.token_endpoint;
} catch (err) {
console.log('failed', err);
throw err;
}
}
Expand Down
51 changes: 47 additions & 4 deletions frontend/apps/web/app/invite/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,55 @@
import { ReactElement, ReactNode } from 'react';
import '@/app/globals.css';
import {
PHProvider,
PostHogPageview,
} from '@/components/providers/posthog-provider';
import { ThemeProvider } from '@/components/providers/theme-provider';
import { fontSans } from '@/libs/fonts';
import { cn } from '@/libs/utils';
import { Metadata } from 'next';
import { ReactElement, ReactNode, Suspense } from 'react';
import BaseLayout from '../BaseLayout';
import { getSystemAppConfig } from '../api/config/config';

export const metadata: Metadata = {
title: 'Neosync',
description: 'Open Source Test Data Management',
icons: [{ rel: 'icon', url: 'favicon.ico' }],
};

export default async function InviteLayout({
children,
}: {
children: ReactNode;
}): Promise<ReactElement> {
// Server Signin is disabled for the invite page due to inability to access path or search params on the server
// Without this, the signin redirect url is set to the root url instead of /invite?token=<token>
return <BaseLayout disableServerSignin>{children}</BaseLayout>;
const appConfig = getSystemAppConfig();
return (
<html lang="en" suppressHydrationWarning>
<head />
<body
className={cn(
'min-h-screen bg-background font-sans antialiased overflow-scroll',
fontSans.variable
)}
>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
<>
<Suspense>
<PostHogPageview config={appConfig.posthog} />
</Suspense>
<PHProvider>
{/* // Server Signin is disabled for the invite page due to inability to access path or search params on the server
// Without this, the signin redirect url is set to the root url instead of /invite?token=<token> */}
<BaseLayout disableServerSignin>{children}</BaseLayout>
</PHProvider>
</>
</ThemeProvider>
</body>
</html>
);
}
26 changes: 0 additions & 26 deletions frontend/apps/web/app/not-found.tsx

This file was deleted.

23 changes: 0 additions & 23 deletions frontend/apps/web/app/page.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SingleTableSchemaFormValues } from '@/app/[account]/new/job/schema';
import EditTransformerOptions from '@/app/[account]/transformers/EditTransformerOptions';
import { SingleTableSchemaFormValues } from '@/app/(mgmt)/[account]/new/job/schema';
import EditTransformerOptions from '@/app/(mgmt)/[account]/transformers/EditTransformerOptions';
import { Button } from '@/components/ui/button';
import { Checkbox } from '@/components/ui/checkbox';
import { FormControl, FormField, FormItem } from '@/components/ui/form';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {
filterInputFreeSystemTransformers,
filterInputFreeUdfTransformers,
} from '@/app/[account]/transformers/EditTransformerOptions';
} from '@/app/(mgmt)/[account]/transformers/EditTransformerOptions';
import { useAccount } from '@/components/providers/account-provider';
import SkeletonTable from '@/components/skeleton/SkeletonTable';
import { useGetSystemTransformers } from '@/libs/hooks/useGetSystemTransformers';
Expand Down
2 changes: 1 addition & 1 deletion frontend/apps/web/components/jobs/subsets/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SubsetFormValues } from '@/app/[account]/new/job/schema';
import { SubsetFormValues } from '@/app/(mgmt)/[account]/new/job/schema';
import { TableRow } from './subset-table/column';

interface DbCol {
Expand Down
9 changes: 6 additions & 3 deletions frontend/apps/web/components/providers/account-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function AccountProvider(props: Props): ReactElement {
const foundAccount = accountsResponse?.accounts.find(
(a) => a.name === accountName
);
if (userAccount && foundAccount && userAccount?.id === foundAccount?.id) {
if (userAccount && foundAccount && userAccount.id === foundAccount.id) {
return;
}
if (foundAccount) {
Expand All @@ -82,9 +82,12 @@ export default function AccountProvider(props: Props): ReactElement {

function setAccount(userAccount: UserAccount): void {
if (userAccount.name !== accountName) {
router.push(`/${userAccount.name}`);
setUserAccount(userAccount);
// this order matters. Otherwise if we push first,
// when it routes to the page, there is no account param and it defaults to personal /shrug
// by setting this here, it finds the last selected account and is able to effectively route to the correct spot.
setLastSelectedAccount(userAccount.name);
setUserAccount(userAccount);
router.push(`/${userAccount.name}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/apps/web/yup-validations/connections.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isConnectionNameAvailable } from '@/app/[account]/new/connection/postgres/PostgresForm';
import { isConnectionNameAvailable } from '@/app/(mgmt)/[account]/new/connection/postgres/PostgresForm';
import * as Yup from 'yup';

export const POSTGRES_CONNECTION = Yup.object({
Expand Down
4 changes: 2 additions & 2 deletions frontend/apps/web/yup-validations/jobs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SubsetFormValues } from '@/app/[account]/new/job/schema';
import { TransformerConfigSchema } from '@/app/[account]/new/transformer/schema';
import { SubsetFormValues } from '@/app/(mgmt)/[account]/new/job/schema';
import { TransformerConfigSchema } from '@/app/(mgmt)/[account]/new/transformer/schema';
import {
AwsS3DestinationConnectionOptions,
Connection,
Expand Down

1 comment on commit b7f4b5b

@vercel
Copy link

@vercel vercel bot commented on b7f4b5b Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.