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

fix: menus are not unregistered upon extension deactivation #2188

Merged
merged 2 commits into from
Apr 26, 2023

Conversation

jeffmaury
Copy link
Contributor

Fixes #2069

What does this PR do?

Unregister contributed menus when extension is stopped

Screenshot/screencast of this PR

What issues does this PR fix or reference?

Fixes #2069

How to test this PR?

Stop and start Kind extension and make sure the Push to cluster menu appears only once on the Images tab

Fixes containers#2069

Signed-off-by: Jeff MAURY <jmaury@redhat.com>
@jeffmaury jeffmaury requested review from a team and benoitf as code owners April 21, 2023 09:02
@jeffmaury jeffmaury requested review from cdrage and lstocchi and removed request for a team April 21, 2023 09:02
Copy link
Contributor

@lstocchi lstocchi left a comment

Choose a reason for hiding this comment

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

LGTM

my only concern is that we should add some rule to avoid duplicate commands. I think it's possible that two extensions contribute to the same menu with two command having the same name. In that case one will overwrite the other.
BTW this fixes our current issue, this is why i gave my LGTM, not sure if you want to fix this other thing in another PR.

Copy link
Contributor

@cdrage cdrage left a comment

Choose a reason for hiding this comment

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

LGTM. I have the same concern as @lstocchi regarding adding logic regarding adding multiple same-named menus.

Comment on lines 800 to 811

const analyzedExtension = this.analyzedExtensions.get(extensionId);
if (analyzedExtension) {
const extensionConfiguration = analyzedExtension.manifest?.contributes?.configuration;
if (extensionConfiguration) {
this.configurationRegistry.deregisterConfigurations([extensionConfiguration]);
}
const menus = analyzedExtension.manifest?.contributes?.menus;
if (menus) {
this.menuRegistry.unregisterMenus(menus);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably need to move this upper before we delete it from activated extensions ?

Signed-off-by: Jeff MAURY <jmaury@redhat.com>
@jeffmaury jeffmaury requested a review from benoitf April 25, 2023 07:59
@jeffmaury jeffmaury merged commit cf8f2d4 into containers:main Apr 26, 2023
@jeffmaury jeffmaury deleted the GH-2069 branch April 26, 2023 08:15
@podman-desktop-bot podman-desktop-bot added this to the 0.15.0 milestone Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants