@workbench-kit/shell-react 0.0.2-prototype.0.2.6 → 0.0.2-prototype.0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/package.json +9 -9
- package/src/{chat-ai-mock-proposals.ts → chat/ai-mock-proposals.ts} +39 -39
- package/src/{chat-command-input.ts → chat/command-input.ts} +52 -52
- package/src/{chat-command-policy.ts → chat/command-policy.ts} +54 -54
- package/src/{chat-command-surface.tsx → chat/command-surface.tsx} +155 -155
- package/src/{use-workbench-chat-command-proposals.ts → chat/use-chat-command-proposals.ts} +194 -194
- package/src/{chat-view-data.ts → chat/view-data.ts} +20 -20
- package/src/{chat-view.tsx → chat/view.tsx} +220 -220
- package/src/{command-inspector-surface.tsx → commands/inspector-surface.tsx} +46 -46
- package/src/{use-workbench-command-descriptors.ts → commands/use-command-descriptors.ts} +41 -41
- package/src/{use-context-key-revision.ts → commands/use-context-key-revision.ts} +18 -18
- package/src/{commands-view-data.ts → commands/view-data.ts} +17 -17
- package/src/{commands-view.tsx → commands/view.tsx} +43 -43
- package/src/devtools/WorkbenchDevtoolsPanel.tsx +124 -124
- package/src/devtools/WorkbenchDevtoolsShell.tsx +17 -17
- package/src/devtools/index.ts +11 -11
- package/src/devtools/use-workbench-devtools-snapshot.ts +84 -84
- package/src/devtools/workbench-devtools-snapshot.ts +140 -140
- package/src/devtools/workbench-devtools.css +82 -82
- package/src/{editor-area-dnd.ts → editor/area-dnd.ts} +69 -69
- package/src/{editor-area-model.ts → editor/area-model.ts} +71 -71
- package/src/{editor-area.css → editor/area.css} +454 -454
- package/src/{editor-area.tsx → editor/area.tsx} +676 -676
- package/src/{editor-host-surface.tsx → editor/host-surface.tsx} +631 -634
- package/src/{editor-pane-visibility.ts → editor/pane-visibility.ts} +130 -130
- package/src/{editor-resource.ts → editor/resource.ts} +36 -36
- package/src/{editor-state-storage.ts → editor/state-storage.ts} +182 -193
- package/src/{editor-tab-context-menu.ts → editor/tab-context-menu.ts} +118 -118
- package/src/{use-editor.ts → editor/use-editor.ts} +114 -107
- package/src/{editor-view-providers.tsx → editor/view-providers.tsx} +552 -552
- package/src/{editor-workspace-file-availability.ts → editor/workspace-file-availability.ts} +15 -15
- package/src/{editor-workspace-reconcile.tsx → editor/workspace-reconcile.tsx} +31 -28
- package/src/{explorer-context-menu.ts → explorer/context-menu.ts} +114 -114
- package/src/{createCommandWorkspaceExplorerPort.ts → explorer/create-command-workspace-explorer-port.ts} +86 -86
- package/src/{explorer-reveal.ts → explorer/reveal.ts} +112 -112
- package/src/{search-view-data.ts → explorer/search-view-data.ts} +15 -15
- package/src/{search-view.tsx → explorer/search-view.tsx} +65 -62
- package/src/{use-active-workspace-path.ts → explorer/use-active-workspace-path.ts} +15 -15
- package/src/{explorer-view-data.ts → explorer/view-data.ts} +58 -58
- package/src/{explorer-view.tsx → explorer/view.tsx} +227 -224
- package/src/{extension-context-menu.ts → extensions/context-menu.ts} +52 -52
- package/src/{extension-management-model.ts → extensions/management-model.ts} +313 -313
- package/src/{use-extension-management.ts → extensions/use-extension-management.ts} +241 -193
- package/src/{extensions-view-data.ts → extensions/view-data.ts} +19 -19
- package/src/{extensions-view.tsx → extensions/view.tsx} +63 -38
- package/src/{field-remap-demo.tsx → field-remap/demo.tsx} +18 -18
- package/src/{field-remap-editor-surface.tsx → field-remap/editor-surface.tsx} +36 -36
- package/src/{field-remap-flow-adapter.ts → field-remap/flow-adapter.ts} +240 -240
- package/src/{field-remap-flow.tsx → field-remap/flow.tsx} +369 -369
- package/src/{field-remap-graph.tsx → field-remap/graph.tsx} +559 -559
- package/src/field-remap/jsonata-transform.ts +166 -0
- package/src/{field-remap-panel.tsx → field-remap/panel.tsx} +193 -175
- package/src/{field-remap-samples.ts → field-remap/samples.ts} +352 -352
- package/src/{table-mapping-adapter.ts → field-remap/table-mapping-adapter.ts} +59 -59
- package/src/{field-remap-tree.tsx → field-remap/tree.tsx} +404 -404
- package/src/{field-remap-view-data.ts → field-remap/view-data.ts} +16 -16
- package/src/{field-remap-view.css → field-remap/view.css} +676 -676
- package/src/{field-remap-view.tsx → field-remap/view.tsx} +86 -86
- package/src/index.ts +212 -199
- package/src/{json-form-source-patch.ts → jdw/json-form-source-patch.ts} +323 -323
- package/src/{jdw-lab-view-data.ts → jdw/lab-view-data.ts} +25 -25
- package/src/{jdw-lab-view.css → jdw/lab-view.css} +21 -21
- package/src/{jdw-lab-view.tsx → jdw/lab-view.tsx} +79 -79
- package/src/{jdw-widget-form-view.tsx → jdw/widget-form-view.tsx} +68 -65
- package/src/{jdw-widget-preview-view.tsx → jdw/widget-preview-view.tsx} +54 -51
- package/src/{keybinding-overrides-storage.ts → management/keybinding-overrides-storage.ts} +49 -57
- package/src/{keybinding-management-settings.tsx → management/keybinding-settings.tsx} +16 -16
- package/src/{management-palette-commands.ts → management/palette-commands.ts} +38 -38
- package/src/{preference-settings-storage.ts → management/preference-settings-storage.ts} +50 -58
- package/src/{management-settings-ids.ts → management/settings-ids.ts} +12 -12
- package/src/{management-settings.tsx → management/settings.tsx} +96 -75
- package/src/{use-command-management.ts → management/use-command-management.ts} +191 -191
- package/src/{use-keybinding-management.ts → management/use-keybinding-management.ts} +130 -130
- package/src/{shell-model.tsx → shell/model.tsx} +149 -149
- package/src/{provider.tsx → shell/provider.tsx} +603 -573
- package/src/{shell-secondary-actions.tsx → shell/secondary-actions.tsx} +59 -59
- package/src/{shell-settings-constants.ts → shell/settings-constants.ts} +9 -9
- package/src/{shell-settings.tsx → shell/settings.tsx} +599 -599
- package/src/{shell.tsx → shell/shell.tsx} +680 -649
- package/src/{shell-titlebar-layout-controls.tsx → shell/titlebar-layout-controls.tsx} +4 -4
- package/src/{shell-view-host.tsx → shell/view-host.tsx} +212 -199
- package/src/{workbench-appearance-storage.ts → workbench/appearance-storage.ts} +107 -115
- package/src/{workbench-command-host.tsx → workbench/command-host.tsx} +243 -243
- package/src/{workbench-command-palette.ts → workbench/command-palette.ts} +208 -208
- package/src/{workbench-keybinding-bridge.ts → workbench/keybinding-bridge.ts} +54 -54
- package/src/{workbench-layout-storage.ts → workbench/layout-storage.ts} +134 -145
- package/src/{workbench-profile-modal.tsx → workbench/profile-modal.tsx} +118 -118
- package/src/{workbench-shell-command-registration.ts → workbench/shell-command-registration.ts} +58 -58
- package/src/{workbench-startup-gate.tsx → workbench/startup-gate.tsx} +136 -136
- package/src/{workbench-status-sections.ts → workbench/status-sections.ts} +43 -43
- package/src/{use-persisted-workbench-appearance.ts → workbench/use-persisted-appearance.ts} +33 -33
- package/src/{workbench-user-commands.ts → workbench/user-commands.ts} +46 -46
- package/src/{workspace-view-state.ts → workbench/workspace-view-state.ts} +35 -35
- package/src/jsonata-transform.ts +0 -36
|
@@ -1,224 +1,227 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useCallback,
|
|
3
|
-
useEffect,
|
|
4
|
-
useMemo,
|
|
5
|
-
useRef,
|
|
6
|
-
useState,
|
|
7
|
-
type MouseEvent as ReactMouseEvent,
|
|
8
|
-
} from 'react';
|
|
9
|
-
import { ContextMenu, type ContextMenuItem } from '@workbench-kit/react/overlay';
|
|
10
|
-
import { ViewEmptyState } from '@workbench-kit/react/primitives';
|
|
11
|
-
import {
|
|
12
|
-
WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID,
|
|
13
|
-
WORKBENCH_WORKSPACE_DELETE_COMMAND_ID,
|
|
14
|
-
WORKBENCH_WORKSPACE_OPEN_COMMAND_ID,
|
|
15
|
-
} from '@workbench-kit/react/workbench/commands';
|
|
16
|
-
import {
|
|
17
|
-
WorkspaceExplorerPanel,
|
|
18
|
-
buildWorkspaceExplorerNodes,
|
|
19
|
-
resolveWorkspaceExplorerSectionTitle,
|
|
20
|
-
useWorkspaceExplorerController,
|
|
21
|
-
} from '@workbench-kit/react/workbench/workspace';
|
|
22
|
-
import { type WorkspaceExplorerItemContextMenuMeta } from '@workbench-kit/react/workbench/workspace/explorer';
|
|
23
|
-
import { resolveWorkspaceCreateParentPath, type WorkspaceTreeNode } from '@workbench-kit/workspace';
|
|
24
|
-
import { createCommandWorkspaceExplorerPort } from './
|
|
25
|
-
import { createExplorerItemContextMenuItems } from './
|
|
26
|
-
import { applyExplorerPathReveal, subscribeExplorerRevealRequest } from './
|
|
27
|
-
import {
|
|
28
|
-
BUILTIN_EXPLORER_REFRESH_COMMAND_ID,
|
|
29
|
-
type BuiltinExplorerViewRenderData,
|
|
30
|
-
} from './
|
|
31
|
-
import { useWorkbench } from '
|
|
32
|
-
import { useActiveWorkspacePath } from './use-active-workspace-path.js';
|
|
33
|
-
import { useActiveEditorTab } from '
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
readonly
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useMemo,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
type MouseEvent as ReactMouseEvent,
|
|
8
|
+
} from 'react';
|
|
9
|
+
import { ContextMenu, type ContextMenuItem } from '@workbench-kit/react/overlay';
|
|
10
|
+
import { ViewEmptyState } from '@workbench-kit/react/primitives';
|
|
11
|
+
import {
|
|
12
|
+
WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID,
|
|
13
|
+
WORKBENCH_WORKSPACE_DELETE_COMMAND_ID,
|
|
14
|
+
WORKBENCH_WORKSPACE_OPEN_COMMAND_ID,
|
|
15
|
+
} from '@workbench-kit/react/workbench/commands';
|
|
16
|
+
import {
|
|
17
|
+
WorkspaceExplorerPanel,
|
|
18
|
+
buildWorkspaceExplorerNodes,
|
|
19
|
+
resolveWorkspaceExplorerSectionTitle,
|
|
20
|
+
useWorkspaceExplorerController,
|
|
21
|
+
} from '@workbench-kit/react/workbench/workspace';
|
|
22
|
+
import { type WorkspaceExplorerItemContextMenuMeta } from '@workbench-kit/react/workbench/workspace/explorer';
|
|
23
|
+
import { resolveWorkspaceCreateParentPath, type WorkspaceTreeNode } from '@workbench-kit/workspace';
|
|
24
|
+
import { createCommandWorkspaceExplorerPort } from './create-command-workspace-explorer-port.js';
|
|
25
|
+
import { createExplorerItemContextMenuItems } from './context-menu.js';
|
|
26
|
+
import { applyExplorerPathReveal, subscribeExplorerRevealRequest } from './reveal.js';
|
|
27
|
+
import {
|
|
28
|
+
BUILTIN_EXPLORER_REFRESH_COMMAND_ID,
|
|
29
|
+
type BuiltinExplorerViewRenderData,
|
|
30
|
+
} from './view-data.js';
|
|
31
|
+
import { useWorkbench } from '../shell/provider.js';
|
|
32
|
+
import { useActiveWorkspacePath } from './use-active-workspace-path.js';
|
|
33
|
+
import { useActiveEditorTab } from '../editor/use-editor.js';
|
|
34
|
+
import {
|
|
35
|
+
isWorkspaceResourceService,
|
|
36
|
+
useWorkspaceResourceState,
|
|
37
|
+
} from '../workbench/workspace-view-state.js';
|
|
38
|
+
|
|
39
|
+
export type { BuiltinExplorerViewRenderData };
|
|
40
|
+
export {
|
|
41
|
+
BUILTIN_EXPLORER_MOVE_COMMAND_ID,
|
|
42
|
+
BUILTIN_EXPLORER_REFRESH_COMMAND_ID,
|
|
43
|
+
BUILTIN_EXPLORER_VIEW_RENDER_KIND,
|
|
44
|
+
isBuiltinExplorerViewRenderData,
|
|
45
|
+
} from './view-data.js';
|
|
46
|
+
|
|
47
|
+
interface ExplorerContextMenuState {
|
|
48
|
+
readonly ariaLabel: string;
|
|
49
|
+
readonly items: ContextMenuItem[];
|
|
50
|
+
readonly x: number;
|
|
51
|
+
readonly y: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function BuiltinExplorerView() {
|
|
55
|
+
const { executeCommand, extensionRegistry, workspaceHostPort } = useWorkbench();
|
|
56
|
+
const activeTab = useActiveEditorTab();
|
|
57
|
+
const workspaceService = isWorkspaceResourceService(workspaceHostPort?.service)
|
|
58
|
+
? workspaceHostPort.service
|
|
59
|
+
: undefined;
|
|
60
|
+
const workspaceState = useWorkspaceResourceState(workspaceService);
|
|
61
|
+
const [contextMenu, setContextMenu] = useState<ExplorerContextMenuState | null>(null);
|
|
62
|
+
const [seededExpandedPaths, setSeededExpandedPaths] = useState(false);
|
|
63
|
+
|
|
64
|
+
const activePath = useActiveWorkspacePath(activeTab?.resourceUri);
|
|
65
|
+
|
|
66
|
+
const port = useMemo(
|
|
67
|
+
() =>
|
|
68
|
+
createCommandWorkspaceExplorerPort({
|
|
69
|
+
executeCommand,
|
|
70
|
+
workspaceState,
|
|
71
|
+
}),
|
|
72
|
+
[executeCommand, workspaceState],
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const explorer = useWorkspaceExplorerController({
|
|
76
|
+
activePath,
|
|
77
|
+
initialExpandedPaths: workspaceState?.expandedPaths,
|
|
78
|
+
port,
|
|
79
|
+
});
|
|
80
|
+
const explorerRef = useRef(explorer);
|
|
81
|
+
explorerRef.current = explorer;
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!workspaceState || seededExpandedPaths) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
workspaceState.expandedPaths.forEach((path) => {
|
|
89
|
+
explorer.revealFolder(path);
|
|
90
|
+
});
|
|
91
|
+
setSeededExpandedPaths(true);
|
|
92
|
+
}, [explorer, seededExpandedPaths, workspaceState]);
|
|
93
|
+
|
|
94
|
+
useEffect(
|
|
95
|
+
() =>
|
|
96
|
+
subscribeExplorerRevealRequest((path) => {
|
|
97
|
+
const currentExplorer = explorerRef.current;
|
|
98
|
+
applyExplorerPathReveal(path, {
|
|
99
|
+
revealFolder: currentExplorer.revealFolder,
|
|
100
|
+
setSelection: (selection) => {
|
|
101
|
+
currentExplorer.handleSelectionChange(selection, { mode: 'single', reason: 'click' });
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}),
|
|
105
|
+
[],
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const nodes = useMemo(
|
|
109
|
+
() =>
|
|
110
|
+
buildWorkspaceExplorerNodes({
|
|
111
|
+
files: workspaceState?.files ?? [],
|
|
112
|
+
folders: workspaceState?.folders ?? [],
|
|
113
|
+
}),
|
|
114
|
+
[workspaceState],
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const sectionTitle = useMemo(
|
|
118
|
+
() => resolveWorkspaceExplorerSectionTitle(workspaceState?.files ?? []),
|
|
119
|
+
[workspaceState?.files],
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const createParentPath = useMemo(
|
|
123
|
+
() =>
|
|
124
|
+
resolveWorkspaceCreateParentPath(
|
|
125
|
+
explorer.selection.focusedPath,
|
|
126
|
+
workspaceState?.folders ?? [],
|
|
127
|
+
),
|
|
128
|
+
[explorer.selection.focusedPath, workspaceState?.folders],
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const executeWorkspaceCommand = useCallback(
|
|
132
|
+
async (commandId: string, payload?: unknown) => {
|
|
133
|
+
await executeCommand(commandId, payload);
|
|
134
|
+
},
|
|
135
|
+
[executeCommand],
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const handleItemContextMenu = useCallback(
|
|
139
|
+
(
|
|
140
|
+
event: ReactMouseEvent<HTMLButtonElement>,
|
|
141
|
+
node: WorkspaceTreeNode,
|
|
142
|
+
meta: WorkspaceExplorerItemContextMenuMeta,
|
|
143
|
+
) => {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
setContextMenu({
|
|
146
|
+
ariaLabel: `${node.name} menu`,
|
|
147
|
+
items: createExplorerItemContextMenuItems({
|
|
148
|
+
actionPaths: meta.actionPaths,
|
|
149
|
+
copyPaths: (paths) => {
|
|
150
|
+
void executeWorkspaceCommand(WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID, { paths });
|
|
151
|
+
},
|
|
152
|
+
createFile: (parentPath) => explorer.startCreate('create-file', parentPath),
|
|
153
|
+
createFolder: (parentPath) => explorer.startCreate('create-folder', parentPath),
|
|
154
|
+
deleteTargets: (paths) => {
|
|
155
|
+
void executeWorkspaceCommand(WORKBENCH_WORKSPACE_DELETE_COMMAND_ID, {
|
|
156
|
+
kind: node.type,
|
|
157
|
+
paths,
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
executeExtensionCommand: (commandId) => executeCommand(commandId),
|
|
161
|
+
extensionRegistry,
|
|
162
|
+
files: workspaceState?.files ?? [],
|
|
163
|
+
node,
|
|
164
|
+
openFiles: (paths) => {
|
|
165
|
+
void executeWorkspaceCommand(WORKBENCH_WORKSPACE_OPEN_COMMAND_ID, {
|
|
166
|
+
kind: 'file',
|
|
167
|
+
paths,
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
revealFolder: explorer.revealFolder,
|
|
171
|
+
renameTarget: () => explorer.startRename(node, meta.actionPaths),
|
|
172
|
+
}),
|
|
173
|
+
x: event.clientX,
|
|
174
|
+
y: event.clientY,
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
[executeWorkspaceCommand, explorer, workspaceState?.files],
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
if (!workspaceService || !workspaceState) {
|
|
181
|
+
return (
|
|
182
|
+
<ViewEmptyState className="workbench-explorer-view">
|
|
183
|
+
No virtual workspace is registered.
|
|
184
|
+
</ViewEmptyState>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<>
|
|
190
|
+
<WorkspaceExplorerPanel
|
|
191
|
+
activePath={activePath}
|
|
192
|
+
aria-label="Workspace Explorer"
|
|
193
|
+
expandedPaths={explorer.expandedPaths}
|
|
194
|
+
focusedPath={explorer.selection.focusedPath}
|
|
195
|
+
inlineEdit={explorer.inlineEdit}
|
|
196
|
+
nodes={nodes}
|
|
197
|
+
onNewFile={() => explorer.startCreate('create-file', createParentPath)}
|
|
198
|
+
onNewFolder={() => explorer.startCreate('create-folder', createParentPath)}
|
|
199
|
+
onRefresh={() => {
|
|
200
|
+
void executeWorkspaceCommand(BUILTIN_EXPLORER_REFRESH_COMMAND_ID);
|
|
201
|
+
}}
|
|
202
|
+
sectionTitle={sectionTitle}
|
|
203
|
+
selectedPaths={explorer.selection.paths}
|
|
204
|
+
selectionAnchorPath={explorer.selection.anchorPath}
|
|
205
|
+
onActivateFile={explorer.handleActivateFile}
|
|
206
|
+
onItemContextMenu={handleItemContextMenu}
|
|
207
|
+
onInlineEditCancel={explorer.cancelInlineEdit}
|
|
208
|
+
onInlineEditCommit={explorer.handleInlineEditCommit}
|
|
209
|
+
onInlineEditValueChange={explorer.handleInlineEditValueChange}
|
|
210
|
+
onRequestDelete={explorer.handleRequestDelete}
|
|
211
|
+
onRequestMove={explorer.handleRequestMove}
|
|
212
|
+
onRequestRename={explorer.handleRequestRename}
|
|
213
|
+
onSelectionChange={explorer.handleSelectionChange}
|
|
214
|
+
onToggleFolder={explorer.handleToggleFolder}
|
|
215
|
+
/>
|
|
216
|
+
{contextMenu ? (
|
|
217
|
+
<ContextMenu
|
|
218
|
+
ariaLabel={contextMenu.ariaLabel}
|
|
219
|
+
items={contextMenu.items}
|
|
220
|
+
x={contextMenu.x}
|
|
221
|
+
y={contextMenu.y}
|
|
222
|
+
onClose={() => setContextMenu(null)}
|
|
223
|
+
/>
|
|
224
|
+
) : null}
|
|
225
|
+
</>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import type { ContextMenuItem } from '@workbench-kit/react/overlay';
|
|
2
|
-
import { commandMenuItemsToContextMenuItems } from '@workbench-kit/react/workbench/commands';
|
|
3
|
-
import {
|
|
4
|
-
resolveWorkbenchMenuContributions,
|
|
5
|
-
type ExtensionRegistry,
|
|
6
|
-
} from '@workbench-kit/workbench-core';
|
|
7
|
-
|
|
8
|
-
export interface ExtensionContextMenuInput {
|
|
9
|
-
readonly contextKeys?: object | undefined;
|
|
10
|
-
readonly executeCommand?: ((commandId: string) => unknown) | undefined;
|
|
11
|
-
readonly extensionRegistry?: ExtensionRegistry | undefined;
|
|
12
|
-
readonly menu: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function createExtensionContextMenuItems({
|
|
16
|
-
contextKeys,
|
|
17
|
-
executeCommand,
|
|
18
|
-
extensionRegistry,
|
|
19
|
-
menu,
|
|
20
|
-
}: ExtensionContextMenuInput): ContextMenuItem[] {
|
|
21
|
-
if (!extensionRegistry || !executeCommand) {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const menuItems = resolveWorkbenchMenuContributions({
|
|
26
|
-
commandRegistry: extensionRegistry.commands,
|
|
27
|
-
context: undefined,
|
|
28
|
-
contextKeys,
|
|
29
|
-
menu,
|
|
30
|
-
menuItems: extensionRegistry.menus.getMenuItems(menu),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return commandMenuItemsToContextMenuItems([...menuItems], (commandId) => {
|
|
34
|
-
void executeCommand(commandId);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function appendExtensionContextMenuItems(
|
|
39
|
-
baseItems: readonly ContextMenuItem[],
|
|
40
|
-
extensionItems: readonly ContextMenuItem[],
|
|
41
|
-
separatorId: string,
|
|
42
|
-
): ContextMenuItem[] {
|
|
43
|
-
if (extensionItems.length === 0) {
|
|
44
|
-
return [...baseItems];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (baseItems.length === 0) {
|
|
48
|
-
return [...extensionItems];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return [...baseItems, { id: separatorId, type: 'separator' }, ...extensionItems];
|
|
52
|
-
}
|
|
1
|
+
import type { ContextMenuItem } from '@workbench-kit/react/overlay';
|
|
2
|
+
import { commandMenuItemsToContextMenuItems } from '@workbench-kit/react/workbench/commands';
|
|
3
|
+
import {
|
|
4
|
+
resolveWorkbenchMenuContributions,
|
|
5
|
+
type ExtensionRegistry,
|
|
6
|
+
} from '@workbench-kit/workbench-core';
|
|
7
|
+
|
|
8
|
+
export interface ExtensionContextMenuInput {
|
|
9
|
+
readonly contextKeys?: object | undefined;
|
|
10
|
+
readonly executeCommand?: ((commandId: string) => unknown) | undefined;
|
|
11
|
+
readonly extensionRegistry?: ExtensionRegistry | undefined;
|
|
12
|
+
readonly menu: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createExtensionContextMenuItems({
|
|
16
|
+
contextKeys,
|
|
17
|
+
executeCommand,
|
|
18
|
+
extensionRegistry,
|
|
19
|
+
menu,
|
|
20
|
+
}: ExtensionContextMenuInput): ContextMenuItem[] {
|
|
21
|
+
if (!extensionRegistry || !executeCommand) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const menuItems = resolveWorkbenchMenuContributions({
|
|
26
|
+
commandRegistry: extensionRegistry.commands,
|
|
27
|
+
context: undefined,
|
|
28
|
+
contextKeys,
|
|
29
|
+
menu,
|
|
30
|
+
menuItems: extensionRegistry.menus.getMenuItems(menu),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return commandMenuItemsToContextMenuItems([...menuItems], (commandId) => {
|
|
34
|
+
void executeCommand(commandId);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function appendExtensionContextMenuItems(
|
|
39
|
+
baseItems: readonly ContextMenuItem[],
|
|
40
|
+
extensionItems: readonly ContextMenuItem[],
|
|
41
|
+
separatorId: string,
|
|
42
|
+
): ContextMenuItem[] {
|
|
43
|
+
if (extensionItems.length === 0) {
|
|
44
|
+
return [...baseItems];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (baseItems.length === 0) {
|
|
48
|
+
return [...extensionItems];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return [...baseItems, { id: separatorId, type: 'separator' }, ...extensionItems];
|
|
52
|
+
}
|