mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-22 11:15:23 -04:00
enhancement(note-deletion): allow to keep uploads
This adds support for keeping the uploads attached to a note when deleting the same note. This is done by a simple checkbox that can be clicked in the DeletionModal. To do this, some parts of the note deletion had to be refactored, especially in the case of the history page. Both the note deletion and history removal methods used the same modal, which isn't applicable now anymore. Additionally, there was a bug that the modal checked for ownership in the frontend before allowing the note deletion. However, in the context of the history page, the ownership couldn't be evaluated since the backend API didn't include that information. This is now fixed as well. Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
ebf8e3a759
commit
1c73e99b0a
18 changed files with 163 additions and 158 deletions
|
@ -5,7 +5,13 @@
|
|||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsArray, IsBoolean, IsDate, IsString } from 'class-validator';
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
IsDate,
|
||||
IsOptional,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
|
@ -26,6 +32,16 @@ export class HistoryEntryDto extends BaseDto {
|
|||
@ApiProperty()
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* The username of the owner of the note
|
||||
* Might be null for anonymous notes
|
||||
* @example "alice"
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
owner: string | null;
|
||||
|
||||
/**
|
||||
* Datestring of the last time this note was updated
|
||||
* @example "2020-12-01 12:23:34"
|
||||
|
|
|
@ -180,6 +180,7 @@ export class HistoryService {
|
|||
*/
|
||||
async toHistoryEntryDto(entry: HistoryEntry): Promise<HistoryEntryDto> {
|
||||
const note = await entry.note;
|
||||
const owner = await note.owner;
|
||||
const revision = await this.revisionsService.getLatestRevision(note);
|
||||
return {
|
||||
identifier: await getIdentifier(entry),
|
||||
|
@ -187,6 +188,7 @@ export class HistoryService {
|
|||
tags: (await revision.tags).map((tag) => tag.name),
|
||||
title: revision.title ?? '',
|
||||
pinStatus: entry.pinStatus,
|
||||
owner: owner ? owner.username : null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue