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(channels): add a New channel button to the Chat sidebar's import card (#8579)
Jacob Beckerman9f3a4302d924
diff --git a/apps/web/src/features/connector-import/connector-import.test.tsx b/apps/web/src/features/connector-import/connector-import.test.tsxindex 037d3db139..a304d68378 100644--- a/apps/web/src/features/connector-import/connector-import.test.tsx+++ b/apps/web/src/features/connector-import/connector-import.test.tsx@@ -42,6 +42,27 @@ describe('ConnectorImportPromotion', () => {expect(host.dialog?.config.action).toBe('Import files');});+ it('renders a secondary action beside the import button', () => {+ const onClick = vi.fn();+ render(() => (+ <ConnectorImportPromotion+ category="files"+ applies+ actionLabel="Import"+ secondaryAction={{ label: 'Start fresh', onClick }}+ />+ ));+ expect(screen.getByRole('button', { name: 'Import' })).toBeTruthy();+ // The dismiss label keeps naming the full import.+ expect(+ screen.getByRole('button', { name: 'Dismiss import files' })+ ).toBeTruthy();+ const button = screen.getByRole('button', { name: 'Start fresh' });+ fireEvent.click(button);+ expect(onClick).toHaveBeenCalledWith(button);+ expect(host.dialog).toBeUndefined();+ });+it('renders nothing while it does not apply', () => {render(() => <ConnectorImportPromotion category="files" applies={false} />);expect(screen.queryByRole('button', { name: 'Import files' })).toBeNull();diff --git a/apps/web/src/features/connector-import/connector-import.tsx b/apps/web/src/features/connector-import/connector-import.tsxindex 5e0e394755..054da26974 100644--- a/apps/web/src/features/connector-import/connector-import.tsx+++ b/apps/web/src/features/connector-import/connector-import.tsx@@ -1,6 +1,7 @@import {allOf,flagVerdict,+ type PromoAction,SidebarPromotion,type Verdict,} from '@app/features/sidebar-promotion/sidebar-promotion';@@ -62,6 +63,10 @@ export function ConnectorImportPromotion(props: {/** See `SidebarPromotion`: `undefined` while the host's gates load. */applies: Verdict;alternatives?: readonly ImportAlternative[];+ /** A shorter card button label, for when a second action shares the row. */+ actionLabel?: string;+ /** A second button beside the import action, e.g. to start from scratch. */+ secondaryAction?: PromoAction;class?: string;}): JSX.Element {const pipedream = usePipedreamMcpFlag();@@ -104,7 +109,7 @@ export function ConnectorImportPromotion(props: {pitch={config().pitch}class={props.class}action={{- label: config().action,+ label: props.actionLabel ?? config().action,onClick: (trigger) => {setOpener(trigger);const [direct, ...others] = alternatives();@@ -113,6 +118,8 @@ export function ConnectorImportPromotion(props: {else openDialog(true);},}}+ secondaryAction={props.secondaryAction}+ dismissLabel={`Dismiss ${config().action.toLowerCase()}`}/></div>{/* Beside the card, so the dialog outlives the card's own gates. */}diff --git a/apps/web/src/features/connector-import/core/catalog.ts b/apps/web/src/features/connector-import/core/catalog.tsindex 5913bf18fd..8cca14dff1 100644--- a/apps/web/src/features/connector-import/core/catalog.ts+++ b/apps/web/src/features/connector-import/core/catalog.ts@@ -165,7 +165,7 @@ export const IMPORT_CATEGORIES: Record<ImportCategory, ImportCategoryConfig> = {},channels: {category: 'channels',- headline: 'Bring Slack to Macro',+ headline: 'Create or import channels',pitch:'Import Slack channels and members, with or without message history.',action: 'Import from Slack',diff --git a/apps/web/src/features/sidebar-promotion/browser-test/promotions.tsx b/apps/web/src/features/sidebar-promotion/browser-test/promotions.tsxindex 9b308696a8..cce8512139 100644--- a/apps/web/src/features/sidebar-promotion/browser-test/promotions.tsx+++ b/apps/web/src/features/sidebar-promotion/browser-test/promotions.tsx@@ -1,4 +1,5 @@import '@app/index.css';+import { IMPORT_CATEGORIES } from '@app/features/connector-import/core/catalog';import { applyTheme } from '@app/features/theme/utils/themeUtils';import { createSignal, For, Show } from 'solid-js';import { render } from 'solid-js/web';@@ -26,6 +27,15 @@ const CARDS: {copy: HOME_SETUP_PROMOTION,secondary: HOME_SETUP_PROMOTION.secondaryAction,},+ {+ sidebar: 'Chat',+ copy: {+ ...IMPORT_CATEGORIES.channels,+ logos: [...IMPORT_CATEGORIES.channels.providers],+ action: 'Import Slack',+ },+ secondary: 'New channel',+ },{ sidebar: 'Calendar', copy: CALENDAR_ACCOUNTS_PROMOTION },{ sidebar: 'Pull requests', copy: PULL_REQUEST_REPOSITORIES_PROMOTION },];diff --git a/apps/web/src/features/slack-import/slack-import-sidebar.test.tsx b/apps/web/src/features/slack-import/slack-import-sidebar.test.tsxindex d29a435120..ac0f7e99b0 100644--- a/apps/web/src/features/slack-import/slack-import-sidebar.test.tsx+++ b/apps/web/src/features/slack-import/slack-import-sidebar.test.tsx@@ -7,12 +7,15 @@ const host = vi.hoisted(() => ({enabled: true,admin: true,openHistory: vi.fn(),+ openNewChannel: vi.fn(),promotion: undefined as| undefined| {category: string;applies: boolean | undefined;alternatives: { label: string; onSelect(opener?: unknown): void }[];+ actionLabel?: string;+ secondaryAction?: { label: string; onClick(trigger: unknown): void };},slackImport: undefined as undefined | { historyOnly?: boolean },}));@@ -23,6 +26,9 @@ vi.mock('@queries/team/teams', () => ({useIsTeamAdmin: () => () => host.admin,useCurrentTeamQuery: () => ({ isSuccess: true, data: { team: { id: 't' } } }),}));+vi.mock('@channel/CreateChannelModal', () => ({+ openNewChannelModal: host.openNewChannel,+}));vi.mock('./slack-import', () => ({SlackImport: (props: {historyOnly?: boolean;@@ -45,6 +51,7 @@ beforeEach(() => {host.promotion = undefined;host.slackImport = undefined;host.openHistory.mockReset();+ host.openNewChannel.mockReset();});afterEach(cleanup);@@ -61,6 +68,14 @@ describe('Slack import sidebar', () => {expect(host.openHistory).toHaveBeenCalledWith(opener);});+ it('offers creating a channel beside the import', () => {+ render(() => <SlackImportSidebar />);+ expect(host.promotion?.actionLabel).toBe('Import Slack');+ expect(host.promotion?.secondaryAction?.label).toBe('New channel');+ host.promotion?.secondaryAction?.onClick(document.createElement('button'));+ expect(host.openNewChannel).toHaveBeenCalledOnce();+ });+it.each([{ enabled: false, admin: true },{ enabled: true, admin: false },diff --git a/apps/web/src/features/slack-import/slack-import-sidebar.tsx b/apps/web/src/features/slack-import/slack-import-sidebar.tsxindex 53444012a5..d7ea77d99b 100644--- a/apps/web/src/features/slack-import/slack-import-sidebar.tsx+++ b/apps/web/src/features/slack-import/slack-import-sidebar.tsx@@ -4,6 +4,7 @@ import {flagVerdict,} from '@app/features/sidebar-promotion/sidebar-promotion';import { useFeatureFlag } from '@app/lib/analytics/posthog';+import { openNewChannelModal } from '@channel/CreateChannelModal';import { enableSlackArchiveImport } from '@core/constant/featureFlags';import { lazyNamed } from '@core/util/lazyNamed';import FileZipIcon from '@phosphor/file-zip.svg';@@ -16,7 +17,8 @@ const SlackImport = lazyNamed(() => import('./slack-import'), 'SlackImport');/*** The Channels rail's Slack card: the shared connector-import card, whose* dialog picks channels through the Slack connector and hands history- * imports to the archive dialog.+ * imports to the archive dialog. Its second button creates a channel from+ * scratch instead.*/export function SlackImportSidebar() {const flag = useFeatureFlag(enableSlackArchiveImport);@@ -62,6 +64,11 @@ export function SlackImportSidebar() {},},]}+ actionLabel="Import Slack"+ secondaryAction={{+ label: 'New channel',+ onClick: () => openNewChannelModal(),+ }}/></>);diff --git a/docs/agent-guide/channels.md b/docs/agent-guide/channels.mdindex 485ebc5f58..8d32fdd4c9 100644--- a/docs/agent-guide/channels.md+++ b/docs/agent-guide/channels.md@@ -122,8 +122,10 @@ internal rollout. Model usage continues through the existing session metering.## Imported Slack history-Import starts from the **Import from Slack** card at the bottom of the Chat-sidebar, or **Settings → Team → Connections → Import from Slack**. The card is+Import starts from the **Create or import channels** card's **Import Slack**+button at the bottom of the Chat sidebar, or **Settings → Team → Connections →+Import from Slack**. The card's **New channel** button beside it opens the new+channel dialog instead. The card isthe shared connector-import card (see[Import from connected apps](setup-cards.md#import-from-connected-apps)) and isvisible to team admins and owners when Slack archive import is enabled. It