Browse Source

Adds indicator if view auto-refresh is unavailable

main
Eric Amodio 3 years ago
parent
commit
0afba2c575
9 changed files with 67 additions and 15 deletions
  1. +1
    -0
      src/constants.ts
  2. +6
    -1
      src/views/branchesView.ts
  3. +17
    -5
      src/views/commitsView.ts
  4. +6
    -1
      src/views/contributorsView.ts
  5. +4
    -2
      src/views/nodes/repositoryNode.ts
  6. +7
    -1
      src/views/nodes/viewNode.ts
  7. +6
    -1
      src/views/remotesView.ts
  8. +6
    -1
      src/views/stashesView.ts
  9. +14
    -3
      src/views/tagsView.ts

+ 1
- 0
src/constants.ts View File

@ -144,6 +144,7 @@ export enum GlyphChars {
SpaceThinnest = '\u200A', SpaceThinnest = '\u200A',
SquareWithBottomShadow = '\u274F', SquareWithBottomShadow = '\u274F',
SquareWithTopShadow = '\u2750', SquareWithTopShadow = '\u2750',
Warning = '\u26a0',
ZeroWidthSpace = '\u200b', ZeroWidthSpace = '\u200b',
} }

+ 6
- 1
src/views/branchesView.ts View File

@ -15,6 +15,7 @@ import {
ViewFilesLayout, ViewFilesLayout,
ViewShowBranchComparison, ViewShowBranchComparison,
} from '../configuration'; } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { import {
GitBranchReference, GitBranchReference,
@ -34,7 +35,7 @@ import {
unknownGitUri, unknownGitUri,
ViewNode, ViewNode,
} from './nodes'; } from './nodes';
import { debug, gate } from '../system';
import { debug, gate, Strings } from '../system';
import { ViewBase } from './viewBase'; import { ViewBase } from './viewBase';
export class BranchesRepositoryNode extends RepositoryFolderNode<BranchesView, BranchesNode> { export class BranchesRepositoryNode extends RepositoryFolderNode<BranchesView, BranchesNode> {
@ -85,6 +86,10 @@ export class BranchesViewNode extends ViewNode {
if (this.children.length === 1) { if (this.children.length === 1) {
const [child] = this.children; const [child] = this.children;
if (!child.repo.supportsChangeEvents) {
this.view.description = `${Strings.pad(GlyphChars.Warning, 0, 2)}Auto-refresh unavailable`;
}
const branches = await child.repo.getBranches({ filter: b => !b.remote }); const branches = await child.repo.getBranches({ filter: b => !b.remote });
if (branches.length === 0) { if (branches.length === 0) {
this.view.message = 'No branches could be found.'; this.view.message = 'No branches could be found.';

+ 17
- 5
src/views/commitsView.ts View File

@ -86,10 +86,12 @@ export class CommitsRepositoryNode extends RepositoryFolderNode
item.contextValue = `${ContextValues.RepositoryFolder}${this.repo.starred ? '+starred' : ''}`; item.contextValue = `${ContextValues.RepositoryFolder}${this.repo.starred ? '+starred' : ''}`;
if (branch != null) { if (branch != null) {
const lastFetched = (await this.repo?.getLastFetched()) ?? 0;
const lastFetched = (await this.repo.getLastFetched()) ?? 0;
const status = branch?.getTrackingStatus(); const status = branch?.getTrackingStatus();
item.description = `${status ? `${status}${Strings.pad(GlyphChars.Dot, 1, 1)}` : ''}${branch.name}${
item.description = `${this.repo.supportsChangeEvents ? '' : Strings.pad(GlyphChars.Warning, 1, 2)}${
status ? `${status}${Strings.pad(GlyphChars.Dot, 1, 1)}` : ''
}${branch.name}${
lastFetched lastFetched
? `${Strings.pad(GlyphChars.Dot, 1, 1)}Last fetched ${Repository.formatLastFetched(lastFetched)}` ? `${Strings.pad(GlyphChars.Dot, 1, 1)}Last fetched ${Repository.formatLastFetched(lastFetched)}`
: '' : ''
@ -126,6 +128,10 @@ export class CommitsRepositoryNode extends RepositoryFolderNode
suffix: ` $(git-branch) ${branch.tracking}${providerName ? ` on ${providerName}` : ''}`, suffix: ` $(git-branch) ${branch.tracking}${providerName ? ` on ${providerName}` : ''}`,
})}` })}`
: `hasn't been published to ${providerName ?? 'a remote'}` : `hasn't been published to ${providerName ?? 'a remote'}`
}${
this.repo.supportsChangeEvents
? ''
: `\n\n${GlyphChars.Warning} Unable to automatically detect repository changes`
}`, }`,
true, true,
); );
@ -213,14 +219,20 @@ export class CommitsViewNode extends ViewNode {
const branch = await child.repo.getBranch(); const branch = await child.repo.getBranch();
if (branch != null) { if (branch != null) {
const lastFetched = (await child.repo?.getLastFetched()) ?? 0;
const lastFetched = (await child.repo.getLastFetched()) ?? 0;
const status = branch.getTrackingStatus(); const status = branch.getTrackingStatus();
this.view.description = `${status ? `${status} ${GlyphChars.Dot} ` : ''}${branch.name}${ this.view.description = `${status ? `${status} ${GlyphChars.Dot} ` : ''}${branch.name}${
branch.rebasing ? ' (Rebasing)' : '' branch.rebasing ? ' (Rebasing)' : ''
}${lastFetched ? ` ${GlyphChars.Dot} Last fetched ${Repository.formatLastFetched(lastFetched)}` : ''}`;
}${lastFetched ? ` ${GlyphChars.Dot} Last fetched ${Repository.formatLastFetched(lastFetched)}` : ''}${
child.repo.supportsChangeEvents
? ''
: `${Strings.pad(GlyphChars.Warning, 3, 2)}Auto-refresh unavailable`
}`;
} else { } else {
this.view.description = undefined;
this.view.description = child.repo.supportsChangeEvents
? undefined
: `${Strings.pad(GlyphChars.Warning, 1, 2)}Auto-refresh unavailable`;
} }
return child.getChildren(); return child.getChildren();

+ 6
- 1
src/views/contributorsView.ts View File

@ -2,11 +2,12 @@
import { commands, ConfigurationChangeEvent, Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode'; import { commands, ConfigurationChangeEvent, Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Avatars } from '../avatars'; import { Avatars } from '../avatars';
import { configuration, ContributorsViewConfig, ViewFilesLayout } from '../configuration'; import { configuration, ContributorsViewConfig, ViewFilesLayout } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { RepositoryChange, RepositoryChangeEvent } from '../git/git'; import { RepositoryChange, RepositoryChangeEvent } from '../git/git';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import { ContributorsNode, RepositoryFolderNode, unknownGitUri, ViewNode } from './nodes'; import { ContributorsNode, RepositoryFolderNode, unknownGitUri, ViewNode } from './nodes';
import { debug, gate } from '../system';
import { debug, gate, Strings } from '../system';
import { ViewBase } from './viewBase'; import { ViewBase } from './viewBase';
export class ContributorsRepositoryNode extends RepositoryFolderNode<ContributorsView, ContributorsNode> { export class ContributorsRepositoryNode extends RepositoryFolderNode<ContributorsView, ContributorsNode> {
@ -64,6 +65,10 @@ export class ContributorsViewNode extends ViewNode {
if (this.children.length === 1) { if (this.children.length === 1) {
const [child] = this.children; const [child] = this.children;
if (!child.repo.supportsChangeEvents) {
this.view.description = `${Strings.pad(GlyphChars.Warning, 0, 2)}Auto-refresh unavailable`;
}
const contributors = await child.repo.getContributors(); const contributors = await child.repo.getContributors();
if (contributors.length === 0) { if (contributors.length === 0) {
this.view.message = 'No contributors could be found.'; this.view.message = 'No contributors could be found.';

+ 4
- 2
src/views/nodes/repositoryNode.ts View File

@ -249,8 +249,10 @@ export class RepositoryNode extends SubscribeableViewNode {
} }
if (!this.repo.supportsChangeEvents) { if (!this.repo.supportsChangeEvents) {
description = `<!>${description ? ` ${GlyphChars.Space}${description}` : ''}`;
tooltip += '\n\n<!> Unable to automatically detect repository changes';
description = `${Strings.pad(GlyphChars.Warning, 1, 0)}${
description ? Strings.pad(description, 2, 0) : ''
}`;
tooltip += `\n\n${GlyphChars.Warning} Unable to automatically detect repository changes`;
} }
const item = new TreeItem(label, TreeItemCollapsibleState.Expanded); const item = new TreeItem(label, TreeItemCollapsibleState.Expanded);

+ 7
- 1
src/views/nodes/viewNode.ts View File

@ -1,5 +1,6 @@
'use strict'; 'use strict';
import { Command, Disposable, Event, TreeItem, TreeItemCollapsibleState, TreeViewVisibilityChangeEvent } from 'vscode'; import { Command, Disposable, Event, TreeItem, TreeItemCollapsibleState, TreeViewVisibilityChangeEvent } from 'vscode';
import { GlyphChars } from '../../constants';
import { Container } from '../../container'; import { Container } from '../../container';
import { import {
GitFile, GitFile,
@ -11,7 +12,7 @@ import {
} from '../../git/git'; } from '../../git/git';
import { GitUri } from '../../git/gitUri'; import { GitUri } from '../../git/gitUri';
import { Logger } from '../../logger'; import { Logger } from '../../logger';
import { debug, Functions, gate, log, logName } from '../../system';
import { debug, Functions, gate, log, logName, Strings } from '../../system';
import { TreeViewNodeCollapsibleStateChangeEvent, View } from '../viewBase'; import { TreeViewNodeCollapsibleStateChangeEvent, View } from '../viewBase';
export enum ContextValues { export enum ContextValues {
@ -352,8 +353,13 @@ export abstract class RepositoryFolderNode<
expand ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed, expand ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed,
); );
item.contextValue = `${ContextValues.RepositoryFolder}${this.repo.starred ? '+starred' : ''}`; item.contextValue = `${ContextValues.RepositoryFolder}${this.repo.starred ? '+starred' : ''}`;
item.description = this.repo.supportsChangeEvents ? undefined : Strings.pad(GlyphChars.Warning, 1, 0);
item.tooltip = `${ item.tooltip = `${
this.repo.formattedName ? `${this.repo.formattedName}\n${this.uri.repoPath}` : this.uri.repoPath ?? '' this.repo.formattedName ? `${this.repo.formattedName}\n${this.uri.repoPath}` : this.uri.repoPath ?? ''
}${
this.repo.supportsChangeEvents
? ''
: `\n\n${GlyphChars.Warning} Unable to automatically detect repository changes`
}`; }`;
return item; return item;

+ 6
- 1
src/views/remotesView.ts View File

@ -9,6 +9,7 @@ import {
window, window,
} from 'vscode'; } from 'vscode';
import { configuration, RemotesViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../configuration'; import { configuration, RemotesViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { import {
GitBranch, GitBranch,
@ -31,7 +32,7 @@ import {
unknownGitUri, unknownGitUri,
ViewNode, ViewNode,
} from './nodes'; } from './nodes';
import { debug, gate } from '../system';
import { debug, gate, Strings } from '../system';
import { ViewBase } from './viewBase'; import { ViewBase } from './viewBase';
export class RemotesRepositoryNode extends RepositoryFolderNode<RemotesView, RemotesNode> { export class RemotesRepositoryNode extends RepositoryFolderNode<RemotesView, RemotesNode> {
@ -80,6 +81,10 @@ export class RemotesViewNode extends ViewNode {
if (this.children.length === 1) { if (this.children.length === 1) {
const [child] = this.children; const [child] = this.children;
if (!child.repo.supportsChangeEvents) {
this.view.description = `${Strings.pad(GlyphChars.Warning, 0, 2)}Auto-refresh unavailable`;
}
const remotes = await child.repo.getRemotes(); const remotes = await child.repo.getRemotes();
if (remotes.length === 0) { if (remotes.length === 0) {
this.view.message = 'No remotes could be found.'; this.view.message = 'No remotes could be found.';

+ 6
- 1
src/views/stashesView.ts View File

@ -9,11 +9,12 @@ import {
window, window,
} from 'vscode'; } from 'vscode';
import { configuration, StashesViewConfig, ViewFilesLayout } from '../configuration'; import { configuration, StashesViewConfig, ViewFilesLayout } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitReference, GitStashReference, RepositoryChange, RepositoryChangeEvent } from '../git/git'; import { GitReference, GitStashReference, RepositoryChange, RepositoryChangeEvent } from '../git/git';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import { RepositoryFolderNode, RepositoryNode, StashesNode, StashNode, unknownGitUri, ViewNode } from './nodes'; import { RepositoryFolderNode, RepositoryNode, StashesNode, StashNode, unknownGitUri, ViewNode } from './nodes';
import { debug, gate } from '../system';
import { debug, gate, Strings } from '../system';
import { ViewBase } from './viewBase'; import { ViewBase } from './viewBase';
export class StashesRepositoryNode extends RepositoryFolderNode<StashesView, StashesNode> { export class StashesRepositoryNode extends RepositoryFolderNode<StashesView, StashesNode> {
@ -62,6 +63,10 @@ export class StashesViewNode extends ViewNode {
if (this.children.length === 1) { if (this.children.length === 1) {
const [child] = this.children; const [child] = this.children;
if (!child.repo.supportsChangeEvents) {
this.view.description = `${Strings.pad(GlyphChars.Warning, 0, 2)}Auto-refresh unavailable`;
}
const stash = await child.repo.getStash(); const stash = await child.repo.getStash();
if (stash == null) { if (stash == null) {
this.view.message = 'No stashes could be found.'; this.view.message = 'No stashes could be found.';

+ 14
- 3
src/views/tagsView.ts View File

@ -9,13 +9,20 @@ import {
window, window,
} from 'vscode'; } from 'vscode';
import { configuration, TagsViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../configuration'; import { configuration, TagsViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitReference, GitTagReference, RepositoryChange, RepositoryChangeEvent } from '../git/git'; import { GitReference, GitTagReference, RepositoryChange, RepositoryChangeEvent } from '../git/git';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import { RepositoryFolderNode, RepositoryNode, TagsNode, unknownGitUri, ViewNode } from './nodes';
import { debug, gate } from '../system';
import {
BranchOrTagFolderNode,
RepositoryFolderNode,
RepositoryNode,
TagsNode,
unknownGitUri,
ViewNode,
} from './nodes';
import { debug, gate, Strings } from '../system';
import { ViewBase } from './viewBase'; import { ViewBase } from './viewBase';
import { BranchOrTagFolderNode } from './nodes/branchOrTagFolderNode';
export class TagsRepositoryNode extends RepositoryFolderNode<TagsView, TagsNode> { export class TagsRepositoryNode extends RepositoryFolderNode<TagsView, TagsNode> {
async getChildren(): Promise<ViewNode[]> { async getChildren(): Promise<ViewNode[]> {
@ -63,6 +70,10 @@ export class TagsViewNode extends ViewNode {
if (this.children.length === 1) { if (this.children.length === 1) {
const [child] = this.children; const [child] = this.children;
if (!child.repo.supportsChangeEvents) {
this.view.description = `${Strings.pad(GlyphChars.Warning, 0, 2)}Auto-refresh unavailable`;
}
const tags = await child.repo.getTags(); const tags = await child.repo.getTags();
if (tags.length === 0) { if (tags.length === 0) {
this.view.message = 'No tags could be found.'; this.view.message = 'No tags could be found.';

Loading…
Cancel
Save