|
581 | 581 | e.stopPropagation(); |
582 | 582 | let sourceElem = <HTMLElement>(<Element>e.target).closest('.gitRef')!; |
583 | 583 | let refName = unescapeHtml(sourceElem.dataset.name!), menu; |
584 | | - if (sourceElem.className === 'gitRef tag') { |
| 584 | + if (sourceElem.classList.contains('tag')) { |
585 | 585 | menu = [{ |
586 | 586 | title: 'Delete Tag', |
587 | 587 | onClick: () => { |
|
594 | 594 | menu = [{ |
595 | 595 | title: 'Checkout Branch', |
596 | 596 | onClick: () => { |
597 | | - if (sourceElem.className === 'gitRef head') { |
| 597 | + if (sourceElem.classList.contains('head')) { |
598 | 598 | sendMessage({ command: 'checkoutBranch', branchName: refName, remoteBranch: null }); |
599 | | - } else if (sourceElem.className === 'gitRef remote') { |
| 599 | + } else if (sourceElem.classList.contains('remote')) { |
600 | 600 | let refNameComps = refName.split('/'); |
601 | 601 | showInputDialog('Enter the name of the new branch you would like to create when checking out <b><i>' + escapeHtml(sourceElem.dataset.name!) + '</i></b>:', refNameComps[refNameComps.length - 1], 'Checkout Branch', (newBranch) => { |
602 | 602 | sendMessage({ command: 'checkoutBranch', branchName: newBranch, remoteBranch: refName }); |
603 | 603 | }, null); |
604 | 604 | } |
605 | 605 | } |
606 | 606 | }]; |
607 | | - if (sourceElem.className === 'gitRef head') { |
| 607 | + if (sourceElem.classList.contains('head')) { |
608 | 608 | menu.push( |
609 | 609 | { |
610 | 610 | title: 'Rename Branch', |
|
616 | 616 | }, { |
617 | 617 | title: 'Delete Branch', |
618 | 618 | onClick: () => { |
619 | | - showCheckboxDialog('Are you sure you want to delete the branch <b><i>' + escapeHtml(refName) + '</i></b>?', 'Force Delete', 'Delete Branch', (forceDelete) => { |
| 619 | + showCheckboxDialog('Are you sure you want to delete the branch <b><i>' + escapeHtml(refName) + '</i></b>?', 'Force Delete', false, 'Delete Branch', (forceDelete) => { |
620 | 620 | sendMessage({ command: 'deleteBranch', branchName: refName, forceDelete: forceDelete }); |
621 | 621 | }, null); |
622 | 622 | } |
|
626 | 626 | menu.push({ |
627 | 627 | title: 'Merge into current branch', |
628 | 628 | onClick: () => { |
629 | | - showConfirmationDialog('Are you sure you want to merge branch <b><i>' + escapeHtml(refName) + '</i></b> into the current branch?', () => { |
630 | | - sendMessage({ command: 'mergeBranch', branchName: refName }); |
| 629 | + showCheckboxDialog('Are you sure you want to merge branch <b><i>' + escapeHtml(refName) + '</i></b> into the current branch?', 'Create a new commit even if fast-forward is possible', true, 'Yes, merge', (createNewCommit) => { |
| 630 | + sendMessage({ command: 'mergeBranch', branchName: refName, createNewCommit: createNewCommit }); |
631 | 631 | }, null); |
632 | 632 | } |
633 | 633 | }); |
|
992 | 992 | } |
993 | 993 | }); |
994 | 994 | } |
995 | | - function showCheckboxDialog(message: string, checkboxLabel: string, actionName: string, actioned: (value: boolean) => void, sourceElem: HTMLElement | null) { |
996 | | - showDialog(message + '<br><label><input id="dialogInput" type="checkbox"/>' + checkboxLabel + '</label>', actionName, 'Cancel', () => { |
| 995 | + function showCheckboxDialog(message: string, checkboxLabel: string, checkboxValue: boolean, actionName: string, actioned: (value: boolean) => void, sourceElem: HTMLElement | null) { |
| 996 | + showDialog(message + '<br><label><input id="dialogInput" type="checkbox"' + (checkboxValue ? ' checked' : '') + '/>' + checkboxLabel + '</label>', actionName, 'Cancel', () => { |
997 | 997 | let value = (<HTMLInputElement>document.getElementById('dialogInput')).checked; |
998 | 998 | hideDialog(); |
999 | 999 | actioned(value); |
|
0 commit comments