muffin-admin 2.6.7 → 2.7.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/dist/types.d.ts CHANGED
@@ -42,8 +42,8 @@ export type AdminResourceProps = {
42
42
  limit: number;
43
43
  limitMax: number;
44
44
  actions: AdminAction[];
45
- fields: AdminField[];
46
45
  filters: AdminInput[];
46
+ fields: AdminField[];
47
47
  show: boolean;
48
48
  edit?: boolean;
49
49
  remove?: boolean;
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { AdminOpts } from "./types";
3
- export declare function setupAdmin<T>(adminType: string[], fc: (props: any) => T): void;
3
+ export declare function setupAdmin<T>(adminType: string[], fc: (opts: any, props?: any) => T): void;
4
4
  export declare function buildAdmin(adminType: string[], props?: {}): any;
5
5
  export declare function findBuilder(adminType: string[]): (props: any) => any;
6
6
  export declare const AdminPropsContext: import("react").Context<AdminOpts>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "2.6.7",
3
+ "version": "2.7.2",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -2,17 +2,12 @@ import IconButton from "@mui/material/IconButton"
2
2
  import SvgIcon from "@mui/material/SvgIcon"
3
3
  import Tooltip from "@mui/material/Tooltip"
4
4
  import Typography from "@mui/material/Typography"
5
- import createTheme from "@mui/material/styles/createTheme"
6
- import { Admin, AppBar, DataProvider, Layout, Login } from "react-admin"
5
+ import { Admin, AdminProps, AppBar, DataProvider, Layout, Login } from "react-admin"
7
6
  import { AdminOpts } from "./types"
8
7
  import { AdminPropsContext, buildAdmin, findBuilder, findIcon, setupAdmin } from "./utils"
9
8
 
10
- const darkTheme = createTheme({
11
- palette: { mode: "dark" },
12
- })
13
-
14
- export function MuffinAdmin(props: AdminOpts) {
15
- const { resources, auth, appBarLinks, adminProps, dashboard } = props
9
+ export function MuffinAdmin(opts: AdminOpts, props: AdminProps) {
10
+ const { resources, auth, appBarLinks, adminProps, dashboard } = opts
16
11
  const children = resources.map((resource) =>
17
12
  buildAdmin(["resource", resource.name], {
18
13
  ...resource,
@@ -29,9 +24,9 @@ export function MuffinAdmin(props: AdminOpts) {
29
24
  id="react-admin-title"
30
25
  style={{
31
26
  flex: 1,
32
- textOverflow: "ellipsis",
33
- whiteSpace: "nowrap",
34
27
  overflow: "hidden",
28
+ whiteSpace: "nowrap",
29
+ textOverflow: "ellipsis",
35
30
  }}
36
31
  />
37
32
  {appBarLinks.map((info) => (
@@ -45,15 +40,16 @@ export function MuffinAdmin(props: AdminOpts) {
45
40
  )
46
41
 
47
42
  return (
48
- <AdminPropsContext.Provider value={props}>
43
+ <AdminPropsContext.Provider value={opts}>
49
44
  <Admin
50
45
  authProvider={buildAdmin(["authprovider"], auth)}
51
- dashboard={dashboard ? buildAdmin(["dashboard"], dashboard) : null}
52
- dataProvider={buildAdmin(["dataprovider"], props) as unknown as DataProvider}
46
+ dataProvider={buildAdmin(["dataprovider"], opts) as unknown as DataProvider}
53
47
  layout={(props) => <Layout {...props} appBar={appBar} />}
54
48
  loginPage={findBuilder(["loginpage"])}
49
+ dashboard={dashboard ? buildAdmin(["dashboard"], dashboard) : null}
55
50
  requireAuth={auth.required}
56
51
  darkTheme={{ palette: { mode: "dark" } }}
52
+ {...props}
57
53
  >
58
54
  {children}
59
55
  </Admin>
@@ -3,9 +3,9 @@ import { ReferenceField, TextField } from "react-admin"
3
3
  export function FKField({ reference, refSource, refKey, link, source, ...props }) {
4
4
  return (
5
5
  <ReferenceField
6
+ source={source}
6
7
  link={link || "show"}
7
8
  reference={reference}
8
- source={source}
9
9
  queryOptions={{ meta: { key: refKey } }}
10
10
  {...props}
11
11
  >
@@ -14,9 +14,9 @@ export function JsonField({ label, source }) {
14
14
  <p></p>
15
15
  {label}
16
16
  <Button
17
- variant="contained"
18
- color="primary"
19
17
  size="small"
18
+ color="primary"
19
+ variant="contained"
20
20
  label={expand ? "colapse" : "expand"}
21
21
  onClick={(e) => {
22
22
  setExpand(!expand)
package/src/types.ts CHANGED
@@ -43,11 +43,14 @@ export type AdminResourceProps = {
43
43
  limit: number
44
44
  limitMax: number
45
45
  actions: AdminAction[]
46
- fields: AdminField[]
47
46
  filters: AdminInput[]
47
+ fields: AdminField[]
48
+ // Enable show button
48
49
  show: boolean
50
+ // Permissions
49
51
  edit?: boolean
50
52
  remove?: boolean
53
+ // Default sorting
51
54
  sort?: {
52
55
  field: string
53
56
  order: "ASC" | "DESC"
package/src/utils.tsx CHANGED
@@ -6,7 +6,7 @@ import { AdminOpts } from "./types"
6
6
 
7
7
  const builders = new Map<string, (props) => any>()
8
8
 
9
- export function setupAdmin<T>(adminType: string[], fc: (props) => T) {
9
+ export function setupAdmin<T>(adminType: string[], fc: (opts, props?) => T) {
10
10
  const key = adminType.join("/")
11
11
  builders.set(key, fc)
12
12
  }