Browse Source

Fixes #2362 allows VFH in mixed repo workspaces

main
Eric Amodio 2 years ago
parent
commit
5bc8c8a7b7
6 changed files with 44 additions and 35 deletions
  1. +1
    -0
      src/plus/webviews/timeline/protocol.ts
  2. +15
    -12
      src/plus/webviews/timeline/timelineWebview.ts
  3. +24
    -14
      src/plus/webviews/timeline/timelineWebviewView.ts
  4. +1
    -1
      src/webviews/apps/plus/timeline/chart.ts
  5. +0
    -1
      src/webviews/apps/plus/timeline/timeline.scss
  6. +3
    -7
      src/webviews/apps/plus/timeline/timeline.ts

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

@ -3,6 +3,7 @@ import { IpcCommandType, IpcNotificationType } from '../../../webviews/protocol'
export interface State {
dataset?: Commit[];
emptyMessage?: string;
period: Period;
title: string;
uri?: string;

+ 15
- 12
src/plus/webviews/timeline/timelineWebview.ts View File

@ -174,38 +174,40 @@ export class TimelineWebview extends WebviewBase {
@debug({ args: false })
private async getState(current: Context): Promise<State> {
const access = await this.container.git.access(PlusFeatures.Timeline);
const dateFormat = configuration.get('defaultDateFormat') ?? 'MMMM Do, YYYY h:mma';
const shortDateFormat = configuration.get('defaultDateShortFormat') ?? 'short';
const period = current.period ?? defaultPeriod;
if (access.allowed === false) {
const dataset = generateRandomTimelineDataset();
if (current.uri == null) {
const access = await this.container.git.access(PlusFeatures.Timeline);
return {
dataset: dataset.sort((a, b) => b.sort - a.sort),
emptyMessage: 'There are no editors open that can provide file history information',
period: period,
title: 'src/app/index.ts',
uri: Uri.file('src/app/index.ts').toString(),
title: '',
dateFormat: dateFormat,
shortDateFormat: shortDateFormat,
access: access,
};
}
if (current.uri == null) {
const gitUri = await GitUri.fromUri(current.uri);
const repoPath = gitUri.repoPath!;
const access = await this.container.git.access(PlusFeatures.Timeline, repoPath);
if (access.allowed === false) {
const dataset = generateRandomTimelineDataset();
return {
dataset: dataset.sort((a, b) => b.sort - a.sort),
period: period,
title: 'There are no editors open that can provide file history information',
title: 'src/app/index.ts',
uri: Uri.file('src/app/index.ts').toString(),
dateFormat: dateFormat,
shortDateFormat: shortDateFormat,
access: access,
};
}
const gitUri = await GitUri.fromUri(current.uri);
const repoPath = gitUri.repoPath!;
const title = gitUri.relativePath;
this.title = `${this.originalTitle}: ${gitUri.fileName}`;
const [currentUser, log] = await Promise.all([
@ -220,8 +222,9 @@ export class TimelineWebview extends WebviewBase {
if (log == null) {
return {
dataset: [],
emptyMessage: 'No commits found for the specified time period',
period: period,
title: 'No commits found for the specified time period',
title: title,
uri: current.uri.toString(),
dateFormat: dateFormat,
shortDateFormat: shortDateFormat,

+ 24
- 14
src/plus/webviews/timeline/timelineWebviewView.ts View File

@ -82,7 +82,7 @@ export class TimelineWebviewView extends WebviewViewBase {
return [
this.container.subscription.onDidChange(this.onSubscriptionChanged, this),
window.onDidChangeActiveTextEditor(this.onActiveEditorChanged, this),
window.onDidChangeActiveTextEditor(debounce(this.onActiveEditorChanged, 250), this),
this.container.git.onDidChangeRepository(this.onRepositoryChanged, this),
this.container.git.onDidChangeRepositories(this.onRepositoriesChanged, this),
];
@ -151,7 +151,14 @@ export class TimelineWebviewView extends WebviewViewBase {
@debug({ args: false })
private onActiveEditorChanged(editor: TextEditor | undefined) {
if (editor == null || !this.container.git.isTrackable(editor.document.uri)) return;
if (editor != null) {
if (!isTextEditor(editor)) return;
if (!this.container.git.isTrackable(editor.document.uri)) {
editor = undefined;
}
}
if (!this.updatePendingEditor(editor)) return;
this.updateState();
@ -186,38 +193,40 @@ export class TimelineWebviewView extends WebviewViewBase {
@debug({ args: false })
private async getState(current: Context): Promise<State> {
const access = await this.container.git.access(PlusFeatures.Timeline);
const dateFormat = configuration.get('defaultDateFormat') ?? 'MMMM Do, YYYY h:mma';
const shortDateFormat = configuration.get('defaultDateShortFormat') ?? 'short';
const period = current.period ?? defaultPeriod;
if (access.allowed === false) {
const dataset = generateRandomTimelineDataset();
if (current.uri == null) {
const access = await this.container.git.access(PlusFeatures.Timeline);
return {
dataset: dataset.sort((a, b) => b.sort - a.sort),
emptyMessage: 'There are no editors open that can provide file history information',
period: period,
title: 'src/app/index.ts',
uri: Uri.file('src/app/index.ts').toString(),
title: '',
dateFormat: dateFormat,
shortDateFormat: shortDateFormat,
access: access,
};
}
if (current.uri == null) {
const gitUri = await GitUri.fromUri(current.uri);
const repoPath = gitUri.repoPath!;
const access = await this.container.git.access(PlusFeatures.Timeline, repoPath);
if (access.allowed === false) {
const dataset = generateRandomTimelineDataset();
return {
dataset: dataset.sort((a, b) => b.sort - a.sort),
period: period,
title: 'There are no editors open that can provide file history information',
title: 'src/app/index.ts',
uri: Uri.file('src/app/index.ts').toString(),
dateFormat: dateFormat,
shortDateFormat: shortDateFormat,
access: access,
};
}
const gitUri = await GitUri.fromUri(current.uri);
const repoPath = gitUri.repoPath!;
const title = gitUri.relativePath;
this.description = gitUri.fileName;
const [currentUser, log] = await Promise.all([
@ -232,8 +241,9 @@ export class TimelineWebviewView extends WebviewViewBase {
if (log == null) {
return {
dataset: [],
emptyMessage: 'No commits found for the specified time period',
period: period,
title: 'No commits found for the specified time period',
title: title,
uri: current.uri.toString(),
dateFormat: dateFormat,
shortDateFormat: shortDateFormat,

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

@ -100,7 +100,7 @@ export class TimelineChart {
$overlay?.classList.toggle('hidden', false);
const $emptyMessage = $overlay.querySelector<HTMLHeadingElement>('[data-bind="empty"]')!;
$emptyMessage.textContent = state.title;
$emptyMessage.textContent = state.emptyMessage ?? '';
return;
}

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

@ -168,7 +168,6 @@ span.button-subaction {
left: 0;
width: 100vw;
height: 100vh;
background-color: var(--color-background);
h1 {
font-weight: 600;

+ 3
- 7
src/webviews/apps/plus/timeline/timeline.ts View File

@ -2,6 +2,7 @@
/*global*/
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 {
DidChangeNotificationType,
@ -93,7 +94,7 @@ export class TimelineApp extends App {
const $slot = document.getElementById('overlay-slot') as HTMLDivElement;
if (this.state.access.allowed !== true) {
if (this.state.access.allowed === false) {
const { current: subscription, required } = this.state.access.subscription;
const requiresPublic = required === SubscriptionPlanId.FreePlus;
@ -128,11 +129,6 @@ export class TimelineApp extends App {
let { title } = this.state;
const empty = this.state.dataset == null || this.state.dataset.length === 0;
if (empty) {
title = '';
}
let description = '';
const index = title.lastIndexOf('/');
if (index >= 0) {
@ -144,7 +140,7 @@ export class TimelineApp extends App {
for (const [key, value] of Object.entries({ title: title, description: description })) {
const $el = document.querySelector(`[data-bind="${key}"]`);
if ($el != null) {
$el.textContent = String(value);
$el.textContent = String(value) || GlyphChars.Space;
}
}

Loading…
Cancel
Save