Files
supabase/apps/studio/state/shortcuts/utils.ts
Gildas Garcia b30db91d71 chore: cleanup UI patterns exports (#47406)
## Problem

We now export components under a subpath in ui-patterns to avoid barrel
files as they slow down every tools (from IDE to linters, etc.) and may
also affect bundles our users have to download.

## Solution

- Remove the UI patterns index file
- Fix invalid impors
2026-06-30 09:23:17 +02:00

23 lines
736 B
TypeScript

import { ICommand } from 'ui-patterns/CommandMenu'
import { SHORTCUT_IDS } from './registry'
/**
* Shared orderer for the Cmd+K "Shortcuts" section. Keeps the "Show all
* keyboard shortcuts" entry pinned to the bottom regardless of registration
* order; everything else is order-stable. Exported so `useDynamicShortcut`
* can share the same ordering behavior.
*/
export const orderShortcutCommands = (
commands: ICommand[],
commandsToInsert: ICommand[]
): ICommand[] => {
const mergedCommands = [...commands, ...commandsToInsert]
return mergedCommands.sort((a, b) => {
if (a.id === SHORTCUT_IDS.SHORTCUTS_OPEN_REFERENCE) return 1
if (b.id === SHORTCUT_IDS.SHORTCUTS_OPEN_REFERENCE) return -1
return 0
})
}