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.

fix(soup): hide disabled context menu items (#2185)

Evan Hutnikc9de926bcd14
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx
index f20d797492..a2c6e8ef7a 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx
@@ -17,6 +17,7 @@ import {
import type { SoupState } from '../create-soup-state';
import { useUserId } from '@core/context/user';
import { useAnalytics } from '@app/component/analytics-context';
+import { Show } from 'solid-js';
interface SoupEntityActionsMenuProps {
entities: EntityData[];
@@ -105,79 +106,106 @@ export const SoupEntityActionsMenu = (props: SoupEntityActionsMenuProps) => {
}
};
+ const showTopGroup = () =>
+ canExecuteAny(markDone.canExecute) || canOpenInSplit();
+
+ const showMiddleGroup = () =>
+ canExecuteAll(renameAction.canExecute) ||
+ canExecuteAny(moveToProjectAction.canExecute) ||
+ canExecuteAny(copyAction.canExecute) ||
+ props.entities.length === 1 ||
+ canExecuteAll(blockSenderAction.canExecute);
+
+ const showDeleteGroup = () => canExecuteAll(deleteAction.canExecute);
+
return (
<>
- <MenuItem
- text="Mark Done"
- disabled={!canExecuteAny(markDone.canExecute)}
- onClick={() => handleAction(markDone.executeWithSoup)}
- />
-
- <MenuItem
- text="Open in new split"
- disabled={!canOpenInSplit()}
- onClick={openInNewSplit}
- />
-
- <Divider />
-
- <MenuItem
- text="Rename"
- disabled={!canExecuteAll(renameAction.canExecute)}
- onClick={() => handleAction(renameAction.executeWithSoup)}
- />
-
- <MenuItem
- text="Move to folder"
- disabled={!canExecuteAny(moveToProjectAction.canExecute)}
- onClick={() => handleAction(moveToProjectAction.executeWithSoup)}
- />
-
- <MenuItem
- text="Duplicate"
- disabled={!canExecuteAny(copyAction.canExecute)}
- onClick={() => handleAction(copyAction.executeWithSoup)}
- />
-
- <MenuItem
- text="Copy Link"
- disabled={props.entities.length !== 1}
- onClick={() => handleAction(copyLinkAction.executeWithSoup)}
- />
-
- <MenuItem
- text="Copy Branch Name"
- disabled={
- props.entities.length !== 1 ||
- !copyBranchNameAction.canExecute(props.entities[0])
- }
- onClick={() => handleAction(copyBranchNameAction.executeWithSoup)}
- />
-
- <MenuItem
- text="Share"
- disabled={
- props.entities.length !== 1 ||
- !shareAction.canExecute(props.entities[0])
- }
- onClick={() => handleAction(shareAction.executeWithSoup)}
- />
+ <Show when={canExecuteAny(markDone.canExecute)}>
+ <MenuItem
+ text="Mark Done"
+ onClick={() => handleAction(markDone.executeWithSoup)}
+ />
+ </Show>
- <MenuItem
- text="Block Sender"
- disabled={!canExecuteAll(blockSenderAction.canExecute)}
- onClick={() => handleAction(blockSenderAction.executeWithSoup)}
- />
+ <Show when={canOpenInSplit()}>
+ <MenuItem text="Open in new split" onClick={openInNewSplit} />
+ </Show>
+
+ <Show when={showTopGroup() && (showMiddleGroup() || showDeleteGroup())}>
+ <Divider />
+ </Show>
+
+ <Show when={canExecuteAll(renameAction.canExecute)}>
+ <MenuItem
+ text="Rename"
+ onClick={() => handleAction(renameAction.executeWithSoup)}
+ />
+ </Show>
+
+ <Show when={canExecuteAny(moveToProjectAction.canExecute)}>
+ <MenuItem
+ text="Move to folder"
+ onClick={() => handleAction(moveToProjectAction.executeWithSoup)}
+ />
+ </Show>
- <Divider />
+ <Show when={canExecuteAny(copyAction.canExecute)}>
+ <MenuItem
+ text="Duplicate"
+ onClick={() => handleAction(copyAction.executeWithSoup)}
+ />
+ </Show>
+
+ <Show when={props.entities.length === 1}>
+ <MenuItem
+ text="Copy Link"
+ onClick={() => handleAction(copyLinkAction.executeWithSoup)}
+ />
+ </Show>
+
+ <Show
+ when={
+ props.entities.length === 1 &&
+ copyBranchNameAction.canExecute(props.entities[0])
+ }
+ >
+ <MenuItem
+ text="Copy Branch Name"
+ onClick={() => handleAction(copyBranchNameAction.executeWithSoup)}
+ />
+ </Show>
+
+ <Show
+ when={
+ props.entities.length === 1 &&
+ shareAction.canExecute(props.entities[0])
+ }
+ >
+ <MenuItem
+ text="Share"
+ onClick={() => handleAction(shareAction.executeWithSoup)}
+ />
+ </Show>
- <div class="text-failure-ink w-full">
+ <Show when={canExecuteAll(blockSenderAction.canExecute)}>
<MenuItem
- text="Delete"
- disabled={!canExecuteAll(deleteAction.canExecute)}
- onClick={() => handleAction(deleteAction.executeWithSoup)}
+ text="Block Sender"
+ onClick={() => handleAction(blockSenderAction.executeWithSoup)}
/>
- </div>
+ </Show>
+
+ <Show when={showDeleteGroup() && showMiddleGroup()}>
+ <Divider />
+ </Show>
+
+ <Show when={showDeleteGroup()}>
+ <div class="text-failure-ink w-full">
+ <MenuItem
+ text="Delete"
+ onClick={() => handleAction(deleteAction.executeWithSoup)}
+ />
+ </div>
+ </Show>
</>
);
};