muffin-admin 12.0.0 → 13.1.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/dist/MuffinAdmin.d.ts +5 -5
- package/dist/MuffinAdmin.js +1 -1
- package/dist/MuffinDashboard.d.ts +1 -1
- package/dist/MuffinDashboard.js +3 -3
- package/dist/MuffinMenu.d.ts +2 -2
- package/dist/MuffinMenu.js +2 -2
- package/dist/MuffinRecordList.d.ts +2 -2
- package/dist/MuffinRecordList.js +1 -1
- package/dist/MuffinResource.d.ts +2 -2
- package/dist/MuffinResourceCreate.d.ts +3 -3
- package/dist/MuffinResourceEdit.d.ts +6 -6
- package/dist/MuffinResourceEdit.js +1 -1
- package/dist/MuffinResourceList.d.ts +2 -2
- package/dist/MuffinResourceList.js +3 -4
- package/dist/MuffinResourceShow.d.ts +5 -5
- package/dist/MuffinResourceShow.js +1 -1
- package/dist/actions/LinkAction.d.ts +2 -2
- package/dist/authprovider.js +7 -9
- package/dist/buildRA.d.ts +4 -3
- package/dist/buildRA.js +1 -1
- package/dist/buttons/ActionButton.d.ts +5 -5
- package/dist/buttons/ActionButton.js +5 -5
- package/dist/buttons/CopyButton.d.ts +1 -1
- package/dist/buttons/LinkButton.d.ts +2 -2
- package/dist/common/AdminModal.d.ts +4 -4
- package/dist/common/ConfirmationProvider.d.ts +2 -2
- package/dist/common/ConfirmationProvider.js +1 -1
- package/dist/common/HelpLink.d.ts +1 -1
- package/dist/common/PayloadButtons.d.ts +1 -1
- package/dist/common/PayloadButtons.js +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/dataprovider.d.ts +7 -7
- package/dist/fields/AvatarField.d.ts +3 -3
- package/dist/fields/AvatarField.js +2 -2
- package/dist/fields/CopyField.d.ts +1 -1
- package/dist/fields/EditableBooleanField.d.ts +1 -1
- package/dist/fields/FKField.d.ts +4 -4
- package/dist/fields/FKField.js +1 -1
- package/dist/fields/JsonField.d.ts +1 -1
- package/dist/filters/DateRangeFilter.d.ts +1 -1
- package/dist/filters/Filter.d.ts +2 -2
- package/dist/filters/Filter.js +2 -2
- package/dist/filters/SearchFilter.d.ts +2 -2
- package/dist/filters/SearchFilter.js +6 -4
- package/dist/hooks/useAction.d.ts +2 -2
- package/dist/hooks/useAction.js +2 -2
- package/dist/i18n/en.d.ts +1 -1
- package/dist/i18n/provider.d.ts +3 -3
- package/dist/i18n/ru.d.ts +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +12 -12
- package/dist/inputs/DateRangeInput.d.ts +2 -2
- package/dist/inputs/FKInput.d.ts +2 -2
- package/dist/inputs/ImgInput.d.ts +2 -2
- package/dist/inputs/JsonInput.d.ts +1 -1
- package/dist/inputs/JsonInput.js +1 -1
- package/dist/inputs/TimestampInput.d.ts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/web.js +0 -1
- package/package.json +15 -29
- package/src/MuffinAdmin.tsx +6 -7
- package/src/MuffinDashboard.tsx +6 -6
- package/src/MuffinMenu.tsx +3 -5
- package/src/MuffinRecordList.tsx +2 -2
- package/src/MuffinResource.tsx +1 -1
- package/src/MuffinResourceCreate.tsx +1 -1
- package/src/MuffinResourceEdit.tsx +1 -1
- package/src/MuffinResourceList.tsx +2 -5
- package/src/MuffinResourceShow.tsx +1 -1
- package/src/actions/LinkAction.tsx +1 -1
- package/src/authprovider.ts +88 -101
- package/src/buildRA.tsx +4 -3
- package/src/buttons/ActionButton.tsx +9 -10
- package/src/buttons/LinkButton.tsx +1 -1
- package/src/common/AdminModal.tsx +3 -3
- package/src/common/ConfirmationProvider.tsx +1 -1
- package/src/common/PayloadButtons.tsx +1 -1
- package/src/context.ts +1 -1
- package/src/dataprovider.ts +2 -2
- package/src/fields/AvatarField.tsx +8 -10
- package/src/fields/FKField.tsx +1 -1
- package/src/filters/Filter.tsx +2 -2
- package/src/filters/SearchFilter.tsx +14 -7
- package/src/globals.d.ts +1 -0
- package/src/hooks/useAction.ts +4 -4
- package/src/i18n/en.ts +1 -1
- package/src/i18n/ru.ts +1 -1
- package/src/index.tsx +12 -13
- package/src/inputs/DateRangeInput.tsx +1 -1
- package/src/inputs/JsonInput.tsx +1 -1
- package/src/utils.tsx +2 -1
- package/src/version.ts +1 -0
- package/src/web.ts +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/i18n/en.d.ts
CHANGED
package/dist/i18n/provider.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const muffinTranslations: {
|
|
2
|
-
en: import("
|
|
3
|
-
ru: import("
|
|
2
|
+
en: import("ra-core").TranslationMessages;
|
|
3
|
+
ru: import("ra-core").TranslationMessages;
|
|
4
4
|
};
|
|
5
|
-
export declare const buildProvider: (translations: any) => import("
|
|
5
|
+
export declare const buildProvider: (translations: any) => import("ra-core").I18nProvider;
|
package/dist/i18n/ru.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export * from "./utils";
|
|
2
|
-
export * from "./MuffinAdmin";
|
|
3
|
-
export * from "./MuffinDashboard";
|
|
4
|
-
export * from "./MuffinMenu";
|
|
5
|
-
export * from "./MuffinRecordList";
|
|
6
|
-
export * from "./MuffinResource";
|
|
7
|
-
export * from "./MuffinResourceCreate";
|
|
8
|
-
export * from "./MuffinResourceEdit";
|
|
9
|
-
export * from "./MuffinResourceList";
|
|
10
|
-
export * from "./MuffinResourceShow";
|
|
11
1
|
export * from "./actions";
|
|
12
2
|
export * from "./authprovider";
|
|
13
3
|
export * from "./buildRA";
|
|
@@ -17,6 +7,16 @@ export * from "./context";
|
|
|
17
7
|
export * from "./dataprovider";
|
|
18
8
|
export * from "./fields";
|
|
19
9
|
export * from "./hooks";
|
|
10
|
+
export * from "./MuffinAdmin";
|
|
11
|
+
export * from "./MuffinDashboard";
|
|
12
|
+
export * from "./MuffinMenu";
|
|
13
|
+
export * from "./MuffinRecordList";
|
|
14
|
+
export * from "./MuffinResource";
|
|
15
|
+
export * from "./MuffinResourceCreate";
|
|
16
|
+
export * from "./MuffinResourceEdit";
|
|
17
|
+
export * from "./MuffinResourceList";
|
|
18
|
+
export * from "./MuffinResourceShow";
|
|
20
19
|
export * from "./types";
|
|
20
|
+
export * from "./utils";
|
|
21
21
|
export declare function initAdmin(prefix?: string, containerId?: string): Promise<void>;
|
|
22
|
-
export
|
|
22
|
+
export { VERSION } from "./version";
|
package/dist/index.js
CHANGED
|
@@ -9,18 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { createRoot } from "react-dom/client";
|
|
12
|
-
import { MuffinAdmin } from "./MuffinAdmin";
|
|
13
12
|
import { MuffinAdminContext } from "./context";
|
|
14
|
-
|
|
15
|
-
export * from "./MuffinAdmin";
|
|
16
|
-
export * from "./MuffinDashboard";
|
|
17
|
-
export * from "./MuffinMenu";
|
|
18
|
-
export * from "./MuffinRecordList";
|
|
19
|
-
export * from "./MuffinResource";
|
|
20
|
-
export * from "./MuffinResourceCreate";
|
|
21
|
-
export * from "./MuffinResourceEdit";
|
|
22
|
-
export * from "./MuffinResourceList";
|
|
23
|
-
export * from "./MuffinResourceShow";
|
|
13
|
+
import { MuffinAdmin } from "./MuffinAdmin";
|
|
24
14
|
export * from "./actions";
|
|
25
15
|
export * from "./authprovider";
|
|
26
16
|
export * from "./buildRA";
|
|
@@ -30,7 +20,17 @@ export * from "./context";
|
|
|
30
20
|
export * from "./dataprovider";
|
|
31
21
|
export * from "./fields";
|
|
32
22
|
export * from "./hooks";
|
|
23
|
+
export * from "./MuffinAdmin";
|
|
24
|
+
export * from "./MuffinDashboard";
|
|
25
|
+
export * from "./MuffinMenu";
|
|
26
|
+
export * from "./MuffinRecordList";
|
|
27
|
+
export * from "./MuffinResource";
|
|
28
|
+
export * from "./MuffinResourceCreate";
|
|
29
|
+
export * from "./MuffinResourceEdit";
|
|
30
|
+
export * from "./MuffinResourceList";
|
|
31
|
+
export * from "./MuffinResourceShow";
|
|
33
32
|
export * from "./types";
|
|
33
|
+
export * from "./utils";
|
|
34
34
|
export function initAdmin() {
|
|
35
35
|
return __awaiter(this, arguments, void 0, function* (prefix = "", containerId = "root") {
|
|
36
36
|
const response = yield fetch(`${prefix}/ra.json`);
|
|
@@ -42,4 +42,4 @@ export function initAdmin() {
|
|
|
42
42
|
root.render(_jsx(MuffinAdminContext.Provider, { value: adminOpts, children: _jsx(MuffinAdmin, {}) }));
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
export
|
|
45
|
+
export { VERSION } from "./version";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { InputProps } from "react-admin";
|
|
1
|
+
import { type InputProps } from "react-admin";
|
|
2
2
|
import "react-datepicker/dist/react-datepicker.css";
|
|
3
3
|
type TProps = InputProps & {
|
|
4
4
|
value: [Date, Date];
|
|
5
5
|
onChange: (value: [Date, Date]) => void;
|
|
6
6
|
};
|
|
7
|
-
export declare function DateRangeInput({ value, onChange, ...props }: TProps): import("react
|
|
7
|
+
export declare function DateRangeInput({ value, onChange, ...props }: TProps): import("react").JSX.Element;
|
|
8
8
|
export {};
|
package/dist/inputs/FKInput.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare function FKInput({ refKey, refSource, fullWidth, reference, source, ...props }: {
|
|
2
2
|
[x: string]: any;
|
|
3
|
+
fullWidth: any;
|
|
3
4
|
refKey: any;
|
|
4
5
|
refSource: any;
|
|
5
|
-
fullWidth: any;
|
|
6
6
|
reference: any;
|
|
7
7
|
source: any;
|
|
8
|
-
}): import("react
|
|
8
|
+
}): import("react").JSX.Element;
|
package/dist/inputs/JsonInput.js
CHANGED
|
@@ -19,7 +19,7 @@ const parseFunction = (json) => {
|
|
|
19
19
|
retval = JSON.parse(json);
|
|
20
20
|
}
|
|
21
21
|
finally {
|
|
22
|
-
//
|
|
22
|
+
// biome-ignore lint/correctness/noUnsafeFinally: intentional - return parsed value or original on error
|
|
23
23
|
return retval;
|
|
24
24
|
}
|
|
25
25
|
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TAdminPath } from "./types";
|
|
1
|
+
import type { TAdminPath } from "./types";
|
|
2
2
|
export declare function setupAdmin<T>(adminType: TAdminPath, fc: (props: any) => T): void;
|
|
3
3
|
export declare function buildAdmin(adminType: TAdminPath, props?: {}): any;
|
|
4
4
|
export declare function findBuilder(adminType: TAdminPath): (props: any) => any;
|
|
@@ -23,6 +23,6 @@ export declare function makeRequest(url: string, params?: APIParams): Promise<{
|
|
|
23
23
|
json: any;
|
|
24
24
|
}>;
|
|
25
25
|
export declare function findIcon(icon?: string): any;
|
|
26
|
-
export declare function buildIcon(icon?: string): import("react
|
|
26
|
+
export declare function buildIcon(icon?: string): import("react").JSX.Element;
|
|
27
27
|
export declare function deepMerge(target: any, ...sources: any[]): any;
|
|
28
28
|
export declare function prepareFilters(filter: any): string;
|
package/dist/utils.js
CHANGED
|
@@ -48,6 +48,7 @@ export function makeRequest(url, params = {}) {
|
|
|
48
48
|
return fetchUtils.fetchJson(url, Object.assign(Object.assign({}, opts), { headers: new Headers(Object.assign(Object.assign({}, requestHeaders), opts.headers)) }));
|
|
49
49
|
}
|
|
50
50
|
export function findIcon(icon) {
|
|
51
|
+
// biome-ignore lint/performance/noDynamicNamespaceImportAccess: icons are looked up by name from admin config
|
|
51
52
|
return icon ? icons[icon] : undefined;
|
|
52
53
|
}
|
|
53
54
|
export function buildIcon(icon) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "13.1.0";
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VERSION = "13.1.0";
|
package/dist/web.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muffin-admin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.1.0",
|
|
4
4
|
"description": "NPM package for https://github.com/klen/muffin-admin",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -28,44 +28,30 @@
|
|
|
28
28
|
"ra-language-russian": "^5.4.4",
|
|
29
29
|
"react": "^19.1.1",
|
|
30
30
|
"react-admin": "^5.10.1",
|
|
31
|
-
"react-datepicker": "^
|
|
31
|
+
"react-datepicker": "^9.1.0",
|
|
32
32
|
"react-dom": "^19.1.1",
|
|
33
33
|
"validator": "^13.12.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
+
"@biomejs/biome": "^2.5.5",
|
|
36
37
|
"@types/lodash": "^4.17.20",
|
|
37
|
-
"@types/node": "
|
|
38
|
-
"@types/react": "19.
|
|
39
|
-
"@types/react-dom": "19.
|
|
40
|
-
"@types/react-window": "^
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
|
42
|
-
"@typescript-eslint/parser": "^7.12.0",
|
|
38
|
+
"@types/node": "26.1.1",
|
|
39
|
+
"@types/react": "19.2.17",
|
|
40
|
+
"@types/react-dom": "19.2.3",
|
|
41
|
+
"@types/react-window": "^2.0.0",
|
|
43
42
|
"css-loader": "^7.1.2",
|
|
44
|
-
"dotenv": "^
|
|
45
|
-
"
|
|
46
|
-
"eslint-config-prettier": "^9.1.0",
|
|
47
|
-
"eslint-plugin-prettier": "^5.1.3",
|
|
48
|
-
"eslint-plugin-react": "^7.34.2",
|
|
43
|
+
"dotenv": "^17.4.2",
|
|
44
|
+
"esbuild-loader": "^4.5.0",
|
|
49
45
|
"html-webpack-plugin": "^5.6.0",
|
|
50
46
|
"husky": "^9.0.11",
|
|
51
|
-
"prettier": "^3.2",
|
|
52
|
-
"prettier-plugin-organize-imports": "^3.2",
|
|
53
47
|
"style-loader": "^4.0.0",
|
|
54
|
-
"
|
|
55
|
-
"typescript": "^5.4.5",
|
|
48
|
+
"typescript": "^7.0.2",
|
|
56
49
|
"webpack": "^5.91.0",
|
|
57
|
-
"webpack-cli": "^
|
|
58
|
-
"webpack-dev-server": "^
|
|
50
|
+
"webpack-cli": "^7.2.1",
|
|
51
|
+
"webpack-dev-server": "^6.0.0"
|
|
59
52
|
},
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"prettier-plugin-organize-imports"
|
|
64
|
-
],
|
|
65
|
-
"printWidth": 100,
|
|
66
|
-
"semi": false,
|
|
67
|
-
"tabWidth": 2,
|
|
68
|
-
"trailingComma": "es5",
|
|
69
|
-
"useTabs": false
|
|
53
|
+
"resolutions": {
|
|
54
|
+
"@mui/material": "^9.2.0",
|
|
55
|
+
"@mui/icons-material": "^9.2.0"
|
|
70
56
|
}
|
|
71
57
|
}
|
package/src/MuffinAdmin.tsx
CHANGED
|
@@ -3,20 +3,19 @@ import SvgIcon from "@mui/material/SvgIcon"
|
|
|
3
3
|
import Tooltip from "@mui/material/Tooltip"
|
|
4
4
|
|
|
5
5
|
import Typography from "@mui/material/Typography"
|
|
6
|
+
import { useEffect } from "react"
|
|
6
7
|
import {
|
|
7
8
|
AdminContext,
|
|
8
|
-
AdminProps,
|
|
9
|
+
type AdminProps,
|
|
9
10
|
AdminUI,
|
|
10
11
|
AppBar,
|
|
11
|
-
AppBarProps,
|
|
12
|
+
type AppBarProps,
|
|
12
13
|
Layout,
|
|
13
|
-
LayoutProps,
|
|
14
|
-
localStorageStore,
|
|
14
|
+
type LayoutProps,
|
|
15
15
|
Login,
|
|
16
|
-
LoginProps,
|
|
16
|
+
type LoginProps,
|
|
17
|
+
localStorageStore,
|
|
17
18
|
} from "react-admin"
|
|
18
|
-
|
|
19
|
-
import { useEffect } from "react"
|
|
20
19
|
import { ConfirmationProvider } from "./common"
|
|
21
20
|
import { useMuffinAdminOpts } from "./hooks"
|
|
22
21
|
import { buildProvider, muffinTranslations } from "./i18n"
|
package/src/MuffinDashboard.tsx
CHANGED
|
@@ -8,18 +8,18 @@ import TableCell from "@mui/material/TableCell"
|
|
|
8
8
|
import TableRow from "@mui/material/TableRow"
|
|
9
9
|
import Typography from "@mui/material/Typography"
|
|
10
10
|
import { useTranslate } from "react-admin"
|
|
11
|
-
import { VERSION } from "."
|
|
12
11
|
import { HelpLink } from "./common/HelpLink"
|
|
13
12
|
import { useMuffinAdminOpts } from "./hooks"
|
|
14
|
-
import { AdminDashboardBlock } from "./types"
|
|
13
|
+
import type { AdminDashboardBlock } from "./types"
|
|
15
14
|
import { buildAdmin, setupAdmin } from "./utils"
|
|
15
|
+
import { VERSION } from "./version"
|
|
16
16
|
|
|
17
17
|
export function MuffinDashboard() {
|
|
18
18
|
const { dashboard, help } = useMuffinAdminOpts()
|
|
19
19
|
const translate = useTranslate()
|
|
20
20
|
return (
|
|
21
|
-
<Stack
|
|
22
|
-
<Stack direction="row" flexWrap
|
|
21
|
+
<Stack sx={{ gap: 2, pt: 1 }}>
|
|
22
|
+
<Stack direction="row" sx={{ flexWrap: "wrap", gap: 1 }}>
|
|
23
23
|
{help && <HelpLink href={help} label={translate("muffin.how_to_use_admin")} />}
|
|
24
24
|
{buildAdmin(["dashboard-actions"])}
|
|
25
25
|
</Stack>
|
|
@@ -28,7 +28,7 @@ export function MuffinDashboard() {
|
|
|
28
28
|
<AdminCards src={dashboard} />
|
|
29
29
|
</Grid>
|
|
30
30
|
{VERSION && (
|
|
31
|
-
<Typography variant="body2" color="textSecondary" align="center"
|
|
31
|
+
<Typography variant="body2" color="textSecondary" align="center" sx={{ my: 1 }}>
|
|
32
32
|
Muffin Admin v.{VERSION}
|
|
33
33
|
</Typography>
|
|
34
34
|
)}
|
|
@@ -57,7 +57,7 @@ function DashboardCard({ title, value }: AdminDashboardBlock) {
|
|
|
57
57
|
return (
|
|
58
58
|
<Card>
|
|
59
59
|
<CardContent>
|
|
60
|
-
<Typography variant="h5" component="h2"
|
|
60
|
+
<Typography variant="h5" component="h2" sx={{ m: 2, textAlign: "center" }}>
|
|
61
61
|
{title}
|
|
62
62
|
</Typography>
|
|
63
63
|
{(Array.isArray(value) && <AdminTableView src={value} />) || (
|
package/src/MuffinMenu.tsx
CHANGED
|
@@ -4,15 +4,13 @@ import Collapse from "@mui/material/Collapse"
|
|
|
4
4
|
import ListItemButton from "@mui/material/ListItemButton"
|
|
5
5
|
import ListItemIcon from "@mui/material/ListItemIcon"
|
|
6
6
|
import ListItemText from "@mui/material/ListItemText"
|
|
7
|
-
import { matchPath, useLocation } from "react-router-dom"
|
|
8
|
-
|
|
9
|
-
import { Menu, MenuProps, useBasename, useTheme, useTranslate } from "react-admin"
|
|
10
|
-
|
|
11
7
|
import find from "lodash/find"
|
|
12
8
|
import groupBy from "lodash/groupBy"
|
|
13
9
|
import { useContext, useState } from "react"
|
|
10
|
+
import { Menu, type MenuProps, useBasename, useTheme, useTranslate } from "react-admin"
|
|
11
|
+
import { matchPath, useLocation } from "react-router-dom"
|
|
14
12
|
import { MuffinAdminContext } from "./context"
|
|
15
|
-
import { AdminResourceProps } from "./types"
|
|
13
|
+
import type { AdminResourceProps } from "./types"
|
|
16
14
|
import { findIcon, setupAdmin } from "./utils"
|
|
17
15
|
|
|
18
16
|
export function MuffinMenu(props: MenuProps) {
|
package/src/MuffinRecordList.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Box from "@mui/material/Box"
|
|
2
2
|
import Typography from "@mui/material/Typography"
|
|
3
|
-
import { Datagrid, SortPayload, useGetList, useRecordContext, useTranslate } from "react-admin"
|
|
3
|
+
import { Datagrid, type SortPayload, useGetList, useRecordContext, useTranslate } from "react-admin"
|
|
4
4
|
import { useMuffinResourceOpts } from "./hooks"
|
|
5
5
|
import { buildAdmin } from "./utils"
|
|
6
6
|
|
|
@@ -17,7 +17,7 @@ export function MuffinRecordList({ resource, filter, sort }: TProps) {
|
|
|
17
17
|
} = useMuffinResourceOpts(resource)
|
|
18
18
|
const { data, isPending } = useGetList(resource, { sort, filter: filter(record) })
|
|
19
19
|
return (
|
|
20
|
-
<Box
|
|
20
|
+
<Box sx={{ p: 2 }}>
|
|
21
21
|
<Typography variant="h6">
|
|
22
22
|
{translate(`resources.${resource}.name`, { smart_count: 2 })}
|
|
23
23
|
</Typography>
|
package/src/MuffinResource.tsx
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import sortBy from "lodash/sortBy"
|
|
2
2
|
import uniq from "lodash/uniq"
|
|
3
|
-
import { PropsWithChildren } from "react"
|
|
3
|
+
import type { PropsWithChildren } from "react"
|
|
4
4
|
import {
|
|
5
5
|
BulkDeleteButton,
|
|
6
6
|
BulkExportButton,
|
|
7
7
|
CreateButton,
|
|
8
8
|
DatagridConfigurable,
|
|
9
9
|
EditButton,
|
|
10
|
-
ExportButton,
|
|
11
10
|
FilterButton,
|
|
12
11
|
InfiniteList,
|
|
13
12
|
List,
|
|
@@ -20,7 +19,7 @@ import { buildRA, buildRAComponent } from "./buildRA"
|
|
|
20
19
|
import { BulkActionButton, ListActionButton } from "./buttons"
|
|
21
20
|
import { HelpLink } from "./common/HelpLink"
|
|
22
21
|
import { useMuffinResourceOpts } from "./hooks"
|
|
23
|
-
import { AdminInput } from "./types"
|
|
22
|
+
import type { AdminInput } from "./types"
|
|
24
23
|
import { buildAdmin, findBuilder, setupAdmin } from "./utils"
|
|
25
24
|
|
|
26
25
|
export function MuffinList({ children }: PropsWithChildren) {
|
|
@@ -119,7 +118,6 @@ function MuffinListToolbar() {
|
|
|
119
118
|
list: { create },
|
|
120
119
|
} = useMuffinResourceOpts()
|
|
121
120
|
const actions = baseActions.filter((a) => a.view?.includes("list"))
|
|
122
|
-
const hasExport = actions.some((a) => a.id === "export")
|
|
123
121
|
return (
|
|
124
122
|
<TopToolbar>
|
|
125
123
|
{help && <HelpLink href={help} />}
|
|
@@ -129,7 +127,6 @@ function MuffinListToolbar() {
|
|
|
129
127
|
{actions.length
|
|
130
128
|
? actions.map((props) => <ListActionButton key={props.id} {...props} />)
|
|
131
129
|
: null}
|
|
132
|
-
{!hasExport && <ExportButton />}
|
|
133
130
|
</TopToolbar>
|
|
134
131
|
)
|
|
135
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRecordContext, useResourceContext } from "react-admin"
|
|
2
2
|
import LinkButton from "../buttons/LinkButton"
|
|
3
3
|
import { useMuffinAdminOpts } from "../hooks"
|
|
4
|
-
import { AdminShowLink } from "../types"
|
|
4
|
+
import type { AdminShowLink } from "../types"
|
|
5
5
|
|
|
6
6
|
export function LinkAction({
|
|
7
7
|
field,
|
package/src/authprovider.ts
CHANGED
|
@@ -1,107 +1,94 @@
|
|
|
1
|
-
import Cookies from "js-cookie"
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import Cookies from "js-cookie"
|
|
2
|
+
import type { AdminOpts } from "./types"
|
|
3
|
+
import { findBuilder, makeRequest, requestHeaders, setupAdmin } from "./utils"
|
|
4
4
|
|
|
5
5
|
setupAdmin(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (storage == "localstorage") {
|
|
19
|
-
localStorage.setItem(name, value);
|
|
20
|
-
requestHeaders["Authorization"] = value;
|
|
21
|
-
} else Cookies.set(name, value);
|
|
22
|
-
},
|
|
23
|
-
);
|
|
6
|
+
["auth-storage-get"],
|
|
7
|
+
({ storage, storageName }: AdminOpts["auth"]) =>
|
|
8
|
+
() =>
|
|
9
|
+
storage == "localstorage" ? localStorage.getItem(storageName) : Cookies.get(storageName)
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
setupAdmin(["auth-storage-set"], ({ storage }) => (name, value, _requestOnly) => {
|
|
13
|
+
if (storage == "localstorage") {
|
|
14
|
+
localStorage.setItem(name, value)
|
|
15
|
+
requestHeaders.Authorization = value
|
|
16
|
+
} else Cookies.set(name, value)
|
|
17
|
+
})
|
|
24
18
|
|
|
25
19
|
export function MuffinAuthProvider(props: AdminOpts["auth"]) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
getIdentity,
|
|
99
|
-
|
|
100
|
-
getPermissions: async () => {
|
|
101
|
-
const role = authGet(storageName + "_role");
|
|
102
|
-
return role || "";
|
|
103
|
-
},
|
|
104
|
-
};
|
|
20
|
+
const { identityURL, authorizeURL, logoutURL, required, storageName, storage } = props
|
|
21
|
+
|
|
22
|
+
const authGet = findBuilder(["auth-storage-get"])(props)
|
|
23
|
+
const authSet = findBuilder(["auth-storage-set"])(props)
|
|
24
|
+
|
|
25
|
+
// Initialize request headers
|
|
26
|
+
if (storage == "localstorage") {
|
|
27
|
+
const token = authGet(storageName)
|
|
28
|
+
if (token) requestHeaders.Authorization = token
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const getIdentity = async () => {
|
|
32
|
+
if (identityURL) {
|
|
33
|
+
const { json } = await makeRequest(identityURL)
|
|
34
|
+
return json
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (required)
|
|
39
|
+
return {
|
|
40
|
+
login: async (data) => {
|
|
41
|
+
if (!authorizeURL) throw { message: "Authorization is not supported" }
|
|
42
|
+
|
|
43
|
+
const { json } = await makeRequest(authorizeURL, {
|
|
44
|
+
data,
|
|
45
|
+
method: "POST",
|
|
46
|
+
})
|
|
47
|
+
authSet(storageName, json)
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
checkError: async (error) => {
|
|
51
|
+
const { status } = error || {}
|
|
52
|
+
|
|
53
|
+
if (status == 401 || status == 403) {
|
|
54
|
+
// Clean storage
|
|
55
|
+
authSet(storageName, "")
|
|
56
|
+
|
|
57
|
+
throw {
|
|
58
|
+
message: "Invalid authorization",
|
|
59
|
+
redirectTo: logoutURL,
|
|
60
|
+
logoutUser: !logoutURL,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
checkAuth: async () => {
|
|
66
|
+
const auth = authGet(storageName)
|
|
67
|
+
if (!auth) throw { message: "Authorization required" }
|
|
68
|
+
|
|
69
|
+
if (!identityURL) return auth
|
|
70
|
+
|
|
71
|
+
const user = await getIdentity()
|
|
72
|
+
if (!user) throw { message: "Authorization required" }
|
|
73
|
+
|
|
74
|
+
return user
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
getAuthorization: () => authGet(storageName),
|
|
78
|
+
|
|
79
|
+
logout: async () => {
|
|
80
|
+
// Clean storage
|
|
81
|
+
authSet(storageName, "")
|
|
82
|
+
if (logoutURL) window.location.href = logoutURL
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
getIdentity,
|
|
86
|
+
|
|
87
|
+
getPermissions: async () => {
|
|
88
|
+
const role = authGet(`${storageName}_role`)
|
|
89
|
+
return role || ""
|
|
90
|
+
},
|
|
91
|
+
}
|
|
105
92
|
}
|
|
106
93
|
|
|
107
|
-
setupAdmin(["auth-provider"], MuffinAuthProvider)
|
|
94
|
+
setupAdmin(["auth-provider"], MuffinAuthProvider)
|