Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(crm): add Hide/Unhide soup context action for companies (#4208)
Evan Hutnik2bf8d16284dd
diff --git a/js/app/packages/app/component/next-soup/actions/index.ts b/js/app/packages/app/component/next-soup/actions/index.tsindex 6c3d160ebc..44728348ce 100644--- a/js/app/packages/app/component/next-soup/actions/index.ts+++ b/js/app/packages/app/component/next-soup/actions/index.ts@@ -4,6 +4,7 @@ export { makeCopyBranchNameAction } from './make-copy-branch-name-action';export { makeCopyEntityIdAction } from './make-copy-entity-id-action';export { makeCopyLinkAction } from './make-copy-link-action';export { makeDeleteAction } from './make-delete-action';+export { makeHideCompanyAction } from './make-hide-company-action';export { makeMarkDoneAction } from './make-mark-done-action';export { makeMarkSenderSignalAction } from './make-mark-sender-important-action';export { makeMarkSenderNoiseAction } from './make-mark-sender-noise-action';diff --git a/js/app/packages/app/component/next-soup/actions/make-hide-company-action.ts b/js/app/packages/app/component/next-soup/actions/make-hide-company-action.tsnew file mode 100644index 0000000000..cdb563eff8--- /dev/null+++ b/js/app/packages/app/component/next-soup/actions/make-hide-company-action.ts@@ -0,0 +1,49 @@+import { useMaybePreviewPanel } from '@app/component/PreviewPanel';+import { toast } from '@core/component/Toast/Toast';+import type { EntityData } from '@entity';+import type { SoupState } from '../create-soup-state';+import { restoreSoupFocus } from '../utils';++type MakeHideCompanyOptions = {+ // Admin/owner-only on the FE; the backend independently enforces+ // EditAccessLevel on PUT /crm/companies/{id}/hidden.+ isTeamAdmin: () => boolean;+ setHidden: (companyId: string, hidden: boolean) => Promise<unknown>;+};++export const makeHideCompanyAction = (options: MakeHideCompanyOptions) => {+ const { isTeamAdmin, setHidden } = options;++ const canExecute = (entity: EntityData): boolean =>+ entity.type === 'crm_company' && isTeamAdmin();++ const previewPanel = useMaybePreviewPanel();++ const executeWithSoup = async (entities: EntityData[], soup: SoupState) => {+ const entity = entities[0];+ if (entity?.type !== 'crm_company') return;++ // The row leaves (Hide) or joins (Unhide) the active list once soup+ // refetches, so move focus to a neighbour first — same as delete.+ const currentIndex = soup.focus.index();+ const nextRow =+ soup.items.at(currentIndex + 1) ?? soup.items.at(currentIndex - 1);+ const inPreview = previewPanel !== undefined;++ const hidden = entity.hidden;++ soup.selection.clear();+ if (nextRow) soup.focus.set(nextRow.id);++ try {+ await setHidden(entity.id, !hidden);+ toast.success(hidden ? 'Unhidden' : 'Hidden');+ } catch {+ toast.failure(hidden ? 'Failed to unhide' : 'Failed to hide');+ }++ await restoreSoupFocus(nextRow?.id, inPreview);+ };++ return { canExecute, executeWithSoup };+};diff --git a/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts b/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.tsindex f18a9fdaa1..770ac904a8 100644--- a/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts+++ b/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts@@ -8,6 +8,8 @@ import { fileTypeToBlockName, itemToBlockName } from '@core/constant/allBlocks';import { useUserId } from '@core/context/user';import { isMobile } from '@core/mobile/isMobile';import type { EntityData } from '@entity';+import { useSetCompanyHiddenMutation } from '@queries/crm/companies';+import { useIsTeamAdmin } from '@queries/team/teams';import {makeBlockSenderAction,makeCopyAction,@@ -15,6 +17,7 @@ import {makeCopyEntityIdAction,makeCopyLinkAction,makeDeleteAction,+ makeHideCompanyAction,makeMarkDoneAction,makeMarkSenderNoiseAction,makeMarkSenderSignalAction,@@ -57,6 +60,8 @@ export function createSoupEntityActions(): {const analytics = useAnalytics();const userId = useUserId();const notificationSource = useGlobalNotificationSource();+ const isTeamAdmin = useIsTeamAdmin();+ const hiddenMutation = useSetCompanyHiddenMutation();const markDone = makeMarkDoneAction({userId: () => userId(),@@ -80,6 +85,11 @@ export function createSoupEntityActions(): {const blockSenderAction = makeBlockSenderAction();const markSenderSignalAction = makeMarkSenderSignalAction();const markSenderNoiseAction = makeMarkSenderNoiseAction();+ const hideCompanyAction = makeHideCompanyAction({+ isTeamAdmin: () => isTeamAdmin(),+ setHidden: (companyId, hidden) =>+ hiddenMutation.mutateAsync({ companyId, hidden }),+ });const buildActionGroups: BuildActionGroups = (soup,@@ -288,6 +298,21 @@ export function createSoupEntityActions(): {});}+ // CRM group: Hide / Unhide (admin/owner only, single company)+ const crmItems: SoupEntityActionItem[] = [];++ const singleEntity = entities.length === 1 ? entities[0] : undefined;+ if (+ singleEntity?.type === 'crm_company' &&+ hideCompanyAction.canExecute(singleEntity)+ ) {+ crmItems.push({+ id: 'hide-company',+ label: singleEntity.hidden ? 'Unhide' : 'Hide',+ onClick: handle(hideCompanyAction.executeWithSoup),+ });+ }+// Delete groupconst deleteItems: SoupEntityActionItem[] = [];@@ -300,7 +325,7 @@ export function createSoupEntityActions(): {});}- return [topItems, middleItems, senderItems, deleteItems]+ return [topItems, middleItems, senderItems, crmItems, deleteItems].filter((items) => items.length > 0).map((items) => ({ items }));};