diff options
-rw-r--r-- | readme.md | 1 | ||||
-rw-r--r-- | source/content.ts | 1 | ||||
-rw-r--r-- | source/features/warning-for-disallow-edits.tsx | 36 |
3 files changed, 38 insertions, 0 deletions
@@ -165,6 +165,7 @@ GitHub Enterprise is also supported. More info in the options. - [Inactive deployments in PR timelines are hidden.](https://github.com/sindresorhus/refined-github/issues/1144) - [The PR/issues search box expands when focused.](https://user-images.githubusercontent.com/1402241/48473156-7ab8c500-e82a-11e8-95c7-a39b0529fe1b.gif) - [A warning appears when trying to create a PR from the default branch.](https://user-images.githubusercontent.com/1402241/52543516-3ca94e00-2de5-11e9-9f80-ff8f9fe8bdc4.png) +- [A warning appears when unchecking `Allow edits from maintainers`.](https://user-images.githubusercontent.com/1402241/53151888-24101380-35ef-11e9-8d30-d6315ad97325.gif) And [many more…](source/content.css) 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 +}); |