From 88ea68e72f2c7f6cd0e681eab2033581903098fa Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Sun, 7 Jan 2024 22:24:19 -0800 Subject: [PATCH] Remove base env, fix hotkeys, and QoL improvements --- .../components/EnvironmentActionsDropdown.tsx | 28 ++++++++++++----- src-web/components/EnvironmentEditDialog.tsx | 31 ++++++------------- src-web/components/SettingsDropdown.tsx | 30 ++++++++++++++++-- src-web/components/SidebarActions.tsx | 17 ---------- src-web/components/Workspace.tsx | 10 ++++-- .../components/WorkspaceActionsDropdown.tsx | 17 ++++++++++ src-web/components/core/Button.tsx | 7 ++--- src-web/components/core/PairEditor.tsx | 2 +- src-web/hooks/useCreateFolder.ts | 2 +- src-web/hooks/useCreateRequest.ts | 13 +++----- 10 files changed, 90 insertions(+), 67 deletions(-) diff --git a/src-web/components/EnvironmentActionsDropdown.tsx b/src-web/components/EnvironmentActionsDropdown.tsx index 67338fd7..c0857ea8 100644 --- a/src-web/components/EnvironmentActionsDropdown.tsx +++ b/src-web/components/EnvironmentActionsDropdown.tsx @@ -2,6 +2,7 @@ import classNames from 'classnames'; import { memo, useCallback, useMemo } from 'react'; import { useActiveEnvironment } from '../hooks/useActiveEnvironment'; import { useAppRoutes } from '../hooks/useAppRoutes'; +import { useCreateEnvironment } from '../hooks/useCreateEnvironment'; import { useEnvironments } from '../hooks/useEnvironments'; import { useHotkey } from '../hooks/useHotkey'; import type { ButtonProps } from './core/Button'; @@ -22,6 +23,7 @@ export const EnvironmentActionsDropdown = memo(function EnvironmentActionsDropdo }: Props) { const environments = useEnvironments(); const activeEnvironment = useActiveEnvironment(); + const createEnvironment = useCreateEnvironment(); const dialog = useDialog(); const routes = useAppRoutes(); @@ -55,15 +57,25 @@ export const EnvironmentActionsDropdown = memo(function EnvironmentActionsDropdo ...((environments.length > 0 ? [{ type: 'separator', label: 'Environments' }] : []) as DropdownItem[]), - { - key: 'edit', - label: 'Manage Environments', - hotkeyAction: 'environmentEditor.toggle', - leftSlot: , - onSelect: showEnvironmentDialog, - }, + environments.length + ? { + key: 'edit', + label: 'Manage Environments', + hotkeyAction: 'environmentEditor.toggle', + leftSlot: , + onSelect: showEnvironmentDialog, + } + : { + key: 'new', + label: 'New Environment', + leftSlot: , + onSelect: async () => { + await createEnvironment.mutateAsync(); + showEnvironmentDialog(); + }, + }, ], - [activeEnvironment, environments, routes, showEnvironmentDialog], + [activeEnvironment?.id, createEnvironment, environments, routes, showEnvironmentDialog], ); return ( diff --git a/src-web/components/EnvironmentEditDialog.tsx b/src-web/components/EnvironmentEditDialog.tsx index d6625c4d..93c78d99 100644 --- a/src-web/components/EnvironmentEditDialog.tsx +++ b/src-web/components/EnvironmentEditDialog.tsx @@ -58,23 +58,15 @@ export const EnvironmentEditDialog = function ({ initialEnvironment }: Props) { {showSidebar && (