Skip to content

Commit

Permalink
fix(api-headless-cms): improve moveEntryToBin operation (#4292)
Browse files Browse the repository at this point in the history
  • Loading branch information
leopuleo authored Sep 25, 2024
1 parent 6860ae8 commit 8f43ff3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ export const assignAfterEntryDelete = (params: AssignAfterEntryDeleteParams) =>
const { context, onEntryAfterDelete } = params;

onEntryAfterDelete.subscribe(async params => {
const { entry, model } = params;
const { entry, model, permanent } = params;

// If the entry is being moved to the trash, we keep the model fields locked because the entry can be restored.
if (!permanent) {
return;
}
const { items } = await context.cms.storageOperations.entries.list(model, {
where: {
entryId_not: entry.entryId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { SecurityIdentity } from "@webiny/api-security/types";
import { entryFromStorageTransform, entryToStorageTransform } from "~/utils/entryStorage";
import { getDate } from "~/utils/date";
import { getIdentity } from "~/utils/identity";
import { validateModelEntryDataOrThrow } from "~/crud/contentEntry/entryDataValidation";
import { CmsContext, CmsEntry, CmsEntryStorageOperationsMoveToBinParams, CmsModel } from "~/types";
import { ROOT_FOLDER } from "~/constants";

Expand All @@ -29,14 +28,6 @@ export class TransformEntryMoveToBin {
}

private async createDeleteEntryData(model: CmsModel, originalEntry: CmsEntry) {
await validateModelEntryDataOrThrow({
context: this.context,
model,
data: originalEntry.values,
entry: originalEntry,
skipValidators: ["required"]
});

const currentDateTime = new Date().toISOString();
const currentIdentity = this.getIdentity();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { SecurityIdentity } from "@webiny/api-security/types";
import { entryFromStorageTransform, entryToStorageTransform } from "~/utils/entryStorage";
import { getDate } from "~/utils/date";
import { getIdentity } from "~/utils/identity";
import { validateModelEntryDataOrThrow } from "~/crud/contentEntry/entryDataValidation";
import { CmsContext, CmsEntry, CmsEntryStorageOperationsMoveToBinParams, CmsModel } from "~/types";

export class TransformEntryRestoreFromBin {
Expand All @@ -28,14 +27,6 @@ export class TransformEntryRestoreFromBin {
}

private async createRestoreFromBinEntryData(model: CmsModel, originalEntry: CmsEntry) {
await validateModelEntryDataOrThrow({
context: this.context,
model,
data: originalEntry.values,
entry: originalEntry,
skipValidators: ["required"]
});

const currentDateTime = new Date().toISOString();
const currentIdentity = this.getIdentity();

Expand Down

0 comments on commit 8f43ff3

Please sign in to comment.