Skip to content

Commit

Permalink
Add issue type functionality for anonymous reports (#10563)
Browse files Browse the repository at this point in the history
  • Loading branch information
obfuscated-loop authored Dec 25, 2023
1 parent 5d721c7 commit cff2406
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 5 deletions.
20 changes: 20 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,25 @@
"menuLoadingText": {
"message": "Loading...",
"description": "Loading messsage"
},
"generalIssueOption": {
"message": "General issue (requires notes)",
"description": "The option text for a general issue"
},
"scrollbarIssueOption": {
"message": "Scrollbar related",
"description": "The option text for a scrollbar issue"
},
"modalIssueOption": {
"message": "Modal related",
"description": "The option text for a modal issue"
},
"scrollbarIssueDescription": {
"message": "Select this option to signify an issue on this page related to scrolling - like 'the site is not showing a scrollbar'.",
"description": "Explanation of what a scrollbar issue is"
},
"modalIssueDescription": {
"message": "Select this option to signify an issue on this page related to a modal - like 'there is a pop-up box blocking interaction'.",
"description": "Explanation of what a modal issue is"
}
}
4 changes: 3 additions & 1 deletion src/data/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ if (!isManifestV3) {
}
// Reporting

function reportWebsite(info, tab, anon, notes, callback) {
function reportWebsite(info, tab, anon, issueType, notes, callback) {
if (tab.url.indexOf("http") != 0 || !tabList[tab.id]) {
return;
}
Expand Down Expand Up @@ -387,6 +387,7 @@ function reportWebsite(info, tab, anon, notes, callback) {
"Content-Type": "application/json",
},
body: JSON.stringify({
issueType,
notes,
url: tab.url,
browser: getBrowserAndVersion(),
Expand Down Expand Up @@ -574,6 +575,7 @@ chrome.runtime.onMessage.addListener((request, info, sendResponse) => {
info,
tabList[request.tabId],
request.anon,
request.issueType,
request.notes,
sendResponse
);
Expand Down
12 changes: 11 additions & 1 deletion src/data/menu/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ <h3>
<span data-translate="reportAnonTitle"></span>
<span id="hostname">example.com</span>
</h3>
<label data-translate="reportAnonNotes"></label>
<select id="report_issue_type">
<option value="general" data-translate="generalIssueOption">
</option>
<option value="scrollbar" data-translate="scrollbarIssueOption">
</option>
<option value="modal" data-translate="modalIssueOption">
</option>
</select>
<label id="general_issue_description" data-translate="reportAnonNotes"></label>
<label id="scrollbar_issue_description" data-translate="scrollbarIssueDescription"></label>
<label id="modal_issue_description" data-translate="modalIssueDescription"></label>
<textarea id="report-notes"></textarea>
<button id="report_anon_send" data-translate="reportAnonSend"></button>
<button
Expand Down
22 changes: 20 additions & 2 deletions src/data/menu/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ const toggle = document.getElementById("toggle");
const refresh = document.getElementById("refresh");
const report = document.getElementById("report");
const options = document.getElementById("options");

const issueTypeSelect = document.getElementById("report_issue_type");
const reportNotesTextarea = document.getElementById("report-notes");

let currentTab = false;

toggle.addEventListener("click", function (e) {
Expand Down Expand Up @@ -54,14 +58,28 @@ document.getElementById("report_anon").addEventListener("click", function (e) {
document.getElementById("hostname").textContent = currentTab.hostname;
});

issueTypeSelect.addEventListener("change", () => {
let issueTypeValue = issueTypeSelect.options[issueTypeSelect.selectedIndex].value;

document.querySelectorAll("label[id*='issue_description']").forEach((label) => {
label.style.display = "none";
});

reportNotesTextarea.style.display = (issueTypeValue == "general") ? "block" : "none";
document.getElementById(`${issueTypeValue}_issue_description`).style.display = "block";
});

document.getElementById("report_anon_send").addEventListener("click", () => {
let issueTypeValue = issueTypeSelect.options[issueTypeSelect.selectedIndex].value;

switchMenu("menu_loading");
chrome.runtime.sendMessage(
{
command: "report_website",
tabId: currentTab.id,
anon: true,
notes: document.getElementById("report-notes").value,
issueType: issueTypeValue,
notes: (issueTypeValue == "general") ? reportNotesTextarea.value : null,
},
(message) => {
if (message.error) {
Expand Down Expand Up @@ -129,7 +147,7 @@ function translate() {
element.textContent = chrome.i18n.getMessage(element.dataset.translate);
}

document.getElementById("report-notes").placeholder = chrome.i18n.getMessage(
reportNotesTextarea.placeholder = chrome.i18n.getMessage(
"reportNotesPlaceholder"
);
}
Expand Down
17 changes: 16 additions & 1 deletion src/data/menu/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,23 @@ h3 {
margin-top: 0px;
}

#report_issue_type, label[id*='issue_description'] {
margin-bottom: 5px;
}

label[id*='issue_description'] {
color: rgb(43, 43, 43);
font-style: italic;
display: none;
}

label#general_issue_description {
display: block;
}

#report-notes {
height: 60px;
height: 70px;
min-width: 100%;
max-width: 100%;
margin-bottom: 5px;
}

0 comments on commit cff2406

Please sign in to comment.