mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 01:35:18 -04:00
Remove AuthorColor entity
It will be replaced with the Author entity, that will save the color Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
0d6c300254
commit
81cc092e51
17 changed files with 7 additions and 98 deletions
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Column, Entity, ManyToOne } from 'typeorm';
|
||||
import { User } from '../users/user.entity';
|
||||
import { Note } from './note.entity';
|
||||
|
||||
@Entity()
|
||||
export class AuthorColor {
|
||||
@ManyToOne((_) => Note, (note) => note.authorColors, {
|
||||
primary: true,
|
||||
})
|
||||
note: Note;
|
||||
|
||||
@ManyToOne((_) => User, {
|
||||
primary: true,
|
||||
})
|
||||
user: User;
|
||||
|
||||
@Column()
|
||||
color: string;
|
||||
}
|
|
@ -17,7 +17,6 @@ import { NoteGroupPermission } from '../permissions/note-group-permission.entity
|
|||
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
||||
import { Revision } from '../revisions/revision.entity';
|
||||
import { User } from '../users/user.entity';
|
||||
import { AuthorColor } from './author-color.entity';
|
||||
import { Tag } from './tag.entity';
|
||||
import { HistoryEntry } from '../history/history-entry.entity';
|
||||
import { MediaUpload } from '../media/media-upload.entity';
|
||||
|
@ -59,8 +58,6 @@ export class Note {
|
|||
owner: User | null;
|
||||
@OneToMany((_) => Revision, (revision) => revision.note, { cascade: true })
|
||||
revisions: Promise<Revision[]>;
|
||||
@OneToMany((_) => AuthorColor, (authorColor) => authorColor.note)
|
||||
authorColors: AuthorColor[];
|
||||
@OneToMany((_) => HistoryEntry, (historyEntry) => historyEntry.user)
|
||||
historyEntries: HistoryEntry[];
|
||||
@OneToMany((_) => MediaUpload, (mediaUpload) => mediaUpload.note)
|
||||
|
@ -90,7 +87,6 @@ export class Note {
|
|||
newNote.alias = alias ?? null;
|
||||
newNote.viewCount = 0;
|
||||
newNote.owner = owner ?? null;
|
||||
newNote.authorColors = [];
|
||||
newNote.userPermissions = [];
|
||||
newNote.groupPermissions = [];
|
||||
newNote.revisions = Promise.resolve([]) as Promise<Revision[]>;
|
||||
|
|
|
@ -5,24 +5,22 @@
|
|||
*/
|
||||
|
||||
import { forwardRef, Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { GroupsModule } from '../groups/groups.module';
|
||||
import { LoggerModule } from '../logger/logger.module';
|
||||
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
||||
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
||||
import { RevisionsModule } from '../revisions/revisions.module';
|
||||
import { UsersModule } from '../users/users.module';
|
||||
import { AuthorColor } from './author-color.entity';
|
||||
import { Note } from './note.entity';
|
||||
import { NotesService } from './notes.service';
|
||||
import { Tag } from './tag.entity';
|
||||
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
||||
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
||||
import { GroupsModule } from '../groups/groups.module';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([
|
||||
Note,
|
||||
AuthorColor,
|
||||
Tag,
|
||||
NoteGroupPermission,
|
||||
NoteUserPermission,
|
||||
|
|
|
@ -14,7 +14,6 @@ import { AuthToken } from '../auth/auth-token.entity';
|
|||
import { Identity } from '../users/identity.entity';
|
||||
import { User } from '../users/user.entity';
|
||||
import { UsersModule } from '../users/users.module';
|
||||
import { AuthorColor } from './author-color.entity';
|
||||
import { Note } from './note.entity';
|
||||
import { NotesService } from './notes.service';
|
||||
import { Repository } from 'typeorm';
|
||||
|
@ -80,8 +79,6 @@ describe('NotesService', () => {
|
|||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Revision))
|
||||
.useClass(Repository)
|
||||
.overrideProvider(getRepositoryToken(NoteGroupPermission))
|
||||
|
@ -688,13 +685,6 @@ describe('NotesService', () => {
|
|||
note.alias = 'testAlias';
|
||||
note.title = 'testTitle';
|
||||
note.description = 'testDescription';
|
||||
note.authorColors = [
|
||||
{
|
||||
note: note,
|
||||
user: user,
|
||||
color: 'red',
|
||||
} as AuthorColor,
|
||||
];
|
||||
note.owner = user;
|
||||
note.userPermissions = [
|
||||
{
|
||||
|
@ -782,13 +772,6 @@ describe('NotesService', () => {
|
|||
note.alias = 'testAlias';
|
||||
note.title = 'testTitle';
|
||||
note.description = 'testDescription';
|
||||
note.authorColors = [
|
||||
{
|
||||
note: note,
|
||||
user: user,
|
||||
color: 'red',
|
||||
} as AuthorColor,
|
||||
];
|
||||
note.owner = user;
|
||||
note.userPermissions = [
|
||||
{
|
||||
|
|
|
@ -60,13 +60,7 @@ export class NotesService {
|
|||
async getUserNotes(user: User): Promise<Note[]> {
|
||||
const notes = await this.noteRepository.find({
|
||||
where: { owner: user },
|
||||
relations: [
|
||||
'owner',
|
||||
'userPermissions',
|
||||
'groupPermissions',
|
||||
'authorColors',
|
||||
'tags',
|
||||
],
|
||||
relations: ['owner', 'userPermissions', 'groupPermissions', 'tags'],
|
||||
});
|
||||
if (notes === undefined) {
|
||||
return [];
|
||||
|
@ -173,7 +167,6 @@ export class NotesService {
|
|||
},
|
||||
],
|
||||
relations: [
|
||||
'authorColors',
|
||||
'owner',
|
||||
'groupPermissions',
|
||||
'groupPermissions.group',
|
||||
|
@ -365,9 +358,7 @@ export class NotesService {
|
|||
title: note.title ?? '',
|
||||
createTime: (await this.getFirstRevision(note)).createdAt,
|
||||
description: note.description ?? '',
|
||||
editedBy: note.authorColors.map(
|
||||
(authorColor) => authorColor.user.userName,
|
||||
),
|
||||
editedBy: [], // TODO temporary placeholder,
|
||||
permissions: this.toNotePermissionsDto(note),
|
||||
tags: this.toTagList(note),
|
||||
updateTime: (await this.getLatestRevision(note)).createdAt,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue