git-machete-intellij-plugin
git-machete-intellij-plugin copied to clipboard
Provide descriptions for hidden (invisible) actions
The description can still be seen from find action... dialog:

- ensure that our actions ("rotating" in particular) have their descriptions
- provide them if missing
@mkondratek amirite that Action disable due to undefined GM repo in the example above is incorrect yet still visible?
Let's first check if it's still a nuisance (as the issue is rather ooold)
@mkondratek, @PawelLipski - please help me understand this issue:
- which actions are "hidden (invisible)" - and which are NOT ?
- "our actions ("rotating" in particular)" - which actions are "rotating"? What does it mean? Where can I find them?
+1, 🎅🏻: would be good to explain what you meant by rotating 😅
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?
Yes, thanks for explanations! :)
@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?
:yes:, we don't keep actions anywhere else
For some of the disabled actions both description from the bottom bar and from the pop-up text box are the same:

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:

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.

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.
I did some more testing and it looks like:
- if the
Gittool 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
Gittool 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
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 - 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?
Sorry, I meant com.intellij.openapi.actionSystem.AnAction#update, overridden on our side by com.virtuslab.gitmachete.frontend.actions.base.BaseProjectDependentAction#update
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.
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
Actionstab - 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 (likeAbort Cherry-pick)
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.
The problem is as follows (needs more investigation for sure):
- If the
Gittool window in the lower left corner of the screen is opened - thencom.virtuslab.gitmachete.frontend.actions.expectedkeys.IExpectsKeyGitMacheteRepository#getGitMacheteRepositorySnapshotis notnull - If the
Gittool window in the lower left corner of the screen is not opened - thencom.virtuslab.gitmachete.frontend.actions.expectedkeys.IExpectsKeyGitMacheteRepository#getGitMacheteRepositorySnapshotisnull
is it a rule in general or e.g. only before opening Git tool window for the first time during IDE instance run?
It happens every time I close the Git tool window (during the same IDE instance run)
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
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)