mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
refactor(note-group-permission-entry-dto): do not embed Group objects
This is part of an effort to consistently not embed Group objects in API responses. Names are returned instead. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
93301d84c7
commit
fe4e3d5657
3 changed files with 12 additions and 12 deletions
|
@ -52,11 +52,11 @@ export class NoteUserPermissionUpdateDto {
|
||||||
|
|
||||||
export class NoteGroupPermissionEntryDto {
|
export class NoteGroupPermissionEntryDto {
|
||||||
/**
|
/**
|
||||||
* Group this permission applies to
|
* Name of the Group this permission applies to
|
||||||
*/
|
*/
|
||||||
@ValidateNested()
|
@IsString()
|
||||||
@ApiProperty({ type: GroupInfoDto })
|
@ApiProperty()
|
||||||
group: GroupInfoDto;
|
groupName: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the group members are allowed to edit the note
|
* True if the group members are allowed to edit the note
|
||||||
|
|
|
@ -691,7 +691,7 @@ describe('NotesService', () => {
|
||||||
expect(permissions.sharedToUsers[0].username).toEqual(user.username);
|
expect(permissions.sharedToUsers[0].username).toEqual(user.username);
|
||||||
expect(permissions.sharedToUsers[0].canEdit).toEqual(true);
|
expect(permissions.sharedToUsers[0].canEdit).toEqual(true);
|
||||||
expect(permissions.sharedToGroups).toHaveLength(1);
|
expect(permissions.sharedToGroups).toHaveLength(1);
|
||||||
expect(permissions.sharedToGroups[0].group.displayName).toEqual(
|
expect(permissions.sharedToGroups[0].groupName).toEqual(
|
||||||
group.displayName,
|
group.displayName,
|
||||||
);
|
);
|
||||||
expect(permissions.sharedToGroups[0].canEdit).toEqual(true);
|
expect(permissions.sharedToGroups[0].canEdit).toEqual(true);
|
||||||
|
@ -783,9 +783,9 @@ describe('NotesService', () => {
|
||||||
);
|
);
|
||||||
expect(metadataDto.permissions.sharedToUsers[0].canEdit).toEqual(true);
|
expect(metadataDto.permissions.sharedToUsers[0].canEdit).toEqual(true);
|
||||||
expect(metadataDto.permissions.sharedToGroups).toHaveLength(1);
|
expect(metadataDto.permissions.sharedToGroups).toHaveLength(1);
|
||||||
expect(
|
expect(metadataDto.permissions.sharedToGroups[0].groupName).toEqual(
|
||||||
metadataDto.permissions.sharedToGroups[0].group.displayName,
|
group.displayName,
|
||||||
).toEqual(group.displayName);
|
);
|
||||||
expect(metadataDto.permissions.sharedToGroups[0].canEdit).toEqual(true);
|
expect(metadataDto.permissions.sharedToGroups[0].canEdit).toEqual(true);
|
||||||
expect(metadataDto.tags).toHaveLength(1);
|
expect(metadataDto.tags).toHaveLength(1);
|
||||||
expect(metadataDto.tags[0]).toEqual((await note.tags)[0].name);
|
expect(metadataDto.tags[0]).toEqual((await note.tags)[0].name);
|
||||||
|
@ -887,9 +887,9 @@ describe('NotesService', () => {
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
expect(noteDto.metadata.permissions.sharedToGroups).toHaveLength(1);
|
expect(noteDto.metadata.permissions.sharedToGroups).toHaveLength(1);
|
||||||
expect(
|
expect(noteDto.metadata.permissions.sharedToGroups[0].groupName).toEqual(
|
||||||
noteDto.metadata.permissions.sharedToGroups[0].group.displayName,
|
group.displayName,
|
||||||
).toEqual(group.displayName);
|
);
|
||||||
expect(noteDto.metadata.permissions.sharedToGroups[0].canEdit).toEqual(
|
expect(noteDto.metadata.permissions.sharedToGroups[0].canEdit).toEqual(
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -379,7 +379,7 @@ export class NotesService {
|
||||||
canEdit: noteUserPermission.canEdit,
|
canEdit: noteUserPermission.canEdit,
|
||||||
})),
|
})),
|
||||||
sharedToGroups: groupPermissions.map((noteGroupPermission) => ({
|
sharedToGroups: groupPermissions.map((noteGroupPermission) => ({
|
||||||
group: this.groupsService.toGroupDto(noteGroupPermission.group),
|
groupName: noteGroupPermission.group.name,
|
||||||
canEdit: noteGroupPermission.canEdit,
|
canEdit: noteGroupPermission.canEdit,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue