Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(front): i#3936 add project name to notifications #478

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Router } from '@angular/router';
import { randUuid } from '@ngneat/falso';
import { randUuid, randCompanyName } from '@ngneat/falso';
import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest';
import { provideMockActions } from '@ngrx/effects/testing';
import { Action } from '@ngrx/store';
Expand Down Expand Up @@ -80,13 +80,15 @@ describe('ProjectEffects', () => {

it('Accepted Invitation', () => {
const id = randUuid();
const projectName = randCompanyName();
const user = UserMockFactory();
const username = user.username;
const effects = spectator.inject(ProjectEffects);

actions$ = hot('-a', {
a: invitationProjectActions.acceptInvitationIdSuccess({
projectId: id,
projectName,
username,
}),
});
Expand All @@ -96,6 +98,7 @@ describe('ProjectEffects', () => {
actions$ = hot('-a', {
a: invitationProjectActions.acceptInvitationIdSuccess({
projectId: id,
projectName,
username,
}),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,12 @@ export class ProjectEffects {
public acceptedInvitation$ = createEffect(() => {
return this.actions$.pipe(
ofType(invitationProjectActions.acceptInvitationIdSuccess),
tap(() => {
tap(({ projectName }) => {
this.appService.toastNotification({
message: 'invitation_accept_message',
paramsMessage: {
project: projectName,
},
status: TuiNotification.Success,
scope: 'invitation_modal',
autoClose: true,
Expand Down Expand Up @@ -240,10 +243,13 @@ export class ProjectEffects {
})
);
},
onError: (_, httpResponse: HttpErrorResponse) => {
onError: (action, httpResponse: HttpErrorResponse) => {
if (httpResponse.status === 403) {
this.appService.toastNotification({
message: 'errors.admin_permission',
paramsMessage: {
project: action.name,
},
status: TuiNotification.Error,
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export class EditProjectComponent implements OnInit {
if (!this.project.userIsAdmin) {
this.appService.toastNotification({
message: 'errors.admin_permission',
paramsMessage: {
project: this.project.name,
},
status: TuiNotification.Error,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export class ProjectMembersComponent {
this.store.dispatch(
invitationProjectActions.acceptInvitationId({
id: this.state.get('project').id,
name: this.state.get('project').name,
})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ export class ProjectOverviewEffects {
})
);
},
onError: (_, httpResponse: HttpErrorResponse) => {
onError: (action, httpResponse: HttpErrorResponse) => {
if (httpResponse.status === 403) {
this.appService.toastNotification({
message: 'errors.admin_permission',
paramsMessage: {
project: action.project.name,
},
status: TuiNotification.Error,
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ export class ProjectFeatureShellComponent implements OnDestroy, AfterViewInit {
this.store.dispatch(
invitationProjectActions.acceptInvitationId({
id: this.state.get('project').id,
name: this.state.get('project').name,
isBanner: true,
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ export class ProjectsSettingsFeatureSettingsComponent {
projectSlug?: Project['slug']
) {
this.appService.toastNotification({
message: 'members.no_longer_admin',
message: 'errors.admin_permission',
paramsMessage: {
project: this.state.get('project').name,
},
status: TuiNotification.Warning,
scope: 'project_settings',
closeOnNavigation: false,
});
void this.router.navigate([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export class WorkspaceDetailProjectsComponent implements OnInit {
this.setCardAmounts(event.newRect.width);
}

public acceptProjectInvite(id: string, name?: string) {
public acceptProjectInvite(id: string, name: string) {
this.store.dispatch(
invitationProjectActions.acceptInvitationId({
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ export const invitationProjectActions = createActionGroup({
}>(),
'Accept invitation id': props<{
id: string;
name?: string;
name: string;
isBanner?: boolean;
}>(),
'Accept invitation id success': props<{
projectId: string;
projectName: string;
username: string;
}>(),
'Accept invitation id error': props<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
randUserName,
randUuid,
randWord,
randCompanyName,
} from '@ngneat/falso';
import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest';
import { provideMockActions } from '@ngrx/effects/testing';
Expand Down Expand Up @@ -102,6 +103,7 @@ describe('InvitationEffects', () => {
const user = UserMockFactory();
const slug = randSlug();
const id = randUuid();
const projectName = randCompanyName();
const username = user.username;
const acceptInvitationIdMockPayload = [
{
Expand All @@ -125,12 +127,13 @@ describe('InvitationEffects', () => {
);

actions$ = hot('-a', {
a: invitationProjectActions.acceptInvitationId({ id }),
a: invitationProjectActions.acceptInvitationId({ id, name: projectName }),
});

const expected = cold('--a', {
a: invitationProjectActions.acceptInvitationIdSuccess({
projectId: id,
projectName,
username,
}),
});
Expand All @@ -140,6 +143,7 @@ describe('InvitationEffects', () => {

it('Accept project invitation id error', () => {
const id = randUuid();
const projectName = randCompanyName();
const effects = spectator.inject(InvitationEffects);
const appService = spectator.inject(AppService);
const projectApiService = spectator.inject(ProjectApiService);
Expand All @@ -159,7 +163,7 @@ describe('InvitationEffects', () => {
);

actions$ = hot('-a', {
a: invitationProjectActions.acceptInvitationId({ id }),
a: invitationProjectActions.acceptInvitationId({ id, name: projectName }),
});

const expected = cold('--a', {
Expand All @@ -178,6 +182,7 @@ describe('InvitationEffects', () => {

it('Accept project invitation revoke error', () => {
const id = randUuid();
const projectName = randCompanyName();
const effects = spectator.inject(InvitationEffects);
const appService = spectator.inject(AppService);
const projectApiService = spectator.inject(ProjectApiService);
Expand All @@ -197,7 +202,7 @@ describe('InvitationEffects', () => {
);

actions$ = hot('-a', {
a: invitationProjectActions.acceptInvitationId({ id }),
a: invitationProjectActions.acceptInvitationId({ id, name: projectName }),
});

const expected = cold('--a', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export class InvitationEffects {
map(([, user]) => {
return invitationProjectActions.acceptInvitationIdSuccess({
projectId: action.id,
projectName: action.name,
username: user.username,
});
})
Expand Down
3 changes: 1 addition & 2 deletions javascript/apps/taiga/src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,10 @@
"project_invitation_no_longer_valid": "The invitation to {{ name }} is no longer valid.",
"lose_story_permissions": "You no longer have permissions to {{permission}} stories",
"you_dont_have_permission_to_see": "You don't have permission to see the project.",
"admin_permission": "You are no longer admin on this project",
"admin_permission": "You are no longer admin on {{project}} project.",
"entity_no_longer_exists": "This {{entity}} no longer exists.",
"user_deleted_entity": "{{user}} has deleted it, so you cannot edit it anymore.",
"deleted_project": "Project {{name}} has been deleted.",
"generic_deleted_project": "This project has been deleted.",
"deleted_workspace": "The workspace {{name}} has been deleted."
},
"form_errors": {
Expand Down
15 changes: 15 additions & 0 deletions javascript/apps/taiga/src/assets/i18n/attachments/ar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"action": "Attach file",
"title": "Attachments",
"attachments_nav": "Attachments navigation",
"collapse_attachments": "Collapse attachments",
"expand_attachments": "Expand attachments",
"column_name": "Name",
"column_date": "Date",
"column_size": "Size",
"column_actions": "Attachments actions",
"download": "Download",
"delete": "Delete",
"error_size": "The file {{filename}} has not been attached because it exceeds the maximum size of {{maxSize}}MB",
"uploading": "Uploading {{file}}"
}
15 changes: 15 additions & 0 deletions javascript/apps/taiga/src/assets/i18n/attachments/bg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"action": "Attach file",
"title": "Attachments",
"attachments_nav": "Attachments navigation",
"collapse_attachments": "Collapse attachments",
"expand_attachments": "Expand attachments",
"column_name": "Name",
"column_date": "Date",
"column_size": "Size",
"column_actions": "Attachments actions",
"download": "Download",
"delete": "Delete",
"error_size": "The file {{filename}} has not been attached because it exceeds the maximum size of {{maxSize}}MB",
"uploading": "Uploading {{file}}"
}
15 changes: 15 additions & 0 deletions javascript/apps/taiga/src/assets/i18n/attachments/ca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"action": "Attach file",
"title": "Attachments",
"attachments_nav": "Attachments navigation",
"collapse_attachments": "Collapse attachments",
"expand_attachments": "Expand attachments",
"column_name": "Name",
"column_date": "Date",
"column_size": "Size",
"column_actions": "Attachments actions",
"download": "Download",
"delete": "Delete",
"error_size": "The file {{filename}} has not been attached because it exceeds the maximum size of {{maxSize}}MB",
"uploading": "Uploading {{file}}"
}
15 changes: 15 additions & 0 deletions javascript/apps/taiga/src/assets/i18n/attachments/es-ES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"action": "Attach file",
"title": "Attachments",
"attachments_nav": "Attachments navigation",
"collapse_attachments": "Collapse attachments",
"expand_attachments": "Expand attachments",
"column_name": "Name",
"column_date": "Date",
"column_size": "Size",
"column_actions": "Attachments actions",
"download": "Download",
"delete": "Delete",
"error_size": "The file {{filename}} has not been attached because it exceeds the maximum size of {{maxSize}}MB",
"uploading": "Uploading {{file}}"
}
15 changes: 15 additions & 0 deletions javascript/apps/taiga/src/assets/i18n/attachments/eu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"action": "Attach file",
"title": "Attachments",
"attachments_nav": "Attachments navigation",
"collapse_attachments": "Collapse attachments",
"expand_attachments": "Expand attachments",
"column_name": "Name",
"column_date": "Date",
"column_size": "Size",
"column_actions": "Attachments actions",
"download": "Download",
"delete": "Delete",
"error_size": "The file {{filename}} has not been attached because it exceeds the maximum size of {{maxSize}}MB",
"uploading": "Uploading {{file}}"
}
15 changes: 15 additions & 0 deletions javascript/apps/taiga/src/assets/i18n/attachments/fa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"action": "Attach file",
"title": "Attachments",
"attachments_nav": "Attachments navigation",
"collapse_attachments": "Collapse attachments",
"expand_attachments": "Expand attachments",
"column_name": "Name",
"column_date": "Date",
"column_size": "Size",
"column_actions": "Attachments actions",
"download": "Download",
"delete": "Delete",
"error_size": "The file {{filename}} has not been attached because it exceeds the maximum size of {{maxSize}}MB",
"uploading": "Uploading {{file}}"
}
15 changes: 15 additions & 0 deletions javascript/apps/taiga/src/assets/i18n/attachments/he.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"action": "Attach file",
"title": "Attachments",
"attachments_nav": "Attachments navigation",
"collapse_attachments": "Collapse attachments",
"expand_attachments": "Expand attachments",
"column_name": "Name",
"column_date": "Date",
"column_size": "Size",
"column_actions": "Attachments actions",
"download": "Download",
"delete": "Delete",
"error_size": "The file {{filename}} has not been attached because it exceeds the maximum size of {{maxSize}}MB",
"uploading": "Uploading {{file}}"
}
15 changes: 15 additions & 0 deletions javascript/apps/taiga/src/assets/i18n/attachments/ja.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"action": "Attach file",
"title": "Attachments",
"attachments_nav": "Attachments navigation",
"collapse_attachments": "Collapse attachments",
"expand_attachments": "Expand attachments",
"column_name": "Name",
"column_date": "Date",
"column_size": "Size",
"column_actions": "Attachments actions",
"download": "Download",
"delete": "Delete",
"error_size": "The file {{filename}} has not been attached because it exceeds the maximum size of {{maxSize}}MB",
"uploading": "Uploading {{file}}"
}
15 changes: 15 additions & 0 deletions javascript/apps/taiga/src/assets/i18n/attachments/ko.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"action": "Attach file",
"title": "Attachments",
"attachments_nav": "Attachments navigation",
"collapse_attachments": "Collapse attachments",
"expand_attachments": "Expand attachments",
"column_name": "Name",
"column_date": "Date",
"column_size": "Size",
"column_actions": "Attachments actions",
"download": "Download",
"delete": "Delete",
"error_size": "The file {{filename}} has not been attached because it exceeds the maximum size of {{maxSize}}MB",
"uploading": "Uploading {{file}}"
}
15 changes: 15 additions & 0 deletions javascript/apps/taiga/src/assets/i18n/attachments/pt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"action": "Attach file",
"title": "Attachments",
"attachments_nav": "Attachments navigation",
"collapse_attachments": "Collapse attachments",
"expand_attachments": "Expand attachments",
"column_name": "Name",
"column_date": "Date",
"column_size": "Size",
"column_actions": "Attachments actions",
"download": "Download",
"delete": "Delete",
"error_size": "The file {{filename}} has not been attached because it exceeds the maximum size of {{maxSize}}MB",
"uploading": "Uploading {{file}}"
}
Loading