SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.15k stars 659 forks source link

[Bug]: I can not view link of logger record #1553

Closed nguyenvanvy1999 closed 12 months ago

nguyenvanvy1999 commented 1 year ago

Contact Details

No response

What happened?

I want to view records what was recored by adminjs/logger But it can not link with id to another record. And it throw an error like image below I was check information of logger record: Record and record id correct image

image

Bug prevalence

Yes

AdminJS dependencies version

"@adminjs/express": "^6.0.0",
"@adminjs/import-export": "^3.0.0",
"@adminjs/logger": "^5.0.1",
"@adminjs/mongoose": "^4.0.0",
"adminjs": "^7.2.1"

What browsers do you see the problem on?

No response

Relevant log output

Error: Component "RecordLink" has not been bundled, ensure it was added to your ComponentLoader instance (the one included in AdminJS options).
See development console for more details...

Relevant code that's giving you issues

resources: [
        {
          resource: this.userModel,
          features: [
            importExportFeature({ componentLoader }),
            loggerFeature({ componentLoader }),
          ],
          options: userOptions(this.userModel),
        },
        {
          resource: this.roleModel,
          features: [
            importExportFeature({ componentLoader }),
            loggerFeature({ componentLoader }),
          ],
          options: roleOptions(this.roleModel),
        },
        {
          resource: this.adminjsLoggerModel,
          features: [importExportFeature({ componentLoader })],
          options: adminjsLoggerOptions,
        },
        createLoggerResource({
          resource: this.adminjsLoggerModel,
          componentLoader,
          featureOptions: {
            componentLoader,
            userIdAttribute: 'userId',
            propertiesMapping: {
              user: 'userId',
              resource: 'resource',
              action: 'action',
              recordId: 'recordId',
              recordTitle: 'recordTitle',
            },
            resourceOptions: {
              navigation: {
                name: 'SectionName',
                icon: 'iconName',
              },
            },
          } as any,
        }),
      ],

With componentLoader is:

    const componentLoader = new ComponentLoader();
taichi-asari-sti commented 9 months ago

I am facing the same issue as you. Have you resolved this problem? If so, could you please share the solution?

nguyenvanvy1999 commented 9 months ago

I am facing the same issue as you. Have you resolved this problem? If so, could you please share the solution?

Hello. This bug happen because you missing passing component loader when you config adminjs. this is solution:

const componentLoader = new ComponentLoader();
const admin = new AdminJS({
  componentLoader, // Pass it here. Then it will work correctly
  resources: [
    {
      resource: this.roleModel,
      features: [
        loggerFeature({ componentLoader }), // And remember pass it here
      ],
    },
  ],
});

Hope it will help you.