mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
* feat(ci): fix typos * [create-pull-request] automated change * Update index.tsx * Update README.fr.md * Create .misspell-fixer.ignore * Update constant.dart * [create-pull-request] automated change * Update database.tsx * [create-pull-request] automated change * [create-pull-request] automated change Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { useRouter } from 'next/router'
|
|
import { observer } from 'mobx-react-lite'
|
|
import { Button, Dropdown, Divider, IconPlus } from 'ui'
|
|
|
|
import { useStore } from 'hooks'
|
|
import { IS_PLATFORM } from 'lib/constants'
|
|
|
|
const OrgDropdown = () => {
|
|
const router = useRouter()
|
|
const { app, ui } = useStore()
|
|
|
|
const sortedOrganizations: any[] = app.organizations.list()
|
|
const selectedOrganization: any = ui.selectedOrganization
|
|
|
|
return IS_PLATFORM ? (
|
|
<Dropdown
|
|
side="bottom"
|
|
align="start"
|
|
overlay={
|
|
<>
|
|
{sortedOrganizations
|
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
.map((x) => (
|
|
<Dropdown.Item key={x.slug} onClick={() => router.push(`/org/${x.slug}/settings`)}>
|
|
{x.name}
|
|
</Dropdown.Item>
|
|
))}
|
|
<Dropdown.Separator />
|
|
<Dropdown.Item icon={<IconPlus size="tiny" />} onClick={() => router.push(`/new`)}>
|
|
New organization
|
|
</Dropdown.Item>
|
|
</>
|
|
}
|
|
>
|
|
<Button as="span" type="text" size="tiny">
|
|
{selectedOrganization.name}
|
|
</Button>
|
|
</Dropdown>
|
|
) : (
|
|
<Button as="span" type="text" size="tiny">
|
|
{selectedOrganization.name}
|
|
</Button>
|
|
)
|
|
}
|
|
|
|
export default observer(OrgDropdown)
|