mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-22 01:19:13 +01:00
Add command palette (#46)
This PR finished the initial PoC command palette. It currently only supports switching between requests and workspaces, but can easily be extended for more.
This commit is contained in:
@@ -1,21 +1,15 @@
|
||||
import { CommandPalette } from '../components/CommandPalette';
|
||||
import { useDialog } from '../components/DialogContext';
|
||||
import { useAppInfo } from './useAppInfo';
|
||||
import { useHotKey } from './useHotKey';
|
||||
|
||||
export function useCommandPalette() {
|
||||
const dialog = useDialog();
|
||||
const appInfo = useAppInfo();
|
||||
useHotKey('command_palette.toggle', () => {
|
||||
// Disabled in production for now
|
||||
if (!appInfo?.isDev) {
|
||||
return;
|
||||
}
|
||||
|
||||
dialog.toggle({
|
||||
id: 'command_palette',
|
||||
size: 'md',
|
||||
size: 'dynamic',
|
||||
hideX: true,
|
||||
vAlign: 'top',
|
||||
noPadding: true,
|
||||
noScroll: true,
|
||||
render: ({ hide }) => <CommandPalette onClose={hide} />,
|
||||
|
||||
@@ -4,10 +4,8 @@ import type { Workspace } from '../lib/models';
|
||||
import { useAppRoutes } from './useAppRoutes';
|
||||
import { getRecentEnvironments } from './useRecentEnvironments';
|
||||
import { getRecentRequests } from './useRecentRequests';
|
||||
import { useSettings } from './useSettings';
|
||||
|
||||
export function useOpenWorkspace() {
|
||||
const settings = useSettings();
|
||||
const routes = useAppRoutes();
|
||||
|
||||
return useMutation({
|
||||
@@ -18,7 +16,7 @@ export function useOpenWorkspace() {
|
||||
workspace: Workspace;
|
||||
inNewWindow: boolean;
|
||||
}) => {
|
||||
if (settings == null || workspace == null) return;
|
||||
if (workspace == null) return;
|
||||
|
||||
if (inNewWindow) {
|
||||
const environmentId = (await getRecentEnvironments(workspace.id))[0];
|
||||
|
||||
Reference in New Issue
Block a user