Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prefix to contributed view container ids #13362

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- [component] add here -->

## v1.46.0 - 01/25/2024

- [plugin] Add prefix to contributed view container ids [#13362](https://github.com/eclipse-theia/theia/pull/13362) - contributed on behalf of STMicroelectronics
- [application-manager] updated message for missing Electron main entries [#13242](https://github.com/eclipse-theia/theia/pull/13242)
- [application-package] bumped the default supported API from `1.84.2` to `1.85.1` [#13276](https://github.com/eclipse-theia/theia/pull/13276) - contributed on behalf of STMicroelectronics
- [browser-only] added support for 'browser-only' Theia [#12853](https://github.com/eclipse-theia/theia/pull/12853)
Expand Down
21 changes: 18 additions & 3 deletions packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ export class PluginViewRegistry implements FrontendApplicationContribution {

private readonly webviewViewRevivals = new Map<string, { readonly webview: WebviewView; readonly revival: Deferred<void> }>();

private nextViewContainerId = 0;

private static readonly BUILTIN_VIEW_CONTAINERS = new Set<string>([
'explorer',
'scm',
'search',
'test',
'debug'
]);

private static readonly ID_MAPPINGS: Map<string, string> = new Map([
// VS Code Viewlets
[EXPLORER_VIEW_CONTAINER_ID, 'workbench.view.explorer'],
Expand Down Expand Up @@ -266,14 +276,15 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
}

registerViewContainer(location: string, viewContainer: ViewContainer): Disposable {
if (this.viewContainers.has(viewContainer.id)) {
const containerId = `workbench.view.extension.${viewContainer.id}`;
if (this.viewContainers.has(containerId)) {
console.warn('view container such id already registered: ', JSON.stringify(viewContainer));
return Disposable.NULL;
}
const toDispose = new DisposableCollection();
const containerClass = 'theia-plugin-view-container';
let themeIconClass = '';
const iconClass = 'plugin-view-container-icon-' + viewContainer.id;
const iconClass = 'plugin-view-container-icon-' + this.nextViewContainerId++; // having dots in class would not work for css, so we need to generate an id.

if (viewContainer.themeIcon) {
const icon = ThemeIcon.fromString(viewContainer.themeIcon);
Expand All @@ -290,7 +301,7 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
`));
}

toDispose.push(this.doRegisterViewContainer(viewContainer.id, location, {
toDispose.push(this.doRegisterViewContainer(containerId, location, {
label: viewContainer.title,
// The container class automatically sets a mask; if we're using a theme icon, we don't want one.
iconClass: (themeIconClass || containerClass) + ' ' + iconClass,
Expand Down Expand Up @@ -349,6 +360,10 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
}

registerView(viewContainerId: string, view: View): Disposable {
if (!PluginViewRegistry.BUILTIN_VIEW_CONTAINERS.has(viewContainerId)) {
// if it's not a built-in view container, it must be a contributed view container, see https://github.com/eclipse-theia/theia/issues/13249
viewContainerId = `workbench.view.extension.${viewContainerId}`;
}
if (this.views.has(view.id)) {
console.warn('view with such id already registered: ', JSON.stringify(view));
return Disposable.NULL;
Expand Down
Loading