From 89e012e46e348362e9c63508eb39a4a73d50b32d Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Thu, 24 Sep 2026 13:20:57 -0700 Subject: [PATCH] =?UTF-8?q?feat(mobile):=20workspace=20header=20=E2=8B=AF?= =?UTF-8?q?=20is=20a=20menu,=20with=20Delete=20back=20in=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #7782 dropped Delete from the workspace sheet and left no way to delete a workspace from its own screen. The header's ⋯ button, which only opened the sheet, is now a native menu: Workspace details, Rename, Pin/Unpin, Mark as Unread, then a Copy submenu (link, ID) and Share, then Delete workspace. Groups are inline submenus so iOS draws the separators. Every item reuses a handler that already exists: rename, share, copy and delete come from useWorkspaceHeaderActions (deleteWorkspace is the handler #7782 removed, restored as it was, leaving for the list once the delete is decided); pin reads the pinned store; unread sets the manual mark, which opening the screen normally clears, so it holds until you leave. Copies thread the screen's onCopied so the header's "Copied" pill confirms them. The unread icon is a bell on both this menu and the home row's, in place of the envelope. Verified on the iPhone 17 Pro Max simulator against production: menu and submenu render with the separators, Pin flips to Unpin and back, Copy link and Copy ID land the right values on the pasteboard, and Delete shows its confirm (cancelled). --- .../WorkspaceRowMenu/WorkspaceRowMenu.tsx | 2 +- .../[id]/WorkspaceScreen/WorkspaceScreen.tsx | 71 +++++++++++++++++-- .../useWorkspaceHeaderActions.ts | 44 +++++++++++- 3 files changed, 110 insertions(+), 7 deletions(-) diff --git a/apps/mobile/screens/(authenticated)/(home)/home/components/WorkspaceRow/components/WorkspaceRowMenu/WorkspaceRowMenu.tsx b/apps/mobile/screens/(authenticated)/(home)/home/components/WorkspaceRow/components/WorkspaceRowMenu/WorkspaceRowMenu.tsx index c454536be92..4ed91edb94c 100644 --- a/apps/mobile/screens/(authenticated)/(home)/home/components/WorkspaceRow/components/WorkspaceRowMenu/WorkspaceRowMenu.tsx +++ b/apps/mobile/screens/(authenticated)/(home)/home/components/WorkspaceRow/components/WorkspaceRowMenu/WorkspaceRowMenu.tsx @@ -41,7 +41,7 @@ export function WorkspaceRowMenu({ {/* Each action is its own direct child: Link.Menu drops anything wrapped in a Fragment. */} {isUnread diff --git a/apps/mobile/screens/(authenticated)/workspace/[id]/WorkspaceScreen/WorkspaceScreen.tsx b/apps/mobile/screens/(authenticated)/workspace/[id]/WorkspaceScreen/WorkspaceScreen.tsx index 1fff9de041a..14c05aa7641 100644 --- a/apps/mobile/screens/(authenticated)/workspace/[id]/WorkspaceScreen/WorkspaceScreen.tsx +++ b/apps/mobile/screens/(authenticated)/workspace/[id]/WorkspaceScreen/WorkspaceScreen.tsx @@ -48,6 +48,7 @@ import { useSlashCommands } from "@/screens/(authenticated)/hooks/useSlashComman import { workspaceDraftKey } from "@/screens/(authenticated)/stores/composerDraftsStore"; import { useLastSessionTabStore } from "@/screens/(authenticated)/stores/lastSessionTabStore"; import { usePendingWorkspaceCreatesStore } from "@/screens/(authenticated)/stores/pendingWorkspaceCreatesStore"; +import { usePinnedWorkspacesStore } from "@/screens/(authenticated)/stores/pinnedWorkspacesStore"; import { useTerminalSeenStore } from "@/screens/(authenticated)/stores/terminalSeenStore"; import { useTerminalTabOrderStore } from "@/screens/(authenticated)/stores/terminalTabOrderStore"; import { useUnreadWorkspacesStore } from "@/screens/(authenticated)/stores/unreadWorkspacesStore"; @@ -66,6 +67,7 @@ import { } from "../components/TerminalWebView"; import { useHostCompatibility } from "../hooks/useHostCompatibility"; import { usePullRequestIconUri } from "../hooks/usePullRequestIconUri"; +import { useWorkspaceHeaderActions } from "../hooks/useWorkspaceHeaderActions"; import { useWorkspacePullRequests } from "../hooks/useWorkspacePullRequest"; import { orderTerminalRows } from "../utils/orderTerminalRows"; import { PULL_REQUEST_SYMBOL, pullRequestStatus } from "../utils/pullRequest"; @@ -353,6 +355,15 @@ export function WorkspaceScreen() { ? hostServiceUrl(host.organizationId, host.machineId) : null; const hostCompatibility = useHostCompatibility(hostUrl); + const { renameWorkspace, deleteWorkspace, copyId, copyLink, shareWorkspace } = + useWorkspaceHeaderActions(workspace, host); + const pinned = usePinnedWorkspacesStore((state) => + id ? id in state.pinnedAt : false, + ); + const togglePin = usePinnedWorkspacesStore((state) => state.togglePin); + const setManualUnread = useUnreadWorkspacesStore( + (state) => state.setManualUnread, + ); useEffect(() => { if (!id) return; @@ -842,11 +853,63 @@ export function WorkspaceScreen() { {workspace ? ( - + accessibilityLabel={t({ message: "Workspace actions" })} + > + + {t({ message: "Workspace details" })} + + void renameWorkspace()} + > + {t({ message: "Rename" })} + + id && togglePin(id)} + > + {pinned ? t({ message: "Unpin" }) : t({ message: "Pin" })} + + id && setManualUnread(id)} + > + {t({ message: "Mark as Unread" })} + + + + copyLink(handleCopied)} + > + {t({ message: "Copy link" })} + + copyId(handleCopied)}> + {t({ message: "Copy ID" })} + + + + {t({ message: "Share" })} + + + + + {t({ message: "Delete workspace" })} + + + ) : null} diff --git a/apps/mobile/screens/(authenticated)/workspace/[id]/hooks/useWorkspaceHeaderActions/useWorkspaceHeaderActions.ts b/apps/mobile/screens/(authenticated)/workspace/[id]/hooks/useWorkspaceHeaderActions/useWorkspaceHeaderActions.ts index 93843df08d4..51a24aa3d97 100644 --- a/apps/mobile/screens/(authenticated)/workspace/[id]/hooks/useWorkspaceHeaderActions/useWorkspaceHeaderActions.ts +++ b/apps/mobile/screens/(authenticated)/workspace/[id]/hooks/useWorkspaceHeaderActions/useWorkspaceHeaderActions.ts @@ -2,8 +2,10 @@ import { useLingui } from "@lingui/react/macro"; import { prompt } from "@superset/alert-prompt"; import { useQueryClient } from "@tanstack/react-query"; import * as Clipboard from "expo-clipboard"; +import { useRouter } from "expo-router"; import { Alert, Share } from "react-native"; import { useCloudWorkspaceActions } from "@/hooks/useCloudWorkspaceActions"; +import { useDeleteWorkspace } from "@/hooks/useDeleteWorkspace"; import type { HostWorkspaceRow } from "@/hooks/useHostWorkspaces"; import type { OrgHost } from "@/hooks/useOrgHosts"; import { @@ -18,8 +20,10 @@ export function useWorkspaceHeaderActions( host: OrgHost | null, ) { const { t } = useLingui(); + const router = useRouter(); const queryClient = useQueryClient(); const cloud = useCloudWorkspaceActions(); + const remove = useDeleteWorkspace(); // A sandbox is its own host, keyed by the workspace's id; its name and its // lifetime belong to the cloud row, not to anything the sandbox serves. const isCloud = host !== null && isSandboxHost(host.machineId); @@ -62,8 +66,42 @@ export function useWorkspaceHeaderActions( }); }; - const copyId = () => { - if (workspace) void Clipboard.setStringAsync(workspace.id); + const deleteWorkspace = () => { + if (!workspace) return; + if (!host) { + Alert.alert( + t({ + message: "Host is not online", + }), + ); + return; + } + remove( + { + id: workspace.id, + name: workspace.name, + type: workspace.type, + hostId: host.machineId, + hostUrl: hostServiceUrl(host.organizationId, host.machineId), + isCloud, + }, + // Nothing on this screen outlives the workspace: every panel below + // reads a row that is now gone, and the host placeholder it falls + // back to describes a machine that is perfectly fine. Leave for the + // list the moment the delete is decided. + () => router.dismissTo("/(authenticated)/(home)"), + ); + }; + + const copyId = (onCopied?: () => void) => { + if (workspace) void Clipboard.setStringAsync(workspace.id).then(onCopied); + }; + + const copyLink = (onCopied?: () => void) => { + if (!workspace) return; + void Clipboard.setStringAsync(workspaceShareUrl(workspace.id)).then( + onCopied, + ); }; const shareWorkspace = () => { @@ -75,7 +113,9 @@ export function useWorkspaceHeaderActions( return { renameWorkspace, + deleteWorkspace, copyId, + copyLink, shareWorkspace, }; }