Browse Source

Closes #2690 adds full history option to timeline

main
Eric Amodio 1 year ago
parent
commit
06c0243604
4 changed files with 10 additions and 5 deletions
  1. +1
    -1
      src/plus/webviews/timeline/protocol.ts
  2. +4
    -2
      src/plus/webviews/timeline/timelineWebview.ts
  3. +1
    -0
      src/webviews/apps/plus/timeline/timeline.html
  4. +4
    -2
      src/webviews/apps/plus/timeline/timeline.ts

+ 1
- 1
src/plus/webviews/timeline/protocol.ts View File

@ -28,7 +28,7 @@ export interface Commit {
sort: number;
}
export type Period = `${number}|${'D' | 'M' | 'Y'}`;
export type Period = `${number}|${'D' | 'M' | 'Y'}` | 'all';
export interface DidChangeParams {
state: State;

+ 4
- 2
src/plus/webviews/timeline/timelineWebview.ts View File

@ -292,7 +292,7 @@ export class TimelineWebviewProvider implements WebviewProvider {
this.container.git.getLogForFile(repoPath, gitUri.fsPath, {
limit: 0,
ref: gitUri.sha,
since: getPeriodDate(period).toISOString(),
since: getPeriodDate(period)?.toISOString(),
}),
]);
@ -471,7 +471,9 @@ function generateRandomTimelineDataset(): Commit[] {
return dataset;
}
function getPeriodDate(period: Period): Date {
function getPeriodDate(period: Period): Date | undefined {
if (period == 'all') return undefined;
const [number, unit] = period.split('|');
let date;

+ 1
- 0
src/webviews/apps/plus/timeline/timeline.html View File

@ -27,6 +27,7 @@
<vscode-option value="1|Y">1 year</vscode-option>
<vscode-option value="2|Y">2 years</vscode-option>
<vscode-option value="4|Y">4 years</vscode-option>
<vscode-option value="all">Full history</vscode-option>
</vscode-dropdown>
</div>
</div>

+ 4
- 2
src/webviews/apps/plus/timeline/timeline.ts View File

@ -2,7 +2,7 @@
import './timeline.scss';
import { provideVSCodeDesignSystem, vsCodeButton, vsCodeDropdown, vsCodeOption } from '@vscode/webview-ui-toolkit';
import { GlyphChars } from '../../../../constants';
import type { State } from '../../../../plus/webviews/timeline/protocol';
import type { Period, State } from '../../../../plus/webviews/timeline/protocol';
import {
DidChangeNotificationType,
OpenDataPointCommandType,
@ -189,7 +189,9 @@ export class TimelineApp extends App {
}
}
function assertPeriod(period: string): asserts period is `${number}|${'D' | 'M' | 'Y'}` {
function assertPeriod(period: string): asserts period is Period {
if (period === 'all') return;
const [value, unit] = period.split('|');
if (isNaN(Number(value)) || (unit !== 'D' && unit !== 'M' && unit !== 'Y')) {
throw new Error(`Invalid period: ${period}`);

Loading…
Cancel
Save