@panneau/app 1.0.1-alpha.0 → 1.0.3-alpha.2
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 +1810 -5
- package/lib/index.js +1841 -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
@@ -1,261 +0,0 @@
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
5
|
-
|
6
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
7
|
-
|
8
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
9
|
-
|
10
|
-
/* eslint-disable jsx-a11y/anchor-is-valid, react/no-array-index-key, react/jsx-props-no-spreading */
|
11
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
12
|
-
import PropTypes from 'prop-types';
|
13
|
-
import get from 'lodash/get';
|
14
|
-
import classNames from 'classnames';
|
15
|
-
import { defineMessages, injectIntl } from 'react-intl';
|
16
|
-
import { PropTypes as PanneauPropTypes, useResourceApi } from '@panneau/core';
|
17
|
-
import { isMessage } from '@panneau/core/utils';
|
18
|
-
import { useComponent } from '@panneau/core/contexts';
|
19
|
-
import { Loading, Errors } from '@panneau/core/components';
|
20
|
-
import ResourceIndexHeader from '../partials/ResourceIndexHeader';
|
21
|
-
var styles = {
|
22
|
-
"container": "panneau-app-resource-index-container",
|
23
|
-
"listContainer": "panneau-app-resource-index-listContainer",
|
24
|
-
"list": "panneau-app-resource-index-list",
|
25
|
-
"loading": "panneau-app-resource-index-loading",
|
26
|
-
"inner": "panneau-app-resource-index-inner",
|
27
|
-
"middle": "panneau-app-resource-index-middle",
|
28
|
-
"alone": "panneau-app-resource-index-alone"
|
29
|
-
};
|
30
|
-
var messages = defineMessages({
|
31
|
-
add: {
|
32
|
-
"id": "core.buttons.resources.add",
|
33
|
-
"defaultMessage": "Add {name}"
|
34
|
-
},
|
35
|
-
title: {
|
36
|
-
"id": "core.titles.resources.index",
|
37
|
-
"defaultMessage": "{name}"
|
38
|
-
},
|
39
|
-
confirmDelete: {
|
40
|
-
"id": "core.resources.index.confirm_delete",
|
41
|
-
"defaultMessage": "Are you sure you want to delete this item from {name}?"
|
42
|
-
}
|
43
|
-
});
|
44
|
-
var propTypes = {
|
45
|
-
intl: PanneauPropTypes.intl.isRequired,
|
46
|
-
resource: PanneauPropTypes.resource.isRequired,
|
47
|
-
query: PropTypes.shape({
|
48
|
-
page: PropTypes.string
|
49
|
-
}),
|
50
|
-
title: PanneauPropTypes.message,
|
51
|
-
showAddButton: PropTypes.bool,
|
52
|
-
addButtonLabel: PanneauPropTypes.message,
|
53
|
-
confirmDeleteMessage: PanneauPropTypes.message,
|
54
|
-
getResourceActionUrl: PropTypes.func.isRequired,
|
55
|
-
gotoResourceAction: PropTypes.func.isRequired
|
56
|
-
};
|
57
|
-
var defaultProps = {
|
58
|
-
query: null,
|
59
|
-
title: messages.title,
|
60
|
-
showAddButton: true,
|
61
|
-
addButtonLabel: messages.add,
|
62
|
-
confirmDeleteMessage: messages.confirmDelete
|
63
|
-
};
|
64
|
-
|
65
|
-
var ResourceIndex = function ResourceIndex(_ref) {
|
66
|
-
var _classNames;
|
67
|
-
|
68
|
-
var intl = _ref.intl,
|
69
|
-
resource = _ref.resource,
|
70
|
-
query = _ref.query,
|
71
|
-
title = _ref.title,
|
72
|
-
addButtonLabel = _ref.addButtonLabel,
|
73
|
-
confirmDeleteMessage = _ref.confirmDeleteMessage,
|
74
|
-
getResourceActionUrl = _ref.getResourceActionUrl,
|
75
|
-
gotoResourceAction = _ref.gotoResourceAction,
|
76
|
-
showAddButton = _ref.showAddButton;
|
77
|
-
|
78
|
-
var _useState = useState({
|
79
|
-
isLoading: false,
|
80
|
-
query: null,
|
81
|
-
items: null,
|
82
|
-
errors: null,
|
83
|
-
pagination: null
|
84
|
-
}),
|
85
|
-
_useState2 = _slicedToArray(_useState, 2),
|
86
|
-
request = _useState2[0],
|
87
|
-
setRequest = _useState2[1];
|
88
|
-
|
89
|
-
var resourceApi = useResourceApi(resource);
|
90
|
-
var isLoading = request.isLoading,
|
91
|
-
items = request.items,
|
92
|
-
pagination = request.pagination,
|
93
|
-
errors = request.errors;
|
94
|
-
|
95
|
-
var _resource$list = resource.list('index'),
|
96
|
-
listType = _resource$list.type,
|
97
|
-
_resource$list$pagina = _resource$list.pagination,
|
98
|
-
hasPagination = _resource$list$pagina === void 0 ? false : _resource$list$pagina,
|
99
|
-
listProps = _objectWithoutProperties(_resource$list, ["type", "pagination"]);
|
100
|
-
|
101
|
-
useEffect(function () {
|
102
|
-
if (isLoading) {
|
103
|
-
return null;
|
104
|
-
}
|
105
|
-
|
106
|
-
var canceled = false;
|
107
|
-
|
108
|
-
var onItemsLoaded = function onItemsLoaded(data) {
|
109
|
-
if (canceled) {
|
110
|
-
return;
|
111
|
-
}
|
112
|
-
|
113
|
-
if (hasPagination) {
|
114
|
-
var newItems = data.data,
|
115
|
-
newPagination = _objectWithoutProperties(data, ["data"]);
|
116
|
-
|
117
|
-
setRequest(_objectSpread({}, request, {
|
118
|
-
items: newItems,
|
119
|
-
pagination: newPagination,
|
120
|
-
isLoading: false
|
121
|
-
}));
|
122
|
-
return;
|
123
|
-
}
|
124
|
-
|
125
|
-
setRequest(_objectSpread({}, request, {
|
126
|
-
items: data,
|
127
|
-
isLoading: false
|
128
|
-
}));
|
129
|
-
};
|
130
|
-
|
131
|
-
var onItemsLoadError = function onItemsLoadError(newErrors) {
|
132
|
-
if (canceled) {
|
133
|
-
return;
|
134
|
-
}
|
135
|
-
|
136
|
-
setRequest(_objectSpread({}, request, {
|
137
|
-
errors: newErrors,
|
138
|
-
isLoading: false
|
139
|
-
}));
|
140
|
-
};
|
141
|
-
|
142
|
-
var _ref2 = query || {},
|
143
|
-
_ref2$page = _ref2.page,
|
144
|
-
page = _ref2$page === void 0 ? null : _ref2$page;
|
145
|
-
|
146
|
-
var params = {};
|
147
|
-
|
148
|
-
if (hasPagination && page !== null) {
|
149
|
-
params.page = page;
|
150
|
-
}
|
151
|
-
|
152
|
-
resourceApi.index(params).then(onItemsLoaded)["catch"](onItemsLoadError);
|
153
|
-
setRequest(_objectSpread({}, request, {
|
154
|
-
isLoading: true
|
155
|
-
}));
|
156
|
-
return function () {
|
157
|
-
canceled = true;
|
158
|
-
};
|
159
|
-
}, [query, hasPagination]);
|
160
|
-
var deleteItem = useCallback(function (id) {
|
161
|
-
var onItemDeleted = function onItemDeleted(_ref3) {
|
162
|
-
var itemId = _ref3.id;
|
163
|
-
setRequest(_objectSpread({}, request, {
|
164
|
-
items: items.filter(function (it) {
|
165
|
-
return it.id !== itemId;
|
166
|
-
})
|
167
|
-
}));
|
168
|
-
};
|
169
|
-
|
170
|
-
var name = resource.name;
|
171
|
-
var confirmMessage = resource.message('confirm_delete', confirmDeleteMessage);
|
172
|
-
var message = isMessage(confirmMessage) ? intl.formatMessage(confirmMessage, {
|
173
|
-
name: name,
|
174
|
-
id: id
|
175
|
-
}) : confirmMessage; // eslint-disable-next-line no-alert
|
176
|
-
|
177
|
-
if (window.confirm(message)) {
|
178
|
-
resourceApi.destroy(id).then(onItemDeleted);
|
179
|
-
}
|
180
|
-
}, [resource, request]);
|
181
|
-
var onClickAction = useCallback(function (e, action, it) {
|
182
|
-
var useRouter = get(action, 'useRouter', true);
|
183
|
-
|
184
|
-
switch (action.id) {
|
185
|
-
case 'edit':
|
186
|
-
case 'show':
|
187
|
-
if (useRouter) {
|
188
|
-
gotoResourceAction(action.id, it.id);
|
189
|
-
} else {
|
190
|
-
window.location.href = getResourceActionUrl(action.id);
|
191
|
-
}
|
192
|
-
|
193
|
-
break;
|
194
|
-
|
195
|
-
case 'delete':
|
196
|
-
{
|
197
|
-
var hasPage = get(action, 'hasPage', false);
|
198
|
-
|
199
|
-
if (!hasPage) {
|
200
|
-
deleteItem(it.id);
|
201
|
-
} else if (useRouter) {
|
202
|
-
gotoResourceAction(action.id, it.id);
|
203
|
-
} else {
|
204
|
-
window.location.href = getResourceActionUrl(action.id);
|
205
|
-
}
|
206
|
-
|
207
|
-
break;
|
208
|
-
}
|
209
|
-
|
210
|
-
default:
|
211
|
-
break;
|
212
|
-
}
|
213
|
-
}, [deleteItem, gotoResourceAction, getResourceActionUrl]); // Components
|
214
|
-
|
215
|
-
var ListComponent = useComponent(listType || 'table', 'lists');
|
216
|
-
var Pagination = useComponent('pagination', 'lists');
|
217
|
-
return React.createElement("div", {
|
218
|
-
className: classNames([styles.container])
|
219
|
-
}, React.createElement("div", {
|
220
|
-
className: "container"
|
221
|
-
}, React.createElement("div", {
|
222
|
-
className: "row justify-content-md-center"
|
223
|
-
}, React.createElement("div", {
|
224
|
-
className: "col-lg-8"
|
225
|
-
}, React.createElement(ResourceIndexHeader, {
|
226
|
-
resource: resource,
|
227
|
-
title: title,
|
228
|
-
addButtonLabel: addButtonLabel,
|
229
|
-
showAddButton: showAddButton,
|
230
|
-
getResourceActionUrl: getResourceActionUrl
|
231
|
-
}), React.createElement("div", {
|
232
|
-
className: styles.listContainer
|
233
|
-
}, React.createElement(Errors, {
|
234
|
-
errors: errors
|
235
|
-
}), React.createElement("div", {
|
236
|
-
className: styles.list
|
237
|
-
}, items !== null && ListComponent !== null ? React.createElement("div", {
|
238
|
-
className: styles.list
|
239
|
-
}, React.createElement(ListComponent, _extends({}, listProps, {
|
240
|
-
items: items || [],
|
241
|
-
onClickAction: onClickAction
|
242
|
-
}))) : null), isLoading ? React.createElement("div", {
|
243
|
-
className: classNames((_classNames = {}, _defineProperty(_classNames, styles.loading, true), _defineProperty(_classNames, styles.alone, items === null), _classNames))
|
244
|
-
}, React.createElement("div", {
|
245
|
-
className: styles.inner
|
246
|
-
}, React.createElement("div", {
|
247
|
-
className: styles.middle
|
248
|
-
}, React.createElement(Loading, {
|
249
|
-
loading: true
|
250
|
-
})))) : null), pagination !== null && pagination.last_page > 1 ? React.createElement(Pagination, {
|
251
|
-
total: pagination.total,
|
252
|
-
perPage: pagination.per_page,
|
253
|
-
currentPage: pagination.current_page,
|
254
|
-
lastPage: pagination.last_page,
|
255
|
-
url: getResourceActionUrl('index')
|
256
|
-
}) : null))));
|
257
|
-
};
|
258
|
-
|
259
|
-
ResourceIndex.propTypes = propTypes;
|
260
|
-
ResourceIndex.defaultProps = defaultProps;
|
261
|
-
export default injectIntl(ResourceIndex);
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
2
|
-
import React from 'react';
|
3
|
-
import ResourceForm from './ResourceForm';
|
4
|
-
var propTypes = {};
|
5
|
-
var defaultProps = {};
|
6
|
-
|
7
|
-
var ResourceShow = function ResourceShow(props) {
|
8
|
-
return React.createElement(ResourceForm, _extends({
|
9
|
-
readOnly: true
|
10
|
-
}, props));
|
11
|
-
};
|
12
|
-
|
13
|
-
ResourceShow.propTypes = propTypes;
|
14
|
-
ResourceShow.defaultProps = defaultProps;
|
15
|
-
export default ResourceShow;
|
@@ -1,111 +0,0 @@
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
-
import React, { useMemo } from 'react';
|
4
|
-
import PropTypes from 'prop-types';
|
5
|
-
import classNames from 'classnames';
|
6
|
-
import { defineMessages, injectIntl } from 'react-intl';
|
7
|
-
import { PropTypes as PanneauPropTypes } from '@panneau/core';
|
8
|
-
import { isMessage, getLocalizedName } from '@panneau/core/utils';
|
9
|
-
import { Button, Label } from '@panneau/core/components';
|
10
|
-
import { useUrlGenerator } from '@panneau/core/contexts';
|
11
|
-
var styles = {
|
12
|
-
"container": "panneau-app-resource-form-header-container",
|
13
|
-
"isFullscreen": "panneau-app-resource-form-header-isFullscreen"
|
14
|
-
};
|
15
|
-
var messages = defineMessages({
|
16
|
-
switchType: {
|
17
|
-
"id": "app.buttons.resources.switch_type",
|
18
|
-
"defaultMessage": "Switch type"
|
19
|
-
},
|
20
|
-
confirmSwitchType: {
|
21
|
-
"id": "app.resources.form.confirm_switch_type",
|
22
|
-
"defaultMessage": "Are you sure you want to switch type?"
|
23
|
-
}
|
24
|
-
});
|
25
|
-
var propTypes = {
|
26
|
-
intl: PanneauPropTypes.intl.isRequired,
|
27
|
-
action: PropTypes.string,
|
28
|
-
type: PropTypes.definitionFormType,
|
29
|
-
fullscreen: PanneauPropTypes.bool,
|
30
|
-
resource: PanneauPropTypes.resource.isRequired,
|
31
|
-
title: PanneauPropTypes.label.isRequired,
|
32
|
-
titleTyped: PanneauPropTypes.label.isRequired,
|
33
|
-
valueHasChanged: PropTypes.bool,
|
34
|
-
confirmSwitchTypeMessage: PanneauPropTypes.label
|
35
|
-
};
|
36
|
-
var defaultProps = {
|
37
|
-
action: 'create',
|
38
|
-
type: null,
|
39
|
-
confirmSwitchTypeMessage: messages.confirmSwitchType,
|
40
|
-
fullscreen: false,
|
41
|
-
valueHasChanged: false
|
42
|
-
};
|
43
|
-
|
44
|
-
var ResourceFormHeader = function ResourceFormHeader(_ref) {
|
45
|
-
var intl = _ref.intl,
|
46
|
-
resource = _ref.resource,
|
47
|
-
type = _ref.type,
|
48
|
-
fullscreen = _ref.fullscreen,
|
49
|
-
action = _ref.action,
|
50
|
-
title = _ref.title,
|
51
|
-
titleTyped = _ref.titleTyped,
|
52
|
-
valueHasChanged = _ref.valueHasChanged,
|
53
|
-
confirmSwitchTypeMessage = _ref.confirmSwitchTypeMessage;
|
54
|
-
var urlGenerator = useUrlGenerator();
|
55
|
-
var localizedName = resource.localizedName('a');
|
56
|
-
var resourceTitle = useMemo(function () {
|
57
|
-
var customTitle = type !== null ? resource.message("titles.resources.".concat(action, "_").concat(type.id)) || resource.message("titles.resources.".concat(action, "_typed")) || resource.message("titles.resources.".concat(action)) || resource.message('titles.resources.default', null) : resource.message("titles.resources.".concat(action)) || resource.message('titles.resources.default', null);
|
58
|
-
var defaultTitle = type !== null ? titleTyped : title;
|
59
|
-
return customTitle || defaultTitle;
|
60
|
-
}, [resource, action, type]);
|
61
|
-
var titleElement = React.createElement("h1", {
|
62
|
-
className: classNames(['mb-0', 'mt-0', styles.title])
|
63
|
-
}, React.createElement(Label, {
|
64
|
-
isHtml: true,
|
65
|
-
values: {
|
66
|
-
name: localizedName,
|
67
|
-
type: type !== null ? getLocalizedName(type) : null
|
68
|
-
}
|
69
|
-
}, resourceTitle));
|
70
|
-
|
71
|
-
var onClickSwitchType = function onClickSwitchType(e) {
|
72
|
-
var confirmMessage = isMessage(confirmSwitchTypeMessage) ? intl.formatMessage(confirmSwitchTypeMessage, {
|
73
|
-
type: getLocalizedName(type)
|
74
|
-
}) : confirmSwitchTypeMessage; // eslint-disable-next-line no-alert
|
75
|
-
|
76
|
-
if (valueHasChanged && !window.confirm(confirmMessage)) {
|
77
|
-
e.preventDefault();
|
78
|
-
}
|
79
|
-
};
|
80
|
-
|
81
|
-
return React.createElement("div", {
|
82
|
-
className: classNames([styles.header, _defineProperty({
|
83
|
-
'py-4': !fullscreen,
|
84
|
-
'px-2': fullscreen,
|
85
|
-
'py-3': fullscreen
|
86
|
-
}, styles.isFullscreen, fullscreen)])
|
87
|
-
}, type !== null && action === 'create' ? React.createElement("div", {
|
88
|
-
className: classNames(['row', 'no-gutters', 'align-items-center'])
|
89
|
-
}, React.createElement("div", {
|
90
|
-
className: "col"
|
91
|
-
}, titleElement), React.createElement("div", {
|
92
|
-
className: classNames(['col', 'col-md-auto', 'text-right'])
|
93
|
-
}, React.createElement(Button, {
|
94
|
-
size: "sm",
|
95
|
-
dropdown: resource.types().map(function (_ref3) {
|
96
|
-
var id = _ref3.id,
|
97
|
-
typeProps = _objectWithoutProperties(_ref3, ["id"]);
|
98
|
-
|
99
|
-
return {
|
100
|
-
label: getLocalizedName(typeProps),
|
101
|
-
href: "".concat(urlGenerator.resource(resource, 'create'), "?type=").concat(id),
|
102
|
-
active: id === type.id,
|
103
|
-
onClick: onClickSwitchType
|
104
|
-
};
|
105
|
-
})
|
106
|
-
}, messages.switchType))) : titleElement);
|
107
|
-
};
|
108
|
-
|
109
|
-
ResourceFormHeader.propTypes = propTypes;
|
110
|
-
ResourceFormHeader.defaultProps = defaultProps;
|
111
|
-
export default injectIntl(ResourceFormHeader);
|
@@ -1,71 +0,0 @@
|
|
1
|
-
/* eslint-disable jsx-a11y/anchor-is-valid, react/jsx-props-no-spreading */
|
2
|
-
import React from 'react';
|
3
|
-
import PropTypes from 'prop-types';
|
4
|
-
import classNames from 'classnames';
|
5
|
-
import { PropTypes as PanneauPropTypes } from '@panneau/core';
|
6
|
-
import { getLocalizedName } from '@panneau/core/utils';
|
7
|
-
import { Button, Label } from '@panneau/core/components';
|
8
|
-
var styles = {
|
9
|
-
"container": "panneau-app-resource-index-header-container",
|
10
|
-
"cols": "panneau-app-resource-index-header-cols",
|
11
|
-
"col": "panneau-app-resource-index-header-col"
|
12
|
-
};
|
13
|
-
var propTypes = {
|
14
|
-
resource: PanneauPropTypes.resource.isRequired,
|
15
|
-
title: PanneauPropTypes.label,
|
16
|
-
showAddButton: PropTypes.bool,
|
17
|
-
addButtonLabel: PanneauPropTypes.label,
|
18
|
-
getResourceActionUrl: PropTypes.func.isRequired
|
19
|
-
};
|
20
|
-
var defaultProps = {
|
21
|
-
title: null,
|
22
|
-
showAddButton: true,
|
23
|
-
addButtonLabel: null
|
24
|
-
};
|
25
|
-
|
26
|
-
var ResourceIndexHeader = function ResourceIndexHeader(_ref) {
|
27
|
-
var resource = _ref.resource,
|
28
|
-
showAddButton = _ref.showAddButton,
|
29
|
-
title = _ref.title,
|
30
|
-
addButtonLabel = _ref.addButtonLabel,
|
31
|
-
getResourceActionUrl = _ref.getResourceActionUrl;
|
32
|
-
var isTyped = resource.type() === 'typed';
|
33
|
-
var resourceName = resource.localizedName('plural'); // Title
|
34
|
-
|
35
|
-
var resourceTitle = resource.message('titles.resources.index', React.createElement(Label, {
|
36
|
-
values: {
|
37
|
-
name: resourceName
|
38
|
-
}
|
39
|
-
}, title)); // Add button
|
40
|
-
|
41
|
-
var resourceAddButtonLabel = resource.message('buttons.resources.add', React.createElement(Label, {
|
42
|
-
values: {
|
43
|
-
name: resourceName
|
44
|
-
}
|
45
|
-
}, addButtonLabel));
|
46
|
-
return React.createElement("div", {
|
47
|
-
className: classNames(['py-4', styles.header])
|
48
|
-
}, React.createElement("div", {
|
49
|
-
className: styles.cols
|
50
|
-
}, React.createElement("div", {
|
51
|
-
className: styles.col
|
52
|
-
}, React.createElement("h1", {
|
53
|
-
className: classNames([styles.title, 'mb-0', 'mt-0'])
|
54
|
-
}, resourceTitle)), React.createElement("div", {
|
55
|
-
className: classNames([styles.col, 'text-right'])
|
56
|
-
}, showAddButton ? React.createElement(Button, {
|
57
|
-
href: isTyped ? getResourceActionUrl('create') : null,
|
58
|
-
dropdown: isTyped ? resource.types().map(function (type) {
|
59
|
-
return {
|
60
|
-
href: "".concat(getResourceActionUrl('create'), "?type=").concat(type.id),
|
61
|
-
label: getLocalizedName(type)
|
62
|
-
};
|
63
|
-
}) : null
|
64
|
-
}, isTyped ? React.createElement(React.Fragment, null, resourceAddButtonLabel, " ", React.createElement("span", {
|
65
|
-
className: "caret"
|
66
|
-
})) : resourceAddButtonLabel) : null)));
|
67
|
-
};
|
68
|
-
|
69
|
-
ResourceIndexHeader.propTypes = propTypes;
|
70
|
-
ResourceIndexHeader.defaultProps = defaultProps;
|
71
|
-
export default ResourceIndexHeader;
|
package/es/defaults/routes.json
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"home": "/",
|
3
|
-
"resource.index": "/:resource",
|
4
|
-
"resource.show": "/:resource/:id",
|
5
|
-
"resource.create": "/:resource/create",
|
6
|
-
"resource.edit": "/:resource/:id/edit",
|
7
|
-
"resource.store": "/:resource",
|
8
|
-
"resource.update": "/:resource/:id",
|
9
|
-
"resource.delete": "/:resource/:id"
|
10
|
-
}
|
package/es/lib/createStore.js
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
-
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
5
|
-
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
7
|
-
|
8
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
9
|
-
import { createStore, applyMiddleware, combineReducers } from 'redux';
|
10
|
-
import { composeWithDevTools } from 'redux-devtools-extension';
|
11
|
-
import thunk from 'redux-thunk';
|
12
|
-
import promise from 'redux-promise';
|
13
|
-
export default (function (reducers, initialState) {
|
14
|
-
var middlewares = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
15
|
-
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
16
|
-
|
17
|
-
var options = _objectSpread({}, opts);
|
18
|
-
|
19
|
-
var reducer = combineReducers(reducers);
|
20
|
-
var enhancer = applyMiddleware.apply(void 0, _toConsumableArray(middlewares).concat([thunk, promise]));
|
21
|
-
|
22
|
-
if (process.env.NODE_ENV !== 'production') {
|
23
|
-
var _options$devTools = options.devTools,
|
24
|
-
devTools = _options$devTools === void 0 ? {} : _options$devTools;
|
25
|
-
var composeEnhancers = composeWithDevTools(devTools);
|
26
|
-
enhancer = composeEnhancers(enhancer);
|
27
|
-
}
|
28
|
-
|
29
|
-
return createStore(reducer, initialState, enhancer);
|
30
|
-
});
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
-
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
4
|
-
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
6
|
-
|
7
|
-
import { SET_USER } from '../actions/AuthActions';
|
8
|
-
var initialState = {
|
9
|
-
user: null
|
10
|
-
};
|
11
|
-
|
12
|
-
var AuthReducer = function AuthReducer() {
|
13
|
-
var previousState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
14
|
-
var action = arguments.length > 1 ? arguments[1] : undefined;
|
15
|
-
var state = previousState;
|
16
|
-
|
17
|
-
switch (action.type) {
|
18
|
-
case SET_USER:
|
19
|
-
{
|
20
|
-
return _objectSpread({}, state, {
|
21
|
-
user: action.payload
|
22
|
-
});
|
23
|
-
}
|
24
|
-
|
25
|
-
default:
|
26
|
-
{
|
27
|
-
return state;
|
28
|
-
}
|
29
|
-
}
|
30
|
-
};
|
31
|
-
|
32
|
-
export default AuthReducer;
|
package/es/reducers/index.js
DELETED