Skip to content

Commit ad5ea22

Browse files
authored
React-admin 3 (#263)
* Update HydraAdmin and AdminGuesser * Use hooks for Guessers and Instrospecter * Remove AdminGuesser * Some cleanup and use AdminGuesser instead of HydraAdmin * Introduce resourceSchemaAnalyzer * Add HydraAdmin back * Fixes
1 parent 66258a1 commit ad5ea22

40 files changed

+2625
-2624
lines changed

.babelrc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
{
22
"plugins": [
3-
"@babel/plugin-proposal-class-properties",
43
"@babel/plugin-proposal-export-default-from"
54
],
65
"presets": [
76
[
8-
"@babel/preset-env",
9-
{
10-
"targets": {
11-
"node": "current"
12-
}
7+
"@babel/preset-env",
8+
{
9+
"targets": {
10+
"node": "current"
11+
}
1312
}
1413
],
1514
"@babel/preset-react"

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = LF
5+
trim_trailing_whitespace = true
6+
insert_final_newline = true
7+
8+
[*.js]
9+
indent_style = space
10+
charset = utf-8
11+
indent_size = 2

.eslintrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323

2424
parser: 'babel-eslint',
2525

26-
plugins: ['import', 'jsx-a11y', 'react', 'prettier'],
26+
plugins: ['markdown', 'import', 'jsx-a11y', 'react', 'prettier'],
2727

2828
extends: ['prettier', 'prettier/react'],
2929

@@ -228,7 +228,6 @@ module.exports = {
228228
{
229229
singleQuote: true,
230230
trailingComma: 'all',
231-
bracketSpacing: false,
232231
jsxBracketSameLine: true,
233232
},
234233
],

.travis.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
language: node_js
22

33
node_js:
4-
- '10'
5-
- '11'
4+
- 'lts/*'
65

7-
cache:
8-
directories:
9-
- node_modules
6+
cache: yarn
107

118
script:
12-
- yarn build
13-
- yarn test
14-
- yarn lint
9+
- yarn build
10+
- yarn test
11+
- yarn lint
1512

1613
deploy:
1714
provider: npm
1815
email: $NPM_AUTH_EMAIL
1916
api_key: $NPM_AUTH_TOKEN
2017
on:
2118
tags: true
22-
node_js: '11'
19+
node_js: 'lts/*'
2320
skip_cleanup: true

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT license
22

3-
Copyright (c) 2017 Kévin Dunglas
3+
Copyright (c) 2020 Kévin Dunglas
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,29 @@ import React from 'react';
2929
import ReactDOM from 'react-dom';
3030
import { HydraAdmin } from '@api-platform/admin';
3131

32-
const Admin = () => <HydraAdmin entrypoint="https://demo.api-platform.com"/> // Replace with your own API entrypoint
32+
const Admin = () => <HydraAdmin entrypoint="https://demo.api-platform.com" />; // Replace with your own API entrypoint
33+
34+
ReactDOM.render(<Admin />, document.getElementById('root'));
35+
```
36+
37+
Or alternatively:
38+
39+
```javascript
40+
import React from 'react';
41+
import ReactDOM from 'react-dom';
42+
import {
43+
AdminGuesser,
44+
hydraDataProvider,
45+
hydraSchemaAnalyzer,
46+
} from '@api-platform/admin';
47+
48+
const Admin = () => (
49+
<AdminGuesser
50+
// Use your custom data provider or resource schema analyzer
51+
dataProvider={hydraDataProvider('https://demo.api-platform.com')}
52+
schemaAnalyzer={hydraSchemaAnalyzer()}
53+
/>
54+
);
3355

3456
ReactDOM.render(<Admin />, document.getElementById('root'));
3557
```

__mocks__/@api-platform/api-doc-parser/lib/hydra/parseHydraDocumentation.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@api-platform/admin",
3-
"version": "1.0.2",
3+
"version": "2.0.0",
44
"description": "Automatic administration interface for Hydra-enabled APIs.",
55
"files": [
66
"*.md",
@@ -17,52 +17,57 @@
1717
"devDependencies": {
1818
"@babel/cli": "^7.2.3",
1919
"@babel/core": "^7.2.2",
20-
"@babel/plugin-proposal-class-properties": "^7.2.3",
2120
"@babel/plugin-proposal-export-default-from": "^7.2.0",
2221
"@babel/preset-env": "^7.2.3",
2322
"@babel/preset-react": "^7.0.0",
24-
"babel-core": "^6.26.3",
2523
"babel-eslint": "^10.0.1",
2624
"babel-jest": "^24.8.0",
2725
"enzyme": "^3.10.0",
2826
"enzyme-adapter-react-16": "^1.14.0",
29-
"eslint": "^6.4.0",
27+
"eslint": "^6.8.0",
3028
"eslint-config-prettier": "^6.3.0",
3129
"eslint-plugin-import": "^2.14.0",
3230
"eslint-plugin-jsx-a11y": "^6.1.2",
31+
"eslint-plugin-markdown": "^1.0.1",
3332
"eslint-plugin-prettier": "^3.0.1",
3433
"eslint-plugin-react": "^7.12.1",
3534
"jest": "^24.8.0",
3635
"jest-enzyme": "^7.1.0",
3736
"prettier": "^1.15.3",
38-
"react": "~16.9.0",
39-
"react-dom": "~16.9.0",
40-
"react-redux": "~5.0.7",
41-
"react-test-renderer": "^16.8.6"
37+
"react": "^16.9.0",
38+
"react-dom": "^16.9.0",
39+
"react-redux": "^7.1.0",
40+
"react-test-renderer": "^16.9.0",
41+
"redux": "^3.7.2 || ^4.0.3"
4242
},
4343
"peerDependencies": {
44-
"react": "~16.0.0 || ~16.1.0 || ~16.2.0 || ~16.3.0 || ~16.4.0",
45-
"react-dom": "~16.0.0 || ~16.1.0 || ~16.2.0 || ~16.3.0 || ~16.4.0"
44+
"react": "^16.9.0",
45+
"react-dom": "^16.9.0"
4646
},
4747
"scripts": {
4848
"build": "babel src -d lib --ignore '*.test.js'",
4949
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check",
50-
"fix": "eslint --fix src",
51-
"lint": "eslint src",
50+
"fix": "eslint --ignore-pattern 'lib/*' --ext .js,.md --fix .",
51+
"lint": "eslint --ignore-pattern 'lib/*' --ext .js,.md .",
5252
"test": "jest src",
5353
"test:watch": "jest --watch src",
5454
"watch": "babel src -d lib --ignore '*.test.js' --watch"
5555
},
5656
"jest": {
5757
"setupFilesAfterEnv": [
5858
"./src/setupTests.js"
59+
],
60+
"testPathIgnorePatterns": [
61+
"/node_modules/",
62+
"/lib/"
5963
]
6064
},
6165
"dependencies": {
6266
"@api-platform/api-doc-parser": "^0.8.1",
67+
"history": "^4.7.2",
6368
"jsonld": "^1.2.1",
6469
"lodash.isplainobject": "^4.0.6",
6570
"prop-types": "^15.6.2",
66-
"react-admin": "^2.9.0"
71+
"react-admin": "^3.0.0"
6772
}
6873
}

0 commit comments

Comments
 (0)