Skip to content

Commit

Permalink
Add dashboard page
Browse files Browse the repository at this point in the history
Can only edit content and navigate through files/directories at this time.
  • Loading branch information
arthur-fontaine committed Jun 18, 2023
1 parent 21e9322 commit 97ef0bf
Show file tree
Hide file tree
Showing 22 changed files with 3,223 additions and 629 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"private": true,
"workspaces": [
"apps/*",
"packages/*"
"packages/*",
"examples/*"
],
"scripts": {
"build": "turbo run build",
Expand All @@ -20,8 +21,10 @@
"@commitlint/cli": "^17.2.0",
"@commitlint/config-conventional": "^17.2.0",
"@tsconfig/strictest": "^2.0.1",
"@whitebird/eslint-config": "latest",
"@whitebird/eslint-config": "1.0.0-beta.1",
"@whitebird/tsconfig": "latest",
"esbuild": "*",
"eslint": "^8.42.0",
"husky": "^8.0.0",
"turbo": "latest",
"typescript": "^4.8.4"
Expand Down
9 changes: 8 additions & 1 deletion packages/octent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,30 @@
},
"dependencies": {
"@hookform/resolvers": "^3.1.0",
"@isomorphic-git/lightning-fs": "^4.6.0",
"@nangohq/frontend": "^0.17.3",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-select": "^1.2.2",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tabs": "^1.0.4",
"@tanstack/router": "0.0.1-beta.89",
"class-variance-authority": "^0.6.0",
"clsx": "^1.2.1",
"isomorphic-git": "^1.24.0",
"lucide-react": "^0.233.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.44.3",
"react-router-dom": "^6.11.2",
"tailwind-merge": "^1.13.0",
"tailwindcss-animate": "^1.0.5",
"zod": "^3.21.4",
"zustand": "^4.3.8"
},
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@types/isomorphic-git__lightning-fs": "^4.4.4",
"@types/react": "^18.0.37",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.59.0",
Expand Down
95 changes: 15 additions & 80 deletions packages/octent/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,97 +1,32 @@
import React from 'react'
import {
Outlet,
RootRoute,
Route,
Router,
RouterProvider,
} from '@tanstack/router'
import React, { useCallback, useContext } from 'react'
createBrowserRouter,
} from 'react-router-dom'

import './globals.css'

import { OctentOptionsContext, OctentOptionsProvider } from './contexts/octent-options-context'
import { useAuth } from './hooks/use-auth'
import { OctentOptionsProvider } from './contexts/octent-options-context'
import { HttpsGitAuthenticationPage } from './pages/authentication/https-git-authentication-page'
import { DashboardPage } from './pages/dashboard/dashboard-page'

import type { OctentOptions } from '.'

// import { GithubAuthenticationPage } from './pages/authentication/github-authentication-page'

function navigate(url: Exclude<Parameters<typeof router.getRoute>[0], '__root__'>) {
location.href = url
}

function Root() {
const renavigate = useCallback((type: string) => {
if (type !== 'none')
// navigate('/dashboard')
console.log('Navigate to dashboard')
else
navigate('/')
}, [])

useAuth.subscribe((state) => {
renavigate(state.type)
})

const authenticationType = useAuth(state => state.type)
renavigate(authenticationType)

return <Outlet />
}

const rootRoute = new RootRoute({
component: Root,
})

function Index() {
const options = useContext(OctentOptionsContext)

const parsedRepositoryUrl = new URL(options.repositoryUrl)

switch (parsedRepositoryUrl.hostname) {
// case 'github.com': {
// console.error('GitHub authentication is not supported yet')
// }
default: {
if (parsedRepositoryUrl.protocol === 'https:')
navigate('/authentication/other')

if (parsedRepositoryUrl.protocol === 'ssh:')
console.error('SSH authentication is not supported yet')
}
}

return <></>
}

const indexRoute = new Route({
path: '/',
component: Index,
getParentRoute: () => rootRoute,
})

const httpsGitAuthenticationRoute = new Route({
path: '/authentication/other',
component: HttpsGitAuthenticationPage,
getParentRoute: () => rootRoute,
})

const routeTree = rootRoute.addChildren([
indexRoute,
httpsGitAuthenticationRoute,
const router = createBrowserRouter([
{
path: '/authentication/other',
element: <HttpsGitAuthenticationPage />,
},
{
path: '/dashboard/*?',
element: <DashboardPage />,
},
])

const router = new Router({ routeTree })

declare module '@tanstack/router' {
interface Register {
router: typeof router
}
}

function App(props: OctentOptions) {
return <div className="App bg-background text-foreground h-screen w-screen">
return <div className="App bg-background text-foreground w-auto h-auto">
<OctentOptionsProvider value={props}>
<RouterProvider router={router} />
</OctentOptionsProvider>
Expand Down
42 changes: 42 additions & 0 deletions packages/octent/src/components/breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { ChevronRight } from 'lucide-react'
import React from 'react'
import { Link } from 'react-router-dom'

import { cn } from '@/lib/utils'

export function Breadcrumb({ path, className = '' }: { path: string[]; className?: string }) {
return (
<div className={
cn(
'mb-4 flex items-center space-x-1 text-sm text-muted-foreground',
className,
)
}>
{
path.slice(0, -1).map((pathPart, index) => (
<BreadcrumbItem
key={index}
pathPart={pathPart}
link={
new URL(`${location.href.replace(/\/$/, '')}/${'../'.repeat(path.length - index - 1)}`).pathname
}
/>
))
}
<div className="font-medium text-foreground">{path.at(-1)}</div>
</div>
)
}

function BreadcrumbItem({ pathPart, link }: { pathPart: string; link: string }) {
return (
<>
<Link to={link} className="flex items-center space-x-1 hover:underline">
<div className="overflow-hidden text-ellipsis whitespace-nowrap">
{pathPart}
</div>
</Link>
<ChevronRight className="h-4 w-4" />
</>
)
}
2 changes: 1 addition & 1 deletion packages/octent/src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Slot } from '@radix-ui/react-slot'
import { type VariantProps, cva } from 'class-variance-authority'
import * as React from 'react'

import { cn } from '@/lib/utils'
import { cn } from '@/lib/utils/cn'

const buttonVariants = cva(
'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-background',
Expand Down
2 changes: 1 addition & 1 deletion packages/octent/src/components/ui/card.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react"

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils/cn"

const Card = React.forwardRef<
HTMLDivElement,
Expand Down
128 changes: 128 additions & 0 deletions packages/octent/src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
"use client"

import * as React from "react"
import * as DialogPrimitive from "@radix-ui/react-dialog"
import { X } from "lucide-react"

import { cn } from "@/lib/utils"

const Dialog = DialogPrimitive.Root

const DialogTrigger = DialogPrimitive.Trigger

const DialogPortal = ({
className,
children,
...props
}: DialogPrimitive.DialogPortalProps) => (
<DialogPrimitive.Portal className={cn(className)} {...props}>
<div className="fixed inset-0 z-50 flex items-start justify-center sm:items-center">
{children}
</div>
</DialogPrimitive.Portal>
)
DialogPortal.displayName = DialogPrimitive.Portal.displayName

const DialogOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
className={cn(
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm transition-all duration-100 data-[state=closed]:animate-out data-[state=closed]:fade-out data-[state=open]:fade-in",
className
)}
{...props}
/>
))
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName

const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
ref={ref}
className={cn(
"fixed z-50 grid w-full gap-4 rounded-b-lg border bg-background p-6 shadow-lg animate-in data-[state=open]:fade-in-90 data-[state=open]:slide-in-from-bottom-10 sm:max-w-lg sm:rounded-lg sm:zoom-in-90 data-[state=open]:sm:slide-in-from-bottom-0",
className
)}
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
</DialogPortal>
))
DialogContent.displayName = DialogPrimitive.Content.displayName

const DialogHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-1.5 text-center sm:text-left",
className
)}
{...props}
/>
)
DialogHeader.displayName = "DialogHeader"

const DialogFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className
)}
{...props}
/>
)
DialogFooter.displayName = "DialogFooter"

const DialogTitle = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Title
ref={ref}
className={cn(
"text-lg font-semibold leading-none tracking-tight",
className
)}
{...props}
/>
))
DialogTitle.displayName = DialogPrimitive.Title.displayName

const DialogDescription = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Description
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
))
DialogDescription.displayName = DialogPrimitive.Description.displayName

export {
Dialog,
DialogTrigger,
DialogContent,
DialogHeader,
DialogFooter,
DialogTitle,
DialogDescription,
}
2 changes: 1 addition & 1 deletion packages/octent/src/components/ui/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from 'react-hook-form'

import { Label } from '@/components/ui/label'
import { cn } from '@/lib/utils'
import { cn } from '@/lib/utils/cn'

const Form = FormProvider

Expand Down
2 changes: 1 addition & 1 deletion packages/octent/src/components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react"

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils/cn"

export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}
Expand Down
14 changes: 7 additions & 7 deletions packages/octent/src/components/ui/label.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"use client"
'use client'

import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"
import { cva, type VariantProps } from "class-variance-authority"
import * as LabelPrimitive from '@radix-ui/react-label'
import { type VariantProps, cva } from 'class-variance-authority'
import * as React from 'react'

import { cn } from "@/lib/utils"
import { cn } from '@/lib/utils/cn'

const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
)

const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants>
VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
<LabelPrimitive.Root
ref={ref}
Expand Down
Loading

0 comments on commit 97ef0bf

Please sign in to comment.