Skip to content

Commit 6a3fd28

Browse files
committed
added more
1 parent 9ef2d67 commit 6a3fd28

File tree

8 files changed

+87
-24
lines changed

8 files changed

+87
-24
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/chat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ export function Chat() {
10491049
onClick={() => document.getElementById('floating-chat-file-input')?.click()}
10501050
title='Attach file'
10511051
className={cn(
1052-
'!bg-transparent cursor-pointer rounded-[6px] p-[0px]',
1052+
'!bg-transparent !border-0 cursor-pointer rounded-[6px] p-[0px]',
10531053
(!activeWorkflowId || isExecuting || chatFiles.length >= 15) &&
10541054
'cursor-not-allowed opacity-50'
10551055
)}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/context-menu/block-context-menu.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export function BlockContextMenu({
2121
onToggleEnabled,
2222
onToggleHandles,
2323
onRemoveFromSubflow,
24-
onOpenPanel,
25-
onOpenLogs,
24+
onOpenEditor,
25+
onRename,
2626
hasClipboard = false,
2727
showRemoveFromSubflow = false,
2828
disableEdit = false,
@@ -36,6 +36,8 @@ export function BlockContextMenu({
3636
(b) => b.type === 'starter' || b.type === 'start_trigger'
3737
)
3838
const allNoteBlocks = selectedBlocks.every((b) => b.type === 'note')
39+
const isSubflow =
40+
isSingleBlock && (selectedBlocks[0]?.type === 'loop' || selectedBlocks[0]?.type === 'parallel')
3941

4042
const canRemoveFromSubflow =
4143
showRemoveFromSubflow &&
@@ -152,29 +154,30 @@ export function BlockContextMenu({
152154
</PopoverItem>
153155
)}
154156

155-
{/* Open Panel - only for single block */}
156-
{isSingleBlock && (
157+
{/* Rename - only for single block, not subflows */}
158+
{isSingleBlock && !isSubflow && (
157159
<PopoverItem
160+
disabled={disableEdit}
158161
onClick={() => {
159-
onOpenPanel()
162+
onRename()
160163
onClose()
161164
}}
162165
>
163-
Open Panel
166+
Rename
164167
</PopoverItem>
165168
)}
166169

167-
{/* Open Logs */}
168-
<PopoverItem
169-
className='group'
170-
onClick={() => {
171-
onOpenLogs()
172-
onClose()
173-
}}
174-
>
175-
<span>Open Logs</span>
176-
<span className='ml-auto text-[var(--text-tertiary)] group-hover:text-inherit'>⌘L</span>
177-
</PopoverItem>
170+
{/* Open Editor - only for single block */}
171+
{isSingleBlock && (
172+
<PopoverItem
173+
onClick={() => {
174+
onOpenEditor()
175+
onClose()
176+
}}
177+
>
178+
Open Editor
179+
</PopoverItem>
180+
)}
178181
</PopoverContent>
179182
</Popover>
180183
)

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/context-menu/pane-context-menu.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ export function PaneContextMenu({
2020
onOpenLogs,
2121
onOpenVariables,
2222
onOpenChat,
23+
onInvite,
2324
hasClipboard = false,
2425
disableEdit = false,
26+
disableAdmin = false,
2527
}: PaneContextMenuProps) {
2628
return (
2729
<Popover open={isOpen} onOpenChange={onClose} variant='secondary' size='sm'>
@@ -131,6 +133,17 @@ export function PaneContextMenu({
131133
>
132134
Open Chat
133135
</PopoverItem>
136+
137+
{/* Invite to Workspace - admin only */}
138+
<PopoverItem
139+
disabled={disableAdmin}
140+
onClick={() => {
141+
onInvite()
142+
onClose()
143+
}}
144+
>
145+
Invite to Workspace
146+
</PopoverItem>
134147
</PopoverContent>
135148
</Popover>
136149
)

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/context-menu/types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export interface BlockContextMenuProps {
4848
onToggleEnabled: () => void
4949
onToggleHandles: () => void
5050
onRemoveFromSubflow: () => void
51-
onOpenPanel: () => void
52-
onOpenLogs: () => void
51+
onOpenEditor: () => void
52+
onRename: () => void
5353
/** Whether clipboard has content for pasting */
5454
hasClipboard?: boolean
5555
/** Whether remove from subflow option should be shown */
@@ -79,8 +79,11 @@ export interface PaneContextMenuProps {
7979
onOpenLogs: () => void
8080
onOpenVariables: () => void
8181
onOpenChat: () => void
82+
onInvite: () => void
8283
/** Whether clipboard has content for pasting */
8384
hasClipboard?: boolean
8485
/** Whether edit actions are disabled (no permission) */
8586
disableEdit?: boolean
87+
/** Whether admin actions are disabled (no admin permission) */
88+
disableAdmin?: boolean
8689
}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/editor.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ const IconComponent = ({ icon: Icon, className }: { icon: any; className?: strin
4242
* @returns Editor panel content
4343
*/
4444
export function Editor() {
45-
const { currentBlockId, connectionsHeight, toggleConnectionsCollapsed } = usePanelEditorStore()
45+
const {
46+
currentBlockId,
47+
connectionsHeight,
48+
toggleConnectionsCollapsed,
49+
shouldFocusRename,
50+
setShouldFocusRename,
51+
} = usePanelEditorStore()
4652
const currentWorkflow = useCurrentWorkflow()
4753
const currentBlock = currentBlockId ? currentWorkflow.getBlockById(currentBlockId) : null
4854
const blockConfig = currentBlock ? getBlock(currentBlock.type) : null
@@ -158,6 +164,14 @@ export function Editor() {
158164
}
159165
}, [isRenaming])
160166

167+
// Trigger rename mode when signaled from context menu
168+
useEffect(() => {
169+
if (shouldFocusRename && currentBlock && !isSubflow) {
170+
handleStartRename()
171+
setShouldFocusRename(false)
172+
}
173+
}, [shouldFocusRename, currentBlock, isSubflow, handleStartRename, setShouldFocusRename])
174+
161175
/**
162176
* Handles opening documentation link in a new secure tab.
163177
*/

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,12 +722,19 @@ const WorkflowContent = React.memo(() => {
722722
})
723723
}, [contextMenuBlocks])
724724

725-
const handleContextOpenPanel = useCallback(() => {
725+
const handleContextOpenEditor = useCallback(() => {
726726
if (contextMenuBlocks.length === 1) {
727727
usePanelEditorStore.getState().setCurrentBlockId(contextMenuBlocks[0].id)
728728
}
729729
}, [contextMenuBlocks])
730730

731+
const handleContextRename = useCallback(() => {
732+
if (contextMenuBlocks.length === 1) {
733+
usePanelEditorStore.getState().setCurrentBlockId(contextMenuBlocks[0].id)
734+
usePanelEditorStore.getState().setShouldFocusRename(true)
735+
}
736+
}, [contextMenuBlocks])
737+
731738
const handleContextAddBlock = useCallback(() => {
732739
useSearchModalStore.getState().open()
733740
}, [])
@@ -744,6 +751,10 @@ const WorkflowContent = React.memo(() => {
744751
useChatStore.getState().setIsChatOpen(true)
745752
}, [])
746753

754+
const handleContextInvite = useCallback(() => {
755+
window.dispatchEvent(new CustomEvent('open-invite-modal'))
756+
}, [])
757+
747758
useEffect(() => {
748759
let cleanup: (() => void) | null = null
749760

@@ -2855,8 +2866,8 @@ const WorkflowContent = React.memo(() => {
28552866
onToggleEnabled={handleContextToggleEnabled}
28562867
onToggleHandles={handleContextToggleHandles}
28572868
onRemoveFromSubflow={handleContextRemoveFromSubflow}
2858-
onOpenPanel={handleContextOpenPanel}
2859-
onOpenLogs={handleContextOpenLogs}
2869+
onOpenEditor={handleContextOpenEditor}
2870+
onRename={handleContextRename}
28602871
hasClipboard={hasClipboard()}
28612872
showRemoveFromSubflow={contextMenuBlocks.some(
28622873
(b) => b.parentId && (b.parentType === 'loop' || b.parentType === 'parallel')
@@ -2877,8 +2888,10 @@ const WorkflowContent = React.memo(() => {
28772888
onOpenLogs={handleContextOpenLogs}
28782889
onOpenVariables={handleContextOpenVariables}
28792890
onOpenChat={handleContextOpenChat}
2891+
onInvite={handleContextInvite}
28802892
hasClipboard={hasClipboard()}
28812893
disableEdit={!effectivePermissions.canEdit}
2894+
disableAdmin={!effectivePermissions.canAdmin}
28822895
/>
28832896
</>
28842897
)}

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ export function WorkspaceHeader({
151151
setIsMounted(true)
152152
}, [])
153153

154+
// Listen for open-invite-modal event from context menu
155+
useEffect(() => {
156+
const handleOpenInvite = () => setIsInviteModalOpen(true)
157+
window.addEventListener('open-invite-modal', handleOpenInvite)
158+
return () => window.removeEventListener('open-invite-modal', handleOpenInvite)
159+
}, [])
160+
154161
/**
155162
* Focus the inline list rename input when it becomes active
156163
*/

apps/sim/stores/panel/editor/store.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ interface PanelEditorState {
2222
setConnectionsHeight: (height: number) => void
2323
/** Toggle connections between collapsed (min height) and expanded (default height) */
2424
toggleConnectionsCollapsed: () => void
25+
/** Flag to signal the editor to focus the rename input */
26+
shouldFocusRename: boolean
27+
/** Sets the shouldFocusRename flag */
28+
setShouldFocusRename: (value: boolean) => void
2529
}
2630

2731
/**
@@ -33,6 +37,8 @@ export const usePanelEditorStore = create<PanelEditorState>()(
3337
(set, get) => ({
3438
currentBlockId: null,
3539
connectionsHeight: EDITOR_CONNECTIONS_HEIGHT.DEFAULT,
40+
shouldFocusRename: false,
41+
setShouldFocusRename: (value) => set({ shouldFocusRename: value }),
3642
setCurrentBlockId: (blockId) => {
3743
set({ currentBlockId: blockId })
3844

@@ -79,6 +85,10 @@ export const usePanelEditorStore = create<PanelEditorState>()(
7985
}),
8086
{
8187
name: 'panel-editor-state',
88+
partialize: (state) => ({
89+
currentBlockId: state.currentBlockId,
90+
connectionsHeight: state.connectionsHeight,
91+
}),
8292
onRehydrateStorage: () => (state) => {
8393
// Sync CSS variables with stored state after rehydration
8494
if (state && typeof window !== 'undefined') {

0 commit comments

Comments
 (0)