@@ -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