Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ import {
LinkOutline,
LockOutline,
MailOutline,
MenuFoldOutline,
MinusOutline,
MoreOutline,
PauseCircleOutline,
Expand Down
38 changes: 35 additions & 3 deletions ui/src/app/views/projectv2/explore/explore-sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,37 @@ export class ProjectV2ExploreSidebarComponent implements OnInit, OnDestroy, Afte
this._cd.markForCheck();
}

collapseAll(): void {
// Check if any repository or entity type is expanded
const hasExpandedChildren = Object.keys(this.treeExpandState).some(key => {
return key.includes('/') && this.treeExpandState[key];
});

if (hasExpandedChildren) {
// First click: collapse all repositories and entity types
Object.keys(this.treeExpandState).forEach(key => {
if (key.includes('/')) {
this.treeExpandState[key] = false;
}
});
} else {
// Second click: collapse all VCS
Object.keys(this.treeExpandState).forEach(key => {
this.treeExpandState[key] = false;
});
}

this.saveTreeExpandState();

// Navigate to explore overview if we're currently viewing an entity
const params = this._routerService.getRouteSnapshotParams({}, this._router.routerState.snapshot.root);
if (params['vcsName'] || params['repoName'] || params['entityType'] || params['entityName']) {
this._router.navigate(['/project', this.project.key, 'explore']);
}

this._cd.markForCheck();
}

async selectRepositoryRef(vcs: VCSProject, repo: ProjectRepository, ref: string) {
this.refSelectState[vcs.name + '/' + repo.name] = ref;
this.saveRefSelectState();
Expand Down Expand Up @@ -247,10 +278,11 @@ export class ProjectV2ExploreSidebarComponent implements OnInit, OnDestroy, Afte
if (keys.indexOf(vcs.name) !== -1 && !this.treeExpandState[vcs.name]) {
state[vcs.name] = false;
}
// Persist repositories that were opened
// Persist repositories that were opened or closed
(this.repositories[vcs.name] ?? []).forEach(repo => {
if (this.treeExpandState[vcs.name + '/' + repo.name]) {
state[vcs.name + '/' + repo.name] = true;
const repoKey = vcs.name + '/' + repo.name;
if (keys.indexOf(repoKey) !== -1) {
state[repoKey] = this.treeExpandState[repoKey];
}
// Persist entity folder that were closed
Object.keys(this.entities[vcs.name + '/' + repo.name] ?? {}).forEach(entityType => {
Expand Down
4 changes: 4 additions & 0 deletions ui/src/app/views/projectv2/explore/explore-sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<a class="title" title="Show overview" [routerLink]="['/project', project.key, 'explore']">
Workspace
</a>
<button class="collapse" nz-button nzType="text" nzSize="small" nz-tooltip
nzTooltipTitle="Collapse folders" (click)="collapseAll()">
<i nz-icon nzType="menu-fold" nzTheme="outline"></i>
</button>
<button class="refresh" nz-button nzType="text" nzSize="small" nz-tooltip
nzTooltipTitle="Click to refresh the workspace" (click)="load()">
<i nz-icon nzType="sync" [nzSpin]="loading" nzTheme="outline"></i>
Expand Down