Browse Source

Consolidates view node view assignments

Ensures view node parent overrides
main
Eric Amodio 1 year ago
parent
commit
151f4bd28a
34 changed files with 110 additions and 106 deletions
  1. +4
    -5
      src/views/nodes/UncommittedFilesNode.ts
  2. +4
    -9
      src/views/nodes/branchNode.ts
  3. +3
    -3
      src/views/nodes/branchOrTagFolderNode.ts
  4. +1
    -1
      src/views/nodes/branchTrackingStatusFilesNode.ts
  5. +1
    -1
      src/views/nodes/branchTrackingStatusNode.ts
  6. +4
    -4
      src/views/nodes/branchesNode.ts
  7. +2
    -3
      src/views/nodes/commitFileNode.ts
  8. +1
    -1
      src/views/nodes/commitNode.ts
  9. +3
    -3
      src/views/nodes/common.ts
  10. +4
    -6
      src/views/nodes/compareBranchNode.ts
  11. +1
    -1
      src/views/nodes/compareResultsNode.ts
  12. +4
    -5
      src/views/nodes/contributorNode.ts
  13. +4
    -5
      src/views/nodes/contributorsNode.ts
  14. +1
    -1
      src/views/nodes/fileHistoryNode.ts
  15. +1
    -1
      src/views/nodes/lineHistoryNode.ts
  16. +1
    -1
      src/views/nodes/mergeConflictCurrentChangesNode.ts
  17. +1
    -1
      src/views/nodes/mergeConflictIncomingChangesNode.ts
  18. +1
    -1
      src/views/nodes/mergeStatusNode.ts
  19. +1
    -1
      src/views/nodes/rebaseStatusNode.ts
  20. +4
    -5
      src/views/nodes/remoteNode.ts
  21. +3
    -4
      src/views/nodes/remotesNode.ts
  22. +3
    -3
      src/views/nodes/repositoriesNode.ts
  23. +3
    -3
      src/views/nodes/repositoryNode.ts
  24. +1
    -1
      src/views/nodes/searchResultsNode.ts
  25. +3
    -4
      src/views/nodes/stashFileNode.ts
  26. +3
    -5
      src/views/nodes/stashNode.ts
  27. +3
    -4
      src/views/nodes/stashesNode.ts
  28. +4
    -4
      src/views/nodes/statusFilesNode.ts
  29. +3
    -4
      src/views/nodes/tagNode.ts
  30. +8
    -4
      src/views/nodes/tagsNode.ts
  31. +5
    -1
      src/views/nodes/viewNode.ts
  32. +4
    -5
      src/views/nodes/worktreeNode.ts
  33. +4
    -5
      src/views/nodes/worktreesNode.ts
  34. +17
    -1
      src/views/viewBase.ts

+ 4
- 5
src/views/nodes/UncommittedFilesNode.ts View File

@ -10,15 +10,14 @@ import type { GitStatus, GitStatusFile } from '../../git/models/status';
import { groupBy, makeHierarchical } from '../../system/array';
import { flatMap } from '../../system/iterable';
import { joinPaths, normalizePath } from '../../system/path';
import type { RepositoriesView } from '../repositoriesView';
import type { WorktreesView } from '../worktreesView';
import type { ViewsWithWorkingTree } from '../viewBase';
import type { FileNode } from './folderNode';
import { FolderNode } from './folderNode';
import { RepositoryNode } from './repositoryNode';
import { UncommittedFileNode } from './UncommittedFileNode';
import { ContextValues, ViewNode } from './viewNode';
export class UncommittedFilesNode extends ViewNode<RepositoriesView | WorktreesView> {
export class UncommittedFilesNode extends ViewNode<ViewsWithWorkingTree> {
static key = ':uncommitted-files';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
@ -27,8 +26,8 @@ export class UncommittedFilesNode extends ViewNode
readonly repoPath: string;
constructor(
view: RepositoriesView | WorktreesView,
parent: ViewNode,
view: ViewsWithWorkingTree,
protected override readonly parent: ViewNode,
public readonly status:
| GitStatus
| {

+ 4
- 9
src/views/nodes/branchNode.ts View File

@ -18,10 +18,8 @@ import { map } from '../../system/iterable';
import type { Deferred } from '../../system/promise';
import { defer, getSettledValue } from '../../system/promise';
import { pad } from '../../system/string';
import type { BranchesView } from '../branchesView';
import type { CommitsView } from '../commitsView';
import { RemotesView } from '../remotesView';
import type { RepositoriesView } from '../repositoriesView';
import type { ViewsWithBranches } from '../viewBase';
import { BranchTrackingStatusNode } from './branchTrackingStatusNode';
import { CommitNode } from './commitNode';
import { LoadMoreNode, MessageNode } from './common';
@ -39,10 +37,7 @@ type State = {
pendingPullRequest: Promise<PullRequest | undefined> | undefined;
};
export class BranchNode
extends ViewRefNode<BranchesView | CommitsView | RemotesView | RepositoriesView, GitBranchReference, State>
implements PageableViewNode
{
export class BranchNode extends ViewRefNode<ViewsWithBranches, GitBranchReference, State> implements PageableViewNode {
static key = ':branch';
static getId(repoPath: string, name: string, root: boolean): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${name})${root ? ':root' : ''}`;
@ -62,8 +57,8 @@ export class BranchNode
constructor(
uri: GitUri,
view: BranchesView | CommitsView | RemotesView | RepositoriesView,
parent: ViewNode,
view: ViewsWithBranches,
public override parent: ViewNode,
public readonly branch: GitBranch,
// Specifies that the node is shown as a root
public readonly root: boolean,

+ 3
- 3
src/views/nodes/branchOrTagFolderNode.ts View File

@ -16,7 +16,7 @@ export class BranchOrTagFolderNode extends ViewNode {
constructor(
view: View,
parent: ViewNode,
protected override readonly parent: ViewNode,
public readonly type: 'branch' | 'remote-branch' | 'tag',
public readonly repoPath: string,
public readonly folderName: string,
@ -48,7 +48,7 @@ export class BranchOrTagFolderNode extends ViewNode {
children.push(
new BranchOrTagFolderNode(
this.view,
this.folderName ? this : this.parent!,
this.folderName ? this : this.parent,
this.type,
this.repoPath,
folder.name,
@ -62,7 +62,7 @@ export class BranchOrTagFolderNode extends ViewNode {
}
// Make sure to set the parent
(folder.value as any).parent = this.folderName ? this : this.parent!;
folder.value.parent = this.folderName ? this : this.parent;
children.push(folder.value);
}

+ 1
- 1
src/views/nodes/branchTrackingStatusFilesNode.ts View File

@ -26,7 +26,7 @@ export class BranchTrackingStatusFilesNode extends ViewNode {
constructor(
view: ViewsWithCommits,
parent: ViewNode,
protected override readonly parent: ViewNode,
public readonly branch: GitBranch,
public readonly status: Required<BranchTrackingStatus>,
public readonly direction: 'ahead' | 'behind',

+ 1
- 1
src/views/nodes/branchTrackingStatusNode.ts View File

@ -45,7 +45,7 @@ export class BranchTrackingStatusNode extends ViewNode impleme
constructor(
view: ViewsWithCommits,
parent: ViewNode,
protected override readonly parent: ViewNode,
public readonly branch: GitBranch,
public readonly status: BranchTrackingStatus,
public readonly upstreamType: 'ahead' | 'behind' | 'same' | 'none',

+ 4
- 4
src/views/nodes/branchesNode.ts View File

@ -5,15 +5,15 @@ import type { Repository } from '../../git/models/repository';
import { makeHierarchical } from '../../system/array';
import { gate } from '../../system/decorators/gate';
import { debug } from '../../system/decorators/log';
import type { BranchesView } from '../branchesView';
import { RepositoriesView } from '../repositoriesView';
import type { ViewsWithBranchesNode } from '../viewBase';
import { BranchNode } from './branchNode';
import { BranchOrTagFolderNode } from './branchOrTagFolderNode';
import { MessageNode } from './common';
import { RepositoryNode } from './repositoryNode';
import { ContextValues, ViewNode } from './viewNode';
export class BranchesNode extends ViewNode<BranchesView | RepositoriesView> {
export class BranchesNode extends ViewNode<ViewsWithBranchesNode> {
static key = ':branches';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
@ -23,8 +23,8 @@ export class BranchesNode extends ViewNode {
constructor(
uri: GitUri,
view: BranchesView | RepositoriesView,
parent: ViewNode,
view: ViewsWithBranchesNode,
protected override readonly parent: ViewNode,
public readonly repo: Repository,
) {
super(uri, view, parent);

+ 2
- 3
src/views/nodes/commitFileNode.ts View File

@ -10,13 +10,12 @@ import type { GitFile } from '../../git/models/file';
import { getGitFileStatusIcon } from '../../git/models/file';
import type { GitRevisionReference } from '../../git/models/reference';
import { joinPaths, relativeDir } from '../../system/path';
import type { StashesView } from '../stashesView';
import type { ViewsWithCommits } from '../viewBase';
import type { ViewsWithCommits, ViewsWithStashes } from '../viewBase';
import type { ViewNode } from './viewNode';
import { ContextValues, ViewRefFileNode } from './viewNode';
export class CommitFileNode<
TView extends ViewsWithCommits | StashesView = ViewsWithCommits | StashesView,
TView extends ViewsWithCommits | ViewsWithStashes = ViewsWithCommits,
> extends ViewRefFileNode<TView> {
static key = ':file';
static getId(parent: ViewNode, path: string): string {

+ 1
- 1
src/views/nodes/commitNode.ts View File

@ -42,7 +42,7 @@ export class CommitNode extends ViewRefNode
constructor(
view: ViewsWithCommits | FileHistoryView,
protected override readonly parent: ViewNode,
parent: ViewNode,
public readonly commit: GitCommit,
private readonly unpublished?: boolean,
public readonly branch?: GitBranch,

+ 3
- 3
src/views/nodes/common.ts View File

@ -10,7 +10,7 @@ import { ContextValues, ViewNode } from './viewNode';
export class MessageNode extends ViewNode {
constructor(
view: View,
parent: ViewNode,
protected override readonly parent: ViewNode,
private readonly _message: string,
private readonly _description?: string,
private readonly _tooltip?: string,
@ -44,7 +44,7 @@ export class MessageNode extends ViewNode {
export class CommandMessageNode extends MessageNode {
constructor(
view: View,
parent: ViewNode,
protected override readonly parent: ViewNode,
private readonly _command: Command,
message: string,
description?: string,
@ -78,7 +78,7 @@ export class CommandMessageNode extends MessageNode {
export class UpdateableMessageNode extends ViewNode {
constructor(
view: View,
parent: ViewNode,
protected override readonly parent: ViewNode,
private _id: string,
private _message: string,
private _tooltip?: string,

+ 4
- 6
src/views/nodes/compareBranchNode.ts View File

@ -11,9 +11,7 @@ import { gate } from '../../system/decorators/gate';
import { debug, log } from '../../system/decorators/log';
import { getSettledValue } from '../../system/promise';
import { pluralize } from '../../system/string';
import type { BranchesView } from '../branchesView';
import type { CommitsView } from '../commitsView';
import type { RepositoriesView } from '../repositoriesView';
import type { ViewsWithBranches } from '../viewBase';
import type { WorktreesView } from '../worktreesView';
import { RepositoryNode } from './repositoryNode';
import type { CommitsQueryResults } from './resultsCommitsNode';
@ -22,7 +20,7 @@ import type { FilesQueryResults } from './resultsFilesNode';
import { ResultsFilesNode } from './resultsFilesNode';
import { ContextValues, ViewNode } from './viewNode';
export class CompareBranchNode extends ViewNode<BranchesView | CommitsView | RepositoriesView | WorktreesView> {
export class CompareBranchNode extends ViewNode<ViewsWithBranches | WorktreesView> {
static key = ':compare-branch';
static getId(repoPath: string, name: string, root: boolean): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${name})${root ? ':root' : ''}`;
@ -33,8 +31,8 @@ export class CompareBranchNode extends ViewNode
constructor(
uri: GitUri,
view: BranchesView | CommitsView | RepositoriesView | WorktreesView,
parent: ViewNode,
view: ViewsWithBranches | WorktreesView,
protected override readonly parent: ViewNode,
public readonly branch: GitBranch,
private showComparison: ViewShowBranchComparison,
// Specifies that the node is shown as a root

+ 1
- 1
src/views/nodes/compareResultsNode.ts View File

@ -32,7 +32,7 @@ export class CompareResultsNode extends ViewNode {
constructor(
view: SearchAndCompareView,
parent: ViewNode,
protected override readonly parent: ViewNode,
public readonly repoPath: string,
private _ref: StoredNamedRef,
private _compareWith: StoredNamedRef,

+ 4
- 5
src/views/nodes/contributorNode.ts View File

@ -10,8 +10,7 @@ import { debug } from '../../system/decorators/log';
import { map } from '../../system/iterable';
import { pluralize } from '../../system/string';
import type { ContactPresence } from '../../vsls/vsls';
import type { ContributorsView } from '../contributorsView';
import type { RepositoriesView } from '../repositoriesView';
import type { ViewsWithContributors } from '../viewBase';
import { CommitNode } from './commitNode';
import { LoadMoreNode, MessageNode } from './common';
import { insertDateMarkers } from './helpers';
@ -19,7 +18,7 @@ import { RepositoryNode } from './repositoryNode';
import type { PageableViewNode } from './viewNode';
import { ContextValues, ViewNode } from './viewNode';
export class ContributorNode extends ViewNode<ContributorsView | RepositoriesView> implements PageableViewNode {
export class ContributorNode extends ViewNode<ViewsWithContributors> implements PageableViewNode {
static key = ':contributor';
static getId(
repoPath: string,
@ -32,8 +31,8 @@ export class ContributorNode extends ViewNode
constructor(
uri: GitUri,
view: ContributorsView | RepositoriesView,
parent: ViewNode,
view: ViewsWithContributors,
protected override readonly parent: ViewNode,
public readonly contributor: GitContributor,
private readonly _options?: {
all?: boolean;

+ 4
- 5
src/views/nodes/contributorsNode.ts View File

@ -6,14 +6,13 @@ import { configuration } from '../../system/configuration';
import { gate } from '../../system/decorators/gate';
import { debug } from '../../system/decorators/log';
import { timeout } from '../../system/decorators/timeout';
import type { ContributorsView } from '../contributorsView';
import type { RepositoriesView } from '../repositoriesView';
import type { ViewsWithContributorsNode } from '../viewBase';
import { MessageNode } from './common';
import { ContributorNode } from './contributorNode';
import { RepositoryNode } from './repositoryNode';
import { ContextValues, ViewNode } from './viewNode';
export class ContributorsNode extends ViewNode<ContributorsView | RepositoriesView> {
export class ContributorsNode extends ViewNode<ViewsWithContributorsNode> {
static key = ':contributors';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
@ -25,8 +24,8 @@ export class ContributorsNode extends ViewNode
constructor(
uri: GitUri,
view: ContributorsView | RepositoriesView,
parent: ViewNode,
view: ViewsWithContributorsNode,
protected override readonly parent: ViewNode,
public readonly repo: Repository,
) {
super(uri, view, parent);

+ 1
- 1
src/views/nodes/fileHistoryNode.ts View File

@ -33,7 +33,7 @@ export class FileHistoryNode extends SubscribeableViewNode impl
constructor(
uri: GitUri,
view: FileHistoryView,
parent: ViewNode,
protected override readonly parent: ViewNode,
private readonly folder: boolean,
private readonly branch: GitBranch | undefined,
) {

+ 1
- 1
src/views/nodes/lineHistoryNode.ts View File

@ -39,7 +39,7 @@ export class LineHistoryNode
constructor(
uri: GitUri,
view: FileHistoryView | LineHistoryView,
parent: ViewNode,
protected override readonly parent: ViewNode,
private readonly branch: GitBranch | undefined,
public readonly selection: Selection,
private readonly editorContents: string | undefined,

+ 1
- 1
src/views/nodes/mergeConflictCurrentChangesNode.ts View File

@ -18,7 +18,7 @@ import { ContextValues, ViewNode } from './viewNode';
export class MergeConflictCurrentChangesNode extends ViewNode<ViewsWithCommits | FileHistoryView | LineHistoryView> {
constructor(
view: ViewsWithCommits | FileHistoryView | LineHistoryView,
parent: ViewNode,
protected override readonly parent: ViewNode,
private readonly status: GitMergeStatus | GitRebaseStatus,
private readonly file: GitFile,
) {

+ 1
- 1
src/views/nodes/mergeConflictIncomingChangesNode.ts View File

@ -18,7 +18,7 @@ import { ContextValues, ViewNode } from './viewNode';
export class MergeConflictIncomingChangesNode extends ViewNode<ViewsWithCommits | FileHistoryView | LineHistoryView> {
constructor(
view: ViewsWithCommits | FileHistoryView | LineHistoryView,
parent: ViewNode,
protected override readonly parent: ViewNode,
private readonly status: GitMergeStatus | GitRebaseStatus,
private readonly file: GitFile,
) {

+ 1
- 1
src/views/nodes/mergeStatusNode.ts View File

@ -24,7 +24,7 @@ export class MergeStatusNode extends ViewNode {
constructor(
view: ViewsWithCommits,
parent: ViewNode,
protected override readonly parent: ViewNode,
public readonly branch: GitBranch,
public readonly mergeStatus: GitMergeStatus,
public readonly status: GitStatus | undefined,

+ 1
- 1
src/views/nodes/rebaseStatusNode.ts View File

@ -34,7 +34,7 @@ export class RebaseStatusNode extends ViewNode {
constructor(
view: ViewsWithCommits,
parent: ViewNode,
protected override readonly parent: ViewNode,
public readonly branch: GitBranch,
public readonly rebaseStatus: GitRebaseStatus,
public readonly status: GitStatus | undefined,

+ 4
- 5
src/views/nodes/remoteNode.ts View File

@ -7,15 +7,14 @@ import { getRemoteUpstreamDescription } from '../../git/models/remote';
import type { Repository } from '../../git/models/repository';
import { makeHierarchical } from '../../system/array';
import { log } from '../../system/decorators/log';
import type { RemotesView } from '../remotesView';
import type { RepositoriesView } from '../repositoriesView';
import type { ViewsWithRemotes } from '../viewBase';
import { BranchNode } from './branchNode';
import { BranchOrTagFolderNode } from './branchOrTagFolderNode';
import { MessageNode } from './common';
import { RepositoryNode } from './repositoryNode';
import { ContextValues, ViewNode } from './viewNode';
export class RemoteNode extends ViewNode<RemotesView | RepositoriesView> {
export class RemoteNode extends ViewNode<ViewsWithRemotes> {
static key = ':remote';
static getId(repoPath: string, name: string, id: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${name}|${id})`;
@ -23,8 +22,8 @@ export class RemoteNode extends ViewNode {
constructor(
uri: GitUri,
view: RemotesView | RepositoriesView,
parent: ViewNode,
view: ViewsWithRemotes,
protected override readonly parent: ViewNode,
public readonly remote: GitRemote,
public readonly repo: Repository,
) {

+ 3
- 4
src/views/nodes/remotesNode.ts View File

@ -3,14 +3,13 @@ import type { GitUri } from '../../git/gitUri';
import type { Repository } from '../../git/models/repository';
import { gate } from '../../system/decorators/gate';
import { debug } from '../../system/decorators/log';
import type { RemotesView } from '../remotesView';
import type { RepositoriesView } from '../repositoriesView';
import type { ViewsWithRemotesNode } from '../viewBase';
import { MessageNode } from './common';
import { RemoteNode } from './remoteNode';
import { RepositoryNode } from './repositoryNode';
import { ContextValues, ViewNode } from './viewNode';
export class RemotesNode extends ViewNode<RemotesView | RepositoriesView> {
export class RemotesNode extends ViewNode<ViewsWithRemotesNode> {
static key = ':remotes';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
@ -18,7 +17,7 @@ export class RemotesNode extends ViewNode {
private _children: ViewNode[] | undefined;
constructor(uri: GitUri, view: RemotesView | RepositoriesView, parent: ViewNode, public readonly repo: Repository) {
constructor(uri: GitUri, view: ViewsWithRemotesNode, parent: ViewNode, public readonly repo: Repository) {
super(uri, view, parent);
}

+ 3
- 3
src/views/nodes/repositoriesNode.ts View File

@ -6,16 +6,16 @@ import { gate } from '../../system/decorators/gate';
import { debug } from '../../system/decorators/log';
import { debounce, szudzikPairing } from '../../system/function';
import { Logger } from '../../system/logger';
import type { RepositoriesView } from '../repositoriesView';
import type { ViewsWithRepositoriesNode } from '../viewBase';
import { MessageNode } from './common';
import { RepositoryNode } from './repositoryNode';
import type { ViewNode } from './viewNode';
import { ContextValues, SubscribeableViewNode } from './viewNode';
export class RepositoriesNode extends SubscribeableViewNode<RepositoriesView> {
export class RepositoriesNode extends SubscribeableViewNode<ViewsWithRepositoriesNode> {
private _children: (RepositoryNode | MessageNode)[] | undefined;
constructor(view: RepositoriesView) {
constructor(view: ViewsWithRepositoriesNode) {
super(unknownGitUri, view);
}

+ 3
- 3
src/views/nodes/repositoryNode.ts View File

@ -12,7 +12,7 @@ import { gate } from '../../system/decorators/gate';
import { debug, log } from '../../system/decorators/log';
import { disposableInterval } from '../../system/function';
import { pad } from '../../system/string';
import type { RepositoriesView } from '../repositoriesView';
import type { ViewsWithRepositories } from '../viewBase';
import { BranchesNode } from './branchesNode';
import { BranchNode } from './branchNode';
import { BranchTrackingStatusNode } from './branchTrackingStatusNode';
@ -30,7 +30,7 @@ import type { ViewNode } from './viewNode';
import { ContextValues, SubscribeableViewNode } from './viewNode';
import { WorktreesNode } from './worktreesNode';
export class RepositoryNode extends SubscribeableViewNode<RepositoriesView> {
export class RepositoryNode extends SubscribeableViewNode<ViewsWithRepositories> {
static key = ':repository';
static getId(repoPath: string): string {
return `gitlens${this.key}(${repoPath})`;
@ -39,7 +39,7 @@ export class RepositoryNode extends SubscribeableViewNode {
private _children: ViewNode[] | undefined;
private _status: Promise<GitStatus | undefined>;
constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly repo: Repository) {
constructor(uri: GitUri, view: ViewsWithRepositories, parent: ViewNode, public readonly repo: Repository) {
super(uri, view, parent);
this._status = this.repo.getStatus();

+ 1
- 1
src/views/nodes/searchResultsNode.ts View File

@ -40,7 +40,7 @@ export class SearchResultsNode extends ViewNode implements
private _instanceId: number;
constructor(
view: SearchAndCompareView,
parent: ViewNode,
protected override readonly parent: ViewNode,
public readonly repoPath: string,
search: SearchQuery,
private _labels: {

+ 3
- 4
src/views/nodes/stashFileNode.ts View File

@ -1,14 +1,13 @@
import type { GitStashCommit } from '../../git/models/commit';
import type { GitFile } from '../../git/models/file';
import type { StashesView } from '../stashesView';
import type { ViewsWithCommits } from '../viewBase';
import type { ViewsWithStashes } from '../viewBase';
import { CommitFileNode } from './commitFileNode';
import type { ViewNode } from './viewNode';
import { ContextValues } from './viewNode';
export class StashFileNode extends CommitFileNode {
export class StashFileNode extends CommitFileNode<ViewsWithStashes> {
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(view: ViewsWithCommits | StashesView, parent: ViewNode, file: GitFile, commit: GitStashCommit) {
constructor(view: ViewsWithStashes, parent: ViewNode, file: GitFile, commit: GitStashCommit) {
super(view, parent, file, commit);
}

+ 3
- 5
src/views/nodes/stashNode.ts View File

@ -7,9 +7,7 @@ import { makeHierarchical } from '../../system/array';
import { configuration } from '../../system/configuration';
import { joinPaths, normalizePath } from '../../system/path';
import { sortCompare } from '../../system/string';
import type { RepositoriesView } from '../repositoriesView';
import type { StashesView } from '../stashesView';
import type { ViewsWithCommits } from '../viewBase';
import type { ViewsWithStashes } from '../viewBase';
import type { FileNode } from './folderNode';
import { FolderNode } from './folderNode';
import { RepositoryNode } from './repositoryNode';
@ -17,14 +15,14 @@ import { StashFileNode } from './stashFileNode';
import type { ViewNode } from './viewNode';
import { ContextValues, ViewRefNode } from './viewNode';
export class StashNode extends ViewRefNode<ViewsWithCommits | StashesView | RepositoriesView, GitStashReference> {
export class StashNode extends ViewRefNode<ViewsWithStashes, GitStashReference> {
static key = ':stash';
static getId(repoPath: string, ref: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${ref})`;
}
constructor(
view: ViewsWithCommits | StashesView | RepositoriesView,
view: ViewsWithStashes,
parent: ViewNode,
public readonly commit: GitStashCommit,
private readonly options?: { icon?: boolean },

+ 3
- 4
src/views/nodes/stashesNode.ts View File

@ -4,14 +4,13 @@ import type { Repository } from '../../git/models/repository';
import { gate } from '../../system/decorators/gate';
import { debug } from '../../system/decorators/log';
import { map } from '../../system/iterable';
import type { RepositoriesView } from '../repositoriesView';
import type { StashesView } from '../stashesView';
import type { ViewsWithStashesNode } from '../viewBase';
import { MessageNode } from './common';
import { RepositoryNode } from './repositoryNode';
import { StashNode } from './stashNode';
import { ContextValues, ViewNode } from './viewNode';
export class StashesNode extends ViewNode<StashesView | RepositoriesView> {
export class StashesNode extends ViewNode<ViewsWithStashesNode> {
static key = ':stashes';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
@ -19,7 +18,7 @@ export class StashesNode extends ViewNode {
private _children: ViewNode[] | undefined;
constructor(uri: GitUri, view: StashesView | RepositoriesView, parent: ViewNode, public readonly repo: Repository) {
constructor(uri: GitUri, view: ViewsWithStashesNode, parent: ViewNode, public readonly repo: Repository) {
super(uri, view, parent);
}

+ 4
- 4
src/views/nodes/statusFilesNode.ts View File

@ -10,7 +10,7 @@ import { groupBy, makeHierarchical } from '../../system/array';
import { filter, flatMap, map } from '../../system/iterable';
import { joinPaths, normalizePath } from '../../system/path';
import { pluralize, sortCompare } from '../../system/string';
import type { RepositoriesView } from '../repositoriesView';
import type { ViewsWithWorkingTree } from '../viewBase';
import { WorktreesView } from '../worktreesView';
import type { FileNode } from './folderNode';
import { FolderNode } from './folderNode';
@ -18,7 +18,7 @@ import { RepositoryNode } from './repositoryNode';
import { StatusFileNode } from './statusFileNode';
import { ContextValues, ViewNode } from './viewNode';
export class StatusFilesNode extends ViewNode<RepositoriesView | WorktreesView> {
export class StatusFilesNode extends ViewNode<ViewsWithWorkingTree> {
static key = ':status-files';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
@ -27,8 +27,8 @@ export class StatusFilesNode extends ViewNode
readonly repoPath: string;
constructor(
view: RepositoriesView | WorktreesView,
parent: ViewNode,
view: ViewsWithWorkingTree,
protected override readonly parent: ViewNode,
public readonly status:
| GitStatus
| {

+ 3
- 4
src/views/nodes/tagNode.ts View File

@ -11,8 +11,7 @@ import { gate } from '../../system/decorators/gate';
import { debug } from '../../system/decorators/log';
import { map } from '../../system/iterable';
import { pad } from '../../system/string';
import type { RepositoriesView } from '../repositoriesView';
import type { TagsView } from '../tagsView';
import type { ViewsWithTags } from '../viewBase';
import { CommitNode } from './commitNode';
import { LoadMoreNode, MessageNode } from './common';
import { insertDateMarkers } from './helpers';
@ -20,13 +19,13 @@ import { RepositoryNode } from './repositoryNode';
import type { PageableViewNode, ViewNode } from './viewNode';
import { ContextValues, ViewRefNode } from './viewNode';
export class TagNode extends ViewRefNode<TagsView | RepositoriesView, GitTagReference> implements PageableViewNode {
export class TagNode extends ViewRefNode<ViewsWithTags, GitTagReference> implements PageableViewNode {
static key = ':tag';
static getId(repoPath: string, name: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${name})`;
}
constructor(uri: GitUri, view: TagsView | RepositoriesView, parent: ViewNode, public readonly tag: GitTag) {
constructor(uri: GitUri, view: ViewsWithTags, public override parent: ViewNode, public readonly tag: GitTag) {
super(uri, view, parent);
}

+ 8
- 4
src/views/nodes/tagsNode.ts View File

@ -5,15 +5,14 @@ import type { Repository } from '../../git/models/repository';
import { makeHierarchical } from '../../system/array';
import { gate } from '../../system/decorators/gate';
import { debug } from '../../system/decorators/log';
import type { RepositoriesView } from '../repositoriesView';
import type { TagsView } from '../tagsView';
import type { ViewsWithTagsNode } from '../viewBase';
import { BranchOrTagFolderNode } from './branchOrTagFolderNode';
import { MessageNode } from './common';
import { RepositoryNode } from './repositoryNode';
import { TagNode } from './tagNode';
import { ContextValues, ViewNode } from './viewNode';
export class TagsNode extends ViewNode<TagsView | RepositoriesView> {
export class TagsNode extends ViewNode<ViewsWithTagsNode> {
static key = ':tags';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
@ -21,7 +20,12 @@ export class TagsNode extends ViewNode {
private _children: ViewNode[] | undefined;
constructor(uri: GitUri, view: TagsView | RepositoriesView, parent: ViewNode, public readonly repo: Repository) {
constructor(
uri: GitUri,
view: ViewsWithTagsNode,
protected override readonly parent: ViewNode,
public readonly repo: Repository,
) {
super(uri, view, parent);
}

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

@ -194,6 +194,10 @@ export abstract class ViewRefNode<
TReference extends GitReference = GitReference,
State extends object = any,
> extends ViewNode<TView, State> {
constructor(uri: GitUri, view: TView, protected override readonly parent: ViewNode) {
super(uri, view, parent);
}
abstract get ref(): TReference;
get repoPath(): string {
@ -397,7 +401,7 @@ export abstract class RepositoryFolderNode<
constructor(
uri: GitUri,
view: TView,
parent: ViewNode,
protected override readonly parent: ViewNode,
public readonly repo: Repository,
splatted: boolean,
private readonly options?: { showBranchAndLastFetched?: boolean },

+ 4
- 5
src/views/nodes/worktreeNode.ts View File

@ -15,8 +15,7 @@ import { map } from '../../system/iterable';
import type { Deferred } from '../../system/promise';
import { defer, getSettledValue } from '../../system/promise';
import { pad } from '../../system/string';
import type { RepositoriesView } from '../repositoriesView';
import type { WorktreesView } from '../worktreesView';
import type { ViewsWithWorktrees } from '../viewBase';
import { CommitNode } from './commitNode';
import { LoadMoreNode, MessageNode } from './common';
import { CompareBranchNode } from './compareBranchNode';
@ -31,7 +30,7 @@ type State = {
pendingPullRequest: Promise<PullRequest | undefined> | undefined;
};
export class WorktreeNode extends ViewNode<WorktreesView | RepositoriesView, State> {
export class WorktreeNode extends ViewNode<ViewsWithWorktrees, State> {
static key = ':worktree';
static getId(repoPath: string, uri: Uri): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${uri.path})`;
@ -41,8 +40,8 @@ export class WorktreeNode extends ViewNode
constructor(
uri: GitUri,
view: WorktreesView | RepositoriesView,
parent: ViewNode,
view: ViewsWithWorktrees,
protected override readonly parent: ViewNode,
public readonly worktree: GitWorktree,
) {
super(uri, view, parent);

+ 4
- 5
src/views/nodes/worktreesNode.ts View File

@ -5,14 +5,13 @@ import type { GitUri } from '../../git/gitUri';
import type { Repository } from '../../git/models/repository';
import { gate } from '../../system/decorators/gate';
import { debug } from '../../system/decorators/log';
import type { RepositoriesView } from '../repositoriesView';
import type { WorktreesView } from '../worktreesView';
import type { ViewsWithWorktreesNode } from '../viewBase';
import { MessageNode } from './common';
import { RepositoryNode } from './repositoryNode';
import { ContextValues, ViewNode } from './viewNode';
import { WorktreeNode } from './worktreeNode';
export class WorktreesNode extends ViewNode<WorktreesView | RepositoriesView> {
export class WorktreesNode extends ViewNode<ViewsWithWorktreesNode> {
static key = ':worktrees';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
@ -22,8 +21,8 @@ export class WorktreesNode extends ViewNode {
constructor(
uri: GitUri,
view: WorktreesView | RepositoriesView,
parent: ViewNode,
view: ViewsWithWorktreesNode,
protected override readonly parent: ViewNode,
public readonly repo: Repository,
) {
super(uri, view, parent);

+ 17
- 1
src/views/viewBase.ts View File

@ -63,8 +63,24 @@ export type View =
| StashesView
| TagsView
| WorktreesView;
export type ViewsWithBranches = BranchesView | CommitsView | RemotesView | RepositoriesView;
export type ViewsWithBranchesNode = BranchesView | RepositoriesView;
export type ViewsWithCommits = Exclude<View, FileHistoryView | LineHistoryView | StashesView>;
export type ViewsWithRepositoryFolders = Exclude<View, RepositoriesView | FileHistoryView | LineHistoryView>;
export type ViewsWithContributors = ContributorsView | RepositoriesView;
export type ViewsWithContributorsNode = ContributorsView | RepositoriesView;
export type ViewsWithRemotes = RemotesView | RepositoriesView;
export type ViewsWithRemotesNode = RemotesView | RepositoriesView;
export type ViewsWithRepositories = RepositoriesView;
export type ViewsWithRepositoriesNode = RepositoriesView;
export type ViewsWithRepositoryFolders = Exclude<View, FileHistoryView | LineHistoryView | RepositoriesView>;
export type ViewsWithStashes = StashesView | ViewsWithCommits;
export type ViewsWithStashesNode = RepositoriesView | StashesView;
export type ViewsWithTags = RepositoriesView | TagsView;
export type ViewsWithTagsNode = RepositoriesView | TagsView;
export type ViewsWithWorkingTree = RepositoriesView | WorktreesView;
export type ViewsWithWorktrees = RepositoriesView | WorktreesView;
export type ViewsWithWorktreesNode = RepositoriesView | WorktreesView;
export interface TreeViewNodeCollapsibleStateChangeEvent<T> extends TreeViewExpansionEvent<T> {
state: TreeItemCollapsibleState;

Loading…
Cancel
Save