@opensumi/ide-preferences 2.27.3-rc-1708395495.0 → 2.27.3-rc-1710386185.0
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/lib/browser/abstract-resource-preference-provider.d.ts +1 -2
- package/lib/browser/abstract-resource-preference-provider.d.ts.map +1 -1
- package/lib/browser/abstract-resource-preference-provider.js +6 -7
- package/lib/browser/abstract-resource-preference-provider.js.map +1 -1
- package/lib/browser/folder-file-preference-provider.d.ts +1 -1
- package/lib/browser/folder-file-preference-provider.d.ts.map +1 -1
- package/lib/browser/folders-preferences-provider.d.ts +1 -1
- package/lib/browser/folders-preferences-provider.d.ts.map +1 -1
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/preference-contribution.d.ts +3 -3
- package/lib/browser/preference-contribution.d.ts.map +1 -1
- package/lib/browser/preference-settings.service.d.ts +19 -6
- package/lib/browser/preference-settings.service.d.ts.map +1 -1
- package/lib/browser/preference-settings.service.js +55 -83
- package/lib/browser/preference-settings.service.js.map +1 -1
- package/lib/browser/preferenceItem.view.d.ts +1 -1
- package/lib/browser/preferenceItem.view.d.ts.map +1 -1
- package/lib/browser/preferences.view.d.ts +0 -3
- package/lib/browser/preferences.view.d.ts.map +1 -1
- package/lib/browser/preferences.view.js +133 -149
- package/lib/browser/preferences.view.js.map +1 -1
- package/lib/browser/userstorage/user-storage.contribution.d.ts.map +1 -1
- package/lib/browser/userstorage/user-storage.service.d.ts +2 -3
- package/lib/browser/userstorage/user-storage.service.d.ts.map +1 -1
- package/lib/browser/userstorage/user-storage.service.js.map +1 -1
- package/lib/browser/workspace-preference-provider.d.ts +1 -1
- package/lib/browser/workspace-preference-provider.d.ts.map +1 -1
- package/lib/common/types.d.ts +6 -5
- package/lib/common/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/browser/abstract-resource-preference-provider.ts +12 -14
- package/src/browser/folder-file-preference-provider.ts +1 -1
- package/src/browser/folders-preferences-provider.ts +3 -3
- package/src/browser/index.ts +5 -5
- package/src/browser/preference-contribution.ts +20 -20
- package/src/browser/preference-settings.service.ts +93 -55
- package/src/browser/preference-widgets.ts +1 -1
- package/src/browser/preferenceItem.view.tsx +8 -8
- package/src/browser/preferences.view.tsx +185 -175
- package/src/browser/userstorage/user-storage.contribution.ts +1 -1
- package/src/browser/userstorage/user-storage.service.ts +6 -7
- package/src/browser/workspace-preference-provider.ts +3 -3
- package/src/common/types.ts +8 -6
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import debounce from 'lodash/debounce';
|
|
2
|
-
import {
|
|
3
|
-
import { observer } from 'mobx-react-lite';
|
|
4
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
3
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
6
4
|
|
|
7
5
|
import {
|
|
8
|
-
Input,
|
|
9
|
-
ComponentContextProvider,
|
|
10
|
-
Tabs,
|
|
11
|
-
IIconResourceOptions,
|
|
12
6
|
BasicRecycleTree,
|
|
7
|
+
ComponentContextProvider,
|
|
13
8
|
IBasicTreeData,
|
|
9
|
+
IIconResourceOptions,
|
|
10
|
+
Input,
|
|
11
|
+
Tabs,
|
|
14
12
|
} from '@opensumi/ide-components';
|
|
15
13
|
import { VirtualList } from '@opensumi/ide-components/lib/virtual-list';
|
|
16
14
|
import { IVirtualListRange } from '@opensumi/ide-components/lib/virtual-list/types';
|
|
17
15
|
import {
|
|
18
|
-
|
|
19
|
-
localize,
|
|
20
|
-
formatLocalize,
|
|
21
|
-
ISettingGroup,
|
|
16
|
+
Disposable,
|
|
22
17
|
IPreferenceSettingsService,
|
|
18
|
+
IResolvedSettingSection,
|
|
19
|
+
ISettingGroup,
|
|
23
20
|
ISettingSection,
|
|
24
|
-
getIcon,
|
|
25
|
-
URI,
|
|
26
21
|
LabelService,
|
|
27
|
-
|
|
22
|
+
URI,
|
|
23
|
+
formatLocalize,
|
|
24
|
+
getIcon,
|
|
25
|
+
localize,
|
|
26
|
+
useEventDrivenState,
|
|
27
|
+
useInjectable,
|
|
28
28
|
} from '@opensumi/ide-core-browser';
|
|
29
29
|
import { EDirection } from '@opensumi/ide-core-browser/lib/components/index';
|
|
30
30
|
import { SplitPanel } from '@opensumi/ide-core-browser/lib/components/layout/split-panel';
|
|
@@ -46,24 +46,135 @@ interface IPreferenceTreeData extends IBasicTreeData {
|
|
|
46
46
|
const TREE_NAME = 'preferenceViewIndexTree';
|
|
47
47
|
const kBaseIndent = 8;
|
|
48
48
|
|
|
49
|
-
const
|
|
49
|
+
export const PreferenceView: ReactEditorComponent<null> = () => {
|
|
50
50
|
const preferenceService: PreferenceSettingsService = useInjectable(IPreferenceSettingsService);
|
|
51
|
-
const [
|
|
51
|
+
const [items, setItems] = useState<ISectionItemData[]>([]);
|
|
52
|
+
const [treeData, setTreeData] = useState<IPreferenceTreeData[]>([]);
|
|
52
53
|
|
|
53
54
|
const updateGroup = useThrottleFn(() => {
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
const currentScope = preferenceService.currentScope;
|
|
56
|
+
const currentSearch = preferenceService.currentSearch;
|
|
57
|
+
const newGroups = preferenceService.getSettingGroups(currentScope, currentSearch);
|
|
58
|
+
|
|
59
|
+
// 如果是搜索模式,是只展示用户左侧选择的组的内容
|
|
60
|
+
const items: ISectionItemData[] = [];
|
|
61
|
+
const treeData: IPreferenceTreeData[] = [];
|
|
62
|
+
|
|
63
|
+
for (let index = 0; index < newGroups.length; index++) {
|
|
64
|
+
const g = newGroups[index];
|
|
65
|
+
const sections = preferenceService.getResolvedSections(g.id, currentScope, currentSearch);
|
|
66
|
+
|
|
67
|
+
items.push(...collectGroup(g, sections));
|
|
68
|
+
treeData.push(collectTreeData(index, g, sections));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
setItems(items);
|
|
72
|
+
setTreeData(treeData);
|
|
73
|
+
|
|
74
|
+
function collectGroup(group: ISettingGroup, sections: IResolvedSettingSection[]) {
|
|
75
|
+
const groupItems = [] as ISectionItemData[];
|
|
76
|
+
|
|
77
|
+
const collectItem = (section: IResolvedSettingSection, prefix = '') => {
|
|
78
|
+
let currentItemPath = prefix;
|
|
79
|
+
if (section.title) {
|
|
80
|
+
currentItemPath = prefix + '/' + section.title;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const innerItems = [] as ISectionItemData[];
|
|
84
|
+
|
|
85
|
+
if (section.component) {
|
|
86
|
+
innerItems.push({
|
|
87
|
+
component: section.component,
|
|
88
|
+
scope: currentScope,
|
|
89
|
+
});
|
|
90
|
+
} else if (section.preferences) {
|
|
91
|
+
innerItems.push(
|
|
92
|
+
...section.preferences.map((pre) => ({
|
|
93
|
+
id: ESectionItemKind.Preference + pre.id,
|
|
94
|
+
preference: pre,
|
|
95
|
+
scope: currentScope,
|
|
96
|
+
_path: currentItemPath,
|
|
97
|
+
})),
|
|
98
|
+
);
|
|
99
|
+
} else if (section.subSections) {
|
|
100
|
+
section.subSections.forEach((v) => {
|
|
101
|
+
const _items = collectItem(v, currentItemPath);
|
|
102
|
+
innerItems.push(..._items);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 如果该 section 有选项,填入一个 title
|
|
107
|
+
if (innerItems.length > 0 && section.title) {
|
|
108
|
+
innerItems.unshift({
|
|
109
|
+
id: ESectionItemKind.Section + section.title,
|
|
110
|
+
title: section.title,
|
|
111
|
+
scope: currentScope,
|
|
112
|
+
_path: currentItemPath,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return innerItems;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
for (const section of sections) {
|
|
120
|
+
const _items = collectItem(section, group.title);
|
|
121
|
+
groupItems.push(..._items);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 如果该 group 有选项,填入一个 title
|
|
125
|
+
if (groupItems.length > 0 && group.title) {
|
|
126
|
+
groupItems.unshift({
|
|
127
|
+
title: group.title,
|
|
128
|
+
id: ESectionItemKind.Group + group.id,
|
|
129
|
+
scope: currentScope,
|
|
130
|
+
_path: group.title,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return groupItems;
|
|
134
|
+
}
|
|
135
|
+
function collectTreeData(index: number, group: ISettingGroup, sections: IResolvedSettingSection[]) {
|
|
136
|
+
const { id, title, iconClass } = group;
|
|
137
|
+
const data = {
|
|
138
|
+
label: toNormalCase(title),
|
|
139
|
+
iconClassName: iconClass,
|
|
140
|
+
groupId: id,
|
|
141
|
+
order: index,
|
|
142
|
+
className: styles.group_item,
|
|
143
|
+
} as IPreferenceTreeData;
|
|
144
|
+
const children = [] as IPreferenceTreeData[];
|
|
145
|
+
sections.forEach((sec, i) => {
|
|
146
|
+
const _treeData = parseTreeData(id, sec, i, 1);
|
|
147
|
+
if (_treeData) {
|
|
148
|
+
children.push(_treeData);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
// 要传这个,让 BasicTree 认为这是文件夹以保持排列顺序
|
|
152
|
+
data.children = children;
|
|
153
|
+
if (children.length > 0) {
|
|
154
|
+
data.expandable = true;
|
|
155
|
+
} else {
|
|
156
|
+
data.expandable = false;
|
|
157
|
+
}
|
|
158
|
+
return data;
|
|
60
159
|
}
|
|
61
160
|
}, 16);
|
|
62
161
|
|
|
63
162
|
useEffect(() => {
|
|
64
|
-
const dispose =
|
|
65
|
-
|
|
66
|
-
|
|
163
|
+
const dispose = new Disposable(
|
|
164
|
+
preferenceService.emitter.on('settingsGroupsChange', () => {
|
|
165
|
+
updateGroup.run();
|
|
166
|
+
}),
|
|
167
|
+
preferenceService.emitter.on('currentSearchChange', () => {
|
|
168
|
+
updateGroup.run();
|
|
169
|
+
}),
|
|
170
|
+
preferenceService.emitter.on('currentScopeChange', () => {
|
|
171
|
+
updateGroup.run();
|
|
172
|
+
}),
|
|
173
|
+
preferenceService.emitter.on('settingsSectionsChange', () => {
|
|
174
|
+
updateGroup.run();
|
|
175
|
+
}),
|
|
176
|
+
);
|
|
177
|
+
|
|
67
178
|
updateGroup.run();
|
|
68
179
|
|
|
69
180
|
return () => {
|
|
@@ -71,29 +182,13 @@ const usePreferenceGroups = () => {
|
|
|
71
182
|
};
|
|
72
183
|
}, []);
|
|
73
184
|
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
updateGroup.run();
|
|
76
|
-
}, [
|
|
77
|
-
preferenceService.settingsGroups.length,
|
|
78
|
-
preferenceService.getSettingGroups,
|
|
79
|
-
preferenceService.currentScope,
|
|
80
|
-
preferenceService.currentSearch,
|
|
81
|
-
preferenceService.settingsSections,
|
|
82
|
-
]);
|
|
83
|
-
|
|
84
|
-
return groups;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const PreferenceView: ReactEditorComponent<null> = observer(() => {
|
|
88
|
-
const preferenceService: PreferenceSettingsService = useInjectable(IPreferenceSettingsService);
|
|
89
|
-
const groups = usePreferenceGroups();
|
|
90
185
|
const labelService = useInjectable<LabelService>(LabelService);
|
|
91
|
-
const getResourceIcon =
|
|
186
|
+
const getResourceIcon = useCallback(
|
|
92
187
|
(uri: string, options: IIconResourceOptions) => labelService.getIcon(URI.parse(uri), options),
|
|
93
188
|
[],
|
|
94
189
|
);
|
|
95
190
|
|
|
96
|
-
const inputRef =
|
|
191
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
97
192
|
|
|
98
193
|
const debouncedSearch = debounce(
|
|
99
194
|
(value: string) => {
|
|
@@ -103,7 +198,7 @@ export const PreferenceView: ReactEditorComponent<null> = observer(() => {
|
|
|
103
198
|
{ maxWait: 300 },
|
|
104
199
|
);
|
|
105
200
|
|
|
106
|
-
|
|
201
|
+
useEffect(() => {
|
|
107
202
|
const focusDispose = preferenceService.onFocus(() => {
|
|
108
203
|
if (inputRef && inputRef.current) {
|
|
109
204
|
inputRef.current.focus();
|
|
@@ -115,22 +210,31 @@ export const PreferenceView: ReactEditorComponent<null> = observer(() => {
|
|
|
115
210
|
};
|
|
116
211
|
}, []);
|
|
117
212
|
|
|
213
|
+
const currentSearch = useEventDrivenState(
|
|
214
|
+
preferenceService.emitter,
|
|
215
|
+
'currentSearchChange',
|
|
216
|
+
() => preferenceService.currentSearch,
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
const tabList = useEventDrivenState(preferenceService.emitter, 'tabListChange', () => preferenceService.tabList);
|
|
220
|
+
const tabIndex = useEventDrivenState(preferenceService.emitter, 'tabIndexChange', () => preferenceService.tabIndex);
|
|
221
|
+
|
|
118
222
|
return (
|
|
119
223
|
<ComponentContextProvider value={{ getIcon, localize, getResourceIcon }}>
|
|
120
224
|
<div className={styles.preferences}>
|
|
121
225
|
<div className={styles.preferences_header}>
|
|
122
226
|
<Tabs
|
|
123
227
|
className={styles.tabs}
|
|
124
|
-
value={
|
|
228
|
+
value={tabIndex}
|
|
125
229
|
onChange={(index: number) => {
|
|
126
|
-
preferenceService.
|
|
230
|
+
preferenceService.updateTabIndex(index);
|
|
127
231
|
}}
|
|
128
|
-
tabs={
|
|
232
|
+
tabs={tabList.map((n) => localize(n.label))}
|
|
129
233
|
/>
|
|
130
234
|
<div className={styles.search_pref}>
|
|
131
235
|
<Input
|
|
132
236
|
autoFocus
|
|
133
|
-
value={
|
|
237
|
+
value={currentSearch}
|
|
134
238
|
placeholder={localize('preference.searchPlaceholder')}
|
|
135
239
|
onValueChange={debouncedSearch}
|
|
136
240
|
ref={inputRef}
|
|
@@ -138,27 +242,25 @@ export const PreferenceView: ReactEditorComponent<null> = observer(() => {
|
|
|
138
242
|
/>
|
|
139
243
|
</div>
|
|
140
244
|
</div>
|
|
141
|
-
{
|
|
245
|
+
{items.length > 0 ? (
|
|
142
246
|
<SplitPanel
|
|
143
247
|
id='preference-panel'
|
|
144
248
|
resizeHandleClassName={styles.devider}
|
|
145
249
|
className={styles.preferences_body}
|
|
146
250
|
direction={EDirection.LeftToRight}
|
|
147
251
|
>
|
|
148
|
-
<PreferenceIndexes data-sp-defaultSize={180} data-sp-minSize={150} />
|
|
149
|
-
<PreferenceBody data-sp-flex={1} />
|
|
252
|
+
<PreferenceIndexes treeData={treeData} data-sp-defaultSize={180} data-sp-minSize={150} />
|
|
253
|
+
<PreferenceBody tabIndex={tabIndex} items={items} data-sp-flex={1} />
|
|
150
254
|
</SplitPanel>
|
|
151
255
|
) : (
|
|
152
256
|
<div className={styles.preference_noResults}>
|
|
153
|
-
{
|
|
154
|
-
? formatLocalize('preference.noResults', preferenceService.currentSearch)
|
|
155
|
-
: formatLocalize('preference.empty')}
|
|
257
|
+
{currentSearch ? formatLocalize('preference.noResults', currentSearch) : formatLocalize('preference.empty')}
|
|
156
258
|
</div>
|
|
157
259
|
)}
|
|
158
260
|
</div>
|
|
159
261
|
</ComponentContextProvider>
|
|
160
262
|
);
|
|
161
|
-
}
|
|
263
|
+
};
|
|
162
264
|
|
|
163
265
|
export const PreferenceItem = ({ data, index }: { data: ISectionItemData; index: number }) => {
|
|
164
266
|
if (data.title) {
|
|
@@ -215,45 +317,13 @@ const parseTreeData = (id: string, section: ISettingSection, order: number, dept
|
|
|
215
317
|
return innerTreeData;
|
|
216
318
|
};
|
|
217
319
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const treeData = React.useMemo(() => {
|
|
223
|
-
if (!groups || groups.length === 0) {
|
|
224
|
-
return [];
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const basicTreeData = [] as IPreferenceTreeData[];
|
|
228
|
-
for (let index = 0; index < groups.length; index++) {
|
|
229
|
-
const { id, title, iconClass } = groups[index];
|
|
230
|
-
const data = {
|
|
231
|
-
label: toNormalCase(title),
|
|
232
|
-
iconClassName: iconClass,
|
|
233
|
-
groupId: id,
|
|
234
|
-
order: index,
|
|
235
|
-
className: styles.group_item,
|
|
236
|
-
} as IPreferenceTreeData;
|
|
237
|
-
const children = [] as IPreferenceTreeData[];
|
|
238
|
-
const sections = preferenceService.getResolvedSections(id);
|
|
239
|
-
sections.forEach((sec, i) => {
|
|
240
|
-
const _treeData = parseTreeData(id, sec, i, 1);
|
|
241
|
-
if (_treeData) {
|
|
242
|
-
children.push(_treeData);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
// 要传这个,让 BasicTree 认为这是文件夹以保持排列顺序
|
|
246
|
-
data.children = children;
|
|
247
|
-
if (children.length > 0) {
|
|
248
|
-
data.expandable = true;
|
|
249
|
-
} else {
|
|
250
|
-
data.expandable = false;
|
|
251
|
-
}
|
|
252
|
-
basicTreeData.push(data);
|
|
253
|
-
}
|
|
320
|
+
interface PreferenceIndexesProps {
|
|
321
|
+
treeData: IPreferenceTreeData[];
|
|
322
|
+
}
|
|
254
323
|
|
|
255
|
-
|
|
256
|
-
|
|
324
|
+
const PreferenceIndexes = (props: PreferenceIndexesProps) => {
|
|
325
|
+
const preferenceService: PreferenceSettingsService = useInjectable(IPreferenceSettingsService);
|
|
326
|
+
const { treeData } = props;
|
|
257
327
|
|
|
258
328
|
return (
|
|
259
329
|
<AutoSizer className={styles.preferences_indexes}>
|
|
@@ -289,90 +359,24 @@ const PreferenceIndexes = observer(() => {
|
|
|
289
359
|
)}
|
|
290
360
|
</AutoSizer>
|
|
291
361
|
);
|
|
292
|
-
}
|
|
362
|
+
};
|
|
293
363
|
|
|
294
|
-
|
|
364
|
+
interface PreferenceBodyProps {
|
|
365
|
+
tabIndex: number;
|
|
366
|
+
items: ISectionItemData[];
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const PreferenceBody = (props: PreferenceBodyProps) => {
|
|
295
370
|
const preferenceService: PreferenceSettingsService = useInjectable(IPreferenceSettingsService);
|
|
296
|
-
const groups = usePreferenceGroups();
|
|
297
371
|
const [focusItem, setFocusItem] = useState<string | undefined>(undefined);
|
|
298
372
|
|
|
299
|
-
|
|
373
|
+
const { items } = props;
|
|
374
|
+
|
|
375
|
+
useEffect(() => {
|
|
300
376
|
if (focusItem && preferenceService.treeHandler?.focusItem) {
|
|
301
377
|
preferenceService.treeHandler.focusItem(focusItem);
|
|
302
378
|
}
|
|
303
|
-
}, [
|
|
304
|
-
|
|
305
|
-
const items = React.useMemo(() => {
|
|
306
|
-
// 如果是搜索模式,是只展示用户左侧选择的组的内容
|
|
307
|
-
const result: ISectionItemData[] = [];
|
|
308
|
-
groups.forEach((v) => {
|
|
309
|
-
result.push(...collectGroup(v));
|
|
310
|
-
});
|
|
311
|
-
return result;
|
|
312
|
-
|
|
313
|
-
function collectGroup(group: ISettingGroup) {
|
|
314
|
-
const groupItems = [] as ISectionItemData[];
|
|
315
|
-
const sections = preferenceService.getResolvedSections(group.id);
|
|
316
|
-
|
|
317
|
-
const collectItem = (section: IResolvedSettingSection, prefix = '') => {
|
|
318
|
-
let currentItemPath = prefix;
|
|
319
|
-
if (section.title) {
|
|
320
|
-
currentItemPath = prefix + '/' + section.title;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const innerItems = [] as ISectionItemData[];
|
|
324
|
-
|
|
325
|
-
if (section.component) {
|
|
326
|
-
innerItems.push({
|
|
327
|
-
component: section.component,
|
|
328
|
-
scope: preferenceService.currentScope,
|
|
329
|
-
});
|
|
330
|
-
} else if (section.preferences) {
|
|
331
|
-
innerItems.push(
|
|
332
|
-
...section.preferences.map((pre) => ({
|
|
333
|
-
id: ESectionItemKind.Preference + pre.id,
|
|
334
|
-
preference: pre,
|
|
335
|
-
scope: preferenceService.currentScope,
|
|
336
|
-
_path: currentItemPath,
|
|
337
|
-
})),
|
|
338
|
-
);
|
|
339
|
-
} else if (section.subSections) {
|
|
340
|
-
section.subSections.forEach((v) => {
|
|
341
|
-
const _items = collectItem(v, currentItemPath);
|
|
342
|
-
innerItems.push(..._items);
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// 如果该 section 有选项,填入一个 title
|
|
347
|
-
if (innerItems.length > 0 && section.title) {
|
|
348
|
-
innerItems.unshift({
|
|
349
|
-
id: ESectionItemKind.Section + section.title,
|
|
350
|
-
title: section.title,
|
|
351
|
-
scope: preferenceService.currentScope,
|
|
352
|
-
_path: currentItemPath,
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
return innerItems;
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
for (const section of sections) {
|
|
360
|
-
const _items = collectItem(section, group.title);
|
|
361
|
-
groupItems.push(..._items);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// 如果该 group 有选项,填入一个 title
|
|
365
|
-
if (groupItems.length > 0 && group.title) {
|
|
366
|
-
groupItems.unshift({
|
|
367
|
-
title: group.title,
|
|
368
|
-
id: ESectionItemKind.Group + group.id,
|
|
369
|
-
scope: preferenceService.currentScope,
|
|
370
|
-
_path: group.title,
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
return groupItems;
|
|
374
|
-
}
|
|
375
|
-
}, [groups, preferenceService.getResolvedSections, preferenceService.currentScope, preferenceService.currentSearch]);
|
|
379
|
+
}, [props.tabIndex, preferenceService.treeHandler, focusItem]);
|
|
376
380
|
|
|
377
381
|
const navigateTo = (id: string) => {
|
|
378
382
|
if (id) {
|
|
@@ -405,11 +409,17 @@ export const PreferenceBody = observer(() => {
|
|
|
405
409
|
},
|
|
406
410
|
);
|
|
407
411
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
412
|
+
const currentSelectId = useEventDrivenState(
|
|
413
|
+
preferenceService.emitter,
|
|
414
|
+
'currentSelectIdChange',
|
|
415
|
+
() => preferenceService.currentSelectId,
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
useEffect(() => {
|
|
419
|
+
if (currentSelectId) {
|
|
420
|
+
navigateTo(currentSelectId);
|
|
411
421
|
}
|
|
412
|
-
}, [items,
|
|
422
|
+
}, [items, currentSelectId]);
|
|
413
423
|
|
|
414
424
|
return (
|
|
415
425
|
<div className={styles.preferences_items}>
|
|
@@ -422,4 +432,4 @@ export const PreferenceBody = observer(() => {
|
|
|
422
432
|
/>
|
|
423
433
|
</div>
|
|
424
434
|
);
|
|
425
|
-
}
|
|
435
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Autowired } from '@opensumi/di';
|
|
2
|
-
import {
|
|
2
|
+
import { ClientAppContribution, Domain, Schemes } from '@opensumi/ide-core-browser';
|
|
3
3
|
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
4
4
|
import { FileServiceClient } from '@opensumi/ide-file-service/lib/browser/file-service-client';
|
|
5
5
|
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import merge from 'lodash/merge';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
4
4
|
import {
|
|
5
|
+
AppConfig,
|
|
5
6
|
DisposableCollection,
|
|
6
|
-
ILogger,
|
|
7
7
|
Emitter,
|
|
8
|
+
FileChangeEvent,
|
|
9
|
+
FileType,
|
|
10
|
+
ILogger,
|
|
8
11
|
URI,
|
|
9
|
-
AppConfig,
|
|
10
12
|
Uri,
|
|
11
|
-
FileType,
|
|
12
|
-
FileChangeEvent,
|
|
13
13
|
} from '@opensumi/ide-core-browser';
|
|
14
14
|
import { Event, FileSystemProviderCapabilities, Schemes } from '@opensumi/ide-core-common';
|
|
15
|
-
import { FileSetContentOptions } from '@opensumi/ide-file-service/lib/common';
|
|
16
|
-
import { IFileServiceClient } from '@opensumi/ide-file-service/lib/common';
|
|
15
|
+
import { FileSetContentOptions, IFileServiceClient } from '@opensumi/ide-file-service/lib/common';
|
|
17
16
|
|
|
18
17
|
import { IUserStorageService } from '../../common';
|
|
19
18
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
+
import { DisposableCollection, URI } from '@opensumi/ide-core-browser';
|
|
3
|
+
import { PreferenceProvider, PreferenceScope } from '@opensumi/ide-core-browser/lib/preferences';
|
|
4
4
|
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
5
5
|
|
|
6
6
|
import { WorkspaceFilePreferenceProviderFactory } from './workspace-file-preference-provider';
|
package/src/common/types.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
+
IDisposable,
|
|
3
|
+
IResolvedPreferenceViewDesc,
|
|
2
4
|
ISettingGroup,
|
|
3
5
|
ISettingSection,
|
|
4
|
-
IDisposable,
|
|
5
6
|
PreferenceScope,
|
|
6
|
-
IResolvedPreferenceViewDesc,
|
|
7
7
|
} from '@opensumi/ide-core-browser';
|
|
8
8
|
|
|
9
9
|
export const SettingContribution = Symbol('SettingContribution');
|
|
10
10
|
|
|
11
|
+
export interface ISettingRegistry {
|
|
12
|
+
registerSettingGroup: (settingGroup: ISettingGroup) => IDisposable;
|
|
13
|
+
registerSettingSection: (key: string, section: ISettingSection) => IDisposable;
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
export interface SettingContribution {
|
|
12
17
|
/**
|
|
13
18
|
* 注册 Setting
|
|
14
19
|
* @param registry
|
|
15
20
|
*/
|
|
16
|
-
registerSetting?(registry:
|
|
17
|
-
registerSettingGroup: (settingGroup: ISettingGroup) => IDisposable;
|
|
18
|
-
registerSettingSection: (key: string, section: ISettingSection) => IDisposable;
|
|
19
|
-
}): void;
|
|
21
|
+
registerSetting?(registry: ISettingRegistry): void;
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* 最后处理一次 SettingGroup
|