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(tasks): add autocopy link bask to task creation (#2252)

Seamus8d40a5822fc2
diff --git a/js/app/packages/block-md/component/ComposeTask.tsx b/js/app/packages/block-md/component/ComposeTask.tsx
index c2cc3a2f15..eaa17fa7e0 100644
--- a/js/app/packages/block-md/component/ComposeTask.tsx
+++ b/js/app/packages/block-md/component/ComposeTask.tsx
@@ -59,6 +59,7 @@ import {
} from '../util/taskComposerStorage';
import { buildConfig } from '@core/component/LexicalMarkdown/builder/MarkdownConfigBuilder';
import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';
+import CheckIcon from '@icon/regular/check.svg';
// Show these props in the composer.
const COMPOSER_PROPERTIES = [
@@ -324,7 +325,7 @@ export function ComposeTask(props: ComposeTaskProps) {
},
};
- const showTaskCreatedToast = (
+ const showTaskCreatedToast = async (
documentId: string,
taskTitle: string,
taskContent: string
@@ -333,6 +334,16 @@ export function ComposeTask(props: ComposeTaskProps) {
<EntityIcon targetType="task" class={p.class} />
);
+ // Auto-copy link to clipboard
+ const url = buildSimpleEntityUrl({ type: 'task', id: documentId }, {});
+ let linkCopied = false;
+ try {
+ await navigator.clipboard.writeText(url);
+ linkCopied = true;
+ } catch {
+ toast.failure('Failed to copy link to clipboard');
+ }
+
toast.custom(
{
title:
@@ -340,13 +351,19 @@ export function ComposeTask(props: ComposeTaskProps) {
itemToSafeName({ type: 'document', subType: { type: 'task' } }),
icon: TaskEntityIcon,
color: 'var(--color-task)',
- children: (
+ content: () => (
<div class="text-xs text-ink-extra-muted line-clamp-2 mb-4">
<StaticMarkdown
markdown={taskContent}
theme={unifiedListMarkdownTheme}
singleLine
/>
+ <Show when={linkCopied}>
+ <div class="bg-hover/50 flex items-center gap-1 rounded-xs p-1">
+ <CheckIcon class="size-3" />
+ <span>Link copied to clipboard</span>
+ </div>
+ </Show>
</div>
),
actions: [
@@ -374,10 +391,6 @@ export function ComposeTask(props: ComposeTaskProps) {
label: 'Copy Link',
icon: LinkIcon,
onClick: () => {
- const url = buildSimpleEntityUrl(
- { type: 'task', id: documentId },
- {}
- );
navigator.clipboard.writeText(url);
},
},
diff --git a/js/app/packages/core/component/Toast/Toast.tsx b/js/app/packages/core/component/Toast/Toast.tsx
index 46b7c6db2f..ffbc1385a4 100644
--- a/js/app/packages/core/component/Toast/Toast.tsx
+++ b/js/app/packages/core/component/Toast/Toast.tsx
@@ -122,7 +122,7 @@ export interface ToastAction {
*/
export interface CustomToastConfig {
title: string;
- children?: JSX.Element;
+ content?: () => JSX.Element;
icon?: Component<{ class?: string }>;
/** Any CSS color value, e.g. 'var(--color-success)' or '#ff6600' */
color?: string;
@@ -341,8 +341,8 @@ function ToastContent(props: {
</Button>
</Toast.CloseButton>
</div>
- <Show when={customConfig().children}>
- <div class="my-2 ml-7">{customConfig().children}</div>
+ <Show when={customConfig().content}>
+ <div class="my-2 ml-7">{customConfig().content?.()}</div>
</Show>
<Show when={customConfig().actions?.length}>
<ActionsRow actions={customConfig().actions!} />