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(top-bar): hide references and notifications pane when unauthed (#2040)

teoc351d516fbb5
diff --git a/js/app/packages/block-canvas/component/TopBar.tsx b/js/app/packages/block-canvas/component/TopBar.tsx
index 3894dfc666..4112e203fe 100644
--- a/js/app/packages/block-canvas/component/TopBar.tsx
+++ b/js/app/packages/block-canvas/component/TopBar.tsx
@@ -12,6 +12,7 @@ import {
import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
import { withAnalytics } from '@coparse/analytics';
+import { useIsAuthenticated } from '@core/auth';
import { createBlockSignal, useBlockId } from '@core/block';
import {
DocumentPropertiesButton,
@@ -51,6 +52,7 @@ const { track, TrackingEvents } = withAnalytics();
export const connectorTypeMenuTriggerSignal = createBlockSignal(false);
export function TopBar() {
+ const isAuth = useIsAuthenticated();
const toolManager = useToolManager();
const { getLocation } = useRenderState();
const getCurrentSavedFile = currentSavedFile.get;
@@ -117,7 +119,7 @@ export function TopBar() {
label: 'References',
icon: Quotes,
action: referencesControl.toggle,
- condition: () => ENABLE_REFERENCES_MODAL,
+ condition: () => !!isAuth() && ENABLE_REFERENCES_MODAL,
buttonComponent: () => (
<ReferencesButton
documentId={documentId}
diff --git a/js/app/packages/block-chat/component/TopBar.tsx b/js/app/packages/block-chat/component/TopBar.tsx
index c14fc0ae61..7d64c25fd7 100644
--- a/js/app/packages/block-chat/component/TopBar.tsx
+++ b/js/app/packages/block-chat/component/TopBar.tsx
@@ -9,6 +9,7 @@ import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHea
import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
import { DEFAULT_CHAT_NAME } from '@block-chat/definition';
+import { useIsAuthenticated } from '@core/auth';
import { useBlockId } from '@core/block';
import {
ReferencesButton,
@@ -18,6 +19,7 @@ import {
ShareTrigger,
useShareDialogContext,
} from '@core/component/TopBar/ShareButton';
+import { ENABLE_REFERENCES_MODAL } from '@core/constant/featureFlags';
import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';
import Notepad from '@icon/regular/notepad.svg';
import Quotes from '@icon/regular/quotes.svg';
@@ -25,6 +27,7 @@ import IconShared from '@icon/regular/share.svg';
import { useOpenInstructionsMd } from 'core/component/AI/util/instructions';
export function TopBar() {
+ const isAuth = useIsAuthenticated();
const blockId = useBlockId();
const name = useBlockDocumentName(DEFAULT_CHAT_NAME);
@@ -52,6 +55,7 @@ export function TopBar() {
label: 'References',
icon: Quotes,
action: referencesControl.toggle,
+ condition: () => !!isAuth() && ENABLE_REFERENCES_MODAL,
buttonComponent: () => (
<ReferencesButton
documentId={blockId}
diff --git a/js/app/packages/block-code/component/TopBar.tsx b/js/app/packages/block-code/component/TopBar.tsx
index 1de80ca9d6..55277d0c28 100644
--- a/js/app/packages/block-code/component/TopBar.tsx
+++ b/js/app/packages/block-code/component/TopBar.tsx
@@ -10,6 +10,7 @@ import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHea
import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
import { withAnalytics } from '@coparse/analytics';
+import { useIsAuthenticated } from '@core/auth';
import { useBlockId } from '@core/block';
import {
DocumentPropertiesButton,
@@ -23,6 +24,7 @@ import {
ShareTrigger,
useShareDialogContext,
} from '@core/component/TopBar/ShareButton';
+import { ENABLE_REFERENCES_MODAL } from '@core/constant/featureFlags';
import { isMobile } from '@core/mobile/isMobile';
import { blockTextSignal } from '@core/signal/load';
import {
@@ -47,6 +49,7 @@ export const TopBar: Component<{
mode: CodeBlockMode;
onModeChange: (mode: CodeBlockMode) => void;
}> = (props) => {
+ const isAuth = useIsAuthenticated();
const blockId = useBlockId();
const text = blockTextSignal.get;
const name = useBlockDocumentName();
@@ -82,6 +85,7 @@ export const TopBar: Component<{
label: 'References',
icon: Quotes,
action: referencesControl.toggle,
+ condition: () => !!isAuth() && ENABLE_REFERENCES_MODAL,
buttonComponent: () => (
<ReferencesButton
documentId={blockId}
diff --git a/js/app/packages/block-image/component/TopBar.tsx b/js/app/packages/block-image/component/TopBar.tsx
index 58dde002d4..ae664bf2fb 100644
--- a/js/app/packages/block-image/component/TopBar.tsx
+++ b/js/app/packages/block-image/component/TopBar.tsx
@@ -8,6 +8,7 @@ import type { FileOperation } from '@app/component/split-layout/components/Split
import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
+import { useIsAuthenticated } from '@core/auth';
import { useBlockId } from '@core/block';
import {
ReferencesButton,
@@ -17,6 +18,7 @@ import {
ShareTrigger,
useShareDialogContext,
} from '@core/component/TopBar/ShareButton';
+import { ENABLE_REFERENCES_MODAL } from '@core/constant/featureFlags';
import { blockFileSignal } from '@core/signal/load';
import {
useBlockDocumentDownloadName,
@@ -29,6 +31,7 @@ import IconShared from '@icon/regular/share.svg';
import { createCallback } from '@solid-primitives/rootless';
export function TopBar() {
+ const isAuth = useIsAuthenticated();
const blockId = useBlockId();
const imageFile = blockFileSignal.get;
const name = useBlockDocumentName();
@@ -61,6 +64,7 @@ export function TopBar() {
label: 'References',
icon: Quotes,
action: referencesControl.toggle,
+ condition: () => !!isAuth() && ENABLE_REFERENCES_MODAL,
buttonComponent: () => (
<ReferencesButton
documentId={blockId}
diff --git a/js/app/packages/block-md/component/TopBar.tsx b/js/app/packages/block-md/component/TopBar.tsx
index d9edcc763d..76d133ec2a 100644
--- a/js/app/packages/block-md/component/TopBar.tsx
+++ b/js/app/packages/block-md/component/TopBar.tsx
@@ -22,6 +22,7 @@ import {
showCommentsPreference,
} from '@block-md/comments/commentStore';
import { useDownloadDocumentAsMarkdownText } from '@block-md/signal/save';
+import { useIsAuthenticated } from '@core/auth';
import { useBlockAliasedName, useBlockId, useBlockName } from '@core/block';
import { BlockLiveIndicators } from '@core/component/LiveIndicators';
import { NotificationsButton } from '@core/component/NotificationsModal';
@@ -35,6 +36,7 @@ import {
import {
ENABLE_HISTORY_COMPONENT,
ENABLE_MARKDOWN_LIVE_COLLABORATION,
+ ENABLE_REFERENCES_MODAL,
} from '@core/constant/featureFlags';
import { isMobile } from '@core/mobile/isMobile';
import { useCanEdit } from '@core/signal/permissions';
@@ -62,6 +64,7 @@ import { HISTORY_DRAWER_ID } from './History';
import { DRAWER_ID as PROPERTIES_DRAWER_ID } from './MarkdownPropertiesModal';
export function TopBar() {
+ const isAuth = useIsAuthenticated();
const canEdit = useCanEdit();
const blockName = useBlockName();
const blockId = useBlockId();
@@ -154,6 +157,7 @@ export function TopBar() {
label: 'Notifications',
icon: Bell,
action: notificationsControl.toggle,
+ condition: () => !!isAuth(),
buttonComponent: () => (
<NotificationsButton
entity={{ id: blockId, type: itemType as EntityType }}
@@ -165,6 +169,7 @@ export function TopBar() {
label: 'References',
icon: Quotes,
action: referencesControl.toggle,
+ condition: () => !!isAuth() && ENABLE_REFERENCES_MODAL,
buttonComponent: () => (
<ReferencesButton
documentId={blockId}
diff --git a/js/app/packages/block-pdf/component/TopBar.tsx b/js/app/packages/block-pdf/component/TopBar.tsx
index dcd07ba1f3..89e275740a 100644
--- a/js/app/packages/block-pdf/component/TopBar.tsx
+++ b/js/app/packages/block-pdf/component/TopBar.tsx
@@ -191,7 +191,7 @@ export function TopBar() {
label: 'References',
icon: Quotes,
action: referencesControl.toggle,
- condition: () => ENABLE_REFERENCES_MODAL,
+ condition: () => !!isAuth() && ENABLE_REFERENCES_MODAL,
buttonComponent: () => (
<ReferencesButton
documentId={documentId}
diff --git a/js/app/packages/block-unknown/component/TopBar.tsx b/js/app/packages/block-unknown/component/TopBar.tsx
index ff4e734c83..c01babbdbb 100644
--- a/js/app/packages/block-unknown/component/TopBar.tsx
+++ b/js/app/packages/block-unknown/component/TopBar.tsx
@@ -8,6 +8,7 @@ import type { FileOperation } from '@app/component/split-layout/components/Split
import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
+import { useIsAuthenticated } from '@core/auth';
import { useBlockId } from '@core/block';
import {
ReferencesButton,
@@ -17,6 +18,7 @@ import {
ShareTrigger,
useShareDialogContext,
} from '@core/component/TopBar/ShareButton';
+import { ENABLE_REFERENCES_MODAL } from '@core/constant/featureFlags';
import {
useBlockDocumentDownloadName,
useBlockDocumentName,
@@ -30,6 +32,7 @@ import { toast } from 'core/component/Toast/Toast';
import { useGetFileBlob } from '../signal/blockData';
export function TopBar() {
+ const isAuth = useIsAuthenticated();
const blockId = useBlockId();
const fileName = useBlockDocumentName();
const downloadName = useBlockDocumentDownloadName();
@@ -66,6 +69,7 @@ export function TopBar() {
label: 'References',
icon: Quotes,
action: referencesControl.toggle,
+ condition: () => !!isAuth() && ENABLE_REFERENCES_MODAL,
buttonComponent: () => (
<ReferencesButton
documentId={blockId}
diff --git a/js/app/packages/block-video/component/TopBar.tsx b/js/app/packages/block-video/component/TopBar.tsx
index af1cfe49ea..62f3eec143 100644
--- a/js/app/packages/block-video/component/TopBar.tsx
+++ b/js/app/packages/block-video/component/TopBar.tsx
@@ -8,6 +8,7 @@ import type { FileOperation } from '@app/component/split-layout/components/Split
import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
import { BlockItemSplitLabel } from '@app/component/split-layout/components/SplitLabel';
+import { useIsAuthenticated } from '@core/auth';
import { useBlockId } from '@core/block';
import {
ReferencesButton,
@@ -17,6 +18,7 @@ import {
ShareTrigger,
useShareDialogContext,
} from '@core/component/TopBar/ShareButton';
+import { ENABLE_REFERENCES_MODAL } from '@core/constant/featureFlags';
import {
useBlockDocumentDownloadName,
useBlockDocumentName,
@@ -30,6 +32,7 @@ import { toast } from 'core/component/Toast/Toast';
import { useGetFileBlob } from '../signal/blockData';
export function TopBar() {
+ const isAuth = useIsAuthenticated();
const blockId = useBlockId();
const name = useBlockDocumentName();
const downloadName = useBlockDocumentDownloadName();
@@ -66,6 +69,7 @@ export function TopBar() {
label: 'References',
icon: Quotes,
action: referencesControl.toggle,
+ condition: () => !!isAuth() && ENABLE_REFERENCES_MODAL,
buttonComponent: () => (
<ReferencesButton
documentId={blockId}