mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 19:26:31 -05: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
|
@ -19,7 +19,6 @@ import { User } from '../../../../users/user.entity';
|
|||
import { Note } from '../../../../notes/note.entity';
|
||||
import { AuthToken } from '../../../../auth/auth-token.entity';
|
||||
import { Identity } from '../../../../users/identity.entity';
|
||||
import { AuthorColor } from '../../../../notes/author-color.entity';
|
||||
import { Authorship } from '../../../../revisions/authorship.entity';
|
||||
import { Revision } from '../../../../revisions/revision.entity';
|
||||
import { Tag } from '../../../../notes/tag.entity';
|
||||
|
@ -58,8 +57,6 @@ describe('HistoryController', () => {
|
|||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Identity))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Revision))
|
||||
|
|
|
@ -12,7 +12,6 @@ import { getRepositoryToken } from '@nestjs/typeorm';
|
|||
import { User } from '../../../users/user.entity';
|
||||
import { Identity } from '../../../users/identity.entity';
|
||||
import { MediaModule } from '../../../media/media.module';
|
||||
import { AuthorColor } from '../../../notes/author-color.entity';
|
||||
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
||||
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
||||
import { Authorship } from '../../../revisions/authorship.entity';
|
||||
|
@ -62,8 +61,6 @@ describe('MeController', () => {
|
|||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Group))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(NoteGroupPermission))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(NoteUserPermission))
|
||||
|
|
|
@ -16,7 +16,6 @@ import externalConfigMock from '../../../config/mock/external-services.config.mo
|
|||
import { MediaModule } from '../../../media/media.module';
|
||||
import { NotesModule } from '../../../notes/notes.module';
|
||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||
import { AuthorColor } from '../../../notes/author-color.entity';
|
||||
import { Authorship } from '../../../revisions/authorship.entity';
|
||||
import { AuthToken } from '../../../auth/auth-token.entity';
|
||||
import { Identity } from '../../../users/identity.entity';
|
||||
|
@ -51,8 +50,6 @@ describe('MediaController', () => {
|
|||
],
|
||||
controllers: [MediaController],
|
||||
})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthToken))
|
||||
|
|
|
@ -26,7 +26,6 @@ import appConfigMock from '../../../config/mock/app.config.mock';
|
|||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||
import { Revision } from '../../../revisions/revision.entity';
|
||||
import { Authorship } from '../../../revisions/authorship.entity';
|
||||
import { AuthorColor } from '../../../notes/author-color.entity';
|
||||
import { User } from '../../../users/user.entity';
|
||||
import { AuthToken } from '../../../auth/auth-token.entity';
|
||||
import { Identity } from '../../../users/identity.entity';
|
||||
|
@ -74,8 +73,7 @@ describe('NotesController', () => {
|
|||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
|
||||
.overrideProvider(getRepositoryToken(User))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthToken))
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
} from '@nestjs/typeorm';
|
||||
import { HistoryModule } from '../../../history/history.module';
|
||||
import { LoggerModule } from '../../../logger/logger.module';
|
||||
import { AuthorColor } from '../../../notes/author-color.entity';
|
||||
import { Note } from '../../../notes/note.entity';
|
||||
import { NotesModule } from '../../../notes/notes.module';
|
||||
import { Tag } from '../../../notes/tag.entity';
|
||||
|
@ -62,8 +61,6 @@ describe('Me Controller', () => {
|
|||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Identity))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Revision))
|
||||
|
|
|
@ -12,7 +12,6 @@ import mediaConfigMock from '../../../config/mock/media.config.mock';
|
|||
import { LoggerModule } from '../../../logger/logger.module';
|
||||
import { MediaUpload } from '../../../media/media-upload.entity';
|
||||
import { MediaModule } from '../../../media/media.module';
|
||||
import { AuthorColor } from '../../../notes/author-color.entity';
|
||||
import { Note } from '../../../notes/note.entity';
|
||||
import { NotesModule } from '../../../notes/notes.module';
|
||||
import { Tag } from '../../../notes/tag.entity';
|
||||
|
@ -42,8 +41,6 @@ describe('Media Controller', () => {
|
|||
NotesModule,
|
||||
],
|
||||
})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthToken))
|
||||
|
|
|
@ -11,7 +11,6 @@ import {
|
|||
TypeOrmModule,
|
||||
} from '@nestjs/typeorm';
|
||||
import { LoggerModule } from '../../../logger/logger.module';
|
||||
import { AuthorColor } from '../../../notes/author-color.entity';
|
||||
import { Note } from '../../../notes/note.entity';
|
||||
import { NotesService } from '../../../notes/notes.service';
|
||||
import { Tag } from '../../../notes/tag.entity';
|
||||
|
@ -76,8 +75,6 @@ describe('Notes Controller', () => {
|
|||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(User))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthToken))
|
||||
|
|
|
@ -12,7 +12,6 @@ import { NotesModule } from '../notes/notes.module';
|
|||
import { getConnectionToken, getRepositoryToken } from '@nestjs/typeorm';
|
||||
import { Identity } from '../users/identity.entity';
|
||||
import { User } from '../users/user.entity';
|
||||
import { AuthorColor } from '../notes/author-color.entity';
|
||||
import { Authorship } from '../revisions/authorship.entity';
|
||||
import { HistoryEntry } from './history-entry.entity';
|
||||
import { Note } from '../notes/note.entity';
|
||||
|
@ -75,8 +74,6 @@ describe('HistoryService', () => {
|
|||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Revision))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Note))
|
||||
|
|
|
@ -9,7 +9,6 @@ import { Test, TestingModule } from '@nestjs/testing';
|
|||
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||
import mediaConfigMock from '../config/mock/media.config.mock';
|
||||
import { LoggerModule } from '../logger/logger.module';
|
||||
import { AuthorColor } from '../notes/author-color.entity';
|
||||
import { Note } from '../notes/note.entity';
|
||||
import { NotesModule } from '../notes/notes.module';
|
||||
import { Tag } from '../notes/tag.entity';
|
||||
|
@ -56,8 +55,6 @@ describe('MediaService', () => {
|
|||
UsersModule,
|
||||
],
|
||||
})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthToken))
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -9,7 +9,6 @@ import { getRepositoryToken } from '@nestjs/typeorm';
|
|||
import { AuthToken } from '../auth/auth-token.entity';
|
||||
import { Group } from '../groups/group.entity';
|
||||
import { LoggerModule } from '../logger/logger.module';
|
||||
import { AuthorColor } from '../notes/author-color.entity';
|
||||
import { Note } from '../notes/note.entity';
|
||||
import { NotesModule } from '../notes/notes.module';
|
||||
import { Tag } from '../notes/tag.entity';
|
||||
|
@ -50,8 +49,6 @@ describe('PermissionsService', () => {
|
|||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Revision))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Note))
|
||||
|
|
|
@ -9,7 +9,6 @@ import { getRepositoryToken } from '@nestjs/typeorm';
|
|||
import { Repository } from 'typeorm';
|
||||
import { NotInDBError } from '../errors/errors';
|
||||
import { LoggerModule } from '../logger/logger.module';
|
||||
import { AuthorColor } from '../notes/author-color.entity';
|
||||
import { Note } from '../notes/note.entity';
|
||||
import { NotesModule } from '../notes/notes.module';
|
||||
import { AuthToken } from '../auth/auth-token.entity';
|
||||
|
@ -49,8 +48,6 @@ describe('RevisionsService', () => {
|
|||
})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(User))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(AuthToken))
|
||||
|
|
|
@ -12,7 +12,6 @@ import { Authorship } from './revisions/authorship.entity';
|
|||
import { NoteGroupPermission } from './permissions/note-group-permission.entity';
|
||||
import { NoteUserPermission } from './permissions/note-user-permission.entity';
|
||||
import { Group } from './groups/group.entity';
|
||||
import { AuthorColor } from './notes/author-color.entity';
|
||||
import { HistoryEntry } from './history/history-entry.entity';
|
||||
import { MediaUpload } from './media/media-upload.entity';
|
||||
import { Tag } from './notes/tag.entity';
|
||||
|
@ -33,7 +32,6 @@ createConnection({
|
|||
NoteGroupPermission,
|
||||
NoteUserPermission,
|
||||
Group,
|
||||
AuthorColor,
|
||||
HistoryEntry,
|
||||
MediaUpload,
|
||||
Tag,
|
||||
|
|
Loading…
Reference in a new issue