Repository navigation
feat(mobile): workspace header ⋯ is a menu, with Delete back in it #7816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)"), | ||
| ); | ||
| }; | ||
|
Comment on lines
+80
to
+94
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: rg -n 'deleteWorkspace|onConfirmed|useDeleteWorkspace|Delete workspace' 'apps/mobile/screens/(authenticated)/workspace' | head -100
git show 6391fa0c41eac4fc2d51a9f3f4a397828040e0ab:'apps/mobile/screens/(authenticated)/workspace/[id]/WorkspaceScreen/WorkspaceScreen.tsx' | rg -n -C 8 'actions|ellipsis'Repository: superset-sh/superset Length of output: 2224 🏁 Script executed: set -eu
base=6391fa0c41eac4fc2d51a9f3f4a397828040e0ab
head=89e012e46e348362e9c63508eb39a4a73d50b32d
printf '%s\n' '--- base workspace actions-related files ---'
git ls-tree -r --name-only "$base" -- 'apps/mobile/screens/(authenticated)/workspace' | rg 'actions|WorkspaceScreen|useWorkspaceHeaderActions|useDeleteWorkspace'
printf '%s\n' '--- base actions references in workspace tree ---'
git grep -n -E 'useDeleteWorkspace|remove\(|dismissTo|router\.(back|dismiss|replace|push)|Delete workspace|deleteWorkspace' "$base" -- 'apps/mobile/screens/(authenticated)/workspace' | head -160
printf '%s\n' '--- base workspace actions route files ---'
for f in $(git ls-tree -r --name-only "$base" -- 'apps/mobile/screens/(authenticated)/workspace' | rg 'actions'); do
printf '\n### %s\n' "$f"
git show "$base:$f" | sed -n '1,240p'
done
printf '%s\n' '--- base and head useWorkspaceHeaderActions ---'
for rev in "$base" "$head"; do
printf '\n### %s\n' "$rev"
git show "$rev:apps/mobile/screens/(authenticated)/workspace/[id]/hooks/useWorkspaceHeaderActions/useWorkspaceHeaderActions.ts" | sed -n '1,180p'
done
printf '%s\n' '--- delete hook ---'
sed -n '1,220p' 'apps/mobile/hooks/useDeleteWorkspace/useDeleteWorkspace.ts'Repository: superset-sh/superset Length of output: 45525 🏁 Script executed: set -eu
base=6391fa0c41eac4fc2d51a9f3f4a397828040e0ab
head=89e012e46e348362e9c63508eb39a4a73d50b32d
git ls-tree -r --name-only "$base" -- 'apps/mobile/screens/(authenticated)/workspace' | rg 'actions|useWorkspaceHeaderActions|useDeleteWorkspace'
git grep -n -E 'useDeleteWorkspace|remove\(|dismissTo|router\.(back|dismiss|replace|push)|Delete workspace|deleteWorkspace' "$base" -- 'apps/mobile/screens/(authenticated)/workspace' | head -160
for f in $(git ls-tree -r --name-only "$base" -- 'apps/mobile/screens/(authenticated)/workspace' | rg 'actions'); do
printf '\n### %s\n' "$f"
git show "$base:$f" | sed -n '1,240p'
done
for rev in "$base" "$head"; do
printf '\n### %s useWorkspaceHeaderActions\n' "$rev"
git show "$rev:apps/mobile/screens/(authenticated)/workspace/[id]/hooks/useWorkspaceHeaderActions/useWorkspaceHeaderActions.ts" | sed -n '1,180p'
done
printf '\n### delete hook\n'
sed -n '1,220p' apps/mobile/hooks/useDeleteWorkspace/useDeleteWorkspace.tsRepository: superset-sh/superset Length of output: 45525 Navigate home only after deletion succeeds. The base 🤖 Prompt for AI Agents |
||
|
|
||
| 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, | ||
| }; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Provide an Android icon for the workspace menu.
On Android, Expo Router 57 silently drops the SF Symbol string used for this menu’s ellipsis icon. The new toolbar control therefore has no visible icon. Its action icons also disappear. Supply Android image sources for the menu root and action icons while keeping SF Symbols on iOS. (docs.expo.dev)
🤖 Prompt for AI Agents