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

Support Webview Views #10137

Closed
wants to merge 9 commits into from

Conversation

ChayaLau
Copy link
Contributor

@ChayaLau ChayaLau commented Sep 19, 2021

Added API to support Webview based views contributions

Signed-off-by: ChayaLau [email protected]

What it does

This commit adds support to install and use webview views extensions - to be shows in the views - side panel
as described in the issue:
#8740

How to test

install the VSCode webview-view-sample extension.
go to the explorer side panel menu and click the button
the list of views should include the calico colors title
expand the view -> expected results - the webview should appear presenting the webview view contribution.

Review checklist

Reminder for reviewers

@ChayaLau ChayaLau force-pushed the webview-view-support branch 2 times, most recently from f322ac9 to ff70576 Compare September 19, 2021 14:28
Added API to support Webview based views contributions

Signed-off-by: ChayaLau <[email protected]>
@ChayaLau ChayaLau force-pushed the webview-view-support branch from af0b1d8 to d12ce31 Compare September 19, 2021 14:39
@ChayaLau
Copy link
Contributor Author

@vince-fugnitto , @msujew, @colin-grant-work
I would like if you can take a look in this PR, so i can get prepared to the next version in advanced.
it is still one of my first commits in this repo - so i would like to hear any comment and recommendation and fix accordingly.
thanks

@msujew msujew self-requested a review September 20, 2021 08:51
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

The functionality looks good to me so far. The sample webview-view extension works perfectly without impacting other webview related extensions like the webview-sample. 👍

I have a few remarks on the code. Nonetheless, impressive work for being quite new to the project.

@ChayaLau
Copy link
Contributor Author

The functionality looks good to me so far. The sample webview-view extension works perfectly without impacting other webview related extensions like the webview-sample. 👍

I have a few remarks on the code. Nonetheless, impressive work for being quite new to the project.

Hi - @msujew,
thank you so much for your review and the comments,
i will handle them and will let you know when done.

@msujew msujew added vscode issues related to VSCode compatibility webviews issues related to webviews labels Sep 21, 2021
Added API to support Webview based views contributions

Signed-off-by: ChayaLau <[email protected]>
@ChayaLau
Copy link
Contributor Author

ChayaLau commented Sep 29, 2021

hi @msujew
I fixed the above according to your advice, thx.
how can i ask for a secondary review or a merge if possible ?

Copy link
Contributor

@tsmaeder tsmaeder left a comment

Choose a reason for hiding this comment

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

A first batch of comments: I think this PR could be simpler, but maybe we should just get the code in an then refactor 🤷

const view = this.views.get(viewId);
if (view?.[1]?.type === PluginViewType.Webview) {
const webviewWidget = this.widgetManager.getWidget(WebviewWidget.FACTORY_ID, <WebviewWidgetIdentifier>{ id: webviewId });
Copy link
Contributor

Choose a reason for hiding this comment

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

Welcome content (https://code.visualstudio.com/api/references/contribution-points#contributes.viewsWelcome) is not handled for webview views. I guess the right thing to do would be to move the welcome content handling out of the tree view and into the PluginViewWidget class. The less protocol we require from the view widget, the more we can reuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you recommend stop working on this for now until the refactoring is done? or we should do the refactoring after all?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, it's better to get the functionality in with limitations than not to have it at all: it's just missing functionality, it does not break anything beyond the new stuff.

@tsmaeder
Copy link
Contributor

tsmaeder commented Oct 5, 2021

I'm thinking this area of the code needs some refactoring, in particular the "welcome content" support in views (which right now is tied to tree view, when it would not have to be). It's like the old joke about the englishman who wanted to go to Letterfrack: "I wouldn't start from here" ;-)

@ChayaLau
Copy link
Contributor Author

ChayaLau commented Oct 24, 2021

I'm thinking this area of the code needs some refactoring, in particular the "welcome content" support in views (which right now is tied to tree view, when it would not have to be). It's like the old joke about the englishman who wanted to go to Letterfrack: "I wouldn't start from here" ;-)

i want to try to get this merged before next release.
i see 3 limitations

  1. the area of register view needs refactoring.
  2. the welcome view is not supported
  3. we might be able to skip the webview view service and register right into plugin view registry. - handled in below commit.
    what is important for before merge, and what can wait to after merge?

@vince-fugnitto
Copy link
Member

vince-fugnitto commented Oct 25, 2021

i want to try to get this merged before next release

@ChayaLau I'm not sure it will be completed in time for the next release unfortunately (Thursday 28th), as there are currently limitations, and I believe CQs are still necessary:

Is there a committer at SAP that can help you register CQs?

@ChayaLau
Copy link
Contributor Author

i want to try to get this merged before next release

@ChayaLau I'm not sure it will be completed in time for the next release unfortunately (Thursday 28th), as there are currently limitations, and I believe CQs are still necessary:

Is there a committer at SAP that can help you register CQs?

yes, i will ask @amiramw to help me with CQ
what about code review changes, about the refactoring, are we going to wait for it?

@amiramw
Copy link
Member

amiramw commented Nov 11, 2021

yes, i will ask @amiramw to help me with CQ

Done: https://dev.eclipse.org/ipzilla/show_bug.cgi?id=23825

@bodarajeshkumar
Copy link

Happy to see this feature getting implemented. I am waiting for this feature to be available in Eclipse-Che. Any update on when this can be merged and available?

@bodarajeshkumar
Copy link

Is there anything blocking this to be merged? Can someone please let me know If I can expect this to be available in the next few releases?

@marcdumais-work
Copy link
Contributor

Looking at the history, I do not see major outstanding comments. It could be that reviewers have postponed a thorough review until the CQ was obtained and need to have another look.

The PR currently has conflicts. Please rebase it to the latest master branch.

@bodarajeshkumar
Copy link

@marcdumais-work Thank you for the update. @ChayaLau I am glad that you implemented this feature and looking forward to it being available. Can you please rebase this to the master branch which can help In merging this feature?

@tsmaeder
Copy link
Contributor

tsmaeder commented Dec 21, 2021

@msujew or @vince-fugnitto I think we as reviewers kinda dropped the ball on this one. I won't be able to address this PR in the next month. Can one of you pick this one up?

@msujew
Copy link
Member

msujew commented Dec 21, 2021

@tsmaeder I will continue with the review at the start of January 👍

@ChayaLau
Copy link
Contributor Author

@tsmaeder I will continue with the review at the start of January 👍

thanks

@vince-fugnitto
Copy link
Member

@msujew or @vince-fugnitto I think we as reviewers kinda dropped the ball on this one.

@ChayaLau do you mind rebasing the pull-request against the latest master? There have been conflicts since #10137 (comment) and they would need to be resolved before we can proceed with a proper review (likely the review took time since there was no activity for a while in order to rebase).

@msujew msujew self-requested a review January 11, 2022 10:38
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

The code looks mostly good to me. I have added some minor comments.

The feature still works as expected, @ChayaLau do you mind rebasing your branch soonish?

Everything looks good to me from an achitectural viewpoint, @colin-grant-work do you have something to add?

@@ -319,6 +326,68 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
return toDispose;
}

public async registerWebviewView(viewId: string, resolver: WebviewViewResolver): Promise<Disposable> {
Copy link
Member

Choose a reason for hiding this comment

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

Minor: methods in JavaScript/TypeScript are public by default, the public modifier is not necessary.

await this.prepareView(view, webviewView.webview.identifier.id);
}
}));
const unsubscribe = () => toDisposeOnDidExpandView.dispose();
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: Rename this to dispose. Keeps it more in line with our usual naming conventions.

let _description: string | undefined;

return {
webview: webview,
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick:

Suggested change
webview: webview,
webview,

Comment on lines +381 to +387
dispose(): void {
webview.dispose();
},

show(preserveFocus: boolean): void {
webview.show();
}
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick:

Suggested change
dispose(): void {
webview.dispose();
},
show(preserveFocus: boolean): void {
webview.show();
}
dispose: webview.dispose,
show: webview.show

protected getWebviewView(handle: string): WebviewView {
const webviewView = this.webviewViews.get(handle);
if (!webviewView) {
throw new Error('unknown webview view');
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: Add the handle to the error message to better determine what went wrong when this error actually occurs.

@msujew
Copy link
Member

msujew commented Jan 26, 2022

@ChayaLau Are you still interested in contributing this feature?

@vince-fugnitto
Copy link
Member

@ChayaLau Are you still interested in contributing this feature?

@msujew it has been a while they haven't commented on this pull-request or other open pull-requests, should we aim to help complete them so they are landed?

@msujew
Copy link
Member

msujew commented Jan 26, 2022

@vince-fugnitto Yes, I think this one in particular is basically done 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vscode issues related to VSCode compatibility webviews issues related to webviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants