2022-01-28 21:00:11 +00:00
|
|
|
import $ from 'jquery';
|
2021-10-16 17:28:04 +00:00
|
|
|
import {
|
2022-12-23 16:03:11 +00:00
|
|
|
initRepoIssueBranchSelect, initRepoIssueCodeCommentCancel, initRepoIssueCommentDelete,
|
|
|
|
initRepoIssueComments, initRepoIssueDependencyDelete, initRepoIssueReferenceIssue,
|
2023-04-03 10:06:57 +00:00
|
|
|
initRepoIssueTitleEdit, initRepoIssueWipToggle,
|
2024-04-11 18:22:59 +00:00
|
|
|
initRepoPullRequestUpdate, updateIssuesMeta, initIssueTemplateCommentEditors, initSingleCommentEditor,
|
2024-07-07 15:32:30 +00:00
|
|
|
} from './repo-issue.ts';
|
|
|
|
import {initUnicodeEscapeButton} from './repo-unicode-escape.ts';
|
|
|
|
import {svg} from '../svg.ts';
|
2021-10-16 17:28:04 +00:00
|
|
|
import {htmlEscape} from 'escape-goat';
|
2023-03-14 09:51:20 +00:00
|
|
|
import {initRepoBranchTagSelector} from '../components/RepoBranchTagSelector.vue';
|
2021-10-16 17:28:04 +00:00
|
|
|
import {
|
2022-12-23 16:03:11 +00:00
|
|
|
initRepoCloneLink, initRepoCommonBranchOrTagDropdown, initRepoCommonFilterSearchDropdown,
|
2024-07-07 15:32:30 +00:00
|
|
|
} from './repo-common.ts';
|
|
|
|
import {initCitationFileCopyContent} from './citation.ts';
|
|
|
|
import {initCompLabelEdit} from './comp/LabelEdit.ts';
|
|
|
|
import {initRepoDiffConversationNav} from './repo-diff.ts';
|
|
|
|
import {initCompReactionSelector} from './comp/ReactionSelector.ts';
|
|
|
|
import {initRepoSettingBranches} from './repo-settings.ts';
|
|
|
|
import {initRepoPullRequestMergeForm} from './repo-issue-pr-form.ts';
|
|
|
|
import {initRepoPullRequestCommitStatus} from './repo-issue-pr-status.ts';
|
|
|
|
import {hideElem, queryElemChildren, showElem} from '../utils/dom.ts';
|
|
|
|
import {POST} from '../modules/fetch.ts';
|
|
|
|
import {initRepoIssueCommentEdit} from './repo-issue-edit.ts';
|
2021-10-16 17:28:04 +00:00
|
|
|
|
2023-04-03 10:06:57 +00:00
|
|
|
// 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>
2023-02-24 01:26:27 +00:00
|
|
|
function reloadConfirmDraftComment() {
|
|
|
|
const commentTextareas = [
|
2024-03-24 18:23:38 +00:00
|
|
|
document.querySelector('.edit-content-zone:not(.tw-hidden) textarea'),
|
2023-04-03 10:06:57 +00:00
|
|
|
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>
2023-02-24 01:26:27 +00:00
|
|
|
];
|
|
|
|
for (const textarea of commentTextareas) {
|
2023-04-03 10:06:57 +00:00
|
|
|
// 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>
2023-02-24 01:26:27 +00:00
|
|
|
// But if they have typed more (like 50) chars and the comment is lost, they will be very unhappy.
|
2023-04-03 10:06:57 +00:00
|
|
|
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>
2023-02-24 01:26:27 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
Actions support workflow dispatch event (#28163)
fix #23668
My plan:
* In the `actions.list` method, if workflow is selected and IsAdmin,
check whether the on event contains `workflow_dispatch`. If so, display
a `Run workflow` button to allow the user to manually trigger the run.
* Providing a form that allows users to select target brach or tag, and
these parameters can be configured in yaml
* Simple form validation, `required` input cannot be empty
* Add a route `/actions/run`, and an `actions.Run` method to handle
* Add `WorkflowDispatchPayload` struct to pass the Webhook event payload
to the runner when triggered, this payload carries the `inputs` values
and other fields, doc: [workflow_dispatch
payload](https://docs.github.com/en/webhooks/webhook-events-and-payloads#workflow_dispatch)
Other PRs
* the `Workflow.WorkflowDispatchConfig()` method still return non-nil
when workflow_dispatch is not defined. I submitted a PR
https://gitea.com/gitea/act/pulls/85 to fix it. Still waiting for them
to process.
Behavior should be same with github, but may cause confusion. Here's a
quick reminder.
*
[Doc](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch)
Said: This event will `only` trigger a workflow run if the workflow file
is `on the default branch`.
* If the workflow yaml file only exists in a non-default branch, it
cannot be triggered. (It will not even show up in the workflow list)
* If the same workflow yaml file exists in each branch at the same time,
the version of the default branch is used. Even if `Use workflow from`
selects another branch
![image](https://github.com/go-gitea/gitea/assets/3114995/4bf596f3-426b-48e8-9b8f-0f6d18defd79)
```yaml
name: Docker Image CI
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Test scenario tags'
required: false
type: boolean
boolean_default_true:
description: 'Test scenario tags'
required: true
type: boolean
default: true
boolean_default_false:
description: 'Test scenario tags'
required: false
type: boolean
default: false
environment:
description: 'Environment to run tests against'
type: environment
required: true
default: 'environment values'
number_required_1:
description: 'number '
type: number
required: true
default: '100'
number_required_2:
description: 'number'
type: number
required: true
default: '100'
number_required_3:
description: 'number'
type: number
required: true
default: '100'
number_1:
description: 'number'
type: number
required: false
number_2:
description: 'number'
type: number
required: false
number_3:
description: 'number'
type: number
required: false
env:
inputs_logLevel: ${{ inputs.logLevel }}
inputs_tags: ${{ inputs.tags }}
inputs_boolean_default_true: ${{ inputs.boolean_default_true }}
inputs_boolean_default_false: ${{ inputs.boolean_default_false }}
inputs_environment: ${{ inputs.environment }}
inputs_number_1: ${{ inputs.number_1 }}
inputs_number_2: ${{ inputs.number_2 }}
inputs_number_3: ${{ inputs.number_3 }}
inputs_number_required_1: ${{ inputs.number_required_1 }}
inputs_number_required_2: ${{ inputs.number_required_2 }}
inputs_number_required_3: ${{ inputs.number_required_3 }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: ls -la
- run: env | grep inputs
- run: echo ${{ inputs.logLevel }}
- run: echo ${{ inputs.boolean_default_false }}
```
![image](https://github.com/go-gitea/gitea/assets/3114995/a58a842d-a0ff-4618-bc6d-83a9596d07c8)
![image](https://github.com/go-gitea/gitea/assets/3114995/44a7cca5-7bd4-42a9-8723-91751a501c88)
---------
Co-authored-by: TKaxv_7S <954067342@qq.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2024-08-19 02:38:40 +00:00
|
|
|
export function initBranchSelectorTabs() {
|
|
|
|
const elSelectBranch = document.querySelector('.ui.dropdown.select-branch');
|
|
|
|
if (!elSelectBranch) return;
|
|
|
|
|
|
|
|
$(elSelectBranch).find('.reference.column').on('click', function () {
|
|
|
|
hideElem($(elSelectBranch).find('.scrolling.reference-list-menu'));
|
|
|
|
showElem(this.getAttribute('data-target'));
|
|
|
|
queryElemChildren(this.parentNode, '.branch-tag-item', (el) => el.classList.remove('active'));
|
|
|
|
this.classList.add('active');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-10-16 17:28:04 +00:00
|
|
|
export function initRepoCommentForm() {
|
2022-06-28 17:52:58 +00:00
|
|
|
const $commentForm = $('.comment.form');
|
2024-03-25 18:37:55 +00:00
|
|
|
if (!$commentForm.length) return;
|
2021-10-16 17:28:04 +00:00
|
|
|
|
2023-05-08 22:22:52 +00:00
|
|
|
if ($commentForm.find('.field.combo-editor-dropzone').length) {
|
2023-08-23 15:15:06 +00:00
|
|
|
// at the moment, if a form has multiple combo-markdown-editors, it must be an issue template form
|
2023-05-08 22:22:52 +00:00
|
|
|
initIssueTemplateCommentEditors($commentForm);
|
2023-08-23 15:15:06 +00:00
|
|
|
} 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
|
2023-05-08 22:22:52 +00:00
|
|
|
initSingleCommentEditor($commentForm);
|
|
|
|
}
|
|
|
|
|
2021-10-16 17:28:04 +00:00
|
|
|
function initBranchSelector() {
|
2024-05-02 10:45:23 +00:00
|
|
|
const elSelectBranch = document.querySelector('.ui.dropdown.select-branch');
|
2024-05-03 02:12:10 +00:00
|
|
|
if (!elSelectBranch) return;
|
2024-05-02 10:45:23 +00:00
|
|
|
|
2024-05-08 15:39:13 +00:00
|
|
|
const urlUpdateIssueRef = elSelectBranch.getAttribute('data-url-update-issueref');
|
2024-05-02 10:45:23 +00:00
|
|
|
const $selectBranch = $(elSelectBranch);
|
2021-10-16 17:28:04 +00:00
|
|
|
const $branchMenu = $selectBranch.find('.reference-list-menu');
|
2024-05-02 10:45:23 +00:00
|
|
|
$branchMenu.find('.item:not(.no-select)').on('click', async function (e) {
|
|
|
|
e.preventDefault();
|
2024-05-08 15:39:13 +00:00
|
|
|
const selectedValue = this.getAttribute('data-id'); // eg: "refs/heads/my-branch"
|
|
|
|
const selectedText = this.getAttribute('data-name'); // eg: "my-branch"
|
|
|
|
if (urlUpdateIssueRef) {
|
|
|
|
// for existing issue, send request to update issue ref, and reload page
|
2024-03-12 04:29:51 +00:00
|
|
|
try {
|
2024-05-08 15:39:13 +00:00
|
|
|
await POST(urlUpdateIssueRef, {data: new URLSearchParams({ref: selectedValue})});
|
2024-03-12 04:29:51 +00:00
|
|
|
window.location.reload();
|
|
|
|
} catch (error) {
|
2024-03-15 18:02:43 +00:00
|
|
|
console.error(error);
|
2024-03-12 04:29:51 +00:00
|
|
|
}
|
2024-05-08 15:39:13 +00:00
|
|
|
} else {
|
|
|
|
// for new issue, only update UI&form, do not send request/reload
|
|
|
|
const selectedHiddenSelector = this.getAttribute('data-id-selector');
|
|
|
|
document.querySelector(selectedHiddenSelector).value = selectedValue;
|
|
|
|
elSelectBranch.querySelector('.text-branch-name').textContent = selectedText;
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
initBranchSelector();
|
|
|
|
|
2021-11-18 16:45:00 +00:00
|
|
|
// List submits
|
2021-10-16 17:28:04 +00:00
|
|
|
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>
2023-02-24 01:26:27 +00:00
|
|
|
$(`.${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) {
|
2021-11-16 02:21:13 +00:00
|
|
|
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>
2023-02-24 01:26:27 +00:00
|
|
|
if (itemEntries.length) {
|
|
|
|
reloadConfirmDraftComment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-10-16 17:28:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$listMenu.find('.item:not(.no-select)').on('click', function (e) {
|
|
|
|
e.preventDefault();
|
2024-07-16 10:14:27 +00:00
|
|
|
if (this.classList.contains('ban-change')) {
|
2021-10-16 17:28:04 +00:00
|
|
|
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>
2023-02-18 19:17:39 +00:00
|
|
|
|
2024-03-24 17:56:02 +00:00
|
|
|
const clickedItem = this; // eslint-disable-line unicorn/no-this-assignment
|
2024-03-26 19:49:38 +00:00
|
|
|
const scope = this.getAttribute('data-scope');
|
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>
2023-02-18 19:17:39 +00:00
|
|
|
|
|
|
|
$(this).parent().find('.item').each(function () {
|
|
|
|
if (scope) {
|
|
|
|
// Enable only clicked item for scoped labels
|
2024-03-26 19:49:38 +00:00
|
|
|
if (this.getAttribute('data-scope') !== scope) {
|
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>
2023-02-18 19:17:39 +00:00
|
|
|
return true;
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
2024-07-16 10:14:27 +00:00
|
|
|
if (this !== clickedItem && !this.classList.contains('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>
2023-02-18 19:17:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
2024-03-24 17:56:02 +00:00
|
|
|
} else if (this !== 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>
2023-02-18 19:17:39 +00:00
|
|
|
// Toggle for other labels
|
|
|
|
return true;
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
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>
2023-02-18 19:17:39 +00:00
|
|
|
|
2024-07-16 10:14:27 +00:00
|
|
|
if (this.classList.contains('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>
2023-02-18 19:17:39 +00:00
|
|
|
$(this).removeClass('checked');
|
2024-03-05 05:29:32 +00:00
|
|
|
$(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>
2023-02-18 19:17:39 +00:00
|
|
|
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');
|
2024-03-05 05:29:32 +00:00
|
|
|
$(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>
2023-02-18 19:17:39 +00:00
|
|
|
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')];
|
|
|
|
}
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
}
|
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>
2023-02-18 19:17:39 +00:00
|
|
|
});
|
2021-10-16 17:28:04 +00:00
|
|
|
|
|
|
|
// 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 () {
|
2024-07-16 10:14:27 +00:00
|
|
|
if (this.classList.contains('checked')) {
|
2021-10-16 17:28:04 +00:00
|
|
|
listIds.push($(this).data('id'));
|
2024-03-24 18:23:38 +00:00
|
|
|
$($(this).data('id-selector')).removeClass('tw-hidden');
|
2021-10-16 17:28:04 +00:00
|
|
|
} else {
|
2024-03-24 18:23:38 +00:00
|
|
|
$($(this).data('id-selector')).addClass('tw-hidden');
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
});
|
2024-03-25 18:37:55 +00:00
|
|
|
if (!listIds.length) {
|
2024-03-24 18:23:38 +00:00
|
|
|
$noSelect.removeClass('tw-hidden');
|
2021-10-16 17:28:04 +00:00
|
|
|
} else {
|
2024-03-24 18:23:38 +00:00
|
|
|
$noSelect.addClass('tw-hidden');
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
2022-01-16 11:19:26 +00:00
|
|
|
$($(this).parent().data('id')).val(listIds.join(','));
|
2021-10-16 17:28:04 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
$listMenu.find('.no-select.item').on('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (hasUpdateAction) {
|
2024-02-16 21:41:23 +00:00
|
|
|
(async () => {
|
|
|
|
await updateIssuesMeta(
|
|
|
|
$listMenu.data('update-url'),
|
|
|
|
'clear',
|
|
|
|
$listMenu.data('issue-id'),
|
|
|
|
'',
|
|
|
|
);
|
|
|
|
reloadConfirmDraftComment();
|
|
|
|
})();
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$(this).parent().find('.item').each(function () {
|
|
|
|
$(this).removeClass('checked');
|
2024-03-05 05:29:32 +00:00
|
|
|
$(this).find('.octicon-check').addClass('tw-invisible');
|
2021-10-16 17:28:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (selector === 'select-reviewers-modify' || selector === 'select-assignees-modify') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$list.find('.item').each(function () {
|
2024-03-24 18:23:38 +00:00
|
|
|
$(this).addClass('tw-hidden');
|
2021-10-16 17:28:04 +00:00
|
|
|
});
|
2024-03-24 18:23:38 +00:00
|
|
|
$noSelect.removeClass('tw-hidden');
|
2022-01-16 11:19:26 +00:00
|
|
|
$($(this).parent().data('id')).val('');
|
2021-10-16 17:28:04 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2024-02-16 21:41:23 +00:00
|
|
|
(async () => {
|
|
|
|
await updateIssuesMeta(
|
|
|
|
$menu.data('update-url'),
|
|
|
|
'',
|
|
|
|
$menu.data('issue-id'),
|
|
|
|
$(this).data('id'),
|
|
|
|
);
|
|
|
|
reloadConfirmDraftComment();
|
|
|
|
})();
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let icon = '';
|
|
|
|
if (input_id === '#milestone_id') {
|
Migrate margin and padding helpers to tailwind (#30043)
This will conclude the refactor of 1:1 class replacements to tailwind,
except `gt-hidden`. Commands ran:
```bash
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-0#tw-$1$2-0#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-1#tw-$1$2-0.5#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-2#tw-$1$2-1#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-3#tw-$1$2-2#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-4#tw-$1$2-4#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-5#tw-$1$2-8#g' {web_src/js,templates,routers,services}/**/*
```
2024-03-24 16:42:49 +00:00
|
|
|
icon = svg('octicon-milestone', 18, 'tw-mr-2');
|
2021-10-16 17:28:04 +00:00
|
|
|
} else if (input_id === '#project_id') {
|
Migrate margin and padding helpers to tailwind (#30043)
This will conclude the refactor of 1:1 class replacements to tailwind,
except `gt-hidden`. Commands ran:
```bash
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-0#tw-$1$2-0#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-1#tw-$1$2-0.5#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-2#tw-$1$2-1#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-3#tw-$1$2-2#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-4#tw-$1$2-4#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-5#tw-$1$2-8#g' {web_src/js,templates,routers,services}/**/*
```
2024-03-24 16:42:49 +00:00
|
|
|
icon = svg('octicon-project', 18, 'tw-mr-2');
|
2021-10-16 17:28:04 +00:00
|
|
|
} else if (input_id === '#assignee_id') {
|
Migrate margin and padding helpers to tailwind (#30043)
This will conclude the refactor of 1:1 class replacements to tailwind,
except `gt-hidden`. Commands ran:
```bash
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-0#tw-$1$2-0#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-1#tw-$1$2-0.5#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-2#tw-$1$2-1#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-3#tw-$1$2-2#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-4#tw-$1$2-4#g' {web_src/js,templates,routers,services}/**/*
perl -p -i -e 's#gt-(p|m)([lrtbxy])?-5#tw-$1$2-8#g' {web_src/js,templates,routers,services}/**/*
```
2024-03-24 16:42:49 +00:00
|
|
|
icon = `<img class="ui avatar image tw-mr-2" alt="avatar" src=${$(this).data('avatar')}>`;
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$list.find('.selected').html(`
|
2024-06-16 02:07:21 +00:00
|
|
|
<a class="item muted sidebar-item-link" href="${htmlEscape(this.getAttribute('data-href'))}">
|
2021-10-16 17:28:04 +00:00
|
|
|
${icon}
|
2024-06-10 10:12:31 +00:00
|
|
|
${htmlEscape(this.textContent)}
|
2021-10-16 17:28:04 +00:00
|
|
|
</a>
|
|
|
|
`);
|
|
|
|
|
2024-03-24 18:23:38 +00:00
|
|
|
$(`.ui${select_id}.list .no-select`).addClass('tw-hidden');
|
2021-10-16 17:28:04 +00:00
|
|
|
$(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) {
|
2024-02-16 21:41:23 +00:00
|
|
|
(async () => {
|
|
|
|
await updateIssuesMeta(
|
|
|
|
$menu.data('update-url'),
|
|
|
|
'',
|
|
|
|
$menu.data('issue-id'),
|
|
|
|
$(this).data('id'),
|
|
|
|
);
|
|
|
|
reloadConfirmDraftComment();
|
|
|
|
})();
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$list.find('.selected').html('');
|
2024-03-24 18:23:38 +00:00
|
|
|
$list.find('.no-select').removeClass('tw-hidden');
|
2022-01-16 11:19:26 +00:00
|
|
|
$(input_id).val('');
|
2021-10-16 17:28:04 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Milestone, Assignee, Project
|
|
|
|
selectItem('.select-project', '#project_id');
|
|
|
|
selectItem('.select-milestone', '#milestone_id');
|
|
|
|
selectItem('.select-assignee', '#assignee_id');
|
|
|
|
}
|
|
|
|
|
2021-11-09 09:27:25 +00:00
|
|
|
export function initRepository() {
|
2024-03-25 18:37:55 +00:00
|
|
|
if (!$('.page-content.repository').length) return;
|
2021-10-16 17:28:04 +00:00
|
|
|
|
2023-05-03 21:58:59 +00:00
|
|
|
initRepoBranchTagSelector('.js-branch-tag-selector');
|
2021-10-16 17:28:04 +00:00
|
|
|
|
|
|
|
// 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) {
|
2022-01-16 11:19:26 +00:00
|
|
|
$($(this).data('target')).removeClass('disabled');
|
|
|
|
if (!$(this).data('context')) $($(this).data('context')).addClass('disabled');
|
2021-10-16 17:28:04 +00:00
|
|
|
} else {
|
2022-01-16 11:19:26 +00:00
|
|
|
$($(this).data('target')).addClass('disabled');
|
|
|
|
if (!$(this).data('context')) $($(this).data('context')).removeClass('disabled');
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$('.enable-system-radio').on('change', function () {
|
|
|
|
if (this.value === 'false') {
|
2022-01-16 11:19:26 +00:00
|
|
|
$($(this).data('target')).addClass('disabled');
|
2022-11-22 00:58:55 +00:00
|
|
|
if ($(this).data('context') !== undefined) $($(this).data('context')).removeClass('disabled');
|
2021-10-16 17:28:04 +00:00
|
|
|
} else if (this.value === 'true') {
|
2022-01-16 11:19:26 +00:00
|
|
|
$($(this).data('target')).removeClass('disabled');
|
2022-11-22 00:58:55 +00:00
|
|
|
if ($(this).data('context') !== undefined) $($(this).data('context')).addClass('disabled');
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
});
|
2022-06-10 05:39:53 +00:00
|
|
|
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');
|
|
|
|
});
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2024-03-16 15:08:10 +00:00
|
|
|
document.querySelector('input[name="auto_init"]').checked = true;
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-11-18 16:45:00 +00:00
|
|
|
// Compare or pull request
|
|
|
|
const $repoDiff = $('.repository.diff');
|
|
|
|
if ($repoDiff.length) {
|
|
|
|
initRepoCommonBranchOrTagDropdown('.choose.branch .dropdown');
|
|
|
|
initRepoCommonFilterSearchDropdown('.choose.branch .dropdown');
|
|
|
|
}
|
|
|
|
|
2022-03-29 03:21:30 +00:00
|
|
|
initRepoCloneLink();
|
2022-11-11 17:02:50 +00:00
|
|
|
initCitationFileCopyContent();
|
2021-11-18 16:45:00 +00:00
|
|
|
initRepoSettingBranches();
|
|
|
|
|
2021-10-16 17:28:04 +00:00
|
|
|
// Issues
|
|
|
|
if ($('.repository.view.issue').length > 0) {
|
2021-11-18 16:45:00 +00:00
|
|
|
initRepoIssueCommentEdit();
|
|
|
|
|
2021-10-16 17:28:04 +00:00
|
|
|
initRepoIssueBranchSelect();
|
|
|
|
initRepoIssueTitleEdit();
|
|
|
|
initRepoIssueWipToggle();
|
|
|
|
initRepoIssueComments();
|
|
|
|
|
|
|
|
initRepoDiffConversationNav();
|
|
|
|
initRepoIssueReferenceIssue();
|
|
|
|
|
|
|
|
initRepoIssueCommentDelete();
|
|
|
|
initRepoIssueDependencyDelete();
|
|
|
|
initRepoIssueCodeCommentCancel();
|
|
|
|
initRepoPullRequestUpdate();
|
2024-04-14 10:44:11 +00:00
|
|
|
initCompReactionSelector();
|
2022-05-12 13:39:02 +00:00
|
|
|
|
|
|
|
initRepoPullRequestMergeForm();
|
2023-11-02 14:49:02 +00:00
|
|
|
initRepoPullRequestCommitStatus();
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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();
|
2023-02-19 04:06:14 +00:00
|
|
|
hideElem($(this).parent());
|
2021-11-18 16:45:00 +00:00
|
|
|
|
|
|
|
const $form = $repoComparePull.find('.pullrequest-form');
|
2023-02-19 04:06:14 +00:00
|
|
|
showElem($form);
|
2021-10-16 17:28:04 +00:00
|
|
|
});
|
|
|
|
}
|
2022-01-07 01:18:52 +00:00
|
|
|
|
|
|
|
initUnicodeEscapeButton();
|
2021-10-16 17:28:04 +00:00
|
|
|
}
|