Files
supabase/packages/ui-patterns/Cmdk/CommandMenuShortcuts.tsx
Alaister YoungandKevin Grüneberg 70da0f1d1d chore: cleanup packages (#27770)
* chore: cleanup packages

- Avoid circular imports
- Export API-types as types
- pg-format without depending on Node internal Buffer (not browser-compatible)
- Avoid importing from barrel files in ui dir

* chore: avoid barrel file imports in studio (#27771)

* chore: avoid barrel file imports

- Removes some unused imports
- Avoids barrel file import for faster builds + less memory

* add eslint rule

* type fixes

* delete layouts barrel

* delete components/grid barrel file

* delete components/grid/utils barrel file

* delete components/grid/components/common barrel file

* delete components/grid/components/editor barrel file

* delete components/grid/components/formatter barrel file

* delete components/grid/components/grid barrel file

* delete components/grid/components/header/filter barrel file

* remote components/grid/store barrel file

* remove components/interfaces/Auth/Policies barrel file

* delete components/interfaces/Settings/Logs barrel file

* delete components/ui/CodeEditor barrel file

* delete components/ui/Forms barrel file

* delete components/ui/Shimmers barrel file

* delete data/analytics barrel file

* delete hooks barrel file

* cleanup lib/common/fetch barrel file

* final * barral files cleanup

* global react-data-grid styles

* remove console.log

---------

Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>

* fix build

---------

Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
2024-07-04 14:48:10 +08:00

54 lines
1.6 KiB
TypeScript

import { IconArrowLeft } from 'ui/src/components/Icon/icons/IconArrowLeft'
import { BadgeExperimental } from './Command.Badges'
import { COMMAND_ROUTES } from './Command.constants'
import { CommandShortcut } from './Command.utils'
import { useCommandMenu } from './CommandMenuContext'
export default function CommandMenuShortcuts() {
const { setPages, pages, currentPage } = useCommandMenu()
return (
<div className="flex w-full gap-2 px-4 pt-4 justify-items-start flex-row items-center justify-between">
<div className="flex gap-2 flex-row items-center">
<CommandShortcut onClick={() => setPages([])}>
<div className="flex items-center gap-2">
<IconArrowLeft width={15} height={15} />
</div>
</CommandShortcut>
{pages.map((page, index) => (
<CommandShortcut
type={page === currentPage ? 'breadcrumb' : 'default'}
key={page}
onClick={() => {
if (index === pages.length - 1) {
return
}
setPages(pages.slice(0, index - 1))
}}
>
{page}
</CommandShortcut>
))}
{currentPage && isExperimental(currentPage) && <BadgeExperimental />}
</div>
</div>
)
}
/**
* TODO: remove this function and store this info on each page
* Temporary function to determine whether or not to show 'Experimental' badge
*/
function isExperimental(page: string) {
switch (page) {
case COMMAND_ROUTES.AI:
case COMMAND_ROUTES.GENERATE_SQL:
return true
default:
return false
}
}