summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/content.ts1
-rw-r--r--source/features/warning-for-disallow-edits.tsx36
2 files changed, 37 insertions, 0 deletions
diff --git a/source/content.ts b/source/content.ts
index 4cd1db0f..2a481ca0 100644
--- a/source/content.ts
+++ b/source/content.ts
@@ -84,6 +84,7 @@ import './features/mark-private-orgs';
import './features/linkify-commit-sha';
import './features/bypass-checks';
import './features/add-co-authored-by';
+import './features/warning-for-disallow-edits';
import './features/warn-pr-from-master';
import './features/split-issue-pr-search-results';
import './features/preview-hidden-comments';
diff --git a/source/features/warning-for-disallow-edits.tsx b/source/features/warning-for-disallow-edits.tsx
new file mode 100644
index 00000000..b896caca
--- /dev/null
+++ b/source/features/warning-for-disallow-edits.tsx
@@ -0,0 +1,36 @@
+import React from 'dom-chef';
+import select from 'select-dom';
+import features from '../libs/features';
+
+function init() {
+ const checkbox = select<HTMLInputElement>('[name="collab_privs"]');
+ const warning = (
+ <div class="flash flash-error mt-3">
+ <strong>Note:</strong> Maintainers may require changes. It’s easier and faster to allow them to make direct changes before merging.
+ </div>
+ );
+ const update = () => {
+ if (checkbox.checked) {
+ warning.remove();
+ } else {
+ // Select every time because the sidebar content may be replaced
+ select(`
+ .new-pr-form .timeline-comment,
+ .discussion-sidebar .js-collab-form + .dropdown
+ `).after(warning);
+ }
+ };
+
+ update(); // The sidebar checkbox may already be un-checked
+ checkbox.addEventListener('change', update);
+}
+
+features.add({
+ id: 'warning-for-disallow-edits',
+ include: [
+ features.isCompare,
+ features.isPRConversation
+ ],
+ load: features.onAjaxedPages,
+ init
+});