Closed steel-hyuk closed 1 year ago
hi@u-hoo.com
The handler does not work when I give the value of the name option of actions.
It happens every moment I try to do that action.
"adminjs": "^7.0.0", "@adminjs/express": "^6.0.0", "@adminjs/nestjs": "^6.0.1", "@adminjs/typeorm": "^5.0.0",
Chrome
[Nest] 28835 - 2023. 04. 28. 오후 4:10:16 ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'handler') TypeError: Cannot read properties of undefined (reading 'handler') at ApiController.recordAction (file:///Users/eunhyuk/works/admin/octopus-admin/node_modules/adminjs/lib/backend/controllers/api-controller.js:149:55) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async file:///Users/eunhyuk/works/admin/octopus-admin/node_modules/@adminjs/express/lib/buildRouter.js:24:22
export const UserResource: ResourceWithOptions = { resource: User, options: { sort: { sortBy: 'id', direction: 'asc', }, listProperties: [], filterProperties: [], editProperties: [], showProperties: [], actions: { delete: { name: '삭제', isVisible: true, icon: 'Trash2', guard: 'confirmDelete', component: false, variant: 'danger', handler: async (request, _response, context) => { const { record, resource, currentAdmin, h } = context; if (!request.params.recordId || !record) { throw new NotFoundError(['You have to pass "recordId" to Delete Action'].join('\n'), 'Action#handler'); } try { await record.update({ archived: true, archived_at: Date() }); } catch (err) { if (err instanceof ValidationError) { const baseMessage = err.baseError?.message || 'thereWereValidationErrors'; return { record: record.toJSON(currentAdmin), notice: { message: baseMessage, type: 'error' } }; } throw err; } return { record: record.toJSON(currentAdmin), redirectUrl: h.resourceUrl({ resourceId: resource._decorated?.id() || resource.id() }), notice: { message: '성공적으로 삭제되었습니다.', type: 'success' } }; } }, } } }
The delete action does not work. It works when I clear 'name' option.
I think you should just use locale for translations and leave name undefined in this case
locale
name
Contact Details
hi@u-hoo.com
What happened?
The handler does not work when I give the value of the name option of actions.
Bug prevalence
It happens every moment I try to do that action.
AdminJS dependencies version
What browsers do you see the problem on?
Chrome
Relevant log output
Relevant code that's giving you issues
The delete action does not work. It works when I clear 'name' option.