Improve tab handling

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 20d527f195
commit 018d1eb412

@ -22,7 +22,7 @@
<button mat-flat-button (click)="this.addImportTab()" color="primary">Import</button>
</div>
</mat-tab>
<mat-tab disabled>
<mat-tab *ngIf="this.selectedRepository" disabled>
<ng-template mat-tab-label>
<button class="new-tab-button" mat-icon-button (click)="this.addTab()">
<ng-icon name="mat-plus"></ng-icon>

@ -30,7 +30,14 @@ export class CoreComponent implements OnInit {
this.selectedRepository = this.repoService.selectedRepository.getValue();
this.repoService.selectedRepository.subscribe(async (selected) => {
this.selectedRepository = selected;
await this.loadRepoData();
if (this.selectedRepository) {
await this.loadRepoData();
this.addTab();
} else {
this.newTab = false;
this.tabService.closeAllTabs();
}
});
this.tabService.tabs.subscribe(tabs => {
this.tabs = tabs;
@ -67,7 +74,11 @@ export class CoreComponent implements OnInit {
this.tabService.closeTab(tab.uuid);
if (previousIndex) {
this.tabGroup.selectedIndex = previousIndex - 1;
if (previousIndex === 1 && this.tabs.length >= 1) {
this.tabGroup.selectedIndex = previousIndex;
} else {
this.tabGroup.selectedIndex = previousIndex - 1;
}
} else {
this.tabGroup.selectedIndex = 0;
}

@ -6,7 +6,6 @@ import {FilesTabComponent} from "./files-tab/files-tab.component";
import {FilesTabSidebarComponent} from "./files-tab/files-tab-sidebar/files-tab-sidebar.component";
import {ImportTabComponent} from "./import-tab/import-tab.component";
import {ImportTabSidebarComponent} from "./import-tab/import-tab-sidebar/import-tab-sidebar.component";
import {FilesystemImportComponent} from "../shared/sidebar/file-import/filesystem-import/filesystem-import.component";
import {MatButtonModule} from "@angular/material/button";
import {MatSidenavModule} from "@angular/material/sidenav";
import {MatProgressBarModule} from "@angular/material/progress-bar";
@ -33,9 +32,9 @@ import {MatDialogModule} from "@angular/material/dialog";
import {MatTooltipModule} from "@angular/material/tooltip";
import {MatInputModule} from "@angular/material/input";
import {TagModule} from "../shared/tag/tag.module";
import { RepositoryFormComponent } from './repositories-tab/repository-form/repository-form.component';
import { EditRepositoryDialogComponent } from './repositories-tab/edit-repository-dialog/edit-repository-dialog.component';
import { DownloadDaemonDialogComponent } from './repositories-tab/download-daemon-dialog/download-daemon-dialog.component';
import { RepositoryFormComponent } from "./repositories-tab/repository-form/repository-form.component";
import { EditRepositoryDialogComponent } from "./repositories-tab/edit-repository-dialog/edit-repository-dialog.component";
import { DownloadDaemonDialogComponent } from "./repositories-tab/download-daemon-dialog/download-daemon-dialog.component";
@NgModule({

@ -32,4 +32,8 @@ export class TabService {
tabs.splice(index, 1)
this.tabs.next(tabs);
}
public closeAllTabs() {
this.tabs.next([]);
}
}

Loading…
Cancel
Save