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
fix(channels): refactor task creation button (#2436)
teoe386cccbfe9a
diff --git a/js/app/packages/channel/Channel/Channel.tsx b/js/app/packages/channel/Channel/Channel.tsxindex 7fe9c496ba..d32debcc54 100644--- a/js/app/packages/channel/Channel/Channel.tsx+++ b/js/app/packages/channel/Channel/Channel.tsx@@ -40,8 +40,10 @@ import {} from '../Input';import { ChannelInputContainer } from '../Input/ChannelInputContainer';import { createChannelMessageActions } from './create-channel-message-actions';+import { useSplitLayout } from '@app/component/split-layout/layout';+import { useChannelName, useChannelActivity } from '@core/context/channels';+import { buildMentionMarkdownString } from '@lexical-core';import { createActivityTracker } from '@channel/activity-tracker';-import { useChannelActivity } from '@core/context/channels';import {invalidateChannelsActivity,useUpdateChannelsActivityMutation,@@ -194,6 +196,9 @@ export function Channel(props: ChannelProps) {attachmentTracker,});+ const channelName = useChannelName(props.channelId);+ const { popoverSplit } = useSplitLayout();+const getMessageActions = createChannelMessageActions({channelId: () => props.channelId,userId,@@ -208,6 +213,21 @@ export function Channel(props: ChannelProps) {onEdit: ({ message }) => {messageEditor.start(message);},+ onCreateTask: (ctx) => {+ popoverSplit({+ type: 'component',+ id: 'task-compose',+ params: {+ initialContent: buildMentionMarkdownString({+ type: 'document',+ documentId: props.channelId,+ documentName: channelName() ?? '',+ blockName: 'channel',+ blockParams: { channel_message_id: ctx.message.id },+ }),+ },+ });+ },});const selection = createMessageSelection({diff --git a/js/app/packages/channel/Channel/create-channel-message-actions.ts b/js/app/packages/channel/Channel/create-channel-message-actions.tsindex ba762a66f6..7728fb750e 100644--- a/js/app/packages/channel/Channel/create-channel-message-actions.ts+++ b/js/app/packages/channel/Channel/create-channel-message-actions.ts@@ -54,6 +54,7 @@ export type CreateChannelMessageActionsOptions = {removeReaction: (input: RemoveReactionInput) => void;onReply?: MessageActionHandler;onEdit?: MessageActionHandler;+ onCreateTask?: MessageActionHandler;effects?: Partial<ChannelMessageActionEffects>;};@@ -162,6 +163,7 @@ export function createChannelMessageActions(});}: undefined,+ onCreateTask: options.onCreateTask,};};}diff --git a/js/app/packages/channel/Message/ActionMenu.tsx b/js/app/packages/channel/Message/ActionMenu.tsxindex ac1d308635..85f2aa6c45 100644--- a/js/app/packages/channel/Message/ActionMenu.tsx+++ b/js/app/packages/channel/Message/ActionMenu.tsx@@ -1,10 +1,6 @@-import { useBlockId } from '@core/block';-import { useSplitLayout } from '@app/component/split-layout/layout';-import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';-import { buildMentionMarkdownString } from '@lexical-core';import ReplyIcon from '@icon/regular/arrow-bend-up-left.svg';import LinkIcon from '@icon/regular/link.svg';-import { AnimatedTaskIcon } from '@macro-icons/wide/animating/task';+import TaskIcon from '@macro-icons/wide/task.svg';import PencilIcon from '@icon/regular/pencil.svg';import PlusIcon from '@icon/regular/plus.svg';import TrashIcon from '@icon/regular/trash.svg';@@ -18,7 +14,7 @@ import type { MessageActionEvent, MessageActionHandler } from './types';const QUICK_REACTION_EMOJIS = ['❤️', '👍', '😂'] as const;-type ActionId = 'reply' | 'copy-link' | 'edit' | 'delete';+type ActionId = 'reply' | 'copy-link' | 'create-task' | 'edit' | 'delete';type ActionItem = {id: ActionId;@@ -26,6 +22,7 @@ type ActionItem = {icon: Component<JSX.SvgSVGAttributes<SVGSVGElement>> | string;onClick?: MessageActionHandler;destructive?: boolean;+ class?: string;};type ActionMenuProps = {@@ -46,7 +43,8 @@ function ActionButton(props: {'size-8 flex items-center justify-center text-ink-muted hover:bg-hover hover-transition-bg',{'text-failure-ink': props.action.destructive,- }+ },+ props.action.class)}onClick={props.onClick}>@@ -60,9 +58,6 @@ export function ActionMenu(props: ActionMenuProps) {const actions = useMessageActions();const selection = useMessageSelection();const [emojiMenuOpen, setEmojiMenuOpen] = createSignal(false);- const channelId = useBlockId();- const channelName = useBlockDocumentName();- const { popoverSplit } = useSplitLayout();const handleReaction = (emoji: string, event?: MessageActionEvent) => {void actions?.onReact?.({@@ -75,6 +70,13 @@ export function ActionMenu(props: ActionMenuProps) {const hasReactAction = () => actions?.onReact !== undefined;const actionItems: ActionItem[] = [+ {+ id: 'create-task',+ label: 'Task',+ icon: TaskIcon,+ onClick: actions?.onCreateTask,+ class: 'text-task',+ },{id: 'reply',label: 'Reply',@@ -148,31 +150,6 @@ export function ActionMenu(props: ActionMenuProps) {/></Show>- <button- type="button"- title="Task"- aria-label="Task"- data-message-action="create-task"- class="size-8 flex items-center justify-center text-task hover:bg-hover hover-transition-bg"- onClick={() => {- popoverSplit({- type: 'component',- id: 'task-compose',- params: {- initialContent: buildMentionMarkdownString({- type: 'document',- documentId: channelId,- documentName: channelName() ?? '',- blockName: 'channel',- blockParams: { channel_message_id: message().id },- }),- },- });- }}- >- <AnimatedTaskIcon class="size-4 opacity-60" />- </button>-<For each={visibleActions}>{(action) => (<ActionButtondiff --git a/js/app/packages/channel/Message/types.ts b/js/app/packages/channel/Message/types.tsindex 2a00b17e77..2462cfe050 100644--- a/js/app/packages/channel/Message/types.ts+++ b/js/app/packages/channel/Message/types.ts@@ -32,4 +32,5 @@ export type MessageActions = {onCopyLink?: MessageActionHandler;onEdit?: MessageActionHandler;onDelete?: MessageActionHandler;+ onCreateTask?: MessageActionHandler;};