Skip to content

Commit 8698325

Browse files
committed
fine tune comment
1 parent bc63562 commit 8698325

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

templates/repo/issue/labels/label_edit_modal.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="ui small modal" id="issue-label-edit-modal"
2-
data-current-page-link="{{$.Link}}"{{/*will be used to construct issue "new" and "edit" URLs*/}}
2+
data-current-page-link="{{$.Link}}"{{/*will be used to construct "new label" and "edit label" URLs*/}}
33
data-text-new-label="{{ctx.Locale.Tr "repo.issues.new_label"}}"
44
data-text-edit-label="{{ctx.Locale.Tr "repo.issues.label_modify"}}"
55
>

web_src/js/features/comp/LabelEdit.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export function initCompLabelEdit(pageSelector: string) {
99
const pageContent = document.querySelector<HTMLElement>(pageSelector);
1010
if (!pageContent) return;
1111

12+
// for guest view, the modal is not available, the "labels" are read-only
1213
const elModal = pageContent.querySelector<HTMLElement>('#issue-label-edit-modal');
1314
if (!elModal) return;
1415

@@ -31,6 +32,7 @@ export function initCompLabelEdit(pageSelector: string) {
3132
};
3233

3334
const showLabelEditModal = (btn:HTMLElement) => {
35+
// the "btn" should contain the label's attributes by its `data-label-xxx` attributes
3436
const form = elModal.querySelector<HTMLFormElement>('form');
3537
elLabelId.value = btn.getAttribute('data-label-id') || '';
3638
elNameInput.value = btn.getAttribute('data-label-name') || '';
@@ -40,6 +42,7 @@ export function initCompLabelEdit(pageSelector: string) {
4042
elColorInput.value = btn.getAttribute('data-label-color') || '';
4143
elColorInput.dispatchEvent(new Event('input', {bubbles: true})); // trigger the color picker
4244

45+
// if label id exists: "edit label" mode; otherwise: "new label" mode
4346
const isEdit = Boolean(elLabelId.value);
4447

4548
// if a label was not exclusive but has issues, then it should warn user if it will become exclusive
@@ -64,6 +67,7 @@ export function initCompLabelEdit(pageSelector: string) {
6467

6568
elModal.addEventListener('input', () => syncModalUi());
6669

70+
// theoretically, if the modal exists, the "new label" button should also exist, just in case it doesn't, use "?."
6771
const elNewLabel = pageContent.querySelector<HTMLElement>('.ui.button.new-label');
6872
elNewLabel?.addEventListener('click', () => showLabelEditModal(elNewLabel));
6973

0 commit comments

Comments
 (0)