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): goto task block from ItemPreview.tsx (#525)

Seamus733682509346
diff --git a/js/app/packages/core/component/ForwardToChannel.tsx b/js/app/packages/core/component/ForwardToChannel.tsx
index f39502873b..80546373d7 100644
--- a/js/app/packages/core/component/ForwardToChannel.tsx
+++ b/js/app/packages/core/component/ForwardToChannel.tsx
@@ -2,7 +2,7 @@ import { useChannelMarkdownArea } from '@block-channel/component/MarkdownArea';
import { withAnalytics } from '@coparse/analytics';
import { TrackingEvents } from '@coparse/analytics/src/types/TrackingEvents';
import { useIsAuthenticated } from '@core/auth';
-import { useBlockId, useBlockName } from '@core/block';
+import { useBlockAliasedName, useBlockId, useBlockName } from '@core/block';
import { RecipientSelector } from '@core/component/RecipientSelector';
import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';
import type { WithCustomUserInput } from '@core/user';
@@ -106,7 +106,7 @@ export function ForwardToChannel(props: ForwardToChannelProps) {
});
const asAttachment = {
- entity_type: blockNameToItemType(useBlockName()) ?? 'unknown',
+ entity_type: blockNameToItemType(useBlockAliasedName()) ?? 'unknown',
entity_id: useBlockId(),
};
diff --git a/js/app/packages/core/component/ItemPreview.tsx b/js/app/packages/core/component/ItemPreview.tsx
index bf01fcea1a..fa84c92f72 100644
--- a/js/app/packages/core/component/ItemPreview.tsx
+++ b/js/app/packages/core/component/ItemPreview.tsx
@@ -1,3 +1,4 @@
+import type { BlockAlias, BlockName } from '@core/block';
import { fileTypeToBlockName } from '@core/constant/allBlocks';
import { isAccessiblePreviewItem, useItemPreview } from '@core/signal/preview';
import { matches } from '@core/util/match';
@@ -13,6 +14,7 @@ import ThreeUsersIcon from '@icon/duotone/users-three-duotone.svg';
import LoadingSpinner from '@icon/regular/spinner.svg';
import type { ChannelType } from '@service-cognition/generated/schemas/channelType';
import type { ItemType } from '@service-storage/client';
+import type { BasicDocumentSubType } from '@service-storage/generated/schemas';
import type { FileType } from '@service-storage/generated/schemas/fileType';
import {
insertProjectIntoHistory,
@@ -43,10 +45,13 @@ function useItemPreviewData(props: ItemPreviewProps) {
const { replaceOrInsertSplit, insertSplit } = useSplitLayout();
function openItem(blockOrFileType: string, id: string, inNewSplit?: boolean) {
- const targetBlock = fileTypeToBlockName(blockOrFileType);
+ const targetBlock: BlockName | BlockAlias =
+ fileTypeToBlockName(blockOrFileType);
+
if (!targetBlock) {
return;
}
+
if (inNewSplit) {
const handle = insertSplit({
type: targetBlock,
@@ -66,13 +71,14 @@ function useItemPreviewData(props: ItemPreviewProps) {
type: ItemPreviewProps['itemType'],
id: string,
fileType?: FileType,
+ subType?: BasicDocumentSubType,
altKey?: boolean
) {
if (type === 'project') {
insertProjectIntoHistory(id);
await postNewHistoryItem('project', id);
}
- const _type = fileType ?? type;
+ const _type = subType ?? fileType ?? type;
if (!_type) return;
openItem(_type, id, altKey);
}
@@ -212,6 +218,7 @@ export function ItemPreview(props: ItemPreviewProps) {
itemData.type,
itemData.id,
fileType,
+ subType,
e.altKey
)
);
@@ -274,6 +281,7 @@ export function InlineItemPreview(props: ItemPreviewProps) {
{(accessibleItem) => {
const itemData = accessibleItem();
const fileType = itemData.fileType;
+ const subType = itemData.subType;
return (
<span class="inline-flex items-center gap-1">
<span class="w-4 h-4">
@@ -287,7 +295,7 @@ export function InlineItemPreview(props: ItemPreviewProps) {
<EntityIcon
targetType={
itemData.type === 'document'
- ? fileType
+ ? subType || fileType
: itemData.type
}
size="xs"