import $ from 'jquery' ;
import {
initRepoIssueBranchSelect , initRepoIssueCodeCommentCancel , initRepoIssueCommentDelete ,
initRepoIssueComments , initRepoIssueDependencyDelete , initRepoIssueReferenceIssue ,
initRepoIssueTitleEdit , initRepoIssueWipToggle ,
initRepoPullRequestUpdate , updateIssuesMeta , handleReply , initIssueTemplateCommentEditors , initSingleCommentEditor ,
} from './repo-issue.js' ;
import { initUnicodeEscapeButton } from './repo-unicode-escape.js' ;
import { svg } from '../svg.js' ;
import { htmlEscape } from 'escape-goat' ;
import { initRepoBranchTagSelector } from '../components/RepoBranchTagSelector.vue' ;
import {
initRepoCloneLink , initRepoCommonBranchOrTagDropdown , initRepoCommonFilterSearchDropdown ,
} from './repo-common.js' ;
import { initCitationFileCopyContent } from './citation.js' ;
import { initCompLabelEdit } from './comp/LabelEdit.js' ;
import { initRepoDiffConversationNav } from './repo-diff.js' ;
import { createDropzone } from './dropzone.js' ;
import { initCommentContent , initMarkupContent } from '../markup/content.js' ;
import { initCompReactionSelector } from './comp/ReactionSelector.js' ;
import { initRepoSettingBranches } from './repo-settings.js' ;
import { initRepoPullRequestMergeForm } from './repo-issue-pr-form.js' ;
import { initRepoPullRequestCommitStatus } from './repo-issue-pr-status.js' ;
import { hideElem , showElem } from '../utils/dom.js' ;
import { getComboMarkdownEditor , initComboMarkdownEditor } from './comp/ComboMarkdownEditor.js' ;
Append `(comment)` when a link points at a comment rather than the whole issue (#23734)
Close #23671
For the feature mentioned above, this PR append ' (comment)' to the
rendered html if it is a hashcomment.
After the PR, type in the following
```
pull request from other repo:
http://localhost:3000/testOrg/testOrgRepo/pulls/2
pull request from this repo:
http://localhost:3000/aaa/testA/pulls/2
issue comment from this repo:
http://localhost:3000/aaa/testA/issues/1#issuecomment-18
http://localhost:3000/aaa/testA/pulls/2#issue-9
issue comment from other repo:
http://localhost:3000/testOrg/testOrgRepo/pulls/2#issuecomment-24
http://localhost:3000/testOrg/testOrgRepo/pulls/2#issue
```
Gives:
<img width="687" alt="截屏2023-03-27 13 53 06"
src="https://user-images.githubusercontent.com/17645053/227852387-2b218e0d-3468-4d90-ad81-d702ddd17fd2.png">
Other than the above feature, this PR also includes two other changes:
1 Right now, the render of links from file changed tab in pull request
might not be very proper, for example, if type in the following. (not
sure if this is an issue or design, if not an issue, I will revert the
changes). example on
[try.gitea.io](https://try.gitea.io/HesterG/testrepo/pulls/1)
```
https://try.gitea.io/HesterG/testrepo/pulls/1/files#issuecomment-162725
https://try.gitea.io/HesterG/testrepo/pulls/1/files
```
it will render the following
<img width="899" alt="截屏2023-03-24 15 41 37"
src="https://user-images.githubusercontent.com/17645053/227456117-5eccedb7-9118-4540-929d-aee9a76de852.png">
In this PR, skip processing the link into a ref issue if it is a link
from files changed tab in pull request
After:
type in following
```
hash comment on files changed tab:
http://localhost:3000/testOrg/testOrgRepo/pulls/2/files#issuecomment-24
files changed link:
http://localhost:3000/testOrg/testOrgRepo/pulls/2/files
```
Gives
<img width="708" alt="截屏2023-03-27 22 09 02"
src="https://user-images.githubusercontent.com/17645053/227964273-5dc06c50-3713-489c-b05d-d95367d0ab0f.png">
2 Right now, after editing the comment area, there will not be tippys
attached to `ref-issue`; and no tippy attached on preview as well.
example:
https://user-images.githubusercontent.com/17645053/227850540-5ae34e2d-b1d7-4d0d-9726-7701bf825d1f.mov
In this PR, in frontend, make sure tippy is added after editing the
comment, and to the comment on preview tab
After:
https://user-images.githubusercontent.com/17645053/227853777-06f56b4c-1148-467c-b6f7-f79418e67504.mov
2 years ago
import { attachRefIssueContextPopup } from './contextpopup.js' ;
import { POST , GET } from '../modules/fetch.js' ;
const { csrfToken } = window . config ;
// if there are draft comments, confirm before reloading, to avoid losing comments
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years ago
function reloadConfirmDraftComment ( ) {
const commentTextareas = [
document . querySelector ( '.edit-content-zone:not(.gt-hidden) textarea' ) ,
document . querySelector ( '#comment-form textarea' ) ,
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years ago
] ;
for ( const textarea of commentTextareas ) {
// Most users won't feel too sad if they lose a comment with 10 chars, they can re-type these in seconds.
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years ago
// But if they have typed more (like 50) chars and the comment is lost, they will be very unhappy.
if ( textarea && textarea . value . trim ( ) . length > 10 ) {
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years ago
textarea . parentElement . scrollIntoView ( ) ;
if ( ! window . confirm ( 'Page will be reloaded, but there are draft comments. Continuing to reload will discard the comments. Continue?' ) ) {
return ;
}
break ;
}
}
window . location . reload ( ) ;
}
export function initRepoCommentForm ( ) {
const $commentForm = $ ( '.comment.form' ) ;
if ( $commentForm . length === 0 ) {
return ;
}
if ( $commentForm . find ( '.field.combo-editor-dropzone' ) . length ) {
// at the moment, if a form has multiple combo-markdown-editors, it must be an issue template form
initIssueTemplateCommentEditors ( $commentForm ) ;
} else if ( $commentForm . find ( '.combo-markdown-editor' ) . length ) {
// it's quite unclear about the "comment form" elements, sometimes it's for issue comment, sometimes it's for file editor/uploader message
initSingleCommentEditor ( $commentForm ) ;
}
function initBranchSelector ( ) {
const $selectBranch = $ ( '.ui.select-branch' ) ;
const $branchMenu = $selectBranch . find ( '.reference-list-menu' ) ;
const $isNewIssue = $branchMenu . hasClass ( 'new-issue' ) ;
$branchMenu . find ( '.item:not(.no-select)' ) . on ( 'click' , async function ( ) {
const selectedValue = $ ( this ) . data ( 'id' ) ;
const editMode = $ ( '#editing_mode' ) . val ( ) ;
$ ( $ ( this ) . data ( 'id-selector' ) ) . val ( selectedValue ) ;
if ( $isNewIssue ) {
$selectBranch . find ( '.ui .branch-name' ) . text ( $ ( this ) . data ( 'name' ) ) ;
return ;
}
if ( editMode === 'true' ) {
const $form = $ ( '#update_issueref_form' ) ;
const params = new URLSearchParams ( ) ;
params . append ( 'ref' , selectedValue ) ;
try {
await POST ( $form . attr ( 'action' ) , { data : params } ) ;
window . location . reload ( ) ;
} catch ( error ) {
console . error ( error ) ;
}
} else if ( editMode === '' ) {
$selectBranch . find ( '.ui .branch-name' ) . text ( selectedValue ) ;
}
} ) ;
$selectBranch . find ( '.reference.column' ) . on ( 'click' , function ( ) {
hideElem ( $selectBranch . find ( '.scrolling.reference-list-menu' ) ) ;
$selectBranch . find ( '.reference .text' ) . removeClass ( 'black' ) ;
showElem ( $ ( $ ( this ) . data ( 'target' ) ) ) ;
$ ( this ) . find ( '.text' ) . addClass ( 'black' ) ;
return false ;
} ) ;
}
initBranchSelector ( ) ;
// List submits
function initListSubmits ( selector , outerSelector ) {
const $list = $ ( ` .ui. ${ outerSelector } .list ` ) ;
const $noSelect = $list . find ( '.no-select' ) ;
const $listMenu = $ ( ` . ${ selector } .menu ` ) ;
let hasUpdateAction = $listMenu . data ( 'action' ) === 'update' ;
const items = { } ;
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years ago
$ ( ` . ${ selector } ` ) . dropdown ( {
'action' : 'nothing' , // do not hide the menu if user presses Enter
fullTextSearch : 'exact' ,
async onHide ( ) {
hasUpdateAction = $listMenu . data ( 'action' ) === 'update' ; // Update the var
if ( hasUpdateAction ) {
// TODO: Add batch functionality and make this 1 network request.
const itemEntries = Object . entries ( items ) ;
for ( const [ elementId , item ] of itemEntries ) {
await updateIssuesMeta (
item [ 'update-url' ] ,
item . action ,
item [ 'issue-id' ] ,
elementId ,
) ;
}
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.
* Close #22607
* Close #20727
Also:
* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329
### The `Enter` support
Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.
After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)
This is only a quick patch, the UX is still not perfect, but it's much
better than before.
### The `confirm` before reloading
And more fixes for the `reload` problem, the new behaviors:
* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.
That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.
Screenshot of the confirm dialog:
<details>
![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)
</details>
---------
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years ago
if ( itemEntries . length ) {
reloadConfirmDraftComment ( ) ;
}
}
} ,
} ) ;
$listMenu . find ( '.item:not(.no-select)' ) . on ( 'click' , function ( e ) {
e . preventDefault ( ) ;
if ( $ ( this ) . hasClass ( 'ban-change' ) ) {
return false ;
}
hasUpdateAction = $listMenu . data ( 'action' ) === 'update' ; // Update the var
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2 years ago
const $clickedItem = $ ( this ) ;
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2 years ago
const scope = $ ( this ) . attr ( 'data-scope' ) ;
$ ( this ) . parent ( ) . find ( '.item' ) . each ( function ( ) {
if ( scope ) {
// Enable only clicked item for scoped labels
if ( $ ( this ) . attr ( 'data-scope' ) !== scope ) {
return true ;
}
if ( ! $ ( this ) . is ( $clickedItem ) && ! $ ( this ) . hasClass ( 'checked' ) ) {
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2 years ago
return true ;
}
} else if ( ! $ ( this ) . is ( $clickedItem ) ) {
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2 years ago
// Toggle for other labels
return true ;
}
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2 years ago
if ( $ ( this ) . hasClass ( 'checked' ) ) {
$ ( this ) . removeClass ( 'checked' ) ;
$ ( this ) . find ( '.octicon-check' ) . addClass ( 'tw-invisible' ) ;
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2 years ago
if ( hasUpdateAction ) {
if ( ! ( $ ( this ) . data ( 'id' ) in items ) ) {
items [ $ ( this ) . data ( 'id' ) ] = {
'update-url' : $listMenu . data ( 'update-url' ) ,
action : 'detach' ,
'issue-id' : $listMenu . data ( 'issue-id' ) ,
} ;
} else {
delete items [ $ ( this ) . data ( 'id' ) ] ;
}
}
} else {
$ ( this ) . addClass ( 'checked' ) ;
$ ( this ) . find ( '.octicon-check' ) . removeClass ( 'tw-invisible' ) ;
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2 years ago
if ( hasUpdateAction ) {
if ( ! ( $ ( this ) . data ( 'id' ) in items ) ) {
items [ $ ( this ) . data ( 'id' ) ] = {
'update-url' : $listMenu . data ( 'update-url' ) ,
action : 'attach' ,
'issue-id' : $listMenu . data ( 'issue-id' ) ,
} ;
} else {
delete items [ $ ( this ) . data ( 'id' ) ] ;
}
}
}
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2 years ago
} ) ;
// TODO: Which thing should be done for choosing review requests
// to make chosen items be shown on time here?
if ( selector === 'select-reviewers-modify' || selector === 'select-assignees-modify' ) {
return false ;
}
const listIds = [ ] ;
$ ( this ) . parent ( ) . find ( '.item' ) . each ( function ( ) {
if ( $ ( this ) . hasClass ( 'checked' ) ) {
listIds . push ( $ ( this ) . data ( 'id' ) ) ;
$ ( $ ( this ) . data ( 'id-selector' ) ) . removeClass ( 'gt-hidden' ) ;
} else {
$ ( $ ( this ) . data ( 'id-selector' ) ) . addClass ( 'gt-hidden' ) ;
}
} ) ;
if ( listIds . length === 0 ) {
$noSelect . removeClass ( 'gt-hidden' ) ;
} else {
$noSelect . addClass ( 'gt-hidden' ) ;
}
$ ( $ ( this ) . parent ( ) . data ( 'id' ) ) . val ( listIds . join ( ',' ) ) ;
return false ;
} ) ;
$listMenu . find ( '.no-select.item' ) . on ( 'click' , function ( e ) {
e . preventDefault ( ) ;
if ( hasUpdateAction ) {
( async ( ) => {
await updateIssuesMeta (
$listMenu . data ( 'update-url' ) ,
'clear' ,
$listMenu . data ( 'issue-id' ) ,
'' ,
) ;
reloadConfirmDraftComment ( ) ;
} ) ( ) ;
}
$ ( this ) . parent ( ) . find ( '.item' ) . each ( function ( ) {
$ ( this ) . removeClass ( 'checked' ) ;
$ ( this ) . find ( '.octicon-check' ) . addClass ( 'tw-invisible' ) ;
} ) ;
if ( selector === 'select-reviewers-modify' || selector === 'select-assignees-modify' ) {
return false ;
}
$list . find ( '.item' ) . each ( function ( ) {
$ ( this ) . addClass ( 'gt-hidden' ) ;
} ) ;
$noSelect . removeClass ( 'gt-hidden' ) ;
$ ( $ ( this ) . parent ( ) . data ( 'id' ) ) . val ( '' ) ;
} ) ;
}
// Init labels and assignees
initListSubmits ( 'select-label' , 'labels' ) ;
initListSubmits ( 'select-assignees' , 'assignees' ) ;
initListSubmits ( 'select-assignees-modify' , 'assignees' ) ;
initListSubmits ( 'select-reviewers-modify' , 'assignees' ) ;
function selectItem ( select _id , input _id ) {
const $menu = $ ( ` ${ select _id } .menu ` ) ;
const $list = $ ( ` .ui ${ select _id } .list ` ) ;
const hasUpdateAction = $menu . data ( 'action' ) === 'update' ;
$menu . find ( '.item:not(.no-select)' ) . on ( 'click' , function ( ) {
$ ( this ) . parent ( ) . find ( '.item' ) . each ( function ( ) {
$ ( this ) . removeClass ( 'selected active' ) ;
} ) ;
$ ( this ) . addClass ( 'selected active' ) ;
if ( hasUpdateAction ) {
( async ( ) => {
await updateIssuesMeta (
$menu . data ( 'update-url' ) ,
'' ,
$menu . data ( 'issue-id' ) ,
$ ( this ) . data ( 'id' ) ,
) ;
reloadConfirmDraftComment ( ) ;
} ) ( ) ;
}
let icon = '' ;
if ( input _id === '#milestone_id' ) {
icon = svg ( 'octicon-milestone' , 18 , 'gt-mr-3' ) ;
} else if ( input _id === '#project_id' ) {
icon = svg ( 'octicon-project' , 18 , 'gt-mr-3' ) ;
} else if ( input _id === '#assignee_id' ) {
icon = ` <img class="ui avatar image gt-mr-3" alt="avatar" src= ${ $ ( this ) . data ( 'avatar' ) } > ` ;
}
$list . find ( '.selected' ) . html ( `
< a class = "item muted sidebar-item-link" href = $ { $ ( this ) . data ( 'href' ) } >
$ { icon }
$ { htmlEscape ( $ ( this ) . text ( ) ) }
< / a >
` );
$ ( ` .ui ${ select _id } .list .no-select ` ) . addClass ( 'gt-hidden' ) ;
$ ( input _id ) . val ( $ ( this ) . data ( 'id' ) ) ;
} ) ;
$menu . find ( '.no-select.item' ) . on ( 'click' , function ( ) {
$ ( this ) . parent ( ) . find ( '.item:not(.no-select)' ) . each ( function ( ) {
$ ( this ) . removeClass ( 'selected active' ) ;
} ) ;
if ( hasUpdateAction ) {
( async ( ) => {
await updateIssuesMeta (
$menu . data ( 'update-url' ) ,
'' ,
$menu . data ( 'issue-id' ) ,
$ ( this ) . data ( 'id' ) ,
) ;
reloadConfirmDraftComment ( ) ;
} ) ( ) ;
}
$list . find ( '.selected' ) . html ( '' ) ;
$list . find ( '.no-select' ) . removeClass ( 'gt-hidden' ) ;
$ ( input _id ) . val ( '' ) ;
} ) ;
}
// Milestone, Assignee, Project
selectItem ( '.select-project' , '#project_id' ) ;
selectItem ( '.select-milestone' , '#milestone_id' ) ;
selectItem ( '.select-assignee' , '#assignee_id' ) ;
}
async function onEditContent ( event ) {
event . preventDefault ( ) ;
const $segment = $ ( this ) . closest ( '.header' ) . next ( ) ;
const $editContentZone = $segment . find ( '.edit-content-zone' ) ;
const $renderContent = $segment . find ( '.render-content' ) ;
const $rawContent = $segment . find ( '.raw-content' ) ;
let comboMarkdownEditor ;
const setupDropzone = async ( $dropzone ) => {
if ( $dropzone . length === 0 ) return null ;
let disableRemovedfileEvent = false ; // when resetting the dropzone (removeAllFiles), disable the "removedfile" event
let fileUuidDict = { } ; // to record: if a comment has been saved, then the uploaded files won't be deleted from server when clicking the Remove in the dropzone
const dz = await createDropzone ( $dropzone [ 0 ] , {
url : $dropzone . attr ( 'data-upload-url' ) ,
headers : { 'X-Csrf-Token' : csrfToken } ,
maxFiles : $dropzone . attr ( 'data-max-file' ) ,
maxFilesize : $dropzone . attr ( 'data-max-size' ) ,
acceptedFiles : ( [ '*/*' , '' ] . includes ( $dropzone . attr ( 'data-accepts' ) ) ) ? null : $dropzone . attr ( 'data-accepts' ) ,
addRemoveLinks : true ,
dictDefaultMessage : $dropzone . attr ( 'data-default-message' ) ,
dictInvalidFileType : $dropzone . attr ( 'data-invalid-input-type' ) ,
dictFileTooBig : $dropzone . attr ( 'data-file-too-big' ) ,
dictRemoveFile : $dropzone . attr ( 'data-remove-file' ) ,
timeout : 0 ,
thumbnailMethod : 'contain' ,
thumbnailWidth : 480 ,
thumbnailHeight : 480 ,
init ( ) {
this . on ( 'success' , ( file , data ) => {
file . uuid = data . uuid ;
fileUuidDict [ file . uuid ] = { submitted : false } ;
const $input = $ ( ` <input id=" ${ data . uuid } " name="files" type="hidden"> ` ) . val ( data . uuid ) ;
$dropzone . find ( '.files' ) . append ( $input ) ;
} ) ;
this . on ( 'removedfile' , async ( file ) => {
if ( disableRemovedfileEvent ) return ;
$ ( ` # ${ file . uuid } ` ) . remove ( ) ;
if ( $dropzone . attr ( 'data-remove-url' ) && ! fileUuidDict [ file . uuid ] . submitted ) {
try {
await POST ( $dropzone . attr ( 'data-remove-url' ) , { data : new URLSearchParams ( { file : file . uuid } ) } ) ;
} catch ( error ) {
console . error ( error ) ;
}
}
} ) ;
this . on ( 'submit' , ( ) => {
$ . each ( fileUuidDict , ( fileUuid ) => {
fileUuidDict [ fileUuid ] . submitted = true ;
} ) ;
} ) ;
this . on ( 'reload' , async ( ) => {
try {
const response = await GET ( $editContentZone . attr ( 'data-attachment-url' ) ) ;
const data = await response . json ( ) ;
// do not trigger the "removedfile" event, otherwise the attachments would be deleted from server
disableRemovedfileEvent = true ;
dz . removeAllFiles ( true ) ;
$dropzone . find ( '.files' ) . empty ( ) ;
fileUuidDict = { } ;
disableRemovedfileEvent = false ;
for ( const attachment of data ) {
const imgSrc = ` ${ $dropzone . attr ( 'data-link-url' ) } / ${ attachment . uuid } ` ;
dz . emit ( 'addedfile' , attachment ) ;
dz . emit ( 'thumbnail' , attachment , imgSrc ) ;
dz . emit ( 'complete' , attachment ) ;
dz . files . push ( attachment ) ;
fileUuidDict [ attachment . uuid ] = { submitted : true } ;
$dropzone . find ( ` img[src=' ${ imgSrc } '] ` ) [ 0 ] . style . maxWidth = '100%' ;
const $input = $ ( ` <input id=" ${ attachment . uuid } " name="files" type="hidden"> ` ) . val ( attachment . uuid ) ;
$dropzone . find ( '.files' ) . append ( $input ) ;
}
} catch ( error ) {
console . error ( error ) ;
}
} ) ;
} ,
} ) ;
dz . emit ( 'reload' ) ;
return dz ;
} ;
const cancelAndReset = ( dz ) => {
showElem ( $renderContent ) ;
hideElem ( $editContentZone ) ;
if ( dz ) {
dz . emit ( 'reload' ) ;
}
} ;
const saveAndRefresh = async ( dz ) => {
showElem ( $renderContent ) ;
hideElem ( $editContentZone ) ;
try {
const params = new URLSearchParams ( {
content : comboMarkdownEditor . value ( ) ,
context : $editContentZone . attr ( 'data-context' ) ,
} ) ;
for ( const file of dz . files ) params . append ( 'files[]' , file . uuid ) ;
const response = await POST ( $editContentZone . attr ( 'data-update-url' ) , { data : params } ) ;
const data = await response . json ( ) ;
if ( ! data . content ) {
$renderContent . html ( $ ( '#no-content' ) . html ( ) ) ;
$rawContent . text ( '' ) ;
} else {
$renderContent . html ( data . content ) ;
$rawContent . text ( comboMarkdownEditor . value ( ) ) ;
const $refIssues = $renderContent . find ( 'p .ref-issue' ) ;
attachRefIssueContextPopup ( $refIssues ) ;
}
const $content = $segment ;
if ( ! $content . find ( '.dropzone-attachments' ) . length ) {
if ( data . attachments !== '' ) {
$content [ 0 ] . insertAdjacentHTML ( 'beforeend' , data . attachments ) ;
}
} else if ( data . attachments === '' ) {
$content . find ( '.dropzone-attachments' ) . remove ( ) ;
} else {
$content . find ( '.dropzone-attachments' ) [ 0 ] . outerHTML = data . attachments ;
}
if ( dz ) {
dz . emit ( 'submit' ) ;
dz . emit ( 'reload' ) ;
}
initMarkupContent ( ) ;
initCommentContent ( ) ;
} catch ( error ) {
console . error ( error ) ;
}
} ;
if ( ! $editContentZone . html ( ) ) {
$editContentZone . html ( $ ( '#issue-comment-editor-template' ) . html ( ) ) ;
comboMarkdownEditor = await initComboMarkdownEditor ( $editContentZone . find ( '.combo-markdown-editor' ) ) ;
const $dropzone = $editContentZone . find ( '.dropzone' ) ;
const dz = await setupDropzone ( $dropzone ) ;
$editContentZone . find ( '.cancel.button' ) . on ( 'click' , ( e ) => {
e . preventDefault ( ) ;
cancelAndReset ( dz ) ;
} ) ;
$editContentZone . find ( '.save.button' ) . on ( 'click' , ( e ) => {
e . preventDefault ( ) ;
saveAndRefresh ( dz ) ;
} ) ;
} else {
comboMarkdownEditor = getComboMarkdownEditor ( $editContentZone . find ( '.combo-markdown-editor' ) ) ;
}
// Show write/preview tab and copy raw content as needed
showElem ( $editContentZone ) ;
hideElem ( $renderContent ) ;
if ( ! comboMarkdownEditor . value ( ) ) {
comboMarkdownEditor . value ( $rawContent . text ( ) ) ;
}
comboMarkdownEditor . focus ( ) ;
}
export function initRepository ( ) {
if ( $ ( '.page-content.repository' ) . length === 0 ) {
return ;
}
initRepoBranchTagSelector ( '.js-branch-tag-selector' ) ;
// Options
if ( $ ( '.repository.settings.options' ) . length > 0 ) {
// Enable or select internal/external wiki system and issue tracker.
$ ( '.enable-system' ) . on ( 'change' , function ( ) {
if ( this . checked ) {
$ ( $ ( this ) . data ( 'target' ) ) . removeClass ( 'disabled' ) ;
if ( ! $ ( this ) . data ( 'context' ) ) $ ( $ ( this ) . data ( 'context' ) ) . addClass ( 'disabled' ) ;
} else {
$ ( $ ( this ) . data ( 'target' ) ) . addClass ( 'disabled' ) ;
if ( ! $ ( this ) . data ( 'context' ) ) $ ( $ ( this ) . data ( 'context' ) ) . removeClass ( 'disabled' ) ;
}
} ) ;
$ ( '.enable-system-radio' ) . on ( 'change' , function ( ) {
if ( this . value === 'false' ) {
$ ( $ ( this ) . data ( 'target' ) ) . addClass ( 'disabled' ) ;
if ( $ ( this ) . data ( 'context' ) !== undefined ) $ ( $ ( this ) . data ( 'context' ) ) . removeClass ( 'disabled' ) ;
} else if ( this . value === 'true' ) {
$ ( $ ( this ) . data ( 'target' ) ) . removeClass ( 'disabled' ) ;
if ( $ ( this ) . data ( 'context' ) !== undefined ) $ ( $ ( this ) . data ( 'context' ) ) . addClass ( 'disabled' ) ;
}
} ) ;
const $trackerIssueStyleRadios = $ ( '.js-tracker-issue-style' ) ;
$trackerIssueStyleRadios . on ( 'change input' , ( ) => {
const checkedVal = $trackerIssueStyleRadios . filter ( ':checked' ) . val ( ) ;
$ ( '#tracker-issue-style-regex-box' ) . toggleClass ( 'disabled' , checkedVal !== 'regexp' ) ;
} ) ;
}
// Labels
initCompLabelEdit ( '.repository.labels' ) ;
// Milestones
if ( $ ( '.repository.new.milestone' ) . length > 0 ) {
$ ( '#clear-date' ) . on ( 'click' , ( ) => {
$ ( '#deadline' ) . val ( '' ) ;
return false ;
} ) ;
}
// Repo Creation
if ( $ ( '.repository.new.repo' ) . length > 0 ) {
$ ( 'input[name="gitignores"], input[name="license"]' ) . on ( 'change' , ( ) => {
const gitignores = $ ( 'input[name="gitignores"]' ) . val ( ) ;
const license = $ ( 'input[name="license"]' ) . val ( ) ;
if ( gitignores || license ) {
document . querySelector ( 'input[name="auto_init"]' ) . checked = true ;
}
} ) ;
}
// Compare or pull request
const $repoDiff = $ ( '.repository.diff' ) ;
if ( $repoDiff . length ) {
initRepoCommonBranchOrTagDropdown ( '.choose.branch .dropdown' ) ;
initRepoCommonFilterSearchDropdown ( '.choose.branch .dropdown' ) ;
}
initRepoCloneLink ( ) ;
initCitationFileCopyContent ( ) ;
initRepoSettingBranches ( ) ;
// Issues
if ( $ ( '.repository.view.issue' ) . length > 0 ) {
initRepoIssueCommentEdit ( ) ;
initRepoIssueBranchSelect ( ) ;
initRepoIssueTitleEdit ( ) ;
initRepoIssueWipToggle ( ) ;
initRepoIssueComments ( ) ;
initRepoDiffConversationNav ( ) ;
initRepoIssueReferenceIssue ( ) ;
initRepoIssueCommentDelete ( ) ;
initRepoIssueDependencyDelete ( ) ;
initRepoIssueCodeCommentCancel ( ) ;
initRepoPullRequestUpdate ( ) ;
initCompReactionSelector ( $ ( document ) ) ;
initRepoPullRequestMergeForm ( ) ;
initRepoPullRequestCommitStatus ( ) ;
}
// Pull request
const $repoComparePull = $ ( '.repository.compare.pull' ) ;
if ( $repoComparePull . length > 0 ) {
// show pull request form
$repoComparePull . find ( 'button.show-form' ) . on ( 'click' , function ( e ) {
e . preventDefault ( ) ;
hideElem ( $ ( this ) . parent ( ) ) ;
const $form = $repoComparePull . find ( '.pullrequest-form' ) ;
showElem ( $form ) ;
} ) ;
}
initUnicodeEscapeButton ( ) ;
}
function initRepoIssueCommentEdit ( ) {
// Edit issue or comment content
$ ( document ) . on ( 'click' , '.edit-content' , onEditContent ) ;
// Quote reply
$ ( document ) . on ( 'click' , '.quote-reply' , async function ( event ) {
event . preventDefault ( ) ;
const target = $ ( this ) . data ( 'target' ) ;
const quote = $ ( ` # ${ target } ` ) . text ( ) . replace ( /\n/g , '\n> ' ) ;
const content = ` > ${ quote } \n \n ` ;
let editor ;
if ( $ ( this ) . hasClass ( 'quote-reply-diff' ) ) {
const $replyBtn = $ ( this ) . closest ( '.comment-code-cloud' ) . find ( 'button.comment-form-reply' ) ;
editor = await handleReply ( $replyBtn ) ;
} else {
// for normal issue/comment page
editor = getComboMarkdownEditor ( $ ( '#comment-form .combo-markdown-editor' ) ) ;
}
if ( editor ) {
if ( editor . value ( ) ) {
editor . value ( ` ${ editor . value ( ) } \n \n ${ content } ` ) ;
} else {
editor . value ( content ) ;
}
editor . focus ( ) ;
editor . moveCursorToEnd ( ) ;
}
} ) ;
}