Skip to content

Commit

Permalink
Feature to disable taking action based on whiteboard
Browse files Browse the repository at this point in the history
  • Loading branch information
kewisch committed Nov 2, 2021
1 parent 8baeaf3 commit f1dbcf3
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amoqueue-wx",
"version": "10.4.6",
"version": "10.5.0",
"author": "Philipp Kewisch <[email protected]>",
"homepage": "https://github.com/kewisch/amo-helper#readme",
"repository": {
Expand Down
9 changes: 8 additions & 1 deletion src/content/reviewinfo/review.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@
background-image: linear-gradient(to bottom,transparent 0,transparent 123px,#0c99d5 123px,#0c99d5 200px,#fff 200px,rgba(12,153,213,0) 400px);
}

#addon .is_recommendable.amoqueue-vip {
#addon .is_promoted.amoqueue-vip {
color: white;
background-color: #1E5631;
font-size: 1.2em;
}

.amoqueue-action-warning {
font-weight: bold;
font-size: 1.2em;
color: red;
}
55 changes: 44 additions & 11 deletions src/content/reviewinfo/review.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,61 @@ async function initLayout() {
});
}

function updateTags(tagMap) {
let value = document.querySelector("#id_action .on-tab input").value;
let submit = document.querySelector(".review-actions-save input[type='submit']");
let message = document.querySelector(".amoqueue-action-warning");

if (tagMap["no-action"]) {
message.textContent = "Please don't take action: " + tagMap["no-action"];
} else {
submit.disabled = true;
if (tagMap["no-reject"] && value.includes("reject")) {
message.textContent = "Please do not reject: " + tagMap["no-reject"];
} else if (tagMap["no-engage"] && (value.includes("reject") || value == "reply")) {
message.textContent = "Please do not engage: " + tagMap["no-engage"];
} else {
message.textContent = "";
submit.disabled = false;
}
}
}

function markVIP() {
let privboard = document.getElementById("id_whiteboard-private");
let privboard = document.getElementById("id_whiteboard-private").textContent;
let hasMozillaAuthor = !!document.querySelector("#scroll_sidebar li a[href$='/firefox/user/4757633/']");

let match = privboard.textContent.match(/\[vip\]\s*([^\n]*)/);
let tags = privboard.matchAll(/\[([a-zA-Z_-]+)\]\s*([^\n]+)/g) || [];
let tagMap = {};
for (let [, tag, reason] of tags) {
tagMap[tag] = reason;
}

if (!tags.vip && hasMozillaAuthor) {
tags.vip = "This is an official Mozilla add-on";
}

if (match || hasMozillaAuthor) {
if (tagMap.vip) {
let history = document.getElementById("versions-history");
let bar = history.parentNode.insertBefore(document.createElement("p"), history.nextElementSibling);
bar.className = "is_recommendable amoqueue-vip";
bar.className = "is_promoted amoqueue-vip";

let descr = bar.appendChild(document.createElement("div"));
descr.textContent = "This is a VIP add-on. Please contact an admin before rejecting or sending an information request.";

if (match && match[1]) {
let reason = bar.appendChild(document.createElement("div"));
reason.textContent = "Details: " + match[1];
} else if (hasMozillaAuthor) {
let reason = bar.appendChild(document.createElement("div"));
reason.textContent = "Details: This is an official Mozilla extension.";
}
let reasonDetails = bar.appendChild(document.createElement("div"));
reasonDetails.textContent = "Details: " + tagMap.vip;
}

let saveSection = document.querySelector(".review-actions-section.review-actions-save");
let message = document.createElement("span");
message.className = "amoqueue-action-warning";
saveSection.insertBefore(message, saveSection.firstElementChild);

updateTags(tagMap);
document.getElementById("id_action").addEventListener("click", (event) => {
updateTags(tagMap);
});
}

function addBlocklistButton() {
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "AMO Review Helper",
"short_name": "AMO Helper",
"version": "10.4.6",
"version": "10.5.0",
"applications": {
"gecko": {
"id": "@amoqueue",
Expand Down

0 comments on commit f1dbcf3

Please sign in to comment.