mirror of
https://github.com/bitwarden/web
synced 2025-12-06 00:03:28 +00:00
Added manual routing
This commit is contained in:
@@ -29,13 +29,13 @@
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" *ngIf="showManageTab">
|
||||
<a class="nav-link" [routerLink]="manageRoute" routerLinkActive="active">
|
||||
<a class="nav-link" routerLink="manage" routerLinkActive="active">
|
||||
<i class="fa fa-sliders" aria-hidden="true"></i>
|
||||
{{'manage' | i18n}}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" *ngIf="showToolsTab">
|
||||
<a class="nav-link" [routerLink]="toolsRoute" routerLinkActive="active">
|
||||
<a class="nav-link" routerLink="tools" routerLinkActive="active">
|
||||
<i class="fa fa-wrench" aria-hidden="true"></i>
|
||||
{{'tools' | i18n}}
|
||||
</a>
|
||||
|
||||
@@ -68,32 +68,4 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy {
|
||||
get showToolsTab(): boolean {
|
||||
return this.organization.canAccessImportExport || this.organization.canAccessReports;
|
||||
}
|
||||
|
||||
get toolsRoute(): string {
|
||||
return this.organization.canAccessImportExport ?
|
||||
'tools/import' :
|
||||
'tools/exposed-passwords-report';
|
||||
}
|
||||
|
||||
get manageRoute(): string {
|
||||
let route: string;
|
||||
switch (true) {
|
||||
case this.organization.canManageUsers:
|
||||
route = 'manage/people';
|
||||
break;
|
||||
case this.organization.canViewAssignedCollections || this.organization.canViewAllCollections:
|
||||
route = 'manage/collections';
|
||||
break;
|
||||
case this.organization.canManageGroups:
|
||||
route = 'manage/groups';
|
||||
break;
|
||||
case this.organization.canManagePolicies:
|
||||
route = 'manage/policies';
|
||||
break;
|
||||
case this.organization.canAccessEventLogs:
|
||||
route = 'manage/events';
|
||||
break;
|
||||
}
|
||||
return route;
|
||||
}
|
||||
}
|
||||
|
||||
45
src/app/organizations/manage/manage-router.component.ts
Normal file
45
src/app/organizations/manage/manage-router.component.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
} from '@angular/core';
|
||||
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { UserService } from 'jslib-common/abstractions/user.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-manage-router',
|
||||
templateUrl: './manage-router.component.html',
|
||||
})
|
||||
export class ManageRouterComponent implements OnInit {
|
||||
|
||||
constructor(private route: ActivatedRoute, private router: Router,
|
||||
private userService: UserService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe(async params => {
|
||||
console.log('Routing...');
|
||||
const org = await this.userService.getOrganization(params.organizationId);
|
||||
switch (true) {
|
||||
case org.canManageUsers:
|
||||
this.routeTo('people');
|
||||
break;
|
||||
case org.canViewAssignedCollections || org.canViewAllCollections:
|
||||
this.routeTo('collections');
|
||||
break;
|
||||
case org.canManageGroups:
|
||||
this.routeTo('groups');
|
||||
break;
|
||||
case org.canManagePolicies:
|
||||
this.routeTo('policies');
|
||||
break;
|
||||
case org.canAccessEventLogs:
|
||||
this.routeTo('events');
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
routeTo(page: string) {
|
||||
this.router.navigate([page], { relativeTo: this.route });
|
||||
}
|
||||
}
|
||||
28
src/app/organizations/tools/tools-router.component.ts
Normal file
28
src/app/organizations/tools/tools-router.component.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
} from '@angular/core';
|
||||
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { UserService } from 'jslib-common/abstractions/user.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tools-router',
|
||||
templateUrl: 'tools-router.component.html',
|
||||
})
|
||||
export class ToolsRouterComponent implements OnInit {
|
||||
constructor(private route: ActivatedRoute, private router: Router,
|
||||
private userService: UserService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe(async params => {
|
||||
console.log('Routing...');
|
||||
const org = await this.userService.getOrganization(params.organizationId);
|
||||
this.routeTo(org.canAccessImportExport ? 'import' : 'exposed-passwords-report');
|
||||
});
|
||||
}
|
||||
|
||||
routeTo(page: string) {
|
||||
this.router.navigate([page], { relativeTo: this.route });
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ import { VerifyEmailTokenComponent } from './accounts/verify-email-token.compone
|
||||
import { VerifyRecoverDeleteComponent } from './accounts/verify-recover-delete.component';
|
||||
|
||||
import { CollectionsComponent as OrgManageCollectionsComponent } from './organizations/manage/collections.component';
|
||||
import { ManageRouterComponent } from './organizations/manage/manage-router.component';
|
||||
import { ToolsRouterComponent } from './organizations/tools/tools-router.component';
|
||||
import { EventsComponent as OrgEventsComponent } from './organizations/manage/events.component';
|
||||
import { GroupsComponent as OrgGroupsComponent } from './organizations/manage/groups.component';
|
||||
import { ManageComponent as OrgManageComponent } from './organizations/manage/manage.component';
|
||||
@@ -277,7 +279,7 @@ const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
pathMatch: 'full',
|
||||
redirectTo: 'import',
|
||||
component: ToolsRouterComponent,
|
||||
},
|
||||
{
|
||||
path: 'import',
|
||||
@@ -365,7 +367,7 @@ const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
pathMatch: 'full',
|
||||
redirectTo: 'people',
|
||||
component: ManageRouterComponent,
|
||||
},
|
||||
{
|
||||
path: 'collections',
|
||||
|
||||
Reference in New Issue
Block a user