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.

chg(soup): mark done button, hot key tokens, trim text content (#330)

Seamuse825680c5989
diff --git a/js/app/packages/app/component/SoupContext.tsx b/js/app/packages/app/component/SoupContext.tsx
index c9de8cc42d..3018977ed0 100644
--- a/js/app/packages/app/component/SoupContext.tsx
+++ b/js/app/packages/app/component/SoupContext.tsx
@@ -326,7 +326,7 @@ export function createNavigationEntityListShortcut({
},
{
testEnabled: (entity) => {
- if (entity.type === 'email') return true;
+ if (entity.type === 'email' || entity.type === 'channel') return true;
if (entityHasUnreadNotifications(notificationSource, entity))
return true;
return false;
@@ -336,6 +336,7 @@ export function createNavigationEntityListShortcut({
registerHotkey({
hotkey: ['e'],
+ hotkeyToken: TOKENS.entity.action.markDone,
scopeId: entityHotkeyScope,
description: 'Mark done',
condition: () =>
@@ -404,6 +405,7 @@ export function createNavigationEntityListShortcut({
registerHotkey({
hotkey: ['delete', 'backspace'],
+ hotkeyToken: TOKENS.entity.action.delete,
scopeId: splitHotkeyScope,
description: () =>
viewData().selectedEntities.length > 1 ? 'Delete items' : 'Delete item',
@@ -468,6 +470,7 @@ export function createNavigationEntityListShortcut({
registerHotkey({
scopeId: splitHotkeyScope,
+ hotkeyToken: TOKENS.entity.action.rename,
description: () =>
viewData().selectedEntities.length > 1 ? 'Rename items' : 'Rename item',
condition: () =>
@@ -513,6 +516,7 @@ export function createNavigationEntityListShortcut({
registerHotkey({
scopeId: splitHotkeyScope,
+ hotkeyToken: TOKENS.entity.action.copy,
description: () =>
viewData().selectedEntities.length > 1 ? 'Copy items' : 'Copy item',
condition: () =>
@@ -567,6 +571,7 @@ export function createNavigationEntityListShortcut({
registerHotkey({
scopeId: splitHotkeyScope,
+ hotkeyToken: TOKENS.entity.action.moveToFolder,
description: () =>
viewData().selectedEntities.length > 1
? 'Move items to project'
diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsx
index 8b5563aac8..69d3678271 100644
--- a/js/app/packages/app/component/UnifiedListView.tsx
+++ b/js/app/packages/app/component/UnifiedListView.tsx
@@ -69,7 +69,6 @@ import {
isChannelMention,
isChannelMessageReply,
isChannelMessageSend,
- markNotificationsForEntityAsDone,
notificationWithMetadata,
type UnifiedNotification,
useNotificationsForEntity,
@@ -133,7 +132,6 @@ import { useSplitLayout } from './split-layout/layout';
import { useSplitPanelOrThrow } from './split-layout/layoutUtils';
import { EmptyState } from './UnifiedListEmptyState';
import {
- archiveEmail,
type DisplayOptions,
type DocumentTypeFilter,
type FilterOptions,
@@ -799,20 +797,12 @@ export function UnifiedListView(props: UnifiedListViewProps) {
const notificationSource = useGlobalNotificationSource();
const markEntityAsDone = (entity: EntityData) => {
- if (emailView() === 'inbox') {
- if (entity.type === 'email') {
- archiveEmail(entity.id, {
- isDone: entity.done,
- optimisticallyExclude: true,
- });
- }
+ const actions = unifiedListContext.actionRegistry;
+ if (actions.isActionEnabled('mark_as_done', entity)) {
+ actions.execute('mark_as_done', entity);
return true;
}
- if (entity.type === 'email') {
- archiveEmail(entity.id, { isDone: entity.done });
- }
- markNotificationsForEntityAsDone(notificationSource, entity);
- return true;
+ return false;
};
const { replaceOrInsertSplit, insertSplit } = useSplitLayout();
@@ -1359,11 +1349,18 @@ export function UnifiedListView(props: UnifiedListViewProps) {
entity={innerProps.entity}
timestamp={timestamp()}
onClick={entityClickHandler}
- onClickRowAction={(entity, type) => {
- if (type === 'done') {
- markEntityAsDone?.(entity);
- }
- }}
+ onClickRowAction={
+ unifiedListContext.actionRegistry.isActionEnabled(
+ 'mark_as_done',
+ innerProps.entity
+ )
+ ? (entity, type) => {
+ if (type === 'done') {
+ markEntityAsDone?.(entity);
+ }
+ }
+ : undefined
+ }
onClickNotification={(notifiedEntity) => {
const notification = notificationWithMetadata(
notifiedEntity.notification
diff --git a/js/app/packages/core/hotkey/tokens.ts b/js/app/packages/core/hotkey/tokens.ts
index 46d01dc568..a0c6e0b40f 100644
--- a/js/app/packages/core/hotkey/tokens.ts
+++ b/js/app/packages/core/hotkey/tokens.ts
@@ -19,6 +19,13 @@ export const TOKENS = {
home: 'entity.jump.home',
end: 'entity.jump.end',
},
+ action: {
+ markDone: 'entity.action.markDone',
+ delete: 'entity.action.delete',
+ rename: 'entity.action.rename',
+ moveToFolder: 'entity.action.moveToFolder',
+ copy: 'entity.action.copy',
+ },
},
// code block
diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
index 4d7082b849..791dd3bde7 100644
--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
@@ -1,4 +1,5 @@
-import { Tooltip } from '@core/component/Tooltip';
+import { LabelAndHotKey, Tooltip } from '@core/component/Tooltip';
+import { TOKENS } from '@core/hotkey/tokens';
import { matches } from '@core/util/match';
import CheckIcon from '@icon/regular/check.svg';
import { notificationWithMetadata } from '@notifications';
@@ -354,7 +355,7 @@ export function EntityWithEverything(
{(lastMessageContent) => (
<div class="truncate shrink grow opacity-60 flex items-center">
<StaticMarkdown
- markdown={lastMessageContent()}
+ markdown={lastMessageContent().trim()}
theme={unifiedListMarkdownTheme}
singleLine={true}
/>
@@ -542,17 +543,29 @@ export function EntityWithEverything(
);
}}
</Show>
- <Show when={props.selected}>
- <button
- class="absolute top-1 right-1 flex items-center justify-center size-8 bg-panel border border-edge-muted hover:bg-accent hover:text-panel"
- onClick={() => {
- props.onClickRowAction?.(props.entity, 'done');
- }}
- ref={setActionButtonRef}
- data-blocks-navigation
- >
- <CheckIcon class="w-4 h-4 pointer-events-none" />
- </button>
+ <Show when={props.highlighted && props.onClickRowAction}>
+ <div class="absolute top-1 right-1 items-center flex">
+ <Tooltip
+ tooltip={
+ <LabelAndHotKey
+ label="Mark as done"
+ hotkeyToken={TOKENS.entity.action.markDone}
+ />
+ }
+ >
+ <button
+ class="bg-panel flex items-center justify-center size-8 border border-edge-muted hover:bg-accent hover:text-panel"
+ onClick={(e) => {
+ e.stopPropagation();
+ props.onClickRowAction?.(props.entity, 'done');
+ }}
+ ref={setActionButtonRef}
+ data-blocks-navigation
+ >
+ <CheckIcon class="w-4 h-4 pointer-events-none" />
+ </button>
+ </Tooltip>
+ </div>
</Show>
</div>
</div>
@@ -633,7 +646,7 @@ export function EntityWithEverything(
return (
<StaticMarkdown
- markdown={metadata.messageContent}
+ markdown={metadata.messageContent.trim()}
theme={unifiedListMarkdownTheme}
singleLine={true}
/>