Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add branching nav items to cmd k (#51255)

Joshen Limbe1ba651ed6e
diff --git a/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx b/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx
index 7e061b6de5b..b426fb729e6 100644
--- a/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx
+++ b/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx
@@ -1,26 +1,37 @@
-import { Forward, GitBranch } from 'lucide-react'
+import { PermissionAction } from '@supabase/shared-types/out/constants'
+import { Forward, GitBranch, Plus } from 'lucide-react'
import { PageType, useRegisterCommands, useRegisterPage, useSetPage } from 'ui-patterns/CommandMenu'
import { COMMAND_MENU_SECTIONS } from '../App/CommandMenu/CommandMenu.utils'
import { orderCommandSectionsByPriority } from '../App/CommandMenu/ordering'
+import { BRANCHING_GITHUB_DISCUSSION_LINK } from './BranchManagement.constants'
import { useBranchesQuery } from '@/data/branches/branches-query'
+import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
+import { useAppStateSnapshot } from '@/state/app-state'
const SWITCH_BRANCH_PAGE_NAME = 'Switch branch'
const EMPTY_ARRAY = [] as Array<any>
export function useBranchCommands() {
const setPage = useSetPage()
+ const { setShowCreateBranchModal } = useAppStateSnapshot()
const { data: selectedProject } = useSelectedProjectQuery()
+ const ref = selectedProject?.ref || '_'
const isBranchingEnabled = selectedProject?.is_branch_enabled === true
+ const { can: canCreateBranches } = useAsyncCheckPermissions(
+ PermissionAction.CREATE,
+ 'preview_branches',
+ { resource: { is_default: false } }
+ )
+
let { data: branches } = useBranchesQuery(
- {
- projectRef: selectedProject?.parent_project_ref || selectedProject?.ref,
- },
+ { projectRef: selectedProject?.parent_project_ref || selectedProject?.ref },
{ enabled: isBranchingEnabled }
)
+
branches ??= EMPTY_ARRAY
useRegisterPage(
@@ -60,4 +71,48 @@ export function useBranchCommands() {
sectionMeta: { priority: 3 },
}
)
+
+ useRegisterCommands(
+ COMMAND_MENU_SECTIONS.ACTIONS,
+ [
+ {
+ id: 'create-branch',
+ name: 'Create branch',
+ value: 'Create branch, New branch',
+ action: () => setShowCreateBranchModal(true),
+ icon: () => <Plus />,
+ },
+ ],
+ {
+ enabled: canCreateBranches,
+ orderSection: orderCommandSectionsByPriority,
+ sectionMeta: { priority: 3 },
+ }
+ )
+
+ useRegisterCommands(
+ COMMAND_MENU_SECTIONS.NAVIGATE,
+ [
+ {
+ id: 'nav-branch-management',
+ name: 'Branch management',
+ route: `/project/${ref}/branches`,
+ },
+ {
+ id: 'nav-branch-merge-requests',
+ name: 'Merge requests',
+ value: 'Branch',
+ route: `/project/${ref}/branches/merge-requests`,
+ },
+ ],
+ { enabled: !!selectedProject }
+ )
+
+ useRegisterCommands(COMMAND_MENU_SECTIONS.NAVIGATE, [
+ {
+ id: 'nav-branch-feedback',
+ name: 'Branching feedback',
+ route: BRANCHING_GITHUB_DISCUSSION_LINK,
+ },
+ ])
}
diff --git a/apps/studio/components/interfaces/BranchManagement/BranchManagement.constants.ts b/apps/studio/components/interfaces/BranchManagement/BranchManagement.constants.ts
new file mode 100644
index 00000000000..d52b0fd0dc1
--- /dev/null
+++ b/apps/studio/components/interfaces/BranchManagement/BranchManagement.constants.ts
@@ -0,0 +1 @@
+export const BRANCHING_GITHUB_DISCUSSION_LINK = 'https://github.com/orgs/supabase/discussions/18937'
diff --git a/apps/studio/components/layouts/AppLayout/BranchDropdownCommandContent.tsx b/apps/studio/components/layouts/AppLayout/BranchDropdownCommandContent.tsx
index ac0d6d4397c..e77fef3876f 100644
--- a/apps/studio/components/layouts/AppLayout/BranchDropdownCommandContent.tsx
+++ b/apps/studio/components/layouts/AppLayout/BranchDropdownCommandContent.tsx
@@ -14,12 +14,11 @@ import {
} from 'ui'
import { BranchLink } from './BranchLink'
+import { BRANCHING_GITHUB_DISCUSSION_LINK } from '@/components/interfaces/BranchManagement/BranchManagement.constants'
import { CommandItemLink } from '@/components/ui/CommandItemLink'
import type { Branch } from '@/data/branches/branches-query'
import { useTrack } from '@/lib/telemetry/track'
-const BRANCHING_GITHUB_DISCUSSION_LINK = 'https://github.com/orgs/supabase/discussions/18937'
-
export interface BranchDropdownCommandContentProps {
embedded: boolean
className?: string
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/ProjectSettings.Commands.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/ProjectSettings.Commands.tsx
index 9755bce0b57..aefdcb0b6c8 100644
--- a/apps/studio/components/layouts/ProjectSettingsLayout/ProjectSettings.Commands.tsx
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/ProjectSettings.Commands.tsx
@@ -45,7 +45,7 @@ export function useProjectSettingsGotoCommands(options?: CommandOptions) {
},
{
id: 'nav-project-settings-general',
- name: 'General Settings',
+ name: 'General settings',
route: `/project/${ref}/settings/general`,
defaultHidden: true,
},
@@ -61,13 +61,13 @@ export function useProjectSettingsGotoCommands(options?: CommandOptions) {
: []),
{
id: 'nav-project-settings-database',
- name: 'Database Settings',
+ name: 'Database settings',
route: `/project/${ref}/database/settings`,
defaultHidden: true,
},
{
id: 'nav-project-settings-auth',
- name: 'Auth Settings',
+ name: 'Auth settings',
route: authenticationSignInProviders
? `/project/${ref}/auth/providers`
: `/project/${ref}/database/policies`,
@@ -77,7 +77,7 @@ export function useProjectSettingsGotoCommands(options?: CommandOptions) {
? [
{
id: 'nav-project-settings-webhooks',
- name: 'Project Webhooks',
+ name: 'Project webhooks',
route: `/project/${ref}/settings/webhooks`,
defaultHidden: true,
} as IRouteCommand,
@@ -95,13 +95,19 @@ export function useProjectSettingsGotoCommands(options?: CommandOptions) {
: []),
{
id: 'nav-project-settings-api',
- name: 'API Settings',
+ name: 'API settings',
route: `/project/${ref}/integrations/data_api/settings`,
defaultHidden: true,
},
+ {
+ id: 'nav-project-settings-integration',
+ name: 'Project Integrations',
+ value: 'Branch integration, Vercel integration, GitHub integration, AWS PrivateLink',
+ route: `/project/${ref}/settings/integrations`,
+ },
{
id: 'nav-project-settings-storage',
- name: 'Storage Settings',
+ name: 'Storage settings',
route: `/project/${ref}/storage/settings`,
defaultHidden: true,
},
@@ -109,7 +115,7 @@ export function useProjectSettingsGotoCommands(options?: CommandOptions) {
? [
{
id: 'nav-project-settings-custom-domains',
- name: 'Custom Domains',
+ name: 'Custom domains',
route: `/project/${ref}/settings/general#custom-domains`,
defaultHidden: true,
} as IRouteCommand,
diff --git a/apps/studio/pages/project/[ref]/branches/index.tsx b/apps/studio/pages/project/[ref]/branches/index.tsx
index f16f58b939c..e40721ce812 100644
--- a/apps/studio/pages/project/[ref]/branches/index.tsx
+++ b/apps/studio/pages/project/[ref]/branches/index.tsx
@@ -6,6 +6,7 @@ import { useRouter } from 'next/router'
import { useState, type PropsWithChildren } from 'react'
import { Button } from 'ui'
+import { BRANCHING_GITHUB_DISCUSSION_LINK } from '@/components/interfaces/BranchManagement/BranchManagement.constants'
import { DeleteBranchModal } from '@/components/interfaces/BranchManagement/DeleteBranchModal'
import { Overview } from '@/components/interfaces/BranchManagement/Overview'
import BranchLayout from '@/components/layouts/BranchLayout/BranchLayout'
@@ -189,11 +190,7 @@ export const BranchesPageWrapper = ({ children }: PropsWithChildren) => {
variant="text"
icon={<MessageCircle className="text-muted" strokeWidth={1} />}
>
- <a
- target="_blank"
- rel="noreferrer"
- href="https://github.com/orgs/supabase/discussions/18937"
- >
+ <a target="_blank" rel="noreferrer" href={BRANCHING_GITHUB_DISCUSSION_LINK}>
Branching feedback
</a>
</Button>
diff --git a/apps/studio/pages/project/[ref]/branches/merge-requests.tsx b/apps/studio/pages/project/[ref]/branches/merge-requests.tsx
index fa1d83f6f99..e98869a918e 100644
--- a/apps/studio/pages/project/[ref]/branches/merge-requests.tsx
+++ b/apps/studio/pages/project/[ref]/branches/merge-requests.tsx
@@ -12,9 +12,12 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
Tooltip,
+ TooltipContent,
+ TooltipTrigger,
} from 'ui'
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
+import { BRANCHING_GITHUB_DISCUSSION_LINK } from '@/components/interfaces/BranchManagement/BranchManagement.constants'
import {
BranchManagementSection,
BranchRow,
@@ -250,14 +253,22 @@ const MergeRequestsPage: NextPageWithLayout = () => {
// whether the branch is linked to a GitHub PR.
branch.review_requested_at && (
<DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- variant="text"
- icon={<MoreVertical />}
- className="px-1"
- onClick={(e) => e.stopPropagation()}
- />
- </DropdownMenuTrigger>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <DropdownMenuTrigger asChild>
+ <Button
+ aria-label="Manage merge request"
+ variant="text"
+ className="px-1"
+ icon={<MoreVertical />}
+ onClick={(e) => e.stopPropagation()}
+ />
+ </DropdownMenuTrigger>
+ </TooltipTrigger>
+ <TooltipContent side="bottom">
+ Manage merge request
+ </TooltipContent>
+ </Tooltip>
<DropdownMenuContent className="w-56" side="bottom" align="end">
<Tooltip>
<DropdownMenuItem
@@ -369,11 +380,7 @@ export const MergeRequestsPageWrapper = ({ children }: PropsWithChildren<{}>) =>
variant="text"
icon={<MessageCircle className="text-muted" strokeWidth={1} />}
>
- <a
- target="_blank"
- rel="noreferrer"
- href="https://github.com/orgs/supabase/discussions/18937"
- >
+ <a target="_blank" rel="noreferrer" href={BRANCHING_GITHUB_DISCUSSION_LINK}>
Branching feedback
</a>
</Button>