Skip to content

Commit f57831d

Browse files
committed
Fix change actions on v3.1 based Gerrit
Adapted to server side change on Gerrit 3.1. Only revisions actions are returned on show-revision-actions event. Also removed unnecessary use of plugin wide variable. Change-Id: I3176fef61ba11a5c26b9e33fd6cbef7af33024d5 Reviewed-by: Alexandru Croitor <[email protected]>
1 parent 2b6a3ba commit f57831d

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

qt-gerrit-ui-plugin/qt-gerrit-ui-plugin.html

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,27 @@
105105
});
106106

107107
// Customize change view
108-
plugin.on('show-revision-actions', function(actions, changeInfo) {
109-
plugin.ca = plugin.changeActions();
108+
plugin.on('show-revision-actions', function(revisionActions, changeInfo) {
109+
var actions = Object.assign({}, revisionActions, changeInfo.actions);
110+
var cActions = plugin.changeActions();
110111

111112
// always hide the rebase button
112-
plugin.ca.setActionHidden('revision', 'rebase', true);
113+
cActions.setActionHidden('revision', 'rebase', true);
113114

114115
// Hide 'Sanity-Review+1' button in header
115-
var secondaryActionsElem = plugin.ca._el.root.querySelector("#secondaryActions");
116+
var secondaryActionsElem = cActions._el.root.querySelector("#secondaryActions");
116117
if (secondaryActionsElem &&
117118
secondaryActionsElem.innerHTML &&
118119
secondaryActionsElem.innerHTML.indexOf('Sanity-Review+1') != -1) {
119-
plugin.ca.hideQuickApproveAction();
120+
cActions.hideQuickApproveAction();
120121
}
121122

122123
// Remove any existing buttons
123124
if (plugin.buttons) {
124125
BUTTONS.forEach((key) => {
125126
if(typeof plugin.buttons[key] !== 'undefined' && plugin.buttons[key] !== null) {
126-
plugin.ca.removeTapListener(plugin.buttons[key], (param) => {} );
127-
plugin.ca.remove(plugin.buttons[key]);
127+
cActions.removeTapListener(plugin.buttons[key], (param) => {} );
128+
cActions.remove(plugin.buttons[key]);
128129
plugin.buttons[key] = null;
129130
}
130131
});
@@ -135,20 +136,20 @@
135136
var action = actions[key];
136137
if (action) {
137138
// hide dropdown action
138-
plugin.ca.setActionHidden(action.__type, action.__key, true);
139+
cActions.setActionHidden(action.__type, action.__key, true);
139140

140141
// add button
141-
plugin.buttons[key] = plugin.ca.add(action.__type, action.label);
142-
plugin.ca.setTitle(plugin.buttons[key], action.title);
143-
plugin.ca.addTapListener(plugin.buttons[key], buttonEventCallback);
142+
plugin.buttons[key] = cActions.add(action.__type, action.label);
143+
cActions.setTitle(plugin.buttons[key], action.title);
144+
cActions.addTapListener(plugin.buttons[key], buttonEventCallback);
144145

145146
if (key === 'gerrit-plugin-qt-workflow~stage') {
146147
// use the submit icon for our stage button
147-
plugin.ca.setIcon(plugin.buttons[key], 'submit');
148+
cActions.setIcon(plugin.buttons[key], 'submit');
148149
// hide submit button when it would be disabled next to the stage button
149150
let submit = actions['submit'];
150151
if (!submit.enabled) {
151-
plugin.ca.setActionHidden('revision', 'submit', true);
152+
cActions.setActionHidden('revision', 'submit', true);
152153
}
153154
}
154155

0 commit comments

Comments
 (0)