From 97e793fbd0b97612cbf0fb50c6f27a0f078c896b Mon Sep 17 00:00:00 2001 From: liangfung <1098486429@qq.com> Date: Thu, 25 Apr 2024 16:57:10 +0800 Subject: [PATCH 01/20] refactor(ui): implify implementation of github provider using PAT --- .../app/(dashboard)/components/sidebar.tsx | 2 +- .../git/components/tabs-header.tsx | 28 +++ .../components/repository-table.tsx | 0 .../{ => generic}/components/repository.tsx | 4 +- .../header.tsx => git/generic/layout.tsx} | 17 +- .../components/create-repository-form.tsx | 2 +- .../git/generic/new/components/new-page.tsx | 15 ++ .../git/{ => generic}/new/page.tsx | 0 .../(integrations)/git/generic/page.tsx | 5 + .../gitops/components/git-privoders.tsx} | 35 ++-- .../gitops/components/git-provider-form.tsx | 168 +++++++++++++++ .../gitops/detail/components/detail.tsx | 4 +- .../detail/components/new-repository-form.tsx | 0 .../components/provider-detail-form.tsx | 0 .../{ => git}/gitops/detail/page.tsx | 0 .../{ => git}/gitops/detail/query.ts | 0 .../header.tsx => gitops/layout.tsx} | 17 +- .../git/gitops/new/components/new-page.tsx | 74 +++++++ .../{ => git}/gitops/new/page.tsx | 0 .../(integrations)/git/gitops/page.tsx | 5 + .../settings/(integrations)/git/layout.tsx | 10 + .../git/new/components/new-page.tsx | 21 -- .../settings/(integrations)/git/page.tsx | 11 - .../gitops/components/basic-info-form.tsx | 101 --------- .../components/oauth-application-form.tsx | 101 --------- .../gitops/new/components/confirm-view.tsx | 63 ------ .../gitops/new/components/new-page.tsx | 194 ------------------ .../settings/(integrations)/gitops/page.tsx | 11 - 28 files changed, 357 insertions(+), 531 deletions(-) create mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/tabs-header.tsx rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/{ => generic}/components/repository-table.tsx (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/{ => generic}/components/repository.tsx (70%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{gitops/components/header.tsx => git/generic/layout.tsx} (58%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/{ => generic/new}/components/create-repository-form.tsx (98%) create mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/{ => generic}/new/page.tsx (100%) create mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/page.tsx rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{gitops/components/git-privoders-page.tsx => git/gitops/components/git-privoders.tsx} (81%) create mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{ => git}/gitops/detail/components/detail.tsx (98%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{ => git}/gitops/detail/components/new-repository-form.tsx (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{ => git}/gitops/detail/components/provider-detail-form.tsx (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{ => git}/gitops/detail/page.tsx (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{ => git}/gitops/detail/query.ts (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/{components/header.tsx => gitops/layout.tsx} (59%) create mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{ => git}/gitops/new/page.tsx (100%) create mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/page.tsx create mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/layout.tsx delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/new/components/new-page.tsx delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/page.tsx delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/basic-info-form.tsx delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/oauth-application-form.tsx delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/new/components/confirm-view.tsx delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/new/components/new-page.tsx delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/page.tsx diff --git a/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx b/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx index bb33237b4266..74d36dc919b3 100644 --- a/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx +++ b/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx @@ -94,7 +94,7 @@ export default function Sidebar({ children, className }: SidebarProps) { } > - + Git Providers SSO diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/tabs-header.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/tabs-header.tsx new file mode 100644 index 000000000000..8f4b212db4a0 --- /dev/null +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/tabs-header.tsx @@ -0,0 +1,28 @@ +'use client' + +import Link from 'next/link' +import { usePathname } from 'next/navigation' + +import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs' + +export default function GitTabsHeader({ className }: { className?: string }) { + const pathname = usePathname() + const defualtValue = pathname.startsWith('/settings/git/generic') + ? 'generic' + : 'gitops' + + return ( + +
+ + + Generic Git Repositories + + + Gitops + + +
+
+ ) +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/repository-table.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository-table.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/repository-table.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository-table.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/repository.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx similarity index 70% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/repository.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx index 636c5e60e179..249cead27011 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/repository.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx @@ -4,16 +4,14 @@ import Link from 'next/link' import { buttonVariants } from '@/components/ui/button' -import { RepositoryHeader } from './header' import RepositoryTable from './repository-table' export default function Repository() { return ( <> -
- + Create
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/header.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/layout.tsx similarity index 58% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/header.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/layout.tsx index 64277a8a0ccc..889de16c4b4b 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/header.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/layout.tsx @@ -1,6 +1,8 @@ +import React from 'react' + import { SubHeader } from '@/components/sub-header' -export const RepositoryHeader = ({ className }: { className?: string }) => { +const Header = ({ className }: { className?: string }) => { return ( { ) } + +export default function GenericGitRepositoriesLayout({ + children +}: { + children: React.ReactNode +}) { + return ( + <> +
+ {children} + + ) +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/create-repository-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/create-repository-form.tsx similarity index 98% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/create-repository-form.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/create-repository-form.tsx index 5ab8b953e47f..2cf0a21261e8 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/create-repository-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/create-repository-form.tsx @@ -93,7 +93,7 @@ export default function CreateRepositoryForm({ )} />
- + diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx new file mode 100644 index 000000000000..52007ccc459b --- /dev/null +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx @@ -0,0 +1,15 @@ +'use client' + +import { useRouter } from 'next/navigation' + +import RepositoryForm from './create-repository-form' + +export const NewRepository = () => { + const router = useRouter() + + const onCreated = () => { + router.replace('/settings/git/generic') + } + + return +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/new/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/page.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/new/page.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/page.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/page.tsx new file mode 100644 index 000000000000..b7de7b5a06c0 --- /dev/null +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/page.tsx @@ -0,0 +1,5 @@ +import Repository from './components/repository' + +export default function Generic() { + return +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/git-privoders-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx similarity index 81% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/git-privoders-page.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx index 32347d88be14..9bf8874cc113 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/git-privoders-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx @@ -10,8 +10,6 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { IconGitHub } from '@/components/ui/icons' import LoadingWrapper from '@/components/loading-wrapper' -import { RepositoryHeader } from './header' - export default function GitProvidersPage() { const [{ data, fetching }] = useQuery({ query: listGithubRepositoryProviders @@ -19,23 +17,20 @@ export default function GitProvidersPage() { const githubRepositoryProviders = data?.githubRepositoryProviders?.edges return ( - <> - - - {githubRepositoryProviders?.length ? ( -
- -
- - Create - -
+ + {githubRepositoryProviders?.length ? ( +
+ +
+ + Create +
- ) : ( - - )} - - +
+ ) : ( + + )} +
) } @@ -58,7 +53,7 @@ const GitProvidersList: React.FC = ({ data }) => {
View @@ -98,7 +93,7 @@ const GitProvidersPlaceholder = () => {
No Data
Create diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx new file mode 100644 index 000000000000..4e2655d7e01e --- /dev/null +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx @@ -0,0 +1,168 @@ +'use client' + +import * as React from 'react' +import { zodResolver } from '@hookform/resolvers/zod' +import { isEmpty } from 'lodash-es' +import { useForm } from 'react-hook-form' +import * as z from 'zod' + +import { Button } from '@/components/ui/button' +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage +} from '@/components/ui/form' +import { IconGitHub, IconSpinner } from '@/components/ui/icons' +import { Input } from '@/components/ui/input' +import { Label } from '@/components/ui/label' +import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group' + +const createGitProviderSchema = z.object({ + provider: z.string(), + displayName: z + .string() + .trim() + .regex( + /^[\w-]+$/, + 'Display name must contain only alphanumeric characters, underscores, and hyphens' + ), + accessToken: z.string() +}) + +const updateGitProviderSchema = createGitProviderSchema + .extend({ + accessToken: createGitProviderSchema.shape.accessToken.optional() + }) + .omit({ provider: true }) + +interface GitProviderFormProps extends React.HTMLAttributes { + isNew?: boolean + defaultValues?: Partial> +} + +export const GitProviderForm: React.FC = ({ + className, + isNew, + defaultValues +}) => { + const formSchema = isNew ? createGitProviderSchema : updateGitProviderSchema + const form = useForm>({ + resolver: zodResolver(formSchema), + defaultValues + }) + const { isSubmitting, dirtyFields } = form.formState + const isDirty = !isEmpty(dirtyFields) + + const onSubmit = (values: z.infer) => { + // + } + + return ( +
+
+ + {isNew && ( + ( + + Choose Git provider + + +
+ + +
+
+
+ +
+ )} + /> + )} + ( + + Display name + + A display name to help identifying among different configs + using the same Git provider. + + + + + + + )} + /> + ( + + Access Token + +
+ Create a dedicated service user and generate a fine-grained + personal access token with the member role for the + organization or all projects to be managed. +
+
• Contents (Read-only)
+
+ + + + +
+ )} + /> +
+
+ +
+
+ +
+
+ +
+ + ) +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx similarity index 98% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/detail/components/detail.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx index ac9a3ef3e7b6..288b053f9582 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/detail/components/detail.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx @@ -64,7 +64,7 @@ const DetailPage: React.FC = () => { } const onDeleteProvider = () => { - router.replace('/settings/gitops') + router.replace('/settings/git/gitops') } const unlinkedRepos = useMemo(() => { @@ -113,7 +113,7 @@ const DetailPage: React.FC = () => { defaultValues={provider} onDelete={onDeleteProvider} onBack={() => { - router.push('/settings/gitops') + router.push('/settings/git/gitops') }} id={id} /> diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/detail/components/new-repository-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/new-repository-form.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/detail/components/new-repository-form.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/new-repository-form.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/detail/components/provider-detail-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/provider-detail-form.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/detail/components/provider-detail-form.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/provider-detail-form.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/detail/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/page.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/detail/page.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/page.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/detail/query.ts b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/query.ts similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/detail/query.ts rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/query.ts diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/header.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/layout.tsx similarity index 59% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/header.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/layout.tsx index 64277a8a0ccc..af160e1dc51f 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/header.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/layout.tsx @@ -1,6 +1,8 @@ +import React from 'react' + import { SubHeader } from '@/components/sub-header' -export const RepositoryHeader = ({ className }: { className?: string }) => { +const Header = ({ className }: { className?: string }) => { return ( { ) } + +export default function GitProvidersLayout({ + children +}: { + children: React.ReactNode +}) { + return ( + <> +
+ {children} + + ) +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx new file mode 100644 index 000000000000..446aee883f7c --- /dev/null +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx @@ -0,0 +1,74 @@ +'use client' + +import { useRouter } from 'next/navigation' +import { createRequest } from '@urql/core' +import { toast } from 'sonner' + +import { graphql } from '@/lib/gql/generates' +import { client, useMutation } from '@/lib/tabby/gql' +import { listGithubRepositoryProviders } from '@/lib/tabby/query' +import { Button } from '@/components/ui/button' +import { CardHeader, CardTitle } from '@/components/ui/card' +import { IconChevronLeft } from '@/components/ui/icons' + +import { GitProviderForm } from '../../components/git-provider-form' + +const createGithubRepositoryProvider = graphql(/* GraphQL */ ` + mutation CreateGithubRepositoryProvider( + $input: CreateGithubRepositoryProviderInput! + ) { + createGithubRepositoryProvider(input: $input) + } +`) + +export const NewProvider = () => { + const router = useRouter() + + const getProvider = (id: string) => { + const queryProvider = client.createRequestOperation( + 'query', + createRequest(listGithubRepositoryProviders, { ids: [id] }) + ) + return client.executeQuery(queryProvider) + } + + // const createGithubRepositoryProviderMutation = useMutation( + // createGithubRepositoryProvider, + // { + // onCompleted(data) { + // if (data?.createGithubRepositoryProvider) { + // } + // }, + // onError(err) { + // toast.error(err?.message) + // }, + // form + // } + // ) + + const handleSubmit = async () => { + // createGithubRepositoryProviderMutation({ + // input: values + // }) + } + + return ( + <> + + +
+ + Create Git Provider +
+
+
+ + + ) +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/new/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/page.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/new/page.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/page.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/page.tsx new file mode 100644 index 000000000000..3afafba648bc --- /dev/null +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/page.tsx @@ -0,0 +1,5 @@ +import GitProvidersPage from './components/git-privoders' + +export default function Gitops() { + return +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/layout.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/layout.tsx new file mode 100644 index 000000000000..2713fff737d2 --- /dev/null +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/layout.tsx @@ -0,0 +1,10 @@ +import GitTabsHeader from './components/tabs-header' + +export default function GitLayout({ children }: { children: React.ReactNode }) { + return ( + <> + + {children} + + ) +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/new/components/new-page.tsx deleted file mode 100644 index 88cb366003ff..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/new/components/new-page.tsx +++ /dev/null @@ -1,21 +0,0 @@ -'use client' - -import { useRouter } from 'next/navigation' - -import RepositoryForm from '../../components/create-repository-form' -import { RepositoryHeader } from '../../components/header' - -export const NewRepository = () => { - const router = useRouter() - - const onCreated = () => { - router.replace('/settings/git') - } - - return ( - <> - - - - ) -} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/page.tsx deleted file mode 100644 index 83ccaa12b3e5..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/page.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { Metadata } from 'next' - -import Repository from './components/repository' - -export const metadata: Metadata = { - title: 'Git Providers' -} - -export default function IndexPage() { - return -} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/basic-info-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/basic-info-form.tsx deleted file mode 100644 index d89f1a8331c0..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/basic-info-form.tsx +++ /dev/null @@ -1,101 +0,0 @@ -'use client' - -import * as React from 'react' -import { UseFormReturn } from 'react-hook-form' -import * as z from 'zod' - -import { cn } from '@/lib/utils' -import { - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage -} from '@/components/ui/form' -import { IconGitHub } from '@/components/ui/icons' -import { Input } from '@/components/ui/input' -import { Label } from '@/components/ui/label' -import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group' - -export const basicInfoFormSchema = z.object({ - displayName: z - .string() - .trim() - .regex( - /^[\w-]+$/, - 'Display name must contain only alphanumeric characters, underscores, and hyphens' - ), - provider: z.string() -}) - -export type BasicInfoFormValues = z.infer - -interface BasicInfoFormProps extends React.HTMLAttributes { - form: UseFormReturn - isUpdate?: boolean -} - -export const BasicInfoForm = React.forwardRef< - HTMLDivElement, - BasicInfoFormProps ->(({ className, form, isUpdate, ...rest }, ref) => { - return ( -
- ( - - Choose Git provider - - -
- - -
-
-
- -
- )} - /> - ( - - Display name - - A display name to help identifying among different configs using - the same Git provider. - - - - - - - )} - /> -
- ) -}) - -BasicInfoForm.displayName = 'BasicInfoForm' diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/oauth-application-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/oauth-application-form.tsx deleted file mode 100644 index 70d9a105bbb2..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/components/oauth-application-form.tsx +++ /dev/null @@ -1,101 +0,0 @@ -'use client' - -import React from 'react' -import type { UseFormReturn } from 'react-hook-form' -import * as z from 'zod' - -import { useExternalURL } from '@/lib/hooks/use-network-setting' -import { cn } from '@/lib/utils' -import { - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage -} from '@/components/ui/form' -import { Input } from '@/components/ui/input' -import { CopyButton } from '@/components/copy-button' - -export const oauthInfoFormSchema = z.object({ - applicationId: z.string(), - secret: z.string() -}) - -export type OAuthApplicationFormValues = z.infer - -interface OAuthApplicationFormProps - extends React.HTMLAttributes { - form: UseFormReturn -} - -export const OAuthApplicationForm = React.forwardRef< - HTMLDivElement, - OAuthApplicationFormProps ->(({ className, form }, ref) => { - const externalURL = useExternalURL() - const integrationsCallbackURL = externalURL - ? `${externalURL}/integrations/github/callback` - : '' - - return ( -
- {!!integrationsCallbackURL && ( - -
-
- Create your OAuth2 application with the following information -
-
-
- Authorization callback URL -
- - {integrationsCallbackURL} - - -
-
-
- )} - ( - - Application ID - - - - - - )} - /> - ( - - Application secret - - - - - - )} - /> -
- ) -}) - -OAuthApplicationForm.displayName = 'OAuthApplicationForm' diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/new/components/confirm-view.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/new/components/confirm-view.tsx deleted file mode 100644 index 8e7c5e49386a..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/new/components/confirm-view.tsx +++ /dev/null @@ -1,63 +0,0 @@ -'use client' - -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle -} from '@/components/ui/card' -import { IconGitHub } from '@/components/ui/icons' -import { Separator } from '@/components/ui/separator' - -import { BasicInfoFormValues } from '../../components/basic-info-form' -import { OAuthApplicationFormValues } from '../../components/oauth-application-form' - -interface ConfirmViewProps { - data: BasicInfoFormValues & OAuthApplicationFormValues -} - -export default function ConfirmView({ data }: ConfirmViewProps) { - return ( -
- - - Confirm the info - - After creation, this Git provider can be chosen under Gitops - - - - - -
- - GitHub.com -
-
- - {data.displayName} - - {data.applicationId} - - {data.secret} -
-
-
- ) -} - -function InfoItem({ - title, - children -}: { - title: string - children: React.ReactNode -}) { - return ( -
-
{title}
-
{children}
-
- ) -} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/new/components/new-page.tsx deleted file mode 100644 index 9b539d3ad41a..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/new/components/new-page.tsx +++ /dev/null @@ -1,194 +0,0 @@ -'use client' - -import { useRef, useState } from 'react' -import { useRouter } from 'next/navigation' -import { zodResolver } from '@hookform/resolvers/zod' -import { createRequest } from '@urql/core' -import { omit } from 'lodash-es' -import { useForm, UseFormReturn } from 'react-hook-form' -import { toast } from 'sonner' -import * as z from 'zod' - -import { graphql } from '@/lib/gql/generates' -import { usePopupWindow } from '@/lib/popup-window-management' -import { client, useMutation } from '@/lib/tabby/gql' -import { listGithubRepositoryProviders } from '@/lib/tabby/query' -import { getAuthToken } from '@/lib/tabby/token-management' -import { Button } from '@/components/ui/button' -import { Form } from '@/components/ui/form' -import { IconSpinner } from '@/components/ui/icons' -import { StepItem, Steps, useSteps } from '@/components/steps/steps' - -import { - BasicInfoForm, - basicInfoFormSchema, - type BasicInfoFormValues -} from '../../components/basic-info-form' -import { RepositoryHeader } from '../../components/header' -import { - OAuthApplicationForm, - oauthInfoFormSchema, - type OAuthApplicationFormValues -} from '../../components/oauth-application-form' -import ConfirmView from '../components/confirm-view' - -const createGithubRepositoryProvider = graphql(/* GraphQL */ ` - mutation CreateGithubRepositoryProvider( - $input: CreateGithubRepositoryProviderInput! - ) { - createGithubRepositoryProvider(input: $input) - } -`) - -export const NewProvider = () => { - const router = useRouter() - const schemas = [basicInfoFormSchema, oauthInfoFormSchema, z.object({})] - - const stepState = useSteps({ - items: [ - { - title: 'Basic info' - }, - { - title: 'OAuth application info' - }, - { - title: 'Confirmation' - } - ] - }) - const { currentStep, setStep } = stepState - const form = useForm({ - resolver: zodResolver(schemas[currentStep]), - defaultValues: { - provider: 'github' - } - }) - const [errorMessage, setErrorMessage] = useState() - - const createdProviderId = useRef() - const { isSubmitting } = form.formState - - const getProvider = (id: string) => { - const queryProvider = client.createRequestOperation( - 'query', - createRequest(listGithubRepositoryProviders, { ids: [id] }) - ) - return client.executeQuery(queryProvider) - } - - const getPopupUrl = (id: string) => { - const accessToken = getAuthToken()?.accessToken - return `/integrations/github/connect/${id}?access_token=${accessToken}` - } - - const { open: openPopup } = usePopupWindow({ - async onMessage(data) { - if (data?.errorMessage) { - setErrorMessage(data.errorMessage) - } else { - const result = await getProvider(createdProviderId.current as string) - if ( - result?.data?.githubRepositoryProviders?.edges?.[0]?.node?.connected - ) { - toast.success('Provider Successfully Created') - router.replace('/settings/gitops') - } else { - setErrorMessage('Connection to GitHub failed, please try again') - } - } - } - }) - - const createGithubRepositoryProviderMutation = useMutation( - createGithubRepositoryProvider, - { - onCompleted(data) { - if (data?.createGithubRepositoryProvider) { - // store providerId - createdProviderId.current = data.createGithubRepositoryProvider - openPopup(getPopupUrl(data.createGithubRepositoryProvider)) - setErrorMessage(undefined) - } - }, - onError(err) { - toast.error(err?.message) - }, - form - } - ) - - const handleSubmit = async () => { - if (currentStep === 0) { - // basic info - setStep(currentStep + 1) - } else if (currentStep === 1) { - // oauth application info - setStep(currentStep + 1) - } else { - if (createdProviderId.current) { - openPopup(getPopupUrl(createdProviderId.current)) - setErrorMessage(undefined) - return - } - - const values = omit(form.getValues(), 'provider') - createGithubRepositoryProviderMutation({ - input: values - }) - } - } - - return ( - <> - - - {stepState.steps?.map((step, index) => { - return - })} - -
- - {currentStep === 0 && ( - } /> - )} - {currentStep === 1 && ( - } /> - )} - {currentStep === 2 && ( - <> - -
- {errorMessage} -
- - )} -
- -
- {currentStep > 0 && ( - - )} - -
-
- - - - ) -} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/page.tsx deleted file mode 100644 index 08f10332a566..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/gitops/page.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { Metadata } from 'next' - -import GitProvidersPage from './components/git-privoders-page' - -export const metadata: Metadata = { - title: 'Git Providers' -} - -export default function IndexPage() { - return -} From ba204e4a0c8f877a2f027cda1d96338affe45c12 Mon Sep 17 00:00:00 2001 From: liangfung <1098486429@qq.com> Date: Thu, 25 Apr 2024 18:29:09 +0800 Subject: [PATCH 02/20] update --- .../app/(dashboard)/components/sidebar.tsx | 9 +- .../git/components/tabs-header.tsx | 10 +- .../git/gitops/components/git-privoders.tsx | 6 - .../gitops/components/git-provider-form.tsx | 54 +++-- .../git/gitops/detail/components/detail.tsx | 3 - .../components/provider-detail-form.tsx | 197 ++++++------------ .../git/gitops/new/components/new-page.tsx | 71 +++++-- ee/tabby-ui/lib/tabby/query.ts | 1 - 8 files changed, 155 insertions(+), 196 deletions(-) diff --git a/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx b/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx index 74d36dc919b3..0d6f093440c8 100644 --- a/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx +++ b/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx @@ -94,7 +94,7 @@ export default function Sidebar({ children, className }: SidebarProps) { } > - + Git Providers SSO @@ -135,9 +135,10 @@ const linkVariants = cva( function SidebarButton({ href, children }: SidebarButtonProps) { const pathname = usePathname() const isSelected = React.useMemo(() => { - return href === '/' - ? href === pathname - : shouldPathnameHighlight(pathname, href) + if (href === '/') return href === pathname + if (href === '/settings/git/gitops') return pathname.startsWith('/settings/git/') + + return shouldPathnameHighlight(pathname, href) }, [pathname, href]) const state = isSelected ? 'selected' : 'not-selected' diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/tabs-header.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/tabs-header.tsx index 8f4b212db4a0..63c359e7bf93 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/tabs-header.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/tabs-header.tsx @@ -5,7 +5,7 @@ import { usePathname } from 'next/navigation' import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs' -export default function GitTabsHeader({ className }: { className?: string }) { +export default function GitTabsHeader() { const pathname = usePathname() const defualtValue = pathname.startsWith('/settings/git/generic') ? 'generic' @@ -13,14 +13,14 @@ export default function GitTabsHeader({ className }: { className?: string }) { return ( -
+
- - Generic Git Repositories - Gitops + + Generic Git Repositories +
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx index 9bf8874cc113..caf5d238b0ea 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx @@ -65,12 +65,6 @@ const GitProvidersList: React.FC = ({ data }) => { Name {item.node.displayName}
-
- - Application ID - - {item.node.applicationId} -
Status diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx index 4e2655d7e01e..20e34923969f 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx @@ -2,11 +2,9 @@ import * as React from 'react' import { zodResolver } from '@hookform/resolvers/zod' -import { isEmpty } from 'lodash-es' -import { useForm } from 'react-hook-form' +import { useForm, UseFormReturn } from 'react-hook-form' import * as z from 'zod' -import { Button } from '@/components/ui/button' import { Form, FormControl, @@ -16,12 +14,12 @@ import { FormLabel, FormMessage } from '@/components/ui/form' -import { IconGitHub, IconSpinner } from '@/components/ui/icons' +import { IconGitHub } from '@/components/ui/icons' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group' -const createGitProviderSchema = z.object({ +export const createGitProviderSchema = z.object({ provider: z.string(), displayName: z .string() @@ -33,33 +31,42 @@ const createGitProviderSchema = z.object({ accessToken: z.string() }) -const updateGitProviderSchema = createGitProviderSchema +export const updateGitProviderSchema = createGitProviderSchema .extend({ - accessToken: createGitProviderSchema.shape.accessToken.optional() + provider: createGitProviderSchema.shape.provider.optional() }) - .omit({ provider: true }) -interface GitProviderFormProps extends React.HTMLAttributes { +export type CreateGitProviderFormValues = z.infer +export type UpdateGitProviderFormValues = z.infer + +interface GitProviderFormProps { isNew?: boolean defaultValues?: Partial> + footer: React.ReactNode + onSubmit: ( + values: any + ) => Promise } -export const GitProviderForm: React.FC = ({ - className, - isNew, - defaultValues -}) => { +export const GitProviderForm = React.forwardRef< + { + form: UseFormReturn< + CreateGitProviderFormValues | UpdateGitProviderFormValues + > + }, + GitProviderFormProps +>(({ isNew, defaultValues, footer, onSubmit }, ref) => { const formSchema = isNew ? createGitProviderSchema : updateGitProviderSchema const form = useForm>({ resolver: zodResolver(formSchema), defaultValues }) - const { isSubmitting, dirtyFields } = form.formState - const isDirty = !isEmpty(dirtyFields) - const onSubmit = (values: z.infer) => { - // - } + React.useImperativeHandle(ref, () => { + return { + form + } + }, [form]) return (
@@ -147,7 +154,8 @@ export const GitProviderForm: React.FC = ({ )} /> -
+ {footer} + {/*
@@ -160,9 +168,11 @@ export const GitProviderForm: React.FC = ({ {isNew ? 'Create' : 'Update'}
-
+
*/}
) -} +}) + +GitProviderForm.displayName = 'GitProviderForm' diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx index 288b053f9582..337f97f048fb 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx @@ -112,9 +112,6 @@ const DetailPage: React.FC = () => { { - router.push('/settings/git/gitops') - }} id={id} />
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/provider-detail-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/provider-detail-form.tsx index 82311d539b2e..1842e16d49c6 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/provider-detail-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/provider-detail-form.tsx @@ -1,9 +1,6 @@ 'use client' import React from 'react' -import { zodResolver } from '@hookform/resolvers/zod' -import { isEmpty, trim } from 'lodash-es' -import { useForm } from 'react-hook-form' import { toast } from 'sonner' import * as z from 'zod' @@ -22,15 +19,12 @@ import { } from '@/components/ui/alert-dialog' import { Button, buttonVariants } from '@/components/ui/button' import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, FormMessage } from '@/components/ui/form' import { IconSpinner } from '@/components/ui/icons' -import { Input } from '@/components/ui/input' +import { GitProviderForm, UpdateGitProviderFormValues, updateGitProviderSchema } from '../../components/git-provider-form' +import { UseFormReturn } from 'react-hook-form' +import { isEmpty } from 'lodash-es' const deleteGithubRepositoryProviderMutation = graphql(/* GraphQL */ ` mutation DeleteGithubRepositoryProvider($id: ID!) { @@ -46,48 +40,34 @@ const updateGithubRepositoryProviderMutation = graphql(/* GraphQL */ ` } `) -export const formSchema = z.object({ - applicationId: z.string(), - displayName: z - .string() - .trim() - .regex( - /^[\w-]+$/, - 'Display name must contain only alphanumeric characters, underscores, and hyphens' - ), - secret: z.string().optional() -}) -type FormValues = z.infer +type FormValues = z.infer interface UpdateProviderFormProps { id: string defaultValues?: Partial onSuccess?: () => void onDelete: () => void - onBack: () => void } + export const UpdateProviderForm: React.FC = ({ defaultValues, onSuccess, onDelete, - onBack, id }) => { + const formRef = React.useRef<{ form: UseFormReturn }>(null) const [deleteAlertVisible, setDeleteAlertVisible] = React.useState(false) const [isDeleting, setIsDeleting] = React.useState(false) - const form = useForm({ - resolver: zodResolver(formSchema), - defaultValues - }) + const form = formRef.current?.form + const isSubmitting = form?.formState?.isSubmitting + const isDirty = !isEmpty(form?.formState?.dirtyFields) const deleteGithubRepositoryProvider = useMutation( deleteGithubRepositoryProviderMutation ) - const isDirty = !isEmpty(form.formState.dirtyFields) - const updateGithubRepositoryProvider = useMutation( updateGithubRepositoryProviderMutation, { @@ -95,7 +75,7 @@ export const UpdateProviderForm: React.FC = ({ onCompleted(values) { if (values?.updateGithubRepositoryProvider) { toast.success('Updated repository provider successfully') - form.reset(form.getValues()) + form?.reset(form?.getValues()) onSuccess?.() } } @@ -107,7 +87,6 @@ export const UpdateProviderForm: React.FC = ({ input: { id, ...values, - secret: trim(values.secret) || undefined } }) } @@ -135,109 +114,59 @@ export const UpdateProviderForm: React.FC = ({ } return ( -
-
- - ( - - Name - - - - - - )} - /> - ( - - Application ID - - - - - - )} - /> - ( - - Application secret - - - - - - )} - /> -
-
- - - - - - - - Are you absolutely sure? - - - This will delete the provider and remove any repositories - that have already been added to the provider. - - - - Cancel - - {isDeleting && ( - - )} - Yes, delete it - - - - - -
+ +
+ +
+
+ + + + + + + + Are you absolutely sure? + + + This will delete the provider and remove any repositories + that have already been added to the provider. + + + + Cancel + + {isDeleting && ( + + )} + Yes, delete it + + + + +
- - -
- +
+ )} + onSubmit={onSubmit} + /> ) } diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx index 446aee883f7c..1d7a826457af 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx @@ -9,9 +9,13 @@ import { client, useMutation } from '@/lib/tabby/gql' import { listGithubRepositoryProviders } from '@/lib/tabby/query' import { Button } from '@/components/ui/button' import { CardHeader, CardTitle } from '@/components/ui/card' -import { IconChevronLeft } from '@/components/ui/icons' +import { IconChevronLeft, IconSpinner } from '@/components/ui/icons' -import { GitProviderForm } from '../../components/git-provider-form' +import { CreateGitProviderFormValues, GitProviderForm, UpdateGitProviderFormValues } from '../../components/git-provider-form' +import { FormMessage } from '@/components/ui/form' +import React from 'react' +import { UseFormReturn } from 'react-hook-form' +import { omit } from 'lodash-es' const createGithubRepositoryProvider = graphql(/* GraphQL */ ` mutation CreateGithubRepositoryProvider( @@ -23,6 +27,8 @@ const createGithubRepositoryProvider = graphql(/* GraphQL */ ` export const NewProvider = () => { const router = useRouter() + const formRef = React.useRef<{ form: UseFormReturn }>(null) + const isSubmitting = formRef.current?.form?.formState?.isSubmitting const getProvider = (id: string) => { const queryProvider = client.createRequestOperation( @@ -32,24 +38,26 @@ export const NewProvider = () => { return client.executeQuery(queryProvider) } - // const createGithubRepositoryProviderMutation = useMutation( - // createGithubRepositoryProvider, - // { - // onCompleted(data) { - // if (data?.createGithubRepositoryProvider) { - // } - // }, - // onError(err) { - // toast.error(err?.message) - // }, - // form - // } - // ) + const createGithubRepositoryProviderMutation = useMutation( + createGithubRepositoryProvider, + { + onCompleted(data) { + if (data?.createGithubRepositoryProvider) { + toast.success('Provider created successfully') + router.replace('/settings/git/gitops') + } + }, + onError(err) { + toast.error(err?.message) + }, + form: formRef.current + } + ) - const handleSubmit = async () => { - // createGithubRepositoryProviderMutation({ - // input: values - // }) + const handleSubmit = async (values: CreateGitProviderFormValues) => { + return createGithubRepositoryProviderMutation({ + input: omit(values, 'provider') + }) } return ( @@ -62,13 +70,34 @@ export const NewProvider = () => { variant={'ghost'} className="px-1" > - + Create Git Provider
- + +
+ +
+
+ +
+ + )} + onSubmit={handleSubmit} + /> ) } diff --git a/ee/tabby-ui/lib/tabby/query.ts b/ee/tabby-ui/lib/tabby/query.ts index 0b62b5a466a4..3b630e042025 100644 --- a/ee/tabby-ui/lib/tabby/query.ts +++ b/ee/tabby-ui/lib/tabby/query.ts @@ -186,7 +186,6 @@ export const listGithubRepositoryProviders = graphql(/* GraphQL */ ` node { id displayName - applicationId connected } cursor From 184f0fc28fd12efa17083a59aa3d626325ad7bf3 Mon Sep 17 00:00:00 2001 From: liangfung <1098486429@qq.com> Date: Thu, 25 Apr 2024 19:45:28 +0800 Subject: [PATCH 03/20] remove useless component --- .../app/(dashboard)/components/sidebar.tsx | 3 +- .../git/generic/components/repository.tsx | 2 + .../git/generic/new/components/new-page.tsx | 22 ++- .../git/gitops/components/git-privoders.tsx | 32 ++-- .../gitops/components/git-provider-form.tsx | 33 ++-- .../git/gitops/detail/components/detail.tsx | 39 ++--- .../components/provider-detail-form.tsx | 39 ++--- .../git/gitops/new/components/new-page.tsx | 55 +++--- ee/tabby-ui/components/steps/steps.css | 24 --- ee/tabby-ui/components/steps/steps.tsx | 161 ------------------ ee/tabby-ui/lib/popup-window-management.ts | 125 -------------- 11 files changed, 129 insertions(+), 406 deletions(-) delete mode 100644 ee/tabby-ui/components/steps/steps.css delete mode 100644 ee/tabby-ui/components/steps/steps.tsx delete mode 100644 ee/tabby-ui/lib/popup-window-management.ts diff --git a/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx b/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx index 0d6f093440c8..b18eb876297c 100644 --- a/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx +++ b/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx @@ -136,7 +136,8 @@ function SidebarButton({ href, children }: SidebarButtonProps) { const pathname = usePathname() const isSelected = React.useMemo(() => { if (href === '/') return href === pathname - if (href === '/settings/git/gitops') return pathname.startsWith('/settings/git/') + if (href === '/settings/git/gitops') + return pathname.startsWith('/settings/git/') return shouldPathnameHighlight(pathname, href) }, [pathname, href]) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx index 249cead27011..614437a1923f 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx @@ -3,12 +3,14 @@ import Link from 'next/link' import { buttonVariants } from '@/components/ui/button' +import { CardTitle } from '@/components/ui/card' import RepositoryTable from './repository-table' export default function Repository() { return ( <> + Generic git repositories
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx index 52007ccc459b..b16bc7d2bff5 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx @@ -2,6 +2,10 @@ import { useRouter } from 'next/navigation' +import { Button } from '@/components/ui/button' +import { CardHeader, CardTitle } from '@/components/ui/card' +import { IconChevronLeft } from '@/components/ui/icons' + import RepositoryForm from './create-repository-form' export const NewRepository = () => { @@ -11,5 +15,21 @@ export const NewRepository = () => { router.replace('/settings/git/generic') } - return + return ( + <> + +
+ + Create Generic git repository +
+
+ + + ) } diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx index caf5d238b0ea..731161f75ed1 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx @@ -17,20 +17,26 @@ export default function GitProvidersPage() { const githubRepositoryProviders = data?.githubRepositoryProviders?.edges return ( - - {githubRepositoryProviders?.length ? ( -
- -
- - Create - + <> + Git Providers + + {githubRepositoryProviders?.length ? ( +
+ +
+ + Create + +
-
- ) : ( - - )} - + ) : ( + + )} + + ) } diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx index 20e34923969f..ea52d9f72235 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx @@ -31,21 +31,22 @@ export const createGitProviderSchema = z.object({ accessToken: z.string() }) -export const updateGitProviderSchema = createGitProviderSchema - .extend({ - provider: createGitProviderSchema.shape.provider.optional() - }) +export const updateGitProviderSchema = createGitProviderSchema.extend({ + provider: createGitProviderSchema.shape.provider.optional() +}) -export type CreateGitProviderFormValues = z.infer -export type UpdateGitProviderFormValues = z.infer +export type CreateGitProviderFormValues = z.infer< + typeof createGitProviderSchema +> +export type UpdateGitProviderFormValues = z.infer< + typeof updateGitProviderSchema +> interface GitProviderFormProps { isNew?: boolean defaultValues?: Partial> footer: React.ReactNode - onSubmit: ( - values: any - ) => Promise + onSubmit: (values: any) => Promise } export const GitProviderForm = React.forwardRef< @@ -62,11 +63,15 @@ export const GitProviderForm = React.forwardRef< defaultValues }) - React.useImperativeHandle(ref, () => { - return { - form - } - }, [form]) + React.useImperativeHandle( + ref, + () => { + return { + form + } + }, + [form] + ) return (
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx index 337f97f048fb..c5981a890899 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx @@ -85,28 +85,29 @@ const DetailPage: React.FC = () => { return ( - - -
+
+
-
- - GitHub.com -
- {provider?.connected ? ( - Connected - ) : ( - Not Connected - )} -
+ + + Provider information +
+
+ + GitHub.com +
+ {provider?.connected ? ( + Connected + ) : ( + Not Connected + )}
- - +
+ }> interface UpdateProviderFormProps { @@ -50,14 +52,15 @@ interface UpdateProviderFormProps { onDelete: () => void } - export const UpdateProviderForm: React.FC = ({ defaultValues, onSuccess, onDelete, id }) => { - const formRef = React.useRef<{ form: UseFormReturn }>(null) + const formRef = React.useRef<{ + form: UseFormReturn + }>(null) const [deleteAlertVisible, setDeleteAlertVisible] = React.useState(false) const [isDeleting, setIsDeleting] = React.useState(false) const form = formRef.current?.form @@ -86,7 +89,7 @@ export const UpdateProviderForm: React.FC = ({ await updateGithubRepositoryProvider({ input: { id, - ...values, + ...values } }) } @@ -117,7 +120,7 @@ export const UpdateProviderForm: React.FC = ({
@@ -134,9 +137,7 @@ export const UpdateProviderForm: React.FC = ({ - - Are you absolutely sure? - + Are you absolutely sure? This will delete the provider and remove any repositories that have already been added to the provider. @@ -149,23 +150,19 @@ export const UpdateProviderForm: React.FC = ({ onClick={handleDeleteRepositoryProvider} disabled={isDeleting} > - {isDeleting && ( - - )} + {isDeleting && } Yes, delete it
- )} + } onSubmit={onSubmit} /> ) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx index 1d7a826457af..59a13b2ed529 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx @@ -1,21 +1,25 @@ 'use client' +import React from 'react' import { useRouter } from 'next/navigation' import { createRequest } from '@urql/core' +import { omit } from 'lodash-es' +import { UseFormReturn } from 'react-hook-form' import { toast } from 'sonner' import { graphql } from '@/lib/gql/generates' import { client, useMutation } from '@/lib/tabby/gql' import { listGithubRepositoryProviders } from '@/lib/tabby/query' import { Button } from '@/components/ui/button' -import { CardHeader, CardTitle } from '@/components/ui/card' +import { CardTitle } from '@/components/ui/card' +import { FormMessage } from '@/components/ui/form' import { IconChevronLeft, IconSpinner } from '@/components/ui/icons' -import { CreateGitProviderFormValues, GitProviderForm, UpdateGitProviderFormValues } from '../../components/git-provider-form' -import { FormMessage } from '@/components/ui/form' -import React from 'react' -import { UseFormReturn } from 'react-hook-form' -import { omit } from 'lodash-es' +import { + CreateGitProviderFormValues, + GitProviderForm, + UpdateGitProviderFormValues +} from '../../components/git-provider-form' const createGithubRepositoryProvider = graphql(/* GraphQL */ ` mutation CreateGithubRepositoryProvider( @@ -27,7 +31,9 @@ const createGithubRepositoryProvider = graphql(/* GraphQL */ ` export const NewProvider = () => { const router = useRouter() - const formRef = React.useRef<{ form: UseFormReturn }>(null) + const formRef = React.useRef<{ + form: UseFormReturn + }>(null) const isSubmitting = formRef.current?.form?.formState?.isSubmitting const getProvider = (id: string) => { @@ -62,40 +68,35 @@ export const NewProvider = () => { return ( <> - - -
- - Create Git Provider -
-
-
+ +
+ + Create Git Provider +
+
-
- )} + } onSubmit={handleSubmit} /> diff --git a/ee/tabby-ui/components/steps/steps.css b/ee/tabby-ui/components/steps/steps.css deleted file mode 100644 index 30adbeece27c..000000000000 --- a/ee/tabby-ui/components/steps/steps.css +++ /dev/null @@ -1,24 +0,0 @@ -.steps-item-title { - position: relative; -} -.steps-item:not(:last-child) .steps-item-title::after { - position: absolute; - top: 1rem; - inset-inline-start: 100%; - display: block; - width: 9999px; - height: 1px; - background: hsl(var(--border)); - content: ""; -} - -.steps-item:last-child { - flex-grow: 0; -} - -.steps-item[data-state=finish] .steps-item-title::after { - background: hsl(var(--primary)); -} -.steps-item[data-state=error] .steps-item-title::after { - background: hsl(var(--destructive)); -} \ No newline at end of file diff --git a/ee/tabby-ui/components/steps/steps.tsx b/ee/tabby-ui/components/steps/steps.tsx deleted file mode 100644 index 72fcd243f96b..000000000000 --- a/ee/tabby-ui/components/steps/steps.tsx +++ /dev/null @@ -1,161 +0,0 @@ -import React from 'react' - -import { cn } from '@/lib/utils' - -import { IconCheck, IconClose } from '../ui/icons' - -import './steps.css' - -type StepStatus = 'current' | 'finish' | 'error' | 'loading' | 'wait' - -type SourceStepItem = { - title: string - description?: string - icon?: React.ReactNode - disabled?: boolean - status?: StepStatus -} - -type ComputedStepItem = SourceStepItem & { - status: StepStatus -} - -interface UseStepsReturn { - currentStep: number - steps: ComputedStepItem[] - setStep: (step: number) => void - // status for currentStep - status?: StepStatus -} - -interface StepsContextValue extends UseStepsReturn {} - -interface StepsProps extends UseStepsReturn { - children: React.ReactNode - className?: string -} - -const StepsContext = React.createContext( - {} as StepsContextValue -) - -const StepsContextProvider: React.FC = ({ - children, - className, - ...props -}) => { - return ( - -
{children}
-
- ) -} - -const Steps = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, children, ...props }, ref) => { - return ( -
- {children} -
- ) -}) -Steps.displayName = 'Steps' - -interface StepItemProps - extends Omit, 'title'>, - ComputedStepItem { - index: number -} - -const StepItem = React.forwardRef( - ({ className, children, ...props }, ref) => { - return ( -
-
- -
-
{props.title}
-
{props.description}
-
-
-
- ) - } -) -StepItem.displayName = 'StepItem' - -const StepIcon: React.FC< - Pick & { index: number } -> = ({ icon, index, status }) => { - const getIcon = () => { - if (icon) { - return icon - } - if (status === 'finish') { - return - } - if (status === 'error') { - return - } - return index + 1 - } - - return ( -
- {getIcon()} -
- ) -} - -interface UseStepsOptions { - items: SourceStepItem[] - initialStep?: number -} - -function useSteps(options: UseStepsOptions): UseStepsReturn { - const { items } = options - const [currentStep, setCurrentStep] = React.useState(options.initialStep || 0) - - const computedSteps = React.useMemo(() => { - return items.map((item, index) => { - const isPrevStep = index < currentStep - const isCurrentStep = index === currentStep - const computedStatusFromIndex = isPrevStep - ? 'finish' - : isCurrentStep - ? 'current' - : 'wait' - return { - ...item, - status: item.status || computedStatusFromIndex - } - }) - }, [items, currentStep]) - - return { - currentStep, - setStep: setCurrentStep, - steps: computedSteps - } -} - -export type { ComputedStepItem } - -export { StepsContextProvider, Steps, StepItem, useSteps } diff --git a/ee/tabby-ui/lib/popup-window-management.ts b/ee/tabby-ui/lib/popup-window-management.ts deleted file mode 100644 index 10316aea2ea1..000000000000 --- a/ee/tabby-ui/lib/popup-window-management.ts +++ /dev/null @@ -1,125 +0,0 @@ -import { useEffect, useRef } from 'react' - -interface PopupWindowManagementOptions { - popupUrl: string - width?: number - height?: number - onMessage?: (data: any) => any -} - -class PopupWindowManagement { - private popupUrl: string | undefined - private width: number - private height: number - private onMessage: ((data: any) => any) | void - private popup: Window | null - - constructor({ - popupUrl, - width = 600, - height = 700, - onMessage - }: PopupWindowManagementOptions) { - this.popupUrl = popupUrl - this.popup = null - this.onMessage = onMessage - this.width = width - this.height = height - window.addEventListener('message', this.handleMessage, false) - } - - destory() { - window.removeEventListener('message', this.handleMessage, false) - - this.close() - this.onMessage = undefined - } - - open() { - if (this.popup && !this.popup.closed) { - this.popup.focus() - return - } - - const left = window.screenX + (window.outerWidth - this.width) / 2 - const top = window.screenY + (window.outerHeight - this.height) / 2.5 - const windowFeatures = `toolbar=no, menubar=no, width=${this.width}, height=${this.height}, top=${top}, left=${left}` - this.popup = window.open(this.popupUrl, 'PopupWindow', windowFeatures) - } - - close() { - if (this.popup && !this.popup.closed) { - this.popup.close() - this.popup = null - } - } - - getPopupUrl() { - return this.popupUrl - } - - private handleMessage = (event: MessageEvent) => { - if (event.origin === window.origin) { - if (event.source === this.popup) { - const data = event.data - this.onMessage?.(data) - } - } - } -} - -const usePopupWindow = ( - options: Omit -) => { - const managementRef = useRef(null) - - const open = (url: string) => { - if (managementRef.current) { - const popupUrl = managementRef.current.getPopupUrl() - if (popupUrl === url) { - managementRef.current.open() - } else { - managementRef.current.destory() - managementRef.current = new PopupWindowManagement({ - ...options, - popupUrl: url - }) - managementRef.current.open() - } - } else { - managementRef.current = new PopupWindowManagement({ - ...options, - popupUrl: url - }) - managementRef.current.open() - } - } - - const close = () => { - managementRef.current?.close() - } - - const destory = () => { - if (managementRef.current) { - managementRef.current.destory() - managementRef.current = null - } - } - - useEffect(() => { - return () => { - if (managementRef.current) { - managementRef.current.destory() - managementRef.current = null - } - } - }, []) - - return { - open, - close, - destory - } -} - -export { usePopupWindow, PopupWindowManagement } From 27fec4f72a4f10000e4329e6c2271c625a675038 Mon Sep 17 00:00:00 2001 From: liangfung <1098486429@qq.com> Date: Thu, 25 Apr 2024 19:49:17 +0800 Subject: [PATCH 04/20] format --- .../(integrations)/git/generic/components/repository.tsx | 2 +- .../(integrations)/git/generic/new/components/new-page.tsx | 2 +- .../(integrations)/git/gitops/components/git-privoders.tsx | 2 +- .../(integrations)/git/gitops/detail/components/detail.tsx | 2 +- .../(integrations)/git/gitops/new/components/new-page.tsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx index 614437a1923f..7ba0ea6b65fe 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx @@ -10,7 +10,7 @@ import RepositoryTable from './repository-table' export default function Repository() { return ( <> - Generic git repositories + Generic git repositories
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx index b16bc7d2bff5..a837cd7e8907 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx @@ -17,7 +17,7 @@ export const NewRepository = () => { return ( <> - +
Create Generic git repository
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx index ea52d9f72235..191fd2c710bb 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx @@ -98,7 +98,7 @@ export const GitProviderForm = React.forwardRef< className="flex cursor-pointer items-center gap-1" htmlFor="github" > - + GitHub.com
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx index d3a2f95285a9..a411331f6d51 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx @@ -90,14 +90,14 @@ const DetailPage: React.FC = () => { Provider information
- + GitHub.com
{provider?.connected ? ( diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx index baff1543c7ee..2459e9dca4bd 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx @@ -73,9 +73,9 @@ export const NewProvider = () => { Create Git Provider
From 63e13ac8785628ab19d446eb4bb8bc2de599d79f Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 11:56:56 +0000 Subject: [PATCH 07/20] [autofix.ci] apply automated fixes --- .../(integrations)/git/generic/new/components/new-page.tsx | 2 +- .../(integrations)/git/gitops/detail/components/detail.tsx | 2 +- .../(integrations)/git/gitops/new/components/new-page.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx index 87f217b51ed6..8e0bf4baf407 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx @@ -22,7 +22,7 @@ export const NewRepository = () => { diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx index a411331f6d51..c53865f6e1d6 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx @@ -90,7 +90,7 @@ const DetailPage: React.FC = () => { diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx index 2459e9dca4bd..39a25afd4a83 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx @@ -73,7 +73,7 @@ export const NewProvider = () => { From 7d5144050f635a367a665a3682511aeebbf7b7b3 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 25 Apr 2024 14:06:20 -0700 Subject: [PATCH 08/20] restructure-repository-providers --- .../app/(dashboard)/components/sidebar.tsx | 9 ++--- .../git/generic/new/components/new-page.tsx | 35 ------------------- .../(integrations)/git/generic/page.tsx | 5 --- .../(integrations)/git/gitops/page.tsx | 5 --- .../components/tabs-header.tsx | 12 +++---- .../git/components/git.tsx} | 6 ++-- .../git}/components/repository-table.tsx | 0 .../generic => repository/git}/layout.tsx | 0 .../new/components/create-repository-form.tsx | 16 +++++---- .../git/new/components/new-page.tsx | 19 ++++++++++ .../generic => repository/git}/new/page.tsx | 0 .../(integrations)/repository/git/page.tsx | 11 ++++++ .../github/components/github-form.tsx} | 0 .../github/components/github.tsx} | 5 +-- .../github}/detail/components/detail.tsx | 0 .../detail/components/new-repository-form.tsx | 0 .../components/provider-detail-form.tsx | 0 .../github}/detail/page.tsx | 0 .../github}/detail/query.ts | 0 .../gitops => repository/github}/layout.tsx | 0 .../github}/new/components/new-page.tsx | 2 +- .../gitops => repository/github}/new/page.tsx | 0 .../(integrations)/repository/github/page.tsx | 11 ++++++ .../{git => repository}/layout.tsx | 0 ee/tabby-ui/lib/tabby/gql.ts | 6 ++-- 25 files changed, 68 insertions(+), 74 deletions(-) delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/page.tsx delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/page.tsx rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git => repository}/components/tabs-header.tsx (59%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/generic/components/repository.tsx => repository/git/components/git.tsx} (56%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/generic => repository/git}/components/repository-table.tsx (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/generic => repository/git}/layout.tsx (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/generic => repository/git}/new/components/create-repository-form.tsx (90%) create mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/components/new-page.tsx rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/generic => repository/git}/new/page.tsx (100%) create mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/gitops/components/git-provider-form.tsx => repository/github/components/github-form.tsx} (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/gitops/components/git-privoders.tsx => repository/github/components/github.tsx} (96%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/gitops => repository/github}/detail/components/detail.tsx (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/gitops => repository/github}/detail/components/new-repository-form.tsx (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/gitops => repository/github}/detail/components/provider-detail-form.tsx (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/gitops => repository/github}/detail/page.tsx (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/gitops => repository/github}/detail/query.ts (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/gitops => repository/github}/layout.tsx (100%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/gitops => repository/github}/new/components/new-page.tsx (98%) rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git/gitops => repository/github}/new/page.tsx (100%) create mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/page.tsx rename ee/tabby-ui/app/(dashboard)/settings/(integrations)/{git => repository}/layout.tsx (100%) diff --git a/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx b/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx index b18eb876297c..25e136d728a1 100644 --- a/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx +++ b/ee/tabby-ui/app/(dashboard)/components/sidebar.tsx @@ -94,8 +94,8 @@ export default function Sidebar({ children, className }: SidebarProps) { } > - - Git Providers + + Repository Providers SSO @@ -136,8 +136,9 @@ function SidebarButton({ href, children }: SidebarButtonProps) { const pathname = usePathname() const isSelected = React.useMemo(() => { if (href === '/') return href === pathname - if (href === '/settings/git/gitops') - return pathname.startsWith('/settings/git/') + if (href.startsWith('/settings/repository/github')) { + return pathname.startsWith('/settings/repository/') + } return shouldPathnameHighlight(pathname, href) }, [pathname, href]) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx deleted file mode 100644 index 8e0bf4baf407..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/new-page.tsx +++ /dev/null @@ -1,35 +0,0 @@ -'use client' - -import { useRouter } from 'next/navigation' - -import { Button } from '@/components/ui/button' -import { CardTitle } from '@/components/ui/card' -import { IconChevronLeft } from '@/components/ui/icons' - -import RepositoryForm from './create-repository-form' - -export const NewRepository = () => { - const router = useRouter() - - const onCreated = () => { - router.replace('/settings/git/generic') - } - - return ( - <> - -
- - Create Generic git repository -
-
- - - ) -} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/page.tsx deleted file mode 100644 index b7de7b5a06c0..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/page.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import Repository from './components/repository' - -export default function Generic() { - return -} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/page.tsx deleted file mode 100644 index 3afafba648bc..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/page.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import GitProvidersPage from './components/git-privoders' - -export default function Gitops() { - return -} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/tabs-header.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx similarity index 59% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/tabs-header.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx index 63c359e7bf93..e51ec10486c0 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/components/tabs-header.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx @@ -7,19 +7,17 @@ import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs' export default function GitTabsHeader() { const pathname = usePathname() - const defualtValue = pathname.startsWith('/settings/git/generic') - ? 'generic' - : 'gitops' + const defualtValue = pathname.indexOf('github') >= 0 ? 'github' : 'git' return (
- - Gitops + + Git - - Generic Git Repositories + + Github
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/components/git.tsx similarity index 56% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/components/git.tsx index 7ba0ea6b65fe..29a7e35b4015 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/components/git.tsx @@ -3,17 +3,15 @@ import Link from 'next/link' import { buttonVariants } from '@/components/ui/button' -import { CardTitle } from '@/components/ui/card' import RepositoryTable from './repository-table' -export default function Repository() { +export default function Git() { return ( <> - Generic git repositories
- + Create
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository-table.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/components/repository-table.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/components/repository-table.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/components/repository-table.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/layout.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/layout.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/layout.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/layout.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/create-repository-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/components/create-repository-form.tsx similarity index 90% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/create-repository-form.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/components/create-repository-form.tsx index 2cf0a21261e8..953b3a3acff7 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/components/create-repository-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/components/create-repository-form.tsx @@ -1,7 +1,7 @@ 'use client' import * as React from 'react' -import Link from 'next/link' +import { useRouter } from 'next/navigation' import { zodResolver } from '@hookform/resolvers/zod' import { useForm } from 'react-hook-form' import * as z from 'zod' @@ -48,6 +48,7 @@ export default function CreateRepositoryForm({ form }) + const router = useRouter() return (
@@ -93,11 +94,14 @@ export default function CreateRepositoryForm({ )} />
- - - + diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/components/new-page.tsx new file mode 100644 index 000000000000..6ac774d515bc --- /dev/null +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/components/new-page.tsx @@ -0,0 +1,19 @@ +'use client' + +import { useRouter } from 'next/navigation' + +import RepositoryForm from './create-repository-form' + +export const NewRepository = () => { + const router = useRouter() + + const onCreated = () => { + router.back() + } + + return ( + <> + + + ) +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/page.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/generic/new/page.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/page.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx new file mode 100644 index 000000000000..6ad5b3d09995 --- /dev/null +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx @@ -0,0 +1,11 @@ +import { Metadata } from 'next' + +import Git from './components/git' + +export const metadata: Metadata = { + title: 'Git Repositories' +} + +export default function Generic() { + return +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-provider-form.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx similarity index 96% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx index 3885c01ce63d..df6a4a264f02 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/components/git-privoders.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx @@ -92,10 +92,7 @@ const GitProvidersPlaceholder = () => {
No Data
- + Create
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/detail.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/new-repository-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/new-repository-form.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/new-repository-form.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/new-repository-form.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/provider-detail-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/provider-detail-form.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/components/provider-detail-form.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/provider-detail-form.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/page.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/query.ts b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/query.ts similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/detail/query.ts rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/query.ts diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/layout.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/layout.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/layout.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/layout.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx similarity index 98% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx index 39a25afd4a83..adcd4803ea3d 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/components/new-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx @@ -19,7 +19,7 @@ import { CreateGitProviderFormValues, GitProviderForm, UpdateGitProviderFormValues -} from '../../components/git-provider-form' +} from '../../components/github-form' const createGithubRepositoryProvider = graphql(/* GraphQL */ ` mutation CreateGithubRepositoryProvider( diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/page.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/gitops/new/page.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/page.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/page.tsx new file mode 100644 index 000000000000..cce57dc7e5ef --- /dev/null +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/page.tsx @@ -0,0 +1,11 @@ +import { Metadata } from 'next' + +import GithubPage from './components/github' + +export const metadata: Metadata = { + title: 'Git Providers' +} + +export default function Github() { + return +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/layout.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/layout.tsx similarity index 100% rename from ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/layout.tsx rename to ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/layout.tsx diff --git a/ee/tabby-ui/lib/tabby/gql.ts b/ee/tabby-ui/lib/tabby/gql.ts index 4a76235dbceb..b68c2f660098 100644 --- a/ee/tabby-ui/lib/tabby/gql.ts +++ b/ee/tabby-ui/lib/tabby/gql.ts @@ -138,11 +138,11 @@ const client = new Client({ }) } }, - deleteRepository(result, args, cache, info) { - if (result.deleteRepository) { + deleteGitRepository(result, args, cache, info) { + if (result.deleteGitRepository) { cache .inspectFields('Query') - .filter(field => field.fieldName === 'repositories') + .filter(field => field.fieldName === 'gitRepositories') .forEach(field => { cache.updateQuery( { From 0c6b508924afdc07e0593f4749aa29438b96f1dc Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 25 Apr 2024 14:09:49 -0700 Subject: [PATCH 09/20] consolidate layouts --- .../(integrations)/repository/git/layout.tsx | 28 ------------------- .../repository/github/layout.tsx | 28 ------------------- .../(integrations)/repository/layout.tsx | 18 ++++++++++-- 3 files changed, 16 insertions(+), 58 deletions(-) delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/layout.tsx delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/layout.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/layout.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/layout.tsx deleted file mode 100644 index 889de16c4b4b..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/layout.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react' - -import { SubHeader } from '@/components/sub-header' - -const Header = ({ className }: { className?: string }) => { - return ( - - Connect to Git repositories and uses these repositories as a context to - enhance performance of large language model. - - ) -} - -export default function GenericGitRepositoriesLayout({ - children -}: { - children: React.ReactNode -}) { - return ( - <> -
- {children} - - ) -} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/layout.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/layout.tsx deleted file mode 100644 index af160e1dc51f..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/layout.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react' - -import { SubHeader } from '@/components/sub-header' - -const Header = ({ className }: { className?: string }) => { - return ( - - Connect to Git repositories and uses these repositories as a context to - enhance performance of large language model. - - ) -} - -export default function GitProvidersLayout({ - children -}: { - children: React.ReactNode -}) { - return ( - <> -
- {children} - - ) -} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/layout.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/layout.tsx index 2713fff737d2..07e9eade0595 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/layout.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/layout.tsx @@ -1,9 +1,23 @@ -import GitTabsHeader from './components/tabs-header' +import { SubHeader } from '@/components/sub-header' +import RepositoryTabsHeader from './components/tabs-header' + +const Header = ({ className }: { className?: string }) => { + return ( + + Connect to Git repositories and uses these repositories as a context to + enhance performance of large language model. + + ) +} export default function GitLayout({ children }: { children: React.ReactNode }) { return ( <> - +
+ {children} ) From 24127f9fda9b3b1aa1ac610301b895eeb740e8d5 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 25 Apr 2024 14:45:37 -0700 Subject: [PATCH 10/20] adjust ux --- .../settings/(integrations)/git/git/page.tsx | 5 + .../repository/components/tabs-header.tsx | 4 +- .../repository/git/new/page.tsx | 5 - .../(integrations)/repository/git/page.tsx | 5 - .../github/components/github-form.tsx | 81 +++---------- .../repository/github/components/github.tsx | 21 ++-- .../github/detail/components/detail.tsx | 113 +++++++++--------- .../detail/components/new-repository-form.tsx | 19 +-- .../components/provider-detail-form.tsx | 19 ++- .../github/new/components/new-page.tsx | 38 +++--- .../repository/github/new/page.tsx | 5 - .../(integrations)/repository/github/page.tsx | 5 - .../(integrations)/repository/layout.tsx | 7 ++ 13 files changed, 125 insertions(+), 202 deletions(-) create mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/git/page.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/git/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/git/page.tsx new file mode 100644 index 000000000000..b7de7b5a06c0 --- /dev/null +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/git/page.tsx @@ -0,0 +1,5 @@ +import Repository from './components/repository' + +export default function Generic() { + return +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx index e51ec10486c0..d58b02ba6434 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx @@ -14,10 +14,10 @@ export default function GitTabsHeader() {
- Git + Git - Github + GitHub
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/page.tsx index eefd0fee06a1..d7d952f27b2d 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/page.tsx @@ -1,11 +1,6 @@ -import { Metadata } from 'next' import { NewRepository } from './components/new-page' -export const metadata: Metadata = { - title: 'New Repository' -} - export default function IndexPage() { return } diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx index 6ad5b3d09995..2a2f7570d3b1 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx @@ -1,11 +1,6 @@ -import { Metadata } from 'next' import Git from './components/git' -export const metadata: Metadata = { - title: 'Git Repositories' -} - export default function Generic() { return } diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx index 191fd2c710bb..d5d3e4803a0f 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx @@ -14,12 +14,9 @@ import { FormLabel, FormMessage } from '@/components/ui/form' -import { IconGitHub } from '@/components/ui/icons' import { Input } from '@/components/ui/input' -import { Label } from '@/components/ui/label' -import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group' -export const createGitProviderSchema = z.object({ +export const createGithubProviderSchema = z.object({ provider: z.string(), displayName: z .string() @@ -31,33 +28,35 @@ export const createGitProviderSchema = z.object({ accessToken: z.string() }) -export const updateGitProviderSchema = createGitProviderSchema.extend({ - provider: createGitProviderSchema.shape.provider.optional() +export const updateGithubProviderSchema = createGithubProviderSchema.extend({ + provider: createGithubProviderSchema.shape.provider.optional() }) -export type CreateGitProviderFormValues = z.infer< - typeof createGitProviderSchema +export type CreateGithubProviderFormValues = z.infer< + typeof createGithubProviderSchema > -export type UpdateGitProviderFormValues = z.infer< - typeof updateGitProviderSchema +export type UpdateGithubProviderFormValues = z.infer< + typeof updateGithubProviderSchema > -interface GitProviderFormProps { +interface GithubProviderFormProps { isNew?: boolean - defaultValues?: Partial> + defaultValues?: Partial> footer: React.ReactNode onSubmit: (values: any) => Promise } -export const GitProviderForm = React.forwardRef< +export const GithubProviderForm = React.forwardRef< { form: UseFormReturn< - CreateGitProviderFormValues | UpdateGitProviderFormValues + CreateGithubProviderFormValues | UpdateGithubProviderFormValues > }, - GitProviderFormProps + GithubProviderFormProps >(({ isNew, defaultValues, footer, onSubmit }, ref) => { - const formSchema = isNew ? createGitProviderSchema : updateGitProviderSchema + const formSchema = isNew + ? createGithubProviderSchema + : updateGithubProviderSchema const form = useForm>({ resolver: zodResolver(formSchema), defaultValues @@ -77,38 +76,6 @@ export const GitProviderForm = React.forwardRef<
- {isNew && ( - ( - - Choose Git provider - - -
- - -
-
-
- -
- )} - /> - )} {footer} - {/*
-
- -
-
- -
-
*/}
) }) -GitProviderForm.displayName = 'GitProviderForm' +GithubProviderForm.displayName = 'GithubProviderForm' diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx index df6a4a264f02..a3372dcf7df4 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx @@ -18,16 +18,12 @@ export default function GitProvidersPage() { return ( <> - Git Providers {githubRepositoryProviders?.length ? (
- + Create
@@ -54,12 +50,12 @@ const GitProvidersList: React.FC = ({ data }) => {
- - GitHub.com + + {item.node.displayName}
View @@ -76,7 +72,9 @@ const GitProvidersList: React.FC = ({ data }) => { Status - {item.node?.connected ? 'Connected' : 'Not Connected'} + {item.node?.connected + ? 'Connected' + : 'access_token needs update'}
@@ -92,7 +90,10 @@ const GitProvidersPlaceholder = () => {
No Data
- + Create
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx index c53865f6e1d6..763bdb39a218 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx @@ -2,7 +2,6 @@ import React, { useEffect, useMemo, useState } from 'react' import { useRouter, useSearchParams } from 'next/navigation' -import { toast } from 'sonner' import { useQuery } from 'urql' import { DEFAULT_PAGE_SIZE } from '@/lib/constants' @@ -13,7 +12,7 @@ import { } from '@/lib/tabby/query' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' -import { CardContent, CardHeader, CardTitle } from '@/components/ui/card' +import { CardContent, CardTitle } from '@/components/ui/card' import { Dialog, DialogContent, @@ -22,7 +21,11 @@ import { DialogTitle, DialogTrigger } from '@/components/ui/dialog' -import { IconChevronLeft, IconGitHub, IconTrash } from '@/components/ui/icons' +import { + IconChevronLeft, + IconPlus, + IconTrash +} from '@/components/ui/icons' import { Table, TableBody, @@ -52,29 +55,14 @@ const DetailPage: React.FC = () => { pause: !id }) const provider = data?.githubRepositoryProviders?.edges?.[0]?.node - const [githubRepositories, fetchingRepositories] = + const [githubRepositories, isGithubRepositoriesLoading] = useAllProvidedRepositories(id) console.log(githubRepositories) - const [open, setOpen] = React.useState(false) - - const onCreated = () => { - toast.success('Added successfully') - setOpen(false) - } - const onDeleteProvider = () => { - router.replace('/settings/git/gitops') + router.back() } - const unlinkedRepos = useMemo(() => { - return githubRepositories?.filter(item => !item.node.active) - }, [githubRepositories]) - - const linkedRepos = useMemo(() => { - return githubRepositories?.filter(item => item.node.active) - }, [githubRepositories]) - if (!id || (!!id && !fetching && !provider)) { return (
@@ -85,7 +73,7 @@ const DetailPage: React.FC = () => { return ( - +
- Provider information + {provider?.displayName}
- - GitHub.com
{provider?.connected ? ( Connected @@ -108,7 +94,7 @@ const DetailPage: React.FC = () => {
- + }> { - - - Repositories - - - - Add repository - - Add a new repository to this provider. - - - setOpen(false)} - onCreated={onCreated} - repositories={unlinkedRepos} - fetchingRepositories={fetchingRepositories} - /> - - - - - - - - - - +
+ + - +
) } @@ -179,19 +141,54 @@ const LinkedRepoTable: React.FC<{ }) } + const [open, setOpen] = React.useState(false) + + const onCreated = () => { + setOpen(false) + } + + const linkedRepos = useMemo(() => { + return data?.filter(item => item.node.active) + }, [data]) + + const unlinkedRepos = useMemo(() => { + return data?.filter(item => !item.node.active) + }, [data]) + return ( - +
Name - Git URL - + URL + + + + + Add new repository + + Add new GitHub repository from this provider + + + setOpen(false)} + onCreated={onCreated} + repositories={unlinkedRepos} + /> + + + + + + - {data?.length ? ( + {linkedRepos?.length ? ( <> - {data?.map(x => { + {linkedRepos?.map(x => { return ( {x.node.name} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/new-repository-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/new-repository-form.tsx index 22287d6c871c..7d739595349a 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/new-repository-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/new-repository-form.tsx @@ -22,13 +22,11 @@ import { FormControl, FormField, FormItem, - FormLabel, FormMessage } from '@/components/ui/form' import { IconCheck, - IconChevronUpDown, - IconSpinner + IconChevronUpDown } from '@/components/ui/icons' import { Popover, @@ -47,8 +45,7 @@ type LinkRepositoryFormValues = z.infer export default function LinkRepositoryForm({ onCreated, onCancel, - repositories, - fetchingRepositories + repositories }: { onCreated?: () => void onCancel: () => void @@ -57,7 +54,6 @@ export default function LinkRepositoryForm({ typeof listGithubRepositories >['githubRepositories']['edges'] | undefined - fetchingRepositories: boolean }) { const [open, setOpen] = React.useState(false) const form = useForm({ @@ -94,7 +90,6 @@ export default function LinkRepositoryForm({ name="id" render={({ field }) => ( - Repository @@ -123,15 +118,7 @@ export default function LinkRepositoryForm({ - - {fetchingRepositories ? ( -
- -
- ) : ( - 'No repository found.' - )} -
+ No repository found. {repositories?.map(repo => ( +type FormValues = z.infer interface UpdateProviderFormProps { id: string @@ -59,7 +59,7 @@ export const UpdateProviderForm: React.FC = ({ id }) => { const formRef = React.useRef<{ - form: UseFormReturn + form: UseFormReturn }>(null) const [deleteAlertVisible, setDeleteAlertVisible] = React.useState(false) const [isDeleting, setIsDeleting] = React.useState(false) @@ -102,22 +102,21 @@ export const UpdateProviderForm: React.FC = ({ try { const res = await deleteGithubRepositoryProvider({ id }) if (res?.data?.deleteGithubRepositoryProvider) { - toast.success('Deleted repository provider successfully') onDelete?.() } else { toast.error( - res?.error?.message || 'Failed to delete repository provider' + res?.error?.message || 'Failed to delete github repository provider' ) } } catch (error) { - toast.error('Failed to delete repository provider') + toast.error('Failed to delete github repository provider') } finally { setIsDeleting(false) } } return ( - { const router = useRouter() const formRef = React.useRef<{ - form: UseFormReturn + form: UseFormReturn }>(null) const isSubmitting = formRef.current?.form?.formState?.isSubmitting @@ -49,8 +48,7 @@ export const NewProvider = () => { { onCompleted(data) { if (data?.createGithubRepositoryProvider) { - toast.success('Provider created successfully') - router.replace('/settings/git/gitops') + router.back() } }, onError(err) { @@ -60,7 +58,7 @@ export const NewProvider = () => { } ) - const handleSubmit = async (values: CreateGitProviderFormValues) => { + const handleSubmit = async (values: CreateGithubProviderFormValues) => { return createGithubRepositoryProviderMutation({ input: omit(values, 'provider') }) @@ -68,19 +66,7 @@ export const NewProvider = () => { return ( <> - -
- - Create Git Provider -
-
- {
+
- + + ) }) GithubProviderForm.displayName = 'GithubProviderForm' + +function ExternalLink({ href, children }: { href: string, children: React.ReactNode }) { + return + {children} + + +} \ No newline at end of file diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx index 763bdb39a218..f439e42aedd7 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react' import { useRouter, useSearchParams } from 'next/navigation' +import { toast } from 'sonner' import { useQuery } from 'urql' import { DEFAULT_PAGE_SIZE } from '@/lib/constants' @@ -12,7 +13,7 @@ import { } from '@/lib/tabby/query' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' -import { CardContent, CardTitle } from '@/components/ui/card' +import { CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Dialog, DialogContent, @@ -21,11 +22,7 @@ import { DialogTitle, DialogTrigger } from '@/components/ui/dialog' -import { - IconChevronLeft, - IconPlus, - IconTrash -} from '@/components/ui/icons' +import { IconChevronLeft, IconGitHub, IconPlus, IconTrash } from '@/components/ui/icons' import { Table, TableBody, @@ -40,6 +37,7 @@ import { ListSkeleton } from '@/components/skeleton' import { updateGithubProvidedRepositoryActiveMutation } from '../query' import LinkRepositoryForm from './new-repository-form' import { UpdateProviderForm } from './provider-detail-form' +import { Separator } from '@/components/ui/separator' type GithubRepositories = QueryResponseData< typeof listGithubRepositories @@ -161,7 +159,7 @@ const LinkedRepoTable: React.FC<{ Name URL - + @@ -177,11 +175,10 @@ const LinkedRepoTable: React.FC<{ /> - + + diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx index 7e2adffaa09f..384f11ad634b 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx @@ -2,10 +2,6 @@ import { Metadata } from 'next' import ProviderDetail from './components/detail' -export const metadata: Metadata = { - title: 'New Provider' -} - export default function IndexPage() { return } diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx index b6de0096d691..d54a8047c5b7 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx @@ -65,7 +65,7 @@ export const NewProvider = () => { } return ( - <> +
{
-
+
) } diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/layout.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/layout.tsx index 34d59df785c5..582ff3d7e8b6 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/layout.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/layout.tsx @@ -21,7 +21,7 @@ export default function GitLayout({ children }: { children: React.ReactNode }) { <>
- {children} +
{children}
) } From 0035535a29f15df5d2467ef1fbb8aa947cc7d853 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 25 Apr 2024 15:09:38 -0700 Subject: [PATCH 12/20] fix spacing --- .../repository/github/components/github.tsx | 9 ++------- .../sso/components/oauth-credential-list.tsx | 6 +++--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx index a3372dcf7df4..c1024bc6a6b7 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx @@ -50,7 +50,6 @@ const GitProvidersList: React.FC = ({ data }) => {
- {item.node.displayName}
@@ -62,12 +61,8 @@ const GitProvidersList: React.FC = ({ data }) => {
- -
- Name - {item.node.displayName} -
-
+ +
Status diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/sso/components/oauth-credential-list.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/sso/components/oauth-credential-list.tsx index e09e7a18b22b..855261782658 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/sso/components/oauth-credential-list.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/sso/components/oauth-credential-list.tsx @@ -130,12 +130,12 @@ const OauthCredentialCard = ({
- -
+ +
Type OAuth 2.0
-
+
Domain {meta?.domain}
From 488311939d5a2dca23e3b2cf7f4247252a781ca3 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 25 Apr 2024 15:10:29 -0700 Subject: [PATCH 13/20] update --- .../(integrations)/repository/components/tabs-header.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx index d58b02ba6434..b7c3047af179 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx @@ -4,6 +4,7 @@ import Link from 'next/link' import { usePathname } from 'next/navigation' import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs' +import { IconGitHub } from '@/components/ui/icons' export default function GitTabsHeader() { const pathname = usePathname() @@ -17,7 +18,7 @@ export default function GitTabsHeader() { Git - GitHub + GitHub
From b8202025cd69ed064aaa173847fb7cd644699e38 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 25 Apr 2024 15:14:08 -0700 Subject: [PATCH 14/20] fix ui --- .../repository/components/tabs-header.tsx | 7 ++- .../repository/git/new/page.tsx | 1 - .../(integrations)/repository/git/page.tsx | 1 - .../github/components/github-form.tsx | 45 ++++++++++++------- .../repository/github/components/github.tsx | 1 - .../github/detail/components/detail.tsx | 17 ++++--- .../detail/components/new-repository-form.tsx | 5 +-- .../repository/github/detail/page.tsx | 1 - .../github/new/components/new-page.tsx | 4 +- .../repository/github/new/page.tsx | 1 - .../(integrations)/repository/github/page.tsx | 1 - .../(integrations)/repository/layout.tsx | 2 +- .../sso/components/oauth-credential-list.tsx | 2 +- 13 files changed, 49 insertions(+), 39 deletions(-) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx index b7c3047af179..18585b8e41c7 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/components/tabs-header.tsx @@ -3,8 +3,8 @@ import Link from 'next/link' import { usePathname } from 'next/navigation' -import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs' import { IconGitHub } from '@/components/ui/icons' +import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs' export default function GitTabsHeader() { const pathname = usePathname() @@ -18,7 +18,10 @@ export default function GitTabsHeader() { Git - GitHub + + + GitHub +
diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/page.tsx index d7d952f27b2d..b06ad0722e21 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/new/page.tsx @@ -1,4 +1,3 @@ - import { NewRepository } from './components/new-page' export default function IndexPage() { diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx index 2a2f7570d3b1..eb59397f42b7 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/git/page.tsx @@ -1,4 +1,3 @@ - import Git from './components/git' export default function Generic() { diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx index f857a33b5801..8080d8fbce64 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx @@ -1,6 +1,7 @@ 'use client' import * as React from 'react' +import Link from 'next/link' import { zodResolver } from '@hookform/resolvers/zod' import { useForm, UseFormReturn } from 'react-hook-form' import * as z from 'zod' @@ -14,9 +15,8 @@ import { FormLabel, FormMessage } from '@/components/ui/form' -import { Input } from '@/components/ui/input' -import Link from 'next/link' import { IconExternalLink } from '@/components/ui/icons' +import { Input } from '@/components/ui/input' export const createGithubProviderSchema = z.object({ provider: z.string(), @@ -108,9 +108,14 @@ export const GithubProviderForm = React.forwardRef< Personal Access Token
- Create a dedicated service user and generate a fine-grained personal access token with the member role for the organization or all projects to be managed. + Create a dedicated service user and generate a{' '} + + fine-grained personal access + {' '} + token with the member role for the organization or all + projects to be managed.
-
• Contents (Read-only)
+
• Contents (Read-only)
{footer} -
- +
+ ) }) GithubProviderForm.displayName = 'GithubProviderForm' -function ExternalLink({ href, children }: { href: string, children: React.ReactNode }) { - return - {children} - - -} \ No newline at end of file +function ExternalLink({ + href, + children +}: { + href: string + children: React.ReactNode +}) { + return ( + + {children} + + + ) +} diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx index c1024bc6a6b7..0535c097248c 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github.tsx @@ -7,7 +7,6 @@ import { ListGithubRepositoryProvidersQuery } from '@/lib/gql/generates/graphql' import { listGithubRepositoryProviders } from '@/lib/tabby/query' import { buttonVariants } from '@/components/ui/button' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' -import { IconGitHub } from '@/components/ui/icons' import LoadingWrapper from '@/components/loading-wrapper' export default function GitProvidersPage() { diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx index f439e42aedd7..763bdb39a218 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx @@ -2,7 +2,6 @@ import React, { useEffect, useMemo, useState } from 'react' import { useRouter, useSearchParams } from 'next/navigation' -import { toast } from 'sonner' import { useQuery } from 'urql' import { DEFAULT_PAGE_SIZE } from '@/lib/constants' @@ -13,7 +12,7 @@ import { } from '@/lib/tabby/query' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' -import { CardContent, CardHeader, CardTitle } from '@/components/ui/card' +import { CardContent, CardTitle } from '@/components/ui/card' import { Dialog, DialogContent, @@ -22,7 +21,11 @@ import { DialogTitle, DialogTrigger } from '@/components/ui/dialog' -import { IconChevronLeft, IconGitHub, IconPlus, IconTrash } from '@/components/ui/icons' +import { + IconChevronLeft, + IconPlus, + IconTrash +} from '@/components/ui/icons' import { Table, TableBody, @@ -37,7 +40,6 @@ import { ListSkeleton } from '@/components/skeleton' import { updateGithubProvidedRepositoryActiveMutation } from '../query' import LinkRepositoryForm from './new-repository-form' import { UpdateProviderForm } from './provider-detail-form' -import { Separator } from '@/components/ui/separator' type GithubRepositories = QueryResponseData< typeof listGithubRepositories @@ -159,7 +161,7 @@ const LinkedRepoTable: React.FC<{ Name URL - + @@ -175,10 +177,11 @@ const LinkedRepoTable: React.FC<{ /> - + - diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/new-repository-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/new-repository-form.tsx index 7d739595349a..f1d76bca2be2 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/new-repository-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/new-repository-form.tsx @@ -24,10 +24,7 @@ import { FormItem, FormMessage } from '@/components/ui/form' -import { - IconCheck, - IconChevronUpDown -} from '@/components/ui/icons' +import { IconCheck, IconChevronUpDown } from '@/components/ui/icons' import { Popover, PopoverContent, diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx index 384f11ad634b..2b546fe267f6 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx @@ -1,4 +1,3 @@ -import { Metadata } from 'next' import ProviderDetail from './components/detail' diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx index d54a8047c5b7..b5e352138155 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx @@ -65,7 +65,7 @@ export const NewProvider = () => { } return ( -
+
{
-
+
-
+
Type OAuth 2.0
From 7348e5a439ca030d45b080f0f13ec1d75dbe763a Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 25 Apr 2024 15:14:23 -0700 Subject: [PATCH 15/20] update --- .../repository/github/detail/components/detail.tsx | 6 +----- .../(integrations)/repository/github/detail/page.tsx | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx index 763bdb39a218..1581cf1c4fa0 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx @@ -21,11 +21,7 @@ import { DialogTitle, DialogTrigger } from '@/components/ui/dialog' -import { - IconChevronLeft, - IconPlus, - IconTrash -} from '@/components/ui/icons' +import { IconChevronLeft, IconPlus, IconTrash } from '@/components/ui/icons' import { Table, TableBody, diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx index 2b546fe267f6..a631dd12d106 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/page.tsx @@ -1,4 +1,3 @@ - import ProviderDetail from './components/detail' export default function IndexPage() { From c448073f3685043900ef0165873083d4608db445 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 25 Apr 2024 15:22:05 -0700 Subject: [PATCH 16/20] update --- .../repository/github/detail/components/detail.tsx | 4 +--- .../github/detail/components/provider-detail-form.tsx | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx index 1581cf1c4fa0..716342fe884a 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx @@ -51,9 +51,7 @@ const DetailPage: React.FC = () => { pause: !id }) const provider = data?.githubRepositoryProviders?.edges?.[0]?.node - const [githubRepositories, isGithubRepositoriesLoading] = - useAllProvidedRepositories(id) - console.log(githubRepositories) + const [githubRepositories, isGithubRepositoriesLoading] = useAllProvidedRepositories(id) const onDeleteProvider = () => { router.back() diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/provider-detail-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/provider-detail-form.tsx index 55a60c16298e..b5ba2479dc01 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/provider-detail-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/provider-detail-form.tsx @@ -77,7 +77,7 @@ export const UpdateProviderForm: React.FC = ({ form, onCompleted(values) { if (values?.updateGithubRepositoryProvider) { - toast.success('Updated repository provider successfully') + toast.success('Updated GitHub repository provider successfully') form?.reset(form?.getValues()) onSuccess?.() } @@ -105,11 +105,11 @@ export const UpdateProviderForm: React.FC = ({ onDelete?.() } else { toast.error( - res?.error?.message || 'Failed to delete github repository provider' + res?.error?.message || 'Failed to delete GitHub repository provider' ) } } catch (error) { - toast.error('Failed to delete github repository provider') + toast.error('Failed to delete GitHub repository provider') } finally { setIsDeleting(false) } From 817ca98c6f29cf33ed0e69ccf52433cc15960c25 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 25 Apr 2024 15:25:31 -0700 Subject: [PATCH 17/20] update --- .../repository/github/components/github-form.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx index 8080d8fbce64..9297f715d6d3 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx @@ -19,7 +19,6 @@ import { IconExternalLink } from '@/components/ui/icons' import { Input } from '@/components/ui/input' export const createGithubProviderSchema = z.object({ - provider: z.string(), displayName: z .string() .trim() @@ -31,7 +30,6 @@ export const createGithubProviderSchema = z.object({ }) export const updateGithubProviderSchema = createGithubProviderSchema.extend({ - provider: createGithubProviderSchema.shape.provider.optional() }) export type CreateGithubProviderFormValues = z.infer< @@ -105,7 +103,7 @@ export const GithubProviderForm = React.forwardRef< name="accessToken" render={({ field }) => ( - Personal Access Token + Personal Access Token
Create a dedicated service user and generate a{' '} From 96cc53881a862e46a817f38cc8b1ca2b947a748d Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 22:26:42 +0000 Subject: [PATCH 18/20] [autofix.ci] apply automated fixes --- .../repository/github/components/github-form.tsx | 3 +-- .../repository/github/detail/components/detail.tsx | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx index 9297f715d6d3..a2015493a17b 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/components/github-form.tsx @@ -29,8 +29,7 @@ export const createGithubProviderSchema = z.object({ accessToken: z.string() }) -export const updateGithubProviderSchema = createGithubProviderSchema.extend({ -}) +export const updateGithubProviderSchema = createGithubProviderSchema.extend({}) export type CreateGithubProviderFormValues = z.infer< typeof createGithubProviderSchema diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx index 716342fe884a..5427f9251f5f 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/detail/components/detail.tsx @@ -51,7 +51,8 @@ const DetailPage: React.FC = () => { pause: !id }) const provider = data?.githubRepositoryProviders?.edges?.[0]?.node - const [githubRepositories, isGithubRepositoriesLoading] = useAllProvidedRepositories(id) + const [githubRepositories, isGithubRepositoriesLoading] = + useAllProvidedRepositories(id) const onDeleteProvider = () => { router.back() From d3b7483a4f7d20c30305677ff7676d38bf8788d2 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 25 Apr 2024 15:30:05 -0700 Subject: [PATCH 19/20] remove usless file --- .../app/(dashboard)/settings/(integrations)/git/git/page.tsx | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/git/page.tsx diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/git/page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/git/page.tsx deleted file mode 100644 index b7de7b5a06c0..000000000000 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/git/git/page.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import Repository from './components/repository' - -export default function Generic() { - return -} From d4faa7a576d5c28494c82afc6ee5e2b825872187 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 25 Apr 2024 15:31:21 -0700 Subject: [PATCH 20/20] update --- .../repository/github/new/components/new-page.tsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx index b5e352138155..dc78637d0aca 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/(integrations)/repository/github/new/components/new-page.tsx @@ -2,14 +2,12 @@ import React from 'react' import { useRouter } from 'next/navigation' -import { createRequest } from '@urql/core' import { omit } from 'lodash-es' import { UseFormReturn } from 'react-hook-form' import { toast } from 'sonner' import { graphql } from '@/lib/gql/generates' -import { client, useMutation } from '@/lib/tabby/gql' -import { listGithubRepositoryProviders } from '@/lib/tabby/query' +import { useMutation } from '@/lib/tabby/gql' import { Button } from '@/components/ui/button' import { FormMessage } from '@/components/ui/form' import { IconSpinner } from '@/components/ui/icons' @@ -35,14 +33,6 @@ export const NewProvider = () => { }>(null) const isSubmitting = formRef.current?.form?.formState?.isSubmitting - const getProvider = (id: string) => { - const queryProvider = client.createRequestOperation( - 'query', - createRequest(listGithubRepositoryProviders, { ids: [id] }) - ) - return client.executeQuery(queryProvider) - } - const createGithubRepositoryProviderMutation = useMutation( createGithubRepositoryProvider, { @@ -69,7 +59,6 @@ export const NewProvider = () => {