Skip to content

Commit e68e1dd

Browse files
committed
Improves timeline slice by interaction mode
- Auto-enables show all branches when slice by branch is selected - Auto-switches to slice by author when show all branches is unchecked
1 parent 3a7ec96 commit e68e1dd

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

src/webviews/apps/plus/timeline/timeline.ts

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,12 @@ export class GlTimelineApp extends GlAppHost<State> {
9494
return !this.repository?.virtual;
9595
}
9696

97-
get isSliceByAllowed() {
98-
return this.config.showAllBranches && this.isSliceBySupported;
99-
}
100-
10197
get isSliceBySupported() {
10298
return !this.repository?.virtual && (this.scope?.type === 'file' || this.scope?.type === 'folder');
10399
}
104100

105101
get sliceBy() {
106-
return this.isSliceByAllowed ? this.config.sliceBy : 'author';
102+
return this.isSliceBySupported && this.config.showAllBranches ? this.config.sliceBy : 'author';
107103
}
108104

109105
get subscription() {
@@ -465,27 +461,22 @@ export class GlTimelineApp extends GlAppHost<State> {
465461
private renderConfigSliceBy() {
466462
if (!this.isSliceBySupported) return nothing;
467463

468-
const { sliceBy, isSliceByAllowed } = this;
469-
470-
const template = html`<label for="sliceBy" ?disabled=${!isSliceByAllowed}>Slice By</label>
471-
<select
472-
class="select"
473-
name="sliceBy"
474-
position="below"
475-
.value=${sliceBy}
476-
?disabled=${!isSliceByAllowed}
477-
@change=${this.onSliceByChanged}
478-
>
479-
<option value="author" ?selected=${sliceBy === 'author'}>Author</option>
480-
<option value="branch" ?selected=${sliceBy === 'branch'}>Branch</option>
481-
</select>`;
482-
483-
if (isSliceByAllowed) return html`<section><span class="select-container">${template}</span></section>`;
464+
const { sliceBy } = this;
484465

485466
return html`<section>
486-
<gl-tooltip style="width: 100%" content="Slicing by branches is only available when viewing all branches">
487-
<span class="select-container">${template}</span>
488-
</gl-tooltip>
467+
<span class="select-container"
468+
><label for="sliceBy">Slice By</label>
469+
<select
470+
class="select"
471+
name="sliceBy"
472+
position="below"
473+
.value=${sliceBy}
474+
@change=${this.onSliceByChanged}
475+
>
476+
<option value="author" ?selected=${sliceBy === 'author'}>Author</option>
477+
<option value="branch" ?selected=${sliceBy === 'branch'}>Branch</option>
478+
</select></span
479+
>
489480
</section>`;
490481
}
491482

src/webviews/plus/timeline/timelineWebview.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,19 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
452452
if (changes.showAllBranches != null && changes.showAllBranches !== config.showAllBranches) {
453453
changed = true;
454454
config.showAllBranches = changes.showAllBranches;
455+
456+
if (config.sliceBy === 'branch' && !config.showAllBranches) {
457+
config.sliceBy = 'author';
458+
}
455459
}
456460

457461
if (changes.sliceBy != null && changes.sliceBy !== config.sliceBy) {
458462
changed = true;
459463
config.sliceBy = changes.sliceBy;
464+
465+
if (config.sliceBy === 'branch' && !config.showAllBranches) {
466+
config.showAllBranches = true;
467+
}
460468
}
461469

462470
if (changed) {

0 commit comments

Comments
 (0)