muffin-admin 1.30.0 → 1.31.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/Makefile +7 -0
- package/dist/admin.js +82 -0
- package/dist/authprovider.js +250 -0
- package/dist/buttons/ActionButton.js +110 -0
- package/dist/buttons/LinkButton.js +44 -0
- package/dist/dashboard.js +70 -0
- package/dist/dataprovider.js +379 -0
- package/dist/fields/AvatarField.js +46 -0
- package/dist/fields/FKField.js +43 -0
- package/dist/fields/JsonField.js +51 -0
- package/dist/hooks/useAction.js +17 -0
- package/dist/index.js +21 -0
- package/dist/inputs/FKInput.js +53 -0
- package/dist/inputs/JsonInput.js +82 -0
- package/dist/resources.js +57 -0
- package/dist/ui.js +95 -0
- package/dist/utils.js +67 -0
- package/dist/views/create.js +25 -0
- package/dist/views/edit.js +53 -0
- package/dist/views/list.js +83 -0
- package/dist/views/show.js +36 -0
- package/dist/web.js +33 -0
- package/package.json +12 -3
- package/webpack.config.js +3 -6
- package/.babelrc +0 -5
- package/admin.jsx +0 -60
- package/authprovider.js +0 -84
- package/buttons/ActionButton.jsx +0 -99
- package/buttons/LinkButton.jsx +0 -21
- package/dashboard.jsx +0 -74
- package/dataprovider.js +0 -94
- package/fields/AvatarField.jsx +0 -34
- package/fields/FKField.jsx +0 -28
- package/fields/JsonField.jsx +0 -25
- package/hooks/useAction.js +0 -9
- package/index.js +0 -15
- package/inputs/FKInput.jsx +0 -42
- package/inputs/JsonInput.jsx +0 -62
- package/resources.jsx +0 -37
- package/ui.jsx +0 -107
- package/utils.js +0 -39
- package/views/create.jsx +0 -30
- package/views/edit.jsx +0 -42
- package/views/list.jsx +0 -86
- package/views/show.jsx +0 -43
package/ui.jsx
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import { required } from 'react-admin'
|
|
4
|
-
import {
|
|
5
|
-
BooleanField,
|
|
6
|
-
ChipField,
|
|
7
|
-
DateField,
|
|
8
|
-
EmailField,
|
|
9
|
-
ImageField,
|
|
10
|
-
FileField,
|
|
11
|
-
NumberField,
|
|
12
|
-
RichTextField,
|
|
13
|
-
TextField,
|
|
14
|
-
UrlField,
|
|
15
|
-
SelectField,
|
|
16
|
-
ArrayField,
|
|
17
|
-
ReferenceField,
|
|
18
|
-
ReferenceManyField,
|
|
19
|
-
ReferenceArrayField,
|
|
20
|
-
} from 'react-admin'
|
|
21
|
-
import {
|
|
22
|
-
BooleanInput,
|
|
23
|
-
NullableBooleanInput,
|
|
24
|
-
DateInput,
|
|
25
|
-
DateTimeInput,
|
|
26
|
-
ImageInput,
|
|
27
|
-
FileInput,
|
|
28
|
-
NumberInput,
|
|
29
|
-
PasswordInput,
|
|
30
|
-
TextInput,
|
|
31
|
-
AutocompleteInput,
|
|
32
|
-
RadioButtonGroupInput,
|
|
33
|
-
SelectInput,
|
|
34
|
-
ArrayInput,
|
|
35
|
-
AutocompleteArrayInput,
|
|
36
|
-
CheckboxGroupInput,
|
|
37
|
-
ReferenceArrayInput,
|
|
38
|
-
ReferenceInput,
|
|
39
|
-
} from 'react-admin'
|
|
40
|
-
|
|
41
|
-
import AvatarField from './fields/AvatarField.jsx'
|
|
42
|
-
import FKField from './fields/FKField.jsx'
|
|
43
|
-
import FKInput from './inputs/FKInput.jsx'
|
|
44
|
-
import JsonField from './fields/JsonField.jsx'
|
|
45
|
-
import JsonInput from './inputs/JsonInput.jsx'
|
|
46
|
-
|
|
47
|
-
const ui = {
|
|
48
|
-
// Fields
|
|
49
|
-
BooleanField,
|
|
50
|
-
ChipField,
|
|
51
|
-
DateField,
|
|
52
|
-
EmailField,
|
|
53
|
-
ImageField,
|
|
54
|
-
FileField,
|
|
55
|
-
NumberField,
|
|
56
|
-
RichTextField,
|
|
57
|
-
TextField,
|
|
58
|
-
UrlField,
|
|
59
|
-
SelectField,
|
|
60
|
-
ArrayField,
|
|
61
|
-
ReferenceField,
|
|
62
|
-
ReferenceManyField,
|
|
63
|
-
ReferenceArrayField,
|
|
64
|
-
AvatarField,
|
|
65
|
-
JsonField,
|
|
66
|
-
FKField,
|
|
67
|
-
|
|
68
|
-
// Inputs
|
|
69
|
-
BooleanInput,
|
|
70
|
-
NullableBooleanInput,
|
|
71
|
-
DateInput,
|
|
72
|
-
DateTimeInput,
|
|
73
|
-
ImageInput,
|
|
74
|
-
FileInput,
|
|
75
|
-
NumberInput,
|
|
76
|
-
PasswordInput,
|
|
77
|
-
TextInput,
|
|
78
|
-
AutocompleteInput,
|
|
79
|
-
RadioButtonGroupInput,
|
|
80
|
-
SelectInput,
|
|
81
|
-
ArrayInput,
|
|
82
|
-
AutocompleteArrayInput,
|
|
83
|
-
CheckboxGroupInput,
|
|
84
|
-
ReferenceArrayInput,
|
|
85
|
-
ReferenceInput,
|
|
86
|
-
JsonInput,
|
|
87
|
-
FKInput,
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const initRAItems = (itemsProps) =>
|
|
91
|
-
itemsProps.map((item) => {
|
|
92
|
-
const Item = ui[item[0]],
|
|
93
|
-
props = { ...item[1] }
|
|
94
|
-
|
|
95
|
-
if (props.required) {
|
|
96
|
-
props.validate = required()
|
|
97
|
-
delete props.required
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
props.fullWidth = props.fullWidth ?? true
|
|
101
|
-
|
|
102
|
-
if (props.children) props.children = initRAItems(props.children)[0]
|
|
103
|
-
|
|
104
|
-
return <Item key={props.source} {...props} />
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
export default initRAItems
|
package/utils.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
import { isValidElement } from 'react'
|
|
4
|
-
|
|
5
|
-
import { fetchUtils } from 'ra-core'
|
|
6
|
-
import { stringify } from 'query-string'
|
|
7
|
-
|
|
8
|
-
const parts = {}
|
|
9
|
-
|
|
10
|
-
export const setupAdmin = (part, gen) => (parts[part] = gen)
|
|
11
|
-
|
|
12
|
-
export const checkParams = (fn) => (props, res) => {
|
|
13
|
-
if (!props || isValidElement(props)) return props
|
|
14
|
-
return fn(props, res)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const processAdmin = (type, props, res) => {
|
|
18
|
-
if (process.env.NODE_ENV == 'development')
|
|
19
|
-
console.log(`${type}${res ? '-' + res : ''}`, props)
|
|
20
|
-
|
|
21
|
-
if (parts[`${type}-${res}`]) return parts[`${type}-${res}`](props, res)
|
|
22
|
-
if (parts[type]) return parts[type](props, res)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const requestHeaders = {}
|
|
26
|
-
|
|
27
|
-
export const makeRequest = (url, params) => {
|
|
28
|
-
let { data, query, ...opts } = params || {}
|
|
29
|
-
|
|
30
|
-
if (data) opts.body = JSON.stringify(data)
|
|
31
|
-
if (query) url = `${url}?${stringify(query)}`
|
|
32
|
-
|
|
33
|
-
opts = {
|
|
34
|
-
...opts,
|
|
35
|
-
headers: new Headers({ ...requestHeaders, ...opts.headers }),
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return fetchUtils.fetchJson(url, opts)
|
|
39
|
-
}
|
package/views/create.jsx
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import { Create, SimpleForm, TopToolbar, ListButton } from 'react-admin'
|
|
4
|
-
|
|
5
|
-
import initRAItems from '../ui.jsx'
|
|
6
|
-
import { checkParams, processAdmin, setupAdmin } from '../utils'
|
|
7
|
-
|
|
8
|
-
// Initialize a create component
|
|
9
|
-
setupAdmin(
|
|
10
|
-
'create',
|
|
11
|
-
checkParams(
|
|
12
|
-
(inputs, res) =>
|
|
13
|
-
function MACreate(props) {
|
|
14
|
-
const Actions = (
|
|
15
|
-
<TopToolbar>
|
|
16
|
-
<ListButton />
|
|
17
|
-
</TopToolbar>
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Create actions={Actions} {...props}>
|
|
22
|
-
<SimpleForm>
|
|
23
|
-
{processAdmin('create-inputs', inputs, res)}
|
|
24
|
-
</SimpleForm>
|
|
25
|
-
</Create>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
)
|
|
29
|
-
)
|
|
30
|
-
setupAdmin('create-inputs', initRAItems)
|
package/views/edit.jsx
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Edit,
|
|
5
|
-
ListButton,
|
|
6
|
-
ShowButton,
|
|
7
|
-
SimpleForm,
|
|
8
|
-
TopToolbar,
|
|
9
|
-
} from 'react-admin'
|
|
10
|
-
|
|
11
|
-
import initRAItems from '../ui.jsx'
|
|
12
|
-
import { checkParams, processAdmin, setupAdmin } from '../utils'
|
|
13
|
-
|
|
14
|
-
import { ActionButton } from '../buttons/ActionButton.jsx'
|
|
15
|
-
|
|
16
|
-
// Initialize an edit component
|
|
17
|
-
setupAdmin(
|
|
18
|
-
'edit',
|
|
19
|
-
checkParams(
|
|
20
|
-
({ actions, inputs }, res) =>
|
|
21
|
-
function MAEdit(props) {
|
|
22
|
-
const Actions = ({ basePath, resource, ...baseProps }) => (
|
|
23
|
-
<TopToolbar>
|
|
24
|
-
{actions.map((props, idx) => {
|
|
25
|
-
let aProps = { resource, basePath, ...baseProps, ...props }
|
|
26
|
-
return <ActionButton key={idx} {...aProps} />
|
|
27
|
-
})}
|
|
28
|
-
<ListButton />
|
|
29
|
-
<ShowButton />
|
|
30
|
-
</TopToolbar>
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<Edit actions={<Actions />} {...props}>
|
|
35
|
-
<SimpleForm>{processAdmin('edit-inputs', inputs, res)}</SimpleForm>
|
|
36
|
-
</Edit>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
)
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
setupAdmin('edit-inputs', initRAItems)
|
package/views/list.jsx
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
BulkDeleteButton,
|
|
5
|
-
Datagrid,
|
|
6
|
-
EditButton,
|
|
7
|
-
Filter,
|
|
8
|
-
List,
|
|
9
|
-
Pagination,
|
|
10
|
-
} from 'react-admin'
|
|
11
|
-
import uniq from 'lodash/uniq'
|
|
12
|
-
import sortBy from 'lodash/sortBy'
|
|
13
|
-
|
|
14
|
-
import initRAItems from '../ui.jsx'
|
|
15
|
-
import { checkParams, processAdmin, setupAdmin } from '../utils'
|
|
16
|
-
import { BulkActionButton } from '../buttons/ActionButton.jsx'
|
|
17
|
-
|
|
18
|
-
const defaultPagination = <Pagination rowsPerPageOptions={[10, 25, 50, 100]} />
|
|
19
|
-
|
|
20
|
-
// Initiliaze a list component
|
|
21
|
-
setupAdmin(
|
|
22
|
-
'list',
|
|
23
|
-
checkParams((props, res) => {
|
|
24
|
-
let {
|
|
25
|
-
children,
|
|
26
|
-
filters,
|
|
27
|
-
edit,
|
|
28
|
-
pagination,
|
|
29
|
-
show,
|
|
30
|
-
limit,
|
|
31
|
-
limitMax,
|
|
32
|
-
actions,
|
|
33
|
-
...listProps
|
|
34
|
-
} = props
|
|
35
|
-
|
|
36
|
-
children = processAdmin('list-fields', children, res)
|
|
37
|
-
if (edit) children.push(<EditButton key='edit-button' />)
|
|
38
|
-
|
|
39
|
-
pagination = pagination || (
|
|
40
|
-
<Pagination
|
|
41
|
-
rowsPerPageOptions={sortBy(uniq([10, 25, 50, 100, limit, limitMax]))}
|
|
42
|
-
/>
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
return function MAList(props) {
|
|
46
|
-
let Filters = (props) => (
|
|
47
|
-
<Filter {...props}>{processAdmin('list-filters', filters, res)}</Filter>
|
|
48
|
-
)
|
|
49
|
-
let Actions = processAdmin('list-bulkActions', actions)
|
|
50
|
-
|
|
51
|
-
props = { ...props, ...listProps }
|
|
52
|
-
return (
|
|
53
|
-
<List
|
|
54
|
-
filters={<Filters />}
|
|
55
|
-
bulkActionButtons={<Actions />}
|
|
56
|
-
perPage={limit}
|
|
57
|
-
pagination={pagination || defaultPagination}
|
|
58
|
-
{...props}
|
|
59
|
-
>
|
|
60
|
-
<Datagrid rowClick={show ? 'show' : null}>{children}</Datagrid>
|
|
61
|
-
</List>
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
setupAdmin(
|
|
68
|
-
'list-bulkActions',
|
|
69
|
-
(actions) =>
|
|
70
|
-
function MABulkActions(props) {
|
|
71
|
-
let buttons = actions.map((action, idx) => {
|
|
72
|
-
let aProps = { ...action, ...props }
|
|
73
|
-
return <BulkActionButton key={idx} {...aProps} />
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<>
|
|
78
|
-
{buttons}
|
|
79
|
-
<BulkDeleteButton {...props} />
|
|
80
|
-
</>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
setupAdmin('list-filters', initRAItems)
|
|
86
|
-
setupAdmin('list-fields', initRAItems)
|
package/views/show.jsx
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ListButton,
|
|
5
|
-
EditButton,
|
|
6
|
-
Show,
|
|
7
|
-
SimpleShowLayout,
|
|
8
|
-
TopToolbar,
|
|
9
|
-
} from 'react-admin'
|
|
10
|
-
|
|
11
|
-
import initRAItems from '../ui.jsx'
|
|
12
|
-
import { checkParams, processAdmin, setupAdmin } from '../utils'
|
|
13
|
-
|
|
14
|
-
import { ActionButton } from '../buttons/ActionButton.jsx'
|
|
15
|
-
|
|
16
|
-
// Initiliaze a show component
|
|
17
|
-
setupAdmin(
|
|
18
|
-
'show',
|
|
19
|
-
checkParams(
|
|
20
|
-
({ actions, fields }, resource) =>
|
|
21
|
-
function MAShow(props) {
|
|
22
|
-
const Actions = () => (
|
|
23
|
-
<TopToolbar>
|
|
24
|
-
{actions.map((props, idx) => {
|
|
25
|
-
return <ActionButton key={idx} resource={resource} {...props} />
|
|
26
|
-
})}
|
|
27
|
-
<ListButton />
|
|
28
|
-
<EditButton />
|
|
29
|
-
</TopToolbar>
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Show actions={<Actions />} {...props}>
|
|
34
|
-
<SimpleShowLayout>
|
|
35
|
-
{processAdmin('show-fields', fields, resource)}
|
|
36
|
-
</SimpleShowLayout>
|
|
37
|
-
</Show>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
)
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
setupAdmin('show-fields', initRAItems)
|