diff options
-rw-r--r-- | source/features/rgh-improve-new-issue-form.tsx | 10 | ||||
-rw-r--r-- | source/features/rgh-welcome-issue.tsx | 6 | ||||
-rw-r--r-- | source/helpers/open-options.ts | 4 |
3 files changed, 15 insertions, 5 deletions
diff --git a/source/features/rgh-improve-new-issue-form.tsx b/source/features/rgh-improve-new-issue-form.tsx index 613acb41..aa86dd0d 100644 --- a/source/features/rgh-improve-new-issue-form.tsx +++ b/source/features/rgh-improve-new-issue-form.tsx @@ -3,7 +3,9 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import features from '.'; +import openOptions from '../helpers/open-options'; import clearCacheHandler from '../helpers/clear-cache-handler'; +import {expectTokenScope} from '../github-helpers/api'; import {isRefinedGitHubRepo} from '../github-helpers'; function init(): void { @@ -18,6 +20,14 @@ function init(): void { Clear cache </button>, ); + void expectTokenScope('repo').catch(() => { + select('#issue_body_template_name')!.before( + <div className="flash flash-warn m-2"> + Your Personal Access Token is either missing, incorrect or expired. Some Refined GitHub features will not work without it.<br/> + You can update it <a href="#" onClick={openOptions as unknown as React.MouseEventHandler}>in the options</a>. + </div>, + ); + }); } void features.add(import.meta.url, { diff --git a/source/features/rgh-welcome-issue.tsx b/source/features/rgh-welcome-issue.tsx index d2b20b70..6dae5826 100644 --- a/source/features/rgh-welcome-issue.tsx +++ b/source/features/rgh-welcome-issue.tsx @@ -3,6 +3,7 @@ import select from 'select-dom'; import delegate from 'delegate-it'; import features from '.'; +import openOptions from '../helpers/open-options'; import {getRghIssueUrl} from '../helpers/rgh-issue-link'; /** @@ -20,11 +21,6 @@ This is done so that when editing that issue we're aware that something is up wi const issueUrl = getRghIssueUrl(3543); const placeholdersSelector = 'a[href="#rgh-linkify-welcome-issue"]'; -function openOptions(event: Event): void { - event.preventDefault(); - void browser.runtime.sendMessage({openOptionsPage: true}); -} - function init(): void { const [opening, closing] = select.all<HTMLAnchorElement>(placeholdersSelector); closing.remove(); diff --git a/source/helpers/open-options.ts b/source/helpers/open-options.ts new file mode 100644 index 00000000..66acb4d7 --- /dev/null +++ b/source/helpers/open-options.ts @@ -0,0 +1,4 @@ +export default function openOptions(event: Event): void { + event.preventDefault(); + void browser.runtime.sendMessage({openOptionsPage: true}); +} |