fix: block deletion for built Nlp Entities

This commit is contained in:
yassinedorbozgithub 2025-05-13 15:13:31 +01:00
parent 933daaa221
commit ab30c46d97
2 changed files with 16 additions and 0 deletions

View File

@ -222,6 +222,21 @@ export class NlpEntityController extends BaseController<
if (!ids?.length) {
throw new BadRequestException('No IDs provided for deletion.');
}
const { count: builtinCount } = await this.filterCount({
_id: { $in: ids },
builtin: true,
});
if (builtinCount) {
this.logger.warn(
`Unable to delete NLP entities with provided IDs: ${ids}`,
);
throw new NotFoundException(
'Cannot delete builtin NLP entities because at least one is built-in',
);
}
const deleteResult = await this.nlpEntityService.deleteMany({
_id: { $in: ids },
});

View File

@ -267,6 +267,7 @@ const NlpEntity = () => {
<DataGrid
columns={nlpEntityColumns}
{...nlpEntityGrid}
isRowSelectable={({ row }) => !row.builtin}
checkboxSelection
onRowSelectionModelChange={handleSelectionChange}
/>