The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add configure org command (#29092)
Charisd6f96780e999
diff --git a/apps/studio/components/interfaces/App/CommandMenu/CommandMenu.tsx b/apps/studio/components/interfaces/App/CommandMenu/CommandMenu.tsxindex 7809b0bd9aa..ec78c4d8430 100644--- a/apps/studio/components/interfaces/App/CommandMenu/CommandMenu.tsx+++ b/apps/studio/components/interfaces/App/CommandMenu/CommandMenu.tsx@@ -11,7 +11,7 @@ import { useDocsSearchCommands } from 'ui-patterns/CommandMenu/prepackaged/DocsSimport { useThemeSwitcherCommands } from 'ui-patterns/CommandMenu/prepackaged/ThemeSwitcher'import { useApiKeysCommands } from './ApiKeys'import { useApiUrlCommand } from './ApiUrl'-import { useProjectSwitchCommand } from './ProjectSwitcher'+import { useProjectSwitchCommand, useConfigureOrganizationCommand } from './OrgProjectSwitcher'import { useSupportCommands } from './Support'import { orderCommandSectionsByPriority } from './ordering'@@ -21,6 +21,7 @@ export default function StudioCommandMenu() {useApiUrlCommand()useProjectLevelTableEditorCommands()useProjectSwitchCommand()+ useConfigureOrganizationCommand()useBranchCommands()useSnippetCommands()useLayoutNavCommands()diff --git a/apps/studio/components/interfaces/App/CommandMenu/ProjectSwitcher.tsx b/apps/studio/components/interfaces/App/CommandMenu/OrgProjectSwitcher.tsxsimilarity index 51%rename from apps/studio/components/interfaces/App/CommandMenu/ProjectSwitcher.tsxrename to apps/studio/components/interfaces/App/CommandMenu/OrgProjectSwitcher.tsxindex 2a66f978b91..c3de2c3f633 100644--- a/apps/studio/components/interfaces/App/CommandMenu/ProjectSwitcher.tsx+++ b/apps/studio/components/interfaces/App/CommandMenu/OrgProjectSwitcher.tsx@@ -1,12 +1,14 @@-import { Forward, Wrench } from 'lucide-react'+import { Forward, Wrench, Building } from 'lucide-react'import { useMemo } from 'react'import { useProjectsQuery } from 'data/projects/projects-query'+import { useOrganizationsQuery } from 'data/organizations/organizations-query'import { PageType, useRegisterCommands, useRegisterPage, useSetPage } from 'ui-patterns/CommandMenu'import { IS_PLATFORM } from 'common'import { COMMAND_MENU_SECTIONS } from './CommandMenu.utils'const PROJECT_SWITCHER_PAGE_NAME = 'Switch project'+const ORGANIZATION_SWITCHER_PAGE_NAME = 'Configure organization'export function useProjectSwitchCommand() {const setPage = useSetPage()@@ -52,3 +54,45 @@ export function useProjectSwitchCommand() {{ enabled: !!projects && projects.length > 0 })}++export function useConfigureOrganizationCommand() {+ const setPage = useSetPage()++ const { data: organizations } = useOrganizationsQuery({ enabled: IS_PLATFORM })++ useRegisterPage(+ ORGANIZATION_SWITCHER_PAGE_NAME,+ {+ type: PageType.Commands,+ sections: [+ {+ id: 'configure-organization',+ name: 'Configure organization',+ commands:+ organizations?.map(({ name, slug }) => ({+ id: `organization-${slug}`,+ name,+ value: `${name} (${slug})`,+ route: `/org/${slug}/general`,+ icon: () => <Building />,+ })) ?? [],+ },+ ],+ },+ { deps: [organizations], enabled: !!organizations && organizations.length > 0 }+ )++ useRegisterCommands(+ COMMAND_MENU_SECTIONS.ACTIONS,+ [+ {+ id: 'configure-organization',+ name: 'Configure organization',+ value: 'Configure organization, Change organization, Select organization',+ action: () => setPage(ORGANIZATION_SWITCHER_PAGE_NAME),+ icon: () => <Building />,+ },+ ],+ { enabled: !!organizations && organizations.length > 0 }+ )+}diff --git a/packages/ui-patterns/CommandMenu/api/CommandInput.tsx b/packages/ui-patterns/CommandMenu/api/CommandInput.tsxindex 9f4b966175a..a2386f484af 100644--- a/packages/ui-patterns/CommandMenu/api/CommandInput.tsx+++ b/packages/ui-patterns/CommandMenu/api/CommandInput.tsx@@ -46,12 +46,19 @@ const CommandInput = forwardRef<const query = useQuery()const setQuery = useSetQuery()- const [inputVal, setInputVal] = useState(query)+ const [inputValue, setInputValue] = useState(query)useEffect(() => {- setQuery(inputVal)- }, [inputVal])-+ setInputValue(query)+ }, [query])++ // To handle CJK input+ const [imeComposing, setImeComposing] = useState(false)+ useEffect(() => {+ if (!imeComposing) {+ setQuery(inputValue)+ }+ }, [inputValue, imeComposing])return (<CommandInput_Shadcn_@@ -59,9 +66,11 @@ const CommandInput = forwardRef<// delays from useEffectautoFocus={false}ref={inputRef}- value={inputVal}- onValueChange={(val)=>setInputVal(val)}+ value={inputValue}+ onValueChange={setInputValue}placeholder="Type a command or search..."+ onCompositionStart={() => setImeComposing(true)}+ onCompositionEnd={() => setImeComposing(false)}className={cn('flex h-11 w-full rounded-md bg-transparent px-4 py-7 outline-none','focus:shadow-none focus:ring-transparent',