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(soup): share email threads from the context menu (#6069)

Peter Chinmancb7d1063786f
diff --git a/apps/web/src/features/next-soup/actions/make-share-action.ts b/apps/web/src/features/next-soup/actions/make-share-action.ts
index 31542945af..24b032074c 100644
--- a/apps/web/src/features/next-soup/actions/make-share-action.ts
+++ b/apps/web/src/features/next-soup/actions/make-share-action.ts
@@ -1,8 +1,8 @@
+import { openGlobalShareModal } from '@app/features/sharing/global-share-modal/GlobalShareModal';
import {
isShareableEntityType,
- openGlobalShareModal,
type ShareableEntityData,
-} from '@app/features/sharing/global-share-modal/GlobalShareModal';
+} from '@app/features/sharing/global-share-modal/shareable-entity';
import type { EntityData } from '@entity';
import type { SoupState } from '../create-soup-state';
diff --git a/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.ts b/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.ts
index c6bed1301d..f3cffa249f 100644
--- a/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.ts
+++ b/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.ts
@@ -6,7 +6,7 @@ import {
} from '@app/features/next-soup/utils';
import { useAllProperties } from '@app/features/property/editor/hooks/useAllProperties';
import { openPropertyEditor } from '@app/features/property/editor/state/propertyEditor';
-import { isShareableEntityType } from '@app/features/sharing/global-share-modal/GlobalShareModal';
+import { isShareableEntityType } from '@app/features/sharing/global-share-modal/shareable-entity';
import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
import type { SplitHandle } from '@components/app/split-layout/layoutManager';
import { useUserId } from '@core/context/user';
diff --git a/apps/web/src/features/sharing/global-share-modal/GlobalShareModal.tsx b/apps/web/src/features/sharing/global-share-modal/GlobalShareModal.tsx
index a04c253a26..5f1e4dc7ec 100644
--- a/apps/web/src/features/sharing/global-share-modal/GlobalShareModal.tsx
+++ b/apps/web/src/features/sharing/global-share-modal/GlobalShareModal.tsx
@@ -3,16 +3,12 @@ import { Permissions } from '@core/component/SharePermissions';
import { ShareModal } from '@core/component/TopBar/ShareButton';
import { itemToBlockName } from '@core/constant/allBlocks';
import { createControlledOpenSignal } from '@core/util/createControlledOpenSignal';
-import type { EntityData } from '@entity';
import type { ItemType } from '@service-storage/client';
import { createSignal, Show } from 'solid-js';
-
-type ShareableEntityType = 'document' | 'chat' | 'project';
-
-export type ShareableEntityData = Extract<
- EntityData,
- { type: ShareableEntityType }
->;
+import {
+ isShareableEntityType,
+ type ShareableEntityData,
+} from './shareable-entity';
type GlobalShareModalProps = {
entity: ShareableEntityData;
@@ -25,12 +21,6 @@ const [modalOpen, setModalOpen] = createControlledOpenSignal(false, {
id: 'global-share',
});
-export const isShareableEntityType = (
- type: EntityData['type']
-): type is ShareableEntityType => {
- return type === 'document' || type === 'chat' || type === 'project';
-};
-
const getEntityBlockAlias = (
entity: ShareableEntityData
): BlockName | BlockAlias => {
diff --git a/apps/web/src/features/sharing/global-share-modal/shareable-entity.ts b/apps/web/src/features/sharing/global-share-modal/shareable-entity.ts
new file mode 100644
index 0000000000..3f8d6daaa7
--- /dev/null
+++ b/apps/web/src/features/sharing/global-share-modal/shareable-entity.ts
@@ -0,0 +1,25 @@
+import { ENABLE_EMAIL_SHARING } from '@core/constant/featureFlags';
+import type { EntityData } from '@entity';
+
+/** Entity types the global share modal knows how to open. */
+export type ShareableEntityType = 'document' | 'chat' | 'project' | 'email';
+
+/** The subset of {@link EntityData} the global share modal accepts. */
+export type ShareableEntityData = Extract<
+ EntityData,
+ { type: ShareableEntityType }
+>;
+
+/**
+ * Whether an entity type can be shared. Callers use this to decide whether to
+ * offer a Share affordance (soup context menu, hotkey) at all; the modal
+ * itself still enforces permissions.
+ */
+export const isShareableEntityType = (
+ type: EntityData['type']
+): type is ShareableEntityType => {
+ // Email threads share through the same modal, which forwards the thread to
+ // a channel. Gated by the flag that also gates the email block's Share tool.
+ if (type === 'email') return ENABLE_EMAIL_SHARING;
+ return type === 'document' || type === 'chat' || type === 'project';
+};
diff --git a/apps/web/src/features/sharing/global-share-modal/tests/shareable-entity.test.ts b/apps/web/src/features/sharing/global-share-modal/tests/shareable-entity.test.ts
new file mode 100644
index 0000000000..402dae3c7a
--- /dev/null
+++ b/apps/web/src/features/sharing/global-share-modal/tests/shareable-entity.test.ts
@@ -0,0 +1,17 @@
+import { describe, expect, it } from 'vitest';
+import { isShareableEntityType } from '../shareable-entity';
+
+describe('isShareableEntityType', () => {
+ it('accepts the entity types the share modal can open', () => {
+ expect(isShareableEntityType('document')).toBe(true);
+ expect(isShareableEntityType('chat')).toBe(true);
+ expect(isShareableEntityType('project')).toBe(true);
+ expect(isShareableEntityType('email')).toBe(true);
+ });
+
+ it('rejects entity types with no share flow', () => {
+ expect(isShareableEntityType('channel')).toBe(false);
+ expect(isShareableEntityType('call')).toBe(false);
+ expect(isShareableEntityType('reminder')).toBe(false);
+ });
+});