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
feat(share): new ShareButton, DialogWarper, ClippedPanel Signals, and disable transitions (#704)
Fake-User4fb8ef8790cb
diff --git a/js/app/bun.lock b/js/app/bun.lockindex 6777a63053..d185e676b6 100644--- a/js/app/bun.lock+++ b/js/app/bun.lock@@ -1,6 +1,5 @@{"lockfileVersion": 1,- "configVersion": 0,"workspaces": {"": {"name": "@coparse/monorepo",diff --git a/js/app/packages/app/component/command/Konsole.tsx b/js/app/packages/app/component/command/Konsole.tsxindex 1cfebc9f73..eeff9db225 100644--- a/js/app/packages/app/component/command/Konsole.tsx+++ b/js/app/packages/app/component/command/Konsole.tsx@@ -1,10 +1,11 @@import { useChannelsContext } from '@core/component/ChannelsProvider';import { ClippedPanel } from '@core/component/ClippedPanel';+import { DialogWrapper } from '@core/component/DialogWrapper';import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';import { ENABLE_SEARCH_PAGINATION } from '@core/constant/featureFlags';import type { CommandWithInfo } from '@core/hotkey/getCommands';import { createFreshSearch } from '@core/util/freshSort';-import { Popover } from '@kobalte/core';+import { Dialog } from '@kobalte/core/dialog';import { Command as CommandK, useCommandState } from 'cmdk-solid';import {registerHotkey,@@ -17,12 +18,12 @@ import {createMemo,createSignal,For,- type JSXElement,onMount,Show,untrack,} from 'solid-js';import { VList } from 'virtua/solid';+import { beveledCorners } from '../../../block-theme/signals/themeSignals';import { KonsoleFilter } from './KonsoleFilter';import {COMMAND_ITEM_HEIGHT,@@ -76,36 +77,25 @@ export function KommandMenu() {}});- const CommandWindow = (props: { children?: JSXElement }) => {- return (- <div- class="z-50 fixed inset-0 flex flex-row justify-center items-center bg-modal-overlay pattern-edge-muted pattern-diagonal-4"- ref={setCommandKRef}- >- {props.children}- </div>- );- };-return (<StaticMarkdownContext>- <Popover.Root+ <Dialogopen={konsoleOpen()}onOpenChange={(_) => toggleKonsoleVisibility()}>- <Popover.Anchor />- <Popover.Portal>- <CommandWindow>- <Popover.Content>- <div class="mt-[25vh] w-6xl max-w-[90vw] max-h-[75vh] overflow-hidden">- <ClippedPanel tl active>+ <Dialog.Portal>+ <Dialog.Overlay class="fixed inset-0 z-modal bg-transparent" />+ <DialogWrapper>+ <div ref={setCommandKRef}>+ <Dialog.Content>+ <ClippedPanel tl={!beveledCorners()} active><KommandMenuInner commandKRef={commandKRef} /></ClippedPanel>- </div>- </Popover.Content>- </CommandWindow>- </Popover.Portal>- </Popover.Root>+ </Dialog.Content>+ </div>+ </DialogWrapper>+ </Dialog.Portal>+ </Dialog></StaticMarkdownContext>);}@@ -324,7 +314,7 @@ export function KommandMenuInner(props: {<div class="flex items-center gap-2 bg-panel px-2 h-[40px] border-b border-edge-muted"><span class="pl-2 pointer-events-none">❯</span><CommandK.Input- class="flex-1 border-0 outline-none! focus:outline-none ring-0! focus:ring-0 font-mono"+ class="flex-1 border-0 outline-none! focus:outline-none ring-0! focus:ring-0"onValueChange={setRawQuery}placeholder="Search"value={rawQuery()}diff --git a/js/app/packages/app/component/dock/Dock.tsx b/js/app/packages/app/component/dock/Dock.tsxindex 6c09e7c341..35cf2e17c1 100644--- a/js/app/packages/app/component/dock/Dock.tsx+++ b/js/app/packages/app/component/dock/Dock.tsx@@ -1,7 +1,7 @@+import { ENABLE_DOCK_NOTITIFCATIONS, ENABLE_JACK_IN } from '@core/constant/featureFlags';import { GlobalNotificationBell } from '@core/component/GlobalNotificationBell';import { createMemo, createSignal, onCleanup, onMount, Show } from 'solid-js';import { isRightPanelOpen, useToggleRightPanel } from '@core/signal/layout';-import { ENABLE_DOCK_NOTITIFCATIONS, ENABLE_JACK_IN } from '@core/constant/featureFlags';import { activeScope, hotkeyScopeTree } from '@core/hotkey/state';import { useSettingsState } from '@core/constant/SettingsState';import { useGlobalNotificationSource } from '../GlobalAppState';@@ -24,13 +24,13 @@ import { runCommand } from '@core/hotkey/hotkeys';import { Hotkey } from '@core/component/Hotkey';import { setCreateMenuOpen } from '../Launcher';import { useHasPaidAccess } from '@core/auth';+import { isTauri } from '@core/util/platform';import { TOKENS } from '@core/hotkey/tokens';import { playSound } from '@app/util/sound';import { QuickAccess } from './QuickAccess';// import { Debug } from './Debug';-import Hints from './Hints';-import { isTauri } from '@core/util/platform';+// import Hints from './Hints';export function Dock() {const activeSplitId = createMemo(() => globalSplitManager()?.activeSplitId());@@ -270,9 +270,11 @@ export function Dock() {<BasicTierLimit /></Show>- <Show when={hasPaid()}>+ {/*<Show when={hasPaid()}><Hints />- </Show>+ </Show>*/}++ <div class="w-full"/><Show when={ENABLE_DOCK_NOTITIFCATIONS}><QuickAccess />diff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.cssindex fe1b2fe647..e858cb3fc0 100644--- a/js/app/packages/app/index.css+++ b/js/app/packages/app/index.css@@ -102,7 +102,8 @@--theme-task: oklch(from var(--a0) l c 150deg);--gutter-size: 8px;- --transition: 0.2s;+ --transition: 0.s;+ /*--transition: 0.15s;*//* Semantic Color names, use these when writing tailwind */diff --git a/js/app/packages/block-channel/component/ParticipantManager.tsx b/js/app/packages/block-channel/component/ParticipantManager.tsxindex 33f9c2d276..df9ca2a4d6 100644--- a/js/app/packages/block-channel/component/ParticipantManager.tsx+++ b/js/app/packages/block-channel/component/ParticipantManager.tsx@@ -7,6 +7,7 @@ import {useRemoveParticipantsFromChannel,} from '@block-channel/signal/participants';import { ClippedPanel } from '@core/component/ClippedPanel';+import { DialogWrapper } from '@core/component/DialogWrapper';import { IconButton } from '@core/component/IconButton';import { getDestinationFromOptions } from '@core/component/NewMessage';import { RecipientSelector } from '@core/component/RecipientSelector';@@ -28,6 +29,7 @@ import { ChannelType } from '@service-comms/generated/models/channelType';import { useUserId } from '@service-gql/client';import { createMemo, createSignal, Show } from 'solid-js';import { VList } from 'virtua/solid';+import { beveledCorners } from '../../block-theme/signals/themeSignals';import { UserItem } from './UserItem';export function ParticipantManager(props: { participantCount: number }) {@@ -84,10 +86,10 @@ export function ParticipantManager(props: { participantCount: number }) {</Dialog.Trigger><Dialog.Portal>- <Dialog.Overlay class="fixed flex inset-0 z-modal bg-modal-overlay pattern-edge-muted pattern-diagonal-4 items-center justify-content" />- <div class="fixed inset-0 z-modal w-screen h-screen flex items-center justify-center bg-transparent">- <Dialog.Content class="w-[512px]">- <ClippedPanel tl>+ <Dialog.Overlay class="fixed inset-0 z-modal bg-transparent" />+ <DialogWrapper>+ <Dialog.Content>+ <ClippedPanel tl={!beveledCorners()} active><div class="flex flex-row items-center px-2 h-[40px] gap-2 border-b-1 border-b-edge-muted"><Dialog.CloseButton><IconButton@@ -135,7 +137,7 @@ export function ParticipantManager(props: { participantCount: number }) {</div></ClippedPanel></Dialog.Content>- </div>+ </DialogWrapper></Dialog.Portal></Dialog>);diff --git a/js/app/packages/block-email/component/Compose.tsx b/js/app/packages/block-email/component/Compose.tsxindex cd0b3bc4a2..e9d9c21cb7 100644--- a/js/app/packages/block-email/component/Compose.tsx+++ b/js/app/packages/block-email/component/Compose.tsx@@ -29,6 +29,7 @@ import {Suspense,Switch,} from 'solid-js';+import { beveledCorners } from '../../block-theme/signals/themeSignals';import { ComposeEmailInput, type ComposeInputData } from './ComposeEmailInput';type EmailComposeErrors =@@ -248,7 +249,7 @@ export function EmailCompose() {'pointer-events-none opacity-50': hasLinkError(),}}>- <ClippedPanel tl tr>+ <ClippedPanel tl={!beveledCorners()}><divclass="w-full p-4 bg-input max-h-full overflow-hidden flex flex-col min-h-0"classList={{diff --git a/js/app/packages/block-theme/signals/themeReactive.ts b/js/app/packages/block-theme/signals/themeReactive.tsindex 64d99ab3f8..8026c9f6c1 100644--- a/js/app/packages/block-theme/signals/themeReactive.ts+++ b/js/app/packages/block-theme/signals/themeReactive.ts@@ -45,7 +45,8 @@ function jamTransition(): void {document.documentElement.style.setProperty('--transition', '0s');setTimeout(() => {- document.documentElement.style.setProperty('--transition', '0.5s');+ document.documentElement.style.setProperty('--transition', '0.0s');+ // document.documentElement.style.setProperty('--transition', '0.15s');transitionState = false;}, 100);}diff --git a/js/app/packages/core/component/DialogWrapper.tsx b/js/app/packages/core/component/DialogWrapper.tsxnew file mode 100644index 0000000000..172972b23a--- /dev/null+++ b/js/app/packages/core/component/DialogWrapper.tsx@@ -0,0 +1,28 @@+import type { JSXElement } from 'solid-js';++export interface DialogWrapperProps {+ children: JSXElement;+ class?: string;+ width?: string;+}++export function DialogWrapper(props: DialogWrapperProps) {+ const width = props.width ?? '800px';++ return (+ <div class="z-modal fixed inset-0 bg-modal-overlay pattern-edge-muted pattern-diagonal-4">+ <div+ style={{+ 'max-width': 'calc(100vw - (var(--gutter-size) * 2))',+ margin: '160px auto 0 auto',+ 'max-height': '75vh',+ overflow: 'hidden',+ width: width,+ }}+ class={props.class}+ >+ {props.children}+ </div>+ </div>+ );+}diff --git a/js/app/packages/core/component/FormControls/SegmentControls.tsx b/js/app/packages/core/component/FormControls/SegmentControls.tsxindex 8bbe32569c..4e22542a72 100644--- a/js/app/packages/core/component/FormControls/SegmentControls.tsx+++ b/js/app/packages/core/component/FormControls/SegmentControls.tsx@@ -51,7 +51,7 @@ export const SegmentedControl: ParentComponent<return (<KSegmentedControl- class="flex gap-3 text-sm"+ class="flex gap-2 text-sm"classList={{[`justify-between`]: !!props.label,'flex-row-reverse': props.labelPlacement === 'right',diff --git a/js/app/packages/core/component/FormControls/ToggleButton.tsx b/js/app/packages/core/component/FormControls/ToggleButton.tsxindex 6e16744b0a..b8f5f9cf07 100644--- a/js/app/packages/core/component/FormControls/ToggleButton.tsx+++ b/js/app/packages/core/component/FormControls/ToggleButton.tsx@@ -6,7 +6,7 @@ import {createEffect,createSignal,type JSX,- onMount,+ // onMount,type ParentComponent,type ValidComponent,} from 'solid-js';@@ -29,23 +29,23 @@ export const ToggleButton: ParentComponent<} & ToggleButtonRootOptions> = (props) => {const [pressed, setPressed] = createSignal(props.pressed);- const [showFlicker, setShowFlicker] = createSignal(false);- let init = true;+ // const [showFlicker, setShowFlicker] = createSignal(false);+ // let init = true;- createEffect((prevPressed) => {- const pressedVal = pressed();+ // createEffect((prevPressed) => {+ // const pressedVal = pressed();- if (init) {- return pressedVal;- }- if (pressedVal === prevPressed) return pressedVal;- if (props.animateFlickerOnDeactivate === false && pressedVal === false) {- return pressedVal;- }+ // if (init) {+ // return pressedVal;+ // }+ // if (pressedVal === prevPressed) return pressedVal;+ // if (props.animateFlickerOnDeactivate === false && pressedVal === false) {+ // return pressedVal;+ // }- setShowFlicker(true);- return pressedVal;- });+ // setShowFlicker(true);+ // return pressedVal;+ // });createEffect(() => {if (props.pressed !== undefined) {@@ -53,11 +53,11 @@ export const ToggleButton: ParentComponent<}});- onMount(() => {- setTimeout(() => {- init = false;- });- });+ // onMount(() => {+ // setTimeout(() => {+ // init = false;+ // });+ // });const onChange = (isPressed: boolean) => {if (props.pressed === undefined) {@@ -79,17 +79,17 @@ export const ToggleButton: ParentComponent<>{(state) => (<div- class="border border-edge-muted min-w-[22px] font-medium font-mono text-center uppercase leading-none"+ class="border border-edge-muted min-w-[22px] font-medium font-mono text-center uppercase leading-none whitespace-nowrap"classList={{[`${sizeClass[props.size || 'Base']}`]: true,'bg-edge-muted text-ink': state.pressed(),'text-ink-muted': !state.pressed(),- 'animate-[flicker_50ms_3]': showFlicker(),+ // 'animate-[flicker_50ms_3]': showFlicker(),'hover:opacity-80': !props.disabled,}}- onAnimationEnd={() => {- setShowFlicker(false);- }}+ // onAnimationEnd={() => {+ // setShowFlicker(false);+ // }}>{props.children}</div>diff --git a/js/app/packages/core/component/FormControls/ToggleSwitch.tsx b/js/app/packages/core/component/FormControls/ToggleSwitch.tsxindex 6c7492c0d0..59ce6470ea 100644--- a/js/app/packages/core/component/FormControls/ToggleSwitch.tsx+++ b/js/app/packages/core/component/FormControls/ToggleSwitch.tsx@@ -66,7 +66,7 @@ export const ToggleSwitch: Component<return (<KSwitch- class="flex justify-between items-center font-medium gap-1"+ class="flex justify-between items-center font-medium gap-2"classList={{[`${sizeClass[props.size || 'Base']}`]: true,[`${props.switchRootClass}`]: !!props.switchRootClass,@@ -83,6 +83,7 @@ export const ToggleSwitch: Component<classList={{[`${sizeClass[props.size || 'Base']}`]: true,'cursor-not-allowed': props.disabled,+ 'whitespace-nowrap': true,}}// style={{ 'font-size-adjust': 'ex-height 0.5' }}>@@ -93,7 +94,6 @@ export const ToggleSwitch: Component<<div class="relative focus-bracket-within [&:focus-within]:[--focus-border-inset:-3px] w-fit h-fit"><KSwitch.Input class="absolute inset-0 !h-full !w-full pointer-events-none" /><KSwitch.Control- class="relative"classList={{'animate-[flicker_50ms_3_150ms]':props.animateFlicker && showFlicker(),@@ -101,6 +101,7 @@ export const ToggleSwitch: Component<onAnimationEnd={() => {setShowFlicker(false);}}+ class="relative"><divclass="relative grid grid-cols-[auto_1fr] auto-cols-auto overflow-clip"@@ -115,12 +116,7 @@ export const ToggleSwitch: Component<</div>{/* Visible Interactive, size relative to Fake Invisible Node */}- <div- class="absolute inset-0"- style={{- 'container-type': 'size',- }}- >+ <div style={{ 'container-type': 'size' }} class="absolute inset-0"><div class="absolute inset-0"><divclass="h-full w-full transition duration-100"diff --git a/js/app/packages/core/component/ForwardToChannel.tsx b/js/app/packages/core/component/ForwardToChannel.tsxindex 5097da8c7e..ae69ef0a9c 100644--- a/js/app/packages/core/component/ForwardToChannel.tsx+++ b/js/app/packages/core/component/ForwardToChannel.tsx@@ -3,41 +3,52 @@ import { withAnalytics } from '@coparse/analytics';import { TrackingEvents } from '@coparse/analytics/src/types/TrackingEvents';import { useIsAuthenticated } from '@core/auth';import { useBlockAliasedName, useBlockId, useBlockName } from '@core/block';+import { ToggleSwitch } from '@core/component/FormControls/ToggleSwitch';import { RecipientSelector } from '@core/component/RecipientSelector';import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';import type { WithCustomUserInput } from '@core/user';import { useSendMessageToPeople } from '@core/util/channels';-import { Switch as KobalteSwitch } from '@kobalte/core/switch';-import PaperPlaneRight from '@phosphor-icons/core/fill/paper-plane-right-fill.svg?component-solid';import { blockNameToItemType } from '@service-storage/client';import type { AccessLevel } from '@service-storage/generated/schemas/accessLevel';import type { SharePermissionV2ChannelSharePermissions } from '@service-storage/generated/schemas/sharePermissionV2ChannelSharePermissions';-import { createEffect, createMemo, createSignal, Show } from 'solid-js';+import {+ createEffect,+ createMemo,+ createSignal,+ onMount,+ Show,+} from 'solid-js';import { getDestinationFromOptions } from './NewMessage';-import { Permissions } from './SharePermissions';+import type { Permissions } from './SharePermissions';import { toast } from './Toast/Toast';-import { ShareOptions } from './TopBar/ShareButton';interface ForwardToChannelProps {- name: string;- projectId?: string;- onSubmit?: () => void;- refetch?: () => void;submitPermissionInfo?: {- userPermissions: Permissions;- channelSharePermissions?: SharePermissionV2ChannelSharePermissions;setChannelPermissions: (channelId: string,accessLevel: AccessLevel) => void;+ channelSharePermissions?: SharePermissionV2ChannelSharePermissions;+ userPermissions: Permissions;};+ onSubmit?: () => void;+ refetch?: () => void;+ projectId?: string;+ name: string;+ ref?: (ref: {+ getSelectedOptions: () => WithCustomUserInput<+ 'user' | 'contact' | 'channel'+ >[];+ setSubmitAccessLevel: (level: AccessLevel | null) => void;+ getSubmitAccessLevel: () => AccessLevel | null;+ handleSubmit: () => void;+ }) => void;}export function ForwardToChannel(props: ForwardToChannelProps) {const isAuthenticated = useIsAuthenticated();const { track } = withAnalytics();- const [triedToSubmit, setTriedToSubmit] = createSignal(false);const [selectedOptions, setSelectedOptions] = createSignal<WithCustomUserInput<'user' | 'contact' | 'channel'>[]>([]);@@ -46,19 +57,25 @@ export function ForwardToChannel(props: ForwardToChannelProps) {state: markdownState,MarkdownArea,} = useChannelMarkdownArea();-+ const [triedToSubmit, setTriedToSubmit] = createSignal(false);const { all: destinationOptions } = useCombinedRecipients();const destination = createMemo(() => {let options = selectedOptions();- if (!options || options.length === 0) return;+ if (!options || options.length === 0) {+ return;+ }return getDestinationFromOptions(options);});const channelPermissions = createMemo(() => {- if (!props.submitPermissionInfo) return;+ if (!props.submitPermissionInfo) {+ return;+ }const destination_ = destination();- if (!destination_ || destination_.type !== 'channel') return;+ if (!destination_ || destination_.type !== 'channel') {+ return;+ }const perms = props.submitPermissionInfo.channelSharePermissions?.find((p) => p.channel_id === destination_.id);@@ -66,7 +83,6 @@ export function ForwardToChannel(props: ForwardToChannelProps) {});const { sendToUsers, sendToChannel } = useSendMessageToPeople();-const [submitAccessLevel, setSubmitAccessLevel] =createSignal<AccessLevel | null>(null);@@ -80,7 +96,9 @@ export function ForwardToChannel(props: ForwardToChannelProps) {});const submitChannelPermissions = (channelId: string) => {- if (!props.submitPermissionInfo) return;+ if (!props.submitPermissionInfo) {+ return;+ }const accessLevel = submitAccessLevel();if (!accessLevel) {@@ -95,10 +113,11 @@ export function ForwardToChannel(props: ForwardToChannelProps) {createSignal<boolean>(true);const canSendAsGroup = createMemo(() => {- const currentSelectedOptions = selectedOptions();- if (!currentSelectedOptions || currentSelectedOptions.length <= 1)+ const _selectedOptions = selectedOptions();+ if (!_selectedOptions || _selectedOptions.length <= 1) {return false;- for (const selectedOption of currentSelectedOptions) {+ }+ for (const selectedOption of _selectedOptions) {if (selectedOption.kind === 'channel') {return false;}@@ -113,25 +132,29 @@ export function ForwardToChannel(props: ForwardToChannelProps) {function handleSubmit() {let options = selectedOptions();- if (!options || options.length === 0) return setTriedToSubmit(true);+ if (!options || options.length === 0) {+ return setTriedToSubmit(true);+ }if (canSendAsGroup() && sendAsGroupMessage()) {const destination_ = destination();if (destination_ && destination_.type === 'users') {sendToUsers({+ attachments: [asAttachment],users: destination_.users,content: markdownState(),- attachments: [asAttachment],mentions: [],}).then((res) => {- if (!res) return;+ if (!res) {+ return;+ }const { channelId, navigateToChannel } = res;submitChannelPermissions(channelId);props.refetch?.();toast.success('Message sent successfully', undefined, {- text: 'View in channel',onClick: navigateToChannel,+ text: 'View in channel',});track(TrackingEvents.SHARE.FORWARD);});@@ -146,9 +169,9 @@ export function ForwardToChannel(props: ForwardToChannelProps) {Promise.all([submitChannelPermissions(option.id),sendToChannel({- channelId: option.id,- content: markdownState(),attachments: [asAttachment],+ content: markdownState(),+ channelId: option.id,mentions: [],}).then((res) => {if (!res) {@@ -159,8 +182,8 @@ export function ForwardToChannel(props: ForwardToChannelProps) {if (!multipleMessages) {const { navigateToChannel } = res;toast.success('Message sent successfully', undefined, {- text: 'View in channel',onClick: () => navigateToChannel(),+ text: 'View in channel',});}track(TrackingEvents.SHARE.FORWARD);@@ -169,9 +192,9 @@ export function ForwardToChannel(props: ForwardToChannelProps) {} else {// handles option.kind of user, custom, and contact (gmail)sendToUsers({- users: [option.id],- content: markdownState(),attachments: [asAttachment],+ content: markdownState(),+ users: [option.id],mentions: [],}).then((res) => {if (!res) {@@ -184,8 +207,8 @@ export function ForwardToChannel(props: ForwardToChannelProps) {props.refetch?.();if (!multipleMessages) {toast.success('Message sent successfully', undefined, {- text: 'View in channel',onClick: () => navigateToChannel(),+ text: 'View in channel',});}track(TrackingEvents.SHARE.FORWARD);@@ -202,110 +225,76 @@ export function ForwardToChannel(props: ForwardToChannelProps) {}const destination_ = destination();- if (!destination_) return;+ if (!destination_) {+ return;+ }props.onSubmit?.();}+ onMount(() => {+ if (props.ref) {+ props.ref({+ getSubmitAccessLevel: submitAccessLevel,+ getSelectedOptions: selectedOptions,+ setSubmitAccessLevel,+ handleSubmit,+ });+ }+ });+return (<Show when={isAuthenticated()}>- <div class="flex flex-col gap-1.5 p-0.5 w-full">- <div class="pl-px font-semibold text-ink text-lg truncate">- {`Share "${props.name}"`}- </div>- <div class="-mt-1.5 mb-1 pr-6 pl-px font-medium text-[8pt] text-ink sm:text-sm select-none">- {`Recipients will receive an email if they don't have an account`}- </div>- <div class="flex justify-between items-baseline">+ <div class="flex flex-col w-full">+ <div class="p-2"><RecipientSelector<'user' | 'contact' | 'channel'>- options={destinationOptions}- selectedOptions={selectedOptions}+ placeholder="To: Email Or Group"setSelectedOptions={setSelectedOptions}- placeholder="To: enter emails or group name"+ selectedOptions={selectedOptions}triedToSubmit={triedToSubmit}+ options={destinationOptions}triggerMode="input"+ noBrackets+ hideBorder+ noPadding/></div>- <div class="flex flex-col bg-input shadow-[inset_0_2px_20px_rgba(0,0,0,0.015)] border border-edge w-full min-h-[60px] sm:min-h-[80px] max-h-[150px] overflow-y-auto">+ <div class="flex flex-col w-full h-[150px] overflow-y-auto border-t-1 border-edge-muted/50"><div- class="flex-1 px-2.5 py-1 w-full text-sm"+ class="flex-1 px-[12px] py-[6px] w-full text-sm"onClick={() => focusMarkdownArea()}><MarkdownArea- placeholder="Add a message (optional)..."- initialValue={markdownState()}- dontFocusOnMount+ placeholder="Optional: Message"onEnter={(e: KeyboardEvent) => {handleSubmit();e.preventDefault();return true;}}- useBlockBoundary={false}+ initialValue={markdownState()}onTab={() => {return true;}}+ useBlockBoundary={false}portalScope="local"+ dontFocusOnMount/></div>- </div>- <div class="flex flex-col">- <div- class={`mx-1.5 flex flex-row justify-between items-center align-middle h-fit ${canSendAsGroup() ? '' : 'opacity-50'}`}- >- <div class="flex flex-col gap-0.5">- <div class="font-sm text-ink-muted text-xs select-none">- {'Send as group message'}- </div>- </div>- <KobalteSwitch- checked={sendAsGroupMessage() && canSendAsGroup()}- onChange={setSendAsGroupMessage}- disabled={!canSendAsGroup()}- class={canSendAsGroup() ? '' : 'cursor-not-allowed'}- >- <KobalteSwitch.Input- class="sr-only"+ <Show when={canSendAsGroup()}>+ <div class="p-2 w-min">+ <ToggleSwitch+ switchRootClass={canSendAsGroup() ? '' : 'cursor-not-allowed'}+ checked={sendAsGroupMessage() && canSendAsGroup()}+ onChange={setSendAsGroupMessage}disabled={!canSendAsGroup()}+ label={'Send In Channel'}+ falseLabel="FALSE"+ trueLabel="TRUE"+ size="SM"/>- <KobalteSwitch.Control- class={`mt-1.5 inline-flex h-5 w-9 rounded-full border-2 border-transparent transition-colors bg-edge data-[checked]:bg-accent- ${canSendAsGroup() ? 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2' : ''}`}- >- <KobalteSwitch.Thumb class="block bg-dialog rounded-full w-4 h-4 transition-transform data-[checked]:translate-x-4" />- </KobalteSwitch.Control>- </KobalteSwitch>- </div>- <div class="flex justify-between items-center gap-1 mt-1">- <div class="flex flex-row justify-start items-center gap-0 w-full h-8 cursor-default">- <button- class="flex flex-row justify-center items-center bg-accent/80 hover:bg-accent active:bg-accent px-2 rounded-lg w-full h-full font-semibold text-dialog text-sm leading-5 whitespace-nowrap"- onClick={handleSubmit}- style={{- gap: '8px',- }}- >- <PaperPlaneRight class="flex w-4 h-4" />- {'Share and send message'}- </button></div>- <Show- when={- props.submitPermissionInfo?.userPermissions ===- Permissions.OWNER- }- >- <div class="w-32">- <ShareOptions- permissions={submitAccessLevel()}- setPermissions={(accessLevel) => {- setSubmitAccessLevel(accessLevel);- }}- hideNoAccess- />- </div>- </Show>- </div>+ </Show></div></div></Show>diff --git a/js/app/packages/core/component/TextButton.tsx b/js/app/packages/core/component/TextButton.tsxindex 508c99b4fc..6f1504b69a 100644--- a/js/app/packages/core/component/TextButton.tsx+++ b/js/app/packages/core/component/TextButton.tsx@@ -20,6 +20,7 @@ type TextButton = {icon?: Component<JSX.SvgSVGAttributes<SVGSVGElement>>;iconColor?: string;width?: string;+ height?: string;textSize?: string;onClick?: JSX.EventHandler<HTMLButtonElement, MouseEvent>;onMouseDown?: JSX.EventHandler<HTMLButtonElement, MouseEvent>;@@ -95,6 +96,7 @@ type TextButtonProps = TextButton &* @param props.secondaryTooltip - An optional tooltip to display on the secondary button* @param props.icon - An optional SVG icon to display on the left side of the text* @param props.width - An optional width for the button, if set to 'min-w-0' button will take up the full width of the parent container. The text will be truncated.+ * @param props.height - An optional height for the button, defaults to 'h-8' if not specified* @param props.onClick - An optional handler for the button's onmousedown event* @param props.onOptionClick - An optional handler for the secondary button's onmousedown event* @param props.showChevron - Whether to show the chevron icon@@ -132,13 +134,13 @@ export function TextButton(props: TextButtonProps) {return (<div- class={`${themeColors[props.theme]} flex flex-row h-8 max-w-full justify-start items-center gap-0 cursor-default ${props.class ?? ''}`}+ class={`${themeColors[props.theme]} flex flex-row ${props.height ?? 'h-8'} max-w-full justify-start items-center gap-0 cursor-default ${props.class ?? ''}`}ref={props.ref}id={props.id}><Wrapper tooltip={props.tooltip}><button- class={`${themeStyles[props.theme]} flex flex-row h-8 px-2 $+ class={`${themeStyles[props.theme]} flex flex-row ${props.height ?? 'h-8'} px-2 $${props.outline ? 'border-1 border-edge' : ''}justify-center items-center w-full ${props.disabled ? 'opacity-50 cursor-not-allowed' : ''}`}onClick={props.onClick}@@ -157,7 +159,7 @@ export function TextButton(props: TextButtonProps) {)}<div class="flex flex-1 justify-between items-center gap-2 min-w-0"><div- class={`${props.width ? props.width + ' truncate ' : ''}${props.textSize ?? 'text-sm'} flex-1 text-center font-medium leading-5 whitespace-nowrap truncate`}+ class={`${props.width ? props.width + ' truncate ' : ''}${props.textSize ?? 'text-xs'} font-mono uppercase flex-1 text-center font-medium leading-5 whitespace-nowrap truncate`}>{props.text ?? props.children}</div>@@ -212,7 +214,7 @@ export function EditingTextButton(const [_, setIsRenaming] = useContext(EditingContext);return (<div- class={`${themeColors[props.theme]} flex flex-row h-8 justify-start items-center gap-0+ class={`${themeColors[props.theme]} flex flex-row ${props.height ?? 'h-8'} justify-start items-center gap-0cursor-default border shadow-inner border-edge bg-input`}ref={props.ref}>diff --git a/js/app/packages/core/component/TopBar/ShareButton.tsx b/js/app/packages/core/component/TopBar/ShareButton.tsxindex 3685bb1412..319bf20866 100644--- a/js/app/packages/core/component/TopBar/ShareButton.tsx+++ b/js/app/packages/core/component/TopBar/ShareButton.tsx@@ -7,6 +7,8 @@ import {useBlockId,useBlockName,} from '@core/block';+import { SegmentedControl } from '@core/component/FormControls/SegmentControls';+import { TextButton } from '@core/component/TextButton';import { UserIcon } from '@core/component/UserIcon';import { ENABLE_MARKDOWN_COMMENTS } from '@core/constant/featureFlags';import clickOutside from '@core/directive/clickOutside';@@ -28,9 +30,9 @@ import IconGlobe from '@icon/regular/globe.svg';import IconLink from '@icon/regular/link.svg';import User from '@icon/regular/user.svg';import IconUsers from '@icon/regular/users.svg';+import CloseIcon from '@icon/regular/x.svg';import { Dialog } from '@kobalte/core/dialog';-import { DropdownMenu } from '@kobalte/core/dropdown-menu';-import { Switch as KobalteSwitch } from '@kobalte/core/switch';+import PaperPlaneRight from '@phosphor-icons/core/fill/paper-plane-right-fill.svg?component-solid';import { cognitionApiServiceClient } from '@service-cognition/client';import { commsServiceClient } from '@service-comms/client';import { useUserId } from '@service-gql/client';@@ -54,11 +56,13 @@ import {Show,Switch,} from 'solid-js';+import { beveledCorners } from '../../../block-theme/signals/themeSignals';+import { ClippedPanel } from '../ClippedPanel';+import { DialogWrapper } from '../DialogWrapper';import { ForwardToChannel } from '../ForwardToChannel';import { IconButton } from '../IconButton';-import { DropdownMenuContent, MENU_ITEM_CLASS, MenuItem } from '../Menu';+import { MENU_ITEM_CLASS } from '../Menu';import { Permissions } from '../SharePermissions';-import { TextButton } from '../TextButton';import { toast } from '../Toast/Toast';import { Tooltip } from '../Tooltip';import { openLoginModal } from './LoginButton';@@ -79,13 +83,13 @@ const permissionsBlockResource = createBlockResource(} else if (itemType === 'document') {return storageServiceClient.getDocumentPermissions({ document_id: id });} else if (itemType === 'project') {- if (id === 'trash') return;+ if (id === 'trash') {+ return;+ }return storageServiceClient.projects.getPermissions({ id });}},- {- initialValue: undefined,- }+ { initialValue: undefined });createBlockEffect(() => {@@ -122,18 +126,17 @@ export const refetchDocumentShareButtonResource = () => {console.warn('no document share permission refetch functions initialized');return;}-refetchArray_.forEach((refetch) => refetch());};interface ShareModalProps {- id: string;- name: string;+ setIsSharePermOpen: (value: boolean) => void;userPermissions: Permissions;- itemType: ItemType;isSharePermOpen: boolean;- setIsSharePermOpen: (value: boolean) => void;+ itemType: ItemType;owner?: string;+ name: string;+ id: string;}export function ShareModal(props: ShareModalProps) {@@ -141,31 +144,43 @@ export function ShareModal(props: ShareModalProps) {const { track } = withAnalytics();const [permissionsResource, { refetch }] = permissionsBlockResource;const userId = useUserId();+ const [submitAccessLevel, setSubmitAccessLevel] =+ createSignal<AccessLevel | null>(null);+ const [forwardToChannelRef, setForwardToChannelRef] = createSignal<any>(null);++ createEffect(() => {+ const ref = forwardToChannelRef();+ if (ref && ref.getSubmitAccessLevel) {+ const currentLevel = ref.getSubmitAccessLevel();+ setSubmitAccessLevel(currentLevel);+ }+ });const [channelNamesResource] = createResource(() => {const result = permissionsResource.latest;- if (!result || isErr(result)) return;-+ if (!result || isErr(result)) {+ return;+ }const [, sharePermission] = result;- if (!sharePermission?.channelSharePermissions?.length) return;-+ if (!sharePermission?.channelSharePermissions?.length) {+ return;+ }const channel_ids = sharePermission.channelSharePermissions.map(({ channel_id }) => channel_id);-return { channel_ids };},commsServiceClient.getBatchChannelPreviews,- {- initialValue: undefined,- }+ { initialValue: undefined });// Create a map of channel IDs to channel namesconst channelNameMap = createMemo(() => {const result = channelNamesResource.latest;- if (!result || isErr(result)) return new Map();+ if (!result || isErr(result)) {+ return new Map();+ }const [, data] = result;const map = new Map();@@ -275,42 +290,42 @@ export function ShareModal(props: ShareModalProps) {let result: MaybeResult<any, any> | MaybeError<any> | null = null;if (props.itemType === 'chat') {result = await cognitionApiServiceClient.updateChatPermissions({- chat_id: props.id,sharePermission: {channelSharePermissions: [{operation: 'replace',- channelId,accessLevel,+ channelId,},],},+ chat_id: props.id,});} else if (props.itemType === 'document') {result = await storageServiceClient.editDocument({- documentId: props.id,sharePermission: {channelSharePermissions: [{operation: 'replace',- channelId,accessLevel,+ channelId,},],},+ documentId: props.id,});} else if (props.itemType === 'project') {result = await storageServiceClient.projects.edit({- id: props.id,sharePermission: {channelSharePermissions: [{operation: 'replace',- channelId,accessLevel,+ channelId,},],},+ id: props.id,});}@@ -331,121 +346,87 @@ export function ShareModal(props: ShareModalProps) {const publicAccessLevel = createMemo(() => {const currentPermissions = permissionsResource.latest;- if (!currentPermissions || isErr(currentPermissions)) return;+ if (!currentPermissions || isErr(currentPermissions)) {+ return;+ }const [, sharePermission] = currentPermissions;return sharePermission.publicAccessLevel;});- const isPublic = createMemo(() => {- const currentPermissions = permissionsResource.latest;- if (!currentPermissions || isErr(currentPermissions)) return;-- const [, sharePermission] = currentPermissions;- return sharePermission.isPublic;- });-- const togglePublicAccess = createCallback(async () => {- const currentPermissions = permissionsResource.latest;- if (!currentPermissions || isErr(currentPermissions)) return;-- const [, sharePermission] = currentPermissions;- const newIsPublic = !sharePermission.isPublic;-- if (props.itemType === 'chat') {- const result = await cognitionApiServiceClient.updateChatPermissions({- chat_id: props.id,- sharePermission: {- isPublic: newIsPublic,- publicAccessLevel: newIsPublic ? 'view' : null,- },- });- if (!isErr(result)) {- refetch();- toast.success(- newIsPublic ? 'Made chat public' : 'Made chat private',- newIsPublic- ? 'Anyone with the link can now view this chat'- : 'Only shared users can access this chat'- );- } else {- toast.alert('Failed to change chat access', 'Please try again');- console.error(result);- }- } else if (props.itemType === 'document') {- const result = await storageServiceClient.editDocument({- documentId: props.id,- sharePermission: {- isPublic: newIsPublic,- publicAccessLevel: newIsPublic ? 'view' : null,- },- });- if (!isErr(result)) {- refetch();- toast.success(- newIsPublic ? 'Made document public' : 'Made document private',- newIsPublic- ? 'Anyone with the link can now view this document'- : 'Only shared users can access this document'- );- } else {- toast.alert('Failed to change document access', 'Please try again');- console.error(result);- }- } else if (props.itemType === 'project') {- const result = await storageServiceClient.projects.edit({- id: props.id,- sharePermission: {- isPublic: newIsPublic,- publicAccessLevel: newIsPublic ? 'view' : null,- },- });- if (!isErr(result)) {- refetch();- toast.success(- newIsPublic ? 'Made folder public' : 'Made folder private',- newIsPublic- ? 'Anyone with the link can now view this folder'- : 'Only shared users can access this folder'- );- } else {- toast.alert('Failed to change folder access', 'Please try again');- console.error(result);- }- }- });-const setPublicPermissions = createCallback(async (accessLevel: AccessLevel | null) => {if (props.itemType === 'chat') {- console.error('Cannot set document permissions on chat');- return;+ const result = await cognitionApiServiceClient.updateChatPermissions({+ sharePermission: {+ publicAccessLevel: accessLevel,+ isPublic: accessLevel != null,+ },+ chat_id: props.id,+ });+ if (!isErr(result)) {+ refetch();+ if (accessLevel === null) {+ toast.success(+ 'Made chat private',+ 'Only shared users can access this chat'+ );+ } else {+ toast.success(+ 'Updated public link sharing',+ `Anyone with the link can ${accessLevel} this chat`+ );+ }+ } else {+ toast.alert('Failed to change chat access', 'Please try again');+ console.error(result);+ }} else if (props.itemType === 'document') {const result = await storageServiceClient.editDocument({- documentId: props.id,sharePermission: {- isPublic: accessLevel != null,publicAccessLevel: accessLevel,+ isPublic: accessLevel != null,},+ documentId: props.id,});if (!isErr(result)) {refetch();- toast.success('Updated public link sharing access level');+ if (accessLevel === null) {+ toast.success(+ 'Made document private',+ 'Only shared users can access this document'+ );+ } else {+ toast.success(+ 'Updated public link sharing',+ `Anyone with the link can ${accessLevel} this document`+ );+ }} else {toast.alert('Failed to change document access', 'Please try again');console.error(result);}} else if (props.itemType === 'project') {const result = await storageServiceClient.projects.edit({- id: props.id,sharePermission: {- isPublic: accessLevel != null,publicAccessLevel: accessLevel,+ isPublic: accessLevel != null,},+ id: props.id,});if (!isErr(result)) {refetch();- toast.success('Updated public link sharing access level');+ if (accessLevel === null) {+ toast.success(+ 'Made folder private',+ 'Only shared users can access this folder'+ );+ } else {+ toast.success(+ 'Updated public link sharing',+ `Anyone with the link can ${accessLevel} this folder`+ );+ }} else {toast.alert('Failed to change folder access', 'Please try again');console.error(result);@@ -454,192 +435,197 @@ export function ShareModal(props: ShareModalProps) {});- const [lastModalOpen, setLastModalOpen] = createSignal(false);-const formattedOwner = createMemo(() => {const ownerValue = props.owner;- if (!ownerValue) return '';+ if (!ownerValue) {+ return '';+ }return ownerValue === userId() ? 'Me' : idToEmail(ownerValue).split('@')[0];});return (<Dialog- open={props.isSharePermOpen}onOpenChange={props.setIsSharePermOpen}+ open={props.isSharePermOpen}><Dialog.Portal>- <Dialog.Overlay class="z-modal-overlay fixed inset-0 flex justify-center items-center bg-modal-overlay portal-scope">- <Dialog.Content class="z-modal-content my-auto w-[440px] max-h-[100%] overflow-y-auto text-ink">- <div class="z-0 relative">- <div class="z-3 relative bg-dialog shadow-xl p-2.5 border-1 border-edge rounded-xl w-full">- <ForwardToChannel- name={props.name}- onSubmit={() => props.setIsSharePermOpen(false)}- refetch={refetch}- submitPermissionInfo={{- userPermissions: props.userPermissions,- channelSharePermissions: recipients(),- setChannelPermissions: (id, accessLevel) =>- setChannelPermissions(id, accessLevel, true),- }}- />+ <Dialog.Overlay class="fixed inset-0 z-modal-overlay bg-transparent" />+ <DialogWrapper>+ <Dialog.Content class="text-ink max-h-[100%] overflow-y-auto">+ <ClippedPanel tl={!beveledCorners()} active>+ <div class="flex flex-row items-center justify-between px-2 h-[40px] gap-2 border-b-1 border-b-edge-muted">+ <div class="flex flex-row items-center gap-2">+ <Dialog.CloseButton>+ <IconButton+ tooltip={{ label: 'Close' }}+ icon={CloseIcon}+ iconSize={16}+ theme="clear"+ size="sm"+ />+ </Dialog.CloseButton>+ <Dialog.Title class="text-sm">{`Share: ${props.name}`}</Dialog.Title>+ </div>++ <div class="flex flex-row items-center gap-2">+ <Show when={props.userPermissions === Permissions.OWNER}>+ <ShareOptions+ setPermissions={(accessLevel) => {+ setSubmitAccessLevel(accessLevel);+ forwardToChannelRef()?.setSubmitAccessLevel(+ accessLevel+ );+ }}+ permissions={submitAccessLevel()}+ label="Permission"+ hideNoAccess+ />+ </Show>++ <TextButton+ onClick={() => {+ const selectedOptions =+ forwardToChannelRef()?.getSelectedOptions();+ if (selectedOptions && selectedOptions.length > 0) {+ forwardToChannelRef()?.handleSubmit();+ }+ }}+ theme={+ forwardToChannelRef()?.getSelectedOptions()?.length > 0+ ? 'accent'+ : 'disabled'+ }+ icon={PaperPlaneRight}+ height="h-[22px]"+ text="Share"+ />+ </div></div>++ <ForwardToChannel+ submitPermissionInfo={{+ setChannelPermissions: (id, accessLevel) =>+ setChannelPermissions(id, accessLevel, true),+ userPermissions: props.userPermissions,+ channelSharePermissions: recipients(),+ }}+ onSubmit={() => props.setIsSharePermOpen(false)}+ ref={setForwardToChannelRef}+ refetch={refetch}+ name={props.name}+ />+<Show when={recipients() || props.owner}>- <div class="z-2 relative">- <div class="bg-input shadow-xl mt-4 p-2 pl-4 border-1 border-edge rounded-xl w-full">- <div class="pt-0.5 pb-2 pl-0.5 font-medium text-ink text-md select-none">- Share Recipients- </div>- <div class="flex w-full h-fit max-h-[120px] overflow-y-auto">- <table class="w-full text-ink text-sm border-collapse">- <tbody class="select-none">- <Show when={props.owner}>- <tr class="rounded-md">- <td class="py-1 w-full min-w-0">- <div class="flex items-center gap-2 overflow-hidden">- <UserIcon- id={props.owner!}- size="xs"- isDeleted={false}- />- <div class="font-medium truncate">- {formattedOwner()}- </div>- </div>- </td>- <td class="align-middle">- <div class={MENU_ITEM_CLASS}>Owner</div>- </td>- </tr>- </Show>- <Show when={recipients()}>- <For each={recipients()!}>- {(recipient) => (- <tr class="hover:bg-hover rounded-md hover-transition-bg">- <td- class="py-1 w-full min-w-0 cursor-pointer"- onClick={() =>- navigateToChannel(recipient.channel_id)- }- >- <div class="flex items-center gap-2 overflow-hidden">- <Switch>- <Match- when={channelNameMap().get(- recipient.channel_id- )}- >- <User class="flex-shrink-0 w-4 h-4" />- </Match>- <Match when={true}>- <IconUsers class="flex-shrink-0 w-4 h-4" />- </Match>- </Switch>- <div class="font-medium truncate">- {channelNameMap().get(- recipient.channel_id- )?.name || recipient.channel_id}- </div>- </div>- </td>- <td class="align-middle">- <div class="font-medium text-ink-muted text-xs">- <ShareOptions- permissions={recipient.access_level}- setPermissions={(accessLevel) => {- if (accessLevel === null) {- removeChannelAccess(- recipient.channel_id- );- } else if (- accessLevel !==- recipient.access_level- ) {- setChannelPermissions(- recipient.channel_id,- accessLevel- );- }- }}- />- </div>- </td>- </tr>- )}- </For>- </Show>- </tbody>- </table>- </div>- </div>- </div>- </Show>- <Show when={props.userPermissions === Permissions.OWNER}>- <div class={`relative ${lastModalOpen() ? `z-3` : `z-1`}`}>- <div class="bg-dialog shadow-xl mt-4 p-3 border-1 border-edge rounded-xl w-full">- <div class="flex flex-row justify-between items-center mb-1 align-middle">- <div class="flex flex-col gap-0.5">- <div class="font-medium text-ink text-base select-none">- Public link sharing is {isPublic() ? 'on' : 'off'}+ <div class="border-t-1 border-edge-muted w-full h-fit max-h-[120px] overflow-y-auto">+ <div class="grid gap-[1px] bg-edge-muted/50 text-ink text-sm select-none">+ <Show when={props.owner}>+ <div class="contents rounded-md">+ <div class="flex items-center gap-2 overflow-hidden">+ <UserIcon+ isDeleted={false}+ id={props.owner!}+ size="xs"+ />+ <div class="font-medium truncate">+ {formattedOwner()}+ </div></div>- <div class="font-medium text-ink-muted text-sm">- {isPublic()- ? 'Anyone with the link can access'- : 'Share recipients still have access'}+ <div class="flex items-center">+ <div class={MENU_ITEM_CLASS}>Owner</div></div></div>+ </Show>- <KobalteSwitch- checked={isPublic()}- onChange={togglePublicAccess}- >- <KobalteSwitch.Input class="sr-only" />- <KobalteSwitch.Control class="inline-flex bg-edge/30 data-[checked]:bg-accent mt-1 border-2 border-transparent rounded-full focus-visible:outline-none hover:ring-1 hover:ring-edge focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 w-11 h-6 transition-colors">- <KobalteSwitch.Thumb class="block bg-dialog rounded-full w-5 h-5 transition-transform data-[checked]:translate-x-5" />- </KobalteSwitch.Control>- </KobalteSwitch>- </div>- <Show when={props.itemType !== 'chat'}>- {/* @daniel: TODO - Proper fix for z indexes */}- <ShareOptions- permissions={publicAccessLevel() ?? null}- setPermissions={setPublicPermissions}- setLastModalOpen={setLastModalOpen}- />+ <Show when={recipients()}>+ <For each={recipients()!}>+ {(recipient) => (+ <div class="flex justify-between p-2 bg-panel hover:bg-hover hover-transition-bg group">+ <div+ class="flex items-center gap-2 overflow-hidden cursor-pointer group-hover:bg-hover"+ onClick={() =>+ navigateToChannel(recipient.channel_id)+ }+ >+ <Switch>+ <Match+ when={channelNameMap().get(+ recipient.channel_id+ )}+ >+ <User class="flex-shrink-0 w-4 h-4" />+ </Match>+ <Match when={true}>+ <IconUsers class="flex-shrink-0 w-4 h-4" />+ </Match>+ </Switch>+ <div class="font-medium truncate">+ {channelNameMap().get(recipient.channel_id)+ ?.name || recipient.channel_id}+ </div>+ </div>+ <div class="flex items-center group-hover:bg-hover">+ <div class="font-medium text-ink-muted text-xs">+ <ShareOptions+ permissions={recipient.access_level}+ setPermissions={(accessLevel) => {+ if (accessLevel === null) {+ removeChannelAccess(recipient.channel_id);+ } else if (+ accessLevel !== recipient.access_level+ ) {+ setChannelPermissions(+ recipient.channel_id,+ accessLevel+ );+ }+ }}+ />+ </div>+ </div>+ </div>+ )}+ </For></Show></div></div></Show>- </div>++ <Show when={props.userPermissions === Permissions.OWNER}>+ <div class="flex gap-2 border-t-1 items-center px-2 border-edge-muted h-[40px]">+ <ShareOptions+ permissions={publicAccessLevel() ?? null}+ hideNoAccess={props.itemType === 'chat'}+ setPermissions={setPublicPermissions}+ label="Link Permission"+ />+ </div>+ </Show>+ </ClippedPanel></Dialog.Content>- </Dialog.Overlay>+ </DialogWrapper></Dialog.Portal></Dialog>);}interface ShareButtonProps {- id: string; // document id or chat id- name: string; // document name or chat nameuserPermissions: Permissions; // user permissions are in service-storage/cognition V2 are unified @sharePermissionV2.tscopyLink?: () => void; // some blocks have their own copy link function e.g. canvas copies current (x,y) position+ name: string; // document name or chat name+ id: string; // document id or chat iditemType: ItemType;owner?: string;}export function ShareButton(props: ShareButtonProps) {- const [permissionsResource] = permissionsBlockResource;const [isSharePermOpen, setIsSharePermOpen] = createSignal(false);- const isAuthenticated = useIsAuthenticated();+ const [permissionsResource] = permissionsBlockResource;const blockScopeId = blockHotkeyScopeSignal.get;-- const blockId = useBlockId();+ const isAuthenticated = useIsAuthenticated();const blockType = useBlockName();+ const blockId = useBlockId();onMount(() => {registerHotkey({- hotkey: 'cmd+s',- scopeId: blockScopeId(),- description: 'Share',keyDownHandler: () => {if (!isAuthenticated()) {openLoginModal();@@ -651,14 +637,17 @@ export function ShareButton(props: ShareButtonProps) {},hotkeyToken: TOKENS.block.share,runWithInputFocused: true,+ scopeId: blockScopeId(),+ description: 'Share',+ hotkey: 'cmd+s',});});const defaultUrl = () => {return buildSimpleEntityUrl({- type: blockType,id: blockId ?? '',+ type: blockType,},{});@@ -690,90 +679,66 @@ export function ShareButton(props: ShareButtonProps) {const shareAccessLevelText = createMemo(() => {const maybeResult = permissionsResource.latest;- if (!maybeResult || isErr(maybeResult)) return '';-+ if (!maybeResult || isErr(maybeResult)) {+ return '';+ }const [, sharePermission] = maybeResult;- if (sharePermission.isPublic) return 'Public';- if (sharePermission.channelSharePermissions?.length) return 'Shared';-+ if (sharePermission.isPublic) {+ return 'Public';+ }+ if (sharePermission.channelSharePermissions?.length) {+ return 'Shared';+ }return 'Just me';});return (<><div class="border-1 border-edge-muted flex">- <Switch>- <Match when={shareAccessLevelText() === 'Public'}>- <Tooltip- tooltip={<div>Anyone with the link can access this document</div>}- >- <button- class="text-xs hover:bg-hover text-ink p-1 flex items-center gap-1"- onClick={(e) => {- if (!isAuthenticated()) {- openLoginModal();- } else {- track(TrackingEvents.SHARE.OPEN);- ShareLinkAction().action(e);- setIsSharePermOpen(true);- }- }}- >- Share- <IconGlobe class="size-4" />- </button>- </Tooltip>- </Match>- <Match when={shareAccessLevelText() === 'Shared'}>- <Tooltip- tooltip={<div>Shared with specific people or channels</div>}- >- <button- class="text-xs hover:bg-hover text-ink p-1 flex items-center gap-1"- onClick={(e) => {- if (!isAuthenticated()) {- openLoginModal();- } else {- track(TrackingEvents.SHARE.OPEN);- ShareLinkAction().action(e);- setIsSharePermOpen(true);- }- }}- >- Share- <IconUsers class="size-4" />- </button>- </Tooltip>- </Match>- <Match when={shareAccessLevelText() === 'Just me'}>- <Tooltip tooltip={<div>Only you can access this document</div>}>- <button- class="text-xs hover:bg-hover text-ink p-1 flex items-center gap-1"- onClick={(e) => {- if (!isAuthenticated()) {- openLoginModal();- } else {- track(TrackingEvents.SHARE.OPEN);- ShareLinkAction().action(e);- setIsSharePermOpen(true);- }- }}- >- Share- <IconEyeSlash class="size-4" />- </button>- </Tooltip>- </Match>- </Switch>+ <Tooltip+ tooltip={+ <div>+ {shareAccessLevelText() === 'Public' &&+ 'Anyone with the link can access this document'}+ {shareAccessLevelText() === 'Shared' &&+ 'Shared with specific people or channels'}+ {shareAccessLevelText() === 'Just me' &&+ 'Only you can access this document'}+ </div>+ }+ >+ <button+ class="text-xs font-mono hover:bg-hover text-ink p-1 flex items-center gap-1"+ onClick={() => {+ if (!isAuthenticated()) {+ openLoginModal();+ } else {+ track(TrackingEvents.SHARE.OPEN);+ setIsSharePermOpen(true);+ }+ }}+ >+ SHARE+ {shareAccessLevelText() === 'Public' && (+ <IconGlobe class="size-4" />+ )}+ {shareAccessLevelText() === 'Shared' && (+ <IconUsers class="size-4" />+ )}+ {shareAccessLevelText() === 'Just me' && (+ <IconEyeSlash class="size-4" />+ )}+ </button>+ </Tooltip><div class="h-[24px] w-[1px] bg-edge-muted" /><IconButton- size="sm"- theme="clear"- icon={ShareLinkAction().icon}- onClick={ShareLinkAction().action}tooltip={{ label: 'Copy Share Link' }}+ onClick={ShareLinkAction().action}+ icon={ShareLinkAction().icon}+ theme="clear"+ size="sm"/></div>@@ -791,67 +756,60 @@ export function ShareButton(props: ShareButtonProps) {}export function ShareOptions(props: {- permissions?: AccessLevel | null;setPermissions: (accessLevel: AccessLevel | null) => void;- disabled?: boolean;+ permissions?: AccessLevel | null;hideNoAccess?: boolean;- setLastModalOpen?: (value: boolean) => void; // @daniel: TODO - Proper fix for z indexes+ label?: string | '';+ disabled?: boolean;}) {- const [open, setOpen] = createSignal(false);- const setLastModalOpen = props.setLastModalOpen;- if (setLastModalOpen) {- createEffect(() => {- setLastModalOpen(open());- });- }-const editPermissionEnabled = blockEditPermissionEnabledSignal();const blockName = useBlockName();+ const options = createMemo(() => {+ const optionsList: { value: string; label: string }[] = [];++ // Add comment option if applicable+ if (blockName !== 'md' || ENABLE_MARKDOWN_COMMENTS) {+ optionsList.push({ value: 'comment', label: accessLevelText('comment') });+ }++ // Always add view option+ optionsList.push({ value: 'view', label: accessLevelText('view') });++ // Add edit option if enabled+ if (editPermissionEnabled) {+ optionsList.push({ value: 'edit', label: accessLevelText('edit') });+ }++ // Add no access option if not hidden+ if (!props.hideNoAccess) {+ optionsList.push({ value: 'none', label: accessLevelText(null) });+ }++ return optionsList;+ });++ const currentValue = createMemo(() => {+ if (props.permissions === null) return 'none';+ return props.permissions || 'none';+ });++ const handleChange = (value: string) => {+ if (value === 'none') {+ props.setPermissions(null);+ } else {+ props.setPermissions(value as AccessLevel);+ }+ };+return (- <DropdownMenu open={open()} onOpenChange={setOpen} sameWidth>- <DropdownMenu.Trigger>- <TextButton- theme="clear"- showChevron- disabled={props.disabled}- tabIndex={-1}- >- {accessLevelText(props.permissions)}- </TextButton>- </DropdownMenu.Trigger>- <DropdownMenuContent>- <Show when={blockName !== 'md' || ENABLE_MARKDOWN_COMMENTS}>- <MenuItem- text={accessLevelText('comment')}- onClick={() => {- props.setPermissions('comment');- }}- />- </Show>- <MenuItem- text={accessLevelText('view')}- onClick={() => {- props.setPermissions('view');- }}- />- <Show when={editPermissionEnabled}>- <MenuItem- text={accessLevelText('edit')}- onClick={() => {- props.setPermissions('edit');- }}- />- </Show>- <Show when={!props.hideNoAccess}>- <MenuItem- text={accessLevelText(null)}- onClick={() => {- props.setPermissions(null);- }}- />- </Show>- </DropdownMenuContent>- </DropdownMenu>+ <SegmentedControl+ disabled={props.disabled}+ onChange={handleChange}+ value={currentValue()}+ label={props.label}+ list={options()}+ size="SM"+ />);}