@webiny/app-headless-cms 5.19.0-beta.6 → 5.20.0-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/FieldEditor/Field.d.ts +8 -1
- package/admin/components/FieldEditor/Field.js +3 -1
- package/admin/icons/clone.svg +14 -0
- package/admin/plugins/transformers/dateTransformer.js +27 -11
- package/admin/views/contentEntries/ContentEntry/prepareFormData.d.ts +1 -1
- package/admin/views/contentEntries/ContentEntry/prepareFormData.js +10 -9
- package/admin/views/contentModels/CloneContentModelDialog.d.ts +11 -0
- package/admin/views/contentModels/CloneContentModelDialog.js +204 -0
- package/admin/views/contentModels/ContentModels.js +22 -1
- package/admin/views/contentModels/ContentModelsDataList.d.ts +3 -1
- package/admin/views/contentModels/ContentModelsDataList.js +17 -5
- package/admin/views/contentModels/NewContentModelDialog.js +1 -0
- package/admin/viewsGraphql.d.ts +1 -0
- package/admin/viewsGraphql.js +3 -2
- package/package.json +17 -17
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
import { CmsEditorField } from "../../../types";
|
|
3
|
+
export interface Props {
|
|
4
|
+
field: CmsEditorField;
|
|
5
|
+
onDelete: Function;
|
|
6
|
+
onEdit: Function;
|
|
7
|
+
parent?: CmsEditorField;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
3
10
|
export default _default;
|
|
@@ -133,12 +133,14 @@ var Field = function Field(props) {
|
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
var isTitleField = field.fieldId === data.titleFieldId && !parent;
|
|
137
|
+
console.log(field.fieldId, isTitleField, parent);
|
|
136
138
|
var lockedFields = data.lockedFields || [];
|
|
137
139
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(FieldContainer, null, /*#__PURE__*/React.createElement(Info, null, /*#__PURE__*/React.createElement(Typography, {
|
|
138
140
|
use: "subtitle1"
|
|
139
141
|
}, field.label), /*#__PURE__*/React.createElement(Typography, {
|
|
140
142
|
use: "caption"
|
|
141
|
-
}, fieldPlugin.field.label, " ", field.multipleValues && /*#__PURE__*/React.createElement(React.Fragment, null, "(", t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["multiple values"]))), ")"),
|
|
143
|
+
}, fieldPlugin.field.label, " ", field.multipleValues && /*#__PURE__*/React.createElement(React.Fragment, null, "(", t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["multiple values"]))), ")"), isTitleField && /*#__PURE__*/React.createElement(React.Fragment, null, "(", t(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["entry title"]))), ")"))), /*#__PURE__*/React.createElement(Actions, null, /*#__PURE__*/React.createElement(IconButton, {
|
|
142
144
|
"data-testid": "cms.editor.edit-field",
|
|
143
145
|
icon: /*#__PURE__*/React.createElement(EditIcon, null),
|
|
144
146
|
onClick: function onClick() {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px"
|
|
4
|
+
height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
|
|
5
|
+
<g id="Bounding_Boxes" display="none">
|
|
6
|
+
<path display="inline" fill="none" d="M0,0h24v24H0V0z"/>
|
|
7
|
+
</g>
|
|
8
|
+
<g id="Rounded">
|
|
9
|
+
<path d="M3,6L3,6C2.45,6,2,6.45,2,7v13c0,1.1,0.9,2,2,2h13c0.55,0,1-0.45,1-1v0c0-0.55-0.45-1-1-1H5c-0.55,0-1-0.45-1-1V7
|
|
10
|
+
C4,6.45,3.55,6,3,6z M20,2H8C6.9,2,6,2.9,6,4v12c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V4C22,2.9,21.1,2,20,2z M18,11h-3v3
|
|
11
|
+
c0,0.55-0.45,1-1,1h0c-0.55,0-1-0.45-1-1v-3h-3c-0.55,0-1-0.45-1-1v0c0-0.55,0.45-1,1-1h3V6c0-0.55,0.45-1,1-1h0c0.55,0,1,0.45,1,1
|
|
12
|
+
v3h3c0.55,0,1,0.45,1,1v0C19,10.55,18.55,11,18,11z"/>
|
|
13
|
+
</g>
|
|
14
|
+
</svg>
|
|
@@ -13,6 +13,10 @@ var throwTransformError = function throwTransformError(params) {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
var dateOnly = function dateOnly(value) {
|
|
16
|
+
if (!value) {
|
|
17
|
+
return new Date().toISOString().substr(0, 10);
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
try {
|
|
17
21
|
var date = new Date(value).toISOString();
|
|
18
22
|
return date.substr(0, 10);
|
|
@@ -28,7 +32,9 @@ var dateOnly = function dateOnly(value) {
|
|
|
28
32
|
var extractTimeZone = function extractTimeZone(value) {
|
|
29
33
|
var result;
|
|
30
34
|
|
|
31
|
-
if (value
|
|
35
|
+
if (!value) {
|
|
36
|
+
return [new Date().toISOString(), "00:00"];
|
|
37
|
+
} else if (value.includes("+")) {
|
|
32
38
|
result = value.split("+");
|
|
33
39
|
} else {
|
|
34
40
|
result = value.split("-");
|
|
@@ -44,7 +50,9 @@ var extractTimeZone = function extractTimeZone(value) {
|
|
|
44
50
|
};
|
|
45
51
|
|
|
46
52
|
var extractTime = function extractTime(value) {
|
|
47
|
-
if (value
|
|
53
|
+
if (!value) {
|
|
54
|
+
return "00:00:00";
|
|
55
|
+
} else if (value.includes(":") === false) {
|
|
48
56
|
throw new WebinyError("Time value is missing : separators.", "TIME_ERROR", {
|
|
49
57
|
value: value
|
|
50
58
|
});
|
|
@@ -60,7 +68,11 @@ var extractTime = function extractTime(value) {
|
|
|
60
68
|
};
|
|
61
69
|
|
|
62
70
|
var dateTimeWithTimezone = function dateTimeWithTimezone(value) {
|
|
63
|
-
if (value
|
|
71
|
+
if (!value) {
|
|
72
|
+
var _date = new Date().toISOString();
|
|
73
|
+
|
|
74
|
+
return _date.replace(/\.([0-9]+)Z/, "+00:00");
|
|
75
|
+
} else if (value.includes("T") === false) {
|
|
64
76
|
return value;
|
|
65
77
|
}
|
|
66
78
|
|
|
@@ -91,7 +103,9 @@ var dateTimeWithTimezone = function dateTimeWithTimezone(value) {
|
|
|
91
103
|
};
|
|
92
104
|
|
|
93
105
|
var dateTimeWithoutTimezone = function dateTimeWithoutTimezone(value) {
|
|
94
|
-
if (value
|
|
106
|
+
if (!value) {
|
|
107
|
+
return new Date().toISOString();
|
|
108
|
+
} else if (value.includes(" ") === false) {
|
|
95
109
|
return value;
|
|
96
110
|
}
|
|
97
111
|
|
|
@@ -106,8 +120,16 @@ var dateTimeWithoutTimezone = function dateTimeWithoutTimezone(value) {
|
|
|
106
120
|
}
|
|
107
121
|
};
|
|
108
122
|
|
|
123
|
+
var time = function time(value) {
|
|
124
|
+
if (!value) {
|
|
125
|
+
return "00:00:00";
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return extractTime(value);
|
|
129
|
+
};
|
|
130
|
+
|
|
109
131
|
var transformers = {
|
|
110
|
-
time:
|
|
132
|
+
time: time,
|
|
111
133
|
date: dateOnly,
|
|
112
134
|
dateTimeWithoutTimezone: dateTimeWithoutTimezone,
|
|
113
135
|
dateTimeWithTimezone: dateTimeWithTimezone
|
|
@@ -120,12 +142,6 @@ export default (function () {
|
|
|
120
142
|
transform: function transform(value, field) {
|
|
121
143
|
// check types in packages/app-headless-cms/src/admin/plugins/fieldRenderers/dateTime/dateTimeField.tsx
|
|
122
144
|
var type = field.settings.type;
|
|
123
|
-
|
|
124
|
-
if (!value) {
|
|
125
|
-
console.log("Field \"".concat(field.fieldId, "\" has no value."));
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
145
|
var transform = transformers[type];
|
|
130
146
|
|
|
131
147
|
if (!transform) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CmsEditorContentModel } from "../../../../types";
|
|
2
|
-
export declare const prepareFormData: (
|
|
2
|
+
export declare const prepareFormData: (input: Record<string, any>, model: CmsEditorContentModel) => Record<string, any>;
|
|
@@ -63,17 +63,18 @@ var createTransformers = function createTransformers(fields) {
|
|
|
63
63
|
return transformers;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
export var prepareFormData = function prepareFormData(
|
|
66
|
+
export var prepareFormData = function prepareFormData(input, model) {
|
|
67
67
|
var transformers = createTransformers(model.fields);
|
|
68
|
-
return Object.keys(
|
|
69
|
-
var value =
|
|
68
|
+
return Object.keys(transformers).reduce(function (output, key) {
|
|
69
|
+
var value = input[key];
|
|
70
|
+
var transform = transformers[key];
|
|
71
|
+
var transformedValue = transform(value);
|
|
70
72
|
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
return acc;
|
|
73
|
+
if (transformedValue === undefined) {
|
|
74
|
+
return output;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
-
},
|
|
77
|
+
output[key] = transformedValue;
|
|
78
|
+
return output;
|
|
79
|
+
}, input);
|
|
79
80
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as UID from "@webiny/ui/Dialog";
|
|
3
|
+
import { CmsEditorContentModel } from "../../../types";
|
|
4
|
+
export interface Props {
|
|
5
|
+
open: boolean;
|
|
6
|
+
onClose: UID.DialogOnClose;
|
|
7
|
+
contentModel: CmsEditorContentModel;
|
|
8
|
+
closeModal: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const CloneContentModelDialog: React.FC<Props>;
|
|
11
|
+
export default CloneContentModelDialog;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/createForOfIteratorHelper";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
|
+
|
|
6
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
7
|
+
|
|
8
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
+
import React, { useCallback } from "react";
|
|
10
|
+
import { css } from "emotion";
|
|
11
|
+
import get from "lodash/get";
|
|
12
|
+
import { useRouter } from "@webiny/react-router";
|
|
13
|
+
import { Form } from "@webiny/form";
|
|
14
|
+
import { Input } from "@webiny/ui/Input";
|
|
15
|
+
import { Select } from "@webiny/ui/Select";
|
|
16
|
+
import { useSnackbar } from "@webiny/app-admin/hooks/useSnackbar";
|
|
17
|
+
import { CircularProgress } from "@webiny/ui/Progress";
|
|
18
|
+
import { validation } from "@webiny/validation";
|
|
19
|
+
import { useQuery, useMutation } from "../../hooks";
|
|
20
|
+
import { i18n } from "@webiny/app/i18n";
|
|
21
|
+
import { ButtonDefault } from "@webiny/ui/Button";
|
|
22
|
+
import * as UID from "@webiny/ui/Dialog";
|
|
23
|
+
import { Grid, Cell } from "@webiny/ui/Grid";
|
|
24
|
+
import { addModelToGroupCache, addModelToListCache } from "./cache";
|
|
25
|
+
import * as GQL from "../../viewsGraphql";
|
|
26
|
+
var t = i18n.ns("app-headless-cms/admin/views/content-models/clone-content-model-dialog");
|
|
27
|
+
var narrowDialog = /*#__PURE__*/css({
|
|
28
|
+
".mdc-dialog__surface": {
|
|
29
|
+
width: 600,
|
|
30
|
+
minWidth: 600
|
|
31
|
+
}
|
|
32
|
+
}, "label:narrowDialog;");
|
|
33
|
+
var noPadding = /*#__PURE__*/css({
|
|
34
|
+
padding: "5px !important"
|
|
35
|
+
}, "label:noPadding;");
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* This list is to disallow creating models that might interfere with GraphQL schema creation.
|
|
39
|
+
* Add more if required.
|
|
40
|
+
*/
|
|
41
|
+
var disallowedModelIdEndingList = ["Response", "List", "Meta", "Input", "Sorter"];
|
|
42
|
+
|
|
43
|
+
var CloneContentModelDialog = function CloneContentModelDialog(_ref) {
|
|
44
|
+
var open = _ref.open,
|
|
45
|
+
onClose = _ref.onClose,
|
|
46
|
+
contentModel = _ref.contentModel,
|
|
47
|
+
closeModal = _ref.closeModal;
|
|
48
|
+
|
|
49
|
+
var _React$useState = React.useState(false),
|
|
50
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
51
|
+
loading = _React$useState2[0],
|
|
52
|
+
setLoading = _React$useState2[1];
|
|
53
|
+
|
|
54
|
+
var _useSnackbar = useSnackbar(),
|
|
55
|
+
showSnackbar = _useSnackbar.showSnackbar;
|
|
56
|
+
|
|
57
|
+
var _useRouter = useRouter(),
|
|
58
|
+
history = _useRouter.history;
|
|
59
|
+
|
|
60
|
+
var _useMutation = useMutation(GQL.CREATE_CONTENT_MODEL_FROM, {
|
|
61
|
+
update: function update(cache, _ref2) {
|
|
62
|
+
var data = _ref2.data;
|
|
63
|
+
var _data$createContentMo = data.createContentModelFrom,
|
|
64
|
+
model = _data$createContentMo.data,
|
|
65
|
+
error = _data$createContentMo.error;
|
|
66
|
+
|
|
67
|
+
if (error) {
|
|
68
|
+
setLoading(false);
|
|
69
|
+
return showSnackbar(error.message);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
addModelToListCache(cache, model);
|
|
73
|
+
addModelToGroupCache(cache, model);
|
|
74
|
+
history.push("/cms/content-models/");
|
|
75
|
+
closeModal();
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
_useMutation2 = _slicedToArray(_useMutation, 1),
|
|
79
|
+
createContentModelFrom = _useMutation2[0];
|
|
80
|
+
|
|
81
|
+
var _useQuery = useQuery(GQL.LIST_MENU_CONTENT_GROUPS_MODELS, {
|
|
82
|
+
skip: !open
|
|
83
|
+
}),
|
|
84
|
+
data = _useQuery.data;
|
|
85
|
+
|
|
86
|
+
var contentModelGroups = get(data, "listContentModelGroups.data", []).map(function (item) {
|
|
87
|
+
return {
|
|
88
|
+
value: item.id,
|
|
89
|
+
label: item.name
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
var nameValidator = useCallback(function (name) {
|
|
93
|
+
var target = (name || "").trim();
|
|
94
|
+
|
|
95
|
+
if (!target.charAt(0).match(/[a-zA-Z]/)) {
|
|
96
|
+
throw new Error("Value is not valid - must not start with a number.");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (target.toLowerCase() === "id") {
|
|
100
|
+
throw new Error('Value is not valid - "id" is an auto-generated field.');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
var _iterator = _createForOfIteratorHelper(disallowedModelIdEndingList),
|
|
104
|
+
_step;
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
108
|
+
var ending = _step.value;
|
|
109
|
+
var re = new RegExp("".concat(ending, "$"), "i");
|
|
110
|
+
var matched = target.match(re);
|
|
111
|
+
|
|
112
|
+
if (matched === null) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
throw new Error("Model name that ends with \"".concat(ending, "\" is not allowed."));
|
|
117
|
+
}
|
|
118
|
+
} catch (err) {
|
|
119
|
+
_iterator.e(err);
|
|
120
|
+
} finally {
|
|
121
|
+
_iterator.f();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return true;
|
|
125
|
+
}, undefined);
|
|
126
|
+
return /*#__PURE__*/React.createElement(UID.Dialog, {
|
|
127
|
+
open: open,
|
|
128
|
+
onClose: onClose,
|
|
129
|
+
className: narrowDialog,
|
|
130
|
+
"data-testid": "cms-clone-content-model-modal"
|
|
131
|
+
}, open && /*#__PURE__*/React.createElement(Form, {
|
|
132
|
+
data: {
|
|
133
|
+
group: contentModel.group.id
|
|
134
|
+
},
|
|
135
|
+
onSubmit: /*#__PURE__*/function () {
|
|
136
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
|
|
137
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
138
|
+
while (1) {
|
|
139
|
+
switch (_context.prev = _context.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
setLoading(true);
|
|
142
|
+
_context.next = 3;
|
|
143
|
+
return createContentModelFrom({
|
|
144
|
+
variables: {
|
|
145
|
+
modelId: contentModel.modelId,
|
|
146
|
+
data: data
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
case 3:
|
|
151
|
+
case "end":
|
|
152
|
+
return _context.stop();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, _callee);
|
|
156
|
+
}));
|
|
157
|
+
|
|
158
|
+
return function (_x) {
|
|
159
|
+
return _ref3.apply(this, arguments);
|
|
160
|
+
};
|
|
161
|
+
}()
|
|
162
|
+
}, function (_ref4) {
|
|
163
|
+
var Bind = _ref4.Bind,
|
|
164
|
+
submit = _ref4.submit;
|
|
165
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, loading && /*#__PURE__*/React.createElement(CircularProgress, null), /*#__PURE__*/React.createElement(UID.DialogTitle, null, t(_templateObject || (_templateObject = _taggedTemplateLiteral(["New Content Model From Existing"])))), /*#__PURE__*/React.createElement(UID.DialogContent, null, /*#__PURE__*/React.createElement(Grid, {
|
|
166
|
+
className: noPadding
|
|
167
|
+
}, /*#__PURE__*/React.createElement(Cell, {
|
|
168
|
+
span: 12
|
|
169
|
+
}, /*#__PURE__*/React.createElement(Bind, {
|
|
170
|
+
name: "name",
|
|
171
|
+
validators: [validation.create("required,maxLength:100"), nameValidator]
|
|
172
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
173
|
+
label: t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Name"]))),
|
|
174
|
+
description: t(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["The name of the content model"]))),
|
|
175
|
+
placeholder: contentModel.name
|
|
176
|
+
}))), /*#__PURE__*/React.createElement(Cell, {
|
|
177
|
+
span: 12
|
|
178
|
+
}, /*#__PURE__*/React.createElement(Bind, {
|
|
179
|
+
name: "group",
|
|
180
|
+
validators: validation.create("required")
|
|
181
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
182
|
+
description: t(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Choose a content model group"]))),
|
|
183
|
+
label: t(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Content model group"]))),
|
|
184
|
+
options: contentModelGroups,
|
|
185
|
+
value: contentModel.group.id
|
|
186
|
+
}))), /*#__PURE__*/React.createElement(Cell, {
|
|
187
|
+
span: 12
|
|
188
|
+
}, /*#__PURE__*/React.createElement(Bind, {
|
|
189
|
+
name: "description"
|
|
190
|
+
}, function (props) {
|
|
191
|
+
return /*#__PURE__*/React.createElement(Input, Object.assign({}, props, {
|
|
192
|
+
rows: 4,
|
|
193
|
+
maxLength: 200,
|
|
194
|
+
characterCount: true,
|
|
195
|
+
label: t(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Description"]))),
|
|
196
|
+
value: contentModel.description
|
|
197
|
+
}));
|
|
198
|
+
})))), /*#__PURE__*/React.createElement(UID.DialogActions, null, /*#__PURE__*/React.createElement(ButtonDefault, {
|
|
199
|
+
onClick: submit
|
|
200
|
+
}, "+ ", t(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Create"]))))));
|
|
201
|
+
}));
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export default CloneContentModelDialog;
|
|
@@ -6,6 +6,7 @@ import ContentModelsDataList from "./ContentModelsDataList";
|
|
|
6
6
|
import NewContentModelDialog from "./NewContentModelDialog";
|
|
7
7
|
import { Cell } from "@webiny/ui/Grid";
|
|
8
8
|
import { Grid } from "@webiny/ui/Grid";
|
|
9
|
+
import CloneContentModelDialog from "./CloneContentModelDialog";
|
|
9
10
|
var grid = /*#__PURE__*/css({
|
|
10
11
|
"&.mdc-layout-grid": {
|
|
11
12
|
padding: 0,
|
|
@@ -39,6 +40,11 @@ function ContentModels() {
|
|
|
39
40
|
newContentModelDialogOpened = _React$useState2[0],
|
|
40
41
|
openNewContentModelDialog = _React$useState2[1];
|
|
41
42
|
|
|
43
|
+
var _React$useState3 = React.useState(null),
|
|
44
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
45
|
+
cloneContentModel = _React$useState4[0],
|
|
46
|
+
setCloneContentModel = _React$useState4[1];
|
|
47
|
+
|
|
42
48
|
var _useSecurity = useSecurity(),
|
|
43
49
|
identity = _useSecurity.identity;
|
|
44
50
|
|
|
@@ -55,15 +61,29 @@ function ContentModels() {
|
|
|
55
61
|
|
|
56
62
|
return permission.rwd.includes("w");
|
|
57
63
|
}, []);
|
|
64
|
+
var closeModal = useCallback(function () {
|
|
65
|
+
setCloneContentModel(null);
|
|
66
|
+
}, []);
|
|
58
67
|
var onCreate = useCallback(function () {
|
|
59
68
|
return openNewContentModelDialog(true);
|
|
60
69
|
}, []);
|
|
61
70
|
var onClose = useCallback(function () {
|
|
62
71
|
return openNewContentModelDialog(false);
|
|
63
72
|
}, []);
|
|
73
|
+
var onClone = useCallback(function (contentModel) {
|
|
74
|
+
return setCloneContentModel(contentModel);
|
|
75
|
+
}, []);
|
|
76
|
+
var onCloneClose = useCallback(function () {
|
|
77
|
+
return setCloneContentModel(null);
|
|
78
|
+
}, []);
|
|
64
79
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(NewContentModelDialog, {
|
|
65
80
|
open: newContentModelDialogOpened,
|
|
66
81
|
onClose: onClose
|
|
82
|
+
}), /*#__PURE__*/React.createElement(CloneContentModelDialog, {
|
|
83
|
+
open: !!cloneContentModel,
|
|
84
|
+
contentModel: cloneContentModel,
|
|
85
|
+
onClose: onCloneClose,
|
|
86
|
+
closeModal: closeModal
|
|
67
87
|
}), /*#__PURE__*/React.createElement(Grid, {
|
|
68
88
|
className: grid
|
|
69
89
|
}, /*#__PURE__*/React.createElement(Cell, {
|
|
@@ -73,7 +93,8 @@ function ContentModels() {
|
|
|
73
93
|
className: centeredContent
|
|
74
94
|
}, /*#__PURE__*/React.createElement(ContentModelsDataList, {
|
|
75
95
|
canCreate: canCreate,
|
|
76
|
-
onCreate: onCreate
|
|
96
|
+
onCreate: onCreate,
|
|
97
|
+
onClone: onClone
|
|
77
98
|
})), /*#__PURE__*/React.createElement(Cell, {
|
|
78
99
|
span: 3
|
|
79
100
|
})));
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { CmsEditorContentModel } from "../../../types";
|
|
2
3
|
declare type ContentModelsDataListProps = {
|
|
3
4
|
canCreate: boolean;
|
|
4
5
|
onCreate: () => void;
|
|
6
|
+
onClone: (contentModel: CmsEditorContentModel) => void;
|
|
5
7
|
};
|
|
6
|
-
declare const ContentModelsDataList: ({ canCreate, onCreate }: ContentModelsDataListProps) => JSX.Element;
|
|
8
|
+
declare const ContentModelsDataList: ({ canCreate, onCreate, onClone }: ContentModelsDataListProps) => JSX.Element;
|
|
7
9
|
export default ContentModelsDataList;
|
|
@@ -2,7 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
4
4
|
|
|
5
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
|
|
5
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
|
|
6
6
|
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import React, { useCallback, useMemo, useState } from "react";
|
|
@@ -12,6 +12,7 @@ import get from "lodash/get";
|
|
|
12
12
|
import { useRouter } from "@webiny/react-router";
|
|
13
13
|
import { DeleteIcon, EditIcon } from "@webiny/ui/List/DataList/icons";
|
|
14
14
|
import { ReactComponent as ViewListIcon } from "@svgr/webpack!../../icons/view_list.svg";
|
|
15
|
+
import { ReactComponent as CloneIcon } from "@svgr/webpack!../../icons/clone.svg";
|
|
15
16
|
import { useApolloClient, useQuery } from "../../hooks";
|
|
16
17
|
import { useSnackbar } from "@webiny/app-admin/hooks/useSnackbar";
|
|
17
18
|
import * as UIL from "@webiny/ui/List";
|
|
@@ -61,7 +62,8 @@ var listItemMinHeight = /*#__PURE__*/css({
|
|
|
61
62
|
|
|
62
63
|
var ContentModelsDataList = function ContentModelsDataList(_ref) {
|
|
63
64
|
var canCreate = _ref.canCreate,
|
|
64
|
-
onCreate = _ref.onCreate
|
|
65
|
+
onCreate = _ref.onCreate,
|
|
66
|
+
onClone = _ref.onClone;
|
|
65
67
|
|
|
66
68
|
var _useState = useState(""),
|
|
67
69
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -259,14 +261,24 @@ var ContentModelsDataList = function ContentModelsDataList(_ref) {
|
|
|
259
261
|
return editRecord(contentModel);
|
|
260
262
|
},
|
|
261
263
|
"data-testid": "cms-edit-content-model-button"
|
|
262
|
-
}))),
|
|
263
|
-
content:
|
|
264
|
+
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
265
|
+
content: "Clone content model",
|
|
266
|
+
placement: "top"
|
|
267
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
268
|
+
"data-testid": "cms-clone-content-model-button",
|
|
269
|
+
icon: /*#__PURE__*/React.createElement(CloneIcon, null),
|
|
270
|
+
label: t(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["View entries"]))),
|
|
271
|
+
onClick: function onClick() {
|
|
272
|
+
return onClone(contentModel);
|
|
273
|
+
}
|
|
274
|
+
})), canDelete(contentModel, "cms.contentModel") && contentModel.plugin ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
275
|
+
content: t(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["Content model is registered via a plugin."]))),
|
|
264
276
|
placement: "top"
|
|
265
277
|
}, /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
266
278
|
disabled: true,
|
|
267
279
|
"data-testid": "cms-delete-content-model-button"
|
|
268
280
|
})) : /*#__PURE__*/React.createElement(Tooltip, {
|
|
269
|
-
content: t(
|
|
281
|
+
content: t(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["Delete content model"]))),
|
|
270
282
|
placement: "top"
|
|
271
283
|
}, /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
272
284
|
onClick: function onClick() {
|
package/admin/viewsGraphql.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const LIST_MENU_CONTENT_GROUPS_MODELS: import("graphql").DocumentNode;
|
|
2
2
|
export declare const LIST_CONTENT_MODELS: import("graphql").DocumentNode;
|
|
3
3
|
export declare const CREATE_CONTENT_MODEL: import("graphql").DocumentNode;
|
|
4
|
+
export declare const CREATE_CONTENT_MODEL_FROM: import("graphql").DocumentNode;
|
|
4
5
|
export declare const DELETE_CONTENT_MODEL: import("graphql").DocumentNode;
|
package/admin/viewsGraphql.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
4
4
|
|
|
5
5
|
import gql from "graphql-tag";
|
|
6
6
|
var ERROR_FIELDS = "\n code\n message\n data\n";
|
|
@@ -9,4 +9,5 @@ var BASE_CONTENT_MODEL_FIELDS = "\n description\n modelId\n name\n s
|
|
|
9
9
|
export var LIST_MENU_CONTENT_GROUPS_MODELS = gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n query CmsListMenuContentGroupsModels {\n listContentModelGroups {\n data {\n id\n name\n icon\n plugin\n contentModels {\n name\n modelId\n plugin\n createdBy {\n id\n displayName\n type\n }\n }\n }\n }\n }\n"])));
|
|
10
10
|
export var LIST_CONTENT_MODELS = gql(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n query CmsListContentModels {\n listContentModels {\n data {\n ", "\n }\n }\n }\n"])), BASE_CONTENT_MODEL_FIELDS);
|
|
11
11
|
export var CREATE_CONTENT_MODEL = gql(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n mutation CmsCreateContentModel($data: CmsContentModelCreateInput!) {\n createContentModel(data: $data) {\n data {\n ", "\n }\n error {\n message\n data\n }\n }\n }\n"])), BASE_CONTENT_MODEL_FIELDS);
|
|
12
|
-
export var
|
|
12
|
+
export var CREATE_CONTENT_MODEL_FROM = gql(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n mutation CmsCreateContentModelFrom($modelId: ID!, $data: CmsContentModelCreateFromInput!) {\n createContentModelFrom(modelId: $modelId, data: $data) {\n data {\n ", "\n }\n error {\n message\n data\n }\n }\n }\n"])), BASE_CONTENT_MODEL_FIELDS);
|
|
13
|
+
export var DELETE_CONTENT_MODEL = gql(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n mutation CmsDeleteContentModel($modelId: ID!) {\n deleteContentModel(modelId: $modelId) {\n data\n error {\n ", "\n }\n }\n }\n"])), ERROR_FIELDS);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-headless-cms",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20.0-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": "4.3.3",
|
|
26
26
|
"@types/react": "16.14.2",
|
|
27
|
-
"@webiny/app": "5.
|
|
28
|
-
"@webiny/app-admin": "5.
|
|
29
|
-
"@webiny/app-graphql-playground": "5.
|
|
30
|
-
"@webiny/app-i18n": "5.
|
|
31
|
-
"@webiny/app-plugin-admin-welcome-screen": "5.
|
|
32
|
-
"@webiny/app-security": "5.
|
|
33
|
-
"@webiny/error": "5.
|
|
34
|
-
"@webiny/form": "5.
|
|
35
|
-
"@webiny/plugins": "5.
|
|
36
|
-
"@webiny/react-router": "5.
|
|
37
|
-
"@webiny/ui": "5.
|
|
38
|
-
"@webiny/utils": "5.
|
|
39
|
-
"@webiny/validation": "5.
|
|
27
|
+
"@webiny/app": "5.20.0-beta.0",
|
|
28
|
+
"@webiny/app-admin": "5.20.0-beta.0",
|
|
29
|
+
"@webiny/app-graphql-playground": "5.20.0-beta.0",
|
|
30
|
+
"@webiny/app-i18n": "5.20.0-beta.0",
|
|
31
|
+
"@webiny/app-plugin-admin-welcome-screen": "5.20.0-beta.0",
|
|
32
|
+
"@webiny/app-security": "5.20.0-beta.0",
|
|
33
|
+
"@webiny/error": "5.20.0-beta.0",
|
|
34
|
+
"@webiny/form": "5.20.0-beta.0",
|
|
35
|
+
"@webiny/plugins": "5.20.0-beta.0",
|
|
36
|
+
"@webiny/react-router": "5.20.0-beta.0",
|
|
37
|
+
"@webiny/ui": "5.20.0-beta.0",
|
|
38
|
+
"@webiny/utils": "5.20.0-beta.0",
|
|
39
|
+
"@webiny/validation": "5.20.0-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.5.5",
|
|
69
69
|
"@babel/preset-react": "^7.0.0",
|
|
70
70
|
"@babel/preset-typescript": "^7.8.3",
|
|
71
|
-
"@webiny/cli": "^5.
|
|
72
|
-
"@webiny/project-utils": "^5.
|
|
71
|
+
"@webiny/cli": "^5.20.0-beta.0",
|
|
72
|
+
"@webiny/project-utils": "^5.20.0-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",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
]
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "2de02bc113e15e3ffa8e1d82deb9d27417787188"
|
|
111
111
|
}
|