feat(browser-extension): add button to open issue in GitHub after report
This commit is contained in:
parent
59f3d7023d
commit
244ed1f210
@ -112,6 +112,9 @@ const reportDialogHtml = `
|
|||||||
<report-dialog-submit-extra-text>
|
<report-dialog-submit-extra-text>
|
||||||
${chrome.i18n.getMessage('reportDialog_submitExtraText')}
|
${chrome.i18n.getMessage('reportDialog_submitExtraText')}
|
||||||
</report-dialog-submit-extra-text>
|
</report-dialog-submit-extra-text>
|
||||||
|
<report-dialog-issue-button role="button" tabindex="0">
|
||||||
|
${chrome.i18n.getMessage('contextMenu_issueOption')}
|
||||||
|
</report-dialog-issue-button>
|
||||||
</report-dialog-submit-view>
|
</report-dialog-submit-view>
|
||||||
</report-dialog-body>
|
</report-dialog-body>
|
||||||
</dialog>
|
</dialog>
|
||||||
@ -121,25 +124,25 @@ const reportDialogHtml = `
|
|||||||
* @description Dialog close button click handler
|
* @description Dialog close button click handler
|
||||||
* @param {MouseEvent} event
|
* @param {MouseEvent} event
|
||||||
*/
|
*/
|
||||||
const closeButtonClickHandler = (event) => {
|
function closeButtonClickHandler(event) {
|
||||||
const dialog = document.getElementById(reportDialogId);
|
const dialog = document.getElementById(reportDialogId);
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
dialog?.remove();
|
dialog?.remove();
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Hide report dialog
|
* @description Hide report dialog
|
||||||
*/
|
*/
|
||||||
const hideReportDialog = () => {
|
function hideReportDialog() {
|
||||||
document.getElementById(reportDialogId)?.remove();
|
document.getElementById(reportDialogId)?.remove();
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Dialog radio input click handler
|
* @description Dialog radio input click handler
|
||||||
* @param {MouseEvent} event
|
* @param {MouseEvent} event
|
||||||
*/
|
*/
|
||||||
const radioClickHandler = (event) => {
|
function radioClickHandler(event) {
|
||||||
const dialog = document.getElementById(reportDialogId);
|
const dialog = document.getElementById(reportDialogId);
|
||||||
const radios = dialog.getElementsByTagName('report-dialog-radio');
|
const radios = dialog.getElementsByTagName('report-dialog-radio');
|
||||||
const submitButton = dialog?.getElementsByTagName('report-dialog-submit-button')[0];
|
const submitButton = dialog?.getElementsByTagName('report-dialog-submit-button')[0];
|
||||||
@ -152,12 +155,12 @@ const radioClickHandler = (event) => {
|
|||||||
event.currentTarget.setAttribute('aria-checked', 'true');
|
event.currentTarget.setAttribute('aria-checked', 'true');
|
||||||
submitButton.setAttribute('aria-disabled', 'false');
|
submitButton.setAttribute('aria-disabled', 'false');
|
||||||
submitButton.addEventListener('click', submitButtonClickHandler);
|
submitButton.addEventListener('click', submitButtonClickHandler);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Show report dialog
|
* @description Show report dialog
|
||||||
*/
|
*/
|
||||||
const showReportDialog = () => {
|
function showReportDialog() {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const result = parser.parseFromString(reportDialogHtml, 'text/html');
|
const result = parser.parseFromString(reportDialogHtml, 'text/html');
|
||||||
const dialog = result.body.firstElementChild;
|
const dialog = result.body.firstElementChild;
|
||||||
@ -181,26 +184,30 @@ const showReportDialog = () => {
|
|||||||
if (!document.getElementById('report-dialog-font')) {
|
if (!document.getElementById('report-dialog-font')) {
|
||||||
document.head.appendChild(link);
|
document.head.appendChild(link);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Dialog submit button click handler
|
* @description Dialog submit button click handler
|
||||||
* @param {MouseEvent} event
|
* @param {MouseEvent} event
|
||||||
*/
|
*/
|
||||||
const submitButtonClickHandler = (event) => {
|
async function submitButtonClickHandler(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
const dialog = document.getElementById(reportDialogId);
|
const dialog = document.getElementById(reportDialogId);
|
||||||
const formView = dialog?.getElementsByTagName('report-dialog-form-view')[0];
|
const formView = dialog?.getElementsByTagName('report-dialog-form-view')[0];
|
||||||
|
const issueButton = dialog?.getElementsByTagName('report-dialog-issue-button')[0];
|
||||||
const option = dialog?.querySelector('report-dialog-radio[aria-checked="true"]');
|
const option = dialog?.querySelector('report-dialog-radio[aria-checked="true"]');
|
||||||
const reasonIndex = option?.dataset.value;
|
const reasonIndex = option?.dataset.value;
|
||||||
const reason = Number.isNaN(reasonIndex) ? 'Unknown' : reasons[reasonIndex];
|
const reason = Number.isNaN(reasonIndex) ? 'Unknown' : reasons[reasonIndex];
|
||||||
const submitView = dialog?.getElementsByTagName('report-dialog-submit-view')[0];
|
const submitView = dialog?.getElementsByTagName('report-dialog-submit-view')[0];
|
||||||
const userAgent = window.navigator.userAgent;
|
const userAgent = window.navigator.userAgent;
|
||||||
|
|
||||||
event.preventDefault();
|
const issueUrl = await dispatch({ userAgent, reason, type: 'REPORT' });
|
||||||
dispatch({ userAgent, reason, type: 'REPORT' });
|
|
||||||
formView?.setAttribute('hidden', 'true');
|
formView?.setAttribute('hidden', 'true');
|
||||||
|
issueButton?.addEventListener('click', () => window.open(issueUrl, '_blank'));
|
||||||
submitView?.removeAttribute('hidden');
|
submitView?.removeAttribute('hidden');
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Listen to messages
|
* @description Listen to messages
|
||||||
|
@ -70,6 +70,18 @@ report-dialog-close-button:hover {
|
|||||||
background-color: var(--cookie-dialog-monster-color-white);
|
background-color: var(--cookie-dialog-monster-color-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
report-dialog-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
report-dialog-form-view {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
report-dialog-form-view[hidden] {
|
report-dialog-form-view[hidden] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@ -96,7 +108,6 @@ report-dialog-radio {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: block;
|
display: block;
|
||||||
font-family: Inter, Arial, Helvetica, sans-serif;
|
font-family: Inter, Arial, Helvetica, sans-serif;
|
||||||
margin-top: 18px;
|
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
padding-left: 24px;
|
padding-left: 24px;
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -148,8 +159,10 @@ report-dialog-radio:before {
|
|||||||
report-dialog-radio-group {
|
report-dialog-radio-group {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
gap: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
report-dialog-issue-button,
|
||||||
report-dialog-submit-button {
|
report-dialog-submit-button {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: var(--cookie-dialog-monster-color-secondary);
|
background-color: var(--cookie-dialog-monster-color-secondary);
|
||||||
@ -162,7 +175,6 @@ report-dialog-submit-button {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
height: 39px;
|
height: 39px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-top: 24px;
|
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
padding: 8px 16px;
|
padding: 8px 16px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -170,12 +182,15 @@ report-dialog-submit-button {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
report-dialog-issue-button:focus,
|
||||||
|
report-dialog-issue-button:hover,
|
||||||
report-dialog-submit-button:focus,
|
report-dialog-submit-button:focus,
|
||||||
report-dialog-submit-button:hover {
|
report-dialog-submit-button:hover {
|
||||||
background-color: var(--cookie-dialog-monster-color-white);
|
background-color: var(--cookie-dialog-monster-color-white);
|
||||||
color: var(--cookie-dialog-monster-color-secondary);
|
color: var(--cookie-dialog-monster-color-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
report-dialog-issue-button[aria-disabled='true'],
|
||||||
report-dialog-submit-button[aria-disabled='true'] {
|
report-dialog-submit-button[aria-disabled='true'] {
|
||||||
background-color: var(--cookie-dialog-monster-color-tertiary);
|
background-color: var(--cookie-dialog-monster-color-tertiary);
|
||||||
border: 1px solid var(--cookie-dialog-monster-color-tertiary);
|
border: 1px solid var(--cookie-dialog-monster-color-tertiary);
|
||||||
@ -186,18 +201,16 @@ report-dialog-submit-button[aria-disabled='true'] {
|
|||||||
report-dialog-submit-extra-text {
|
report-dialog-submit-extra-text {
|
||||||
font-family: inherit !important;
|
font-family: inherit !important;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 14px;
|
line-height: 16px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
margin-top: 16px;
|
text-align: justify;
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
report-dialog-submit-text {
|
report-dialog-submit-text {
|
||||||
font-family: inherit !important;
|
font-family: inherit !important;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
line-height: 18px;
|
line-height: 20px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
margin-top: 24px;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,8 +219,9 @@ report-dialog-submit-view {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
font-family: Inter, Arial, Helvetica, sans-serif;
|
font-family: Inter, Arial, Helvetica, sans-serif;
|
||||||
|
gap: 24px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
min-height: 269px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
report-dialog-submit-view[hidden] {
|
report-dialog-submit-view[hidden] {
|
||||||
|
Loading…
Reference in New Issue
Block a user