New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add prevent-pr-commit-link-loss
feature
#3085
Conversation
Thank you for the PR! You can simplify this to a single |
I'll try and implement it with delegate, never used it before 👍 |
Update @fregante , let me know what you think. Cheers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much shorter! Here’s a few more notes
source/features/stop-redirecting-commit-pull-url-to-commit-url.tsx
Outdated
Show resolved
Hide resolved
source/features/stop-redirecting-commit-pull-url-to-commit-url.tsx
Outdated
Show resolved
Hide resolved
source/features/stop-redirecting-commit-pull-url-to-commit-url.tsx
Outdated
Show resolved
Hide resolved
source/features/stop-redirecting-commit-pull-url-to-commit-url.tsx
Outdated
Show resolved
Hide resolved
source/features/stop-redirecting-commit-pull-url-to-commit-url.tsx
Outdated
Show resolved
Hide resolved
source/features/stop-redirecting-commit-pull-url-to-commit-url.tsx
Outdated
Show resolved
Hide resolved
….tsx Co-authored-by: Fregante <opensource@bfred.it>
….tsx Co-authored-by: Fregante <opensource@bfred.it>
….tsx Co-authored-by: Fregante <opensource@bfred.it>
….tsx Co-authored-by: Fregante <opensource@bfred.it>
@fregante Thanks a lot for the help. Pushed all suggestions and a few tests. |
source/features/stop-redirecting-commit-pull-url-to-commit-url.tsx
Outdated
Show resolved
Hide resolved
….tsx Co-authored-by: Fregante <opensource@bfred.it>
Co-authored-by: Fregante <opensource@bfred.it>
On further thought, this really cannot be done automatically. Proper replacement requires a Markdown parser and we can't import that. If you can, I suggest reimplementing it as an actionable warning instead, so the user can make an informed decision. Here's the code for this alert, but it needs more work: select('.form-actions').prepend(
<div class="flash flash-warn mb-2">
<AlertIcon /> Your PR Commit link may be <a href="https://github.com/sindresorhus/refined-github/issues/2327">misinterpreted by GitHub.</a>
<button type="button" class="btn btn-sm primary flash-action">Fix link</button>
</div>
); |
Thanks for all the help @fregante Is there anything pending? |
@max-arias this only works for comments. Can you make sure this also works when opening an issue or PR? |
@max-arias I once started working on it and dont have time to continue. @@ -27,7 +27,11 @@ function updateUI(event: delegate.Event<InputEvent, HTMLTextAreaElement>): void
const field = event.delegateTarget;
if (prCommitRegex.test(field.value)) {
- select('.form-actions', field.form!)!.prepend(getUI(field));
+ if (pageDetect.hasComments()) {
+ select('.form-actions', field.form!)!.prepend(getUI(field));
+ } else {
+ select('#new_issue .flex-items-center, #new_pull_request .flex-justify-end')!.before(<div className="form-actions">
{getUI(field)} </div>);
+ }
} else {
getUI(field).remove();
}
@@ -44,7 +48,7 @@ features.add({
screenshot: 'https://user-images.githubusercontent.com/1402241/82131169-93fd5180-97d2-11ea-9695-97051c55091f.gif'
}, {
include: [
- pageDetect.hasComments
+ pageDetect.hasRichTextEditor
],
init
}); |
Thanks @yakov116 . Little busy during the week, I'll see if I can put a few hours this weekend. Cheers. |
Closes: #2327
Note: I had to rename the URL to something other than the URL, otherwise Github replaces the URL anyways with the commit URL in the markdown 🤷♂️ .
IssueHunt Summary
Referenced issues
This pull request has been submitted to: