@uxf/cms 11.47.2 → 11.48.1
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/api/index.js +3 -2
- package/config/index.d.ts +0 -2
- package/config/index.js +1 -3
- package/context/cms-provider.d.ts +2 -2
- package/context/cms-provider.js +7 -2
- package/lib/api/create-axios-instance.d.ts +1 -1
- package/lib/api/create-axios-instance.js +3 -4
- package/lib/api/create-axios-request.d.ts +2 -1
- package/lib/api/create-axios-request.js +3 -4
- package/lib/api/create-use-axios-request.d.ts +2 -1
- package/lib/api/create-use-axios-request.js +3 -4
- package/lib/layout/layout.js +1 -2
- package/lib/layout/types.d.ts +1 -0
- package/package.json +5 -5
- package/pages/grid-page/grid-page.js +6 -5
- package/pages/grid-page/types.d.ts +2 -0
- package/security/use-logged-user.js +7 -1
- package/config/config.d.ts +0 -10
- package/config/config.js +0 -22
package/api/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.dataGridAutocompleteGet = void 0;
|
|
4
5
|
exports.contentGet = contentGet;
|
|
@@ -19,9 +20,9 @@ exports.userConfigGetAll = userConfigGetAll;
|
|
|
19
20
|
exports.userConfigGet = userConfigGet;
|
|
20
21
|
exports.uploadFile = uploadFile;
|
|
21
22
|
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
22
|
-
// eslint-disable-next-line import/no-cycle
|
|
23
23
|
const api_1 = require("../lib/api");
|
|
24
|
-
|
|
24
|
+
// TODO @vejvis - doufám, že tohle bude fungovat
|
|
25
|
+
const { axiosRequest, axiosInstance } = (0, api_1.createAxiosInstance)((_a = process.env.NEXT_PUBLIC_FRONTEND_URL) !== null && _a !== void 0 ? _a : "");
|
|
25
26
|
function contentGet(ctx, contentId) {
|
|
26
27
|
return axiosRequest(ctx, `/api/cms/content/${contentId}`, "get", null, null);
|
|
27
28
|
}
|
package/config/index.d.ts
CHANGED
package/config/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.container =
|
|
4
|
-
const config_1 = require("./config");
|
|
3
|
+
exports.container = void 0;
|
|
5
4
|
// eslint-disable-next-line import/no-cycle
|
|
6
5
|
const container_1 = require("./container");
|
|
7
|
-
exports.config = new config_1.Config();
|
|
8
6
|
exports.container = new container_1.Container();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PropsWithChildren, ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { SWRConfiguration } from "swr";
|
|
3
3
|
interface Props {
|
|
4
|
-
|
|
4
|
+
swrConfig?: SWRConfiguration;
|
|
5
5
|
}
|
|
6
6
|
export declare function CmsProvider(props: PropsWithChildren<Props>): ReactNode;
|
|
7
7
|
export {};
|
package/context/cms-provider.js
CHANGED
|
@@ -8,6 +8,11 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const swr_1 = require("swr");
|
|
9
9
|
const fetcher = (input) => fetch(input).then((res) => res.json());
|
|
10
10
|
function CmsProvider(props) {
|
|
11
|
-
var _a;
|
|
12
|
-
|
|
11
|
+
var _a, _b, _c, _d;
|
|
12
|
+
const swrConfig = {
|
|
13
|
+
...props.swrConfig,
|
|
14
|
+
provider: (_b = (_a = props.swrConfig) === null || _a === void 0 ? void 0 : _a.provider) !== null && _b !== void 0 ? _b : (() => new Map()),
|
|
15
|
+
fetcher: (_d = (_c = props.swrConfig) === null || _c === void 0 ? void 0 : _c.fetcher) !== null && _d !== void 0 ? _d : fetcher,
|
|
16
|
+
};
|
|
17
|
+
return react_1.default.createElement(swr_1.SWRConfig, { value: swrConfig }, props.children);
|
|
13
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from "axios";
|
|
2
|
-
export declare function createAxiosInstance(requestConfig?: AxiosRequestConfig): {
|
|
2
|
+
export declare function createAxiosInstance(baseURL: string, requestConfig?: AxiosRequestConfig): {
|
|
3
3
|
axiosInstance: import("axios").AxiosInstance;
|
|
4
4
|
axiosRequest: <Response>(ctx: any, url: string, method: import("axios").Method, body: object | null, query: object | null) => Promise<import("axios").AxiosResponse<Response, any>>;
|
|
5
5
|
useAxiosRequest: <Response extends Record<string, any> | boolean, RequestBody extends Record<string, any> | null, RequestQuery extends Record<string, any> | null, RequestPath extends Record<string, any> | null>(url: string, method: import("axios").Method, config: import("./types").RequestConfig<RequestBody, RequestQuery, RequestPath>) => [import("axios-hooks").ResponseValues<Response, any, any>, import("./types").Execute<Response, RequestBody, RequestQuery, RequestPath>];
|
|
@@ -5,14 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createAxiosInstance = createAxiosInstance;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
// eslint-disable-next-line import/no-cycle
|
|
9
8
|
const create_axios_request_1 = require("./create-axios-request");
|
|
10
9
|
const create_use_axios_request_1 = require("./create-use-axios-request");
|
|
11
|
-
function createAxiosInstance(requestConfig = {}) {
|
|
10
|
+
function createAxiosInstance(baseURL, requestConfig = {}) {
|
|
12
11
|
const instance = axios_1.default.create();
|
|
13
12
|
return {
|
|
14
13
|
axiosInstance: instance,
|
|
15
|
-
axiosRequest: (0, create_axios_request_1.createAxiosRequest)(instance, requestConfig),
|
|
16
|
-
useAxiosRequest: (0, create_use_axios_request_1.createUseAxiosRequest)(instance, requestConfig),
|
|
14
|
+
axiosRequest: (0, create_axios_request_1.createAxiosRequest)(baseURL, instance, requestConfig),
|
|
15
|
+
useAxiosRequest: (0, create_use_axios_request_1.createUseAxiosRequest)(baseURL, instance, requestConfig),
|
|
17
16
|
};
|
|
18
17
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig, Method } from "axios";
|
|
2
|
-
|
|
2
|
+
/** @deprecated use swr */
|
|
3
|
+
export declare const createAxiosRequest: (baseURL: string, axiosInstance: AxiosInstance, requestConfig: AxiosRequestConfig) => <Response>(ctx: any, url: string, method: Method, body: object | null, query: object | null) => Promise<import("axios").AxiosResponse<Response, any>>;
|
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createAxiosRequest = void 0;
|
|
4
4
|
const qs_1 = require("qs");
|
|
5
|
-
// eslint-disable-next-line import/no-cycle
|
|
6
|
-
const config_1 = require("../../config");
|
|
7
5
|
const BadRequestError_1 = require("../../errors/BadRequestError");
|
|
8
6
|
const ForbiddenError_1 = require("../../errors/ForbiddenError");
|
|
9
7
|
const NetworkError_1 = require("../../errors/NetworkError");
|
|
10
8
|
const UnauthorizedError_1 = require("../../errors/UnauthorizedError");
|
|
11
|
-
|
|
9
|
+
/** @deprecated use swr */
|
|
10
|
+
const createAxiosRequest = (baseURL, axiosInstance, requestConfig) => (ctx, url, method, body, query) => {
|
|
12
11
|
var _a;
|
|
13
12
|
return axiosInstance
|
|
14
13
|
.request({
|
|
15
|
-
baseURL
|
|
14
|
+
baseURL,
|
|
16
15
|
headers: ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.req) === null || _a === void 0 ? void 0 : _a.headers.cookie) ? { cookie: ctx.req.headers.cookie } : {},
|
|
17
16
|
...requestConfig,
|
|
18
17
|
url: query && Object.keys(query).length > 0 ? `${url}?${(0, qs_1.stringify)(query)}` : url,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig, Method } from "axios";
|
|
2
2
|
import { ResponseValues } from "axios-hooks";
|
|
3
3
|
import { Execute, RequestConfig } from "./types";
|
|
4
|
-
|
|
4
|
+
/** @deprecated use swr */
|
|
5
|
+
export declare const createUseAxiosRequest: (baseURL: string, axiosInstance: AxiosInstance, requestConfig: AxiosRequestConfig) => <Response extends Record<string, any> | boolean, RequestBody extends Record<string, any> | null, RequestQuery extends Record<string, any> | null, RequestPath extends Record<string, any> | null>(url: string, method: Method, config: RequestConfig<RequestBody, RequestQuery, RequestPath>) => [ResponseValues<Response, any, any>, Execute<Response, RequestBody, RequestQuery, RequestPath>];
|
|
@@ -3,9 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createUseAxiosRequest = void 0;
|
|
4
4
|
const axios_hooks_1 = require("axios-hooks");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const createUseAxiosRequest = (axiosInstance, requestConfig) => {
|
|
6
|
+
/** @deprecated use swr */
|
|
7
|
+
const createUseAxiosRequest = (baseURL, axiosInstance, requestConfig) => {
|
|
9
8
|
const useAxios = (0, axios_hooks_1.makeUseAxios)({
|
|
10
9
|
axios: axiosInstance,
|
|
11
10
|
defaultOptions: {
|
|
@@ -16,7 +15,7 @@ const createUseAxiosRequest = (axiosInstance, requestConfig) => {
|
|
|
16
15
|
// TODO Vejvis!!! nějaká demence s typem configu
|
|
17
16
|
const { body, query, skip } = config;
|
|
18
17
|
const [result, executeHandler] = useAxios({
|
|
19
|
-
baseURL
|
|
18
|
+
baseURL,
|
|
20
19
|
...requestConfig,
|
|
21
20
|
url,
|
|
22
21
|
method,
|
package/lib/layout/layout.js
CHANGED
|
@@ -9,7 +9,6 @@ const rem_1 = require("@uxf/styles/units/rem");
|
|
|
9
9
|
const loader_1 = require("@uxf/ui/loader/loader");
|
|
10
10
|
const head_1 = __importDefault(require("next/head"));
|
|
11
11
|
const react_1 = __importDefault(require("react"));
|
|
12
|
-
const config_1 = require("../../config");
|
|
13
12
|
const breadcrumbs_1 = require("./breadcrumbs");
|
|
14
13
|
const layout_container_1 = require("./layout-container");
|
|
15
14
|
const sidebar_1 = require("./sidebar");
|
|
@@ -20,7 +19,7 @@ const Layout = (props) => {
|
|
|
20
19
|
react_1.default.createElement(head_1.default, null,
|
|
21
20
|
react_1.default.createElement("meta", { content: "width=device-width, initial-scale=1", name: "viewport" }),
|
|
22
21
|
react_1.default.createElement("meta", { charSet: "utf-8" }),
|
|
23
|
-
react_1.default.createElement("title", null, `${props.title} | ${
|
|
22
|
+
react_1.default.createElement("title", null, `${props.title} | ${props.appName}`)),
|
|
24
23
|
react_1.default.createElement("div", { className: "uxf-cms-layout" },
|
|
25
24
|
react_1.default.createElement("div", { className: "uxf-cms-layout__wrapper" },
|
|
26
25
|
react_1.default.createElement(sidebar_1.Sidebar, { Logo: props.Logo, menuConfiguration: props.menuConfiguration }),
|
package/lib/layout/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/cms",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.48.1",
|
|
4
4
|
"description": "UXF Cms",
|
|
5
5
|
"author": "UXFans <dev@uxf.cz>",
|
|
6
6
|
"homepage": "https://gitlab.com/uxf-npm/cms#readme",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"@redux-devtools/extension": "3.3.0",
|
|
33
33
|
"@uxf/core": "11.47.0",
|
|
34
34
|
"@uxf/core-react": "11.47.0",
|
|
35
|
-
"@uxf/data-grid": "11.
|
|
36
|
-
"@uxf/form": "11.
|
|
35
|
+
"@uxf/data-grid": "11.48.0",
|
|
36
|
+
"@uxf/form": "11.48.0",
|
|
37
37
|
"@uxf/router": "11.46.0",
|
|
38
|
-
"@uxf/ui": "11.
|
|
39
|
-
"@uxf/wysiwyg": "11.
|
|
38
|
+
"@uxf/ui": "11.48.0",
|
|
39
|
+
"@uxf/wysiwyg": "11.48.0",
|
|
40
40
|
"axios": "1.7.5",
|
|
41
41
|
"axios-hooks": "5.0.2",
|
|
42
42
|
"es6-error": "4.1.1",
|
|
@@ -47,14 +47,15 @@ const url_1 = require("url");
|
|
|
47
47
|
const swr_1 = require("../../api/swr");
|
|
48
48
|
const api_1 = require("../../lib/api");
|
|
49
49
|
const restricted_page_1 = require("../../security/restricted-page");
|
|
50
|
-
|
|
50
|
+
// TODO use swr
|
|
51
|
+
const { axiosRequest } = (0, api_1.createAxiosInstance)("");
|
|
51
52
|
const dataGridLoader = (gridName, request) => {
|
|
52
53
|
return axiosRequest(null, `/api/cms/datagrid/${gridName}`, "get", null, request).then((r) => r.data);
|
|
53
54
|
};
|
|
54
55
|
exports.dataGridLoader = dataGridLoader;
|
|
55
56
|
const DefaultLayout = (props) => react_1.default.createElement("div", { ...props });
|
|
56
57
|
function GridPageComponent(props) {
|
|
57
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
58
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
58
59
|
// eslint-disable-next-line react/destructuring-assignment
|
|
59
60
|
const { query, AddIcon = react_1.default.createElement(icon_1.Icon, { name: "plus" }), onAddTitle = "Přidat záznam" } = props;
|
|
60
61
|
const Layout = (_b = (_a = props.ui) === null || _a === void 0 ? void 0 : _a.Layout) !== null && _b !== void 0 ? _b : DefaultLayout;
|
|
@@ -128,9 +129,9 @@ function GridPageComponent(props) {
|
|
|
128
129
|
},
|
|
129
130
|
}
|
|
130
131
|
: undefined);
|
|
131
|
-
return (react_1.default.createElement(Layout, { key: props.entityAlias, title: (
|
|
132
|
+
return (react_1.default.createElement(Layout, { appName: (_g = props.appName) !== null && _g !== void 0 ? _g : "", key: props.entityAlias, title: (_k = (_h = props.title) !== null && _h !== void 0 ? _h : (_j = props.metaSchema) === null || _j === void 0 ? void 0 : _j.title) !== null && _k !== void 0 ? _k : "" },
|
|
132
133
|
react_1.default.createElement("div", { className: "mb-10" },
|
|
133
|
-
react_1.default.createElement(data_grid_1.DataGrid, { NoRowsFallback: (
|
|
134
|
+
react_1.default.createElement(data_grid_1.DataGrid, { NoRowsFallback: (_l = props.ui) === null || _l === void 0 ? void 0 : _l.NoRowsFallback, SelectedRowsToolbarActions: (_m = props.ui) === null || _m === void 0 ? void 0 : _m.SelectedRowsToolbarActions, actionCell: actionCell, actions: actions, bodyCells: (_o = props.ui) === null || _o === void 0 ? void 0 : _o.BodyCells, customActions: cActions, data: data, error: error, filterHandlers: (_p = props.ui) === null || _p === void 0 ? void 0 : _p.FilterHandlers, gridName: props.entityAlias, isLoading: isLoading, isRowSelectable: props.selectable, onCsvDownload: (r) => window.open(`/api/cms/datagrid/export/${props.entityAlias}?${(0, qs_1.stringify)(r)}`), reload: reload, rowHeight: props.rowHeight, schema: props.gridSchema, state: state }))));
|
|
134
135
|
}
|
|
135
136
|
GridPageComponent.displayName = "GridPageComponent";
|
|
136
137
|
/** @deprecated - use custom DataGrid on project */
|
|
@@ -151,7 +152,7 @@ const GridPage = (config) => {
|
|
|
151
152
|
if ((0, is_nil_1.isNil)(schema) || (0, is_nil_1.isNil)(metadata)) {
|
|
152
153
|
return react_1.default.createElement("div", null, "Omlouv\u00E1me se, n\u011Bco se pokazilo.");
|
|
153
154
|
}
|
|
154
|
-
return (react_1.default.createElement(GridPageComponent, { AddIcon: config.AddIcon, customActions: config.customActions, entityAlias: config.entityAlias, getEditUrl: config.getEditUrl, getOpenUrl: config.getOpenUrl, gridSchema: schema, initialHiddenColumns: (_b = userConfigQuery.data) !== null && _b !== void 0 ? _b : [], initialUserConfig: config.initialUserConfig, loader: config.loader, metaSchema: metadata, onAdd: config.onAdd, onAddTitle: config.onAddTitle, onEdit: config.onEdit, onOpen: config.onOpen, onRemove: config.onRemove, query: router.query, rowHeight: config.rowHeight, selectable: config.selectable, title: config.title, ui: config.ui }));
|
|
155
|
+
return (react_1.default.createElement(GridPageComponent, { AddIcon: config.AddIcon, appName: config.appName, customActions: config.customActions, entityAlias: config.entityAlias, getEditUrl: config.getEditUrl, getOpenUrl: config.getOpenUrl, gridSchema: schema, initialHiddenColumns: (_b = userConfigQuery.data) !== null && _b !== void 0 ? _b : [], initialUserConfig: config.initialUserConfig, loader: config.loader, metaSchema: metadata, onAdd: config.onAdd, onAddTitle: config.onAddTitle, onEdit: config.onEdit, onOpen: config.onOpen, onRemove: config.onRemove, query: router.query, rowHeight: config.rowHeight, selectable: config.selectable, title: config.title, ui: config.ui }));
|
|
155
156
|
}
|
|
156
157
|
return (0, restricted_page_1.restrictedPage)(Component, { allowedRole: (_a = config.allowedRoles) !== null && _a !== void 0 ? _a : ["ROLE_ROOT"] });
|
|
157
158
|
};
|
|
@@ -20,6 +20,7 @@ type UIComponents = {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
export type GridPageComponentProps = {
|
|
23
|
+
appName?: string;
|
|
23
24
|
ui?: UIComponents;
|
|
24
25
|
entityAlias: string;
|
|
25
26
|
title?: string;
|
|
@@ -42,6 +43,7 @@ export type GridPageComponentProps = {
|
|
|
42
43
|
initialUserConfig?: DataGridUserConfig<any> | Nullish;
|
|
43
44
|
};
|
|
44
45
|
export type GridPageConfig<T extends object = any> = {
|
|
46
|
+
appName?: string;
|
|
45
47
|
ui?: UIComponents;
|
|
46
48
|
title?: string;
|
|
47
49
|
entityAlias: string;
|
|
@@ -6,6 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.useLoggedUser = useLoggedUser;
|
|
7
7
|
const swr_1 = __importDefault(require("swr"));
|
|
8
8
|
function useLoggedUser() {
|
|
9
|
-
const { data, error, isLoading } = (0, swr_1.default)("/api/cms/user"
|
|
9
|
+
const { data, error, isLoading } = (0, swr_1.default)("/api/cms/user", {
|
|
10
|
+
keepPreviousData: true,
|
|
11
|
+
// immutable
|
|
12
|
+
revalidateIfStale: false,
|
|
13
|
+
revalidateOnFocus: false,
|
|
14
|
+
revalidateOnReconnect: false,
|
|
15
|
+
});
|
|
10
16
|
return { data: data === null || data === void 0 ? void 0 : data.user, error, isLoading };
|
|
11
17
|
}
|
package/config/config.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type ConfigStore = {
|
|
2
|
-
"api-url": string;
|
|
3
|
-
"app-name": string;
|
|
4
|
-
};
|
|
5
|
-
export declare class Config {
|
|
6
|
-
private store;
|
|
7
|
-
set<T extends keyof ConfigStore>(key: T, value: ConfigStore[T]): Config;
|
|
8
|
-
get<T extends keyof ConfigStore>(key: T): ConfigStore[T];
|
|
9
|
-
}
|
|
10
|
-
export {};
|
package/config/config.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Config = void 0;
|
|
4
|
-
class Config {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.store = {
|
|
7
|
-
"app-name": "UXFans",
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
set(key, value) {
|
|
11
|
-
this.store[key] = value;
|
|
12
|
-
return this;
|
|
13
|
-
}
|
|
14
|
-
get(key) {
|
|
15
|
-
const value = this.store[key];
|
|
16
|
-
if (value === undefined) {
|
|
17
|
-
throw new Error(`Config attribute '${key}' is empty.`);
|
|
18
|
-
}
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.Config = Config;
|