diff options
Diffstat (limited to 'source/features/warning-for-disallow-edits.tsx')
-rw-r--r-- | source/features/warning-for-disallow-edits.tsx | 36 |
1 files changed, 36 insertions, 0 deletions
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 +}); |