Check label permissions on votes change
Some conditions aren't checked on label change callback. Instead of
copying them from the install function, use global state to indicate
whether to display or not.
R=gavinmak@google.com
Fixed: 1306251
Change-Id: I890cdeb1f0af1ce6239592df841a24f535fe9b83
diff --git a/web/autosubmit.ts b/web/autosubmit.ts
index 732a638..ac863e5 100644
--- a/web/autosubmit.ts
+++ b/web/autosubmit.ts
@@ -48,6 +48,7 @@
let CQ_LABEL_MAX_VALUE = 0;
let APPROVED_BY_ALL_OTHER_REVIEWERS = false;
let CHANGE: ChangeInfo | null = null;
+let BUTTONS_INSTALLED = false;
/**
* There are two main flows that need to handle the AS+1 vote:
@@ -59,6 +60,7 @@
* This function adds both behaviors. See crbug.com/631551 for more context.
*/
export async function installAutoSubmit(plugin: PluginApi, change: ChangeInfo) {
+ BUTTONS_INSTALLED = false;
if (!change || !change.permitted_labels) {
// Could happen if the user is not logged in.
return;
@@ -93,6 +95,7 @@
return;
}
+ BUTTONS_INSTALLED = true;
// Check to see if we are still waiting for any other reviewers to
// approve.
await checkIfApprovedByAllOtherReviewers(plugin, change);
@@ -218,6 +221,9 @@
* Inform user that CQ+2 was automatically set
*/
export function installLabelValuesCallbackAutosubmit(plugin: PluginApi) {
+ if (!BUTTONS_INSTALLED) {
+ return;
+ }
const replyApi = plugin.changeReply();
replyApi.addLabelValuesChangedCallback(
async (labelDetail: LabelsChangedDetail, change?: ChangeInfo) => {