@@ -1105,10 +1105,10 @@ webui.LogView = function(historyView) {
1105
1105
streams = [ ]
1106
1106
$ ( content ) . empty ( ) ;
1107
1107
self . nextRef = ref ;
1108
- self . populate ( ) ;
1108
+ self . populate ( ref ) ;
1109
1109
} ;
1110
1110
1111
- self . populate = function ( ) {
1111
+ self . populate = function ( ref ) {
1112
1112
var maxCount = 1000 ;
1113
1113
if ( content . childElementCount > 0 ) {
1114
1114
// The last node is the 'Show more commits placeholder'. Remove it.
@@ -1127,8 +1127,7 @@ webui.LogView = function(historyView) {
1127
1127
}
1128
1128
var end = data . length ;
1129
1129
}
1130
-
1131
- var entry = new Entry ( self , data . substring ( start , end ) ) ;
1130
+ var entry = new Entry ( self , data . substring ( start , end ) , count == 0 ? true : false , ref ) ;
1132
1131
content . appendChild ( entry . element ) ;
1133
1132
if ( ! self . lineHeight ) {
1134
1133
self . lineHeight = Math . ceil ( $ ( entry . element ) . outerHeight ( ) / 2 ) * 2 ;
@@ -1269,7 +1268,7 @@ webui.LogView = function(historyView) {
1269
1268
this . date . setUTCSeconds ( parseInt ( secs ) ) ;
1270
1269
} ;
1271
1270
1272
- function Entry ( logView , data ) {
1271
+ function Entry ( logView , data , revert , ref ) {
1273
1272
var self = this ;
1274
1273
1275
1274
self . abbrevCommitHash = function ( ) {
@@ -1286,13 +1285,20 @@ webui.LogView = function(historyView) {
1286
1285
} ;
1287
1286
1288
1287
self . createElement = function ( ) {
1288
+ var contents = "" ;
1289
+ if ( revert && ( ref == 'HEAD' || ref == $ ( '.branch-current' ) . text ( ) ) ) {
1290
+ contents = '<div style="overflow:hidden; display: flex"><p class="list-group-item-text"></p>' +
1291
+ '<button type="button" class="btn btn-danger file-action-button" id="revertBtn" style="margin-left: 20px;">Revert</button></div>'
1292
+ } else {
1293
+ contents = '<p class="list-group-item-text"></p>'
1294
+ }
1289
1295
self . element = $ ( '<a class="log-entry list-group-item">' +
1290
1296
'<header>' +
1291
1297
'<h6></h6>' +
1292
1298
'<span class="log-entry-date">' + self . author . date . toLocaleString ( ) + ' </span> ' +
1293
1299
'<span class="badge">' + self . abbrevCommitHash ( ) + '</span>' +
1294
1300
'</header>' +
1295
- '<p class="list-group-item-text"></p>' +
1301
+ contents +
1296
1302
'</a>' ) [ 0 ] ;
1297
1303
$ ( '<a target="_blank" href="mailto:' + self . author . email + '">' + self . author . name + '</a>' ) . appendTo ( $ ( "h6" , self . element ) ) ;
1298
1304
$ ( ".list-group-item-text" , self . element ) [ 0 ] . appendChild ( document . createTextNode ( self . abbrevMessage ( ) ) ) ;
@@ -1333,6 +1339,89 @@ webui.LogView = function(historyView) {
1333
1339
}
1334
1340
} ;
1335
1341
1342
+ self . chooseRevert = function ( ) {
1343
+ function removePopup ( popup ) {
1344
+ $ ( popup ) . children ( ".modal-fade" ) . modal ( "hide" ) ;
1345
+ $ ( ".modal-backdrop" ) . remove ( ) ;
1346
+ $ ( "#chooseRevert" ) . remove ( ) ;
1347
+ }
1348
+
1349
+ function confirmRevert ( type ) {
1350
+ if ( type == 'revert' ) {
1351
+ webui . git_command ( [ "revert" , "--no-commit" , "HEAD" ] , function ( output ) {
1352
+ webui . showSuccess ( output ) ;
1353
+ workspaceView . update ( ) ;
1354
+ } ) ;
1355
+ } else if ( type == 'hardReset' ) {
1356
+ webui . git_command ( [ "reset" , "--hard" , "HEAD~1" ] , function ( output ) {
1357
+ webui . showSuccess ( output ) ;
1358
+ workspaceView . update ( ) ;
1359
+ } ) ;
1360
+ }
1361
+
1362
+ }
1363
+
1364
+ var popup = $ (
1365
+ '<div class="modal fade" tabindex="-1" id="chooseRevert" role="dialog" data-backdrop="static">' +
1366
+ '<div class="modal-dialog modal-md" role="document">' +
1367
+ '<div class="modal-content">' +
1368
+ '<div class="modal-header">' +
1369
+ '<h5 class="modal-title">Choose Revert Type</h5>' +
1370
+ '<button type="button" class="btn btn-default close" data-dismiss="modal">' + webui . largeXIcon + '</button>' +
1371
+ '</div>' +
1372
+ '<div class="modal-body">' +
1373
+ '<div class="row">' +
1374
+ '<div class="col-sm-1">' +
1375
+ webui . warningIcon +
1376
+ '</div>' +
1377
+ '<div class="col-sm-11">' +
1378
+ '<p>There are a few options available to revert the previous commit. Please read the description carefully to make sure you choose' +
1379
+ ' the correct option.</p>' +
1380
+ '<h4>Revert</h2><p><i>git revert --no-commit</i> - This will create a new change, which will be the reversal of the previous commit.' +
1381
+ 'It will not be automatically committed, so you can inspect/modify/combine the changes with others before you commit.</p>' +
1382
+ '<h4>Hard Reset</h2><p><i>git reset --hard HEAD~1</i> - This will delete the previous commit entirely, and reset you to a state' +
1383
+ ' before the commit. <b>WARNING:</b> This will also delete <b>all uncommitted changes</b>, so make sure you have no changes left before' +
1384
+ ' attempting this operation.</p>' +
1385
+ '</div>' +
1386
+ '</div>' +
1387
+ '</div>' +
1388
+ '<div class="modal-footer"></div>' +
1389
+ '</div>' +
1390
+ '</div>' +
1391
+ '</div>'
1392
+ ) [ 0 ] ;
1393
+
1394
+ $ ( "body" ) . append ( popup ) ;
1395
+
1396
+ var popupFooter = $ ( ".modal-footer" , popup ) [ 0 ] ;
1397
+ webui . detachChildren ( popupFooter ) ;
1398
+
1399
+ $ (
1400
+ '<button class="btn btn-sm btn-warning action-btn" id="revertNoCommitBtn">Revert</button>' +
1401
+ '<button class="btn btn-sm btn-warning action-btn" id="hardResetBtn">Hard Reset</button>' +
1402
+ '<button class="btn btn-sm btn-secondary action-btn" id="cancelRevertBtn">Cancel</button>'
1403
+ ) . appendTo ( popupFooter ) ;
1404
+
1405
+ $ ( popup ) . modal ( 'show' ) ;
1406
+
1407
+ $ ( "#revertNoCommitBtn" ) . on ( 'click' , function ( ) {
1408
+ removePopup ( popup ) ;
1409
+ confirmRevert ( "revert" ) ;
1410
+ } ) ;
1411
+
1412
+ $ ( "#hardResetBtn" ) . on ( 'click' , function ( ) {
1413
+ removePopup ( popup ) ;
1414
+ confirmRevert ( "hardReset" ) ;
1415
+ } ) ;
1416
+
1417
+
1418
+
1419
+ $ ( "#chooseRevert" ) . find ( ".close, #cancelRevertBtn" ) . click ( function ( ) {
1420
+ removePopup ( popup ) ;
1421
+ } )
1422
+ } ;
1423
+
1424
+
1336
1425
self . parents = [ ] ;
1337
1426
self . message = ""
1338
1427
@@ -1363,6 +1452,11 @@ webui.LogView = function(historyView) {
1363
1452
self . message = self . message . trim ( ) ;
1364
1453
1365
1454
self . createElement ( ) ;
1455
+
1456
+ $ ( "#revertBtn" ) . off ( "click" ) ;
1457
+ $ ( "#revertBtn" ) . on ( "click" , function ( ) {
1458
+ self . chooseRevert ( ) ;
1459
+ } ) ;
1366
1460
} ;
1367
1461
1368
1462
self . historyView = historyView ;
0 commit comments