Skip to content

Commit 743ce92

Browse files
Rafał Dzięgielewskigitbook-bot
Rafał Dzięgielewski
authored andcommitted
GITBOOK-96: what's new + small fixes
1 parent 9ba9571 commit 743ce92

35 files changed

+1112
-384
lines changed
Loading
Loading
Loading

SUMMARY.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
* [Mongoose](installation/adapters/mongoose.md)
2525
* [Community Adapters](installation/adapters/community-adapters/README.md)
2626
* [AdonisJS](https://github.com/chirgjin/adminjs-adonis)
27-
* [Troubleshooting](installation/troubleshooting.md)
27+
* [What's new in v7?](installation/whats-new-in-v7.md)
28+
* [Migration Guide v7](installation/migration-guide-v7.md)
2829

2930
## Basics
3031

@@ -46,6 +47,7 @@
4647
* [Edit](basics/api/edit.md)
4748
* [Delete](basics/api/delete.md)
4849
* [Bulk Delete](basics/api/bulk-delete.md)
50+
* [Themes](basics/themes.md)
4951

5052
## UI Customization
5153

basics/api/list.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ description: allows you to list and filer all the records for a given resource
2828

2929
**Example** 
3030

31-
__[_https://demo.adminjs.com_/admin/api/resources/Admin/actions/list?direction=desc\&sortBy=\_id\&filters.email=admin\&page=1](https://demo.adminjs.com/admin/api/resources/Admin/actions/list?direction=desc\&sortBy=\_id\&filters.email=admin\&page=1)
31+
[_https://demo.adminjs.com_/admin/api/resources/Admin/actions/list?direction=desc\&sortBy=\_id\&filters.email=admin\&page=1](https://demo.adminjs.com/admin/api/resources/Admin/actions/list?direction=desc\&sortBy=\_id\&filters.email=admin\&page=1)
3232

3333
```json
3434
{

basics/features/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Features should be included in `features` section of your resource, example:
88

99
<pre class="language-typescript"><code class="lang-typescript"><strong>import { ResourceWithOptions } from 'adminjs';
1010
</strong><strong>
11-
</strong><strong>import User from './user.entity';
11+
</strong><strong>import User from './user.entity.js';
1212
</strong><strong>
1313
</strong><strong>const UserResource: ResourceWithOptions = {
1414
</strong><strong> resource: User,

basics/features/import-and-export.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ Then add one line (`features`) to resource entry in AdminJS config.
1717
```javascript
1818
import importExportFeature from '@adminjs/import-export';
1919

20+
import componentLoader from './component-loader.js';
2021
...
2122

2223
{
2324
resource: Entity,
2425
features: [
25-
importExportFeature(),
26+
importExportFeature({ componentLoader }),
2627
],
2728
}
2829
```

basics/features/leaflet-maps.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The feature goes inside `features` in your resource specification. Take a look a
6868
```typescript
6969
import leafletFeatures, { getLeafletDist } from '@adminjs/leaflet';
7070
// other imports
71-
import Marker from './marker.entity';
71+
import Marker from './marker.entity.js';
7272

7373
// Other code - remember to set up the common configuration!
7474

@@ -144,7 +144,7 @@ The feature goes inside `features` in your resource specification. Take a look a
144144
```typescript
145145
import leafletFeatures, { getLeafletDist } from '@adminjs/leaflet';
146146
// other imports
147-
import MapEntity from './map.entity';
147+
import MapEntity from './map.entity.js';
148148

149149
// Other code - remember to set up the common configuration!
150150

@@ -233,7 +233,10 @@ An example application can be found in [@adminjs/leaflet GitHub repository](http
233233

234234
```bash
235235
$ git clone https://github.com/SoftwareBrothers/adminjs-leaflet.git
236-
$ cd adminjs-leaflet/example-app
236+
$ cd adminjs-leaflet
237+
$ yarn install
238+
$ yarn build
239+
$ cd example-app
237240
$ yarn install
238241
$ docker-compose up -d
239242
$ yarn start

basics/features/logger.md

+22-17
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ Then we have to define `Log` entity - the place we will track changes. Below yo
2222
{% tab title="Sequelize" %}
2323
```typescript
2424
import { DataTypes, Model } from 'sequelize';
25-
import db from './sequelize.connection';
26-
import User from './user.entity';
25+
26+
import db from './sequelize.connection.js';
27+
import User from './user.entity.js';
2728

2829
export interface ILog = {
2930
id: number;
@@ -224,7 +225,7 @@ export const LogModel = model<Log>('Log', LogSchema);
224225

225226
{% tab title="ObjectionJS" %}
226227
```typescript
227-
import { BaseModel } from '../utils/base-model';
228+
import { BaseModel } from '../utils/base-model.js';
228229

229230
class Log extends BaseModel {
230231
id: number;
@@ -286,12 +287,15 @@ To get logger to work, add extra property to resource config. Below you can find
286287

287288
```javascript
288289
import loggerFeature from '@adminjs/logger';
289-
import ResourceModel from './resource.entity';
290+
291+
import ResourceModel from './resource.entity.js';
292+
import componentLoader from './component-loader.js';
290293

291294
export default {
292295
resource: ResourceModel,
293296
features: [
294297
loggerFeature({
298+
componentLoader,
295299
propertiesMapping: {
296300
user: 'userId',
297301
},
@@ -308,22 +312,23 @@ To have Log resource appear in AdminJS panel, we have to define it first.&#x20;
308312

309313
```javascript
310314
import { createLoggerResource } from '@adminjs/logger';
311-
import Log from './logs.entity';
315+
316+
import Log from './logs.entity.js';
312317

313318
const config = {
314-
resource: Log,
315-
featureOptions: {
316-
propertiesMapping: {
317-
recordTitle: 'title' //field to store logged record's title
318-
},
319-
userIdAttribute: 'id', //primary key currently logged user
320-
resourceOptions: {
321-
navigation: {
322-
name: 'SectionName',
323-
icon: 'iconName'
324-
}
325-
}
319+
resource: Log,
320+
featureOptions: {
321+
propertiesMapping: {
322+
recordTitle: 'title' //field to store logged record's title
323+
,
324+
userIdAttribute: 'id', //primary key currently logged user
325+
resourceOptions: {
326+
navigation: {
327+
name: 'SectionName',
328+
icon: 'iconName'
329+
}
326330
}
331+
}
327332
}
328333

329334
export default createLoggerResource(config)

basics/features/password.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ Next step is to add feature option to user resource
1717
```javascript
1818
import argon2 from 'argon2';
1919
import passwordsFeature from '@adminjs/passwords';
20-
import User from './models/user';
20+
21+
import User from './models/user.js';
22+
import componentLoader from './component-loader.js';
2123

2224
const adminJsOptions = {
2325
resources: [
@@ -29,6 +31,7 @@ const adminJsOptions = {
2931
},
3032
features: [
3133
passwordsFeature({
34+
componentLoader,
3235
properties: {
3336
encryptedPassword: 'password',
3437
password: 'newPassword'

basics/features/upload.md

+21-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ There is possibility to use different storage for files:&#x20;
1414

1515
To install the upload feature run:
1616

17-
<pre class="language-shell"><code class="lang-shell"><strong>$ yarn add @adminjs/upload</strong></code></pre>
17+
<pre class="language-shell"><code class="lang-shell"><strong>$ yarn add @adminjs/upload
18+
</strong></code></pre>
1819

1920
The main concept of the upload feature is that it sends uploaded files to an external source. The database keeps the information about path and folder name where the file was stored.
2021

@@ -43,15 +44,21 @@ Next, you should decide, where your files will be stored and prepare resource en
4344
{% tab title="Local Filesystem" %}
4445
In this example your local server should have established `bucket` folder and it should be accessible by web browser (via `baseUrl` path)
4546

46-
```javascript
47+
<pre class="language-javascript"><code class="lang-javascript"><strong>import * as url from 'url'
48+
</strong>// other imports
49+
50+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
51+
4752
app.use(express.static(path.join(__dirname, '../public')));
48-
```
53+
</code></pre>
4954

5055

5156

5257
```typescript
5358
import uploadFeature from '@adminjs/upload';
54-
import { File } from './models/file';
59+
60+
import { File } from './models/file.js';
61+
import componentLoader from './component-loader.js';
5562

5663
const localProvider = {
5764
bucket: 'public/files',
@@ -81,6 +88,7 @@ export const files = {
8188
},
8289
features: [
8390
uploadFeature({
91+
componentLoader,
8492
provider: { local: localProvider },
8593
validation: { mimeTypes: ['image/png', 'application/pdf', 'audio/mpeg'] },
8694
}),
@@ -92,7 +100,8 @@ export const files = {
92100
{% tab title="AWS S3" %}
93101
```typescript
94102
import uploadFeature from '@adminjs/upload';
95-
import { File } from './models/file';
103+
104+
import { File } from './models/file.js';
96105

97106
const AWScredentials = {
98107
accessKeyId: 'AWS_ACCESS_KEY_ID',
@@ -132,7 +141,8 @@ export const files = {
132141

133142
{% tab title="Google Cloud Storage" %}
134143
<pre class="language-typescript"><code class="lang-typescript">import uploadFeature from '@adminjs/upload';
135-
import { File } from './models/file';
144+
145+
import { File } from './models/file.js';
136146

137147
<strong>const GCScredentials = {
138148
</strong> serviceAccount: 'SERVICE_ACCOUNT',
@@ -165,14 +175,15 @@ export const files = {
165175
validation: { mimeTypes: ['image/png'] },
166176
}),
167177
],
168-
};</code></pre>
178+
};
179+
</code></pre>
169180
{% endtab %}
170181
{% endtabs %}
171182

172183
After that add files resource to AdminJS options config
173184

174185
```typescript
175-
import { files } from './resources/files';
186+
import { files } from './resources/files.js';
176187

177188
const adminJsOptions = {
178189
resources: [
@@ -220,7 +231,8 @@ export class File extends BaseEntity {
220231
{% tab title="Resource" %}
221232
```typescript
222233
import uploadFeature from '@adminjs/upload';
223-
import { File } from './models/file';
234+
235+
import { File } from './models/file.js';
224236

225237
const localProvider = {
226238
bucket: 'public/files',

basics/features/writing-your-own-features.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ As you can see, in the example above you have to take care of merging previous o
3131

3232
```javascript
3333
import { buildFeature, FeatureType } from 'adminjs';
34-
import SomeModel from 'some-model.entity';
34+
35+
import SomeModel from 'some-model.entity.js';
3536

3637
const someBeforeHook = () => { /* noop */ };
3738

basics/resource.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ For other adapters the setup would be basically the same, you just have to pass
6161
This option requires you to define all resources explicitly. It is also the recommended approach since it allows you to customize every resource. In order to define resources, you must specify `resources` property when setting up your AdminJS instance. Example:
6262

6363
```typescript
64-
import User from './user.entity'
65-
import Profile from './profile.entity'
64+
import User from './user.entity.js'
65+
import Profile from './profile.entity.js'
6666

6767
// User and Profile are models defined in your ORM/ODM
6868

@@ -264,7 +264,8 @@ Usage example:
264264
```typescript
265265
import passwordsFeature from '@adminjs/passwords'
266266
import argon2 from 'argon2'
267-
import { User } from './user.entity'
267+
268+
import { User } from './user.entity.js'
268269

269270
const UserResource = {
270271
resource: User,

0 commit comments

Comments
 (0)