Skip to content

Commit

Permalink
Implement dropdown menu for repo change (#347)
Browse files Browse the repository at this point in the history
Introduce a dropdown menu for repository selection,
simplifying the process of switching between repositories. 

This enhancement offers users a quicker and more
intuitive method to navigate to previously visited repositories.
  • Loading branch information
NereusWB922 authored Apr 3, 2024
1 parent d92079b commit 775e59c
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
32 changes: 32 additions & 0 deletions src/app/shared/layout/header.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.repo-menu-footer {
display: flex;
justify-content: space-between;
align-items: center;
position: sticky;
bottom: 0;
z-index: 1;
padding: 10px;
}

.new-repo-button {
flex-grow: 1;
}

.keep-filter-button {
margin-left: 2px;
}

.repo-options {
max-height: 300px;
overflow-y: auto;
}

.repo-options button {
font-size: 17px;
}

/* Overwrite the width of the menu */
::ng-deep .repo-menu {
width: fit-content !important;
min-width: 320px !important;
}
30 changes: 28 additions & 2 deletions src/app/shared/layout/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,40 @@
{{ this.currentRepo || 'No Repository Set' }}
</span>
<button
mat-button
mat-icon-button
matTooltip="{{ viewService.isRepoSet() ? 'Change Repository' : 'Select Repository' }}"
(click)="this.openChangeRepoDialog()"
[matMenuTriggerFor]="repoMenu"
>
<mat-icon>edit</mat-icon>
</button>
</div>

<mat-menu #repoMenu xPosition="before" class="repo-menu">
<div class="repo-options">
<div *ngFor="let repo of this.repoUrlCacheService.suggestions">
<button mat-menu-item *ngIf="repo !== this.currentRepo" (click)="this.applyRepoDropdown(repo, true)">
{{ repo }}
</button>
</div>
</div>

<div class="repo-menu-footer">
<button mat-flat-button color="primary" class="new-repo-button" (click)="this.openChangeRepoDialog()" matTooltip="Add new repository">
<mat-icon>add</mat-icon>
</button>

<button
mat-icon-button
(click)="toggleKeepFilters($event)"
class="keep-filter-button"
matTooltip="{{ keepFilters ? 'Keep filter on' : 'Keep filter off' }}"
color="{{ keepFilters ? 'primary' : 'warn' }}"
>
<mat-icon>{{ keepFilters ? 'filter_alt' : 'filter_alt_off' }}</mat-icon>
</button>
</div>
</mat-menu>

<span style="flex: 1 1 auto"></span>

<button mat-button matTooltip="Download WATcher Log" (click)="this.exportLogFile()">
Expand Down
17 changes: 15 additions & 2 deletions src/app/shared/layout/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const ISSUE_TRACKER_URL = 'https://github.com/CATcher-org/WATcher/issues';

@Component({
selector: 'app-layout-header',
templateUrl: './header.component.html'
templateUrl: './header.component.html',
styleUrls: ['./header.component.css']
})
export class HeaderComponent implements OnInit {
private prevUrl;
Expand Down Expand Up @@ -55,16 +56,18 @@ export class HeaderComponent implements OnInit {
/** Model for the displayed repository name */
currentRepo = '';

keepFilters = false;

constructor(
private router: Router,
public auth: AuthService,
public viewService: ViewService,
public userService: UserService,
public logger: LoggingService,
public repoUrlCacheService: RepoUrlCacheService,
private location: Location,
private githubEventService: GithubEventService,
private issueService: IssueService,
private repoUrlCacheService: RepoUrlCacheService,
private labelService: LabelService,
private errorHandlingService: ErrorHandlingService,
private githubService: GithubService,
Expand Down Expand Up @@ -265,6 +268,16 @@ export class HeaderComponent implements OnInit {
});
}

applyRepoDropdown(repoString: string) {
const newRepo = Repo.of(repoString);
this.changeRepositoryIfValid(newRepo, newRepo.toString(), this.keepFilters);
}

toggleKeepFilters(event: MouseEvent) {
event.stopPropagation();
this.keepFilters = !this.keepFilters;
}

openChangeRepoDialog() {
const dialogRef = this.dialogService.openChangeRepoDialog(this.currentRepo);

Expand Down

0 comments on commit 775e59c

Please sign in to comment.