Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 370421 - Can not render commands multiple times in one div for "tool" style
Summary: Can not render commands multiple times in one div for "tool" style
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: 0.4   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 0.4 RC1   Edit
Assignee: Susan McCourt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-02 06:10 EST by Szymon Brandys CLA
Modified: 2012-02-03 02:16 EST (History)
1 user (show)

See Also:


Attachments
Two "undefined" commands when "See Full Log" is non-href (5.08 KB, image/png)
2012-02-02 06:12 EST, Szymon Brandys CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Szymon Brandys CLA 2012-02-02 06:10:34 EST
I render commands for two different objects in one action div. I do this in the "Commits for ... branch" section of the repo view, where you have "Fetch", "Merge", "Rebase" for a remote tracking branch and "Push All" for a local branch. It worked well and two sets of actions were rendered in one div. I had to add a third #renderCommand to the same div for the "See Full Log" command and this is where the problem began.

I added a command to git-repository.js (see eclipse.orion.git.repositories.viewAllCommand around line 74) and the result was just "See Full Log" in the action area. I noticed that when this command is changed to a non-href command, everything is rendered almost properly, but I see two undefined commands now. It seems like all 3 #renderCommand where trying to render the "View All" command. See the screenshot.

The workaround was to render "See Full Log" in a separate div.

The code in gitRepositoryExplorer.js that adds commands is around line 542.
Comment 1 Szymon Brandys CLA 2012-02-02 06:12:14 EST
Created attachment 210438 [details]
Two "undefined" commands when "See Full Log" is non-href
Comment 2 Susan McCourt CLA 2012-02-02 10:54:13 EST
thanks for the detailed description.
I'm going to review these scenarios after implementing bug 360986.
Comment 3 Susan McCourt CLA 2012-02-02 22:31:25 EST
the bug is in your handling of the view all command, and in particular the looseness of the visibleWhen expression.

I see that you defined a command with no image, no name, etc.  The visibleWhen expression has a side effect of setting values on the command and then computing whether the command is valid for the item.  But when this visibleWhen is called on the second render, it fails and blows out of the command code, so the rest does not render.  

So the first time you call renderCommands, you set the image and name and it validates as expected.  The link gets drawn.  But the second time through, it is still going to visit the "see all" command since you are rendering the same set of commands again.  This time, it's evaluating the visibleWhen expression against the second set of items.  Your visibleWhen wasn't strict enough to rule out items it doesn't understand.  It had

return item.ViewAllLink !== null

but for items that don't match at all, the link will be "undefined" and this expression will evaluate to true.  So then we try to render this partially formed command and it blows up.  I could better protect the command framework against malformed commands, but then your symptom would have been double rendering of the link.

So the bottom line is that if you want to render multiple item objects in a single div, you want to make sure that the commands contributed to that dom node will evaluate cleanly against all the items.

I have a fix in my workspace, hopefully will push it tonight, I have to fix a couple more bugs.
Comment 4 Susan McCourt CLA 2012-02-03 02:16:43 EST
pushed.