Skip to content

Commit

Permalink
feat(workflows): ui review
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaviju committed Sep 29, 2023
1 parent 3e90c35 commit e1b807b
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
[@mainNavContainer]="menuState"
class="main-nav-container-inner">
<!-- visibility: hidden prevent focus in the project menu when the setting menu is visible -->
{{ showProjectSettings }}
<tg-project-navigation-menu
[collapsed]="collapsed"
[class.collapsed]="collapsed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Actions, ofType } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { RxState } from '@rx-angular/state';
import { Project, Workflow } from '@taiga/data';
import { TuiNotification } from '@taiga-ui/core';
import { Membership, Project, Workflow } from '@taiga/data';
import { AppService } from '~/app/services/app.service';
import { WsService } from '~/app/services/ws';
import { RouteHistoryService } from '~/app/shared/route-history/route-history.service';
import { filterNil } from '~/app/shared/utils/operators';
import {
Expand All @@ -39,7 +42,9 @@ export class ProjectFeatureNewWorkflowComponent {
private store: Store,
private router: Router,
private actions$: Actions,
private routeHistoryService: RouteHistoryService
private routeHistoryService: RouteHistoryService,
private wsService: WsService,
private appService: AppService
) {
this.state.connect(
'project',
Expand All @@ -50,6 +55,8 @@ export class ProjectFeatureNewWorkflowComponent {
.subscribe(() => {
this.cancelCreateWorkflow();
});

this.events();
}

public createWorkflow(workflow: Workflow['name']) {
Expand All @@ -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`,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
{
Expand All @@ -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,
},
},
{
Expand All @@ -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,
},
},
{
Expand All @@ -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,
},
},
],
},
Expand Down

0 comments on commit e1b807b

Please sign in to comment.