@@ -205,16 +205,16 @@ webui.SideBarView = function(mainView) {
205
205
'</svg>' +
206
206
'</button>' +
207
207
'</div>' +
208
- '<div class="modal-body"><div class="list-group"></div>< /div>' +
208
+ '<div class="modal-body"></div>' +
209
209
'</div>' +
210
210
'</div>' +
211
211
'</div>' ) [ 0 ] ;
212
212
self . element . appendChild ( popup ) ;
213
- var popupContent = $ ( ".list-group " , popup ) [ 0 ] ;
213
+ var popupContent = $ ( ".modal-body " , popup ) [ 0 ] ;
214
214
$ ( self . buildAccordion ( section , refs , id , undefined , "popup" ) ) . appendTo ( popupContent ) ;
215
215
$ ( popupContent ) . find ( ".btn-delete-branch, .btn-checkout-local-branch, .btn-checkout-remote-branch" ) . click ( function ( ) {
216
216
$ ( popup ) . modal ( 'hide' ) ;
217
- } )
217
+ } ) ;
218
218
return popup ;
219
219
} ;
220
220
@@ -1819,13 +1819,58 @@ $(function () {
1819
1819
1820
1820
$ ( document ) . on ( 'click' , '.btn-delete-branch' , function ( e ) {
1821
1821
e . preventDefault ( ) ;
1822
+ $ ( "#confirm-branch-delete" ) . remove ( ) ; //removes any remaining modals. If there are more than one modals, the ids are duplicated and event listeners won't work.
1822
1823
var refName = $ ( this ) . parent ( ) . parent ( ) . parent ( ) . siblings (
1823
1824
".card-header" ) . children ( "button" ) . html ( ) ;
1824
1825
1825
- webui . git ( "branch -d " + refName , function ( ) {
1826
- webui . showWarning ( "Local branch " + refName + " deleted." ) ;
1827
- updateSideBar ( ) ;
1826
+ console . log ( $ ( this ) . parent ( ) . parent ( ) . parent ( ) [ 0 ] ) ;
1827
+
1828
+ var popup = $ ( '<div class="modal fade" id="confirm-branch-delete" role="dialog">' +
1829
+ '<div class="modal-dialog modal-md">' +
1830
+ '<div class="modal-content">' +
1831
+ '<div class="modal-header">' +
1832
+ '<h5 class="modal-title">Confirm <pre>' + refName + ' </pre>Deletion</h5>' +
1833
+ '<button type="button" class="btn btn-default close" data-dismiss="modal">' +
1834
+ '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16">' +
1835
+ '<path fill-rule="evenodd" clip-rule="evenodd" d="M13.854 2.146a.5.5 0 0 1 0 .708l-11 11a.5.5 0 0 1-.708-.708l11-11a.5.5 0 0 1 .708 0Z" fill="#000"/>' +
1836
+ '<path fill-rule="evenodd" clip-rule="evenodd" d="M2.146 2.146a.5.5 0 0 0 0 .708l11 11a.5.5 0 0 0 .708-.708l-11-11a.5.5 0 0 0-.708 0Z" fill="#000"/>' +
1837
+ '</svg>' +
1838
+ '</button>' +
1839
+ '</div>' +
1840
+ '<div class="modal-body"></div>' +
1841
+ '</div>' +
1842
+ '</div>' +
1843
+ '</div>' ) [ 0 ] ;
1844
+
1845
+ $ ( "body" ) . append ( popup ) ;
1846
+ var popupContent = $ ( ".modal-body" , popup ) [ 0 ] ;
1847
+
1848
+ $ ( '<div class="row"><div class="col-sm-1">' +
1849
+ '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="#dc3545" class="bi bi-exclamation-circle-fill" viewBox="0 0 16 16">' +
1850
+ '<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8 4a.905.905 0 0 0-.9.995l.35 3.507a.552.552 0 0 0 1.1 0l.35-3.507A.905.905 0 0 0 8 4zm.002 6a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"></path>' +
1851
+ '</svg></div>' +
1852
+ '<div class="col-sm-11">By deleting this branch, you might lose uncommitted work. <br/> Do you want to proceed?</div></div>' +
1853
+ '<button class="btn btn-sm btn-danger float-right" id="confirm-delete">Delete Branch</button>' +
1854
+ '<button class="btn btn-sm btn-secondary float-right" id="cancel-delete">Cancel</button>' ) . appendTo ( popupContent ) ;
1855
+ $ ( popup ) . modal ( 'show' ) ;
1856
+
1857
+ $ ( "#confirm-branch-delete" ) . on ( 'click' , '#confirm-delete' , function ( e ) {
1858
+ $ ( popup ) . children ( ".modal-fade" ) . modal ( 'hide' ) ;
1859
+ $ ( ".modal-backdrop" ) . remove ( ) ;
1860
+ $ ( "#confirm-branch-delete" ) . remove ( ) ;
1861
+ webui . git ( "branch -d " + refName , function ( ) {
1862
+ webui . showWarning ( "Local branch " + refName + " deleted." ) ;
1863
+ updateSideBar ( ) ;
1864
+ } ) ;
1865
+
1866
+ } ) ;
1867
+
1868
+ $ ( "#confirm-branch-delete" ) . find ( "#cancel-delete, .close" ) . click ( function ( ) {
1869
+ $ ( popup ) . children ( ".modal-fade" ) . modal ( 'hide' ) ;
1870
+ $ ( ".modal-backdrop" ) . remove ( ) ;
1871
+ $ ( "#confirm-branch-delete" ) . remove ( ) ;
1828
1872
} ) ;
1873
+
1829
1874
} ) ;
1830
1875
1831
1876
$ ( document ) . on ( 'click' , '.btn-checkout-remote-branch' , function ( e ) {
0 commit comments