@@ -1096,10 +1096,10 @@ webui.LogView = function(historyView) {
1096
1096
streams = [ ]
1097
1097
$ ( content ) . empty ( ) ;
1098
1098
self . nextRef = ref ;
1099
- self . populate ( ) ;
1099
+ self . populate ( ref ) ;
1100
1100
} ;
1101
1101
1102
- self . populate = function ( ) {
1102
+ self . populate = function ( ref ) {
1103
1103
var maxCount = 1000 ;
1104
1104
if ( content . childElementCount > 0 ) {
1105
1105
// The last node is the 'Show more commits placeholder'. Remove it.
@@ -1118,8 +1118,7 @@ webui.LogView = function(historyView) {
1118
1118
}
1119
1119
var end = data . length ;
1120
1120
}
1121
-
1122
- var entry = new Entry ( self , data . substring ( start , end ) ) ;
1121
+ var entry = new Entry ( self , data . substring ( start , end ) , count == 0 ? true : false , ref ) ;
1123
1122
content . appendChild ( entry . element ) ;
1124
1123
if ( ! self . lineHeight ) {
1125
1124
self . lineHeight = Math . ceil ( $ ( entry . element ) . outerHeight ( ) / 2 ) * 2 ;
@@ -1260,7 +1259,7 @@ webui.LogView = function(historyView) {
1260
1259
this . date . setUTCSeconds ( parseInt ( secs ) ) ;
1261
1260
} ;
1262
1261
1263
- function Entry ( logView , data ) {
1262
+ function Entry ( logView , data , revert , ref ) {
1264
1263
var self = this ;
1265
1264
1266
1265
self . abbrevCommitHash = function ( ) {
@@ -1277,13 +1276,20 @@ webui.LogView = function(historyView) {
1277
1276
} ;
1278
1277
1279
1278
self . createElement = function ( ) {
1279
+ var contents = "" ;
1280
+ if ( revert && ( ref == 'HEAD' || ref == $ ( '.branch-current' ) . text ( ) ) ) {
1281
+ contents = '<div style="overflow:hidden; display: flex"><p class="list-group-item-text"></p>' +
1282
+ '<button type="button" class="btn btn-danger file-action-button" id="revertBtn" style="margin-left: 20px;">Revert</button></div>'
1283
+ } else {
1284
+ contents = '<p class="list-group-item-text"></p>'
1285
+ }
1280
1286
self . element = $ ( '<a class="log-entry list-group-item">' +
1281
1287
'<header>' +
1282
1288
'<h6></h6>' +
1283
1289
'<span class="log-entry-date">' + self . author . date . toLocaleString ( ) + ' </span> ' +
1284
1290
'<span class="badge">' + self . abbrevCommitHash ( ) + '</span>' +
1285
1291
'</header>' +
1286
- '<p class="list-group-item-text"></p>' +
1292
+ contents +
1287
1293
'</a>' ) [ 0 ] ;
1288
1294
$ ( '<a target="_blank" href="mailto:' + self . author . email + '">' + self . author . name + '</a>' ) . appendTo ( $ ( "h6" , self . element ) ) ;
1289
1295
$ ( ".list-group-item-text" , self . element ) [ 0 ] . appendChild ( document . createTextNode ( self . abbrevMessage ( ) ) ) ;
@@ -1324,6 +1330,89 @@ webui.LogView = function(historyView) {
1324
1330
}
1325
1331
} ;
1326
1332
1333
+ self . chooseRevert = function ( ) {
1334
+ function removePopup ( popup ) {
1335
+ $ ( popup ) . children ( ".modal-fade" ) . modal ( "hide" ) ;
1336
+ $ ( ".modal-backdrop" ) . remove ( ) ;
1337
+ $ ( "#chooseRevert" ) . remove ( ) ;
1338
+ }
1339
+
1340
+ function confirmRevert ( type ) {
1341
+ if ( type == 'revert' ) {
1342
+ webui . git_command ( [ "revert" , "--no-commit" , "HEAD" ] , function ( output ) {
1343
+ webui . showSuccess ( output ) ;
1344
+ workspaceView . update ( ) ;
1345
+ } ) ;
1346
+ } else if ( type == 'hardReset' ) {
1347
+ webui . git_command ( [ "reset" , "--hard" , "HEAD~1" ] , function ( output ) {
1348
+ webui . showSuccess ( output ) ;
1349
+ workspaceView . update ( ) ;
1350
+ } ) ;
1351
+ }
1352
+
1353
+ }
1354
+
1355
+ var popup = $ (
1356
+ '<div class="modal fade" tabindex="-1" id="chooseRevert" role="dialog" data-backdrop="static">' +
1357
+ '<div class="modal-dialog modal-md" role="document">' +
1358
+ '<div class="modal-content">' +
1359
+ '<div class="modal-header">' +
1360
+ '<h5 class="modal-title">Choose Revert Type</h5>' +
1361
+ '<button type="button" class="btn btn-default close" data-dismiss="modal">' + webui . largeXIcon + '</button>' +
1362
+ '</div>' +
1363
+ '<div class="modal-body">' +
1364
+ '<div class="row">' +
1365
+ '<div class="col-sm-1">' +
1366
+ webui . warningIcon +
1367
+ '</div>' +
1368
+ '<div class="col-sm-11">' +
1369
+ '<p>There are a few options available to revert the previous commit. Please read the description carefully to make sure you choose' +
1370
+ ' the correct option.</p>' +
1371
+ '<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.' +
1372
+ 'It will not be autometically committed, so you can inspect/modify/combine the changes with others before you commit.</p>' +
1373
+ '<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' +
1374
+ ' before the commit. <b>WARNING:</b> This will also delete <b>all uncommitted changes</b>, so make sure you have no changes left before' +
1375
+ ' attempting this operation.</p>' +
1376
+ '</div>' +
1377
+ '</div>' +
1378
+ '</div>' +
1379
+ '<div class="modal-footer"></div>' +
1380
+ '</div>' +
1381
+ '</div>' +
1382
+ '</div>'
1383
+ ) [ 0 ] ;
1384
+
1385
+ $ ( "body" ) . append ( popup ) ;
1386
+
1387
+ var popupFooter = $ ( ".modal-footer" , popup ) [ 0 ] ;
1388
+ webui . detachChildren ( popupFooter ) ;
1389
+
1390
+ $ (
1391
+ '<button class="btn btn-sm btn-warning action-btn" id="revertNoCommitBtn">Revert</button>' +
1392
+ '<button class="btn btn-sm btn-warning action-btn" id="hardResetBtn">Hard Reset</button>' +
1393
+ '<button class="btn btn-sm btn-secondary action-btn" id="cancelRevertBtn">Cancel</button>'
1394
+ ) . appendTo ( popupFooter ) ;
1395
+
1396
+ $ ( popup ) . modal ( 'show' ) ;
1397
+
1398
+ $ ( "#revertNoCommitBtn" ) . on ( 'click' , function ( ) {
1399
+ removePopup ( popup ) ;
1400
+ confirmRevert ( "revert" ) ;
1401
+ } ) ;
1402
+
1403
+ $ ( "#hardResetBtn" ) . on ( 'click' , function ( ) {
1404
+ removePopup ( popup ) ;
1405
+ confirmRevert ( "hardReset" ) ;
1406
+ } ) ;
1407
+
1408
+
1409
+
1410
+ $ ( "#chooseRevert" ) . find ( ".close, #cancelRevertBtn" ) . click ( function ( ) {
1411
+ removePopup ( popup ) ;
1412
+ } )
1413
+ } ;
1414
+
1415
+
1327
1416
self . parents = [ ] ;
1328
1417
self . message = ""
1329
1418
@@ -1354,6 +1443,11 @@ webui.LogView = function(historyView) {
1354
1443
self . message = self . message . trim ( ) ;
1355
1444
1356
1445
self . createElement ( ) ;
1446
+
1447
+ $ ( "#revertBtn" ) . off ( "click" ) ;
1448
+ $ ( "#revertBtn" ) . on ( "click" , function ( ) {
1449
+ self . chooseRevert ( ) ;
1450
+ } ) ;
1357
1451
} ;
1358
1452
1359
1453
self . historyView = historyView ;
0 commit comments