feat(webui): add a compact composer workspace toolbar (#6256)
* feat(webui): add a compact composer workspace toolbar * refactor(webui): simplify composer workspace access control * feat(webui): add a draggable workspace access capsule * refactor(webui): simplify composer permission controls * fix(webui): align mobile workspace permissions and stabilize CI test
This commit is contained in:
1 parent
0254bf1217
commit
cf0a0276a7
34 files changed
+528
-267
No files matched your search
@@ -82,7 +82,7 @@ import {
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import {
|
||||
WorkspaceAccessToggle,
|
||||
WorkspaceAccessMenu,
|
||||
WorkspaceProjectPicker,
|
||||
} from "@/components/thread/WorkspaceControls";
|
||||
import {
|
||||
@@ -257,6 +257,7 @@ interface ThreadComposerProps {
|
||||
workspaceDefaultScope?: WorkspaceScopePayload | null;
|
||||
workspaceControls?: WorkspacesPayload["controls"] | null;
|
||||
workspaceScopeDisabled?: boolean;
|
||||
workspaceProjectLocked?: boolean;
|
||||
workspaceError?: string | null;
|
||||
onFavoriteWorkspaceProject?: (path: string, pinned: boolean) => Promise<ProjectDirectory[]>;
|
||||
onResolveWorkspaceProject?: (path: string) => Promise<ProjectDirectory>;
|
||||
@@ -1114,6 +1115,7 @@ export function ThreadComposer({
|
||||
workspaceDefaultScope = null,
|
||||
workspaceControls = null,
|
||||
workspaceScopeDisabled = false,
|
||||
workspaceProjectLocked = false,
|
||||
workspaceError = null,
|
||||
onLoadWorkspaceProjects,
|
||||
onResolveWorkspaceProject,
|
||||
@@ -1174,6 +1176,7 @@ export function ThreadComposer({
|
||||
// Coarser than hasTouchPrimaryPointer on purpose: tablets with a physical
|
||||
// keyboard still get the newline-on-Enter behavior.
|
||||
const hasCoarsePointer = useMediaQuery("(pointer: coarse)");
|
||||
const mobileWorkspaceControls = useMediaQuery("(max-width: 639px)");
|
||||
const { readingTextSize } = useLocalPreferences();
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||
const mentionOverlayRef = useRef<HTMLDivElement>(null);
|
||||
@@ -1213,7 +1216,7 @@ export function ThreadComposer({
|
||||
const isHero = variant === "hero";
|
||||
const voiceShortcutLabel = useMemo(getVoiceShortcutLabel, []);
|
||||
const projectPickerAvailable =
|
||||
isHero
|
||||
!workspaceProjectLocked
|
||||
&& !!workspaceDefaultScope
|
||||
&& !!onWorkspaceScopeChange
|
||||
&& !!onLoadWorkspaceProjects
|
||||
@@ -1236,9 +1239,7 @@ export function ThreadComposer({
|
||||
));
|
||||
}, [activeTurnId, isStreaming, pendingQueueKey, setQueuedPrompt]);
|
||||
|
||||
const resolvedPlaceholder = isStreaming
|
||||
? t("thread.composer.placeholderStreaming")
|
||||
: placeholder ?? t("thread.composer.placeholderThread");
|
||||
const resolvedPlaceholder = placeholder ?? t("thread.composer.placeholderThread");
|
||||
|
||||
const maxAttachments = ingressLimits?.attachments.max_count
|
||||
?? MAX_ATTACHMENTS_PER_MESSAGE;
|
||||
@@ -2526,17 +2527,15 @@ export function ThreadComposer({
|
||||
return () => observer?.disconnect();
|
||||
}, [compactControls, compactWhenIdle, modelLabel, voiceRecorder.isRecording, workspaceScope]);
|
||||
const accessControl = workspaceScope && !workspaceControlsHidden ? (
|
||||
<WorkspaceAccessToggle
|
||||
<WorkspaceAccessMenu
|
||||
scope={workspaceScope}
|
||||
disabled={interactionDisabled || workspaceScopeDisabled}
|
||||
isHero={isHero}
|
||||
onChange={onWorkspaceScopeChange}
|
||||
/>
|
||||
) : null;
|
||||
const workspaceControl = showProjectPicker ? (
|
||||
<WorkspaceProjectPicker
|
||||
layoutAnchor={workspacePickerLayoutAnchor}
|
||||
isHero={isHero}
|
||||
disabled={interactionDisabled || workspaceScopeDisabled}
|
||||
scope={workspaceScope}
|
||||
defaultScope={workspaceDefaultScope}
|
||||
@@ -2566,7 +2565,7 @@ export function ThreadComposer({
|
||||
onClick={modelNeedsSetup ? onModelBadgeClick : undefined}
|
||||
/>
|
||||
) : null;
|
||||
const usageControl = !voiceRecorder.isRecording ? (
|
||||
const usageControl = !voiceRecorder.isRecording && (contextUsage || recentRoundUsage.length) ? (
|
||||
<ComposerUsagePopover context={contextUsage} rounds={recentRoundUsage} showLabel={compactControls} bottomSheet={compactControls} />
|
||||
) : null;
|
||||
const inputTextClasses = cn(
|
||||
@@ -2626,8 +2625,10 @@ export function ThreadComposer({
|
||||
if (!handleSessionDrop(event)) onDrop(event);
|
||||
}}
|
||||
className={cn(
|
||||
"relative w-full",
|
||||
isHero ? "px-0" : "px-1 pb-1.5 pt-1 sm:px-0",
|
||||
"thread-composer-form relative w-full [--composer-action-margin:0px]",
|
||||
isHero
|
||||
? "px-0 [--composer-action-size:2rem] [--composer-footer-inset:0.75rem] sm:[--composer-footer-inset:1rem]"
|
||||
: "px-1 pb-1.5 pt-1 [--composer-action-size:2.25rem] [--composer-footer-inset:0.625rem] sm:px-0 sm:[--composer-footer-inset:0.75rem]",
|
||||
compactWhenIdle && "thread-composer-collapsible-layout",
|
||||
paletteBeside && "grid grid-cols-2 items-start gap-2 p-0",
|
||||
)}
|
||||
@@ -2800,13 +2801,13 @@ export function ThreadComposer({
|
||||
) : null}
|
||||
<div
|
||||
className={cn(
|
||||
"thread-composer-footer flex flex-nowrap items-center motion-safe:transition-[padding-bottom] motion-safe:[transition-duration:220ms] motion-safe:ease-in-out",
|
||||
"thread-composer-footer flex flex-nowrap items-center px-[var(--composer-footer-inset)] motion-safe:transition-[padding-bottom] motion-safe:[transition-duration:220ms] motion-safe:ease-in-out",
|
||||
isHero
|
||||
? cn(
|
||||
"gap-x-1.5 px-3 sm:px-4",
|
||||
"gap-x-1.5",
|
||||
showProjectPicker && compactControls ? "pb-1.5" : "pb-3.5",
|
||||
)
|
||||
: "gap-x-2 px-2.5 pb-2 sm:px-3",
|
||||
: "gap-x-2 pb-2",
|
||||
)}
|
||||
>
|
||||
<div
|
||||
@@ -2832,13 +2833,12 @@ export function ThreadComposer({
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
className={cn(
|
||||
"thread-composer-action thread-composer-round-action touch-target shrink-0 rounded-xl text-muted-foreground hover:text-foreground",
|
||||
isHero
|
||||
? "h-8 w-8"
|
||||
: "h-9 w-9",
|
||||
"h-[var(--composer-action-size)] w-[var(--composer-action-size)]",
|
||||
)}
|
||||
>
|
||||
<AttachIcon className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
{!mobileWorkspaceControls ? accessControl : null}
|
||||
{voiceRecorder.isRecording ? (
|
||||
<VoiceRecordingMeter
|
||||
ariaLabel={voiceRecordingStatusLabel}
|
||||
@@ -2847,12 +2847,7 @@ export function ThreadComposer({
|
||||
isHero={isHero}
|
||||
levels={voiceRecorder.levels}
|
||||
/>
|
||||
) : compactControls ? modelControl : (
|
||||
<div className="thread-composer-workspace-group flex min-w-0 items-center gap-0.5">
|
||||
{workspaceControl}
|
||||
{accessControl}
|
||||
</div>
|
||||
)}
|
||||
) : null}
|
||||
</div>
|
||||
<div
|
||||
className={cn(
|
||||
@@ -2860,7 +2855,7 @@ export function ThreadComposer({
|
||||
isHero ? "gap-1.5" : "gap-2",
|
||||
)}
|
||||
>
|
||||
{!compactControls ? modelControl : null}
|
||||
{modelControl}
|
||||
{!compactControls ? usageControl : null}
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
@@ -2934,26 +2929,19 @@ export function ThreadComposer({
|
||||
</TooltipProvider>
|
||||
</div>
|
||||
</div>
|
||||
{compactControls && projectPickerAvailable ? (
|
||||
<div
|
||||
className="inline-disclosure"
|
||||
data-composer-workspace-drawer=""
|
||||
data-state={showProjectPicker ? "open" : "closed"}
|
||||
aria-hidden={showProjectPicker ? undefined : true}
|
||||
>
|
||||
<div className="inline-disclosure-clip">
|
||||
<div className="inline-disclosure-content thread-composer-workspace-row flex min-w-0 items-center justify-between gap-2 rounded-b-[28px] bg-muted/45 px-3 py-1.5 dark:bg-white/[0.045] sm:px-4">
|
||||
{workspaceControl}
|
||||
<div className="ml-auto flex min-w-0 justify-end">{accessControl}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
{compactControls && (!projectPickerAvailable || usageControl) ? (
|
||||
<div className="thread-composer-meta mx-auto flex w-full max-w-[58rem] items-center justify-between gap-2 px-3">
|
||||
{!projectPickerAvailable ? accessControl : null}
|
||||
<div className="ml-auto">{usageControl}</div>
|
||||
{workspaceControl || mobileWorkspaceControls && accessControl || compactControls && usageControl ? (
|
||||
<div className={cn(
|
||||
"thread-composer-meta mx-auto mt-1 flex w-full min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pr-2 sm:pr-3",
|
||||
isHero ? "max-w-[58rem]" : "max-w-[49.5rem]",
|
||||
paletteBeside && "col-start-1 row-start-2",
|
||||
)}>
|
||||
{mobileWorkspaceControls && compactControls && usageControl ? <div className="flex w-full justify-end">{usageControl}</div> : null}
|
||||
<div className={cn("thread-composer-workspace-group flex min-w-0 items-center gap-1", mobileWorkspaceControls ? "flex-1" : "flex-auto max-[359px]:flex-wrap")}>
|
||||
{workspaceControl}
|
||||
</div>
|
||||
{!mobileWorkspaceControls && compactControls && usageControl ? <div className="ml-auto shrink-0">{usageControl}</div> : null}
|
||||
{mobileWorkspaceControls && accessControl ? <div className="ml-auto min-w-0 max-w-[55%] shrink">{accessControl}</div> : null}
|
||||
</div>
|
||||
) : null}
|
||||
</form>
|
||||
|
||||
@@ -778,6 +778,10 @@ export function ThreadShell({
|
||||
|
||||
const showHeroComposer = displayMessages.length === 0 && !initialHistoryLoading;
|
||||
const composerVariant = showHeroComposer ? emptyComposerVariant : "thread";
|
||||
// The server owns the project lock. Old servers have no marker, so an existing
|
||||
// user turn is read-only here too; the gateway remains the editing authority.
|
||||
const projectLocked = session?.projectLocked === true
|
||||
|| (session?.projectLocked === undefined && displayMessages.some((message) => message.role === "user" && message.deliveryStatus !== "failed"));
|
||||
const wasShowingHeroComposerRef = useRef(showHeroComposer);
|
||||
const sessionModelPreset = session?.modelPreset?.trim() || null;
|
||||
const [localModelPreset, setLocalModelPreset] = useState<string | null>(null);
|
||||
@@ -1338,6 +1342,7 @@ export function ThreadShell({
|
||||
workspaceDefaultScope={workspaceDefaultScope}
|
||||
workspaceControls={workspaceControls}
|
||||
workspaceScopeDisabled={workspaceScopeDisabled}
|
||||
workspaceProjectLocked={projectLocked}
|
||||
workspaceError={workspaceError}
|
||||
onWorkspaceScopeChange={onWorkspaceScopeChange}
|
||||
pendingQueueKey={temporary ? null : chatId}
|
||||
@@ -1395,6 +1400,7 @@ export function ThreadShell({
|
||||
workspaceDefaultScope={workspaceDefaultScope}
|
||||
workspaceControls={workspaceControls}
|
||||
workspaceScopeDisabled={workspaceScopeDisabled}
|
||||
workspaceProjectLocked={projectLocked}
|
||||
workspaceError={workspaceError}
|
||||
onWorkspaceScopeChange={onWorkspaceScopeChange}
|
||||
transcriptionProvider={settingsSnapshot?.transcription?.provider}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { FullAccessIcon, WorkspaceIcon, RestrictedAccessIcon } from "@/components/icons/product-icons";
|
||||
import { FullAccessIcon, RestrictedAccessIcon, WorkspaceIcon } from "@/components/icons/product-icons";
|
||||
import type { HTMLAttributes, ReactElement } from "react";
|
||||
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||
import { ArrowLeft, ArrowRight, Check, ChevronRight, FolderSearch, History, Search, Star } from "lucide-react";
|
||||
import { ArrowLeft, ArrowRight, Check, ChevronDown, ChevronRight, FolderSearch, History, Search, Star } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ToggleButton } from "@/components/ui/toggle-button";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { floatingItemClassName, floatingItemFocusClassName } from "@/components/ui/floating-surface";
|
||||
import { HoverHint } from "@/components/ui/tooltip";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
||||
import { Input, SearchInput } from "@/components/ui/input";
|
||||
import { Dialog, DialogContent, DialogTrigger, DialogTitle, DialogDescription } from "@/components/ui/dialog";
|
||||
import { SidebarSelectionHighlight, SIDEBAR_SELECTION_ITEM_CLASS } from "@/components/SidebarSelectionHighlight";
|
||||
@@ -152,9 +153,8 @@ function WorkspacePickerPath({ path }: { path: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope, controls, error, onLoadProjects, onResolveProject, onFavoriteProject, onBrowseDirectories, layoutAnchor, onChange }: {
|
||||
export function WorkspaceProjectPicker({ disabled, scope, defaultScope, controls, error, onLoadProjects, onResolveProject, onFavoriteProject, onBrowseDirectories, layoutAnchor, onChange }: {
|
||||
layoutAnchor?: HTMLElement | null;
|
||||
isHero: boolean;
|
||||
disabled?: boolean;
|
||||
scope: WorkspaceScopePayload | null;
|
||||
defaultScope: WorkspaceScopePayload | null;
|
||||
@@ -217,7 +217,7 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,
|
||||
const currentProjectScope = selectedProjectScope(scope, defaultScope);
|
||||
const displayedScope = scope ?? defaultScope;
|
||||
const projectLabel = displayedScope ? displayedScope.project_name || projectNameFromPath(displayedScope.project_path) : "";
|
||||
const visible = isHero && !!defaultScope && !!onChange && controls?.can_change_project !== false;
|
||||
const visible = !!defaultScope && !!onChange && controls?.can_change_project !== false;
|
||||
const canBrowse = controls?.can_browse_directories === true && !!onBrowseDirectories;
|
||||
const directoryCache = useMemo(() => onBrowseDirectories ? createWorkspaceDirectoryCache(onBrowseDirectories) : null, [onBrowseDirectories]);
|
||||
const previousColumns = useMemo<PickerColumn[]>(() => currentVisit.ancestors.map(ancestor => {
|
||||
@@ -551,13 +551,14 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,
|
||||
|
||||
if (!visible || !defaultScope || !onChange) return null;
|
||||
return (
|
||||
<div className="inline-flex min-w-0 max-w-[11rem] shrink items-center">
|
||||
<div className="inline-flex min-w-0 max-w-[17.5rem] shrink items-center">
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<HoverHint content={`${t("workspace.picker.switchDirectory")}\n${displayedScope?.project_path ?? ""}`}>
|
||||
<DialogTrigger asChild>
|
||||
<button ref={triggerRef} onClick={event => { openedWithKeyboard.current = event.detail === 0; }} onPointerDown={() => setKeyboardInteraction(false)} onKeyDown={() => setKeyboardInteraction(true)} type="button" disabled={disabled} aria-label={t("workspace.picker.switchDirectory")} className="thread-composer-workspace touch-target inline-flex h-8 min-w-0 max-w-full items-center gap-1.5 rounded-control px-2 text-[12px] font-medium text-muted-foreground outline-none transition-colors hover:bg-foreground/[0.055] hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-55">
|
||||
<WorkspaceIcon className="h-3.5 w-3.5 shrink-0" />
|
||||
<button ref={triggerRef} onClick={event => { openedWithKeyboard.current = event.detail === 0; }} onPointerDown={() => setKeyboardInteraction(false)} onKeyDown={() => setKeyboardInteraction(true)} type="button" disabled={disabled} aria-label={t("workspace.picker.switchDirectory")} className="settings-hover thread-composer-workspace touch-target inline-flex h-7 min-w-0 max-w-full items-center gap-1.5 rounded-md px-2 text-[12px] font-medium text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-55">
|
||||
<WorkspaceIcon className="h-3 w-3 shrink-0" />
|
||||
<span className="min-w-0 truncate">{projectLabel}</span>
|
||||
<ChevronDown className="h-3 w-3 shrink-0" aria-hidden />
|
||||
</button>
|
||||
</DialogTrigger>
|
||||
</HoverHint>
|
||||
@@ -679,58 +680,67 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,
|
||||
);
|
||||
}
|
||||
|
||||
export function WorkspaceAccessToggle({
|
||||
export function WorkspaceAccessMenu({
|
||||
scope,
|
||||
disabled,
|
||||
isHero,
|
||||
onChange,
|
||||
}: {
|
||||
scope: WorkspaceScopePayload;
|
||||
disabled?: boolean;
|
||||
isHero: boolean;
|
||||
onChange?: (scope: WorkspaceScopePayload) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const mode = scope.access_mode;
|
||||
const isFull = mode === "full";
|
||||
const accessLabel = t(
|
||||
isFull ? "thread.composer.workspace.full" : "thread.composer.workspace.default",
|
||||
);
|
||||
const shortAccessLabel = t(
|
||||
isFull ? "thread.composer.workspace.fullShort" : "thread.composer.workspace.defaultShort",
|
||||
);
|
||||
const accessAriaLabel = `${t("thread.composer.workspace.accessAria")}: ${accessLabel}`;
|
||||
const coarsePointer = useMediaQuery("(pointer: coarse)");
|
||||
const [open, setOpen] = useState(false);
|
||||
const restoreTriggerFocus = useRef(true);
|
||||
const descriptionId = useId();
|
||||
const isFull = scope.access_mode === "full";
|
||||
const label = t(isFull ? "thread.composer.workspace.full" : "thread.composer.workspace.default");
|
||||
const description = t(isFull ? "thread.composer.workspace.fullDescription" : "thread.composer.workspace.defaultDescription");
|
||||
const accessAriaLabel = `${t("thread.composer.workspace.accessAria")}: ${label}`;
|
||||
const AccessIcon = isFull ? FullAccessIcon : RestrictedAccessIcon;
|
||||
|
||||
useEffect(() => { if (disabled || !onChange) setOpen(false); }, [disabled, onChange]);
|
||||
|
||||
return (
|
||||
<HoverHint side="top" contentClassName="w-max max-w-[calc(100vw-2rem)] text-left leading-relaxed"
|
||||
content={t(isFull ? "thread.composer.workspace.fullDescription" : "thread.composer.workspace.defaultDescription")}>
|
||||
<Button
|
||||
type="button"
|
||||
variant={null}
|
||||
aria-label={accessAriaLabel}
|
||||
aria-pressed={isFull}
|
||||
disabled={disabled || !onChange}
|
||||
onClick={() => onChange?.(scopeWithAccessMode(scope, isFull ? "restricted" : "full"))}
|
||||
<DropdownMenu open={open} onOpenChange={setOpen}>
|
||||
<HoverHint enabled={!open && !coarsePointer} content={description}>
|
||||
<DropdownMenuTrigger asChild disabled={disabled || !onChange}>
|
||||
<button type="button" aria-label={accessAriaLabel} aria-describedby={descriptionId}
|
||||
onPointerDown={() => { restoreTriggerFocus.current = false; }}
|
||||
onKeyDown={() => { restoreTriggerFocus.current = true; }}
|
||||
className={cn(
|
||||
"settings-hover thread-composer-access touch-target min-w-0 max-w-[min(12.5rem,42vw)] whitespace-nowrap rounded-control border border-transparent font-semibold shadow-none",
|
||||
isHero ? "h-8 px-2.5 text-[12px]" : "h-9 px-3 text-[12.5px]",
|
||||
isFull
|
||||
? "bg-transparent text-orange-600 hover:text-orange-600 dark:text-orange-300 dark:hover:text-orange-300"
|
||||
: "bg-transparent text-muted-foreground hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{isFull ? (
|
||||
<FullAccessIcon className={cn("thread-composer-access-icon mr-1.5 shrink-0", isHero ? "h-3.5 w-3.5" : "h-3.5 w-3.5")} />
|
||||
) : (
|
||||
<RestrictedAccessIcon className={cn("thread-composer-access-icon mr-1.5 shrink-0", isHero ? "h-3.5 w-3.5" : "h-3.5 w-3.5")} />
|
||||
)}
|
||||
<span aria-hidden className="thread-composer-access-label-full min-w-0 truncate">
|
||||
{accessLabel}
|
||||
"thread-composer-access touch-target inline-flex h-8 min-w-0 max-w-full shrink items-center gap-1.5 rounded-md px-2 text-[12px] font-medium outline-none transition-colors motion-reduce:transition-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-55",
|
||||
isFull ? "text-orange-600 hover:text-orange-700 dark:text-orange-300 dark:hover:text-orange-200" : "text-muted-foreground hover:text-foreground",
|
||||
)}>
|
||||
<AccessIcon className="h-3.5 w-3.5 shrink-0" />
|
||||
<span className="min-w-0 truncate">{label}</span>
|
||||
<ChevronDown className="h-3 w-3 shrink-0" aria-hidden />
|
||||
<span id={descriptionId} className="sr-only">{description}</span>
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
</HoverHint>
|
||||
<DropdownMenuContent side="top" align="start" sideOffset={8} aria-label={t("thread.composer.workspace.accessAria")}
|
||||
onPointerDownCapture={() => { restoreTriggerFocus.current = false; }}
|
||||
onKeyDownCapture={() => { restoreTriggerFocus.current = true; }}
|
||||
onPointerDownOutside={() => { restoreTriggerFocus.current = false; }}
|
||||
onCloseAutoFocus={event => { if (!restoreTriggerFocus.current) event.preventDefault(); }}
|
||||
className="w-max min-w-[13rem] max-w-[calc(100vw-2rem)]">
|
||||
{(["restricted", "full"] as const).map(mode => {
|
||||
const full = mode === "full";
|
||||
const optionLabel = t(full ? "thread.composer.workspace.full" : "thread.composer.workspace.default");
|
||||
const OptionIcon = full ? FullAccessIcon : RestrictedAccessIcon;
|
||||
return <DropdownMenuItem key={mode} role="menuitemradio" aria-checked={scope.access_mode === mode} aria-label={optionLabel}
|
||||
className="touch-target gap-2.5"
|
||||
onSelect={() => { if (!disabled && scope.access_mode !== mode) onChange?.(scopeWithAccessMode(scope, mode)); }}>
|
||||
<OptionIcon className={full ? "text-orange-600 dark:text-orange-300" : undefined} />
|
||||
<span className="min-w-0 flex-1">{optionLabel}</span>
|
||||
<span aria-hidden className="flex h-3.5 w-3.5 shrink-0 items-center justify-center">
|
||||
{scope.access_mode === mode && <Check className={cn("h-3.5 w-3.5", full && "text-orange-600 dark:text-orange-300")} />}
|
||||
</span>
|
||||
<span aria-hidden className="thread-composer-access-label-short hidden min-w-0 truncate">
|
||||
{shortAccessLabel}
|
||||
</span>
|
||||
</Button>
|
||||
</HoverHint>
|
||||
</DropdownMenuItem>;
|
||||
})}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user