Skip to content

Commit

Permalink
Teams Features (#99)
Browse files Browse the repository at this point in the history
* Update README.md

* Teams (#97)

* Add prisma adapter. Remove unused code. Add session & accounts data in database.

* Update prisma scheme to allow teams

* Remove unused files in favour of CSS classes

* Add team name

* Add util for getting current user

* Update dashboard route name

* Add dialog to create team

* Ensure github username, name and email are stored upon auth

* Ensure user id is accessible in session

* Automatically create team upon new user sign in. Add option to create new teams and route accordingly.

* Redirect after team is successfully created

* Add route for settings & add option to delete team

* Ensure nav works correctly. Add route to handle team settings. Add placeholder button.

* Fetch projects for a team

* Ensure only projects per team are fetched

* Update schema to track requests for adding projects

* Add button to create project

* Break up github webhook into smaller files. Ensure team id is matched with relevant project.

* Update lockfile

* Ensure all pathname work. Rename repo to project for consistency.

* Refactor instructions

* Remove unused code

* Add slug to projects

* Make sure all routes are consistent

* Ensure feedback works. Allow longer feedback input.

* Fix

* Fix nav

* Fix

* Add back commented code

* Update stripe API route

* Update env variable name

* Fix

* Fix

* Fix

* Update schema for clarity

* Rename files, remove unnecessary toasts

* Ensure search works

* Add team slug to usage redirects. Rename repo to project for consistency.

* UI fixes

* Make sure all nav components are consistent

* Update README.md

* Schema commit

* migration schema (#98)

* migration schema

* onboarding flow for next-auth

* onboard legacy projects

* only connect orphaned projects

* reinstall

* set rubric ts pack at latest

---------

Co-authored-by: Dexter Storey <36115192+DexterStorey@users.noreply.github.com>
Co-authored-by: DexterStorey <dexter@dexterstorey.com>

---------

Co-authored-by: Sarim Malik <sarim@rubriclabs.com>
  • Loading branch information
DexterStorey and sarimrmalik authored Jan 29, 2024
1 parent a9b096d commit 36fcd40
Show file tree
Hide file tree
Showing 83 changed files with 1,452 additions and 801 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
}
}
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Maige

_Staging2_

Repo maintenance made simpler.

Quickly set up Maige and let AI handle your issue labels with ease. Get started at [Maige.app](https://maige.app).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Toaster} from 'sonner'
import {MainNavigation} from '~/components/dashboard/Navigation'
import MainNav from '~/components/dashboard/Navigation/MainNav'

export default async function RootLayout({
children
Expand All @@ -9,7 +9,7 @@ export default async function RootLayout({
return (
<div className='space-y-4'>
<Toaster position='bottom-right' />
<MainNavigation />
<MainNav />
<div className='z-10 h-full w-full'>{children}</div>
</div>
)
Expand Down
34 changes: 34 additions & 0 deletions app/[slug]/(base)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {redirect} from 'next/navigation'
import {Suspense} from 'react'
import Projects from '~/components/dashboard/Projects/ProjectsList'
import {getCurrentUser} from '~/utils/session'

export default async function Dashboard({params}: {params: {slug: string}}) {
const user = await getCurrentUser()
if (!user) redirect('/')

const team = await prisma.team.findUnique({
where: {slug: params.slug},
select: {id: true}
})
const projects = await prisma.project.findMany({
where: {
teamId: team.id
},
include: {
instructions: true
}
})

return (
<div className='flex flex-col items-center'>
<Suspense fallback={<p>Loading...</p>}>
<Projects
teamId={team.id}
slug={params.slug}
projects={projects}
/>
</Suspense>
</div>
)
}
15 changes: 15 additions & 0 deletions app/[slug]/(base)/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {TrashIcon} from 'lucide-react'
import {Button} from '~/components/ui/button'

export default function Settings() {
return (
<div className='flex h-full w-full flex-col gap-4'>
<h3>Settings</h3>
<Button
className='w-fit'
variant='destructive'>
Delete team <TrashIcon className='h-4 w-4' />
</Button>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default async function RootLayout({
}: {
children: React.ReactNode
params: {
slug: string
metric: string[] | undefined
}
}) {
Expand All @@ -24,7 +25,10 @@ export default async function RootLayout({

return (
<div className='space-y-2'>
<ChartsLinks route={route} />
<ChartsLinks
teamSlug={params.slug}
route={route}
/>
<div className='space-y-5'>
<UsageCharts route={route} />
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ export default async function Usage({
}: {
searchParams: {[key: string]: string | string[] | undefined}
params: {
slug: string
metric: string[] | undefined
}
}) {
const route = params.metric ? params.metric[0] : ''

return (
<UsageTable
teamSlug={params.slug}
route={route}
searchParams={searchParams}
/>
Expand Down
34 changes: 34 additions & 0 deletions app/[slug]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import DashboardHeader from '~/components/dashboard/Navigation/DashboardHeader'
import {getCurrentUser} from '~/utils/session'

async function Teams() {
const user = await getCurrentUser()
if (!user) return <></>

const teams = await prisma.membership
.findMany({
where: {userId: user.id},
select: {team: true}
})
.then(memberships => memberships.map(m => m.team))

return (
<DashboardHeader
user={user}
teams={teams}
/>
)
}

export default async function RootLayout({
children
}: {
children: React.ReactNode
}) {
return (
<div className='relative min-h-screen w-full px-8'>
<Teams />
<div className='w-full'>{children}</div>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,40 @@ import {Instructions} from '~/components/dashboard/Instructions'
import {PanelSkeletons} from '~/components/dashboard/Loader'
import prisma from '~/prisma'

export default async function Page({params}: {params: {projectId: string}}) {
export default async function Page({
params
}: {
params: {projectId: string; slug: string}
}) {
return (
<Suspense fallback={<PanelSkeletons amount={3} />}>
<div className='flex w-full flex-col gap-8'>
<div className='text-2xl font-medium'>Custom Instructions</div>
<InstructionsWrapper projectId={params.projectId} />
<h3>Instructions</h3>
<InstructionsWrapper
teamSlug={params.slug}
projectId={params.projectId}
/>
</div>
</Suspense>
)
}

async function InstructionsWrapper({projectId}: {projectId: string}) {
async function InstructionsWrapper({
projectId,
teamSlug
}: {
projectId: string
teamSlug: string
}) {
const instructions = await prisma.instruction.findMany({
where: {
projectId
projectId: projectId
}
})

return (
<Instructions
teamSlug={teamSlug}
projectId={projectId}
instructions={instructions}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import {getServerSession} from 'next-auth'
import {redirect} from 'next/navigation'
import {authOptions} from '~/authOptions'
import {RepoNavigation} from '~/components/dashboard/Navigation/RepoNavigation'
import ProjectNav from '~/components/dashboard/Navigation/ProjectNav'

export default async function Layout({
params,
children
}: {
params: {projectId: string}
params: {slug: string; projectId: string}
children: React.ReactNode
}) {
const session = await getServerSession(authOptions)
if (!session) redirect('/dashboard')
if (!session) redirect('/')

return (
<div className='space-y-4'>
<RepoNavigation />
<ProjectNav
projectId={params.projectId}
repoSlug={params.slug}
/>
<div className='z-10 h-full w-full'>{children}</div>
</div>
)
Expand Down
10 changes: 10 additions & 0 deletions app/[slug]/project/[projectId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default async function Page({params}: {params: {projectId: string}}) {
const project = await prisma.project.findUnique({
where: {id: params.projectId}
})
return (
<div className='flex flex-col gap-4'>
<h3>{project.name}</h3>
</div>
)
}
15 changes: 15 additions & 0 deletions app/[slug]/project/[projectId]/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {TrashIcon} from 'lucide-react'
import {Button} from '~/components/ui/button'

export default function Settings() {
return (
<div className='flex h-full w-full flex-col gap-4'>
<h3>Settings</h3>
<Button
variant='destructive'
className='w-fit'>
Delete project <TrashIcon className='h-4 w-4' />
</Button>
</div>
)
}
Loading

1 comment on commit 36fcd40

@vercel
Copy link

@vercel vercel bot commented on 36fcd40 Jan 29, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.