diff --git a/javascript/apps/taiga/src/app/modules/project/feature-navigation/project-feature-navigation.component.html b/javascript/apps/taiga/src/app/modules/project/feature-navigation/project-feature-navigation.component.html index e9df29b54..a708bf20d 100644 --- a/javascript/apps/taiga/src/app/modules/project/feature-navigation/project-feature-navigation.component.html +++ b/javascript/apps/taiga/src/app/modules/project/feature-navigation/project-feature-navigation.component.html @@ -10,7 +10,6 @@ [@mainNavContainer]="menuState" class="main-nav-container-inner"> - {{ showProjectSettings }} { this.cancelCreateWorkflow(); }); + + this.events(); } public createWorkflow(workflow: Workflow['name']) { @@ -71,4 +78,32 @@ export class ProjectFeatureNewWorkflowComponent { ? [previousUrl] : [`/project/${project.id}${project.slug}/overview`]; } + + public events() { + this.wsService + .userEvents<{ membership: Membership }>('projectmemberships.update') + .pipe(untilDestroyed(this)) + .subscribe((eventResponse) => { + const response = eventResponse.event.content; + if (!response.membership.role.isAdmin) { + this.userLoseAdminRole(); + } + }); + } + + public userLoseAdminRole() { + this.appService.toastNotification({ + message: 'errors.admin_permission', + paramsMessage: { + project: this.state.get('project').name, + }, + status: TuiNotification.Warning, + closeOnNavigation: false, + }); + void this.router.navigate([ + `/project/${this.state.get('project').id}/${ + this.state.get('project').slug + }/overview`, + ]); + } } diff --git a/javascript/apps/taiga/src/app/modules/project/feature-shell/project-feature-shell-routing.module.ts b/javascript/apps/taiga/src/app/modules/project/feature-shell/project-feature-shell-routing.module.ts index 00b68e79b..60250c240 100644 --- a/javascript/apps/taiga/src/app/modules/project/feature-shell/project-feature-shell-routing.module.ts +++ b/javascript/apps/taiga/src/app/modules/project/feature-shell/project-feature-shell-routing.module.ts @@ -22,50 +22,13 @@ const routes: Routes = [ }, children: [ { - path: '', - loadChildren: () => - import( - '~/app/modules/project/feature-overview/project-feature-overview.module' - ).then((m) => m.ProjectFeatureOverviewModule), - }, - { - path: ':slug', - loadChildren: () => - import( - '~/app/modules/project/feature-overview/project-feature-overview.module' - ).then((m) => m.ProjectFeatureOverviewModule), - }, - { - path: 'overview', - loadChildren: () => - import( - '~/app/modules/project/feature-overview/project-feature-overview.module' - ).then((m) => m.ProjectFeatureOverviewModule), - data: { - overview: true, - }, - }, - { - path: ':slug/overview', - loadChildren: () => - import( - '~/app/modules/project/feature-overview/project-feature-overview.module' - ).then((m) => m.ProjectFeatureOverviewModule), - data: { - overview: true, - }, + path: ':slug/kanban', + redirectTo: ':slug/kanban/main', + pathMatch: 'full', }, { path: 'kanban', - loadChildren: () => - import( - '~/app/modules/project/feature-view-setter/project-feature-view-setter.module' - ).then((m) => m.ProjectFeatureViewSetterModule), - canDeactivate: [CanDeactivateGuard], - }, - { - path: ':slug/kanban', - redirectTo: ':slug/kanban/main', + redirectTo: '/kanban/main', pathMatch: 'full', }, { @@ -80,14 +43,14 @@ const routes: Routes = [ }, }, { - path: ':slug/new-workflow', + path: ':slug/stories/:storyRef', loadChildren: () => import( - '~/app/modules/project/feature-new-workflow/project-feature-new-workflow.module' - ).then((m) => m.ProjectFeatureNewWorkflowModule), + '~/app/modules/project/feature-view-setter/project-feature-view-setter.module' + ).then((m) => m.ProjectFeatureViewSetterModule), canDeactivate: [CanDeactivateGuard], data: { - newKanban: true, + stories: true, }, }, { @@ -98,18 +61,20 @@ const routes: Routes = [ ).then((m) => m.ProjectFeatureViewSetterModule), canDeactivate: [CanDeactivateGuard], data: { - kanban: true, + stories: true, }, }, { - path: ':slug/stories/:storyRef', + path: ':slug/settings', loadChildren: () => import( - '~/app/modules/project/feature-view-setter/project-feature-view-setter.module' - ).then((m) => m.ProjectFeatureViewSetterModule), - canDeactivate: [CanDeactivateGuard], + '~/app/modules/project/settings/feature-settings/feature-settings.module' + ).then((m) => m.ProjectSettingsFeatureSettingsModule), data: { - stories: true, + settings: true, + }, + resolve: { + project: ProjectAdminResolver, }, }, { @@ -126,17 +91,37 @@ const routes: Routes = [ }, }, { - path: ':slug/settings', + path: 'overview', loadChildren: () => import( - '~/app/modules/project/settings/feature-settings/feature-settings.module' - ).then((m) => m.ProjectSettingsFeatureSettingsModule), + '~/app/modules/project/feature-overview/project-feature-overview.module' + ).then((m) => m.ProjectFeatureOverviewModule), data: { - settings: true, + overview: true, }, + }, + { + path: ':slug/overview', + loadChildren: () => + import( + '~/app/modules/project/feature-overview/project-feature-overview.module' + ).then((m) => m.ProjectFeatureOverviewModule), + data: { + overview: true, + }, + }, + { + path: ':slug/new-workflow', + loadChildren: () => + import( + '~/app/modules/project/feature-new-workflow/project-feature-new-workflow.module' + ).then((m) => m.ProjectFeatureNewWorkflowModule), resolve: { project: ProjectAdminResolver, }, + data: { + newKanban: true, + }, }, ], },