mirror of
https://github.com/supabase/supabase.git
synced 2026-07-04 17:24:20 +08:00
* 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>
77 lines
2.4 KiB
TypeScript
77 lines
2.4 KiB
TypeScript
import { useRouter } from 'next/router'
|
|
|
|
import AlertError from 'components/ui/AlertError'
|
|
import { OrganizationInviteByToken } from 'data/organization-members/organization-invitation-token-query'
|
|
import { useSignOut } from 'lib/auth'
|
|
import { useProfile } from 'lib/profile'
|
|
import { ResponseError } from 'types'
|
|
import { cn } from 'ui'
|
|
|
|
interface OrganizationInviteError {
|
|
data?: OrganizationInviteByToken
|
|
error?: ResponseError
|
|
isError: boolean
|
|
}
|
|
|
|
export const OrganizationInviteError = ({ data, error, isError }: OrganizationInviteError) => {
|
|
const router = useRouter()
|
|
const signOut = useSignOut()
|
|
const { profile } = useProfile()
|
|
|
|
const hasError =
|
|
isError || data?.token_does_not_exist || data?.expired_token || !data?.email_match
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'flex flex-col items-center justify-center gap-y-1 text-sm',
|
|
hasError ? 'text-foreground-light' : 'text-foreground'
|
|
)}
|
|
>
|
|
{isError ? (
|
|
<AlertError
|
|
error={error}
|
|
subject="Failed to retrieve token"
|
|
className="[&>h5]:text-left [&>div]:items-start rounded-t-none"
|
|
/>
|
|
) : data?.token_does_not_exist ? (
|
|
<>
|
|
<p>The invite token is invalid.</p>
|
|
<p className="text-foreground-lighter">
|
|
Try copying and pasting the link from the invite email, or ask the organization owner to
|
|
invite you again.
|
|
</p>
|
|
</>
|
|
) : !data?.email_match ? (
|
|
<>
|
|
<p>
|
|
Your email address {profile?.primary_email} does not match the email address this
|
|
invitation was sent to.
|
|
</p>
|
|
<p className="text-foreground-lighter">
|
|
To accept this invitation, you will need to{' '}
|
|
<a
|
|
className="cursor-pointer text-brand"
|
|
onClick={async () => {
|
|
await signOut()
|
|
router.reload()
|
|
}}
|
|
>
|
|
sign out
|
|
</a>{' '}
|
|
and then sign in or create a new account using the same email address used in the
|
|
invitation.
|
|
</p>
|
|
</>
|
|
) : data.expired_token ? (
|
|
<>
|
|
<p>The invite token has expired.</p>
|
|
<p className="text-foreground-lighter">
|
|
Please request a new one from the organization owner.
|
|
</p>
|
|
</>
|
|
) : null}
|
|
</div>
|
|
)
|
|
}
|