git-machete-intellij-plugin icon indicating copy to clipboard operation
git-machete-intellij-plugin copied to clipboard

Provide descriptions for hidden (invisible) actions

Open mkondratek opened this issue 5 years ago • 22 comments

The description can still be seen from find action... dialog:

image

  • ensure that our actions ("rotating" in particular) have their descriptions
  • provide them if missing

mkondratek avatar Sep 25 '20 06:09 mkondratek

@mkondratek amirite that Action disable due to undefined GM repo in the example above is incorrect yet still visible?

PawelLipski avatar Sep 27 '20 18:09 PawelLipski

Let's first check if it's still a nuisance (as the issue is rather ooold)

PawelLipski avatar Sep 23 '22 09:09 PawelLipski

@mkondratek, @PawelLipski - please help me understand this issue:

  1. which actions are "hidden (invisible)" - and which are NOT ?
  2. "our actions ("rotating" in particular)" - which actions are "rotating"? What does it mean? Where can I find them?

LukaszKontowski avatar Sep 27 '22 15:09 LukaszKontowski

+1, 🎅🏻: would be good to explain what you meant by rotating 😅

PawelLipski avatar Sep 27 '22 19:09 PawelLipski

Ok, so this is about actions that are (disabled and) hidden (see in code setenabledandvisible). The actions are still visible in the find action results. The issue is that we are not sure if the actions (disabled and invisible from toolbar/disabled in context-menu) have proper descriptions in the find action results.

By "rotating" I meant actions that appear and disappear in the toolbar depending on the currently checked out branch (its status to parent/remote; e.g. fast forward is available for the green edge but not for red edge).

Is it clear?

mkondratek avatar Sep 27 '22 22:09 mkondratek

Yes, thanks for explanations! :)

LukaszKontowski avatar Sep 28 '22 07:09 LukaszKontowski

@mkondratek - just to make it 100% clear - do I get it right that all our actions are available under the frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions directory?

LukaszKontowski avatar Sep 28 '22 11:09 LukaszKontowski

:yes:, we don't keep actions anywhere else

PawelLipski avatar Sep 28 '22 11:09 PawelLipski

For some of the disabled actions both description from the bottom bar and from the pop-up text box are the same: image

For others however - there is a standard description on the bottom bar. But the text that is displayed in the pop-up text box is not a description, but an info for the user - it tells, why this action is not available now: image

Anyway - it all looks good to me. The disabled actions do have descriptions and (sometimes) additional info with the reason why they are not available right now. However, sometimes it happens that when using the Find -> Actions way in IntelliJ, we do not get proper descriptions on the pop-up text boxes... But a misleading "Action disabled due to undefined Git Machete repository" info. This seems to be a bug. For example - I tried to check it 3 times in a row (without doing anything else in IDE nor in git on the repo) - and the result was:

  • first time I got "Action disabled due to undefined Git Machete repository" (NOT OK)
  • second time I got proper descriptions + useful info (OK)
  • third time I got "Action disabled due to undefined Git Machete repository" (NOT OK)

I don't know what is the reason for such behavior. And if this is a bug in our plugin or maybe a bug in IDE itself. image

LukaszKontowski avatar Sep 28 '22 13:09 LukaszKontowski

So, as described above - looks like we have proper descriptions for all actions (active and disabled/hidden). But the problem is that sometimes descriptions for disabled actions are replaced by the "Action disabled due to undefined Git Machete repository" info (which is sad). @mkondratek, @PawelLipski - do you know what could be the cause of such situations? I can try to fix this bug in this issue.

LukaszKontowski avatar Sep 29 '22 09:09 LukaszKontowski

I did some more testing and it looks like:

  • if the Git tool window in the lower left corner of the screen is opened - then almost always descriptions are displayed properly in pop-up text boxes for disabled actions
  • if the Git tool window in the lower left corner of the screen is NOT opened - then we get the "Action disabled due to undefined Git Machete repository" info

LukaszKontowski avatar Sep 29 '22 09:09 LukaszKontowski

if the Git tool window in the lower left corner of the screen is NOT opened - then we get the "Action disabled due to undefined Git Machete repository" info

Huh looks like update() isn't triggered on our actions when Git tool window is hidden... sounds like a reasonable optimization from IntelliJ's side. Can you verify this is indeed the case?

PawelLipski avatar Sep 29 '22 09:09 PawelLipski

@PawelLipski - do you have the com.intellij.dvcs.repo.Repository.update() (https://github.com/JetBrains/intellij-community/blob/master/platform/dvcs-api/src/com/intellij/dvcs/repo/Repository.java#L113) method in mind? Or something else?

LukaszKontowski avatar Sep 29 '22 12:09 LukaszKontowski

Sorry, I meant com.intellij.openapi.actionSystem.AnAction#update, overridden on our side by com.virtuslab.gitmachete.frontend.actions.base.BaseProjectDependentAction#update

PawelLipski avatar Sep 29 '22 12:09 PawelLipski

Hmmm 🤔 but let's take a look onto some git4idea actions. Push/pull/smth, some of them are available with Find Action, some of them are not, but do they have proper description no matter if the git tool window is opened? If so I would take a close look into some of them (git4idea actions) and see how they handle proper descriptions.

mkondratek avatar Sep 29 '22 13:09 mkondratek

I'm not sure, which actions are git4idea actions, but here's what I've found:

  • Open the Search Everywhere window and got to the Actions tab
  • Search for actions using the "Git" string
  • Hover the mouse pointer (cursor) over a Git action (not Git Machete action) provided by IntelliJ IDEA itself
  • No description is displayed - neither for active ones (like Clone...) nor for disabled ones (like Abort Cherry-pick)

LukaszKontowski avatar Sep 30 '22 13:09 LukaszKontowski

By git4idea actions I mean actions that are provided from this plugin so probably all git-related actions that are not ours (Push, Cherry Pick, Clone, as you mentioned).

By Find Action I mean exactly the place you mentioned - search everywhere/actions (there is a direct shortcut for it ⇧ ⌘ A).

Lack of description among git4idea actions in that place may be a result of their oversight, idk.

mkondratek avatar Sep 30 '22 18:09 mkondratek

The problem is as follows (needs more investigation for sure):

  • If the Git tool window in the lower left corner of the screen is opened - then com.virtuslab.gitmachete.frontend.actions.expectedkeys.IExpectsKeyGitMacheteRepository#getGitMacheteRepositorySnapshot is not null
  • If the Git tool window in the lower left corner of the screen is not opened - then com.virtuslab.gitmachete.frontend.actions.expectedkeys.IExpectsKeyGitMacheteRepository#getGitMacheteRepositorySnapshot is null

LukaszKontowski avatar Oct 03 '22 09:10 LukaszKontowski

is it a rule in general or e.g. only before opening Git tool window for the first time during IDE instance run?

mkondratek avatar Oct 03 '22 10:10 mkondratek

It happens every time I close the Git tool window (during the same IDE instance run)

LukaszKontowski avatar Oct 03 '22 10:10 LukaszKontowski

In fact, following part of mentioned method resolves to null in these situations (this is the cause of described situation): anActionEvent.getData(DataKeys.KEY_GIT_MACHETE_REPOSITORY_SNAPSHOT)

Looks like this is defined by IntelliJ code, not ours

LukaszKontowski avatar Oct 03 '22 10:10 LukaszKontowski

It is WE who set this data (probably in EnhancedGraphTable.java).

anyway, I am wondering if is it necessary to be limited like that. probably we can provide the snapshot all the time 🤔 I do not remember the logic behind it, and it might be a separate issue starting here. on the other hand we can just agree that the actions are not available at this state and provide proper message in description (it could include "open Git Machete to possible enable this action" - but it sounds strange)

mkondratek avatar Oct 03 '22 10:10 mkondratek