@panneau/app 1.0.1-alpha.0 → 1.0.3-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/styles.css +7 -0
- package/es/index.js +1812 -5
- package/lib/index.js +1842 -15
- package/package.json +66 -54
- package/scss/styles.scss +3 -0
- package/es/Panneau.js +0 -318
- package/es/actions/AuthActions.js +0 -16
- package/es/actions/LayoutActions.js +0 -14
- package/es/components/App.js +0 -129
- package/es/components/Layout.js +0 -68
- package/es/components/Panneau.js +0 -79
- package/es/components/index.js +0 -3
- package/es/components/pages/Account.js +0 -38
- package/es/components/pages/Home.js +0 -12
- package/es/components/pages/ResourceCreate.js +0 -44
- package/es/components/pages/ResourceDelete.js +0 -11
- package/es/components/pages/ResourceEdit.js +0 -28
- package/es/components/pages/ResourceForm.js +0 -343
- package/es/components/pages/ResourceIndex.js +0 -261
- package/es/components/pages/ResourceShow.js +0 -15
- package/es/components/partials/ResourceFormHeader.js +0 -111
- package/es/components/partials/ResourceIndexHeader.js +0 -71
- package/es/defaults/routes.json +0 -10
- package/es/lib/createStore.js +0 -30
- package/es/reducers/AuthReducer.js +0 -32
- package/es/reducers/index.js +0 -4
- package/lib/Panneau.js +0 -340
- package/lib/actions/AuthActions.js +0 -25
- package/lib/actions/LayoutActions.js +0 -25
- package/lib/components/App.js +0 -159
- package/lib/components/Layout.js +0 -87
- package/lib/components/Panneau.js +0 -103
- package/lib/components/index.js +0 -23
- package/lib/components/pages/Account.js +0 -54
- package/lib/components/pages/Home.js +0 -23
- package/lib/components/pages/ResourceCreate.js +0 -65
- package/lib/components/pages/ResourceDelete.js +0 -22
- package/lib/components/pages/ResourceEdit.js +0 -44
- package/lib/components/pages/ResourceForm.js +0 -376
- package/lib/components/pages/ResourceIndex.js +0 -289
- package/lib/components/pages/ResourceShow.js +0 -28
- package/lib/components/partials/ResourceFormHeader.js +0 -137
- package/lib/components/partials/ResourceIndexHeader.js +0 -87
- package/lib/defaults/routes.json +0 -10
- package/lib/lib/createStore.js +0 -46
- package/lib/reducers/AuthReducer.js +0 -43
- package/lib/reducers/index.js +0 -15
- package/src/Panneau.js +0 -274
- package/src/actions/AuthActions.js +0 -17
- package/src/actions/LayoutActions.js +0 -12
- package/src/components/App.jsx +0 -121
- package/src/components/Layout.jsx +0 -51
- package/src/components/Panneau.jsx +0 -95
- package/src/components/index.js +0 -7
- package/src/components/pages/Account.jsx +0 -34
- package/src/components/pages/Home.jsx +0 -19
- package/src/components/pages/ResourceCreate.jsx +0 -50
- package/src/components/pages/ResourceDelete.jsx +0 -18
- package/src/components/pages/ResourceEdit.jsx +0 -39
- package/src/components/pages/ResourceForm.jsx +0 -361
- package/src/components/pages/ResourceIndex.jsx +0 -256
- package/src/components/pages/ResourceShow.jsx +0 -23
- package/src/components/partials/ResourceFormHeader.jsx +0 -137
- package/src/components/partials/ResourceIndexHeader.jsx +0 -84
- package/src/defaults/routes.json +0 -10
- package/src/index.js +0 -9
- package/src/lib/createStore.js +0 -21
- package/src/reducers/AuthReducer.js +0 -23
- package/src/reducers/index.js +0 -5
- package/src/styles/layout.scss +0 -5
- package/src/styles/pages/resource-form.scss +0 -42
- package/src/styles/pages/resource-index.scss +0 -43
- package/src/styles/partials/resource-form-header.scss +0 -7
- package/src/styles/partials/resource-index-header.scss +0 -13
- package/src/styles/vendor.global.scss +0 -5
package/src/components/App.jsx
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
import React, { useCallback } from 'react';
|
2
|
-
// import PropTypes from 'prop-types';
|
3
|
-
import { Route, Switch, Redirect, withRouter } from 'react-router';
|
4
|
-
import { connect } from 'react-redux';
|
5
|
-
import queryString from 'query-string';
|
6
|
-
import { PropTypes as PanneauPropTypes } from '@panneau/core';
|
7
|
-
import { useUrlGenerator, useDefinition } from '@panneau/core/contexts';
|
8
|
-
import 'bootstrap';
|
9
|
-
|
10
|
-
import Layout from './Layout';
|
11
|
-
import Home from './pages/Home';
|
12
|
-
import Account from './pages/Account';
|
13
|
-
import ResourceIndex from './pages/ResourceIndex';
|
14
|
-
import ResourceCreate from './pages/ResourceCreate';
|
15
|
-
import ResourceShow from './pages/ResourceShow';
|
16
|
-
import ResourceEdit from './pages/ResourceEdit';
|
17
|
-
import ResourceDelete from './pages/ResourceDelete';
|
18
|
-
|
19
|
-
const ResourcePages = {
|
20
|
-
index: ResourceIndex,
|
21
|
-
create: ResourceCreate,
|
22
|
-
show: ResourceShow,
|
23
|
-
edit: ResourceEdit,
|
24
|
-
delete: ResourceDelete,
|
25
|
-
};
|
26
|
-
|
27
|
-
const propTypes = {
|
28
|
-
history: PanneauPropTypes.history.isRequired,
|
29
|
-
user: PanneauPropTypes.user,
|
30
|
-
};
|
31
|
-
|
32
|
-
const defaultProps = { user: null };
|
33
|
-
|
34
|
-
const App = ({ history, user }) => {
|
35
|
-
const urlGenerator = useUrlGenerator();
|
36
|
-
const definition = useDefinition();
|
37
|
-
const resources = definition.resources();
|
38
|
-
|
39
|
-
const getResourceActionUrl = useCallback(
|
40
|
-
(resource, action, id) => urlGenerator.resource(resource, action, id),
|
41
|
-
[urlGenerator],
|
42
|
-
);
|
43
|
-
|
44
|
-
const gotoResourceAction = (...args) => history.push(getResourceActionUrl(...args));
|
45
|
-
|
46
|
-
const renderResourceRoutes = (resource = null) => {
|
47
|
-
const id = resource !== null ? resource.id() : 'default';
|
48
|
-
return Object.keys(ResourcePages).map(action => (
|
49
|
-
<Route
|
50
|
-
key={`resource-${id}-${action}`}
|
51
|
-
exact
|
52
|
-
path={urlGenerator.resource(resource, action)}
|
53
|
-
render={({
|
54
|
-
match: {
|
55
|
-
params: { resource: resourceId = null, id: itemId = null },
|
56
|
-
},
|
57
|
-
location: { search },
|
58
|
-
}) => {
|
59
|
-
const query = queryString.parse(search);
|
60
|
-
const matchedResource =
|
61
|
-
resource ||
|
62
|
-
resources.find(it => resourceId !== null && it.id() === resourceId) ||
|
63
|
-
null;
|
64
|
-
|
65
|
-
const PageComponent = ResourcePages[action];
|
66
|
-
return (
|
67
|
-
<PageComponent
|
68
|
-
action={action}
|
69
|
-
query={query}
|
70
|
-
itemId={itemId}
|
71
|
-
resource={matchedResource}
|
72
|
-
getResourceActionUrl={(...args) =>
|
73
|
-
getResourceActionUrl(matchedResource, ...args)
|
74
|
-
}
|
75
|
-
gotoResourceAction={(...args) =>
|
76
|
-
gotoResourceAction(matchedResource, ...args)
|
77
|
-
}
|
78
|
-
/>
|
79
|
-
);
|
80
|
-
}}
|
81
|
-
/>
|
82
|
-
));
|
83
|
-
};
|
84
|
-
|
85
|
-
return (
|
86
|
-
<Layout>
|
87
|
-
<Switch>
|
88
|
-
{user !== null ? (
|
89
|
-
<Route
|
90
|
-
exact
|
91
|
-
path={urlGenerator.route('account')}
|
92
|
-
render={() => <Account resource={definition.resource('users')} />}
|
93
|
-
/>
|
94
|
-
) : (
|
95
|
-
<Route
|
96
|
-
exact
|
97
|
-
path={urlGenerator.route('account')}
|
98
|
-
render={() => <Redirect to={urlGenerator.route('home')} />}
|
99
|
-
/>
|
100
|
-
)}
|
101
|
-
{resources
|
102
|
-
.filter(resource => resource.hasRoutes())
|
103
|
-
.reduce(
|
104
|
-
(routes, resource) => [...routes, ...renderResourceRoutes(resource)],
|
105
|
-
[],
|
106
|
-
)}
|
107
|
-
{renderResourceRoutes()}
|
108
|
-
<Route exact path={urlGenerator.route('home')} component={Home} />
|
109
|
-
</Switch>
|
110
|
-
</Layout>
|
111
|
-
);
|
112
|
-
};
|
113
|
-
|
114
|
-
App.propTypes = propTypes;
|
115
|
-
App.defaultProps = defaultProps;
|
116
|
-
|
117
|
-
const WithStateContainer = connect(({ auth }) => ({
|
118
|
-
user: auth.user || null,
|
119
|
-
}))(App);
|
120
|
-
const WithRouter = withRouter(WithStateContainer);
|
121
|
-
export default WithRouter;
|
@@ -1,51 +0,0 @@
|
|
1
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
2
|
-
import React, { useCallback } from 'react';
|
3
|
-
import PropTypes from 'prop-types';
|
4
|
-
import { connect } from 'react-redux';
|
5
|
-
import { withRouter } from 'react-router';
|
6
|
-
import { PropTypes as PanneauPropTypes } from '@panneau/core';
|
7
|
-
import { useDefinition, useComponents, useUrlGenerator } from '@panneau/core/contexts';
|
8
|
-
|
9
|
-
import { updateLayout as updateLayoutAction } from '../actions/LayoutActions';
|
10
|
-
|
11
|
-
const propTypes = {
|
12
|
-
history: PanneauPropTypes.history.isRequired,
|
13
|
-
updateLayout: PropTypes.func.isRequired,
|
14
|
-
};
|
15
|
-
|
16
|
-
const defaultProps = {};
|
17
|
-
|
18
|
-
const Layout = ({ updateLayout, history, ...props }) => {
|
19
|
-
const urlGenerator = useUrlGenerator();
|
20
|
-
const definition = useDefinition();
|
21
|
-
const layoutsCollection = useComponents('layouts');
|
22
|
-
const gotoHome = useCallback(() => history(urlGenerator.route('home')), [urlGenerator]);
|
23
|
-
const gotoLink = useCallback(path => history(path), []);
|
24
|
-
const gotoRoute = useCallback(name => history(urlGenerator.route(name)), [urlGenerator]);
|
25
|
-
const { type: componentName = 'normal', ...layoutProps } = definition.layout();
|
26
|
-
const LayoutComponent = layoutsCollection.getComponent(componentName);
|
27
|
-
return LayoutComponent !== null ? (
|
28
|
-
<LayoutComponent
|
29
|
-
gotoHome={gotoHome}
|
30
|
-
gotoLink={gotoLink}
|
31
|
-
gotoRoute={gotoRoute}
|
32
|
-
updateLayout={updateLayout}
|
33
|
-
{...layoutProps}
|
34
|
-
{...props}
|
35
|
-
/>
|
36
|
-
) : null;
|
37
|
-
};
|
38
|
-
|
39
|
-
Layout.propTypes = propTypes;
|
40
|
-
Layout.defaultProps = defaultProps;
|
41
|
-
|
42
|
-
const WithStateContainer = connect(
|
43
|
-
({ layout }) => ({
|
44
|
-
...layout,
|
45
|
-
}),
|
46
|
-
dispatch => ({
|
47
|
-
updateLayout: layout => dispatch(updateLayoutAction(layout)),
|
48
|
-
}),
|
49
|
-
)(Layout);
|
50
|
-
const WithRouterContainer = withRouter(WithStateContainer);
|
51
|
-
export default WithRouterContainer;
|
@@ -1,95 +0,0 @@
|
|
1
|
-
import React, { useMemo } from 'react';
|
2
|
-
import PropTypes from 'prop-types';
|
3
|
-
import { IntlProvider } from 'react-intl';
|
4
|
-
import { Router } from 'react-router';
|
5
|
-
import { createBrowserHistory, createMemoryHistory } from 'history';
|
6
|
-
import { PropTypes as PanneauPropTypes, Definition } from '@panneau/core';
|
7
|
-
import {
|
8
|
-
DefinitionProvider,
|
9
|
-
UrlGeneratorProvider,
|
10
|
-
ComponentsProvider,
|
11
|
-
} from '@panneau/core/contexts';
|
12
|
-
import { Provider as ReduxProvider } from 'react-redux';
|
13
|
-
|
14
|
-
import defaultRoutes from '../defaults/routes.json';
|
15
|
-
import reducers from '../reducers/index';
|
16
|
-
import createStore from '../lib/createStore';
|
17
|
-
|
18
|
-
import '../styles/vendor.global.scss';
|
19
|
-
|
20
|
-
import App from './App';
|
21
|
-
|
22
|
-
window.parent.React2 = React;
|
23
|
-
|
24
|
-
const propTypes = {
|
25
|
-
locale: PropTypes.string,
|
26
|
-
messages: PropTypes.objectOf(PropTypes.objectOf(PropTypes.string)),
|
27
|
-
routes: PropTypes.objectOf(PropTypes.string),
|
28
|
-
memoryRouter: PropTypes.bool,
|
29
|
-
definition: PanneauPropTypes.definitions.definition.isRequired,
|
30
|
-
componentsCollection: PanneauPropTypes.componentsCollection.isRequired,
|
31
|
-
user: PanneauPropTypes.user,
|
32
|
-
};
|
33
|
-
|
34
|
-
const defaultProps = {
|
35
|
-
locale: 'en',
|
36
|
-
messages: {},
|
37
|
-
routes: defaultRoutes,
|
38
|
-
memoryRouter: false,
|
39
|
-
user: null,
|
40
|
-
};
|
41
|
-
|
42
|
-
const Panneau = ({
|
43
|
-
locale,
|
44
|
-
messages,
|
45
|
-
memoryRouter,
|
46
|
-
routes,
|
47
|
-
definition: definitionData,
|
48
|
-
componentsCollection,
|
49
|
-
user,
|
50
|
-
}) => {
|
51
|
-
const store = useMemo(
|
52
|
-
() =>
|
53
|
-
createStore(reducers, {
|
54
|
-
auth: {
|
55
|
-
user,
|
56
|
-
},
|
57
|
-
}),
|
58
|
-
[],
|
59
|
-
);
|
60
|
-
|
61
|
-
const history = useMemo(() => (memoryRouter ? createMemoryHistory() : createBrowserHistory()), [
|
62
|
-
memoryRouter,
|
63
|
-
]);
|
64
|
-
|
65
|
-
const definition = useMemo(() => new Definition(definitionData), [definitionData]);
|
66
|
-
|
67
|
-
const allRoutes = useMemo(
|
68
|
-
() => ({
|
69
|
-
...routes,
|
70
|
-
...definition.allRoutes(),
|
71
|
-
}),
|
72
|
-
[routes, definition],
|
73
|
-
);
|
74
|
-
|
75
|
-
return (
|
76
|
-
<ReduxProvider store={store}>
|
77
|
-
<IntlProvider locale={locale} messages={messages}>
|
78
|
-
<Router history={history}>
|
79
|
-
<DefinitionProvider definition={definition}>
|
80
|
-
<UrlGeneratorProvider routes={allRoutes}>
|
81
|
-
<ComponentsProvider collection={componentsCollection}>
|
82
|
-
<App />
|
83
|
-
</ComponentsProvider>
|
84
|
-
</UrlGeneratorProvider>
|
85
|
-
</DefinitionProvider>
|
86
|
-
</Router>
|
87
|
-
</IntlProvider>
|
88
|
-
</ReduxProvider>
|
89
|
-
);
|
90
|
-
};
|
91
|
-
|
92
|
-
Panneau.propTypes = propTypes;
|
93
|
-
Panneau.defaultProps = defaultProps;
|
94
|
-
|
95
|
-
export default Panneau;
|
package/src/components/index.js
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
// import PropTypes from 'prop-types';
|
3
|
-
import { connect } from 'react-redux';
|
4
|
-
import { defineMessages } from 'react-intl';
|
5
|
-
import { PropTypes as PanneauPropTypes } from '@panneau/core';
|
6
|
-
|
7
|
-
import ResourceForm from './ResourceForm';
|
8
|
-
|
9
|
-
const messages = defineMessages({
|
10
|
-
title: {
|
11
|
-
id: 'core.titles.account',
|
12
|
-
description: 'The title of the account page',
|
13
|
-
defaultMessage: 'Edit account',
|
14
|
-
},
|
15
|
-
});
|
16
|
-
|
17
|
-
const propTypes = {
|
18
|
-
user: PanneauPropTypes.user.isRequired,
|
19
|
-
resource: PanneauPropTypes.resource.isRequired,
|
20
|
-
};
|
21
|
-
|
22
|
-
const defaultProps = {};
|
23
|
-
|
24
|
-
const AccountPage = ({ user, resource }) => (
|
25
|
-
<ResourceForm itemId={user.id} action="edit" title={messages.title} resource={resource} />
|
26
|
-
);
|
27
|
-
|
28
|
-
AccountPage.propTypes = propTypes;
|
29
|
-
AccountPage.defaultProps = defaultProps;
|
30
|
-
|
31
|
-
const WithStateContainer = connect(({ auth }) => ({
|
32
|
-
user: auth.user || null,
|
33
|
-
}))(AccountPage);
|
34
|
-
export default WithStateContainer;
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
// import PropTypes from 'prop-types';
|
3
|
-
|
4
|
-
const propTypes = {
|
5
|
-
|
6
|
-
};
|
7
|
-
|
8
|
-
const defaultProps = {
|
9
|
-
|
10
|
-
};
|
11
|
-
|
12
|
-
const HomePage = () => (
|
13
|
-
<div />
|
14
|
-
);
|
15
|
-
|
16
|
-
HomePage.propTypes = propTypes;
|
17
|
-
HomePage.defaultProps = defaultProps;
|
18
|
-
|
19
|
-
export default HomePage;
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import React, { useCallback } from 'react';
|
2
|
-
import PropTypes from 'prop-types';
|
3
|
-
import { defineMessages } from 'react-intl';
|
4
|
-
|
5
|
-
import ResourceForm from './ResourceForm';
|
6
|
-
|
7
|
-
export const messages = defineMessages({
|
8
|
-
create: {
|
9
|
-
id: 'core.buttons.resources.create',
|
10
|
-
description: 'The label of the "create" form button',
|
11
|
-
defaultMessage: 'Create',
|
12
|
-
},
|
13
|
-
title: {
|
14
|
-
id: 'core.titles.resources.create',
|
15
|
-
description: 'The title of the resource create form',
|
16
|
-
defaultMessage: 'Create {name}',
|
17
|
-
},
|
18
|
-
titleTyped: {
|
19
|
-
id: 'core.titles.resources.create_typed',
|
20
|
-
description: 'The title of the typed resource create form',
|
21
|
-
defaultMessage: 'Create {name} <small class="text-muted">({type})</small>',
|
22
|
-
},
|
23
|
-
});
|
24
|
-
|
25
|
-
const propTypes = {
|
26
|
-
gotoResourceAction: PropTypes.func.isRequired,
|
27
|
-
};
|
28
|
-
|
29
|
-
const defaultProps = {};
|
30
|
-
|
31
|
-
const ResourceCreate = ({ gotoResourceAction, ...props }) => {
|
32
|
-
const onFormComplete = useCallback(it => gotoResourceAction('edit', it.id), [
|
33
|
-
gotoResourceAction,
|
34
|
-
]);
|
35
|
-
return (
|
36
|
-
<ResourceForm
|
37
|
-
title={messages.title}
|
38
|
-
titleTyped={messages.titleTyped}
|
39
|
-
saveButtonLabel={messages.create}
|
40
|
-
onFormComplete={onFormComplete}
|
41
|
-
gotoResourceAction={gotoResourceAction}
|
42
|
-
{...props}
|
43
|
-
/>
|
44
|
-
);
|
45
|
-
};
|
46
|
-
|
47
|
-
ResourceCreate.propTypes = propTypes;
|
48
|
-
ResourceCreate.defaultProps = defaultProps;
|
49
|
-
|
50
|
-
export default ResourceCreate;
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
|
3
|
-
const propTypes = {
|
4
|
-
|
5
|
-
};
|
6
|
-
|
7
|
-
const defaultProps = {
|
8
|
-
|
9
|
-
};
|
10
|
-
|
11
|
-
const HomePage = () => (
|
12
|
-
<div>Delete resource</div>
|
13
|
-
);
|
14
|
-
|
15
|
-
HomePage.propTypes = propTypes;
|
16
|
-
HomePage.defaultProps = defaultProps;
|
17
|
-
|
18
|
-
export default HomePage;
|
@@ -1,39 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { defineMessages } from 'react-intl';
|
3
|
-
|
4
|
-
import ResourceForm from './ResourceForm';
|
5
|
-
|
6
|
-
const messages = defineMessages({
|
7
|
-
title: {
|
8
|
-
id: 'core.titles.resources.edit',
|
9
|
-
description: 'The title of the resource edit form',
|
10
|
-
defaultMessage: 'Edit {name}',
|
11
|
-
},
|
12
|
-
titleTyped: {
|
13
|
-
id: 'core.titles.resources.edit_typed',
|
14
|
-
description: 'The title of the typed resource edit form',
|
15
|
-
defaultMessage: 'Edit {name} <small class="text-muted">({type})</small>',
|
16
|
-
},
|
17
|
-
});
|
18
|
-
|
19
|
-
const propTypes = {
|
20
|
-
|
21
|
-
};
|
22
|
-
|
23
|
-
const defaultProps = {
|
24
|
-
|
25
|
-
};
|
26
|
-
|
27
|
-
const ResourceEdit = props => (
|
28
|
-
<ResourceForm
|
29
|
-
title={messages.title}
|
30
|
-
titleTyped={messages.titleTyped}
|
31
|
-
action="edit"
|
32
|
-
{...props}
|
33
|
-
/>
|
34
|
-
);
|
35
|
-
|
36
|
-
ResourceEdit.propTypes = propTypes;
|
37
|
-
ResourceEdit.defaultProps = defaultProps;
|
38
|
-
|
39
|
-
export default ResourceEdit;
|