Fossil SCM

Diff context chunk loader UI controls now show a load-pending message and any error messages directly next to the controls, rather than via toasts, per forum feedback.

stephan 2021-09-21 18:17 trunk
Commit ba400826919f8d68b42d1ad9a76eb582c989b09774e0886347ab8ec8dd5a89e9
+1 -1
--- src/builtin.c
+++ src/builtin.c
@@ -704,11 +704,11 @@
704704
** the final one! */
705705
} fjs[] = {
706706
/* This list ordering isn't strictly important. */
707707
{"confirmer", 0, 0},
708708
{"copybutton", 0, "dom\0"},
709
- {"diff", 0, "dom\0fetch\0popupwidget\0"},
709
+ {"diff", 0, "dom\0fetch\0"},
710710
{"dom", 0, 0},
711711
{"fetch", 0, 0},
712712
{"numbered-lines", 0, "popupwidget\0copybutton\0"},
713713
{"pikchr", 0, "dom\0"},
714714
{"popupwidget", 0, "dom\0"},
715715
--- src/builtin.c
+++ src/builtin.c
@@ -704,11 +704,11 @@
704 ** the final one! */
705 } fjs[] = {
706 /* This list ordering isn't strictly important. */
707 {"confirmer", 0, 0},
708 {"copybutton", 0, "dom\0"},
709 {"diff", 0, "dom\0fetch\0popupwidget\0"},
710 {"dom", 0, 0},
711 {"fetch", 0, 0},
712 {"numbered-lines", 0, "popupwidget\0copybutton\0"},
713 {"pikchr", 0, "dom\0"},
714 {"popupwidget", 0, "dom\0"},
715
--- src/builtin.c
+++ src/builtin.c
@@ -704,11 +704,11 @@
704 ** the final one! */
705 } fjs[] = {
706 /* This list ordering isn't strictly important. */
707 {"confirmer", 0, 0},
708 {"copybutton", 0, "dom\0"},
709 {"diff", 0, "dom\0fetch\0"},
710 {"dom", 0, 0},
711 {"fetch", 0, 0},
712 {"numbered-lines", 0, "popupwidget\0copybutton\0"},
713 {"pikchr", 0, "dom\0"},
714 {"popupwidget", 0, "dom\0"},
715
+6 -1
--- src/default.css
+++ src/default.css
@@ -602,11 +602,16 @@
602602
tr.diffskip > td.chunkctrl {
603603
text-align: left;
604604
font-family: monospace;
605605
}
606606
tr.diffskip > td.chunkctrl > div {
607
- /* Exists solely for layout purposes. */
607
+ display: flex;
608
+ align-items: center;
609
+}
610
+tr.diffskip > td.chunkctrl > div > span.error {
611
+ padding: 0.25em 0.5em;
612
+ border-radius: 0.5em;
608613
}
609614
tr.diffskip > td.chunkctrl .jcbutton
610615
/* class name .button breaks w/ some skins! */ {
611616
min-width: 3.5ex;
612617
max-width: 3.5ex;
613618
--- src/default.css
+++ src/default.css
@@ -602,11 +602,16 @@
602 tr.diffskip > td.chunkctrl {
603 text-align: left;
604 font-family: monospace;
605 }
606 tr.diffskip > td.chunkctrl > div {
607 /* Exists solely for layout purposes. */
 
 
 
 
 
608 }
609 tr.diffskip > td.chunkctrl .jcbutton
610 /* class name .button breaks w/ some skins! */ {
611 min-width: 3.5ex;
612 max-width: 3.5ex;
613
--- src/default.css
+++ src/default.css
@@ -602,11 +602,16 @@
602 tr.diffskip > td.chunkctrl {
603 text-align: left;
604 font-family: monospace;
605 }
606 tr.diffskip > td.chunkctrl > div {
607 display: flex;
608 align-items: center;
609 }
610 tr.diffskip > td.chunkctrl > div > span.error {
611 padding: 0.25em 0.5em;
612 border-radius: 0.5em;
613 }
614 tr.diffskip > td.chunkctrl .jcbutton
615 /* class name .button breaks w/ some skins! */ {
616 min-width: 3.5ex;
617 max-width: 3.5ex;
618
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -33,11 +33,11 @@
3333
/* Default callack handlers for Diff.fetchArtifactChunk(),
3434
unless overridden by options passeed to that function. */
3535
beforesend: function(){},
3636
aftersend: function(){},
3737
onerror: function(e){
38
- F.toast.error("XHR error: ",e.message);
38
+ console.error("XHR error: ",e);
3939
}
4040
}
4141
}
4242
};
4343
/**
@@ -138,10 +138,11 @@
138138
this.e.td = D.addClass(
139139
/* Holder for our UI controls */
140140
D.attr(D.td(tr), 'colspan', this.isSplit ? 5 : 4),
141141
'chunkctrl'
142142
);
143
+ this.e.msgWidget = D.addClass(D.span(), 'hidden');
143144
this.e.btnWrapper = D.div();
144145
D.append(this.e.td, this.e.btnWrapper);
145146
/**
146147
Depending on various factors, we need one or more of:
147148
@@ -188,10 +189,11 @@
188189
}
189190
//this.e.btnUp = btnUp;
190191
//this.e.btnDown = btnDown;
191192
if(btnDown) D.append(this.e.btnWrapper, btnDown);
192193
if(btnUp) D.append(this.e.btnWrapper, btnUp);
194
+ D.append(this.e.btnWrapper, this.e.msgWidget);
193195
/* For debugging only... */
194196
this.e.posState = D.span();
195197
D.append(this.e.btnWrapper, this.e.posState);
196198
this.updatePosDebug();
197199
};
@@ -295,10 +297,11 @@
295297
if(!lines.length){
296298
/* No more data to load */
297299
this.destroy();
298300
return this;
299301
}
302
+ this.msg(false);
300303
//console.debug("Loaded line range ",
301304
//urlParam.from,"-",urlParam.to, "fetchType ",fetchType);
302305
const lineno = [],
303306
trPrev = this.e.tr.previousElementSibling,
304307
trNext = this.e.tr.nextElementSibling,
@@ -454,10 +457,28 @@
454457
return this;
455458
}else{
456459
throw new Error("Unexpected 'fetchType' value.");
457460
}
458461
},
462
+
463
+ /**
464
+ Sets this widget's message to the given text. If the message
465
+ represents an error, the first argument must be truthy, else it
466
+ must be falsy. Returns this object.
467
+ */
468
+ msg: function(isError,txt){
469
+ if(txt){
470
+ if(isError) D.addClass(this.e.msgWidget, 'error');
471
+ else D.removeClass(this.e.msgWidget, 'error');
472
+ D.append(
473
+ D.removeClass(D.clearElement(this.e.msgWidget), 'hidden'),
474
+ txt);
475
+ }else{
476
+ D.addClass(D.clearElement(this.e.msgWidget), 'hidden');
477
+ }
478
+ return this;
479
+ },
459480
460481
/**
461482
Fetches and inserts a line chunk. fetchType is:
462483
463484
this.FetchType.NextUp = upwards from next chunk (this.pos.next)
@@ -480,18 +501,18 @@
480501
fetchChunk: function(fetchType){
481502
/* Forewarning, this is a bit confusing: when fetching the
482503
previous lines, we're doing so on behalf of the *next* diff
483504
chunk (this.pos.next), and vice versa. */
484505
if(this.$isFetching){
485
- F.toast.warning("Cannot load chunk while a load is pending.");
486
- return this;
506
+ return this.msg(true,"Cannot load chunk while a load is pending.");
487507
}
488508
if(fetchType===this.FetchType.NextUp && !this.pos.next
489509
|| fetchType===this.FetchType.PrevDown && !this.pos.prev){
490510
console.error("Attempt to fetch diff lines but don't have any.");
491511
return this;
492512
}
513
+ this.msg(false,"Fetching diff chunk...");
493514
const fOpt = {
494515
urlParams:{
495516
name: this.fileHash, from: 0, to: 0
496517
},
497518
aftersend: ()=>delete this.$isFetching,
@@ -528,10 +549,11 @@
528549
fetchType = this.FetchType.FillGap;
529550
}
530551
}
531552
this.$isFetching = true;
532553
//console.debug("fetchChunk(",fetchType,")",up);
554
+ fOpt.onerror = (err)=>this.msg(true,err.message);
533555
Diff.fetchArtifactChunk(fOpt);
534556
return this;
535557
}
536558
};
537559
538560
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -33,11 +33,11 @@
33 /* Default callack handlers for Diff.fetchArtifactChunk(),
34 unless overridden by options passeed to that function. */
35 beforesend: function(){},
36 aftersend: function(){},
37 onerror: function(e){
38 F.toast.error("XHR error: ",e.message);
39 }
40 }
41 }
42 };
43 /**
@@ -138,10 +138,11 @@
138 this.e.td = D.addClass(
139 /* Holder for our UI controls */
140 D.attr(D.td(tr), 'colspan', this.isSplit ? 5 : 4),
141 'chunkctrl'
142 );
 
143 this.e.btnWrapper = D.div();
144 D.append(this.e.td, this.e.btnWrapper);
145 /**
146 Depending on various factors, we need one or more of:
147
@@ -188,10 +189,11 @@
188 }
189 //this.e.btnUp = btnUp;
190 //this.e.btnDown = btnDown;
191 if(btnDown) D.append(this.e.btnWrapper, btnDown);
192 if(btnUp) D.append(this.e.btnWrapper, btnUp);
 
193 /* For debugging only... */
194 this.e.posState = D.span();
195 D.append(this.e.btnWrapper, this.e.posState);
196 this.updatePosDebug();
197 };
@@ -295,10 +297,11 @@
295 if(!lines.length){
296 /* No more data to load */
297 this.destroy();
298 return this;
299 }
 
300 //console.debug("Loaded line range ",
301 //urlParam.from,"-",urlParam.to, "fetchType ",fetchType);
302 const lineno = [],
303 trPrev = this.e.tr.previousElementSibling,
304 trNext = this.e.tr.nextElementSibling,
@@ -454,10 +457,28 @@
454 return this;
455 }else{
456 throw new Error("Unexpected 'fetchType' value.");
457 }
458 },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
460 /**
461 Fetches and inserts a line chunk. fetchType is:
462
463 this.FetchType.NextUp = upwards from next chunk (this.pos.next)
@@ -480,18 +501,18 @@
480 fetchChunk: function(fetchType){
481 /* Forewarning, this is a bit confusing: when fetching the
482 previous lines, we're doing so on behalf of the *next* diff
483 chunk (this.pos.next), and vice versa. */
484 if(this.$isFetching){
485 F.toast.warning("Cannot load chunk while a load is pending.");
486 return this;
487 }
488 if(fetchType===this.FetchType.NextUp && !this.pos.next
489 || fetchType===this.FetchType.PrevDown && !this.pos.prev){
490 console.error("Attempt to fetch diff lines but don't have any.");
491 return this;
492 }
 
493 const fOpt = {
494 urlParams:{
495 name: this.fileHash, from: 0, to: 0
496 },
497 aftersend: ()=>delete this.$isFetching,
@@ -528,10 +549,11 @@
528 fetchType = this.FetchType.FillGap;
529 }
530 }
531 this.$isFetching = true;
532 //console.debug("fetchChunk(",fetchType,")",up);
 
533 Diff.fetchArtifactChunk(fOpt);
534 return this;
535 }
536 };
537
538
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -33,11 +33,11 @@
33 /* Default callack handlers for Diff.fetchArtifactChunk(),
34 unless overridden by options passeed to that function. */
35 beforesend: function(){},
36 aftersend: function(){},
37 onerror: function(e){
38 console.error("XHR error: ",e);
39 }
40 }
41 }
42 };
43 /**
@@ -138,10 +138,11 @@
138 this.e.td = D.addClass(
139 /* Holder for our UI controls */
140 D.attr(D.td(tr), 'colspan', this.isSplit ? 5 : 4),
141 'chunkctrl'
142 );
143 this.e.msgWidget = D.addClass(D.span(), 'hidden');
144 this.e.btnWrapper = D.div();
145 D.append(this.e.td, this.e.btnWrapper);
146 /**
147 Depending on various factors, we need one or more of:
148
@@ -188,10 +189,11 @@
189 }
190 //this.e.btnUp = btnUp;
191 //this.e.btnDown = btnDown;
192 if(btnDown) D.append(this.e.btnWrapper, btnDown);
193 if(btnUp) D.append(this.e.btnWrapper, btnUp);
194 D.append(this.e.btnWrapper, this.e.msgWidget);
195 /* For debugging only... */
196 this.e.posState = D.span();
197 D.append(this.e.btnWrapper, this.e.posState);
198 this.updatePosDebug();
199 };
@@ -295,10 +297,11 @@
297 if(!lines.length){
298 /* No more data to load */
299 this.destroy();
300 return this;
301 }
302 this.msg(false);
303 //console.debug("Loaded line range ",
304 //urlParam.from,"-",urlParam.to, "fetchType ",fetchType);
305 const lineno = [],
306 trPrev = this.e.tr.previousElementSibling,
307 trNext = this.e.tr.nextElementSibling,
@@ -454,10 +457,28 @@
457 return this;
458 }else{
459 throw new Error("Unexpected 'fetchType' value.");
460 }
461 },
462
463 /**
464 Sets this widget's message to the given text. If the message
465 represents an error, the first argument must be truthy, else it
466 must be falsy. Returns this object.
467 */
468 msg: function(isError,txt){
469 if(txt){
470 if(isError) D.addClass(this.e.msgWidget, 'error');
471 else D.removeClass(this.e.msgWidget, 'error');
472 D.append(
473 D.removeClass(D.clearElement(this.e.msgWidget), 'hidden'),
474 txt);
475 }else{
476 D.addClass(D.clearElement(this.e.msgWidget), 'hidden');
477 }
478 return this;
479 },
480
481 /**
482 Fetches and inserts a line chunk. fetchType is:
483
484 this.FetchType.NextUp = upwards from next chunk (this.pos.next)
@@ -480,18 +501,18 @@
501 fetchChunk: function(fetchType){
502 /* Forewarning, this is a bit confusing: when fetching the
503 previous lines, we're doing so on behalf of the *next* diff
504 chunk (this.pos.next), and vice versa. */
505 if(this.$isFetching){
506 return this.msg(true,"Cannot load chunk while a load is pending.");
 
507 }
508 if(fetchType===this.FetchType.NextUp && !this.pos.next
509 || fetchType===this.FetchType.PrevDown && !this.pos.prev){
510 console.error("Attempt to fetch diff lines but don't have any.");
511 return this;
512 }
513 this.msg(false,"Fetching diff chunk...");
514 const fOpt = {
515 urlParams:{
516 name: this.fileHash, from: 0, to: 0
517 },
518 aftersend: ()=>delete this.$isFetching,
@@ -528,10 +549,11 @@
549 fetchType = this.FetchType.FillGap;
550 }
551 }
552 this.$isFetching = true;
553 //console.debug("fetchChunk(",fetchType,")",up);
554 fOpt.onerror = (err)=>this.msg(true,err.message);
555 Diff.fetchArtifactChunk(fOpt);
556 return this;
557 }
558 };
559
560

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button