@webiny/app-headless-cms 5.22.0-beta.1 → 5.22.1-beta.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/admin/components/ContentEntryForm/useContentEntryForm.js +12 -3
- package/admin/plugins/fieldRenderers/file/fileField.js +1 -2
- package/admin/plugins/fieldRenderers/ref/components/MissingEntryHelpText.d.ts +5 -0
- package/admin/plugins/fieldRenderers/ref/components/MissingEntryHelpText.js +30 -0
- package/admin/plugins/fieldRenderers/ref/components/NewRefEntryFormDialog.d.ts +9 -0
- package/admin/plugins/fieldRenderers/ref/components/NewRefEntryFormDialog.js +147 -0
- package/admin/plugins/fieldRenderers/ref/components/createEntryUrl.d.ts +1 -0
- package/admin/plugins/fieldRenderers/ref/components/createEntryUrl.js +3 -0
- package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntry.d.ts +11 -0
- package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntry.js +30 -0
- package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntryDialog.d.ts +10 -0
- package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntryDialog.js +28 -0
- package/admin/views/contentEntries/ContentEntriesContext.d.ts +7 -7
- package/admin/views/contentEntries/ContentEntriesContext.js +3 -1
- package/admin/views/contentEntries/ContentEntry/ContentEntryContext.d.ts +10 -3
- package/admin/views/contentEntries/ContentEntry/ContentEntryContext.js +27 -7
- package/package.json +17 -17
|
@@ -128,7 +128,10 @@ export function useContentEntryForm(params) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
resetInvalidFieldValues();
|
|
131
|
-
|
|
131
|
+
|
|
132
|
+
if (typeof params.onSubmit !== "function") {
|
|
133
|
+
GQLCache.addEntryToListCache(contentModel, cache, entry, listQueryVariables);
|
|
134
|
+
}
|
|
132
135
|
}
|
|
133
136
|
});
|
|
134
137
|
|
|
@@ -149,7 +152,13 @@ export function useContentEntryForm(params) {
|
|
|
149
152
|
case 10:
|
|
150
153
|
resetInvalidFieldValues();
|
|
151
154
|
showSnackbar("".concat(contentModel.name, " entry created successfully!"));
|
|
152
|
-
|
|
155
|
+
|
|
156
|
+
if (typeof params.onSubmit === "function") {
|
|
157
|
+
params.onSubmit(entry);
|
|
158
|
+
} else {
|
|
159
|
+
goToRevision(entry.id);
|
|
160
|
+
}
|
|
161
|
+
|
|
153
162
|
return _context.abrupt("return", entry);
|
|
154
163
|
|
|
155
164
|
case 14:
|
|
@@ -243,7 +252,7 @@ export function useContentEntryForm(params) {
|
|
|
243
252
|
GQLCache.updateLatestRevisionInListCache(contentModel, cache, newRevision, listQueryVariables);
|
|
244
253
|
GQLCache.addRevisionToRevisionsCache(contentModel, cache, newRevision);
|
|
245
254
|
showSnackbar("A new revision was created!");
|
|
246
|
-
|
|
255
|
+
goToRevision(newRevision.id);
|
|
247
256
|
}
|
|
248
257
|
});
|
|
249
258
|
|
|
@@ -7,7 +7,6 @@ import { i18n } from "@webiny/app/i18n";
|
|
|
7
7
|
import { Cell, Grid } from "@webiny/ui/Grid";
|
|
8
8
|
import { FileManager } from "@webiny/app-admin/components";
|
|
9
9
|
import File from "./File";
|
|
10
|
-
import { FormElementMessage } from "@webiny/ui/FormElementMessage";
|
|
11
10
|
var t = i18n.ns("app-headless-cms/admin/fields/file");
|
|
12
11
|
var plugin = {
|
|
13
12
|
type: "cms-editor-field-renderer",
|
|
@@ -57,7 +56,7 @@ var plugin = {
|
|
|
57
56
|
description: field.helpText
|
|
58
57
|
}));
|
|
59
58
|
});
|
|
60
|
-
})
|
|
59
|
+
})));
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2;
|
|
4
|
+
|
|
5
|
+
import React from "react";
|
|
6
|
+
import styled from "@emotion/styled";
|
|
7
|
+
import { Typography } from "@webiny/ui/Typography";
|
|
8
|
+
import { Link } from "@webiny/react-router";
|
|
9
|
+
import { createNewEntryUrl } from "./createEntryUrl";
|
|
10
|
+
import { i18n } from "@webiny/app/i18n";
|
|
11
|
+
var t = i18n.ns("app-headless-cms/admin/fields/ref");
|
|
12
|
+
var missingEntryLabel = t(_templateObject || (_templateObject = _taggedTemplateLiteral(["If you can't find the intended reference value in the target model,\n please close this dialog and populate the {newEntryLink} in the target model first."])));
|
|
13
|
+
var HelpTextTypography = /*#__PURE__*/styled(Typography, {
|
|
14
|
+
label: "HelpTextTypography",
|
|
15
|
+
target: "ex67440"
|
|
16
|
+
})("&{display:inline-block;color:var(--mdc-theme-text-secondary-on-background) !important;}");
|
|
17
|
+
|
|
18
|
+
var MissingEntryHelpText = function MissingEntryHelpText(_ref) {
|
|
19
|
+
var refModelId = _ref.refModelId;
|
|
20
|
+
return /*#__PURE__*/React.createElement(HelpTextTypography, {
|
|
21
|
+
use: "caption"
|
|
22
|
+
}, missingEntryLabel({
|
|
23
|
+
newEntryLink: /*#__PURE__*/React.createElement(Link, {
|
|
24
|
+
to: createNewEntryUrl(refModelId),
|
|
25
|
+
target: "_blank"
|
|
26
|
+
}, t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["entry"]))))
|
|
27
|
+
}));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default MissingEntryHelpText;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const NewEntryButton: () => JSX.Element;
|
|
3
|
+
interface NewRefEntryProps {
|
|
4
|
+
modelId: string;
|
|
5
|
+
children: React.ReactElement;
|
|
6
|
+
onChange: Function;
|
|
7
|
+
}
|
|
8
|
+
declare const NewRefEntryFormDialog: React.FC<NewRefEntryProps>;
|
|
9
|
+
export default NewRefEntryFormDialog;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
|
+
|
|
4
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
5
|
+
|
|
6
|
+
import React, { useCallback, useState } from "react";
|
|
7
|
+
import get from "lodash/get";
|
|
8
|
+
import { css } from "emotion";
|
|
9
|
+
import styled from "@emotion/styled";
|
|
10
|
+
import { Dialog, DialogActions, DialogButton, DialogCancel, DialogContent, DialogTitle } from "@webiny/ui/Dialog";
|
|
11
|
+
import { ButtonDefault, ButtonIcon } from "@webiny/ui/Button";
|
|
12
|
+
import { useSnackbar } from "@webiny/app-admin";
|
|
13
|
+
import { i18n } from "@webiny/app/i18n";
|
|
14
|
+
import { ReactComponent as AddIcon } from "@webiny/app-admin/assets/icons/add-18px.svg";
|
|
15
|
+
import { Provider as ContentEntriesProvider } from "../../../../views/contentEntries/ContentEntriesContext";
|
|
16
|
+
import { Provider as ContentEntryProvider } from "../../../../views/contentEntries/ContentEntry/ContentEntryContext";
|
|
17
|
+
import { ContentEntryForm } from "../../../../components/ContentEntryForm/ContentEntryForm";
|
|
18
|
+
import { useQuery } from "../../../../hooks";
|
|
19
|
+
import { GET_CONTENT_MODEL } from "../../../../graphql/contentModels";
|
|
20
|
+
import { useContentEntry } from "../../../../views/contentEntries/hooks/useContentEntry";
|
|
21
|
+
import { useNewRefEntryDialog } from "../hooks/useNewRefEntryDialog";
|
|
22
|
+
var t = i18n.ns("app-headless-cms/admin/fields/ref");
|
|
23
|
+
var dialogContentStyles = /*#__PURE__*/css("width:786px;label:dialogContentStyles;");
|
|
24
|
+
var dialogContainerStyles = /*#__PURE__*/css("&.mdc-dialog{z-index:17;}label:dialogContainerStyles;");
|
|
25
|
+
|
|
26
|
+
var EntryForm = function EntryForm(_ref) {
|
|
27
|
+
var onCreate = _ref.onCreate;
|
|
28
|
+
|
|
29
|
+
var _useContentEntry = useContentEntry(),
|
|
30
|
+
setFormRef = _useContentEntry.setFormRef,
|
|
31
|
+
contentModel = _useContentEntry.contentModel;
|
|
32
|
+
|
|
33
|
+
return /*#__PURE__*/React.createElement(ContentEntryForm, {
|
|
34
|
+
contentModel: contentModel,
|
|
35
|
+
onSubmit: onCreate,
|
|
36
|
+
onForm: function onForm(form) {
|
|
37
|
+
return setFormRef(form);
|
|
38
|
+
},
|
|
39
|
+
entry: {}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var DialogSaveButton = function DialogSaveButton() {
|
|
44
|
+
var _useContentEntry2 = useContentEntry(),
|
|
45
|
+
form = _useContentEntry2.form;
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/React.createElement(DialogButton, {
|
|
48
|
+
onClick: function onClick() {
|
|
49
|
+
return form.current.submit();
|
|
50
|
+
}
|
|
51
|
+
}, t(_templateObject || (_templateObject = _taggedTemplateLiteral(["Save"]))));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var DefaultButton = /*#__PURE__*/styled(ButtonDefault, {
|
|
55
|
+
label: "DefaultButton",
|
|
56
|
+
target: "eantjap0"
|
|
57
|
+
})("margin-left:32px;");
|
|
58
|
+
export var NewEntryButton = function NewEntryButton() {
|
|
59
|
+
var _useNewRefEntryDialog = useNewRefEntryDialog(),
|
|
60
|
+
setOpen = _useNewRefEntryDialog.setOpen;
|
|
61
|
+
|
|
62
|
+
return /*#__PURE__*/React.createElement(DefaultButton, {
|
|
63
|
+
small: true,
|
|
64
|
+
onClick: function onClick() {
|
|
65
|
+
return setOpen(true);
|
|
66
|
+
}
|
|
67
|
+
}, /*#__PURE__*/React.createElement(ButtonIcon, {
|
|
68
|
+
icon: /*#__PURE__*/React.createElement(AddIcon, null)
|
|
69
|
+
}), t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["New Entry"]))));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
var NewRefEntryFormDialog = function NewRefEntryFormDialog(_ref2) {
|
|
73
|
+
var modelId = _ref2.modelId,
|
|
74
|
+
children = _ref2.children,
|
|
75
|
+
onChange = _ref2.onChange;
|
|
76
|
+
|
|
77
|
+
var _useState = useState(),
|
|
78
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
79
|
+
contentModel = _useState2[0],
|
|
80
|
+
setContentModel = _useState2[1];
|
|
81
|
+
|
|
82
|
+
var _useSnackbar = useSnackbar(),
|
|
83
|
+
showSnackbar = _useSnackbar.showSnackbar;
|
|
84
|
+
|
|
85
|
+
useQuery(GET_CONTENT_MODEL, {
|
|
86
|
+
skip: !modelId,
|
|
87
|
+
variables: {
|
|
88
|
+
modelId: modelId
|
|
89
|
+
},
|
|
90
|
+
onCompleted: function onCompleted(data) {
|
|
91
|
+
var contentModelData = get(data, "getContentModel.data");
|
|
92
|
+
|
|
93
|
+
if (contentModelData) {
|
|
94
|
+
return setContentModel(contentModelData);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
showSnackbar(t(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Could not load content for model \"{modelId}\". Redirecting..."])))({
|
|
98
|
+
modelId: modelId
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
var _useNewRefEntryDialog2 = useNewRefEntryDialog(),
|
|
104
|
+
open = _useNewRefEntryDialog2.open,
|
|
105
|
+
setOpen = _useNewRefEntryDialog2.setOpen;
|
|
106
|
+
|
|
107
|
+
var hideDialog = useCallback(function () {
|
|
108
|
+
return setOpen(false);
|
|
109
|
+
}, []);
|
|
110
|
+
var onCreate = useCallback(function (entry) {
|
|
111
|
+
onChange(entry);
|
|
112
|
+
/*
|
|
113
|
+
Close the modal
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
setOpen(false);
|
|
117
|
+
}, [modelId, onChange]);
|
|
118
|
+
|
|
119
|
+
if (!contentModel) {
|
|
120
|
+
return children;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return /*#__PURE__*/React.createElement(ContentEntriesProvider, {
|
|
124
|
+
contentModel: contentModel,
|
|
125
|
+
key: contentModel.modelId,
|
|
126
|
+
insideDialog: true
|
|
127
|
+
}, /*#__PURE__*/React.createElement(ContentEntryProvider, {
|
|
128
|
+
isNewEntry: function isNewEntry() {
|
|
129
|
+
return true;
|
|
130
|
+
},
|
|
131
|
+
getContentId: function getContentId() {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}, /*#__PURE__*/React.createElement(Dialog, {
|
|
135
|
+
open: open,
|
|
136
|
+
onClose: hideDialog,
|
|
137
|
+
className: dialogContainerStyles
|
|
138
|
+
}, /*#__PURE__*/React.createElement(DialogTitle, null, t(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["New {modelName} Entry"])))({
|
|
139
|
+
modelName: contentModel.name
|
|
140
|
+
})), /*#__PURE__*/React.createElement(DialogContent, {
|
|
141
|
+
className: dialogContentStyles
|
|
142
|
+
}, /*#__PURE__*/React.createElement(EntryForm, {
|
|
143
|
+
onCreate: onCreate
|
|
144
|
+
})), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(DialogCancel, null, t(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Cancel"])))), /*#__PURE__*/React.createElement(DialogSaveButton, null))), children));
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export default NewRefEntryFormDialog;
|
|
@@ -2,4 +2,7 @@ export var createEntryUrl = function createEntryUrl(_ref) {
|
|
|
2
2
|
var modelId = _ref.modelId,
|
|
3
3
|
id = _ref.id;
|
|
4
4
|
return "/cms/content-entries/".concat(modelId, "?id=").concat(encodeURIComponent(id));
|
|
5
|
+
};
|
|
6
|
+
export var createNewEntryUrl = function createNewEntryUrl(modelId) {
|
|
7
|
+
return "/cms/content-entries/".concat(modelId, "?new=true");
|
|
5
8
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CmsEditorField } from "../../../../../types";
|
|
2
|
+
interface UseNewRefEntryParams {
|
|
3
|
+
field: CmsEditorField;
|
|
4
|
+
}
|
|
5
|
+
interface UseNewRefEntry {
|
|
6
|
+
renderNewEntryModal: boolean;
|
|
7
|
+
renderedInPreviewTab: boolean;
|
|
8
|
+
refModelId: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const useNewRefEntry: ({ field }: UseNewRefEntryParams) => UseNewRefEntry;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { Context as ContentEntriesContext } from "../../../../views/contentEntries/ContentEntriesContext";
|
|
3
|
+
export var useNewRefEntry = function useNewRefEntry(_ref) {
|
|
4
|
+
var field = _ref.field;
|
|
5
|
+
var refModelId = field.settings.models[0].modelId;
|
|
6
|
+
var contentEntriesContextValue = useContext(ContentEntriesContext);
|
|
7
|
+
/**
|
|
8
|
+
* We don't wrap the "ContentEntryForm" with "ContentEntriesContextProvider"
|
|
9
|
+
* when rendering it inside content model editor's preview tab.
|
|
10
|
+
*
|
|
11
|
+
* And we also don't want to have new ref field Dialog in the preview tab.
|
|
12
|
+
* Therefore, we check for "contentEntriesContextValue" to know that we're inside preview tab.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
var renderedInPreviewTab = contentEntriesContextValue === null;
|
|
16
|
+
var renderNewEntryModal;
|
|
17
|
+
|
|
18
|
+
if (renderedInPreviewTab) {
|
|
19
|
+
renderNewEntryModal = false;
|
|
20
|
+
} else {
|
|
21
|
+
var insideDialog = contentEntriesContextValue.insideDialog;
|
|
22
|
+
renderNewEntryModal = !insideDialog;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
renderNewEntryModal: renderNewEntryModal,
|
|
27
|
+
renderedInPreviewTab: renderedInPreviewTab,
|
|
28
|
+
refModelId: refModelId
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface NewRefEntryDialogContextValue {
|
|
3
|
+
open: boolean;
|
|
4
|
+
setOpen: Function;
|
|
5
|
+
}
|
|
6
|
+
export declare const NewRefEntryDialogContext: React.Context<NewRefEntryDialogContextValue>;
|
|
7
|
+
export declare const NewRefEntryDialogContextProvider: ({ children }: {
|
|
8
|
+
children: any;
|
|
9
|
+
}) => JSX.Element;
|
|
10
|
+
export declare const useNewRefEntryDialog: () => NewRefEntryDialogContextValue;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { createContext, useContext, useState } from "react";
|
|
3
|
+
export var NewRefEntryDialogContext = /*#__PURE__*/createContext(null);
|
|
4
|
+
export var NewRefEntryDialogContextProvider = function NewRefEntryDialogContextProvider(_ref) {
|
|
5
|
+
var children = _ref.children;
|
|
6
|
+
|
|
7
|
+
var _useState = useState(false),
|
|
8
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
9
|
+
open = _useState2[0],
|
|
10
|
+
setOpen = _useState2[1];
|
|
11
|
+
|
|
12
|
+
return /*#__PURE__*/React.createElement(NewRefEntryDialogContext.Provider, {
|
|
13
|
+
value: {
|
|
14
|
+
open: open,
|
|
15
|
+
setOpen: setOpen
|
|
16
|
+
}
|
|
17
|
+
}, children);
|
|
18
|
+
};
|
|
19
|
+
export var useNewRefEntryDialog = function useNewRefEntryDialog() {
|
|
20
|
+
var _useContext = useContext(NewRefEntryDialogContext),
|
|
21
|
+
open = _useContext.open,
|
|
22
|
+
setOpen = _useContext.setOpen;
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
open: open,
|
|
26
|
+
setOpen: setOpen
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -13,12 +13,12 @@ export interface ContentEntriesContext {
|
|
|
13
13
|
canCreate: boolean;
|
|
14
14
|
listQueryVariables: ListQueryVariables;
|
|
15
15
|
setListQueryVariables: Dispatch<SetStateAction<ListQueryVariables>>;
|
|
16
|
+
insideDialog?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export declare const Context: React.Context<ContentEntriesContext>;
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
19
|
+
export interface ContentEntriesContextProviderProps {
|
|
20
|
+
contentModel: CmsEditorContentModel;
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
insideDialog?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const Provider: React.FC<ContentEntriesContextProviderProps>;
|
|
@@ -17,7 +17,8 @@ var SORTERS = [{
|
|
|
17
17
|
export var Context = /*#__PURE__*/React.createContext(null);
|
|
18
18
|
export var Provider = function Provider(_ref) {
|
|
19
19
|
var contentModel = _ref.contentModel,
|
|
20
|
-
children = _ref.children
|
|
20
|
+
children = _ref.children,
|
|
21
|
+
insideDialog = _ref.insideDialog;
|
|
21
22
|
|
|
22
23
|
var _useSecurity = useSecurity(),
|
|
23
24
|
identity = _useSecurity.identity;
|
|
@@ -65,6 +66,7 @@ export var Provider = function Provider(_ref) {
|
|
|
65
66
|
}]);
|
|
66
67
|
}, [contentModel.modelId]);
|
|
67
68
|
var value = {
|
|
69
|
+
insideDialog: insideDialog,
|
|
68
70
|
contentModel: contentModel,
|
|
69
71
|
sorters: sorters,
|
|
70
72
|
canCreate: canCreate,
|
|
@@ -20,9 +20,16 @@ export interface ContentEntryContext extends ContentEntriesContext {
|
|
|
20
20
|
showEmptyView: boolean;
|
|
21
21
|
}
|
|
22
22
|
export declare const Context: React.Context<ContentEntryContext>;
|
|
23
|
+
export interface ContentEntryContextProviderProps extends GetContentEntryFormType {
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
interface GetContentEntryFormType {
|
|
27
|
+
getContentId?: () => string | null;
|
|
28
|
+
isNewEntry?: () => boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare const useContentEntryProviderProps: () => GetContentEntryFormType;
|
|
23
31
|
export declare const Provider: {
|
|
24
|
-
({ children }:
|
|
25
|
-
children: any;
|
|
26
|
-
}): JSX.Element;
|
|
32
|
+
({ children, isNewEntry, getContentId }: ContentEntryContextProviderProps): JSX.Element;
|
|
27
33
|
displayName: string;
|
|
28
34
|
};
|
|
35
|
+
export {};
|
|
@@ -9,8 +9,29 @@ import { useQuery } from "../../../hooks";
|
|
|
9
9
|
import { useContentEntries } from "../hooks/useContentEntries";
|
|
10
10
|
import { parseIdentifier } from "@webiny/utils";
|
|
11
11
|
export var Context = /*#__PURE__*/React.createContext(null);
|
|
12
|
+
export var useContentEntryProviderProps = function useContentEntryProviderProps() {
|
|
13
|
+
var _useRouter = useRouter(),
|
|
14
|
+
location = _useRouter.location;
|
|
15
|
+
|
|
16
|
+
var query = new URLSearchParams(location.search);
|
|
17
|
+
|
|
18
|
+
var isNewEntry = function isNewEntry() {
|
|
19
|
+
return query.get("new") === "true";
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var getContentId = function getContentId() {
|
|
23
|
+
return query.get("id");
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
getContentId: getContentId,
|
|
28
|
+
isNewEntry: isNewEntry
|
|
29
|
+
};
|
|
30
|
+
};
|
|
12
31
|
export var Provider = function Provider(_ref) {
|
|
13
|
-
var children = _ref.children
|
|
32
|
+
var children = _ref.children,
|
|
33
|
+
isNewEntry = _ref.isNewEntry,
|
|
34
|
+
getContentId = _ref.getContentId;
|
|
14
35
|
|
|
15
36
|
var _useContentEntries = useContentEntries(),
|
|
16
37
|
contentModel = _useContentEntries.contentModel,
|
|
@@ -22,9 +43,8 @@ export var Provider = function Provider(_ref) {
|
|
|
22
43
|
var formRef = useRef(null);
|
|
23
44
|
var tabsRef = useRef(null);
|
|
24
45
|
|
|
25
|
-
var
|
|
26
|
-
history =
|
|
27
|
-
location = _useRouter.location;
|
|
46
|
+
var _useRouter2 = useRouter(),
|
|
47
|
+
history = _useRouter2.history;
|
|
28
48
|
|
|
29
49
|
var _useSnackbar = useSnackbar(),
|
|
30
50
|
showSnackbar = _useSnackbar.showSnackbar;
|
|
@@ -34,9 +54,9 @@ export var Provider = function Provider(_ref) {
|
|
|
34
54
|
isLoading = _useState2[0],
|
|
35
55
|
setLoading = _useState2[1];
|
|
36
56
|
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var contentId =
|
|
57
|
+
var contentEntryProviderProps = useContentEntryProviderProps();
|
|
58
|
+
var newEntry = typeof isNewEntry === "function" ? isNewEntry() : contentEntryProviderProps.isNewEntry();
|
|
59
|
+
var contentId = typeof getContentId === "function" ? getContentId() : contentEntryProviderProps.getContentId();
|
|
40
60
|
var revisionId = contentId ? decodeURIComponent(contentId) : null;
|
|
41
61
|
var entryId = null;
|
|
42
62
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-headless-cms",
|
|
3
|
-
"version": "5.22.
|
|
3
|
+
"version": "5.22.1-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
"@fortawesome/react-fontawesome": "0.1.16",
|
|
25
25
|
"@svgr/webpack": "6.2.0",
|
|
26
26
|
"@types/react": "16.14.2",
|
|
27
|
-
"@webiny/app": "5.22.
|
|
28
|
-
"@webiny/app-admin": "5.22.
|
|
29
|
-
"@webiny/app-graphql-playground": "5.22.
|
|
30
|
-
"@webiny/app-i18n": "5.22.
|
|
31
|
-
"@webiny/app-plugin-admin-welcome-screen": "5.22.
|
|
32
|
-
"@webiny/app-security": "5.22.
|
|
33
|
-
"@webiny/error": "5.22.
|
|
34
|
-
"@webiny/form": "5.22.
|
|
35
|
-
"@webiny/plugins": "5.22.
|
|
36
|
-
"@webiny/react-router": "5.22.
|
|
37
|
-
"@webiny/ui": "5.22.
|
|
38
|
-
"@webiny/utils": "5.22.
|
|
39
|
-
"@webiny/validation": "5.22.
|
|
27
|
+
"@webiny/app": "5.22.1-beta.0",
|
|
28
|
+
"@webiny/app-admin": "5.22.1-beta.0",
|
|
29
|
+
"@webiny/app-graphql-playground": "5.22.1-beta.0",
|
|
30
|
+
"@webiny/app-i18n": "5.22.1-beta.0",
|
|
31
|
+
"@webiny/app-plugin-admin-welcome-screen": "5.22.1-beta.0",
|
|
32
|
+
"@webiny/app-security": "5.22.1-beta.0",
|
|
33
|
+
"@webiny/error": "5.22.1-beta.0",
|
|
34
|
+
"@webiny/form": "5.22.1-beta.0",
|
|
35
|
+
"@webiny/plugins": "5.22.1-beta.0",
|
|
36
|
+
"@webiny/react-router": "5.22.1-beta.0",
|
|
37
|
+
"@webiny/ui": "5.22.1-beta.0",
|
|
38
|
+
"@webiny/utils": "5.22.1-beta.0",
|
|
39
|
+
"@webiny/validation": "5.22.1-beta.0",
|
|
40
40
|
"apollo-cache": "1.3.5",
|
|
41
41
|
"apollo-client": "2.6.10",
|
|
42
42
|
"apollo-link": "1.2.14",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"@babel/preset-env": "^7.16.4",
|
|
69
69
|
"@babel/preset-react": "^7.16.0",
|
|
70
70
|
"@babel/preset-typescript": "^7.16.0",
|
|
71
|
-
"@webiny/cli": "^5.22.
|
|
72
|
-
"@webiny/project-utils": "^5.22.
|
|
71
|
+
"@webiny/cli": "^5.22.1-beta.0",
|
|
72
|
+
"@webiny/project-utils": "^5.22.1-beta.0",
|
|
73
73
|
"babel-plugin-emotion": "^9.2.8",
|
|
74
74
|
"babel-plugin-lodash": "^3.3.4",
|
|
75
75
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
]
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "37f7c3d99baa1793fe29221b5eca40fe92cfe190"
|
|
105
105
|
}
|