Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(projects): move Delete project into a Project actions menu (#7458)

teo48733cb19b72
diff --git a/apps/web/src/components/entity-detail/EntityDetailTopBar.tsx b/apps/web/src/components/entity-detail/EntityDetailTopBar.tsx
index 5c0d721483..43bdeb2165 100644
--- a/apps/web/src/components/entity-detail/EntityDetailTopBar.tsx
+++ b/apps/web/src/components/entity-detail/EntityDetailTopBar.tsx
@@ -6,14 +6,16 @@ import { EntityDetailBreadcrumbSkeleton } from './EntityDetailBreadcrumbSkeleton
/** The shared Tasks detail chrome for tasks and native projects. */
export function EntityDetailTopBar(
- props: ParentProps<{ navigation?: JSX.Element }>
+ props: ParentProps<{ navigation?: JSX.Element; titleMenu?: JSX.Element }>
) {
return (
<ViewShell.TopBar class={cn('touch:flex', props.navigation && 'gap-3')}>
<ViewBreadcrumbs.Outlet
aria-label="Task location"
fallback={<EntityDetailBreadcrumbSkeleton />}
- />
+ >
+ {props.titleMenu}
+ </ViewBreadcrumbs.Outlet>
<Show when={props.navigation}>
<div class="min-w-0 overflow-x-auto">{props.navigation}</div>
</Show>
diff --git a/apps/web/src/features/projects/components/project-row-menu.test.tsx b/apps/web/src/features/projects/components/project-row-menu.test.tsx
new file mode 100644
index 0000000000..f01195a8ea
--- /dev/null
+++ b/apps/web/src/features/projects/components/project-row-menu.test.tsx
@@ -0,0 +1,131 @@
+import { cleanup, render, screen, waitFor } from '@solidjs/testing-library';
+import type { ParentProps } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import type { ProjectRow } from '../context/projects-context';
+import type { ProjectAccess } from '../core/project';
+import { ProjectMenuDropdown } from './project-row-menu';
+
+vi.mock('@core/mobile/isMobile', () => ({ isMobile: () => false }));
+vi.mock('@app/components/ui/components/Tooltip', () => ({
+ Tooltip: (props: ParentProps) => props.children,
+}));
+vi.mock('@entity', () => ({
+ InlineEntity: (props: { entity: { name: string } }) => props.entity.name,
+}));
+
+let animationStyle: HTMLStyleElement;
+beforeEach(() => {
+ vi.spyOn(window, 'scrollTo').mockImplementation(() => {});
+ vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ }
+ );
+ Object.defineProperty(HTMLElement.prototype, 'scrollIntoView', {
+ configurable: true,
+ value: vi.fn(),
+ });
+ animationStyle = document.createElement('style');
+ animationStyle.textContent = '* { animation-name: none !important; }';
+ document.head.append(animationStyle);
+});
+afterEach(() => {
+ cleanup();
+ vi.unstubAllGlobals();
+ animationStyle.remove();
+ vi.restoreAllMocks();
+});
+
+const project = (access: ProjectAccess): ProjectRow => ({
+ project: { id: 'launch', name: 'Launch', updatedAt: '', access },
+ properties: [],
+});
+
+function setup(row: ProjectRow) {
+ const onDelete = vi.fn();
+ render(() => (
+ <ProjectMenuDropdown
+ targets={() => [row]}
+ canOpenInNewSplit
+ onOpenInNewSplit={vi.fn()}
+ onRename={vi.fn()}
+ onSetOption={vi.fn()}
+ onCopyLink={vi.fn()}
+ onCopyId={vi.fn()}
+ onShare={vi.fn()}
+ onDelete={onDelete}
+ />
+ ));
+ return { onDelete };
+}
+
+// jsdom has no PointerEvent, so a mouse press is a MouseEvent tagged as one.
+function click(element: Element) {
+ for (const type of ['pointerdown', 'pointerup']) {
+ const event = new MouseEvent(type, {
+ bubbles: true,
+ cancelable: true,
+ button: 0,
+ });
+ Object.defineProperty(event, 'pointerType', { value: 'mouse' });
+ element.dispatchEvent(event);
+ }
+}
+
+async function openMenu() {
+ click(screen.getByRole('button', { name: 'Project actions' }));
+ await screen.findByRole('menu');
+}
+
+const entries = () =>
+ screen
+ .getAllByRole('menuitem')
+ .map((item) => item.firstChild?.textContent ?? '');
+
+describe('project actions dropdown', () => {
+ it('offers an owner every action the row menu has', async () => {
+ setup(project('owner'));
+ await openMenu();
+ expect(entries()).toEqual([
+ 'Open in new split',
+ 'Rename',
+ 'Copy Link',
+ 'Copy ID',
+ 'Share',
+ 'Delete',
+ ]);
+ });
+
+ it('deletes the project it was opened for', async () => {
+ const { onDelete } = setup(project('owner'));
+ await openMenu();
+ click(screen.getByRole('menuitem', { name: 'Delete' }));
+ await waitFor(() =>
+ expect(onDelete).toHaveBeenCalledWith([
+ {
+ project: {
+ id: 'launch',
+ name: 'Launch',
+ updatedAt: '',
+ access: 'owner',
+ },
+ properties: [],
+ },
+ ])
+ );
+ });
+
+ it('keeps view access to navigation and links', async () => {
+ setup(project('view'));
+ await openMenu();
+ expect(entries()).toEqual([
+ 'Open in new split',
+ 'Copy Link',
+ 'Copy ID',
+ 'Share',
+ ]);
+ });
+});
diff --git a/apps/web/src/features/projects/components/project-row-menu.tsx b/apps/web/src/features/projects/components/project-row-menu.tsx
index 74eecfa8e0..7bf09fb132 100644
--- a/apps/web/src/features/projects/components/project-row-menu.tsx
+++ b/apps/web/src/features/projects/components/project-row-menu.tsx
@@ -13,9 +13,11 @@ import { touchHandler } from '@core/directive/touchHandler';
import { isMobile } from '@core/mobile/isMobile';
import type { InitiativeEntity } from '@entity';
import { ContextMenu } from '@kobalte/core/context-menu';
+import DotsThreeIcon from '@phosphor/dots-three.svg';
import { PropertyValueIcon } from '@property/component/propertyValue';
import type { Property } from '@property/types';
import { formatOptionValue } from '@property/utils/formatting';
+import { Dropdown } from '@ui';
import {
createSignal,
For,
@@ -28,7 +30,7 @@ import { match } from 'ts-pattern';
import type { ProjectRow } from '../context/projects-context';
import { type ProjectMenuItem, projectMenuGroups } from '../core/project-menu';
-type ProjectRowMenuProps = {
+type ProjectMenuProps = {
/** The projects the menu acts on, read each time it opens. */
targets(): readonly ProjectRow[];
/** Definitions offering the choices; their entries wait until they load. */
@@ -70,7 +72,7 @@ type ProjectMenuEntry =
};
function projectMenuEntries(
- props: ProjectRowMenuProps,
+ props: ProjectMenuProps,
rows: readonly ProjectRow[]
): ProjectMenuEntry[][] {
const single = (callback?: (row: ProjectRow) => void) => () => {
@@ -188,7 +190,7 @@ const initiativeEntity = (row: ProjectRow): InitiativeEntity => ({
*/
export function ProjectRowMenu(
props: ParentProps<
- ProjectRowMenuProps & {
+ ProjectMenuProps & {
onOpenChange(open: boolean): void;
onCloseAutoFocus?(event: Event): void;
}
@@ -236,7 +238,7 @@ export function ProjectRowMenu(
</ContextMenuTrigger>
<ContextMenu.Portal>
<ContextMenuContent
- class="w-56 text-xs text-ink-muted"
+ class="w-64 text-xs text-ink-muted"
onCloseAutoFocus={props.onCloseAutoFocus}
>
<ProjectMenuItems {...props} />
@@ -248,7 +250,22 @@ export function ProjectRowMenu(
);
}
-function ProjectMenuItems(props: ProjectRowMenuProps) {
+export function ProjectMenuDropdown(props: ProjectMenuProps) {
+ return (
+ <Dropdown placement="bottom-start">
+ <Dropdown.Trigger variant="ghost" size="icon-sm" label="Project actions">
+ <DotsThreeIcon />
+ </Dropdown.Trigger>
+ <Dropdown.Content class="w-64 text-xs text-ink-muted">
+ <Dropdown.Group>
+ <ProjectMenuItems {...props} />
+ </Dropdown.Group>
+ </Dropdown.Content>
+ </Dropdown>
+ );
+}
+
+function ProjectMenuItems(props: ProjectMenuProps) {
// Mounted per opening, so the entries match the rows they act on.
const entries = projectMenuEntries(props, props.targets());
return (
diff --git a/apps/web/src/features/projects/project-detail.tsx b/apps/web/src/features/projects/project-detail.tsx
index 31b7d66b75..8b8086776c 100644
--- a/apps/web/src/features/projects/project-detail.tsx
+++ b/apps/web/src/features/projects/project-detail.tsx
@@ -1,11 +1,16 @@
import { EntityDetailTopBar } from '@app/components/entity-detail/EntityDetailTopBar';
import { ViewBreadcrumbs } from '@app/components/view-shell';
+import {
+ makeCopyEntityIdAction,
+ makeCopyLinkAction,
+} from '@app/features/next-soup/actions';
import { useNavigate } from '@app/lib/split-router';
import {
projectDetailRoute,
projectTaskRoute,
tasksSplitRoute,
} from '@app/routes/routes';
+import { globalSplitManager } from '@app/signal/splitLayout';
import type { ComposeTaskProps } from '@block-md/component/ComposeTask';
import { useSplitLayout } from '@components/app/split-layout/layout';
import {
@@ -13,13 +18,20 @@ import {
useSplitPanelOrThrow,
} from '@components/app/split-layout/layoutUtils';
import { TabsInset } from '@core/component/TabsInset';
+import { toast } from '@core/component/Toast/Toast';
import { ShareTrigger } from '@core/component/TopBar/ShareButton';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import StackIcon from '@phosphor/stack.svg';
+import { SYSTEM_PROPERTY_IDS } from '@property/identifiers';
+import type { Property } from '@property/types';
import { Button } from '@ui';
-import { Match, Show, Suspense, Switch } from 'solid-js';
+import { createSignal, Match, Show, Suspense, Switch } from 'solid-js';
+import { DeleteProjectsDialog } from './components/delete-projects-dialog';
+import { ProjectMenuDropdown } from './components/project-row-menu';
import { ProjectContentSkeleton } from './components/project-skeletons';
+import { RenameProjectDialog } from './components/rename-project-dialog';
import {
+ type ProjectSource,
type ProjectsContext,
useProjectsContext,
} from './context/projects-context';
@@ -29,7 +41,8 @@ import {
type ProjectDetail as ProjectDetailData,
type ProjectSection,
} from './core/project';
-import type { ProjectRoute } from './core/route';
+import { type ProjectRoute, projectRouteId } from './core/route';
+import { openProject } from './open-project';
import { ProjectDiscussion } from './project-collaboration';
import { ProjectDescription } from './project-description';
import { useProjectShareModal } from './project-share';
@@ -85,19 +98,103 @@ type ProjectDetailProps = {
onDelete?(): void;
};
-function ProjectShareTrigger(props: {
+function ProjectTitleMenu(props: {
project: ProjectDetailData;
+ source: ProjectSource;
commands: ReturnType<ProjectsContext['createCommands']>;
+ section: ProjectSection;
+ onShare(): void;
+ onDelete(): void;
}) {
- const panel = useSplitPanelOrThrow();
- const openShare = useProjectShareModal(() => props.project, props.commands);
+ const definitions = useProjectsContext().createPropertyDefinitionsSource();
+ const layout = useSplitLayout();
+ const copyLink = makeCopyLinkAction();
+ const copyId = makeCopyEntityIdAction();
+ const [renaming, setRenaming] = createSignal(false);
+ const [deleting, setDeleting] = createSignal(false);
+ const [error, setError] = createSignal<string>();
+ const definition = (id: string) =>
+ definitions
+ .properties()
+ .find((property) => property.propertyDefinitionId === id);
+ const ownValue = (property: Property) =>
+ props.source
+ .properties()
+ .find(
+ (current) =>
+ current.propertyDefinitionId === property.propertyDefinitionId
+ ) ?? property;
+ const setOption = async (property: Property, optionId: string) => {
+ try {
+ await props.commands.saveProperty(props.project.id, ownValue(property), {
+ valueType: 'SELECT_STRING',
+ values: [optionId],
+ });
+ } catch (error) {
+ console.error('Failed to update project', error);
+ toast.failure(`Could not update ${property.displayName.toLowerCase()}`);
+ }
+ };
+ const deleteProject = async () => {
+ setError(undefined);
+ try {
+ await props.commands.delete(props.project.id);
+ props.onDelete();
+ } catch (error) {
+ setError(
+ error instanceof Error ? error.message : 'Could not delete project.'
+ );
+ }
+ };
return (
- <ShareTrigger
- onClick={openShare}
- id={props.project.id}
- blockType="initiative"
- hotkeyScope={panel.splitHotkeyScope}
- />
+ <>
+ <ProjectMenuDropdown
+ targets={() => [
+ { project: props.project, properties: props.source.properties() },
+ ]}
+ status={definition(SYSTEM_PROPERTY_IDS.STATUS)}
+ priority={definition(SYSTEM_PROPERTY_IDS.PRIORITY)}
+ canOpenInNewSplit={globalSplitManager()?.canAppendSplit() ?? false}
+ onOpenInNewSplit={(row) =>
+ openProject(layout, row.project.id, {
+ section: props.section,
+ newSplit: true,
+ })
+ }
+ onRename={() => setRenaming(true)}
+ onSetOption={(_, property, optionId) =>
+ void setOption(property, optionId)
+ }
+ onCopyLink={(row) =>
+ void copyLink.executeByBlock(
+ projectRouteId({ id: row.project.id, section: 'overview' }),
+ 'component'
+ )
+ }
+ onCopyId={(row) => void copyId.executeById(row.project.id)}
+ onShare={props.onShare}
+ onDelete={() => {
+ setError(undefined);
+ setDeleting(true);
+ }}
+ />
+ <Show when={renaming()}>
+ <RenameProjectDialog
+ name={props.project.name}
+ onOpenChange={setRenaming}
+ onRename={(name) => props.commands.rename(props.project.id, name)}
+ />
+ </Show>
+ <Show when={deleting()}>
+ <DeleteProjectsDialog
+ count={1}
+ pending={props.commands.pending()}
+ error={error()}
+ onOpenChange={setDeleting}
+ onDelete={() => void deleteProject()}
+ />
+ </Show>
+ </>
);
}
@@ -106,6 +203,8 @@ function ProjectDetailHost(props: ProjectDetailProps) {
const source = context.createProjectSource(() => props.route.id);
useSplitDisplayName(() => source.project()?.name ?? 'Project');
const commands = context.createCommands();
+ const openShare = useProjectShareModal(source.project, commands);
+ const panel = useSplitPanelOrThrow();
const layout = useSplitLayout();
const navigate = useNavigate();
const section = (section: ProjectSection) =>
@@ -133,6 +232,23 @@ function ProjectDetailHost(props: ProjectDetailProps) {
{(breadcrumb) => <ProjectBreadcrumbContent {...breadcrumb()} />}
</Show>
<EntityDetailTopBar
+ titleMenu={
+ <Show when={source.project()}>
+ {(project) => (
+ <ProjectTitleMenu
+ project={project()}
+ source={source}
+ commands={commands}
+ section={props.route.section}
+ onShare={openShare}
+ onDelete={
+ props.onDelete ??
+ (() => navigate({ route: tasksSplitRoute, params: {} }))
+ }
+ />
+ )}
+ </Show>
+ }
navigation={
<TabsInset
list={[
@@ -148,7 +264,12 @@ function ProjectDetailHost(props: ProjectDetailProps) {
>
<Show when={source.project()}>
{(project) => (
- <ProjectShareTrigger project={project()} commands={commands} />
+ <ShareTrigger
+ onClick={openShare}
+ id={project().id}
+ blockType="initiative"
+ hotkeyScope={panel.splitHotkeyScope}
+ />
)}
</Show>
</EntityDetailTopBar>
@@ -167,10 +288,6 @@ function ProjectDetailHost(props: ProjectDetailProps) {
source={source}
commands={commands}
section={props.route.section}
- onDelete={
- props.onDelete ??
- (() => navigate({ route: tasksSplitRoute, params: {} }))
- }
onOpenTask={(task, options) => {
const event = options?.event;
if (
diff --git a/apps/web/src/features/projects/views/project-workspace.tsx b/apps/web/src/features/projects/views/project-workspace.tsx
index 649e1334f6..347ed8a7f4 100644
--- a/apps/web/src/features/projects/views/project-workspace.tsx
+++ b/apps/web/src/features/projects/views/project-workspace.tsx
@@ -4,16 +4,13 @@ import { InlineTitleEditor } from '@core/component/InlineTitleEditor';
import { PropertyValuePill } from '@property/component/PropertyValuePill';
import { SYSTEM_PROPERTY_IDS } from '@property/identifiers';
import { EntityPropertiesSection } from '@property/side-panel/properties/EntityPropertiesSection';
-import { Button } from '@ui';
import { createSignal, For, type JSX, Match, Show, Switch } from 'solid-js';
-import { DeleteProjectsDialog } from '../components/delete-projects-dialog';
import {
type ProjectSource,
type ProjectsContext,
useProjectsContext,
} from '../context/projects-context';
import {
- canDeleteProject,
canEditProject,
type ProjectDetail,
type ProjectSection,
@@ -37,14 +34,12 @@ export function ProjectWorkspace(props: {
source: ProjectSource;
commands: ReturnType<ProjectsContext['createCommands']>;
section: ProjectSection;
- onDelete(): void;
onOpenTask: ProjectTasksListProps['onOpenTask'];
onCreateTask(): void;
discussion: JSX.Element;
description: JSX.Element;
}) {
const definitions = useProjectsContext().createPropertyDefinitionsSource();
- const [deleting, setDeleting] = createSignal(false);
const [error, setError] = createSignal<string>();
const canEdit = () => canEditProject(props.project);
const run = async (action: () => Promise<void>) => {
@@ -89,22 +84,6 @@ export function ProjectWorkspace(props: {
)}
</Show>
</SidePanel.Section>
- <Show when={canDeleteProject(props.project)}>
- <SidePanel.HeaderActions>
- <Button
- variant="ghost"
- size="sm"
- depth={2}
- class="gap-1.5 border border-edge-muted px-2"
- onClick={() => {
- setError(undefined);
- setDeleting(true);
- }}
- >
- Delete project
- </Button>
- </SidePanel.HeaderActions>
- </Show>
<div class="flex size-full min-h-0 min-w-0 flex-col overflow-hidden">
<Show when={error()}>
{(message) => (
@@ -191,22 +170,6 @@ export function ProjectWorkspace(props: {
</Switch>
</div>
</div>
- <Show when={deleting()}>
- <DeleteProjectsDialog
- count={1}
- pending={props.commands.pending()}
- error={error()}
- onOpenChange={(open) => {
- if (!open) setDeleting(false);
- }}
- onDelete={() =>
- void run(async () => {
- await props.commands.delete(props.project.id);
- props.onDelete();
- })
- }
- />
- </Show>
</SidePanel.Layout>
);
}
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 0bb8b04cac..cd69c6a369 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -2658,8 +2658,8 @@ contracts and test coverage.
Actions live in the top bar immediately before Share, with consistent compact
buttons (labels collapse on narrow headers). There are no Actions sections in
information panels. Markdown/tasks include Ask Macro and document/task dispatch; email
-includes Ask Macro and Create task; PDF and calls include Ask Macro; native
-projects expose Delete project with its existing confirmation dialog.
+includes Ask Macro and Create task; PDF and calls include Ask Macro. Native
+projects put Delete in the `Project actions` menu after the project title.
Standard metadata is quiet, non-collapsible text at the bottom of each panel,
separated by a muted divider. Owner and available timestamps share one format;
diff --git a/docs/AGENT_GUIDE/tasks.md b/docs/AGENT_GUIDE/tasks.md
index 62b453f0f6..d7ececaca5 100644
--- a/docs/AGENT_GUIDE/tasks.md
+++ b/docs/AGENT_GUIDE/tasks.md
@@ -401,7 +401,9 @@ Closing the popover without submitting keeps the underlying view open.
Opening a project keeps the Tasks workspace and its navigation. The top bar
shows the Projects return breadcrumb and the project name, with the same Share
-and side-panel controls as task detail. Choose Overview or Tasks using the inset
+and side-panel controls as task detail. `Project actions` (the dots button
+after the name) opens the row context menu's entries for this project,
+including `Delete` for its owner. Choose Overview or Tasks using the inset
tabs in that top bar. In Tasks, an outlined circular search button expands into
a focused `Search in <project name>` field. Close or Escape clears the query and
restores focus to the button. The task toolbar stays the same height and scrolls