-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AdminJS v7 - feedback, urgent issues, questions, discussions #1473
Comments
https://www.npmjs.com/package/@adminjs/mongoose the docs are wrong - still showing require statements. import { Database as MongooseDatabase, Resource as MongooseResource } from '@adminjs/mongoose'; Using this, like in the new example app. |
Great work guys! I'm really in favor of moving to ESM-only but I feel like one thing hasn't been thought through. It's cooperation with NestJS which still uses CJS and has no plans to move to ESM. Do you have any solution for that? |
@mszula until Nest.js moves to ESM or starts dual packaging, you will either have to set up AdminJS express/fastify way or use dynamic imports: src/app.module.ts import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [
import('@adminjs/nestjs').then(({ AdminModule }) =>
AdminModule.createAdminAsync({
useFactory: () => ({
adminJsOptions: { rootPath: '/' },
}),
}),
),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {} tsconfig.json {
"compilerOptions": {
// ...
"moduleResolution": "nodenext"
}
} Instead of import { NestFactory, HttpAdapterHost } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const AdminJS = await import('adminjs');
const AdminJSExpress = await import('@adminjs/express');
const expressApp = app.get(HttpAdapterHost).httpAdapter;
const admin = new AdminJS.default({});
expressApp.use(
admin.options.rootPath,
AdminJSExpress.default.buildRouter(admin),
);
await app.listen(3000);
}
bootstrap(); Note that these changes still rely on you not actually updating to ESM, so you will have to As for whether it is possible to still set it up Nest-way - maybe, I don't know. It should be in the interest of NestJS maintainers to proceed with that migration because we cannot impede our own product's development based on their choice of not supporting ESM. Technically ESM projects should be able to import CJS packages, but it doesn't seem to be the case here. |
@ddresch Have you managed to fix your problem? From what I can see you just need to make changes to your
|
Yes – I fixed all my issues now. Thanks for your feedback! |
TypeError: Unknown file extension ".json" |
or use alternatives: https://www.stefanjudis.com/snippets/how-to-import-json-files-in-es-modules-node-js/ |
TypeError: Unknown file extension ".json" Getting this error in adminjs 7 package with nestjs |
Can you show full error log? This could be Nest issue since json imports work fine with every other framework I tried. |
TypeError: Unknown file extension ".json" for E:\application\admin-mode\node_modules\adminjs\lib\locale\de\translation.json Node version: v16.14.0 |
@Aladinndevolpment Looks like type assertions are supported from Node 17+ |
@mickyarun This is the same problem @ddresch had, I think you just have to add:
to your |
@dziraf |
Yes, this is a bug. Thank you for reporting, I passed it up.
The |
After migration to v7, I always get an error "You have to implement action component for your Action" for custom resource action without component. Something was changed with that, or that's just a bug 😄 ?
Edit: I created PR for that 😊 |
@mickyarun you need to add the componentLoader instance to the options object of the upload feature instance. Like stated in the error. |
@ddresch I have added it already, this is happening only if node_env = production My component file
This is my bundle script
|
Hi! // imports
// ...
import encryptPassword from '@adminjs/passwords'
const componentLoader = new ComponentLoader()
const resources = Prisma.dmmf.datamodel.models.map((model) => {
if (model.name === 'User') {
return {
resource: { client, model },
options: {},
features: [
encryptPassword({
properties: {
encryptedPassword: 'password',
password: 'newPassword',
},
hash,
componentLoader,
}),
],
}
}
return {
resource: { client, model },
options: {},
}
})
const admin = new AdminJS({ resources, componentLoader }) |
@dziraf Any help on the above issue, its happening only in production with ADMIN_JS_SKIP_BUNDLE |
@mickyarun If you use @SOULPWRD is an entry file generated in |
I hope this message finds you well. I am writing to inquire about the progress on resolving the issue detailed in #1347 While I understand that this bug may be deemed less significant, and potentially tedious to address, I was hoping that you could kindly provide me with an estimated timeframe for a resolution. As a temporary workaround, we can turn Chrome's autocomplete feature off. However, it would be highly appreciated if an option to address this issue could be implemented as soon as possible. If it is not possible for you to address this issue within a reasonable timeframe, please let me know if you would welcome a Pull Request from me to resolve the issue. Thank you for your time and efforts on this matter. |
Fixed in #1495 |
Login Page stopped to show errors, e.g in case of incorrect credentials. |
[BUG] idk if iam doing something wrong or if its specfic to version 7 or not i am using mongooes adapter i have a field name idAuthor Refrence to "user" collection but when i name it idAuthor it doenst show me dropdown is there a way i can keep idAuthor with dropdown |
No I didn't added, all generated files are in .adminjs folder, still I am not able to solve this issue. @dziraf tried adding assetsCDN with all the files components.bundle.js, app.bundle.js,global.bundle.js,design-system.bundle.js still same. The issue is in @adminjs/bundler only, if don't set ADMIN_JS_SKIP_BUNDLE="true" and copy that bundle file to public folder and add the path in assetsCDN , then run with ADMIN_JS_SKIP_BUNDLE="true" its working. so @adminjs/bundler not bundling default plugins |
Hi I am facing issue with importing @adminjs/nestjs and @adminjs/objection packages I am getting error Cannot find module '@adminjs/objection' or its corresponding type declarations. and yes ive tried to put "moduleResolution": "nodenext", |
Hey @ismoilh , if you have solved this issue kindly help me. I am having the same issue. |
Hi, I wanted to add AdminJs to my expressjs and typescript project using "adminjs": "^7.2.0" with "@adminjs/express": "^6.0.0", "@adminjs/sequelize": "^4.0.0", and getting the error My index.ts import express from 'express';
import AdminJs from 'adminjs';
import AdminJsExpress from '@adminjs/express';
import AdminJsSequelize from '@adminjs/sequelize';
import * as allModels from './models';
const host = process.env.HOST ?? 'localhost';
const port = process.env.PORT ? Number(process.env.PORT) : 3000;
const app = express();
AdminJs.registerAdapter({
Resource: AdminJsSequelize.Resource,
Database: AdminJsSequelize.Database,
});
const localModel = Object.values(allModels);
localModel.pop(); // Remove Sequelize instance
localModel.pop(); // Remove Sequelize instance
const adminOptions =
{
// We pass Category to `resources`
resources: localModel,
}
const admin = new AdminJs(adminOptions)
const adminRouter = AdminJsExpress.buildRouter(admin)
app.use(admin.options.rootPath, adminRouter);
app.get('/', (req, res) => {
res.send({ message: 'Hello API' });
});
app.listen(port, host, () => {
console.log(`[ ready ] http://${host}:${port}`);
}); My tsconfig.base.json {
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2020", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {}
},
"exclude": ["node_modules", "tmp"]
}
Besides that I tried to use AdminJs version 6 but when NPM tries to resolve the version of @adminjs/express and @admin/sequelize it can not resolve the versions of the dependencies in a straigthforward way. Any advice how is the best way to proceed? Thanks in advance |
I had that issue as well first, but setting |
That helped! However I had to modify the imports in this "hacky" way
|
Like @Aladinndevolpment I'm in a catch-22 with the JSON import. Using express with javascript. Using nodejs 17.3 I get this when I try to start app.js (this is the app.js from the getting started documentation)
If I try to go back to an earlier nodejs (e.g. 16.13) it fails on the I'm two pages into the getting started tutorial and completely blocked. Node v17.3 might not work, but Node v18.17 does! |
For those integrating AdminJS with a NestJS monorepo, follow the steps below to configure it properly.
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"moduleResolution": "nodenext",
"module": "nodenext",
"target": "esnext",
"declaration": false,
"outDir": "../../dist/apps/[appName]"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
Set "admin": {
"type": "application",
"root": "apps/admin",
"entryFile": "main",
"sourceRoot": "apps/admin/src",
"compilerOptions": {
"webpack": false,
"tsConfigPath": "apps/admin/tsconfig.app.json"
}
} |
Hi, yes it is.
Sorry for a late reply. I was waiting until the version 7 gets a bit stable. Unfortunately, the problem still persists. |
Hi @dziraf, I'm facing issues with deleting rows with Hapi and TypeORM. Just created a new project and tried again. |
Hey @dziraf do you have in mind when you will be able to fix this issue? |
Hi, guys cc @dziraf, I faced an issue with filter UI on action list resources. export const userResource: ResourceWithOptions = {
resource: UserModel,
options: {
id: 'users',
navigation: {
icon: 'Users',
},
href: ({ h, resource }) => {
return h.resourceActionUrl({
resourceId: resource.decorate().id(),
actionName: 'list',
search: `?filters.role=User`,
});
}, and I faced an issue with the UI. It looks like: The filter drawer section display below the table (broken UI) my versions: "dependencies": {
"@adminjs/bundler": "^3.0.0",
"@adminjs/express": "^6.0.1",
"@adminjs/mongoose": "^4.0.0",
"@adminjs/themes": "^1.0.1",
"mongoose": "^7.4.0",
"adminjs": "^7.4.2",
} |
Same here! MongooseModel.count() is deprecated! Will it be fixed in the next version? |
Hey guys, a minor issue I found while adding filters on page navigation. The following two options act differently.
The first one hides the resource from the navigation, but it is still acccessible via URL, while the second correctly shows the resource in navigation. |
Is there a simple way to use buildAuthenticatedRouter (express) using 'username' instead of 'email' as the required parameter? I noticed it's coded in types.ts but it's difficult to replace 'authenticate' (AuthenticationOptions) in practice (app.ts). The reason is that in my application a person can reuse its email address (e.g. as staff with multiple roles, as a tenant with multiple shops, or a customer doing business with different tenants) but is always constrained to a distinct username in each instance. So far AdminJS is great, thanks! |
This is a thread to aggregate all questions/feedback/urgent bugs/discussions related to the recently released version 7.
Feel free to share your ideas or let us know about any issues you're facing related to migration or usage.
What's new in version 7
describes the largest changes in version 7.
Migration Guide will help you migrate your project to version 7.
Demo Application
Demo application also includes our new
Themes
feature. If you would like to see themes in action, use one of these credentials to sign in:[email protected] / password
- a dark theme[email protected] / password
- a theme which uses custom components to remove the sidebar and instead move resources to the top bar[email protected] / password
- an example of a custom theme which you can build yourself in your own project (source code)If you notice that parts of our documentation are outdated or unclear, please share that in this thread as well.
The text was updated successfully, but these errors were encountered: