@workbench-kit/shell-react 0.0.2-prototype.0.2.6
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/package.json +49 -0
- package/src/chat-ai-mock-proposals.ts +39 -0
- package/src/chat-command-input.ts +52 -0
- package/src/chat-command-policy.ts +54 -0
- package/src/chat-command-surface.tsx +155 -0
- package/src/chat-view-data.ts +20 -0
- package/src/chat-view.tsx +220 -0
- package/src/command-inspector-surface.tsx +46 -0
- package/src/commands-view-data.ts +17 -0
- package/src/commands-view.tsx +43 -0
- package/src/createCommandWorkspaceExplorerPort.ts +86 -0
- package/src/devtools/WorkbenchDevtoolsPanel.tsx +124 -0
- package/src/devtools/WorkbenchDevtoolsShell.tsx +17 -0
- package/src/devtools/index.ts +11 -0
- package/src/devtools/use-workbench-devtools-snapshot.ts +84 -0
- package/src/devtools/workbench-devtools-snapshot.ts +140 -0
- package/src/devtools/workbench-devtools.css +82 -0
- package/src/editor-area-dnd.ts +69 -0
- package/src/editor-area-model.ts +71 -0
- package/src/editor-area.css +454 -0
- package/src/editor-area.tsx +676 -0
- package/src/editor-host-surface.tsx +634 -0
- package/src/editor-pane-visibility.ts +130 -0
- package/src/editor-resource.ts +36 -0
- package/src/editor-state-storage.ts +193 -0
- package/src/editor-tab-context-menu.ts +118 -0
- package/src/editor-view-providers.tsx +552 -0
- package/src/editor-workspace-file-availability.ts +15 -0
- package/src/editor-workspace-reconcile.tsx +28 -0
- package/src/explorer-context-menu.ts +114 -0
- package/src/explorer-reveal.ts +112 -0
- package/src/explorer-view-data.ts +58 -0
- package/src/explorer-view.tsx +224 -0
- package/src/extension-context-menu.ts +52 -0
- package/src/extension-management-model.ts +313 -0
- package/src/extensions-view-data.ts +19 -0
- package/src/extensions-view.tsx +38 -0
- package/src/field-remap-demo.tsx +18 -0
- package/src/field-remap-editor-surface.tsx +36 -0
- package/src/field-remap-flow-adapter.ts +240 -0
- package/src/field-remap-flow.tsx +369 -0
- package/src/field-remap-graph.tsx +559 -0
- package/src/field-remap-panel.tsx +175 -0
- package/src/field-remap-samples.ts +352 -0
- package/src/field-remap-tree.tsx +404 -0
- package/src/field-remap-view-data.ts +16 -0
- package/src/field-remap-view.css +676 -0
- package/src/field-remap-view.tsx +86 -0
- package/src/index.ts +199 -0
- package/src/jdw-lab-view-data.ts +25 -0
- package/src/jdw-lab-view.css +21 -0
- package/src/jdw-lab-view.tsx +79 -0
- package/src/jdw-widget-form-view.tsx +65 -0
- package/src/jdw-widget-preview-view.tsx +51 -0
- package/src/json-form-source-patch.ts +323 -0
- package/src/jsonata-transform.ts +36 -0
- package/src/keybinding-management-settings.tsx +16 -0
- package/src/keybinding-overrides-storage.ts +57 -0
- package/src/management-palette-commands.ts +38 -0
- package/src/management-settings-ids.ts +12 -0
- package/src/management-settings.tsx +75 -0
- package/src/preference-settings-storage.ts +58 -0
- package/src/provider.tsx +573 -0
- package/src/search-view-data.ts +15 -0
- package/src/search-view.tsx +62 -0
- package/src/shell-model.tsx +149 -0
- package/src/shell-secondary-actions.tsx +59 -0
- package/src/shell-settings-constants.ts +9 -0
- package/src/shell-settings.tsx +599 -0
- package/src/shell-titlebar-layout-controls.tsx +4 -0
- package/src/shell-view-host.tsx +199 -0
- package/src/shell.tsx +649 -0
- package/src/table-mapping-adapter.ts +59 -0
- package/src/use-active-workspace-path.ts +15 -0
- package/src/use-command-management.ts +191 -0
- package/src/use-context-key-revision.ts +18 -0
- package/src/use-editor.ts +107 -0
- package/src/use-extension-management.ts +193 -0
- package/src/use-keybinding-management.ts +130 -0
- package/src/use-persisted-workbench-appearance.ts +33 -0
- package/src/use-workbench-chat-command-proposals.ts +194 -0
- package/src/use-workbench-command-descriptors.ts +41 -0
- package/src/workbench-appearance-storage.ts +115 -0
- package/src/workbench-command-host.tsx +243 -0
- package/src/workbench-command-palette.ts +208 -0
- package/src/workbench-keybinding-bridge.ts +54 -0
- package/src/workbench-layout-storage.ts +145 -0
- package/src/workbench-profile-modal.tsx +118 -0
- package/src/workbench-shell-command-registration.ts +58 -0
- package/src/workbench-startup-gate.tsx +136 -0
- package/src/workbench-status-sections.ts +43 -0
- package/src/workbench-user-commands.ts +46 -0
- package/src/workspace-view-state.ts +35 -0
package/src/shell.tsx
ADDED
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useReducer, useState, type ReactNode } from 'react';
|
|
2
|
+
import { Modal } from '@workbench-kit/react/modal';
|
|
3
|
+
import { TilepaperAppIcon } from '@workbench-kit/react';
|
|
4
|
+
import { Badge, Button, IconButton } from '@workbench-kit/react/primitives';
|
|
5
|
+
import {
|
|
6
|
+
WorkbenchSettingsModal,
|
|
7
|
+
type WorkbenchSettingsCategory,
|
|
8
|
+
} from '@workbench-kit/react/workbench/settings';
|
|
9
|
+
import {
|
|
10
|
+
WorkbenchShell as ReactWorkbenchShell,
|
|
11
|
+
type StatusBarItemModel,
|
|
12
|
+
type StatusBarSectionModel,
|
|
13
|
+
} from '@workbench-kit/react/workbench/shell';
|
|
14
|
+
import {
|
|
15
|
+
WORKBENCH_SETTINGS_CAPABILITY_ID,
|
|
16
|
+
filterActivitiesByWhenClause,
|
|
17
|
+
} from '@workbench-kit/workbench-core';
|
|
18
|
+
import type { WorkbenchSettingsCapability } from '@workbench-kit/workbench-core';
|
|
19
|
+
import { WORKBENCH_PERMISSION_CONTEXT_KEY_CAN_OPEN_SETTINGS } from '@workbench-kit/platform';
|
|
20
|
+
import { isPreferenceScope, type PreferenceScope } from '@workbench-kit/workbench-config';
|
|
21
|
+
import {
|
|
22
|
+
resolveActiveThemePreset,
|
|
23
|
+
DEFAULT_SHELL_PRESET,
|
|
24
|
+
useResolvedWorkbenchTheme,
|
|
25
|
+
} from '@workbench-kit/react/workbench';
|
|
26
|
+
|
|
27
|
+
import { EditorArea } from './editor-area.js';
|
|
28
|
+
import { BUILTIN_COMMANDS_VIEW_CONTAINER_ID } from './commands-view-data.js';
|
|
29
|
+
import { BUILTIN_EXTENSIONS_VIEW_CONTAINER_ID } from './extensions-view-data.js';
|
|
30
|
+
import {
|
|
31
|
+
filterActivityBarItems,
|
|
32
|
+
sortActivityBarItems,
|
|
33
|
+
} from '@workbench-kit/react/workbench/activityBarOrder';
|
|
34
|
+
import { useWorkbench } from './provider.js';
|
|
35
|
+
import { WorkbenchCommandHost, type WorkbenchCommandHostProps } from './workbench-command-host.js';
|
|
36
|
+
import {
|
|
37
|
+
MANAGE_ACCOUNTS_COMMAND_ID,
|
|
38
|
+
MANAGE_COMMANDS_COMMAND_ID,
|
|
39
|
+
MANAGE_EXTENSIONS_COMMAND_ID,
|
|
40
|
+
MANAGE_KEYBINDINGS_COMMAND_ID,
|
|
41
|
+
WORKBENCH_ACCOUNTS_SETTINGS_CATEGORY_ID,
|
|
42
|
+
WORKBENCH_COMMANDS_SETTINGS_CATEGORY_ID,
|
|
43
|
+
WORKBENCH_KEYBINDINGS_SETTINGS_CATEGORY_ID,
|
|
44
|
+
} from './management-settings-ids.js';
|
|
45
|
+
import { createWorkbenchManagementPaletteCommands } from './management-palette-commands.js';
|
|
46
|
+
import {
|
|
47
|
+
WorkbenchAccountManagementSettings,
|
|
48
|
+
WorkbenchCommandManagementSettings,
|
|
49
|
+
WorkbenchKeybindingManagementSettings,
|
|
50
|
+
type WorkbenchAccountManagementInput,
|
|
51
|
+
} from './management-settings.js';
|
|
52
|
+
import { mergeWorkbenchCommandDescriptors } from './workbench-command-palette.js';
|
|
53
|
+
import {
|
|
54
|
+
createWorkbenchSecondaryActivityItems,
|
|
55
|
+
getWorkbenchSecondaryActivityRoute,
|
|
56
|
+
} from './shell-secondary-actions.js';
|
|
57
|
+
import { SETTINGS_EXTENSION_ID, WORKBENCH_PREFERENCE_SCOPES } from './shell-settings-constants.js';
|
|
58
|
+
import { createSettingsCategories, type WorkbenchThemeOption } from './shell-settings.js';
|
|
59
|
+
import {
|
|
60
|
+
createDefaultWorkbenchStatusSections,
|
|
61
|
+
createWorkbenchShellActivityItems,
|
|
62
|
+
} from './shell-model.js';
|
|
63
|
+
import { renderDefaultPrimarySidebar } from './shell-view-host.js';
|
|
64
|
+
import { WorkbenchShellTitleBarLayoutControls } from './shell-titlebar-layout-controls.js';
|
|
65
|
+
import { WorkbenchProfileModal, type WorkbenchProfileInput } from './workbench-profile-modal.js';
|
|
66
|
+
import { useContextKeyRevision } from './use-context-key-revision.js';
|
|
67
|
+
export type { WorkbenchLocaleOption, WorkbenchThemeOption } from './shell-settings.js';
|
|
68
|
+
|
|
69
|
+
/** Virtual width used to bridge layout `sizePercent` into pixel SplitView units. */
|
|
70
|
+
const SHELL_REACT_SIDEBAR_LAYOUT_REFERENCE_WIDTH_PX = 1200;
|
|
71
|
+
const SHELL_REACT_PRIMARY_SIDEBAR_MIN_PX = 200;
|
|
72
|
+
const SHELL_REACT_PRIMARY_SIDEBAR_MAX_PX = 480;
|
|
73
|
+
|
|
74
|
+
function clampShellReactPrimarySidebarSizePx(sizePx: number): number {
|
|
75
|
+
if (!Number.isFinite(sizePx)) {
|
|
76
|
+
return SHELL_REACT_PRIMARY_SIDEBAR_MIN_PX;
|
|
77
|
+
}
|
|
78
|
+
return Math.min(
|
|
79
|
+
SHELL_REACT_PRIMARY_SIDEBAR_MAX_PX,
|
|
80
|
+
Math.max(SHELL_REACT_PRIMARY_SIDEBAR_MIN_PX, Math.round(sizePx)),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function shellReactPrimarySidebarSizePxFromPercent(sizePercent: number | undefined): number {
|
|
85
|
+
const percent = Number.isFinite(sizePercent) ? (sizePercent as number) : 20;
|
|
86
|
+
return clampShellReactPrimarySidebarSizePx(
|
|
87
|
+
(percent / 100) * SHELL_REACT_SIDEBAR_LAYOUT_REFERENCE_WIDTH_PX,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface WorkbenchShellProps {
|
|
92
|
+
accountManagement?: WorkbenchAccountManagementInput | undefined;
|
|
93
|
+
additionalSettingsCategories?: readonly WorkbenchSettingsCategory[] | undefined;
|
|
94
|
+
catalogUrl?: string | undefined;
|
|
95
|
+
commandHost?: false | Omit<WorkbenchCommandHostProps, 'onOpenSettings'>;
|
|
96
|
+
compactStatus?: boolean;
|
|
97
|
+
darkPreset?: string | undefined;
|
|
98
|
+
editorArea?: ReactNode;
|
|
99
|
+
helpContent?: ReactNode;
|
|
100
|
+
helpTitle?: ReactNode;
|
|
101
|
+
lightPreset?: string | undefined;
|
|
102
|
+
onDarkPresetChange?: ((preset: string) => void) | undefined;
|
|
103
|
+
onLightPresetChange?: ((preset: string) => void) | undefined;
|
|
104
|
+
onShellPresetChange?: ((preset: string) => void) | undefined;
|
|
105
|
+
onThemeChange?: ((theme: string) => void) | undefined;
|
|
106
|
+
onLocaleChange?: ((locale: string) => void) | undefined;
|
|
107
|
+
locale?: string | undefined;
|
|
108
|
+
onStatusItemActivate?: (item: StatusBarItemModel) => void;
|
|
109
|
+
primarySidebar?: ReactNode;
|
|
110
|
+
profile?: WorkbenchProfileInput | undefined;
|
|
111
|
+
profileExtraContent?: ReactNode;
|
|
112
|
+
rootClassName?: string;
|
|
113
|
+
shellPreset?: string | undefined;
|
|
114
|
+
statusSections?: StatusBarSectionModel[];
|
|
115
|
+
theme?: string;
|
|
116
|
+
themeOptions?: readonly WorkbenchThemeOption[] | undefined;
|
|
117
|
+
title?: ReactNode;
|
|
118
|
+
titleBar?: ReactNode;
|
|
119
|
+
titleBarActions?: ReactNode;
|
|
120
|
+
titleMeta?: ReactNode;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const OPEN_SETTINGS_COMMAND_ID = 'workbench-kit.builtin.settings.open';
|
|
124
|
+
|
|
125
|
+
export function WorkbenchShell({
|
|
126
|
+
accountManagement,
|
|
127
|
+
additionalSettingsCategories,
|
|
128
|
+
catalogUrl = '/extension-catalog.json',
|
|
129
|
+
commandHost,
|
|
130
|
+
compactStatus = true,
|
|
131
|
+
darkPreset,
|
|
132
|
+
editorArea,
|
|
133
|
+
helpContent,
|
|
134
|
+
helpTitle = 'Workbench Help',
|
|
135
|
+
lightPreset,
|
|
136
|
+
locale = 'en',
|
|
137
|
+
onDarkPresetChange,
|
|
138
|
+
onLightPresetChange,
|
|
139
|
+
onLocaleChange,
|
|
140
|
+
onShellPresetChange,
|
|
141
|
+
onThemeChange,
|
|
142
|
+
onStatusItemActivate,
|
|
143
|
+
primarySidebar,
|
|
144
|
+
profile,
|
|
145
|
+
profileExtraContent,
|
|
146
|
+
rootClassName,
|
|
147
|
+
shellPreset = DEFAULT_SHELL_PRESET,
|
|
148
|
+
statusSections,
|
|
149
|
+
theme,
|
|
150
|
+
themeOptions,
|
|
151
|
+
title = 'Workbench',
|
|
152
|
+
titleBar,
|
|
153
|
+
titleBarActions,
|
|
154
|
+
titleMeta,
|
|
155
|
+
}: WorkbenchShellProps) {
|
|
156
|
+
const resolvedEditorArea = editorArea ?? <EditorArea />;
|
|
157
|
+
const resolvedWorkbenchTheme = useResolvedWorkbenchTheme(theme ?? 'system');
|
|
158
|
+
const activeThemePreset =
|
|
159
|
+
lightPreset !== undefined && darkPreset !== undefined
|
|
160
|
+
? resolveActiveThemePreset(resolvedWorkbenchTheme, { darkPreset, lightPreset })
|
|
161
|
+
: undefined;
|
|
162
|
+
const {
|
|
163
|
+
contextKeyService,
|
|
164
|
+
executeCommand,
|
|
165
|
+
extensionRegistry,
|
|
166
|
+
layoutService,
|
|
167
|
+
missingExtensionIds,
|
|
168
|
+
preferenceService,
|
|
169
|
+
} = useWorkbench();
|
|
170
|
+
const contextKeyRevision = useContextKeyRevision(contextKeyService);
|
|
171
|
+
const forceRender = useForceRender();
|
|
172
|
+
const [preferenceRevision, bumpPreferenceRevision] = useReducer((count: number) => count + 1, 0);
|
|
173
|
+
const [isHelpOpen, setHelpOpen] = useState(false);
|
|
174
|
+
const [isProfileOpen, setProfileOpen] = useState(false);
|
|
175
|
+
const [isSettingsOpen, setSettingsOpen] = useState(false);
|
|
176
|
+
const [settingsSearchValue, setSettingsSearchValue] = useState('');
|
|
177
|
+
const [settingsCategoryId, setSettingsCategoryId] = useState<string | undefined>();
|
|
178
|
+
const [settingsScopeId, setSettingsScopeId] = useState<PreferenceScope>('workspace');
|
|
179
|
+
const showSettingsModal = useCallback((categoryId?: string) => {
|
|
180
|
+
setHelpOpen(false);
|
|
181
|
+
setProfileOpen(false);
|
|
182
|
+
setSettingsCategoryId(categoryId);
|
|
183
|
+
setSettingsOpen(true);
|
|
184
|
+
}, []);
|
|
185
|
+
const settingsCapability = useMemo<WorkbenchSettingsCapability>(
|
|
186
|
+
() => ({
|
|
187
|
+
openSettings: showSettingsModal,
|
|
188
|
+
}),
|
|
189
|
+
[showSettingsModal],
|
|
190
|
+
);
|
|
191
|
+
const layout = layoutService.getState();
|
|
192
|
+
const resolvedStatusSections = useMemo(
|
|
193
|
+
() =>
|
|
194
|
+
statusSections ??
|
|
195
|
+
createDefaultWorkbenchStatusSections({
|
|
196
|
+
dependencyDiagnostics: extensionRegistry.getDependencyDiagnostics(),
|
|
197
|
+
extensionCount: extensionRegistry.getExtensions().length,
|
|
198
|
+
missingExtensionIds,
|
|
199
|
+
profile,
|
|
200
|
+
}),
|
|
201
|
+
[extensionRegistry, missingExtensionIds, profile, statusSections],
|
|
202
|
+
);
|
|
203
|
+
const activeViewContainerId = layout.sideBar.activeViewContainer;
|
|
204
|
+
const visibleActivities = useMemo(
|
|
205
|
+
() =>
|
|
206
|
+
filterActivitiesByWhenClause(
|
|
207
|
+
extensionRegistry.activities.getActivities(),
|
|
208
|
+
contextKeyService.createSnapshot(),
|
|
209
|
+
),
|
|
210
|
+
[contextKeyRevision, contextKeyService, extensionRegistry],
|
|
211
|
+
);
|
|
212
|
+
const activityItems = sortActivityBarItems(
|
|
213
|
+
createWorkbenchShellActivityItems({
|
|
214
|
+
activeViewContainerId,
|
|
215
|
+
activities: visibleActivities,
|
|
216
|
+
viewContainers: extensionRegistry.views.getViewContainers(),
|
|
217
|
+
views: extensionRegistry.views.getViews(),
|
|
218
|
+
}),
|
|
219
|
+
layout.activityBar.itemOrder,
|
|
220
|
+
);
|
|
221
|
+
const visibleActivityItems = filterActivityBarItems(
|
|
222
|
+
activityItems,
|
|
223
|
+
layout.activityBar.hiddenItemIds,
|
|
224
|
+
);
|
|
225
|
+
const canOpenSettingsValue = contextKeyService.get(
|
|
226
|
+
WORKBENCH_PERMISSION_CONTEXT_KEY_CAN_OPEN_SETTINGS,
|
|
227
|
+
);
|
|
228
|
+
const secondaryActivityItems = createWorkbenchSecondaryActivityItems({
|
|
229
|
+
hasProfile: profile !== undefined,
|
|
230
|
+
isProfileOpen,
|
|
231
|
+
isSettingsOpen,
|
|
232
|
+
showSettings: canOpenSettingsValue !== false,
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
if (visibleActivityItems.length === 0) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const visibleActivityIds = new Set(visibleActivityItems.map((item) => item.id));
|
|
241
|
+
if (activeViewContainerId !== undefined && !visibleActivityIds.has(activeViewContainerId)) {
|
|
242
|
+
layoutService.setActiveViewContainer(visibleActivityItems[0]?.id);
|
|
243
|
+
}
|
|
244
|
+
}, [activeViewContainerId, layoutService, visibleActivityItems]);
|
|
245
|
+
const settingsCategories = useMemo(() => {
|
|
246
|
+
const managementCategories: WorkbenchSettingsCategory[] = [];
|
|
247
|
+
|
|
248
|
+
if (commandHost !== false) {
|
|
249
|
+
managementCategories.push({
|
|
250
|
+
content: <WorkbenchCommandManagementSettings />,
|
|
251
|
+
id: WORKBENCH_COMMANDS_SETTINGS_CATEGORY_ID,
|
|
252
|
+
label: 'Commands',
|
|
253
|
+
title: 'Command management',
|
|
254
|
+
});
|
|
255
|
+
managementCategories.push({
|
|
256
|
+
content: <WorkbenchKeybindingManagementSettings />,
|
|
257
|
+
id: WORKBENCH_KEYBINDINGS_SETTINGS_CATEGORY_ID,
|
|
258
|
+
label: 'Keyboard Shortcuts',
|
|
259
|
+
title: 'Keyboard shortcut management',
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (accountManagement) {
|
|
264
|
+
managementCategories.push({
|
|
265
|
+
content: <WorkbenchAccountManagementSettings accountManagement={accountManagement} />,
|
|
266
|
+
id: WORKBENCH_ACCOUNTS_SETTINGS_CATEGORY_ID,
|
|
267
|
+
label: 'Linked Accounts',
|
|
268
|
+
title: 'Linked account management',
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return [
|
|
273
|
+
...managementCategories,
|
|
274
|
+
...(additionalSettingsCategories ?? []),
|
|
275
|
+
...createSettingsCategories(extensionRegistry, {
|
|
276
|
+
activeScope: settingsScopeId,
|
|
277
|
+
darkPreset,
|
|
278
|
+
lightPreset,
|
|
279
|
+
locale,
|
|
280
|
+
onDarkPresetChange,
|
|
281
|
+
onLightPresetChange,
|
|
282
|
+
onLocaleChange,
|
|
283
|
+
onShellPresetChange,
|
|
284
|
+
onThemeChange,
|
|
285
|
+
preferenceService,
|
|
286
|
+
shellPreset,
|
|
287
|
+
theme,
|
|
288
|
+
themeOptions,
|
|
289
|
+
}),
|
|
290
|
+
];
|
|
291
|
+
}, [
|
|
292
|
+
accountManagement,
|
|
293
|
+
additionalSettingsCategories,
|
|
294
|
+
commandHost,
|
|
295
|
+
darkPreset,
|
|
296
|
+
extensionRegistry,
|
|
297
|
+
lightPreset,
|
|
298
|
+
locale,
|
|
299
|
+
onDarkPresetChange,
|
|
300
|
+
onLightPresetChange,
|
|
301
|
+
onLocaleChange,
|
|
302
|
+
onShellPresetChange,
|
|
303
|
+
onThemeChange,
|
|
304
|
+
preferenceService,
|
|
305
|
+
preferenceRevision,
|
|
306
|
+
settingsScopeId,
|
|
307
|
+
shellPreset,
|
|
308
|
+
theme,
|
|
309
|
+
themeOptions,
|
|
310
|
+
]);
|
|
311
|
+
const defaultSettingsCategoryId =
|
|
312
|
+
settingsCategories.find((category) => category.id === SETTINGS_EXTENSION_ID)?.id ??
|
|
313
|
+
settingsCategories[0]?.id;
|
|
314
|
+
const settingsContributionCount = extensionRegistry.configurations.getConfigurations().length;
|
|
315
|
+
const showHelpModal = useCallback(() => {
|
|
316
|
+
setSettingsOpen(false);
|
|
317
|
+
setProfileOpen(false);
|
|
318
|
+
setHelpOpen(true);
|
|
319
|
+
}, []);
|
|
320
|
+
const showProfileModal = useCallback(() => {
|
|
321
|
+
setSettingsOpen(false);
|
|
322
|
+
setHelpOpen(false);
|
|
323
|
+
setProfileOpen(true);
|
|
324
|
+
}, []);
|
|
325
|
+
const resolvedTitleBar =
|
|
326
|
+
titleBar === undefined ? (
|
|
327
|
+
<WorkbenchShellTitleBar
|
|
328
|
+
helpContent={helpContent}
|
|
329
|
+
isAuxiliarySidebarVisible={layout.auxiliaryBar.visible}
|
|
330
|
+
isPanelVisible={layout.panel.visible}
|
|
331
|
+
isPrimarySidebarVisible={layout.sideBar.visible}
|
|
332
|
+
title={title}
|
|
333
|
+
titleBarActions={titleBarActions}
|
|
334
|
+
titleMeta={titleMeta}
|
|
335
|
+
onHelpOpen={showHelpModal}
|
|
336
|
+
onToggleAuxiliarySidebar={() => {
|
|
337
|
+
layoutService.setAuxiliaryBarVisible(!layout.auxiliaryBar.visible);
|
|
338
|
+
}}
|
|
339
|
+
onTogglePanel={() => {
|
|
340
|
+
layoutService.setPanelVisible(!layout.panel.visible);
|
|
341
|
+
}}
|
|
342
|
+
onTogglePrimarySidebar={() => {
|
|
343
|
+
layoutService.setSideBarVisible(!layout.sideBar.visible);
|
|
344
|
+
}}
|
|
345
|
+
/>
|
|
346
|
+
) : (
|
|
347
|
+
titleBar
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
useEffect(() => {
|
|
351
|
+
const layoutDisposable = layoutService.onDidChangeLayout(forceRender);
|
|
352
|
+
const viewProviderDisposable = extensionRegistry.views.onDidRegisterViewProvider(forceRender);
|
|
353
|
+
const preferenceDisposable = preferenceService.onDidChangePreference(bumpPreferenceRevision);
|
|
354
|
+
|
|
355
|
+
return () => {
|
|
356
|
+
layoutDisposable.dispose();
|
|
357
|
+
viewProviderDisposable.dispose();
|
|
358
|
+
preferenceDisposable.dispose();
|
|
359
|
+
};
|
|
360
|
+
}, [extensionRegistry, forceRender, layoutService, preferenceService]);
|
|
361
|
+
|
|
362
|
+
useEffect(() => {
|
|
363
|
+
if (!activeViewContainerId) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
for (const view of extensionRegistry.views.getViews(activeViewContainerId)) {
|
|
368
|
+
void extensionRegistry.activateView(view.id).then(forceRender);
|
|
369
|
+
}
|
|
370
|
+
}, [activeViewContainerId, extensionRegistry, forceRender]);
|
|
371
|
+
|
|
372
|
+
useEffect(() => {
|
|
373
|
+
if (extensionRegistry.capabilityRegistry.has(WORKBENCH_SETTINGS_CAPABILITY_ID)) {
|
|
374
|
+
return undefined;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const disposable = extensionRegistry.capabilityRegistry.register({
|
|
378
|
+
id: WORKBENCH_SETTINGS_CAPABILITY_ID,
|
|
379
|
+
get: () => settingsCapability,
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
return () => {
|
|
383
|
+
disposable.dispose();
|
|
384
|
+
};
|
|
385
|
+
}, [extensionRegistry, settingsCapability]);
|
|
386
|
+
|
|
387
|
+
const openSettings = (categoryId?: string) => {
|
|
388
|
+
showSettingsModal(categoryId);
|
|
389
|
+
if (
|
|
390
|
+
categoryId === undefined &&
|
|
391
|
+
extensionRegistry.commands.hasCommand(OPEN_SETTINGS_COMMAND_ID)
|
|
392
|
+
) {
|
|
393
|
+
void executeCommand(OPEN_SETTINGS_COMMAND_ID).catch(() => undefined);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
const resolvedCommandHost = useMemo(():
|
|
398
|
+
false | Omit<WorkbenchCommandHostProps, 'onOpenSettings'> => {
|
|
399
|
+
if (commandHost === false) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const hostProps = commandHost ?? {};
|
|
404
|
+
const additionalCommands = mergeWorkbenchCommandDescriptors(
|
|
405
|
+
[...createWorkbenchManagementPaletteCommands()],
|
|
406
|
+
[...(hostProps.additionalCommands ?? [])],
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
return {
|
|
410
|
+
...hostProps,
|
|
411
|
+
additionalCommands,
|
|
412
|
+
onRunCommand: (command, context) => {
|
|
413
|
+
if (command.id === MANAGE_COMMANDS_COMMAND_ID) {
|
|
414
|
+
layoutService.setActiveViewContainer(BUILTIN_COMMANDS_VIEW_CONTAINER_ID);
|
|
415
|
+
layoutService.setSideBarVisible(true);
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (command.id === MANAGE_KEYBINDINGS_COMMAND_ID) {
|
|
420
|
+
openSettings(WORKBENCH_KEYBINDINGS_SETTINGS_CATEGORY_ID);
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (command.id === MANAGE_EXTENSIONS_COMMAND_ID) {
|
|
425
|
+
layoutService.setActiveViewContainer(BUILTIN_EXTENSIONS_VIEW_CONTAINER_ID);
|
|
426
|
+
layoutService.setSideBarVisible(true);
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
if (command.id === MANAGE_ACCOUNTS_COMMAND_ID) {
|
|
431
|
+
openSettings(WORKBENCH_ACCOUNTS_SETTINGS_CATEGORY_ID);
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return hostProps.onRunCommand?.(command, context) ?? false;
|
|
436
|
+
},
|
|
437
|
+
};
|
|
438
|
+
}, [commandHost, layoutService]);
|
|
439
|
+
|
|
440
|
+
const handleStatusItemActivate = useCallback(
|
|
441
|
+
(item: StatusBarItemModel) => {
|
|
442
|
+
if (item.id === 'workbench.account') {
|
|
443
|
+
if (profile) {
|
|
444
|
+
showProfileModal();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if (accountManagement) {
|
|
449
|
+
openSettings(WORKBENCH_ACCOUNTS_SETTINGS_CATEGORY_ID);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
onStatusItemActivate?.(item);
|
|
457
|
+
},
|
|
458
|
+
[accountManagement, onStatusItemActivate, profile, showProfileModal],
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
return (
|
|
462
|
+
<ReactWorkbenchShell
|
|
463
|
+
activityBar={{
|
|
464
|
+
visible: layout.activityBar.visible,
|
|
465
|
+
items: visibleActivityItems,
|
|
466
|
+
reorderable: true,
|
|
467
|
+
secondaryItems: secondaryActivityItems,
|
|
468
|
+
onItemActivate: (item) => {
|
|
469
|
+
const secondaryActivityRoute = getWorkbenchSecondaryActivityRoute(item.id);
|
|
470
|
+
if (secondaryActivityRoute === 'profile') {
|
|
471
|
+
showProfileModal();
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
if (secondaryActivityRoute === 'settings') {
|
|
476
|
+
openSettings();
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
layoutService.focusSideBarViewContainer(item.id);
|
|
481
|
+
},
|
|
482
|
+
onItemsReorder: (itemIds) => {
|
|
483
|
+
const preservedItemIds =
|
|
484
|
+
layout.activityBar.itemOrder?.filter((itemId) => !itemIds.includes(itemId)) ?? [];
|
|
485
|
+
layoutService.setActivityBarItemOrder([...itemIds, ...preservedItemIds]);
|
|
486
|
+
},
|
|
487
|
+
}}
|
|
488
|
+
compactStatus={compactStatus}
|
|
489
|
+
onStatusItemActivate={handleStatusItemActivate}
|
|
490
|
+
primarySidebar={{
|
|
491
|
+
isVisible: layout.sideBar.visible,
|
|
492
|
+
// Provider layout still stores sideBar.sizePercent; convert at the shell boundary
|
|
493
|
+
// until workbench-core persists pixel widths directly.
|
|
494
|
+
maxPrimarySizePx: SHELL_REACT_PRIMARY_SIDEBAR_MAX_PX,
|
|
495
|
+
minPrimarySizePx: SHELL_REACT_PRIMARY_SIDEBAR_MIN_PX,
|
|
496
|
+
node:
|
|
497
|
+
primarySidebar ??
|
|
498
|
+
renderDefaultPrimarySidebar(extensionRegistry, activeViewContainerId, catalogUrl),
|
|
499
|
+
onSizePxChange: (sizePx) => {
|
|
500
|
+
layoutService.setSideBarSizePercent(
|
|
501
|
+
(clampShellReactPrimarySidebarSizePx(sizePx) /
|
|
502
|
+
SHELL_REACT_SIDEBAR_LAYOUT_REFERENCE_WIDTH_PX) *
|
|
503
|
+
100,
|
|
504
|
+
);
|
|
505
|
+
},
|
|
506
|
+
primarySizePx: shellReactPrimarySidebarSizePxFromPercent(layout.sideBar.sizePercent),
|
|
507
|
+
}}
|
|
508
|
+
auxiliarySidebar={{
|
|
509
|
+
isVisible: layout.auxiliaryBar.visible,
|
|
510
|
+
node: <aside aria-label="Secondary Side Bar" className="workbench-auxiliary-side-bar" />,
|
|
511
|
+
}}
|
|
512
|
+
bottomPanel={{
|
|
513
|
+
isVisible: layout.panel.visible,
|
|
514
|
+
node: <section aria-label="Panel" className="workbench-bottom-panel" />,
|
|
515
|
+
}}
|
|
516
|
+
rootClassName={rootClassName}
|
|
517
|
+
secondaryArea={resolvedEditorArea}
|
|
518
|
+
statusSections={resolvedStatusSections}
|
|
519
|
+
titleBar={resolvedTitleBar}
|
|
520
|
+
theme={resolvedWorkbenchTheme}
|
|
521
|
+
themePreset={activeThemePreset}
|
|
522
|
+
shellPreset={shellPreset}
|
|
523
|
+
overlays={
|
|
524
|
+
<>
|
|
525
|
+
{commandHost !== false ? (
|
|
526
|
+
<WorkbenchCommandHost
|
|
527
|
+
{...(resolvedCommandHost === false ? {} : resolvedCommandHost)}
|
|
528
|
+
onOpenSettings={() => openSettings()}
|
|
529
|
+
/>
|
|
530
|
+
) : null}
|
|
531
|
+
{isSettingsOpen ? (
|
|
532
|
+
<WorkbenchSettingsModal
|
|
533
|
+
activeCategoryId={settingsCategoryId}
|
|
534
|
+
activeScopeId={settingsScopeId}
|
|
535
|
+
categories={settingsCategories}
|
|
536
|
+
defaultActiveCategoryId={defaultSettingsCategoryId}
|
|
537
|
+
defaultActiveScopeId="workspace"
|
|
538
|
+
footer={<Button onClick={() => setSettingsOpen(false)}>Close</Button>}
|
|
539
|
+
scopes={[...WORKBENCH_PREFERENCE_SCOPES]}
|
|
540
|
+
searchValue={settingsSearchValue}
|
|
541
|
+
title="Settings"
|
|
542
|
+
titleSuffix={
|
|
543
|
+
<Badge variant="muted">
|
|
544
|
+
{settingsContributionCount === 1
|
|
545
|
+
? '1 contribution'
|
|
546
|
+
: `${settingsContributionCount} contributions`}
|
|
547
|
+
</Badge>
|
|
548
|
+
}
|
|
549
|
+
onActiveCategoryIdChange={setSettingsCategoryId}
|
|
550
|
+
onClose={() => setSettingsOpen(false)}
|
|
551
|
+
onScopeChange={(scopeId) => {
|
|
552
|
+
if (isPreferenceScope(scopeId)) {
|
|
553
|
+
setSettingsScopeId(scopeId);
|
|
554
|
+
}
|
|
555
|
+
}}
|
|
556
|
+
onSearchValueChange={setSettingsSearchValue}
|
|
557
|
+
/>
|
|
558
|
+
) : null}
|
|
559
|
+
{isProfileOpen && profile ? (
|
|
560
|
+
<WorkbenchProfileModal
|
|
561
|
+
extraContent={profileExtraContent}
|
|
562
|
+
profile={profile}
|
|
563
|
+
onClose={() => setProfileOpen(false)}
|
|
564
|
+
/>
|
|
565
|
+
) : null}
|
|
566
|
+
{isHelpOpen && helpContent ? (
|
|
567
|
+
<Modal
|
|
568
|
+
bodyPadding="lg"
|
|
569
|
+
bodyScroll="auto"
|
|
570
|
+
className="workbench-help-modal"
|
|
571
|
+
closeLabel="Close help"
|
|
572
|
+
footer={<Button onClick={() => setHelpOpen(false)}>Close</Button>}
|
|
573
|
+
title={helpTitle}
|
|
574
|
+
onClose={() => setHelpOpen(false)}
|
|
575
|
+
>
|
|
576
|
+
{helpContent}
|
|
577
|
+
</Modal>
|
|
578
|
+
) : null}
|
|
579
|
+
</>
|
|
580
|
+
}
|
|
581
|
+
/>
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function WorkbenchShellTitleBar({
|
|
586
|
+
helpContent,
|
|
587
|
+
isAuxiliarySidebarVisible,
|
|
588
|
+
isPanelVisible,
|
|
589
|
+
isPrimarySidebarVisible,
|
|
590
|
+
title,
|
|
591
|
+
titleBarActions,
|
|
592
|
+
titleMeta,
|
|
593
|
+
onHelpOpen,
|
|
594
|
+
onToggleAuxiliarySidebar,
|
|
595
|
+
onTogglePanel,
|
|
596
|
+
onTogglePrimarySidebar,
|
|
597
|
+
}: {
|
|
598
|
+
helpContent: ReactNode | undefined;
|
|
599
|
+
isAuxiliarySidebarVisible: boolean;
|
|
600
|
+
isPanelVisible: boolean;
|
|
601
|
+
isPrimarySidebarVisible: boolean;
|
|
602
|
+
title: ReactNode;
|
|
603
|
+
titleBarActions: ReactNode | undefined;
|
|
604
|
+
titleMeta: ReactNode | undefined;
|
|
605
|
+
onHelpOpen: () => void;
|
|
606
|
+
onToggleAuxiliarySidebar: () => void;
|
|
607
|
+
onTogglePanel: () => void;
|
|
608
|
+
onTogglePrimarySidebar: () => void;
|
|
609
|
+
}) {
|
|
610
|
+
return (
|
|
611
|
+
<>
|
|
612
|
+
<div className="workbench-shell-titlebar__identity">
|
|
613
|
+
<span aria-hidden className="workbench-shell-titlebar__app-icon">
|
|
614
|
+
<TilepaperAppIcon compact />
|
|
615
|
+
</span>
|
|
616
|
+
<span className="workbench-shell-titlebar__title">{title}</span>
|
|
617
|
+
{titleMeta ? <span className="workbench-shell-titlebar__meta">{titleMeta}</span> : null}
|
|
618
|
+
</div>
|
|
619
|
+
<div className="workbench-shell-titlebar__actions">
|
|
620
|
+
<WorkbenchShellTitleBarLayoutControls
|
|
621
|
+
isAuxiliarySidebarVisible={isAuxiliarySidebarVisible}
|
|
622
|
+
isPanelVisible={isPanelVisible}
|
|
623
|
+
isPrimarySidebarVisible={isPrimarySidebarVisible}
|
|
624
|
+
onToggleAuxiliarySidebar={onToggleAuxiliarySidebar}
|
|
625
|
+
onTogglePanel={onTogglePanel}
|
|
626
|
+
onTogglePrimarySidebar={onTogglePrimarySidebar}
|
|
627
|
+
/>
|
|
628
|
+
{titleBarActions}
|
|
629
|
+
{helpContent ? (
|
|
630
|
+
<IconButton
|
|
631
|
+
className="workbench-shell-titlebar__action"
|
|
632
|
+
compact
|
|
633
|
+
icon="question"
|
|
634
|
+
label="Help"
|
|
635
|
+
onClick={onHelpOpen}
|
|
636
|
+
/>
|
|
637
|
+
) : null}
|
|
638
|
+
</div>
|
|
639
|
+
</>
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function useForceRender() {
|
|
644
|
+
const [, forceRender] = useReducer((count: number) => count + 1, 0);
|
|
645
|
+
|
|
646
|
+
return useCallback(() => {
|
|
647
|
+
forceRender();
|
|
648
|
+
}, []);
|
|
649
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { MappingEdge } from '@workbench-kit/field-remap';
|
|
2
|
+
import type { FieldItemInput, Mapping } from 'react-table-mapping';
|
|
3
|
+
|
|
4
|
+
/** One column: field name (static string cell). */
|
|
5
|
+
export const FIELD_REMAP_NAME_COLUMNS = [{ title: 'Field', key: 'name' }] as const;
|
|
6
|
+
|
|
7
|
+
export interface FieldRemapLeaf {
|
|
8
|
+
/** Kit field/slot id (may contain dots, e.g. `a.user_name`). */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly label: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* react-table-mapping builds connectors with `querySelector('#connector-…'+id)`.
|
|
15
|
+
* Dots in ids break CSS selectors (`#a.user_name` → id=a + class=user_name).
|
|
16
|
+
* Encode kit ids for the OSS UI and decode when adapting mappings.
|
|
17
|
+
*/
|
|
18
|
+
export function toTableMappingFieldId(kitFieldId: string): string {
|
|
19
|
+
return kitFieldId.split('.').join('__');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function fromTableMappingFieldId(tableFieldId: string): string {
|
|
23
|
+
return tableFieldId.split('__').join('.');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Build react-table-mapping source/target rows from leaf field descriptors. */
|
|
27
|
+
export function toTableMappingFields(leaves: readonly FieldRemapLeaf[]): FieldItemInput[] {
|
|
28
|
+
return leaves.map((leaf) => {
|
|
29
|
+
const id = toTableMappingFieldId(leaf.id);
|
|
30
|
+
return {
|
|
31
|
+
id,
|
|
32
|
+
key: id,
|
|
33
|
+
name: {
|
|
34
|
+
type: 'string' as const,
|
|
35
|
+
columnKey: 'name',
|
|
36
|
+
value: leaf.label,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** OSS Mapping[] → kit MappingEdge[] (identity / pass-through). */
|
|
43
|
+
export function tableMappingsToEdges(mappings: readonly Mapping[]): MappingEdge[] {
|
|
44
|
+
return mappings.map((mapping) => ({
|
|
45
|
+
id: mapping.id,
|
|
46
|
+
sourceFieldId: fromTableMappingFieldId(mapping.source),
|
|
47
|
+
targetSlotId: fromTableMappingFieldId(mapping.target),
|
|
48
|
+
transformIds: ['identity'] as const,
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** kit MappingEdge[] → OSS Mapping[] for controlled mappings. */
|
|
53
|
+
export function edgesToTableMappings(edges: readonly MappingEdge[]): Mapping[] {
|
|
54
|
+
return edges.map((edge) => ({
|
|
55
|
+
id: edge.id,
|
|
56
|
+
source: toTableMappingFieldId(edge.sourceFieldId),
|
|
57
|
+
target: toTableMappingFieldId(edge.targetSlotId),
|
|
58
|
+
}));
|
|
59
|
+
}
|