Skip to content

Commit e281b6b

Browse files
authored
Add cancel-wiki-edit-button feature (refined-github#4467)
1 parent f2b54d9 commit e281b6b

4 files changed

Lines changed: 32 additions & 4 deletions

File tree

.github/workflows/features.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ jobs:
2121
id: name
2222
uses: AsasInnab/regex-action@v1
2323
with:
24-
regex_pattern: '(?<=Add `)\w+(?=` feature)'
24+
regex_pattern: '(?<=Add `)[a-z-]+(?=` feature)'
2525
regex_flags: g
2626
search_string: ${{ github.event.pull_request.title }}
2727

28-
- name: Has ${{ steps.name.outputs.first_match }}.tsx been created?
28+
- name: Has `${{ steps.name.outputs.first_match }}.tsx` been created?
2929
uses: mudlabs/simple-diff@v1.2.0
3030
with:
3131
path: source/features/${{ steps.name.outputs.first_match }}.tsx
3232

33-
- name: Has `${{ steps.name.outputs.first_match }}` been imported
33+
- name: Has `${{ steps.name.outputs.first_match }}` been imported?
3434
run: grep "import './features/${{ steps.name.outputs.first_match }}';" source/refined-github.ts -q
3535

36-
- name: Has `${{ steps.name.outputs.first_match }}` been documented
36+
- name: Has `${{ steps.name.outputs.first_match }}` been documented?
3737
run: grep '"${{ steps.name.outputs.first_match }}"' readme.md -q

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ Thanks for contributing! 🦋🙌
383383
- [](# "linkify-full-profile-readme-title") [Linkifies the readme text on profile pages.](https://user-images.githubusercontent.com/16872793/90910173-ebe4bf00-e3a4-11ea-8fc5-aea3d1a2e5e5.png)
384384
- [](# "convert-pr-to-draft-improvements") [Moves the "Convert PR to Draft" button to the mergeability box and adds visual feedback to its confirm button.](https://user-images.githubusercontent.com/1402241/95644892-885f3f80-0a7f-11eb-8428-8e0fb0c8dfa5.gif)
385385
- [](# "clean-header-search-field") [Clears duplicate queries in the header search field.](https://user-images.githubusercontent.com/1402241/114177338-7c890300-9966-11eb-83a3-a711a76fae99.png)
386+
- [](# "cancel-wiki-edit-button") [Adds a cancel button when editing wiki pages.](https://user-images.githubusercontent.com/44045911/122222158-93a71c80-cee4-11eb-9a43-98457cac93df.png)
386387

387388
<!-- Refer to style guide above. Keep this message between sections. -->
388389

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'dom-chef';
2+
import elementReady from 'element-ready';
3+
import * as pageDetect from 'github-url-detection';
4+
5+
import features from '.';
6+
7+
async function init(): Promise<void> {
8+
const submitButton = await elementReady('button#gollum-editor-submit');
9+
submitButton!.before(
10+
<a
11+
className="flex-auto btn btn-danger float-left text-center mr-1"
12+
href={submitButton!.form!.action}
13+
>
14+
Cancel
15+
</a>
16+
);
17+
}
18+
19+
void features.add(__filebasename, {
20+
include: [
21+
pageDetect.isEditingWikiPage,
22+
pageDetect.isNewWikiPage
23+
],
24+
awaitDomReady: false,
25+
init
26+
});

source/refined-github.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ import './features/avoid-accidental-submissions';
219219
import './features/delete-review-comments-faster';
220220
import './features/no-useless-split-diff-view';
221221
import './features/list-pr-for-branch';
222+
import './features/cancel-wiki-edit-button';
222223

223224
// Add global for easier debugging
224225
(window as any).select = select;

0 commit comments

Comments
 (0)