Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1022 from marmelab/next
Browse files Browse the repository at this point in the history
[RFR] Release 1.3.0
  • Loading branch information
fzaninotto authored Sep 13, 2017
2 parents a56dfaf + 1722863 commit 49a616c
Show file tree
Hide file tree
Showing 247 changed files with 8,198 additions and 3,599 deletions.
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
lib
example/static
docs/_site/
docs/js/
docs/css/

81 changes: 72 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,82 @@
{
"env": {
"es6": true,
"browser": true,
"mocha": true,
"node": true,
"phantomjs": true,
"protractor": true,
"protractor": true
},
"extends": "airbnb",
"plugins": [
"prettier",
"react"
],
"extends": [
"eslint:recommended",
"prettier",
"prettier/react",
"plugin:react/recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"modules": true
}
},
"rules": {
"indent": ["warn", 4],
"max-len": ["off"],
"react/forbid-prop-types": ["warn", { "forbid": ["any", "array"] }],
"react/jsx-indent": ["warn", 4],
"react/jsx-indent-props": ["warn", 4],
"react/jsx-filename-extension": ["off"]
"prettier/prettier": [
"error",
{
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "es5"
}
],
"react/forbid-prop-types": [
"off"
],
"react/prop-types": [
"warn"
],
"react/jsx-no-bind": [
"warn"
],
"react/jsx-indent": [
"off"
],
"react/jsx-indent-props": [
"off"
],
"react/jsx-filename-extension": [
"off"
],
"import/no-named-as-default": [
"off"
],
"no-unused-vars": [
"error",
{
"ignoreRestSiblings": true
}
]
},
}
"overrides": [
{
"files": [
"**/*.spec.js"
],
"rules": {
"react/jsx-no-bind": [
"off"
],
"react/prop-types": [
"off"
]
}
}
]
}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## v.1.3.0

* Add permissions handling ([djhi](https://github.com/djhi))
* Add Not Found page ([fzaninotto](https://github.com/fzaninotto))
* Add support for layoutless custom routes ([marcw](https://github.com/marcw))
* Add support for custom validator messages ([fzaninotto](https://github.com/fzaninotto))
* Add support for nested filter object ([mtakayuki](https://github.com/mtakayuki))
* Add response body to HttpError ([marcw](https://github.com/marcw))
* Add ability to refresh views using a redux action ([djhi](https://github.com/djhi))
* Add `previousData` to `crudDelete` payload ([grahamlyus](https://github.com/grahamlyus))
* Add greek translation ([zifnab87](https://github.com/zifnab87))
* Add Ukrainian translation ([vitivs](https://github.com/vitivs))
* Upgrade dependencies (MUI 0.19, react in peer dependencies) ([djhi](https://github.com/djhi))
* Update the redux state structure to avoid name conflicts ([lutangar](https://github.com/lutangar))
* Update code formatting standard (prettier) ([fzaninotto](https://github.com/fzaninotto))
* Fix query string builder in REST clients ([mtakayuki](https://github.com/mtakayuki))
* Fix webpack file present in root directory ([fzaninotto](https://github.com/fzaninotto))
* Fix forms default values handling ([djhi](https://github.com/djhi))
* Fix `<SelectInput>` with `allowEmpty` throws key-warning ([fab1an](https://github.com/fab1an))
* Fix `onMenuTap` warning on medium and larger devices ([jf248](https://github.com/jf248))
* Fix links in documentation ([Phocea](https://github.com/Phocea))

## v1.2.3

* Add Epilogue REST client ([dunghuynh](https://github.com/dunghuynh))
Expand Down
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ At any given time, `next` represents the latest development version of the libra

### Coding style

Please follow the coding style of the current code base. Admin-on-rest uses eslint, so if possible, enable linting in your editor to get realtime feedback.
You must follow the coding style of the existing files. Admin-on-rest uses eslint and [prettier](https://github.com/prettier/prettier). You can reformat all the project files automatically by calling

```sh
make prettier
```

**Tip**: If possible, enable linting in your editor to get realtime feedback and/or fixes.

## License

Expand Down
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install: package.json ## install dependencies
@npm install

run: example_install ## run the example
@cd example && ../node_modules/.bin/webpack-dev-server --hot --inline --config ./webpack.config.js
@cd example && ./node_modules/.bin/webpack-dev-server --hot --inline --config ./webpack.config.js

example_install: example/package.json
@cd example && npm install
Expand All @@ -21,9 +21,17 @@ watch: ## continuously compile ES6 files to JS
doc: ## compile doc as html and launch doc web server
@cd docs && jekyll server . --watch

test: test-unit test-e2e ## launch all tests
lint: ## lint the code and check coding conventions
@echo "Running linter..."
@./node_modules/.bin/eslint .

prettier: ## prettify the source code using prettier
@./node_modules/.bin/prettier-eslint --write --list-different "src/**/*.js" "example/**/*.js"

test: test-unit lint test-e2e ## launch all tests

test-unit: ## launch unit tests
@echo "Running unit tests..."
@NODE_ENV=test NODE_ICU_DATA=node_modules/full-icu ./node_modules/.bin/mocha \
--require ignore-styles \
--compilers js:babel-register \
Expand All @@ -39,7 +47,7 @@ test-unit-watch: ## launch unit tests and watch for changes
test-e2e: ## launch end-to-end tests
@if [ "$(build)" != "false" ]; then \
echo 'Building example code (call "make build=false test-e2e" to skip the build)...'; \
cd example && ../node_modules/.bin/webpack; \
cd example && ./node_modules/.bin/webpack; \
fi
@echo 'Launching e2e tests...'
@NODE_ENV=test node_modules/.bin/mocha \
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,30 @@ The credentials are **login/password**

## Contributing

Pull requests are welcome. Try to follow the coding style of the existing files, and include unit tests and documentation. Be prepared for a thorough code review, and be patient for the merge - this is an open-source initiative.
Pull requests are welcome. You must follow the coding style of the existing files (based on [prettier](https://github.com/prettier/prettier)), and include unit tests and documentation. Be prepared for a thorough code review, and be patient for the merge - this is an open-source initiative.

If you want to contribute to the documentation, install jekyll, then call
You can run the tests (linting, unit and functional tests) by calling

```sh
make doc
make test
```

And then browse to [http://localhost:4000/](http://localhost:4000/)
If you have coding standards problems, you can fix them automatically using `prettier` by calling

*Note*: if you have added a section with heading to the docs, you also have to add it to `docs/_layouts/default.html` (the links on the left) manually.
```sh
make prettier
```

You can run the unit tests by calling
If you want to contribute to the documentation, install jekyll, then call

```sh
make test
make doc
```

And then browse to [http://localhost:4000/](http://localhost:4000/)

*Note*: if you have added a section with heading to the docs, you also have to add it to `docs/_layouts/default.html` (the links on the left) manually.

If you are using admin-on-rest as a dependency, and if you want to try and hack it, here is the advised process:

```sh
Expand Down
46 changes: 43 additions & 3 deletions docs/Admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Here are all the props accepted by the component:
* [`restClient`](#restclient)
* [`title`](#title)
* [`dashboard`](#dashboard)
* [`catchAll](#catchall)
* [`menu`](#menu)
* [`theme`](#theme)
* [`appLayout`](#applayout)
Expand Down Expand Up @@ -81,7 +82,6 @@ const App = () => (

By default, the homepage of an an admin app is the `list` of the first child `<Resource>`. But you can also specify a custom component instead. To fit in the general design, use Material UI's `<Card>` component, and admin-on-rest's `<ViewTitle>` component:

{% raw %}
```jsx
// in src/Dashboard.js
import React from 'react';
Expand All @@ -95,7 +95,6 @@ export default () => (
</Card>
);
```
{% endraw %}

```jsx
// in src/App.js
Expand All @@ -110,6 +109,43 @@ const App = () => (

![Custom home page](http://static.marmelab.com/admin-on-rest/dashboard.png)

## `catchAll`

When users type URLs that don't match any of the children `<Resource>` components, they see a default "Not Found" page.

![Not Found](./img/not-found.png)

You can customize this page to use the component of your choice by passing it as the `catchAll` prop. To fit in the general design, use Material UI's `<Card>` component, and admin-on-rest's `<ViewTitle>` component:

```jsx
// in src/NotFound.js
import React from 'react';
import { Card, CardText } from 'material-ui/Card';
import { ViewTitle } from 'admin-on-rest/lib/mui';

export default () => (
<Card>
<ViewTitle title="Not Found" />
<CardText>
<h1>404: Page not found</h1>
</CardText>
</Card>
);
```

```jsx
// in src/App.js
import NotFound from './NotFound';

const App = () => (
<Admin catchAll={NotFound} restClient={simpleRestClient('http://path.to.my.api')}>
// ...
</Admin>
);
```

**Tip**: If your custom `catchAll` component contains react-router `<Route>` components, this allows you to register new routes displayed within the admin-on-rest layout easily. Note that these routes will match *after* all the admin-on-rest resource routes have been tested. To add custom routes *before* the admin-on-rest ones, and therefore override the default resource routes, use the [`customRoutes` prop](#customroutes) instead.

## `menu`

Admin-on-rest uses the list of `<Resource>` components passed as children of `<Admin>` to build a menu to each resource with a `list` component.
Expand Down Expand Up @@ -285,10 +321,12 @@ import React from 'react';
import { Route } from 'react-router-dom';
import Foo from './Foo';
import Bar from './Bar';
import Baz from './Baz';

export default [
<Route exact path="/foo" component={Foo} />,
<Route exact path="/bar" component={Bar} />,
<Route exact path="/baz" component={Baz} noLayout />,
];
```

Expand All @@ -311,10 +349,12 @@ export default App;
```

Now, when a user browses to `/foo` or `/bar`, the components you defined will appear in the main part of the screen.
When a user browses to `/baz`, the component will appear outside of the defined Layout, leaving you the freedom
to design the screen the way you want.

**Tip**: It's up to you to create a [custom menu](#applayout) entry, or custom buttons, to lead to your custom pages.

**Tip**: Your custom pages take precedence over admin-on-rest's own routes. That means that `customRoutes` lets you override any route you want!
**Tip**: Your custom pages take precedence over admin-on-rest's own routes. That means that `customRoutes` lets you override any route you want! If you want to add routes *after* all the admin-on-rest routes, use the [`catchAll` prop](#catchall) instead.

**Tip**: To look like other admin-on-rest pages, your custom pages should have the following structure:

Expand Down
2 changes: 1 addition & 1 deletion docs/Authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,4 @@ export default withRouter(MyPage);
```
{% endraw %}

The `<Restricted>` component calls the `authClient` function with `AUTH_CHECK` and `authParams`. If the response is a fulfilled promise, the child component is rendered. If the response is a rejected promise, `<Restricted>` redirects to the login form. Upon successful login, the user is redirected to the initial location (that's why it's necessary to get the location from the router).
The `<Restricted>` component calls the `authClient` function with `AUTH_CHECK` and `authParams`. If the response is a fulfilled promise, the child component is rendered. If the response is a rejected promise, `<Restricted>` redirects to the login form. Upon successful login, the user is redirected to the initial location (that's why it's necessary to get the location from the router).
Loading

0 comments on commit 49a616c

Please sign in to comment.