Files
1127c4ba88 Project Level Permissions (#27347)
* fix: update Permission params

* fix: upgrade check permission hook to support project level role

* fix: usePermissionsLoaded

* fix: Permission params can be undefined

* Scaffold new access management UI

* Add validation

* Update roles view

* Add tooltip

* Add button to apply role to all projects

* Update UI to select projects first instead of roles

* Merge master update UI

* Midway trying to implementation project level perms API

* First pass implementating updating project level permissions

* Add client side validation for assigning/removing roles

* Midway implementing new invites

* Integrate most of the project level permissions functionality

* fix: filter out org-level permissions before checking

* Add relevant UI guards in org level pages for project role POV

* Minor refactors

* Small refactors

* More fixes

* Moar refactors

* More fixes

* More fixes

* Refactor update role logic and smack some test cases on it

* Fixes

* Fix type issue

* Fix type

* more fixes, refactors, adding checks...

* MORE fixes

* Add perms checking for replicas

* Add ButtonTooltip component and use them to prevent repetition of pointer events auto for buttons with tooltips

* Convert all buttons with tooltips to use ButtonTooltip

* refactor

* PRettier

* Small fix

* Remove commented out code in organization-invitation-accept-mutation

* fix: switch to use the platform oauth authorizations routes

* Add perms checking for org audit logs and org oauth apps

* PRettier

* Fix incorrect URL for oauth app flow

* Fix incorrect URL for oauth app flow

* Fix

* Add perms checking for warehouse related UI

* Update roles helper icon

* remove unused lib

* Update package lock... again

* Update package lock... again

* Smalllll update

* Update some checks

* Add gate for project level permissions

* Last fix

* update codegen

* Update warehouse endpoint routes

* Fix

---------

Co-authored-by: phamhieu <phamhieu1998@gmail.com>
Co-authored-by: Alaister Young <a@alaisteryoung.com>
2024-07-01 17:59:54 +08:00

122 lines
4.7 KiB
TypeScript

import {
Button,
Input,
Input_Shadcn_,
Label_Shadcn_,
CollapsibleContent_Shadcn_,
CollapsibleTrigger_Shadcn_,
Collapsible_Shadcn_,
IconChevronDown,
} from 'ui'
import Link from 'next/link'
import Panel from 'components/ui/Panel'
import { useSession } from 'lib/auth'
import type { Profile } from 'data/profile/types'
import { ChevronDown } from 'lucide-react'
const AccountInformation = ({ profile }: { profile?: Profile }) => {
const session = useSession()
return (
<Panel
title={
<h5 key="panel-title" className="mb-0">
Account Information
</h5>
}
>
<Panel.Content>
<div className="grid gap-4">
<div className="grid grid-cols-12 gap-6">
<Label_Shadcn_ className="col-span-4 text-foreground-light">Username</Label_Shadcn_>
<Input_Shadcn_
className="col-span-8"
readOnly
disabled
placeholder="Username"
value={profile?.username ?? ''}
/>
</div>
<div className="grid grid-cols-12 gap-6">
<Label_Shadcn_ className="col-span-4 text-foreground-light">Email</Label_Shadcn_>
<div className="col-span-8">
<Input_Shadcn_
className="w-full"
readOnly
disabled
placeholder="Email"
value={profile?.primary_email ?? ''}
/>
<div className="col-span-8 mt-4">
<Collapsible_Shadcn_ className="-mt-1.5 pb-1.5">
<CollapsibleTrigger_Shadcn_ className="group font-normal p-0 [&[data-state=open]>div>svg]:!-rotate-180">
<div className="flex items-center gap-x-2 w-full">
<p className="text-xs text-foreground-light group-hover:text-foreground transition">
How can I change my email?
</p>
<ChevronDown
className="transition-transform duration-200"
strokeWidth={1.5}
size={14}
/>
</div>
</CollapsibleTrigger_Shadcn_>
<CollapsibleContent_Shadcn_ className=" mt-2">
<div className="bg-surface-200 p-4 rounded-lg grid gap-4">
{session?.user.app_metadata.provider === 'email' ? (
<div>
<ol className="text-sm ml-4 pl-2 list-decimal">
<li>Create a new account with the new email</li>
<li>Invite this email to be an owner of the Org</li>
<li>Join the Org</li>
<li>Remove the old email from the Org</li>
<li>Email Supabase Support to delete the old email (Optional) </li>
</ol>
</div>
) : (
<div>
<ol className="text-sm ml-4 pl-2 list-decimal">
<li>Log out of Supabase</li>
<li>
Change your Primary Email in{' '}
<Link href="https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-email-preferences/changing-your-primary-email-address">
GitHub
</Link>{' '}
(your public, not primary email)
</li>
<li>Log out of GitHub</li>
<li>
Log back into GitHub (with the new, desired email set as primary)
</li>
<li>Log back into Supabase</li>
</ol>
</div>
)}
</div>
</CollapsibleContent_Shadcn_>
</Collapsible_Shadcn_>
</div>
</div>
</div>
{session?.user.app_metadata.provider === 'email' && (
<div className="text-sm grid gap-2 md:grid md:grid-cols-12 md:gap-x-4">
<div className="flex flex-col space-y-2 col-span-4 ">
<p className="text-foreground-light break-all">Password</p>
</div>
<div className="col-span-8">
<Button asChild type="default">
<Link href="/reset-password">Reset password</Link>
</Button>
</div>
</div>
)}
</div>
</Panel.Content>
</Panel>
)
}
export default AccountInformation