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

Made Preferences widget rebindable #6397

Conversation

NicholasStenbeck
Copy link
Contributor

Signed-off-by: Nicholas Stenbeck nicholas.stenbeck@ericsson.com

Recreated and features the same changes as the original pull request

What it does

This change makes the Preferences widget rebindable to allow custom Preferences widgets.

How to test

  1. Create new widget with yo thea-extension
  2. Copy browser widget to packages/ in main repo
  3. Change the code to include the following:
In my-widget/package.json
"dependencies": {
  "@theia/core": "^0.10.0",
  "@theia/preferences": "^0.10.0”
}

Versions may differ. Use the versions the rest of your repo uses.

In my-widget-frontend-module.ts
import { PreferencesWidgetFactory } from '@theia/preferences/lib/browser/preference-frontend-module’;

Remove unused imports and style import if it creates issues; it’s not important for this test

export default new ContainerModule((bind, unbind, isbound, rebind) => {
    ...
    rebind(PreferencesWidgetFactory).toDynamicValue(ctx => ({
        id: MyWidget.ID,
        createWidget: () => ctx.container.get<MyWidget>(MyWidget)
    })).inSingletonScope();
}
In my-widget.tsx
import { PreferencesContainer } from ‘@theia/preferences/lib/browser/preferences-tree-widget’;
...
static readonly ID = PreferencesContainer.ID;
// tslint:disable-next-line: no-any
public async activatePreferenceEditor(preferenceScope: any): Promise<void> {
    return new Promise(() => { });
}
In my-widget-contribution.ts
registerCommands(commands: CommandRegistry): void {
    commands.registerCommand(CommonCommands.OPEN_PREFERENCES, {
        execute: () => super.openView({ activate: false, reveal: true })
    });
}
In examples/browser/package.json
"dependencies": {
  ...
  "hello-world-widget": "^0.0.0"
}
  1. Run yarn in project rootc
  2. Run yarn start in examples/browser/
  3. The preferences widget should now be replaced when you open it

Review checklist

Reminder for reviewers

Signed-off-by: Nicholas Stenbeck <nicholas.stenbeck@ericsson.com>
@akosyakov akosyakov added the preferences issues related to preferences label Oct 16, 2019
@marcdumais-work
Copy link
Contributor

Note: this is a resubmission of #6244, that was approved by @svenefftinge. The code is the same, but this time Nicholas used an Ericsson email address.

@akosyakov
Copy link
Member

@marcdumais-work I think you can approve and merge it :) the change looks harmless

Copy link
Contributor

@marcdumais-work marcdumais-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @NicholasStenbeck

@marcdumais-work marcdumais-work merged commit aebea67 into eclipse-theia:master Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preferences issues related to preferences
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants