summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contributing.md2
-rw-r--r--source/features/submit-review-as-single-comment.tsx9
-rw-r--r--source/libs/utils.ts29
-rw-r--r--source/manifest.json4
-rw-r--r--source/refined-github.css (renamed from source/content.css)0
-rw-r--r--source/refined-github.ts (renamed from source/content.ts)2
-rw-r--r--webpack.config.ts2
7 files changed, 20 insertions, 28 deletions
diff --git a/contributing.md b/contributing.md
index 7b01ced8..1d98dd58 100644
--- a/contributing.md
+++ b/contributing.md
@@ -8,7 +8,7 @@ Suggestions and pull requests are highly encouraged! Have a look at the [open is
- The extension can be loaded into Chrome or Firefox manually ([See notes below](#loading-into-the-browser))
- [JSX](https://reactjs.org/docs/introducing-jsx.html) is used to create DOM elements.
- All the [latest DOM APIs](https://github.com/WebReflection/dom4#features) and JavaScript features are available because the extension only has to work in the latest Chrome and Firefox. 🎉
-- Each JavaScript feature lives in its own file under [`source/features`](https://github.com/sindresorhus/refined-github/tree/master/source/features) and it's imported in [`source/content.ts`](https://github.com/sindresorhus/refined-github/blob/master/source/content.ts).
+- Each JavaScript feature lives in its own file under [`source/features`](https://github.com/sindresorhus/refined-github/tree/master/source/features) and it's imported in [`source/refined-github.ts`](https://github.com/sindresorhus/refined-github/blob/master/source/refined-github.ts).
- Some GitHub pages are loaded via AJAX/PJAX, so some features use the special `onAjaxedPages` loader (see it as a custom "on DOM ready").
- See what a _feature_ [looks like](https://github.com/sindresorhus/refined-github/blob/master/source/features/user-profile-follower-badge.tsx).
- Follow [the styleguide](https://github.com/sindresorhus/refined-github/blob/master/readme.md#L100) that appears in the Readme's source to write readable descriptions.
diff --git a/source/features/submit-review-as-single-comment.tsx b/source/features/submit-review-as-single-comment.tsx
index e2b44c05..f2668188 100644
--- a/source/features/submit-review-as-single-comment.tsx
+++ b/source/features/submit-review-as-single-comment.tsx
@@ -5,7 +5,7 @@ import insertText from 'insert-text-textarea';
import delegate, {DelegateEvent} from 'delegate-it';
import features from '../libs/features';
import {observeOneMutation} from '../libs/simplified-element-observer';
-import {reportBug} from '../libs/utils';
+import {logError} from '../libs/utils';
import oneEvent from '../libs/one-event';
const pendingSelector = '.timeline-comment-label.is-pending';
@@ -54,7 +54,8 @@ async function handleSubmitSingle(event: DelegateEvent): Promise<void> {
const commentContainer = event.delegateTarget.closest('.js-comment')!;
const commentText = select<HTMLTextAreaElement>('[name="pull_request_review_comment[body]"]', commentContainer)!.value;
if (!commentText) {
- reportBug(__featureName__, 'comment not found');
+ alert('Error: Comment not found and not submitted. More info in the console.');
+ logError(__featureName__, 'Comment not found');
return;
}
@@ -93,10 +94,10 @@ async function handleSubmitSingle(event: DelegateEvent): Promise<void> {
commentForm.hidden = false;
// Place comment in console to allow recovery
+ alert('There was an error sending the comment. More info in the console.');
console.log('You were trying to sending this comment:');
console.log(commentText);
- reportBug(__featureName__, 'there was an error sending the comment');
- console.error(error);
+ logError(__featureName__, error);
}
}
diff --git a/source/libs/utils.ts b/source/libs/utils.ts
index 38d4b6b9..68ff552b 100644
--- a/source/libs/utils.ts
+++ b/source/libs/utils.ts
@@ -8,14 +8,16 @@ export function logError(featureName: typeof __featureName__, error: Error | str
const message = typeof error === 'string' ? error : error.message;
// Don't change this to `throw Error` because Firefox doesn't show extensions' errors in the console.
// Use `return` after calling this function.
- console.error(`❌ Refined GitHub: feature \`${featureName}\`\n\n`, error, ...extras, stripIndent(`
-
- Search for open issues:
- https://github.com/sindresorhus/refined-github/issues?q=is%3Aissue+${encodeURIComponent(message)}
-
- or open a new one:
- https://github.com/sindresorhus/refined-github/issues/new?labels=bug&template=bug_report.md&title=${encodeURIComponent(`\`${featureName}\`: ${message}`)}
- `));
+ console.error(
+ `❌ Refined GitHub → ${featureName} →`,
+ error,
+ ...extras,
+ stripIndent(`
+ Search issue: https://github.com/sindresorhus/refined-github/issues?q=is%3Aissue+${encodeURIComponent(message)}
+
+ Open an issue: https://github.com/sindresorhus/refined-github/issues/new?labels=bug&template=bug_report.md&title=${encodeURIComponent(`\`${featureName}\`: ${message}`)}
+ `)
+ );
}
export const getUsername = onetime(() => select('meta[name="user-login"]')!.getAttribute('content')!);
@@ -156,17 +158,6 @@ export async function poll<T>(callback: () => T, frequency: number): Promise<T>
});
}
-// TODO: Merge this with `logError`
-export function reportBug(featureName: string, bugName: string): void {
- alert(`Refined GitHub: ${bugName}. Can you report this issue? You’ll find more information in the console.`);
- const issuesUrl = new URL('https://github.com/sindresorhus/refined-github/issues');
- const newIssueUrl = new URL('https://github.com/sindresorhus/refined-github/new?labels=bug&template=bug_report.md');
- issuesUrl.searchParams.set('q', `is:issue ${featureName}`);
- newIssueUrl.searchParams.set('title', `\`${featureName}\` ${bugName}`);
- console.log('Find existing issues:\n' + String(issuesUrl));
- console.log('Open new issue:\n' + String(newIssueUrl));
-}
-
/**
* Prepend `:scope >` to a single or group of css selectors.
* @param {string} selector A css selector.
diff --git a/source/manifest.json b/source/manifest.json
index 7b91f757..e093b04f 100644
--- a/source/manifest.json
+++ b/source/manifest.json
@@ -46,11 +46,11 @@
"https://gist.github.com/*"
],
"css": [
- "content.css"
+ "refined-github.css"
],
"js": [
"browser-polyfill.min.js",
- "content.js"
+ "refined-github.js"
]
}
],
diff --git a/source/content.css b/source/refined-github.css
index 8d7a5592..8d7a5592 100644
--- a/source/content.css
+++ b/source/refined-github.css
diff --git a/source/content.ts b/source/refined-github.ts
index 08d28986..91a90fd1 100644
--- a/source/content.ts
+++ b/source/refined-github.ts
@@ -1,6 +1,6 @@
import select from 'select-dom';
-import './content.css';
+import './refined-github.css';
import './features/scrollable-code-and-blockquote.css';
import './features/center-reactions-popup.css';
import './features/widen-search-field.css';
diff --git a/webpack.config.ts b/webpack.config.ts
index 224d3606..00eb6c69 100644
--- a/webpack.config.ts
+++ b/webpack.config.ts
@@ -50,7 +50,7 @@ const config: Configuration = {
builtAt: true
},
entry: {
- content: './source/content',
+ 'refined-github': './source/refined-github',
background: './source/background',
options: './source/options',
'resolve-conflicts': './source/resolve-conflicts'