mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: block deletion for built Nlp Entities
This commit is contained in:
parent
933daaa221
commit
ab30c46d97
@ -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 },
|
||||
});
|
||||
|
@ -267,6 +267,7 @@ const NlpEntity = () => {
|
||||
<DataGrid
|
||||
columns={nlpEntityColumns}
|
||||
{...nlpEntityGrid}
|
||||
isRowSelectable={({ row }) => !row.builtin}
|
||||
checkboxSelection
|
||||
onRowSelectionModelChange={handleSelectionChange}
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user