Hello!
I apologize in advance for the length of this post.
My organization is upgrading from Gerrit 2.13 to 3.3. With our current version of Gerrit, we have modified the source code to embed one of our tools (let's call it "hammer") inside the Gerrit UI. We had first considered creating a Gerrit plugin to do that, but I could not figure out how to do that so we went with modification of the source code.
I added a new section to the UI to contain the hammer tool. Hammer does some communicating with the Gerrit UI via the postMessage() function to size itself properly vertically and then do a few other things. To imbed the Hammer section inside the Gerrit UI, we made the following changes to files in gerrit-gwtui/src/main/java/com/google/gerrit/client/change:
ChangeScreen.ui.xml - after the Files section and before the History section, we added this code:
<div id='hammerSectionHeader' class='{style.sectionHeader} {style.headerButtons}'>
<ui:msg>Hammer</ui:msg>
</img>
</div>
<c:HammerSection ui:field='hammerSection'/>
HammerSection.java - new file that extends FlowPanel. It has 3 pieces of private data (changeId, project, and branch) and in the set() function which takes a ChangeInfo object as input, it sets that data to the values from the ChangeInfo object. Then it runs this code:
HTML oHTML = new HTML("<div id='hammer-frame-wrapper'><iframe id='hammer-frame' src='https://our-tools-server.com/hammer.php?sGerritChangeId=" + this.changeid + "&sGerritProject=" + this.project + "&sGerritBranch=" + this.branch + "&sGerritUser=" + Gerrit.getUserAccount().username() + "'></iframe></div>");
add(oHTML);
When the Gerrit review page loads, the iframe loads with the hammer tool data that corresponds with the specified Gerrit change id, project, and branch.
I have been trying to get this to work in Gerrit 3.3 and I have a few problems. Keep in mind that I am new to Polymer and web components. I added the following code to polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts right before <paper-tabs id="secondaryTabs"....> because I wanted this to look like just another section in the review:
<paper-tabs id="tertiaryTabs">
<paper-tab>Hammer</paper-tab>
</paper-tabs>
<section id="hammerSection">
</section>
Note that the URL does have a change id in it so it did use [[_change.change_id]] fine, but the project and branch data was not filled in. Here are some questions:
- Does gr-change-view_html.ts not have permission to use those variables to form a URL inside an iframe?
- Why would it fill in the change id but not the project or branch?
- How would I make it so that code has access to the _change object or is there something else I should use to form that URL to the hammer tool?
Another question - we configured our Gerrit server to use a MySQL database and our hammer tool currently has the capability to query the DB directly. One of the things it can do is query information about change messages or patch comments using the change message or patch comment uuid. We modified the comment-added hook to pass along not only the change message id but also a list of all of the ids of line comments that were added at the same time. The hammer tool is called by that hook and it queries the Gerrit MySQL DB to get info about all of those line comments. Questions about that:
- How would I do this with Gerrit 3.3?
- Can I get direct access to its NotesDB internal database?
- Can I query change messages or line comments using the REST API providing change message or line comment uuids?
Any help would be greatly appreciated. Thanks!