@webiny/app-headless-cms 5.25.0-beta.0 → 5.25.0-beta.3
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/ContentEntryForm.js +43 -7
- package/admin/components/ContentEntryForm/ContentEntryForm.js.map +1 -1
- package/admin/components/ContentEntryForm/useContentEntryForm.d.ts +1 -1
- package/admin/components/ContentEntryForm/useContentEntryForm.js +9 -3
- package/admin/components/ContentEntryForm/useContentEntryForm.js.map +1 -1
- package/admin/components/FieldEditor/Styled.d.ts +0 -1
- package/admin/graphql/contentEntries.js.map +1 -1
- package/admin/icons/draft.svg +3 -0
- package/admin/icons/published.svg +3 -0
- package/admin/icons/unpublished.svg +3 -0
- package/admin/menus/GlobalSearchPlugins.d.ts +0 -1
- package/admin/plugins/editor/defaultBar/BackButton.js +4 -2
- package/admin/plugins/editor/defaultBar/BackButton.js.map +1 -1
- package/admin/plugins/editor/defaultBar/Divider.d.ts +0 -1
- package/admin/plugins/editor/defaultBar/Name/NameStyled.d.ts +0 -1
- package/admin/plugins/editor/defaultBar/index.d.ts +0 -1
- package/admin/plugins/editor/formSettings/components/GeneralSettings.d.ts +0 -1
- package/admin/plugins/editor/formSettings/components/GroupSelect.d.ts +0 -1
- package/admin/plugins/fieldRenderers/boolean/booleanSwitch.js.map +1 -1
- package/admin/plugins/fieldRenderers/file/fileFields.js.map +1 -1
- package/admin/plugins/fieldRenderers/file/utils.d.ts +0 -1
- package/admin/plugins/fieldRenderers/number/numberInput.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/components/ContentEntriesAutocomplete.js +29 -3
- package/admin/plugins/fieldRenderers/ref/components/ContentEntriesAutocomplete.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/components/ContentEntriesMultiAutoComplete.js +5 -3
- package/admin/plugins/fieldRenderers/ref/components/ContentEntriesMultiAutoComplete.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/components/EntryStatus.d.ts +10 -0
- package/admin/plugins/fieldRenderers/ref/components/EntryStatus.js +50 -0
- package/admin/plugins/fieldRenderers/ref/components/EntryStatus.js.map +1 -0
- package/admin/plugins/fieldRenderers/ref/components/graphql.d.ts +19 -11
- package/admin/plugins/fieldRenderers/ref/components/graphql.js +5 -6
- package/admin/plugins/fieldRenderers/ref/components/graphql.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/components/helpers.d.ts +6 -0
- package/admin/plugins/fieldRenderers/ref/components/helpers.js +41 -0
- package/admin/plugins/fieldRenderers/ref/components/helpers.js.map +1 -0
- package/admin/plugins/fieldRenderers/ref/components/renderItem.d.ts +4 -2
- package/admin/plugins/fieldRenderers/ref/components/renderItem.js +15 -0
- package/admin/plugins/fieldRenderers/ref/components/renderItem.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/components/types.d.ts +26 -0
- package/admin/plugins/fieldRenderers/ref/components/types.js +1 -0
- package/admin/plugins/fieldRenderers/ref/components/types.js.map +1 -0
- package/admin/plugins/fieldRenderers/ref/components/useReference.d.ts +1 -1
- package/admin/plugins/fieldRenderers/ref/components/useReference.js +61 -66
- package/admin/plugins/fieldRenderers/ref/components/useReference.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/components/useReferences.d.ts +4 -11
- package/admin/plugins/fieldRenderers/ref/components/useReferences.js +52 -40
- package/admin/plugins/fieldRenderers/ref/components/useReferences.js.map +1 -1
- package/admin/plugins/fieldValidators/date/createDateInputField.d.ts +0 -1
- package/admin/plugins/fields/file.js +2 -2
- package/admin/plugins/fields/file.js.map +1 -1
- package/admin/plugins/icons.js +1 -0
- package/admin/plugins/icons.js.map +1 -1
- package/admin/plugins/index.d.ts +0 -1
- package/admin/plugins/permissionRenderer/components/StyledComponents.d.ts +0 -1
- package/admin/plugins/upgrades/v5.0.0.d.ts +0 -1
- package/admin/plugins/upgrades/v5.19.0.d.ts +0 -1
- package/admin/plugins/upgrades/v5.5.0.d.ts +0 -1
- package/admin/plugins/upgrades/v5.8.0.d.ts +0 -1
- package/admin/views/contentEntries/ContentEntries.js +12 -7
- package/admin/views/contentEntries/ContentEntries.js.map +1 -1
- package/admin/views/contentEntries/ContentEntry/ContentEntryContext.js +2 -2
- package/admin/views/contentEntries/ContentEntry/ContentEntryContext.js.map +1 -1
- package/admin/views/contentEntries/ContentEntry/header/requestChanges/RequestChanges.d.ts +0 -1
- package/admin/views/contentEntries/hooks/useContentEntriesList.d.ts +0 -1
- package/admin/views/contentModels/CloneContentModelDialog.js +55 -40
- package/admin/views/contentModels/CloneContentModelDialog.js.map +1 -1
- package/admin/views/contentModels/ContentModelEditor.js +2 -2
- package/admin/views/contentModels/ContentModelEditor.js.map +1 -1
- package/package.json +22 -22
- package/types.d.ts +3 -8
- package/admin/plugins/fieldRenderers/ref/components/getOptions.d.ts +0 -16
- package/admin/plugins/fieldRenderers/ref/components/getOptions.js +0 -21
- package/admin/plugins/fieldRenderers/ref/components/getOptions.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
3
|
|
|
3
4
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
@@ -12,10 +13,25 @@ import { useNewRefEntry } from "../hooks/useNewRefEntry";
|
|
|
12
13
|
import { useReference } from "./useReference";
|
|
13
14
|
import { renderItem } from "./renderItem";
|
|
14
15
|
import { createEntryUrl } from "./createEntryUrl";
|
|
16
|
+
import { EntryStatus } from "./EntryStatus";
|
|
15
17
|
var t = i18n.ns("app-headless-cms/admin/fields/ref");
|
|
16
18
|
var unpublishedLabel = t(_templateObject || (_templateObject = _taggedTemplateLiteral(["Selected content entry is not published. Make sure to {publishItLink} before publishing the main content entry."])));
|
|
17
19
|
var publishedLabel = t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Selected content entry is published. You can view it {here}."])));
|
|
18
20
|
|
|
21
|
+
var getItemOption = function getItemOption(options, id) {
|
|
22
|
+
if (!id || !options || options.length === 0) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var _id$split = id.split("#"),
|
|
27
|
+
_id$split2 = _slicedToArray(_id$split, 1),
|
|
28
|
+
entryId = _id$split2[0];
|
|
29
|
+
|
|
30
|
+
return options.find(function (item) {
|
|
31
|
+
return item.entryId === entryId;
|
|
32
|
+
}) || null;
|
|
33
|
+
};
|
|
34
|
+
|
|
19
35
|
var ContentEntriesAutocomplete = function ContentEntriesAutocomplete(_ref) {
|
|
20
36
|
var bind = _ref.bind,
|
|
21
37
|
field = _ref.field;
|
|
@@ -55,15 +71,21 @@ var ContentEntriesAutocomplete = function ContentEntriesAutocomplete(_ref) {
|
|
|
55
71
|
renderNewEntryModal = _useNewRefEntry.renderNewEntryModal,
|
|
56
72
|
refModelId = _useNewRefEntry.refModelId,
|
|
57
73
|
helpText = _useNewRefEntry.helpText;
|
|
74
|
+
|
|
75
|
+
var item = getItemOption(options, bind.value ? bind.value.id : null);
|
|
58
76
|
/*
|
|
59
77
|
* Wrap AutoComplete input in NewRefEntry modal.
|
|
60
78
|
*/
|
|
61
79
|
|
|
62
|
-
|
|
63
80
|
if (renderNewEntryModal) {
|
|
64
81
|
return /*#__PURE__*/React.createElement(NewRefEntryFormDialog, {
|
|
65
82
|
modelId: refModelId,
|
|
66
83
|
onChange: function onChange(entry) {
|
|
84
|
+
/**
|
|
85
|
+
* TODO @ts-refactor @ashutosh
|
|
86
|
+
* Need to figure out correct types.
|
|
87
|
+
*/
|
|
88
|
+
// @ts-ignore
|
|
67
89
|
return _onChange(entry, entry);
|
|
68
90
|
}
|
|
69
91
|
}, /*#__PURE__*/React.createElement(AutoComplete, Object.assign({}, bind, {
|
|
@@ -73,7 +95,9 @@ var ContentEntriesAutocomplete = function ContentEntriesAutocomplete(_ref) {
|
|
|
73
95
|
value: value || undefined,
|
|
74
96
|
options: options,
|
|
75
97
|
label: field.label,
|
|
76
|
-
description: /*#__PURE__*/React.createElement(React.Fragment, null, field.helpText,
|
|
98
|
+
description: /*#__PURE__*/React.createElement(React.Fragment, null, field.helpText, /*#__PURE__*/React.createElement(EntryStatus, {
|
|
99
|
+
item: item
|
|
100
|
+
}, entryInfo)),
|
|
77
101
|
onInput: debounce(function (search) {
|
|
78
102
|
return setSearch(search);
|
|
79
103
|
}, 250),
|
|
@@ -88,7 +112,9 @@ var ContentEntriesAutocomplete = function ContentEntriesAutocomplete(_ref) {
|
|
|
88
112
|
value: value || undefined,
|
|
89
113
|
options: options,
|
|
90
114
|
label: field.label,
|
|
91
|
-
description: /*#__PURE__*/React.createElement(React.Fragment, null, field.helpText,
|
|
115
|
+
description: /*#__PURE__*/React.createElement(React.Fragment, null, field.helpText, /*#__PURE__*/React.createElement(EntryStatus, {
|
|
116
|
+
item: item
|
|
117
|
+
}, entryInfo)),
|
|
92
118
|
onInput: debounce(function (search) {
|
|
93
119
|
return setSearch(search);
|
|
94
120
|
}, 250),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ContentEntriesAutocomplete.tsx"],"names":["React","debounce","NewRefEntryFormDialog","NewEntryButton","AutoComplete","i18n","Link","useNewRefEntry","useReference","renderItem","createEntryUrl","t","ns","unpublishedLabel","publishedLabel","ContentEntriesAutocomplete","bind","field","
|
|
1
|
+
{"version":3,"sources":["ContentEntriesAutocomplete.tsx"],"names":["React","debounce","NewRefEntryFormDialog","NewEntryButton","AutoComplete","i18n","Link","useNewRefEntry","useReference","renderItem","createEntryUrl","EntryStatus","t","ns","unpublishedLabel","publishedLabel","getItemOption","options","id","length","split","entryId","find","item","ContentEntriesAutocomplete","bind","field","setSearch","value","loading","onChange","entryInfo","published","link","publishItLink","here","renderNewEntryModal","refModelId","helpText","entry","undefined","label","search"],"mappings":";;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,OAAOC,qBAAP,IAAgCC,cAA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MAAA,KAAK,EAAES,KAAK,CAACe,KAPjB;AAQI,MAAA,WAAW,eACP,0CACKf,KAAK,CAACY,QADX,eAEI,oBAAC,WAAD;AAAa,QAAA,IAAI,EAAEf;AAAnB,SAA0BQ,SAA1B,CAFJ,CATR;AAcI,MAAA,OAAO,EAAE9B,QAAQ,CAAC,UAAAyC,MAAM;AAAA,eAAIf,SAAS,CAACe,MAAD,CAAb;AAAA,OAAP,EAA8B,GAA9B,CAdrB;AAeI,MAAA,aAAa,eAAE,oBAAC,cAAD;AAfnB,OAXJ,CADJ;AA+BH;;AAED,sBACI,oBAAC,YAAD,oBACQjB,IADR;AAEI,IAAA,UAAU,EAAEhB,UAFhB;AAGI,IAAA,QAAQ,EAAEqB,SAHd;AAII,IAAA,OAAO,EAAED,OAJb;AAKI,IAAA,KAAK,EAAED,KAAK,IAAIY,SALpB;AAMI,IAAA,OAAO,EAAEvB,OANb;AAOI,IAAA,KAAK,EAAES,KAAK,CAACe,KAPjB;AAQI,IAAA,WAAW,eACP,0CACKf,KAAK,CAACY,QADX,eAEI,oBAAC,WAAD;AAAa,MAAA,IAAI,EAAEf;AAAnB,OAA0BQ,SAA1B,CAFJ,CATR;AAcI,IAAA,OAAO,EAAE9B,QAAQ,CAAC,UAAAyC,MAAM;AAAA,aAAIf,SAAS,CAACe,MAAD,CAAb;AAAA,KAAP,EAA8B,GAA9B,CAdrB;AAeI,IAAA,aAAa,EAAEJ;AAfnB,KADJ;AAmBH,CA3ED;;AA6EA,eAAed,0BAAf","sourcesContent":["import React from \"react\";\nimport debounce from \"lodash/debounce\";\nimport NewRefEntryFormDialog, { NewEntryButton } from \"./NewRefEntryFormDialog\";\nimport { AutoComplete } from \"@webiny/ui/AutoComplete\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { Link } from \"@webiny/react-router\";\nimport { useNewRefEntry } from \"../hooks/useNewRefEntry\";\nimport { useReference } from \"./useReference\";\nimport { renderItem } from \"./renderItem\";\nimport { createEntryUrl } from \"./createEntryUrl\";\nimport { CmsEditorField } from \"~/types\";\nimport { BindComponentRenderProp } from \"@webiny/form\";\nimport { OptionItem } from \"./types\";\nimport { EntryStatus } from \"./EntryStatus\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/fields/ref\");\n\nconst unpublishedLabel = t`Selected content entry is not published. Make sure to {publishItLink} before publishing the main content entry.`;\nconst publishedLabel = t`Selected content entry is published. You can view it {here}.`;\n\nconst getItemOption = (options: OptionItem[], id?: string | null): OptionItem | null => {\n if (!id || !options || options.length === 0) {\n return null;\n }\n const [entryId] = id.split(\"#\");\n return options.find(item => item.entryId === entryId) || null;\n};\n\ninterface ContentEntriesAutocompleteProps {\n bind: BindComponentRenderProp;\n field: CmsEditorField;\n}\nconst ContentEntriesAutocomplete: React.FC<ContentEntriesAutocompleteProps> = ({ bind, field }) => {\n const { options, setSearch, value, loading, onChange } = useReference({\n bind,\n field\n });\n\n let entryInfo: string | null = null;\n if (value && !value.published) {\n const link = createEntryUrl(value);\n entryInfo = unpublishedLabel({ publishItLink: <Link to={link}>{t`publish it`}</Link> });\n } else if (value) {\n const link = createEntryUrl(value);\n entryInfo = publishedLabel({\n here: <Link to={link}>{t`here`}</Link>\n });\n }\n const { renderNewEntryModal, refModelId, helpText } = useNewRefEntry({ field });\n\n const item = getItemOption(options, bind.value ? bind.value.id : null);\n /*\n * Wrap AutoComplete input in NewRefEntry modal.\n */\n if (renderNewEntryModal) {\n return (\n <NewRefEntryFormDialog\n modelId={refModelId}\n onChange={entry => {\n /**\n * TODO @ts-refactor @ashutosh\n * Need to figure out correct types.\n */\n // @ts-ignore\n return onChange(entry, entry);\n }}\n >\n <AutoComplete\n {...bind}\n renderItem={renderItem}\n onChange={onChange}\n loading={loading}\n value={value || undefined}\n options={options}\n label={field.label}\n description={\n <>\n {field.helpText}\n <EntryStatus item={item}>{entryInfo}</EntryStatus>\n </>\n }\n onInput={debounce(search => setSearch(search), 250)}\n noResultFound={<NewEntryButton />}\n />\n </NewRefEntryFormDialog>\n );\n }\n\n return (\n <AutoComplete\n {...bind}\n renderItem={renderItem}\n onChange={onChange}\n loading={loading}\n value={value || undefined}\n options={options}\n label={field.label}\n description={\n <>\n {field.helpText}\n <EntryStatus item={item}>{entryInfo}</EntryStatus>\n </>\n }\n onInput={debounce(search => setSearch(search), 250)}\n noResultFound={helpText}\n />\n );\n};\n\nexport default ContentEntriesAutocomplete;\n"]}
|
|
@@ -9,7 +9,7 @@ import { MultiAutoComplete } from "@webiny/ui/AutoComplete";
|
|
|
9
9
|
import { Link } from "@webiny/react-router";
|
|
10
10
|
import { i18n } from "@webiny/app/i18n";
|
|
11
11
|
import { useReferences } from "./useReferences";
|
|
12
|
-
import { renderItem } from "./renderItem";
|
|
12
|
+
import { renderItem, renderListItemOptions } from "./renderItem";
|
|
13
13
|
import NewRefEntryFormDialog, { NewEntryButton } from "./NewRefEntryFormDialog";
|
|
14
14
|
import { useNewRefEntry } from "../hooks/useNewRefEntry";
|
|
15
15
|
var t = i18n.ns("app-headless-cms/admin/fields/ref");
|
|
@@ -54,10 +54,10 @@ var ContentEntriesMultiAutocomplete = function ContentEntriesMultiAutocomplete(_
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
var warning = entries.filter(function (item) {
|
|
57
|
-
return item.published
|
|
57
|
+
return !item.published;
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
if (warning.length) {
|
|
60
|
+
if (warning.length > 0) {
|
|
61
61
|
warning = warn({
|
|
62
62
|
entries: /*#__PURE__*/React.createElement(React.Fragment, null, warning.map(entryWarning))
|
|
63
63
|
});
|
|
@@ -78,6 +78,7 @@ var ContentEntriesMultiAutocomplete = function ContentEntriesMultiAutocomplete(_
|
|
|
78
78
|
}, /*#__PURE__*/React.createElement(MultiAutoComplete, Object.assign({}, bind, {
|
|
79
79
|
renderItem: renderItem,
|
|
80
80
|
renderListItemLabel: renderItem,
|
|
81
|
+
renderListItemOptions: renderListItemOptions,
|
|
81
82
|
useMultipleSelectionList: true,
|
|
82
83
|
onChange: onChange,
|
|
83
84
|
loading: loading,
|
|
@@ -93,6 +94,7 @@ var ContentEntriesMultiAutocomplete = function ContentEntriesMultiAutocomplete(_
|
|
|
93
94
|
return /*#__PURE__*/React.createElement(MultiAutoComplete, Object.assign({}, bind, {
|
|
94
95
|
renderItem: renderItem,
|
|
95
96
|
renderListItemLabel: renderItem,
|
|
97
|
+
renderListItemOptions: renderListItemOptions,
|
|
96
98
|
useMultipleSelectionList: true,
|
|
97
99
|
onChange: onChange,
|
|
98
100
|
loading: loading,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ContentEntriesMultiAutoComplete.tsx"],"names":["React","useCallback","debounce","MultiAutoComplete","Link","i18n","useReferences","renderItem","NewRefEntryFormDialog","NewEntryButton","useNewRefEntry","t","ns","warn","ContentEntriesMultiAutocomplete","bind","field","options","setSearch","entries","loading","onChange","renderNewEntryModal","refModelId","helpText","entryWarning","entry","index","id","modelId","name","published","encodeURIComponent","warning","filter","item","length","map","refEntryOnChange","value","label"],"mappings":";;;;;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,SAASC,iBAAT,QAAkC,yBAAlC;AACA,SAASC,IAAT,QAAqB,sBAArB;AACA,SAASC,IAAT,QAAqB,kBAArB;AACA,
|
|
1
|
+
{"version":3,"sources":["ContentEntriesMultiAutoComplete.tsx"],"names":["React","useCallback","debounce","MultiAutoComplete","Link","i18n","useReferences","renderItem","renderListItemOptions","NewRefEntryFormDialog","NewEntryButton","useNewRefEntry","t","ns","warn","ContentEntriesMultiAutocomplete","bind","field","options","setSearch","entries","loading","onChange","renderNewEntryModal","refModelId","helpText","entryWarning","entry","index","id","modelId","name","published","encodeURIComponent","warning","filter","item","length","map","refEntryOnChange","value","label"],"mappings":";;;;;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,SAAS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,GAAZ,CAXrB;AAYI,MAAA,WAAW,eACP,0CACKF,KAAK,CAACQ,QADX,EAEKS,OAFL,CAbR;AAkBI,MAAA,aAAa,eAAE,oBAAC,cAAD;AAlBnB,OADJ,CADJ;AAwBH;;AAED,sBACI,oBAAC,iBAAD,oBACQlB,IADR;AAEI,IAAA,UAAU,EAAET,UAFhB;AAGI,IAAA,mBAAmB,EAAEA,UAHzB;AAII,IAAA,qBAAqB,EAAEC,qBAJ3B;AAKI,IAAA,wBAAwB,MAL5B;AAMI,IAAA,QAAQ,EAAEc,QANd;AAOI,IAAA,OAAO,EAAED,OAPb;AAQI,IAAA,KAAK,EAAED,OARX;AASI,IAAA,OAAO,EAAEF,OATb;AAUI,IAAA,KAAK,EAAED,KAAK,CAACwB,KAVjB;AAWI,IAAA,OAAO,EAAEvC,QAAQ,CAACiB,SAAD,EAAY,GAAZ,CAXrB;AAYI,IAAA,WAAW,eACP,0CACKF,KAAK,CAACQ,QADX,EAEKS,OAFL,CAbR;AAkBI,IAAA,aAAa,EAAET;AAlBnB,KADJ;AAsBH,CA1FD;;AA4FA,eAAeV,+BAAf","sourcesContent":["import React, { useCallback } from \"react\";\nimport debounce from \"lodash/debounce\";\nimport { MultiAutoComplete } from \"@webiny/ui/AutoComplete\";\nimport { Link } from \"@webiny/react-router\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { useReferences } from \"./useReferences\";\nimport { renderItem, renderListItemOptions } from \"./renderItem\";\nimport NewRefEntryFormDialog, { NewEntryButton } from \"./NewRefEntryFormDialog\";\nimport { useNewRefEntry } from \"../hooks/useNewRefEntry\";\nimport { CmsEditorField } from \"~/types\";\nimport { BindComponentRenderProp } from \"@webiny/form\";\nimport { OptionItem } from \"./types\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/fields/ref\");\n\nconst warn = t`Before publishing the main content entry, make sure you publish the following referenced entries: {entries}`;\n\ninterface ContentEntriesMultiAutocompleteProps {\n bind: BindComponentRenderProp;\n field: CmsEditorField;\n}\nconst ContentEntriesMultiAutocomplete: React.FC<ContentEntriesMultiAutocompleteProps> = ({\n bind,\n field\n}) => {\n const { options, setSearch, entries, loading, onChange } = useReferences({ bind, field });\n\n const { renderNewEntryModal, refModelId, helpText } = useNewRefEntry({ field });\n\n const entryWarning = (entry: OptionItem, index: number): React.ReactElement | null => {\n const { id, modelId, name, published } = entry;\n if (published) {\n return null;\n }\n return (\n <React.Fragment key={id}>\n {index > 0 && \", \"}\n <Link to={`/cms/content-entries/${modelId}?id=${encodeURIComponent(id)}`}>\n {name}\n </Link>\n </React.Fragment>\n );\n };\n\n let warning = entries.filter(item => !item.published);\n if (warning.length > 0) {\n warning = warn({\n entries: <>{warning.map(entryWarning)}</>\n });\n }\n\n const refEntryOnChange = useCallback(\n // TODO @ts-refactor figure out which type is this\n value => {\n /**\n * Append new selected entry at the end of existing entries.\n */\n onChange([...entries, value]);\n },\n [onChange, entries]\n );\n\n if (renderNewEntryModal) {\n return (\n <NewRefEntryFormDialog modelId={refModelId} onChange={refEntryOnChange}>\n <MultiAutoComplete\n {...bind}\n renderItem={renderItem}\n renderListItemLabel={renderItem}\n renderListItemOptions={renderListItemOptions}\n useMultipleSelectionList\n onChange={onChange}\n loading={loading}\n value={entries}\n options={options}\n label={field.label}\n onInput={debounce(setSearch, 250)}\n description={\n <>\n {field.helpText}\n {warning}\n </>\n }\n noResultFound={<NewEntryButton />}\n />\n </NewRefEntryFormDialog>\n );\n }\n\n return (\n <MultiAutoComplete\n {...bind}\n renderItem={renderItem}\n renderListItemLabel={renderItem}\n renderListItemOptions={renderListItemOptions}\n useMultipleSelectionList\n onChange={onChange}\n loading={loading}\n value={entries}\n options={options}\n label={field.label}\n onInput={debounce(setSearch, 250)}\n description={\n <>\n {field.helpText}\n {warning}\n </>\n }\n noResultFound={helpText}\n />\n );\n};\n\nexport default ContentEntriesMultiAutocomplete;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OptionItem } from "./types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { TooltipProps } from "@webiny/ui/Tooltip";
|
|
4
|
+
interface EntryStatusProps {
|
|
5
|
+
item: OptionItem | null;
|
|
6
|
+
placement?: TooltipProps["placement"];
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const EntryStatus: React.FC<EntryStatusProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { getEntryStatus, getItemStatusText } from "./helpers";
|
|
3
|
+
import { Tooltip } from "@webiny/ui/Tooltip";
|
|
4
|
+
import { ReactComponent as PublishedIcon } from "../../../../icons/published.svg";
|
|
5
|
+
import { ReactComponent as UnpublishedIcon } from "../../../../icons/unpublished.svg";
|
|
6
|
+
import { ReactComponent as DraftIcon } from "../../../../icons/draft.svg";
|
|
7
|
+
import styled from "@emotion/styled";
|
|
8
|
+
var EntryStatusText = /*#__PURE__*/styled("div", {
|
|
9
|
+
target: "ermydxe0",
|
|
10
|
+
label: "EntryStatusText"
|
|
11
|
+
})({
|
|
12
|
+
display: "table-cell",
|
|
13
|
+
verticalAlign: "middle"
|
|
14
|
+
});
|
|
15
|
+
var EntryStatusWrapper = /*#__PURE__*/styled("div", {
|
|
16
|
+
target: "ermydxe1",
|
|
17
|
+
label: "EntryStatusWrapper"
|
|
18
|
+
})({
|
|
19
|
+
display: "table"
|
|
20
|
+
});
|
|
21
|
+
var EntryStatusTooltip = /*#__PURE__*/styled("div", {
|
|
22
|
+
target: "ermydxe2",
|
|
23
|
+
label: "EntryStatusTooltip"
|
|
24
|
+
})({
|
|
25
|
+
display: "table-cell",
|
|
26
|
+
width: "30px",
|
|
27
|
+
verticalAlign: "middle"
|
|
28
|
+
});
|
|
29
|
+
export var EntryStatus = function EntryStatus(props) {
|
|
30
|
+
var item = props.item,
|
|
31
|
+
children = props.children,
|
|
32
|
+
_props$placement = props.placement,
|
|
33
|
+
placement = _props$placement === void 0 ? "bottom" : _props$placement,
|
|
34
|
+
className = props.className;
|
|
35
|
+
|
|
36
|
+
if (!item) {
|
|
37
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var status = getEntryStatus(item);
|
|
41
|
+
var tooltipText = getItemStatusText(item);
|
|
42
|
+
var published = status === "published";
|
|
43
|
+
var unpublished = status === "unpublished";
|
|
44
|
+
return /*#__PURE__*/React.createElement(EntryStatusWrapper, {
|
|
45
|
+
className: className
|
|
46
|
+
}, /*#__PURE__*/React.createElement(EntryStatusTooltip, null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
47
|
+
content: tooltipText,
|
|
48
|
+
placement: placement
|
|
49
|
+
}, published && /*#__PURE__*/React.createElement(PublishedIcon, null), unpublished && /*#__PURE__*/React.createElement(UnpublishedIcon, null), !published && !unpublished && /*#__PURE__*/React.createElement(DraftIcon, null))), children && /*#__PURE__*/React.createElement(EntryStatusText, null, children));
|
|
50
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["EntryStatus.tsx"],"names":["React","getEntryStatus","getItemStatusText","Tooltip","ReactComponent","PublishedIcon","UnpublishedIcon","DraftIcon","styled","EntryStatusText","display","verticalAlign","EntryStatusWrapper","EntryStatusTooltip","width","EntryStatus","props","item","children","placement","className","status","tooltipText","published","unpublished"],"mappings":"AACA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SACIC,cADJ,EAEIC,iBAFJ;AAIA,SAASC,OAAT,QAAsC,oBAAtC;AACA,SAASC,cAAc,IAAIC,aAA3B;AACA,SAASD,cAAc,IAAIE,eAA3B;AACA,SAASF,cAAc,IAAIG,SAA3B;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AAEA,IAAMC,eAAe,gBAAGD,MAAH,CAAU,KAAV;AAAA;AAAA;AAAA,GAAiB;AAClCE,EAAAA,OAAO,EAAE,YADyB;AAElCC,EAAAA,aAAa,EAAE;AAFmB,CAAjB,CAArB;AAKA,IAAMC,kBAAk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;AAYH,CAtBM","sourcesContent":["import { OptionItem } from \"~/admin/plugins/fieldRenderers/ref/components/types\";\nimport React from \"react\";\nimport {\n getEntryStatus,\n getItemStatusText\n} from \"~/admin/plugins/fieldRenderers/ref/components/helpers\";\nimport { Tooltip, TooltipProps } from \"@webiny/ui/Tooltip\";\nimport { ReactComponent as PublishedIcon } from \"~/admin/icons/published.svg\";\nimport { ReactComponent as UnpublishedIcon } from \"~/admin/icons/unpublished.svg\";\nimport { ReactComponent as DraftIcon } from \"~/admin/icons/draft.svg\";\nimport styled from \"@emotion/styled\";\n\nconst EntryStatusText = styled(\"div\")({\n display: \"table-cell\",\n verticalAlign: \"middle\"\n});\n\nconst EntryStatusWrapper = styled(\"div\")({\n display: \"table\"\n});\nconst EntryStatusTooltip = styled(\"div\")({\n display: \"table-cell\",\n width: \"30px\",\n verticalAlign: \"middle\"\n});\n\ninterface EntryStatusProps {\n item: OptionItem | null;\n placement?: TooltipProps[\"placement\"];\n className?: string;\n}\nexport const EntryStatus: React.FC<EntryStatusProps> = props => {\n const { item, children, placement = \"bottom\", className } = props;\n if (!item) {\n return <>{children}</>;\n }\n const status = getEntryStatus(item);\n const tooltipText = getItemStatusText(item);\n\n const published = status === \"published\";\n const unpublished = status === \"unpublished\";\n return (\n <EntryStatusWrapper className={className}>\n <EntryStatusTooltip>\n <Tooltip content={tooltipText} placement={placement}>\n {published && <PublishedIcon />}\n {unpublished && <UnpublishedIcon />}\n {!published && !unpublished && <DraftIcon />}\n </Tooltip>\n </EntryStatusTooltip>\n {children && <EntryStatusText>{children}</EntryStatusText>}\n </EntryStatusWrapper>\n );\n};\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CmsErrorResponse
|
|
1
|
+
import { CmsErrorResponse } from "../../../../../types";
|
|
2
|
+
import { CmsReferenceContentEntry } from "./types";
|
|
2
3
|
/**
|
|
3
4
|
* #########################
|
|
4
5
|
* Common variables
|
|
@@ -13,13 +14,13 @@ export interface CmsEntryGetEntryVariable {
|
|
|
13
14
|
*/
|
|
14
15
|
export interface CmsEntrySearchQueryResponse {
|
|
15
16
|
content: {
|
|
16
|
-
data:
|
|
17
|
-
error
|
|
17
|
+
data: CmsReferenceContentEntry[];
|
|
18
|
+
error: CmsErrorResponse | null;
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
export interface CmsEntrySearchQueryVariables {
|
|
21
22
|
modelIds: string[];
|
|
22
|
-
query
|
|
23
|
+
query?: string;
|
|
23
24
|
limit?: number;
|
|
24
25
|
}
|
|
25
26
|
export declare const SEARCH_CONTENT_ENTRIES: import("graphql").DocumentNode;
|
|
@@ -28,9 +29,13 @@ export declare const SEARCH_CONTENT_ENTRIES: import("graphql").DocumentNode;
|
|
|
28
29
|
* Get Entries Query Response
|
|
29
30
|
*/
|
|
30
31
|
export interface CmsEntryGetListResponse {
|
|
31
|
-
|
|
32
|
-
data:
|
|
33
|
-
error
|
|
32
|
+
latest: {
|
|
33
|
+
data: CmsReferenceContentEntry[];
|
|
34
|
+
error: CmsErrorResponse | null;
|
|
35
|
+
};
|
|
36
|
+
published: {
|
|
37
|
+
data: CmsReferenceContentEntry[];
|
|
38
|
+
error: CmsErrorResponse | null;
|
|
34
39
|
};
|
|
35
40
|
}
|
|
36
41
|
export interface CmsEntryGetListVariables {
|
|
@@ -42,13 +47,16 @@ export declare const GET_CONTENT_ENTRIES: import("graphql").DocumentNode;
|
|
|
42
47
|
* Get Entry Query Response
|
|
43
48
|
*/
|
|
44
49
|
export interface CmsEntryGetQueryResponse {
|
|
45
|
-
|
|
46
|
-
data:
|
|
47
|
-
error
|
|
50
|
+
latest: {
|
|
51
|
+
data: CmsReferenceContentEntry | null;
|
|
52
|
+
error: CmsErrorResponse | null;
|
|
53
|
+
};
|
|
54
|
+
published: {
|
|
55
|
+
data: CmsReferenceContentEntry | null;
|
|
56
|
+
error: CmsErrorResponse | null;
|
|
48
57
|
};
|
|
49
58
|
}
|
|
50
59
|
export interface CmsEntryGetQueryVariables {
|
|
51
60
|
entry: CmsEntryGetEntryVariable;
|
|
52
61
|
}
|
|
53
62
|
export declare const GET_CONTENT_ENTRY: import("graphql").DocumentNode;
|
|
54
|
-
export declare const GET_CONTENT_MODELS: import("graphql").DocumentNode;
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
4
4
|
|
|
5
5
|
import gql from "graphql-tag";
|
|
6
|
-
var fields = "\ndata {\n id\n status\n title\n model {\n modelId\n name\n }\n}\nerror {\n code\n message\n data\n}";
|
|
6
|
+
var fields = "\ndata {\n id\n entryId\n status\n title\n model {\n modelId\n name\n }\n published {\n id\n entryId\n title\n }\n}\nerror {\n code\n message\n data\n}";
|
|
7
7
|
/**
|
|
8
8
|
* #########################
|
|
9
9
|
* Common variables
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
export var SEARCH_CONTENT_ENTRIES = gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n query CmsSearchContentEntries($modelIds: [ID!]!, $query: String
|
|
12
|
+
export var SEARCH_CONTENT_ENTRIES = gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n query CmsSearchContentEntries($modelIds: [ID!]!, $query: String, $limit: Int) {\n content: searchContentEntries(modelIds: $modelIds, query: $query, limit: $limit) {\n ", "\n }\n }\n"])), fields);
|
|
13
13
|
/**
|
|
14
14
|
* #########################
|
|
15
15
|
* Get Entries Query Response
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
export var GET_CONTENT_ENTRIES = gql(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n query CmsGetContentEntries($entries: [CmsModelEntryInput!]!) {\n
|
|
18
|
+
export var GET_CONTENT_ENTRIES = gql(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n query CmsGetContentEntries($entries: [CmsModelEntryInput!]!) {\n latest: getLatestContentEntries(entries: $entries) {\n ", "\n }\n published: getPublishedContentEntries(entries: $entries) {\n ", "\n }\n }\n"])), fields, fields);
|
|
19
19
|
/**
|
|
20
20
|
* #########################
|
|
21
21
|
* Get Entry Query Response
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
export var GET_CONTENT_ENTRY = gql(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n query CmsGetContentEntry($entry: CmsModelEntryInput!) {\n
|
|
25
|
-
export var GET_CONTENT_MODELS = gql(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n query CmsGetContentModels {\n listContentModels {\n data {\n modelId\n titleFieldId\n }\n }\n }\n"])));
|
|
24
|
+
export var GET_CONTENT_ENTRY = gql(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n query CmsGetContentEntry($entry: CmsModelEntryInput!) {\n latest: getLatestContentEntry(entry: $entry) {\n ", "\n }\n published: getPublishedContentEntry(entry: $entry) {\n ", "\n }\n }\n"])), fields, fields);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["graphql.ts"],"names":["gql","fields","SEARCH_CONTENT_ENTRIES","GET_CONTENT_ENTRIES","GET_CONTENT_ENTRY"
|
|
1
|
+
{"version":3,"sources":["graphql.ts"],"names":["gql","fields","SEARCH_CONTENT_ENTRIES","GET_CONTENT_ENTRIES","GET_CONTENT_ENTRY"],"mappings":";;;;AAAA,OAAOA,GAAP,MAAgB,aAAhB;AAIA,IAAMC,MAAM,gOAAZ;AAsBA;AACA;AACA;AACA;;AAsBA,OAAO,IAAMC,sBAAsB,GAAGF,GAAH,6RAGrBC,MAHqB,CAA5B;AAOP;AACA;AACA;AACA;;AAeA,OAAO,IAAME,mBAAmB,GAAGH,GAAH,iVAGlBC,MAHkB,EAMlBA,MANkB,CAAzB;AAWP;AACA;AACA;AACA;;AAeA,OAAO,IAAMG,iBAAiB,GAAGJ,GAAH,8TAGhBC,MAHgB,EAMhBA,MANgB,CAAvB","sourcesContent":["import gql from \"graphql-tag\";\nimport { CmsErrorResponse } from \"~/types\";\nimport { CmsReferenceContentEntry } from \"./types\";\n\nconst fields = `\ndata {\n id\n entryId\n status\n title\n model {\n modelId\n name\n }\n published {\n id\n entryId\n title\n }\n}\nerror {\n code\n message\n data\n}`;\n\n/**\n * #########################\n * Common variables\n */\nexport interface CmsEntryGetEntryVariable {\n modelId: string;\n id: string;\n}\n\n/**\n * #########################\n * Search Entries Query Response\n */\n\nexport interface CmsEntrySearchQueryResponse {\n content: {\n data: CmsReferenceContentEntry[];\n error: CmsErrorResponse | null;\n };\n}\nexport interface CmsEntrySearchQueryVariables {\n modelIds: string[];\n query?: string;\n limit?: number;\n}\nexport const SEARCH_CONTENT_ENTRIES = gql`\n query CmsSearchContentEntries($modelIds: [ID!]!, $query: String, $limit: Int) {\n content: searchContentEntries(modelIds: $modelIds, query: $query, limit: $limit) {\n ${fields}\n }\n }\n`;\n/**\n * #########################\n * Get Entries Query Response\n */\n\nexport interface CmsEntryGetListResponse {\n latest: {\n data: CmsReferenceContentEntry[];\n error: CmsErrorResponse | null;\n };\n published: {\n data: CmsReferenceContentEntry[];\n error: CmsErrorResponse | null;\n };\n}\nexport interface CmsEntryGetListVariables {\n entries: CmsEntryGetEntryVariable[];\n}\nexport const GET_CONTENT_ENTRIES = gql`\n query CmsGetContentEntries($entries: [CmsModelEntryInput!]!) {\n latest: getLatestContentEntries(entries: $entries) {\n ${fields}\n }\n published: getPublishedContentEntries(entries: $entries) {\n ${fields}\n }\n }\n`;\n\n/**\n * #########################\n * Get Entry Query Response\n */\nexport interface CmsEntryGetQueryResponse {\n latest: {\n data: CmsReferenceContentEntry | null;\n error: CmsErrorResponse | null;\n };\n published: {\n data: CmsReferenceContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\nexport interface CmsEntryGetQueryVariables {\n entry: CmsEntryGetEntryVariable;\n}\n\nexport const GET_CONTENT_ENTRY = gql`\n query CmsGetContentEntry($entry: CmsModelEntryInput!) {\n latest: getLatestContentEntry(entry: $entry) {\n ${fields}\n }\n published: getPublishedContentEntry(entry: $entry) {\n ${fields}\n }\n }\n`;\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CmsReferenceContentEntry, OptionItem, OptionItemCollection } from "./types";
|
|
2
|
+
import { CmsContentEntryStatusType } from "../../../../../types";
|
|
3
|
+
export declare const convertReferenceEntryToOption: (entry: CmsReferenceContentEntry) => OptionItem;
|
|
4
|
+
export declare const convertReferenceEntriesToOptionCollection: (entries: CmsReferenceContentEntry[]) => OptionItemCollection;
|
|
5
|
+
export declare const getEntryStatus: (item: OptionItem) => CmsContentEntryStatusType;
|
|
6
|
+
export declare const getItemStatusText: (item: OptionItem) => string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export var convertReferenceEntryToOption = function convertReferenceEntryToOption(entry) {
|
|
2
|
+
return {
|
|
3
|
+
id: entry.id,
|
|
4
|
+
entryId: entry.entryId,
|
|
5
|
+
modelId: entry.model.modelId,
|
|
6
|
+
modelName: entry.model.name,
|
|
7
|
+
published: entry.published ? entry.published.id : null,
|
|
8
|
+
latest: entry.id,
|
|
9
|
+
status: entry.status,
|
|
10
|
+
name: entry.title
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export var convertReferenceEntriesToOptionCollection = function convertReferenceEntriesToOptionCollection(entries) {
|
|
14
|
+
return entries.reduce(function (collection, entry) {
|
|
15
|
+
collection[entry.entryId] = convertReferenceEntryToOption(entry);
|
|
16
|
+
return collection;
|
|
17
|
+
}, {});
|
|
18
|
+
};
|
|
19
|
+
export var getEntryStatus = function getEntryStatus(item) {
|
|
20
|
+
if (item.status === "published") {
|
|
21
|
+
return "published";
|
|
22
|
+
} else if (item.status === "unpublished" || !item.published && item.status === "draft") {
|
|
23
|
+
return "unpublished";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return "draft";
|
|
27
|
+
};
|
|
28
|
+
export var getItemStatusText = function getItemStatusText(item) {
|
|
29
|
+
var status = getEntryStatus(item);
|
|
30
|
+
|
|
31
|
+
switch (status) {
|
|
32
|
+
case "published":
|
|
33
|
+
return "This entry is published.";
|
|
34
|
+
|
|
35
|
+
case "unpublished":
|
|
36
|
+
return "This entry has not been published.";
|
|
37
|
+
|
|
38
|
+
default:
|
|
39
|
+
return "Latest revision of this entry is in draft stage.";
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["helpers.ts"],"names":["convertReferenceEntryToOption","entry","id","entryId","modelId","model","modelName","name","published","latest","status","title","convertReferenceEntriesToOptionCollection","entries","reduce","collection","getEntryStatus","item","getItemStatusText"],"mappings":"AAGA,OAAO,IAAMA,6BAA6B,GAAG,SAAhCA,6BAAgC,CAACC,KAAD,EAAiD;AAC1F,SAAO;AACHC,IAAAA,EAAE,EAAED,KAAK,CAACC,EADP;AAEHC,IAAAA,OAAO,EAAEF,KAAK,CAACE,OAFZ;AAGHC,IAAAA,OAAO,EAAEH,KAAK,CAACI,KAAN,CAAYD,OAHlB;AAIHE,IAAAA,SAAS,EAAEL,KAAK,CAACI,KAAN,CAAYE,IAJpB;AAKHC,IAAAA,SAAS,EAAEP,KAAK,CAACO,SAAN,GAAkBP,KAAK,CAACO,SAAN,CAAgBN,EAAlC,GAAuC,IAL/C;AAMHO,IAAAA,MAAM,EAAER,KAAK,CAACC,EANX;AAOHQ,IAAAA,MAAM,EAAET,KAAK,CAACS,MAPX;AAQHH,IAAAA,IAAI,EAAEN,KAAK,CAACU;AART,GAAP;AAUH,CAXM;AAaP,OAAO,IAAMC,yCAAyC,GAAG,SAA5CA,yCAA4C,CACrDC,OADqD,EAE9B;AACvB,SAAOA,OAAO,CAACC,MAAR,CAAe,UAACC,UAAD,EAAad,KAAb,EAAuB;AACzCc,IAAAA,UAAU,CAACd,KAAK,CAACE,OAAP,CAAV,GAA4BH,6BAA6B,CAACC,KAAD,CAAzD;AACA,WAAOc,UAAP;AACH,GAHM,EAGJ,EAHI,CAAP;AAIH,CAPM;AASP,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,IAAD,EAAiD;AAC3E,MAAIA,IAAI,CAACP,MAAL,KAAgB,WAApB,EAAiC;AAC7B,WAAO,WAAP;AACH,GAFD,MAEO,IAAIO,IAAI,CAACP,MAAL,KAAgB,aAAhB,IAAkC,CAACO,IAAI,CAACT,SAAN,IAAmBS,IAAI,CAACP,MAAL,KAAgB,OAAzE,EAAmF;AACtF,WAAO,aAAP;AACH;;AACD,SAAO,OAAP;AACH,CAPM;AASP,OAAO,IAAMQ,iBAAiB,GAAG,SAApBA,iBAAoB,CAACD,IAAD,EAA8B;AAC3D,MAAMP,MAAM,GAAGM,cAAc,CAACC,IAAD,CAA7B;;AACA,UAAQP,MAAR;AACI,SAAK,WAAL;AACI,aAAO,0BAAP;;AACJ,SAAK,aAAL;AACI,aAAO,oCAAP;;AACJ;AACI,aAAO,kDAAP;AANR;AAQH,CAVM","sourcesContent":["import { CmsReferenceContentEntry, OptionItem, OptionItemCollection } from \"./types\";\nimport { CmsContentEntryStatusType } from \"~/types\";\n\nexport const convertReferenceEntryToOption = (entry: CmsReferenceContentEntry): OptionItem => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n modelId: entry.model.modelId,\n modelName: entry.model.name,\n published: entry.published ? entry.published.id : null,\n latest: entry.id,\n status: entry.status,\n name: entry.title\n };\n};\n\nexport const convertReferenceEntriesToOptionCollection = (\n entries: CmsReferenceContentEntry[]\n): OptionItemCollection => {\n return entries.reduce((collection, entry) => {\n collection[entry.entryId] = convertReferenceEntryToOption(entry);\n return collection;\n }, {} as OptionItemCollection);\n};\n\nexport const getEntryStatus = (item: OptionItem): CmsContentEntryStatusType => {\n if (item.status === \"published\") {\n return \"published\";\n } else if (item.status === \"unpublished\" || (!item.published && item.status === \"draft\")) {\n return \"unpublished\";\n }\n return \"draft\";\n};\n\nexport const getItemStatusText = (item: OptionItem): string => {\n const status = getEntryStatus(item);\n switch (status) {\n case \"published\":\n return \"This entry is published.\";\n case \"unpublished\":\n return \"This entry has not been published.\";\n default:\n return \"Latest revision of this entry is in draft stage.\";\n }\n};\n"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
import { OptionItem } from "./types";
|
|
3
|
+
export interface RenderItemProps {
|
|
3
4
|
name: string;
|
|
4
5
|
modelName: string;
|
|
5
6
|
modelId: string;
|
|
6
7
|
id: string;
|
|
7
8
|
}
|
|
8
|
-
export declare const renderItem: React.FC<
|
|
9
|
+
export declare const renderItem: React.FC<RenderItemProps>;
|
|
10
|
+
export declare const renderListItemOptions: (item: OptionItem) => JSX.Element;
|
|
@@ -3,16 +3,31 @@ import styled from "@emotion/styled";
|
|
|
3
3
|
import { Typography } from "@webiny/ui/Typography";
|
|
4
4
|
import { createEntryUrl } from "./createEntryUrl";
|
|
5
5
|
import { Link } from "@webiny/react-router";
|
|
6
|
+
import { EntryStatus } from "./EntryStatus";
|
|
7
|
+
import { IconButton } from "@webiny/ui/Button";
|
|
8
|
+
import { css } from "emotion";
|
|
6
9
|
var ModelId = /*#__PURE__*/styled("span", {
|
|
7
10
|
target: "ejkg0kv0",
|
|
8
11
|
label: "ModelId"
|
|
9
12
|
})({
|
|
10
13
|
color: "var(--mdc-theme-text-secondary-on-background) !important"
|
|
11
14
|
});
|
|
15
|
+
var iconButtonClassName = /*#__PURE__*/css({
|
|
16
|
+
verticalAlign: "top"
|
|
17
|
+
}, "label:iconButtonClassName;");
|
|
12
18
|
export var renderItem = function renderItem(props) {
|
|
13
19
|
return /*#__PURE__*/React.createElement(Typography, {
|
|
14
20
|
use: "body2"
|
|
15
21
|
}, /*#__PURE__*/React.createElement(Link, {
|
|
16
22
|
to: createEntryUrl(props)
|
|
17
23
|
}, props.name), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(ModelId, null, "Model: ", props.modelName));
|
|
24
|
+
};
|
|
25
|
+
export var renderListItemOptions = function renderListItemOptions(item) {
|
|
26
|
+
return /*#__PURE__*/React.createElement(IconButton, {
|
|
27
|
+
icon: /*#__PURE__*/React.createElement(EntryStatus, {
|
|
28
|
+
item: item,
|
|
29
|
+
placement: "top"
|
|
30
|
+
}),
|
|
31
|
+
className: iconButtonClassName
|
|
32
|
+
});
|
|
18
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["renderItem.tsx"],"names":["React","styled","Typography","createEntryUrl","Link","ModelId","color","renderItem","props","name","modelName"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,SAASC,UAAT,QAA2B,uBAA3B;AACA,SAASC,cAAT;AACA,SAASC,IAAT,QAAqB,sBAArB;AAEA,IAAMC,OAAO,
|
|
1
|
+
{"version":3,"sources":["renderItem.tsx"],"names":["React","styled","Typography","createEntryUrl","Link","EntryStatus","IconButton","css","ModelId","color","iconButtonClassName","verticalAlign","renderItem","props","name","modelName","renderListItemOptions","item"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,SAASC,UAAT,QAA2B,uBAA3B;AACA,SAASC,cAAT;AACA,SAASC,IAAT,QAAqB,sBAArB;AAEA,SAASC,WAAT;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,SAASC,GAAT,QAAoB,SAApB;AAEA,IAAMC,OAAO,gBAAGP,MAAH,CAAU,MAAV;AAAA;AAAA;AAAA,GAAkB;AAC3BQ,EAAAA,KAAK,EAAE;AADoB,CAAlB,CAAb;AAIA,IAAMC,mBAAmB,gBAAGH,GAAG,CAAC;AAC5BI,EAAAA,aAAa,EAAE;AADa,CAAD,+BAA/B;AAUA,OAAO,IAAMC,UAAqC,GAAG,SAAxCA,UAAwC,CAAAC,KAAK,EAAI;AAC1D,sBACI,oBAAC,UAAD;AAAY,IAAA,GAAG,EAAE;AAAjB,kBACI,oBAAC,IAAD;AAAM,IAAA,EAAE,EAAEV,cAAc,CAACU,KAAD;AAAxB,KAAkCA,KAAK,CAACC,IAAxC,CADJ,eAEI,+BAFJ,eAGI,oBAAC,OAAD,mBAAiBD,KAAK,CAACE,SAAvB,CAHJ,CADJ;AAOH,CARM;AAUP,OAAO,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,IAAD,EAAsB;AACvD,sBACI,oBAAC,UAAD;AACI,IAAA,IAAI,eAAE,oBAAC,WAAD;AAAa,MAAA,IAAI,EAAEA,IAAnB;AAAyB,MAAA,SAAS,EAAE;AAApC,MADV;AAEI,IAAA,SAAS,EAAEP;AAFf,IADJ;AAMH,CAPM","sourcesContent":["import React from \"react\";\nimport styled from \"@emotion/styled\";\nimport { Typography } from \"@webiny/ui/Typography\";\nimport { createEntryUrl } from \"./createEntryUrl\";\nimport { Link } from \"@webiny/react-router\";\nimport { OptionItem } from \"./types\";\nimport { EntryStatus } from \"./EntryStatus\";\nimport { IconButton } from \"@webiny/ui/Button\";\nimport { css } from \"emotion\";\n\nconst ModelId = styled(\"span\")({\n color: \"var(--mdc-theme-text-secondary-on-background) !important\"\n});\n\nconst iconButtonClassName = css({\n verticalAlign: \"top\"\n});\n\nexport interface RenderItemProps {\n name: string;\n modelName: string;\n modelId: string;\n id: string;\n}\nexport const renderItem: React.FC<RenderItemProps> = props => {\n return (\n <Typography use={\"body2\"}>\n <Link to={createEntryUrl(props)}>{props.name}</Link>\n <br />\n <ModelId>Model: {props.modelName}</ModelId>\n </Typography>\n );\n};\n\nexport const renderListItemOptions = (item: OptionItem) => {\n return (\n <IconButton\n icon={<EntryStatus item={item} placement={\"top\"} />}\n className={iconButtonClassName}\n />\n );\n};\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CmsContentEntryStatusType, CmsModel } from "../../../../../types";
|
|
2
|
+
export interface OptionItem {
|
|
3
|
+
id: string;
|
|
4
|
+
entryId: string;
|
|
5
|
+
modelId: string;
|
|
6
|
+
modelName: string;
|
|
7
|
+
name: string;
|
|
8
|
+
published: string | null;
|
|
9
|
+
latest: string | null;
|
|
10
|
+
status: CmsContentEntryStatusType;
|
|
11
|
+
}
|
|
12
|
+
export interface OptionItemCollection {
|
|
13
|
+
[key: string]: OptionItem;
|
|
14
|
+
}
|
|
15
|
+
export interface CmsReferenceContentEntry {
|
|
16
|
+
id: string;
|
|
17
|
+
entryId: string;
|
|
18
|
+
title: string;
|
|
19
|
+
status: CmsContentEntryStatusType;
|
|
20
|
+
model: Pick<CmsModel, "modelId" | "name">;
|
|
21
|
+
published?: {
|
|
22
|
+
id: string;
|
|
23
|
+
entryId: string;
|
|
24
|
+
title: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OptionItem } from "./getOptions";
|
|
2
1
|
import { CmsEditorField } from "../../../../../types";
|
|
3
2
|
import { BindComponentRenderProp } from "@webiny/form";
|
|
3
|
+
import { OptionItem } from "./types";
|
|
4
4
|
interface UseReferenceHookArgs {
|
|
5
5
|
bind: BindComponentRenderProp;
|
|
6
6
|
field: CmsEditorField;
|