Skip to content

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

feat(studio): wire list-page shortcuts on database replication and migrations pages (#45551)

Ali Waseem9a3250b84346
diff --git a/apps/studio/components/interfaces/Database/Migrations/Migrations.tsx b/apps/studio/components/interfaces/Database/Migrations/Migrations.tsx
index 29aa51519a6..87f922dfd11 100644
--- a/apps/studio/components/interfaces/Database/Migrations/Migrations.tsx
+++ b/apps/studio/components/interfaces/Database/Migrations/Migrations.tsx
@@ -1,6 +1,6 @@
import { SupportCategories } from '@supabase/shared-types/out/constants'
import { Search } from 'lucide-react'
-import { useState } from 'react'
+import { useRef, useState } from 'react'
import {
Button,
Card,
@@ -28,10 +28,24 @@ import { DatabaseMigration, useMigrationsQuery } from '@/data/database/migration
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { DOCS_URL } from '@/lib/constants'
import { formatMigrationVersionLabel, parseMigrationVersion } from '@/lib/migration-utils'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
const Migrations = () => {
const [search, setSearch] = useState('')
const [selectedMigration, setSelectedMigration] = useState<DatabaseMigration>()
+ const searchInputRef = useRef<HTMLInputElement>(null)
+
+ useShortcut(
+ SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH,
+ () => {
+ searchInputRef.current?.focus()
+ searchInputRef.current?.select()
+ },
+ { label: 'Search migrations' }
+ )
+
+ useShortcut(SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS, () => setSearch(''))
const { data: project } = useSelectedProjectQuery()
const {
@@ -96,6 +110,7 @@ const Migrations = () => {
{data.length > 0 && (
<div className="flex flex-col gap-y-4">
<Input
+ ref={searchInputRef}
size="tiny"
placeholder="Search for a migration"
value={search}
diff --git a/apps/studio/components/interfaces/Database/Replication/Destinations.tsx b/apps/studio/components/interfaces/Database/Replication/Destinations.tsx
index c25e0a6ca06..449a36c43ee 100644
--- a/apps/studio/components/interfaces/Database/Replication/Destinations.tsx
+++ b/apps/studio/components/interfaces/Database/Replication/Destinations.tsx
@@ -36,6 +36,7 @@ import {
} from './useIsETLPrivateAlpha'
import { AlertError } from '@/components/ui/AlertError'
import { DocsButton } from '@/components/ui/DocsButton'
+import { Shortcut } from '@/components/ui/Shortcut'
import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'
import { useReplicationDestinationsQuery } from '@/data/replication/destinations-query'
import { replicationKeys } from '@/data/replication/keys'
@@ -44,6 +45,8 @@ import { useReplicationPipelinesQuery } from '@/data/replication/pipelines-query
import { useReplicationSourcesQuery } from '@/data/replication/sources-query'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { DOCS_URL } from '@/lib/constants'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
export const Destinations = () => {
const queryClient = useQueryClient()
@@ -65,6 +68,7 @@ export const Destinations = () => {
: null
const prefetchedRef = useRef(false)
+ const searchInputRef = useRef<HTMLInputElement>(null)
const [filterString, setFilterString] = useState<string>('')
const [statusRefetchInterval, setStatusRefetchInterval] = useState<number | false>(5000)
const [showDisableExternalReplicationDialog, setShowDisableExternalReplicationDialog] =
@@ -143,6 +147,17 @@ export const Destinations = () => {
setDestinationType(newDestinationDefaultType)
}
+ useShortcut(
+ SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH,
+ () => {
+ searchInputRef.current?.focus()
+ searchInputRef.current?.select()
+ },
+ { label: 'Search destinations' }
+ )
+
+ useShortcut(SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS, () => setFilterString(''))
+
useEffect(() => {
if (
projectRef &&
@@ -190,6 +205,7 @@ export const Destinations = () => {
<div className="flex items-center justify-between">
<div className="flex items-center">
<Input
+ ref={searchInputRef}
placeholder="Filter destinations"
size="tiny"
icon={<Search />}
@@ -209,14 +225,22 @@ export const Destinations = () => {
/>
</div>
<div className="flex items-center gap-x-2">
- <Button
- type="default"
- icon={<Plus />}
- disabled={!newDestinationDefaultType}
- onClick={openDestinationPanel}
+ <Shortcut
+ id={SHORTCUT_IDS.LIST_PAGE_NEW_ITEM}
+ label="Add destination"
+ onTrigger={openDestinationPanel}
+ options={{ enabled: !!newDestinationDefaultType }}
+ side="bottom"
>
- Add destination
- </Button>
+ <Button
+ type="default"
+ icon={<Plus />}
+ disabled={!newDestinationDefaultType}
+ onClick={openDestinationPanel}
+ >
+ Add destination
+ </Button>
+ </Shortcut>
<DocsButton href={`${DOCS_URL}/guides/database/replication`} />
{canDisableExternalReplication && (
<DropdownMenu>