@webiny/app-headless-cms 0.0.0-unstable.9e825fd5fb → 0.0.0-unstable.ad3a7a4920
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/Dialog.js +1 -1
- package/admin/components/Dialog.js.map +1 -1
- package/admin/hooks/useContentModels.d.ts +8 -0
- package/admin/hooks/useContentModels.js +9 -2
- package/admin/hooks/useContentModels.js.map +1 -1
- package/admin/menus/ContentGroupsMenuItems.js +1 -2
- package/admin/menus/ContentGroupsMenuItems.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/advanced/components/Entries.js +1 -1
- package/admin/plugins/fieldRenderers/ref/advanced/components/Entries.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/advanced/components/NewReferencedEntryDialog.js +3 -3
- package/admin/plugins/fieldRenderers/ref/advanced/components/NewReferencedEntryDialog.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/advanced/components/ReferencesDialog.js +1 -1
- package/admin/plugins/fieldRenderers/ref/advanced/components/ReferencesDialog.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/advanced/hooks/graphql.js +1 -5
- package/admin/plugins/fieldRenderers/ref/advanced/hooks/graphql.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/components/NewRefEntryFormDialog.d.ts +2 -2
- package/admin/plugins/fieldRenderers/ref/components/NewRefEntryFormDialog.js +3 -3
- package/admin/plugins/fieldRenderers/ref/components/NewRefEntryFormDialog.js.map +1 -1
- package/admin/plugins/fields/dynamicZone.d.ts +2 -2
- package/admin/plugins/fields/dynamicZone.js +1 -1
- package/admin/plugins/fields/dynamicZone.js.map +1 -1
- package/admin/plugins/routes.js +2 -1
- package/admin/plugins/routes.js.map +1 -1
- package/admin/views/contentEntries/ContentEntries.js +8 -57
- package/admin/views/contentEntries/ContentEntries.js.map +1 -1
- package/admin/views/contentEntries/ContentEntriesContainer.d.ts +4 -0
- package/admin/views/contentEntries/ContentEntriesContainer.js +65 -0
- package/admin/views/contentEntries/ContentEntriesContainer.js.map +1 -0
- package/admin/views/contentEntries/ContentEntriesContext.d.ts +1 -1
- package/admin/views/contentEntries/ContentEntriesContext.js +4 -4
- package/admin/views/contentEntries/ContentEntriesContext.js.map +1 -1
- package/admin/views/contentEntries/ContentEntriesList.js +2 -3
- package/admin/views/contentEntries/ContentEntriesList.js.map +1 -1
- package/admin/views/contentEntries/ContentEntry/ContentEntryContext.d.ts +1 -1
- package/admin/views/contentEntries/ContentEntry/ContentEntryContext.js +4 -4
- package/admin/views/contentEntries/ContentEntry/ContentEntryContext.js.map +1 -1
- package/admin/views/contentEntries/experiment/ContentEntriesViewConfig.d.ts +2 -0
- package/admin/views/contentEntries/experiment/ContentEntriesViewConfig.js +36 -39
- package/admin/views/contentEntries/experiment/ContentEntriesViewConfig.js.map +1 -1
- package/admin/views/contentEntries/experiment/Property.js +57 -9
- package/admin/views/contentEntries/experiment/Property.js.map +1 -1
- package/admin/views/contentModels/ContentModelsDataList.js +3 -3
- package/admin/views/contentModels/ContentModelsDataList.js.map +1 -1
- package/package.json +19 -19
|
@@ -24,5 +24,5 @@ Object.keys(_Dialog).forEach(function (key) {
|
|
|
24
24
|
var Dialog = /*#__PURE__*/(0, _styled.default)(_Dialog.Dialog, {
|
|
25
25
|
label: "Dialog",
|
|
26
26
|
target: "e1q5k1p00"
|
|
27
|
-
})(".mdc-dialog__surface{width:600px;min-width:600px;overflow:initial;}.mdc-dialog__content{overflow:
|
|
27
|
+
})(".mdc-dialog__surface{width:600px;min-width:600px;overflow:initial;}.mdc-dialog__content{overflow:auto;.mdc-list:first-of-type{padding:0;}}");
|
|
28
28
|
exports.Dialog = Dialog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Dialog","styled","BaseDialog"],"sources":["Dialog.tsx"],"sourcesContent":["import styled from \"@emotion/styled\";\nimport { Dialog as BaseDialog } from \"@webiny/ui/Dialog\";\nexport * from \"@webiny/ui/Dialog\";\n\nexport const Dialog = styled(BaseDialog)`\n .mdc-dialog__surface {\n width: 600px;\n min-width: 600px;\n overflow: initial;\n }\n\n .mdc-dialog__content {\n overflow:
|
|
1
|
+
{"version":3,"names":["Dialog","styled","BaseDialog"],"sources":["Dialog.tsx"],"sourcesContent":["import styled from \"@emotion/styled\";\nimport { Dialog as BaseDialog } from \"@webiny/ui/Dialog\";\nexport * from \"@webiny/ui/Dialog\";\n\nexport const Dialog = styled(BaseDialog)`\n .mdc-dialog__surface {\n width: 600px;\n min-width: 600px;\n overflow: initial;\n }\n\n .mdc-dialog__content {\n overflow: auto;\n .mdc-list:first-of-type {\n padding: 0;\n }\n }\n`;\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEO,IAAMA,MAAM,oBAAGC,eAAM,EAACC,cAAU;EAAA;EAAA;AAAA,gJAatC;AAAC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { CmsModel } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use `useModels` hook instead.
|
|
4
|
+
*/
|
|
2
5
|
export declare const useContentModels: () => {
|
|
3
6
|
models: CmsModel[];
|
|
4
7
|
loading: boolean;
|
|
5
8
|
error: string | null;
|
|
6
9
|
};
|
|
10
|
+
export declare const useModels: () => {
|
|
11
|
+
models: CmsModel[];
|
|
12
|
+
loading: boolean;
|
|
13
|
+
error: string | null;
|
|
14
|
+
};
|
|
@@ -4,10 +4,13 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.useContentModels = void 0;
|
|
7
|
+
exports.useModels = exports.useContentModels = void 0;
|
|
8
8
|
var GQL = _interopRequireWildcard(require("../viewsGraphql"));
|
|
9
9
|
var _index = require("./index");
|
|
10
10
|
var _react = require("react");
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `useModels` hook instead.
|
|
13
|
+
*/
|
|
11
14
|
var useContentModels = function useContentModels() {
|
|
12
15
|
var _useQuery = (0, _index.useQuery)(GQL.LIST_CONTENT_MODELS),
|
|
13
16
|
data = _useQuery.data,
|
|
@@ -30,4 +33,8 @@ var useContentModels = function useContentModels() {
|
|
|
30
33
|
error: error
|
|
31
34
|
};
|
|
32
35
|
};
|
|
33
|
-
exports.useContentModels = useContentModels;
|
|
36
|
+
exports.useContentModels = useContentModels;
|
|
37
|
+
var useModels = function useModels() {
|
|
38
|
+
return useContentModels();
|
|
39
|
+
};
|
|
40
|
+
exports.useModels = useModels;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useContentModels","useQuery","GQL","LIST_CONTENT_MODELS","data","loading","apolloError","error","models","useMemo","listContentModels","message"],"sources":["useContentModels.ts"],"sourcesContent":["import * as GQL from \"~/admin/viewsGraphql\";\nimport { useQuery } from \"~/admin/hooks/index\";\nimport { ListCmsModelsQueryResponse } from \"~/admin/viewsGraphql\";\nimport { useMemo } from \"react\";\nimport { CmsModel } from \"~/types\";\n\nexport const useContentModels = () => {\n const {\n data,\n loading,\n error: apolloError\n } = useQuery<ListCmsModelsQueryResponse>(GQL.LIST_CONTENT_MODELS);\n\n const models = useMemo<CmsModel[]>(() => {\n return data?.listContentModels?.data || [];\n }, [data]);\n\n const error = useMemo(() => {\n if (!!apolloError) {\n return apolloError.message;\n }\n return data?.listContentModels?.error?.message || null;\n }, [apolloError]);\n\n return {\n models,\n loading,\n error\n };\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;
|
|
1
|
+
{"version":3,"names":["useContentModels","useQuery","GQL","LIST_CONTENT_MODELS","data","loading","apolloError","error","models","useMemo","listContentModels","message","useModels"],"sources":["useContentModels.ts"],"sourcesContent":["import * as GQL from \"~/admin/viewsGraphql\";\nimport { useQuery } from \"~/admin/hooks/index\";\nimport { ListCmsModelsQueryResponse } from \"~/admin/viewsGraphql\";\nimport { useMemo } from \"react\";\nimport { CmsModel } from \"~/types\";\n\n/**\n * @deprecated Use `useModels` hook instead.\n */\nexport const useContentModels = () => {\n const {\n data,\n loading,\n error: apolloError\n } = useQuery<ListCmsModelsQueryResponse>(GQL.LIST_CONTENT_MODELS);\n\n const models = useMemo<CmsModel[]>(() => {\n return data?.listContentModels?.data || [];\n }, [data]);\n\n const error = useMemo(() => {\n if (!!apolloError) {\n return apolloError.message;\n }\n return data?.listContentModels?.error?.message || null;\n }, [apolloError]);\n\n return {\n models,\n loading,\n error\n };\n};\n\nexport const useModels = () => {\n return useContentModels();\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AAGA;AACA;AACA;AACO,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgB,GAAS;EAClC,gBAII,IAAAC,eAAQ,EAA6BC,GAAG,CAACC,mBAAmB,CAAC;IAH7DC,IAAI,aAAJA,IAAI;IACJC,OAAO,aAAPA,OAAO;IACAC,WAAW,aAAlBC,KAAK;EAGT,IAAMC,MAAM,GAAG,IAAAC,cAAO,EAAa,YAAM;IAAA;IACrC,OAAO,CAAAL,IAAI,aAAJA,IAAI,gDAAJA,IAAI,CAAEM,iBAAiB,0DAAvB,sBAAyBN,IAAI,KAAI,EAAE;EAC9C,CAAC,EAAE,CAACA,IAAI,CAAC,CAAC;EAEV,IAAMG,KAAK,GAAG,IAAAE,cAAO,EAAC,YAAM;IAAA;IACxB,IAAI,CAAC,CAACH,WAAW,EAAE;MACf,OAAOA,WAAW,CAACK,OAAO;IAC9B;IACA,OAAO,CAAAP,IAAI,aAAJA,IAAI,iDAAJA,IAAI,CAAEM,iBAAiB,qFAAvB,uBAAyBH,KAAK,2DAA9B,uBAAgCI,OAAO,KAAI,IAAI;EAC1D,CAAC,EAAE,CAACL,WAAW,CAAC,CAAC;EAEjB,OAAO;IACHE,MAAM,EAANA,MAAM;IACNH,OAAO,EAAPA,OAAO;IACPE,KAAK,EAALA;EACJ,CAAC;AACL,CAAC;AAAC;AAEK,IAAMK,SAAS,GAAG,SAAZA,SAAS,GAAS;EAC3B,OAAOZ,gBAAgB,EAAE;AAC7B,CAAC;AAAC"}
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.ContentGroupsMenuItems = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
10
|
-
var _pluralize = _interopRequireDefault(require("pluralize"));
|
|
11
10
|
var _reactFontawesome = require("@fortawesome/react-fontawesome");
|
|
12
11
|
var _viewsGraphql = require("../viewsGraphql");
|
|
13
12
|
var _useQuery = _interopRequireDefault(require("../hooks/useQuery"));
|
|
@@ -76,7 +75,7 @@ var ContentGroupsMenuItems = function ContentGroupsMenuItems() {
|
|
|
76
75
|
contentModel: contentModel
|
|
77
76
|
}, /*#__PURE__*/_react.default.createElement(_appAdmin.AddMenu, {
|
|
78
77
|
name: contentModel.modelId,
|
|
79
|
-
label:
|
|
78
|
+
label: contentModel.name,
|
|
80
79
|
path: "/cms/content-entries/".concat(contentModel.modelId)
|
|
81
80
|
}));
|
|
82
81
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HasContentEntryPermissions","group","contentModel","children","usePermission","canReadEntries","contentModelGroup","hasContentEntryPermission","contentModels","some","length","Icon","color","icon","split","ContentGroupsMenuItems","response","useQuery","LIST_MENU_CONTENT_GROUPS_MODELS","groups","get","map","id","name","modelId"
|
|
1
|
+
{"version":3,"names":["HasContentEntryPermissions","group","contentModel","children","usePermission","canReadEntries","contentModelGroup","hasContentEntryPermission","contentModels","some","length","Icon","color","icon","split","ContentGroupsMenuItems","response","useQuery","LIST_MENU_CONTENT_GROUPS_MODELS","groups","get","map","id","name","modelId"],"sources":["ContentGroupsMenuItems.tsx"],"sourcesContent":["import React from \"react\";\nimport get from \"lodash/get\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport {\n LIST_MENU_CONTENT_GROUPS_MODELS,\n ListMenuCmsGroupsQueryResponse\n} from \"~/admin/viewsGraphql\";\nimport useQuery from \"~/admin/hooks/useQuery\";\nimport usePermission from \"~/admin/hooks/usePermission\";\nimport { AddMenu as Menu } from \"@webiny/app-admin\";\nimport { NothingToShow } from \"./NothingToShowElement\";\nimport { CmsGroup, CmsModel } from \"~/types\";\nimport { IconProp } from \"@fortawesome/fontawesome-svg-core\";\n\ninterface HasContentEntryPermissionsProps {\n group: CmsGroup;\n contentModel?: CmsModel;\n children: JSX.Element;\n}\n\nconst HasContentEntryPermissions: React.FC<HasContentEntryPermissionsProps> = ({\n group,\n contentModel,\n children\n}) => {\n const { canReadEntries } = usePermission();\n\n if (contentModel) {\n if (!canReadEntries({ contentModelGroup: group, contentModel })) {\n return null;\n }\n } else {\n const hasContentEntryPermission = group.contentModels.some(contentModel =>\n canReadEntries({\n contentModelGroup: group,\n contentModel\n })\n );\n\n if (group.contentModels.length > 0 && !hasContentEntryPermission) {\n return null;\n }\n }\n\n return children;\n};\n\ninterface IconProps {\n group: CmsGroup;\n}\nconst Icon: React.FC<IconProps> = ({ group }) => {\n return (\n <FontAwesomeIcon\n style={{ color: \"var(--mdc-theme-text-secondary-on-background)\" }}\n icon={(group.icon || \"\").split(\"/\") as IconProp}\n />\n );\n};\n\nexport const ContentGroupsMenuItems: React.FC = () => {\n const response = useQuery<ListMenuCmsGroupsQueryResponse>(LIST_MENU_CONTENT_GROUPS_MODELS);\n const groups: CmsGroup[] = get(response, \"data.listContentModelGroups.data\") || [];\n\n if (!groups || groups.length === 0) {\n return null;\n }\n\n return (\n <>\n {groups.map(group => {\n return (\n <HasContentEntryPermissions key={group.id} group={group}>\n <Menu\n name={group.id}\n label={group.name}\n tags={[\"headlessCMS\"]}\n icon={<Icon group={group} />}\n >\n {group.contentModels.length === 0 && (\n <Menu name={`${group.id}-empty`} element={<NothingToShow />} />\n )}\n {group.contentModels.length > 0 &&\n group.contentModels.map(contentModel => (\n <HasContentEntryPermissions\n key={contentModel.modelId}\n group={group}\n contentModel={contentModel}\n >\n <Menu\n name={contentModel.modelId}\n label={contentModel.name}\n path={`/cms/content-entries/${contentModel.modelId}`}\n />\n </HasContentEntryPermissions>\n ))}\n </Menu>\n </HasContentEntryPermissions>\n );\n })}\n </>\n );\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAUA,IAAMA,0BAAqE,GAAG,SAAxEA,0BAAqE,OAIrE;EAAA,IAHFC,KAAK,QAALA,KAAK;IACLC,YAAY,QAAZA,YAAY;IACZC,QAAQ,QAARA,QAAQ;EAER,qBAA2B,IAAAC,uBAAa,GAAE;IAAlCC,cAAc,kBAAdA,cAAc;EAEtB,IAAIH,YAAY,EAAE;IACd,IAAI,CAACG,cAAc,CAAC;MAAEC,iBAAiB,EAAEL,KAAK;MAAEC,YAAY,EAAZA;IAAa,CAAC,CAAC,EAAE;MAC7D,OAAO,IAAI;IACf;EACJ,CAAC,MAAM;IACH,IAAMK,yBAAyB,GAAGN,KAAK,CAACO,aAAa,CAACC,IAAI,CAAC,UAAAP,YAAY;MAAA,OACnEG,cAAc,CAAC;QACXC,iBAAiB,EAAEL,KAAK;QACxBC,YAAY,EAAZA;MACJ,CAAC,CAAC;IAAA,EACL;IAED,IAAID,KAAK,CAACO,aAAa,CAACE,MAAM,GAAG,CAAC,IAAI,CAACH,yBAAyB,EAAE;MAC9D,OAAO,IAAI;IACf;EACJ;EAEA,OAAOJ,QAAQ;AACnB,CAAC;AAKD,IAAMQ,IAAyB,GAAG,SAA5BA,IAAyB,QAAkB;EAAA,IAAZV,KAAK,SAALA,KAAK;EACtC,oBACI,6BAAC,iCAAe;IACZ,KAAK,EAAE;MAAEW,KAAK,EAAE;IAAgD,CAAE;IAClE,IAAI,EAAE,CAACX,KAAK,CAACY,IAAI,IAAI,EAAE,EAAEC,KAAK,CAAC,GAAG;EAAc,EAClD;AAEV,CAAC;AAEM,IAAMC,sBAAgC,G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CAAC;AAAC"}
|
|
@@ -46,7 +46,7 @@ var Entries = function Entries(props) {
|
|
|
46
46
|
loadMore();
|
|
47
47
|
}, 500), [entries, loadMore]);
|
|
48
48
|
if (entries.length === 0) {
|
|
49
|
-
return null;
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "No entries found.");
|
|
50
50
|
}
|
|
51
51
|
return /*#__PURE__*/_react.default.createElement(Container, {
|
|
52
52
|
className: "entries"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Container","styled","minWidth","height","backgroundColor","boxSizing","display","overflowX","overflowY","paddingRight","ContainerChild","width","margin","Entries","props","entries","children","loadMore","loadMoreOnScroll","useCallback","debounce","position","top","length","map","entry","index","id"],"sources":["Entries.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport debounce from \"lodash/debounce\";\nimport styled from \"@emotion/styled\";\nimport { CmsReferenceContentEntry } from \"~/admin/plugins/fieldRenderers/ref/components/types\";\nimport { Scrollbar } from \"@webiny/ui/Scrollbar\";\nimport { positionValues as PositionValues } from \"react-custom-scrollbars\";\n\nconst Container = styled(\"div\")(() => ({\n minWidth: \"100%\",\n height: \"460px\",\n backgroundColor: \"var(--mdc-theme-background)\",\n boxSizing: \"border-box\",\n display: \"flex\",\n \">div>div\": {\n overflowX: \"hidden !important\" as any,\n overflowY: \"scroll\",\n paddingRight: 20\n }\n}));\nconst ContainerChild = styled(\"div\")({\n boxSizing: \"border-box\",\n width: \"100%\",\n margin: \"0 2px 25px 2px\"\n});\n\ninterface Props {\n entries: CmsReferenceContentEntry[];\n children: (entry: CmsReferenceContentEntry, index: number) => React.ReactNode;\n loadMore: () => void;\n}\n\nexport const Entries: React.VFC<Props> = props => {\n const { entries, children, loadMore } = props;\n\n const loadMoreOnScroll = useCallback(\n debounce((position: PositionValues) => {\n if (position.top <= 0.9) {\n return;\n }\n loadMore();\n }, 500),\n [entries, loadMore]\n );\n\n if (entries.length === 0) {\n return
|
|
1
|
+
{"version":3,"names":["Container","styled","minWidth","height","backgroundColor","boxSizing","display","overflowX","overflowY","paddingRight","ContainerChild","width","margin","Entries","props","entries","children","loadMore","loadMoreOnScroll","useCallback","debounce","position","top","length","map","entry","index","id"],"sources":["Entries.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport debounce from \"lodash/debounce\";\nimport styled from \"@emotion/styled\";\nimport { CmsReferenceContentEntry } from \"~/admin/plugins/fieldRenderers/ref/components/types\";\nimport { Scrollbar } from \"@webiny/ui/Scrollbar\";\nimport { positionValues as PositionValues } from \"react-custom-scrollbars\";\n\nconst Container = styled(\"div\")(() => ({\n minWidth: \"100%\",\n height: \"460px\",\n backgroundColor: \"var(--mdc-theme-background)\",\n boxSizing: \"border-box\",\n display: \"flex\",\n \">div>div\": {\n overflowX: \"hidden !important\" as any,\n overflowY: \"scroll\",\n paddingRight: 20\n }\n}));\nconst ContainerChild = styled(\"div\")({\n boxSizing: \"border-box\",\n width: \"100%\",\n margin: \"0 2px 25px 2px\"\n});\n\ninterface Props {\n entries: CmsReferenceContentEntry[];\n children: (entry: CmsReferenceContentEntry, index: number) => React.ReactNode;\n loadMore: () => void;\n}\n\nexport const Entries: React.VFC<Props> = props => {\n const { entries, children, loadMore } = props;\n\n const loadMoreOnScroll = useCallback(\n debounce((position: PositionValues) => {\n if (position.top <= 0.9) {\n return;\n }\n loadMore();\n }, 500),\n [entries, loadMore]\n );\n\n if (entries.length === 0) {\n return <>No entries found.</>;\n }\n return (\n <Container className={\"entries\"}>\n <Scrollbar data-testid=\"advanced-ref-field-entries\" onScrollFrame={loadMoreOnScroll}>\n {entries.map((entry, index) => {\n return (\n <ContainerChild key={`entry-${entry.id}`}>\n {children(entry, index)}\n </ContainerChild>\n );\n })}\n </Scrollbar>\n </Container>\n );\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AAEA;AAGA,IAAMA,SAAS,oBAAGC,eAAM,EAAC,KAAK;EAAA;EAAA;AAAA,GAAE;EAAA,OAAO;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,CAAC,CACV;EAEzB,CAAC,CAAC,CACM,CACJ;AAEpB,CAAC;AAAC"}
|
|
@@ -35,7 +35,7 @@ var EntryForm = function EntryForm(_ref) {
|
|
|
35
35
|
}, /*#__PURE__*/_react.default.createElement(_ContentEntryForm.ContentEntryForm, {
|
|
36
36
|
onSubmit: function onSubmit(data) {
|
|
37
37
|
/**
|
|
38
|
-
* We know that data is
|
|
38
|
+
* We know that data is CmsContentEntry.
|
|
39
39
|
*/
|
|
40
40
|
return onCreate(data);
|
|
41
41
|
},
|
|
@@ -119,11 +119,11 @@ var NewReferencedEntryDialog = function NewReferencedEntryDialog(_ref3) {
|
|
|
119
119
|
if (!model) {
|
|
120
120
|
return null;
|
|
121
121
|
}
|
|
122
|
-
return /*#__PURE__*/_react.default.createElement(_ContentEntriesContext.
|
|
122
|
+
return /*#__PURE__*/_react.default.createElement(_ContentEntriesContext.ContentEntriesProvider, {
|
|
123
123
|
contentModel: model,
|
|
124
124
|
key: model.modelId,
|
|
125
125
|
insideDialog: true
|
|
126
|
-
}, /*#__PURE__*/_react.default.createElement(_ContentEntryContext.
|
|
126
|
+
}, /*#__PURE__*/_react.default.createElement(_ContentEntryContext.ContentEntryProvider, {
|
|
127
127
|
isNewEntry: function isNewEntry() {
|
|
128
128
|
return true;
|
|
129
129
|
},
|
package/admin/plugins/fieldRenderers/ref/advanced/components/NewReferencedEntryDialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["t","i18n","ns","EntryForm","onCreate","useContentEntry","setFormRef","contentModel","data","form","DialogSaveButton","onClick","useCallback","ev","current","submit","NewReferencedEntryDialog","baseModel","model","onClose","onChange","useCms","apolloClient","useState","undefined","setModel","useEffect","query","GET_CONTENT_MODEL","variables","modelId","response","getContentModel","entry","published","meta","status","modelName","name"],"sources":["NewReferencedEntryDialog.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"names":["t","i18n","ns","EntryForm","onCreate","useContentEntry","setFormRef","contentModel","data","form","DialogSaveButton","onClick","useCallback","ev","current","submit","NewReferencedEntryDialog","baseModel","model","onClose","onChange","useCms","apolloClient","useState","undefined","setModel","useEffect","query","GET_CONTENT_MODEL","variables","modelId","response","getContentModel","entry","published","meta","status","modelName","name"],"sources":["NewReferencedEntryDialog.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\nimport { ContentEntryProvider } from \"~/admin/views/contentEntries/ContentEntry/ContentEntryContext\";\nimport { DialogActions, DialogCancel, DialogContent, DialogTitle } from \"@webiny/ui/Dialog\";\nimport { ContentEntriesProvider } from \"~/admin/views/contentEntries/ContentEntriesContext\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { CmsContentEntry, CmsModel } from \"~/types\";\nimport { useContentEntry } from \"~/admin/views/contentEntries/hooks/useContentEntry\";\nimport { ModelProvider } from \"~/admin/components/ModelProvider\";\nimport { ContentEntryForm } from \"~/admin/components/ContentEntryForm/ContentEntryForm\";\nimport { ButtonPrimary } from \"@webiny/ui/Button\";\nimport {\n GET_CONTENT_MODEL,\n GetCmsModelQueryResponse,\n GetCmsModelQueryVariables\n} from \"~/admin/graphql/contentModels\";\nimport { useCms } from \"~/admin/hooks\";\nimport { FullWidthDialog } from \"./dialog/Dialog\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/fields/ref\");\n\ninterface EntryFormProps {\n onCreate: (entry: CmsContentEntry) => void;\n}\n\nconst EntryForm: React.VFC<EntryFormProps> = ({ onCreate }) => {\n const { setFormRef, contentModel } = useContentEntry();\n\n return (\n <ModelProvider model={contentModel}>\n <ContentEntryForm\n onSubmit={data => {\n /**\n * We know that data is CmsContentEntry.\n */\n return onCreate(data as unknown as CmsContentEntry);\n }}\n onForm={form => setFormRef(form)}\n entry={{}}\n addEntryToListCache={false}\n />\n </ModelProvider>\n );\n};\n\nconst DialogSaveButton: React.VFC = () => {\n const { form } = useContentEntry();\n\n const onClick = useCallback(\n (ev: React.MouseEvent) => {\n (async () => {\n await form.current.submit(ev);\n })();\n },\n [form.current]\n );\n\n return <ButtonPrimary onClick={onClick}>{t`Create Entry`}</ButtonPrimary>;\n};\n\ninterface Props {\n model: Pick<CmsModel, \"modelId\">;\n onClose: () => void;\n onChange: (entry: any) => void;\n}\n\nexport const NewReferencedEntryDialog: React.VFC<Props> = ({\n model: baseModel,\n onClose,\n onChange\n}) => {\n const { apolloClient } = useCms();\n const [model, setModel] = useState<CmsModel | undefined>(undefined);\n\n useEffect(() => {\n (async () => {\n const response = await apolloClient.query<\n GetCmsModelQueryResponse,\n GetCmsModelQueryVariables\n >({\n query: GET_CONTENT_MODEL,\n variables: {\n modelId: baseModel.modelId\n }\n });\n setModel(response.data.getContentModel.data);\n })();\n }, [baseModel.modelId]);\n\n const onCreate = useCallback(\n (entry: CmsContentEntry) => {\n if (!model) {\n onClose();\n return;\n }\n onChange({\n ...entry,\n /*\n * Format data for AutoComplete.\n */\n published: entry.meta?.status === \"published\",\n modelId: model.modelId,\n modelName: model.name\n });\n onClose();\n },\n [onChange, model]\n );\n if (!model) {\n return null;\n }\n\n return (\n <ContentEntriesProvider contentModel={model} key={model.modelId} insideDialog={true}>\n <ContentEntryProvider isNewEntry={() => true} getContentId={() => null}>\n <FullWidthDialog open={true} onClose={onClose}>\n <DialogTitle>{t`New {modelName} Entry`({ modelName: model.name })}</DialogTitle>\n <DialogContent>\n <EntryForm onCreate={onCreate} />\n </DialogContent>\n <DialogActions>\n <DialogCancel>{t`Cancel`}</DialogCancel>\n <DialogSaveButton />\n </DialogActions>\n </FullWidthDialog>\n </ContentEntryProvider>\n </ContentEntriesProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAKA;AACA;AAAkD;AAElD,IAAMA,CAAC,GAAGC,UAAI,CAACC,EAAE,CAAC,mCAAmC,CAAC;AAMtD,IAAMC,SAAoC,GAAG,SAAvCA,SAAoC,OAAqB;EAAA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EnB,KAAK,CAACoB;EAAK,CAAC,CAAC,CAAe,eAChF,6BAAC,qBAAa,qBACV,6BAAC,SAAS;IAAC,QAAQ,EAAElC;EAAS,EAAG,CACrB,eAChB,6BAAC,qBAAa,qBACV,6BAAC,oBAAY,QAAEJ,CAAC,4FAAwB,eACxC,6BAAC,gBAAgB,OAAG,CACR,CACF,CACC,CACF;AAEjC,CAAC;AAAC"}
|
|
@@ -38,7 +38,7 @@ var Content = /*#__PURE__*/(0, _styled.default)("div", {
|
|
|
38
38
|
flexDirection: "column",
|
|
39
39
|
position: "relative",
|
|
40
40
|
width: "100%",
|
|
41
|
-
minHeight: "
|
|
41
|
+
minHeight: "20px",
|
|
42
42
|
boxSizing: "border-box",
|
|
43
43
|
padding: "20px 0 20px 20px",
|
|
44
44
|
backgroundColor: "var(--mdc-theme-background)",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Container","styled","width","boxSizing","padding","Content","display","flex","flexDirection","position","minHeight","backgroundColor","border","overflowX","DialogContent","BaseDialogContent","isSelected","entryId","values","some","value","parseIdentifier","id","valueEntryId","ReferencesDialog","props","contentModel","onDialogClose","storeValues","initialValues","multiple","useSnackbar","showSnackbar","useState","setValues","onChange","useCallback","reference","referenceEntryId","newValues","filter","length","onDialogSave","useEntries","model","limit","entries","loading","error","runSearch","loadMore","useEffect","debouncedSearch","useRef","onInput","ev","String","target","trim","current","clearTimeout","setTimeout","entry"],"sources":["ReferencesDialog.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport styled from \"@emotion/styled\";\nimport { DialogHeader } from \"./dialog/DialogHeader\";\nimport { Search } from \"./Search\";\nimport { Entry } from \"./Entry\";\nimport { DialogActions, DialogContent as BaseDialogContent } from \"~/admin/components/Dialog\";\nimport { CmsModelFieldRendererProps } from \"~/types\";\nimport { CmsReferenceValue } from \"~/admin/plugins/fieldRenderers/ref/components/types\";\nimport { ButtonDefault, ButtonPrimary } from \"@webiny/ui/Button\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { Dialog } from \"./dialog/Dialog\";\nimport { AbsoluteLoader } from \"~/admin/plugins/fieldRenderers/ref/advanced/components/Loader\";\nimport { useEntries } from \"~/admin/plugins/fieldRenderers/ref/advanced/hooks/useEntries\";\nimport { Entries } from \"./Entries\";\n\nconst Container = styled(\"div\")({\n width: \"100%\",\n boxSizing: \"border-box\",\n padding: \"20px\"\n});\n\nconst Content = styled(\"div\")({\n display: \"flex\",\n flex: \"1\",\n flexDirection: \"column\",\n position: \"relative\",\n width: \"100%\",\n minHeight: \"100px\",\n boxSizing: \"border-box\",\n padding: \"20px 0 20px 20px\",\n backgroundColor: \"var(--mdc-theme-background)\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n overflowX: \"hidden\"\n});\n\nconst DialogContent = styled(BaseDialogContent)({\n padding: \"0 !important\"\n});\n\nconst isSelected = (entryId: string, values: CmsReferenceValue[]) => {\n if (!entryId) {\n return false;\n }\n return values.some(value => {\n const { id: valueEntryId } = parseIdentifier(value.id);\n return entryId === valueEntryId;\n });\n};\n\ninterface Props extends CmsModelFieldRendererProps {\n values?: CmsReferenceValue[] | null;\n onDialogClose: () => void;\n storeValues: (values: CmsReferenceValue[]) => void;\n multiple: boolean;\n}\n\nexport const ReferencesDialog: React.VFC<Props> = props => {\n const { contentModel, onDialogClose, storeValues, values: initialValues, multiple } = props;\n const { showSnackbar } = useSnackbar();\n\n const [values, setValues] = useState<CmsReferenceValue[]>(initialValues || []);\n\n /**\n * On change needs to handle the adding or removing of a reference.\n *\n * This is for both single and multiple reference fields.\n */\n const onChange = useCallback(\n (reference: CmsReferenceValue) => {\n const { id: referenceEntryId } = parseIdentifier(reference.id);\n /**\n * Let's handle the single usage first as it is quite simple.\n */\n if (!multiple) {\n const [value] = values;\n if (!value?.id) {\n setValues([reference]);\n return;\n }\n const { id: valueEntryId } = parseIdentifier(value.id);\n if (referenceEntryId === valueEntryId) {\n setValues([]);\n return;\n }\n setValues([reference]);\n return;\n }\n\n const newValues = values.filter(value => {\n if (!value?.id) {\n return false;\n }\n const { id: valueEntryId } = parseIdentifier(value.id);\n return referenceEntryId !== valueEntryId;\n });\n if (newValues.length === values.length) {\n setValues([...values, reference]);\n return;\n }\n setValues(newValues);\n },\n [setValues, values]\n );\n\n const onDialogSave = useCallback(() => {\n storeValues(values);\n onDialogClose();\n }, [values]);\n /**\n * Searching and list of reference entries.\n */\n const { entries, loading, error, runSearch, loadMore } = useEntries({\n model: contentModel,\n limit: 10\n });\n\n useEffect(() => {\n runSearch(\"\");\n }, []);\n\n useEffect(() => {\n if (!error) {\n return;\n }\n showSnackbar(error);\n }, [error]);\n\n const debouncedSearch = useRef<number | null>(null);\n\n const onInput = useCallback(ev => {\n const value = (String(ev.target.value) || \"\").trim();\n if (debouncedSearch.current) {\n clearTimeout(debouncedSearch.current);\n debouncedSearch.current = null;\n }\n /**\n * We can safely cast as setTimeout really produces a number.\n * There is an error while coding because Storm thinks this is NodeJS timeout.\n */\n debouncedSearch.current = setTimeout(() => {\n runSearch(value);\n }, 200) as unknown as number;\n }, []);\n\n return (\n <>\n <Dialog open={true} onClose={onDialogClose}>\n <DialogHeader model={contentModel} onClose={onDialogClose} />\n <DialogContent>\n <Container>\n <Search onInput={onInput} />\n <Content>\n {loading && <AbsoluteLoader />}\n <Entries entries={entries} loadMore={loadMore}>\n {entry => {\n return (\n <Entry\n model={contentModel}\n key={`reference-entry-${entry.id}`}\n entry={entry}\n selected={isSelected(entry.entryId, values)}\n onChange={onChange}\n />\n );\n }}\n </Entries>\n </Content>\n </Container>\n </DialogContent>\n <DialogActions>\n <ButtonDefault onClick={onDialogClose}>Cancel</ButtonDefault>\n <ButtonPrimary onClick={onDialogSave}>Save</ButtonPrimary>\n </DialogActions>\n </Dialog>\n </>\n );\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;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AE,CAAC;EAEN,oBACI,yEACI,6BAAC,eAAM;IAAC,IAAI,EAAE,IAAK;IAAC,OAAO,EAAEO;EAAc,gBACvC,6BAAC,0BAAY;IAAC,KAAK,EAAED,YAAa;IAAC,OAAO,EAAEC;EAAc,EAAG,eAC7D,6BAAC,aAAa,qBACV,6BAAC,SAAS,qBACN,6BAAC,cAAM;IAAC,OAAO,EAAE2B;EAAQ,EAAG,eAC5B,6BAAC,OAAO,QACHP,OAAO,iBAAI,6BAAC,sBAAc,OAAG,eAC9B,6BAAC,gBAAO;IAAC,OAAO,EAAED,OAAQ;IAAC,QAAQ,EAAEI;EAAS,GACzC,UAAAY,KAAK,EAAI;IACN,oBACI,6BAAC,YAAK;MACF,KAAK,EAAEpC,YAAa;MACpB,GAAG,4BAAqBoC,KAAK,CAACxC,EAAE,CAAG;MACnC,KAAK,EAAEwC,KAAM;MACb,QAAQ,EAAE9C,UAAU,CAAC8C,KAAK,CAAC7C,OAAO,EAAEC,MAAM,CAAE;MAC5C,QAAQ,EAAEiB;IAAS,EACrB;EAEV,CAAC,CACK,CACJ,CACF,CACA,eAChB,6BAAC,qBAAa,qBACV,6BAAC,qBAAa;IAAC,OAAO,EAAER;EAAc,GAAC,QAAM,CAAgB,eAC7D,6BAAC,qBAAa;IAAC,OAAO,EAAEe;EAAa,GAAC,MAAI,CAAgB,CAC9C,CACX,CACV;AAEX,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["Container","styled","width","boxSizing","padding","Content","display","flex","flexDirection","position","minHeight","backgroundColor","border","overflowX","DialogContent","BaseDialogContent","isSelected","entryId","values","some","value","parseIdentifier","id","valueEntryId","ReferencesDialog","props","contentModel","onDialogClose","storeValues","initialValues","multiple","useSnackbar","showSnackbar","useState","setValues","onChange","useCallback","reference","referenceEntryId","newValues","filter","length","onDialogSave","useEntries","model","limit","entries","loading","error","runSearch","loadMore","useEffect","debouncedSearch","useRef","onInput","ev","String","target","trim","current","clearTimeout","setTimeout","entry"],"sources":["ReferencesDialog.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport styled from \"@emotion/styled\";\nimport { DialogHeader } from \"./dialog/DialogHeader\";\nimport { Search } from \"./Search\";\nimport { Entry } from \"./Entry\";\nimport { DialogActions, DialogContent as BaseDialogContent } from \"~/admin/components/Dialog\";\nimport { CmsModelFieldRendererProps } from \"~/types\";\nimport { CmsReferenceValue } from \"~/admin/plugins/fieldRenderers/ref/components/types\";\nimport { ButtonDefault, ButtonPrimary } from \"@webiny/ui/Button\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { Dialog } from \"./dialog/Dialog\";\nimport { AbsoluteLoader } from \"~/admin/plugins/fieldRenderers/ref/advanced/components/Loader\";\nimport { useEntries } from \"~/admin/plugins/fieldRenderers/ref/advanced/hooks/useEntries\";\nimport { Entries } from \"./Entries\";\n\nconst Container = styled(\"div\")({\n width: \"100%\",\n boxSizing: \"border-box\",\n padding: \"20px\"\n});\n\nconst Content = styled(\"div\")({\n display: \"flex\",\n flex: \"1\",\n flexDirection: \"column\",\n position: \"relative\",\n width: \"100%\",\n minHeight: \"20px\",\n boxSizing: \"border-box\",\n padding: \"20px 0 20px 20px\",\n backgroundColor: \"var(--mdc-theme-background)\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n overflowX: \"hidden\"\n});\n\nconst DialogContent = styled(BaseDialogContent)({\n padding: \"0 !important\"\n});\n\nconst isSelected = (entryId: string, values: CmsReferenceValue[]) => {\n if (!entryId) {\n return false;\n }\n return values.some(value => {\n const { id: valueEntryId } = parseIdentifier(value.id);\n return entryId === valueEntryId;\n });\n};\n\ninterface Props extends CmsModelFieldRendererProps {\n values?: CmsReferenceValue[] | null;\n onDialogClose: () => void;\n storeValues: (values: CmsReferenceValue[]) => void;\n multiple: boolean;\n}\n\nexport const ReferencesDialog: React.VFC<Props> = props => {\n const { contentModel, onDialogClose, storeValues, values: initialValues, multiple } = props;\n const { showSnackbar } = useSnackbar();\n\n const [values, setValues] = useState<CmsReferenceValue[]>(initialValues || []);\n\n /**\n * On change needs to handle the adding or removing of a reference.\n *\n * This is for both single and multiple reference fields.\n */\n const onChange = useCallback(\n (reference: CmsReferenceValue) => {\n const { id: referenceEntryId } = parseIdentifier(reference.id);\n /**\n * Let's handle the single usage first as it is quite simple.\n */\n if (!multiple) {\n const [value] = values;\n if (!value?.id) {\n setValues([reference]);\n return;\n }\n const { id: valueEntryId } = parseIdentifier(value.id);\n if (referenceEntryId === valueEntryId) {\n setValues([]);\n return;\n }\n setValues([reference]);\n return;\n }\n\n const newValues = values.filter(value => {\n if (!value?.id) {\n return false;\n }\n const { id: valueEntryId } = parseIdentifier(value.id);\n return referenceEntryId !== valueEntryId;\n });\n if (newValues.length === values.length) {\n setValues([...values, reference]);\n return;\n }\n setValues(newValues);\n },\n [setValues, values]\n );\n\n const onDialogSave = useCallback(() => {\n storeValues(values);\n onDialogClose();\n }, [values]);\n /**\n * Searching and list of reference entries.\n */\n const { entries, loading, error, runSearch, loadMore } = useEntries({\n model: contentModel,\n limit: 10\n });\n\n useEffect(() => {\n runSearch(\"\");\n }, []);\n\n useEffect(() => {\n if (!error) {\n return;\n }\n showSnackbar(error);\n }, [error]);\n\n const debouncedSearch = useRef<number | null>(null);\n\n const onInput = useCallback(ev => {\n const value = (String(ev.target.value) || \"\").trim();\n if (debouncedSearch.current) {\n clearTimeout(debouncedSearch.current);\n debouncedSearch.current = null;\n }\n /**\n * We can safely cast as setTimeout really produces a number.\n * There is an error while coding because Storm thinks this is NodeJS timeout.\n */\n debouncedSearch.current = setTimeout(() => {\n runSearch(value);\n }, 200) as unknown as number;\n }, []);\n\n return (\n <>\n <Dialog open={true} onClose={onDialogClose}>\n <DialogHeader model={contentModel} onClose={onDialogClose} />\n <DialogContent>\n <Container>\n <Search onInput={onInput} />\n <Content>\n {loading && <AbsoluteLoader />}\n <Entries entries={entries} loadMore={loadMore}>\n {entry => {\n return (\n <Entry\n model={contentModel}\n key={`reference-entry-${entry.id}`}\n entry={entry}\n selected={isSelected(entry.entryId, values)}\n onChange={onChange}\n />\n );\n }}\n </Entries>\n </Content>\n </Container>\n </DialogContent>\n <DialogActions>\n <ButtonDefault onClick={onDialogClose}>Cancel</ButtonDefault>\n <ButtonPrimary onClick={onDialogSave}>Save</ButtonPrimary>\n </DialogActions>\n </Dialog>\n </>\n );\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,SAAS,oBAAGC,eAAM,EAAC,KAAK;EAAA;EAAA;AAAA,GAAE;EAC5BC,KAAK,EAAE,MAAM;EACbC,SAAS,EAAE,YAAY;EACvBC,OAAO,EAAE;AACb,CAAC,CAAC;AAEF,IAAMC,OAAO,oBAAGJ,eAAM,EAAC,KAAK;EAAA;EAAA;AAAA,GAAE;EAC1BK,OAAO,EAAE,MAAM;EACfC,IAAI,EAAE,GAAG;EACTC,aAAa,EAAE,QAAQ;EACvBC,QAAQ,EAAE,UAAU;EACpBP,KAAK,EAAE,MAAM;EACbQ,SAAS,EAAE,MAAM;EACjBP,SAAS,EAAE,YAAY;EACvBC,OAAO,EAAE,kBAAkB;EAC3BO,eAAe,EAAE,6BAA6B;EAC9CC,MAAM,EAAE,0CAA0C;EAClDC,SAAS,EAAE;AACf,CAAC,CAAC;AAEF,IAAMC,aAAa,oBAAGb,eAAM,EAACc,qBAAiB;EAAA;EAAA;AAAA,GAAE;EAC5CX,OAAO,EAAE;AACb,CAAC,CAAC;AAEF,IAAMY,UAAU,GAAG,SAAbA,UAAU,CAAIC,OAAe,EAAEC,MAA2B,EAAK;EACjE,IAAI,CAACD,OAAO,EAAE;IACV,OAAO,KAAK;EAChB;EACA,OAAOC,MAAM,CAACC,IAAI,CAAC,UAAAC,KAAK,EAAI;IACxB,uBAA6B,IAAAC,sBAAe,EAACD,KAAK,CAACE,EAAE,CAAC;MAA1CC,YAAY,oBAAhBD,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defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.createSearchQuery = exports.LIST_LATEST_CONTENT_ENTRIES = void 0;
|
|
8
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
9
|
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
10
|
-
var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
|
|
11
|
-
var _pluralize = _interopRequireDefault(require("pluralize"));
|
|
12
10
|
var _templateObject, _templateObject2;
|
|
13
11
|
var fields = "\n data {\n id\n entryId\n title\n description\n image\n status\n createdOn\n savedOn\n model {\n name\n modelId\n }\n createdBy {\n id\n displayName\n type\n }\n modifiedBy {\n id\n displayName\n type\n }\n published {\n id\n }\n }\n error {\n message\n code\n data\n }\n";
|
|
14
12
|
var LIST_LATEST_CONTENT_ENTRIES = (0, _graphqlTag.default)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n query CmsListLatestContentEntries($entries: [CmsModelEntryInput!]!) {\n entries: getLatestContentEntries(entries: $entries) {\n ", "\n }\n }\n"])), fields);
|
|
15
13
|
exports.LIST_LATEST_CONTENT_ENTRIES = LIST_LATEST_CONTENT_ENTRIES;
|
|
16
14
|
var createSearchQuery = function createSearchQuery(model) {
|
|
17
|
-
|
|
18
|
-
var ucFirstModelId = (0, _upperFirst.default)(model.modelId);
|
|
19
|
-
return (0, _graphqlTag.default)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n query Search", "($where: ", "ListWhereInput, $sort: [", "ListSorter], $limit: Int, $after: String) {\n content: list", "(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n ) {\n data {\n id\n entryId\n savedOn\n createdOn\n createdBy {\n id\n type\n displayName\n }\n ownedBy {\n id\n type\n displayName\n }\n modifiedBy {\n id\n type\n displayName\n }\n meta {\n title\n description\n image\n status\n }\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n message\n code\n data\n }\n }\n }"])), ucFirstPluralizedModelId, ucFirstModelId, ucFirstModelId, ucFirstPluralizedModelId);
|
|
15
|
+
return (0, _graphqlTag.default)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n query Search", "($where: ", "ListWhereInput, $sort: [", "ListSorter], $limit: Int, $after: String) {\n content: list", "(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n ) {\n data {\n id\n entryId\n savedOn\n createdOn\n createdBy {\n id\n type\n displayName\n }\n ownedBy {\n id\n type\n displayName\n }\n modifiedBy {\n id\n type\n displayName\n }\n meta {\n title\n description\n image\n status\n }\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n message\n code\n data\n }\n }\n }"])), model.pluralApiName, model.singularApiName, model.singularApiName, model.pluralApiName);
|
|
20
16
|
};
|
|
21
17
|
exports.createSearchQuery = createSearchQuery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fields","LIST_LATEST_CONTENT_ENTRIES","gql","createSearchQuery","model","
|
|
1
|
+
{"version":3,"names":["fields","LIST_LATEST_CONTENT_ENTRIES","gql","createSearchQuery","model","pluralApiName","singularApiName"],"sources":["graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport {\n CmsContentEntryStatusType,\n CmsIdentity,\n CmsErrorResponse,\n CmsMetaResponse,\n CmsModel\n} from \"~/types\";\nimport { CmsReferenceContentEntry } from \"~/admin/plugins/fieldRenderers/ref/components/types\";\nimport { CmsEntryGetEntryVariable } from \"~/admin/plugins/fieldRenderers/ref/components/graphql\";\n\nconst fields = `\n data {\n id\n entryId\n title\n description\n image\n status\n createdOn\n savedOn\n model {\n name\n modelId\n }\n createdBy {\n id\n displayName\n type\n }\n modifiedBy {\n id\n displayName\n type\n }\n published {\n id\n }\n }\n error {\n message\n code\n data\n }\n`;\n\nexport interface ListLatestCmsEntriesResponse {\n entries: {\n data: CmsReferenceContentEntry[];\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface ListLatestCmsEntriesVariables {\n entries: CmsEntryGetEntryVariable[];\n}\n\nexport const LIST_LATEST_CONTENT_ENTRIES = gql`\n query CmsListLatestContentEntries($entries: [CmsModelEntryInput!]!) {\n entries: getLatestContentEntries(entries: $entries) {\n ${fields}\n }\n }\n`;\n\nexport interface SearchQueryResponseEntry {\n id: string;\n entryId: string;\n savedOn: Date;\n createdOn: Date;\n createdBy: CmsIdentity;\n ownedBy: CmsIdentity;\n modifiedBy: CmsIdentity;\n meta: {\n title: string;\n description?: string;\n image?: string;\n status: CmsContentEntryStatusType;\n };\n}\n\nexport interface SearchQueryResponse {\n content: {\n data: SearchQueryResponseEntry[];\n error: CmsErrorResponse | null;\n meta: CmsMetaResponse;\n };\n}\n\nexport interface SearchQueryVariables {\n where?: {\n [key: string]: any;\n };\n sort?: string[];\n limit?: number;\n after?: string;\n}\n\nexport const createSearchQuery = (model: CmsModel) => {\n return gql`\n query Search${model.pluralApiName}($where: ${model.singularApiName}ListWhereInput, $sort: [${model.singularApiName}ListSorter], $limit: Int, $after: String) {\n content: list${model.pluralApiName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n ) {\n data {\n id\n entryId\n savedOn\n createdOn\n createdBy {\n id\n type\n displayName\n }\n ownedBy {\n id\n type\n displayName\n }\n modifiedBy {\n id\n type\n displayName\n }\n meta {\n title\n description\n image\n status\n }\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n message\n code\n data\n }\n }\n }`;\n};\n"],"mappings":";;;;;;;;AAAA;AAA8B;AAW9B,IAAMA,MAAM,ygBAiCX;AAaM,IAAMC,2BAA2B,OAAGC,mBAAG,qQAGhCF,MAAM,CAGnB;AAAC;AAmCK,IAAMG,iBAAiB,GAAG,SAApBA,iBAAiB,CAAIC,KAAe,EAAK;EAClD,WAAOF,mBAAG,8vCACQE,KAAK,CAACC,aAAa,EAAYD,KAAK,CAACE,eAAe,EAA2BF,KAAK,CAACE,eAAe,EAC/FF,KAAK,CAACC,aAAa;AA6C9C,CAAC;AAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { CmsContentEntry } from "../../../../../types";
|
|
3
3
|
export declare const NewEntryButton: () => JSX.Element;
|
|
4
4
|
interface NewRefEntryProps {
|
|
5
5
|
modelId: string;
|
|
6
6
|
children: React.ReactElement;
|
|
7
|
-
onChange: (entry:
|
|
7
|
+
onChange: (entry: CmsContentEntry) => void;
|
|
8
8
|
}
|
|
9
9
|
declare const NewRefEntryFormDialog: React.FC<NewRefEntryProps>;
|
|
10
10
|
export default NewRefEntryFormDialog;
|
|
@@ -40,7 +40,7 @@ var EntryForm = function EntryForm(_ref) {
|
|
|
40
40
|
}, /*#__PURE__*/_react.default.createElement(_ContentEntryForm.ContentEntryForm, {
|
|
41
41
|
onSubmit: function onSubmit(data) {
|
|
42
42
|
/**
|
|
43
|
-
* We know that data is
|
|
43
|
+
* We know that data is CmsContentEntry.
|
|
44
44
|
*/
|
|
45
45
|
return onCreate(data);
|
|
46
46
|
},
|
|
@@ -125,11 +125,11 @@ var NewRefEntryFormDialog = function NewRefEntryFormDialog(_ref2) {
|
|
|
125
125
|
if (!contentModel) {
|
|
126
126
|
return children;
|
|
127
127
|
}
|
|
128
|
-
return /*#__PURE__*/_react.default.createElement(_ContentEntriesContext.
|
|
128
|
+
return /*#__PURE__*/_react.default.createElement(_ContentEntriesContext.ContentEntriesProvider, {
|
|
129
129
|
contentModel: contentModel,
|
|
130
130
|
key: contentModel.modelId,
|
|
131
131
|
insideDialog: true
|
|
132
|
-
}, /*#__PURE__*/_react.default.createElement(_ContentEntryContext.
|
|
132
|
+
}, /*#__PURE__*/_react.default.createElement(_ContentEntryContext.ContentEntryProvider, {
|
|
133
133
|
isNewEntry: function isNewEntry() {
|
|
134
134
|
return true;
|
|
135
135
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["t","i18n","ns","dialogContentStyles","css","dialogContainerStyles","EntryForm","onCreate","useContentEntry","setFormRef","contentModel","data","form","DialogSaveButton","current","submit","DefaultButton","styled","ButtonDefault","NewEntryButton","useNewRefEntryDialog","setOpen","NewRefEntryFormDialog","modelId","children","onChange","useState","undefined","setContentModel","useSnackbar","showSnackbar","useQuery","GET_CONTENT_MODEL","skip","variables","onCompleted","contentModelData","get","open","hideDialog","useCallback","entry","published","modelName","name"],"sources":["NewRefEntryFormDialog.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport get from \"lodash/get\";\nimport { css } from \"emotion\";\nimport styled from \"@emotion/styled\";\nimport { Dialog, DialogActions, DialogCancel, DialogContent, DialogTitle } from \"@webiny/ui/Dialog\";\nimport { ButtonDefault, ButtonIcon, ButtonPrimary } from \"@webiny/ui/Button\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { ReactComponent as AddIcon } from \"@webiny/app-admin/assets/icons/add-18px.svg\";\nimport {
|
|
1
|
+
{"version":3,"names":["t","i18n","ns","dialogContentStyles","css","dialogContainerStyles","EntryForm","onCreate","useContentEntry","setFormRef","contentModel","data","form","DialogSaveButton","current","submit","DefaultButton","styled","ButtonDefault","NewEntryButton","useNewRefEntryDialog","setOpen","NewRefEntryFormDialog","modelId","children","onChange","useState","undefined","setContentModel","useSnackbar","showSnackbar","useQuery","GET_CONTENT_MODEL","skip","variables","onCompleted","contentModelData","get","open","hideDialog","useCallback","entry","published","modelName","name"],"sources":["NewRefEntryFormDialog.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport get from \"lodash/get\";\nimport { css } from \"emotion\";\nimport styled from \"@emotion/styled\";\nimport { Dialog, DialogActions, DialogCancel, DialogContent, DialogTitle } from \"@webiny/ui/Dialog\";\nimport { ButtonDefault, ButtonIcon, ButtonPrimary } from \"@webiny/ui/Button\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { ReactComponent as AddIcon } from \"@webiny/app-admin/assets/icons/add-18px.svg\";\nimport { ContentEntriesProvider } from \"~/admin/views/contentEntries/ContentEntriesContext\";\nimport { ContentEntryProvider } from \"~/admin/views/contentEntries/ContentEntry/ContentEntryContext\";\nimport { ContentEntryForm } from \"~/admin/components/ContentEntryForm/ContentEntryForm\";\nimport { useQuery } from \"~/admin/hooks\";\nimport {\n GET_CONTENT_MODEL,\n GetCmsModelQueryResponse,\n GetCmsModelQueryVariables\n} from \"~/admin/graphql/contentModels\";\nimport { useContentEntry } from \"~/admin/views/contentEntries/hooks/useContentEntry\";\nimport { useNewRefEntryDialog } from \"../hooks/useNewRefEntryDialog\";\nimport { CmsContentEntry, CmsModel } from \"~/types\";\nimport { ModelProvider } from \"~/admin/components/ModelProvider\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/fields/ref\");\n\nconst dialogContentStyles = css`\n width: 786px;\n`;\n\nconst dialogContainerStyles = css`\n /*\n* By default, a Dialog component has the \"z-index\" value of 20.\n* As we are rendering the content entry form in a \"Dialog\", the File Manager view triggered by a \"file\" field\n* will render below the source form, rendering it useless for the user.\n*\n* To fix that issue, we're setting the \"z-index\" CSS property for this particular Dialog to less than 18,\n* which is the \"z-index\" value assigned to File Manager view, so that it will render below the File Manager view as expected.\n*/\n\n &.mdc-dialog {\n z-index: 17;\n }\n`;\n\ninterface EntryFormProps {\n onCreate: (entry: CmsContentEntry) => void;\n}\nconst EntryForm: React.FC<EntryFormProps> = ({ onCreate }) => {\n const { setFormRef, contentModel } = useContentEntry();\n\n return (\n <ModelProvider model={contentModel}>\n <ContentEntryForm\n onSubmit={data => {\n /**\n * We know that data is CmsContentEntry.\n */\n return onCreate(data as unknown as CmsContentEntry);\n }}\n onForm={form => setFormRef(form)}\n entry={{}}\n addEntryToListCache={false}\n />\n </ModelProvider>\n );\n};\n\nconst DialogSaveButton: React.FC = () => {\n const { form } = useContentEntry();\n\n return <ButtonPrimary onClick={form.current.submit}>{t`Create Entry`}</ButtonPrimary>;\n};\n\nconst DefaultButton = styled(ButtonDefault)`\n margin-left: 32px;\n`;\n\nexport const NewEntryButton = () => {\n const { setOpen } = useNewRefEntryDialog();\n return (\n <DefaultButton small={true} onClick={() => setOpen(true)}>\n <ButtonIcon icon={<AddIcon />} />\n {t`New Entry`}\n </DefaultButton>\n );\n};\n\ninterface NewRefEntryProps {\n modelId: string;\n children: React.ReactElement;\n onChange: (entry: CmsContentEntry) => void;\n}\n\nconst NewRefEntryFormDialog: React.FC<NewRefEntryProps> = ({ modelId, children, onChange }) => {\n const [contentModel, setContentModel] = useState<CmsModel | undefined>(undefined);\n\n const { showSnackbar } = useSnackbar();\n\n useQuery<GetCmsModelQueryResponse, GetCmsModelQueryVariables>(GET_CONTENT_MODEL, {\n skip: !modelId,\n variables: { modelId },\n onCompleted: data => {\n const contentModelData = get(data, \"getContentModel.data\") as unknown as CmsModel;\n if (contentModelData) {\n setContentModel(contentModelData);\n return;\n }\n\n showSnackbar(\n t`Could not load content for model \"{modelId}\". Redirecting...`({\n modelId\n })\n );\n }\n });\n\n const { open, setOpen } = useNewRefEntryDialog();\n const hideDialog = useCallback(() => setOpen(false), []);\n\n const onCreate = useCallback(\n (entry: CmsContentEntry) => {\n if (!contentModel) {\n setOpen(false);\n return;\n }\n onChange({\n ...entry,\n /*\n * Format data for AutoComplete.\n */\n published: get(entry, \"meta.status\") === \"published\",\n modelId: contentModel.modelId,\n modelName: contentModel.name\n });\n setOpen(false);\n },\n [onChange, contentModel]\n );\n\n if (!contentModel) {\n return children;\n }\n\n return (\n <ContentEntriesProvider\n contentModel={contentModel}\n key={contentModel.modelId}\n insideDialog={true}\n >\n <ContentEntryProvider isNewEntry={() => true} getContentId={() => null}>\n <Dialog open={open} onClose={hideDialog} className={dialogContainerStyles}>\n <DialogTitle>\n {t`New {modelName} Entry`({ modelName: contentModel.name })}\n </DialogTitle>\n <DialogContent className={dialogContentStyles}>\n <EntryForm onCreate={onCreate} />\n </DialogContent>\n <DialogActions>\n <DialogCancel>{t`Cancel`}</DialogCancel>\n <DialogSaveButton />\n </DialogActions>\n </Dialog>\n {children}\n </ContentEntryProvider>\n </ContentEntriesProvider>\n );\n};\n\nexport default NewRefEntryFormDialog;\n"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AAEA;AAAiE;AAEjE,IAAMA,CAAC,GAAGC,UAAI,CAACC,EAAE,CAAC,mCAAmC,CAAC;AAEtD,IAAMC,mBAAmB,oBAAGC,YAAG,2CAE9B;AAED,IAAMC,qBAAqB,oBAAGD,YAAG,0DAahC;AAKD,IAAME,SAAmC,GAAG,SAAtCA,SAAmC,OAAqB;EAAA,IAAfC,QAAQ,QAARA,QAAQ;EACnD,uBAAqC,IAAAC,iCAAe,GAAE;IAA9CC,UAAU,oBAAVA,UAAU;IAAEC,YAAY,oBAAZA,YAAY;EAEhC,oBACI,6BAAC,4BAAa;IAAC,KAAK,EAAEA;EAAa,gBAC/B,6BAAC,kCAAgB;IACb,QAAQ,EAAE,kBAAAC,IAAI,EAAI;MACd;AACpB;AACA;MACoB,OAAOJ,QAAQ,CAACI,IAAI,CAA+B;IACvD,CAAE;IACF,MAAM,EAAE,gBAAAC,IAAI;MAAA,OAAIH,UAAU,CAACG,IAAI,CAAC;IAAA,CAAC;IACjC,KAAK,EAAE,CAAC,CAAE;IACV,mBAAmB,EAAE;EAAM,EAC7B,CACU;AAExB,CAAC;AAED,IAAMC,gBAA0B,GAAG,SAA7BA,gBAA0B,GAAS;EACrC,wBAAiB,IAAAL,iCAAe,GAAE;IAA1BI,IAAI,qBAAJA,IAAI;EAEZ,oBAAO,6BAAC,qBAAa;IAAC,OAAO,EAAEA,IAAI,CAACE,OAAO,CAACC;EAAO,GAAEf,CAAC,gGAA+B;AACzF,CAAC;AAED,IAAMgB,aAAa,oBAAGC,eAAM,EAACC,qBAAa;EAAA;EAAA;AAAA,uBAEzC;AAEM,IAAMC,cAAc,GAAG,SAAjBA,c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|
|
2
|
-
export declare const dynamicZoneField:
|
|
1
|
+
import { CmsModelFieldTypePlugin } from "../../../types";
|
|
2
|
+
export declare const dynamicZoneField: CmsModelFieldTypePlugin;
|
|
@@ -42,7 +42,7 @@ var dynamicZoneField = {
|
|
|
42
42
|
},
|
|
43
43
|
listValidators: listValidators,
|
|
44
44
|
canAccept: function canAccept(_, draggable) {
|
|
45
|
-
return draggable.fieldType !== "dynamicZone";
|
|
45
|
+
return draggable.fieldType !== "dynamicZone" && draggable.fieldType !== "ref";
|
|
46
46
|
},
|
|
47
47
|
multipleValuesLabel: t(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["Use as a list of values"]))),
|
|
48
48
|
createField: function createField() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["t","i18n","ns","listValidators","validators","commonValidators","title","description","dynamicZoneField","type","name","field","label","icon","allowMultipleValues","allowPredefinedValues","multipleValues","canAccept","_","draggable","fieldType","multipleValuesLabel","createField","listValidation","settings","templates","renderer","render","graphql","queryField","model","prefix","singularApiName","createTypeName","fieldId","fragments","map","template","gqlTypeName","createFieldsList","fields","join"],"sources":["dynamicZone.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as ObjectIcon } from \"@material-design-icons/svg/outlined/dynamic_form.svg\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { DynamicZone } from \"~/admin/plugins/fields/dynamicZone/DynamicZone\";\nimport { createFieldsList } from \"~/admin/graphql/createFieldsList\";\nimport { createTypeName } from \"~/utils/createTypeName\";\nimport {
|
|
1
|
+
{"version":3,"names":["t","i18n","ns","listValidators","validators","commonValidators","title","description","dynamicZoneField","type","name","field","label","icon","allowMultipleValues","allowPredefinedValues","multipleValues","canAccept","_","draggable","fieldType","multipleValuesLabel","createField","listValidation","settings","templates","renderer","render","graphql","queryField","model","prefix","singularApiName","createTypeName","fieldId","fragments","map","template","gqlTypeName","createFieldsList","fields","join"],"sources":["dynamicZone.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as ObjectIcon } from \"@material-design-icons/svg/outlined/dynamic_form.svg\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { DynamicZone } from \"~/admin/plugins/fields/dynamicZone/DynamicZone\";\nimport { createFieldsList } from \"~/admin/graphql/createFieldsList\";\nimport { createTypeName } from \"~/utils/createTypeName\";\nimport { CmsModelFieldTypePlugin, CmsModelFieldValidatorsGroup } from \"~/types\";\nimport { commonValidators } from \"./dynamicZone/commonValidators\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/fields\");\n\nconst listValidators: CmsModelFieldValidatorsGroup = {\n validators: commonValidators,\n title: \"List validators\",\n description: \"These validators are applied to the entire dynamic zone.\"\n};\n\nexport const dynamicZoneField: CmsModelFieldTypePlugin = {\n type: \"cms-editor-field-type\",\n name: \"cms-editor-field-type-dynamic-zone\",\n field: {\n type: \"dynamicZone\",\n label: t`Dynamic Zone`,\n description: t`Define content templates to be used during content creation.`,\n icon: <ObjectIcon />,\n allowMultipleValues: true,\n allowPredefinedValues: false,\n validators: field => {\n if (field.multipleValues) {\n return {\n validators: [\"dynamicZone\"],\n title: \"Template Validators\",\n description: \"Validators for each of the templates in this dynamic zone.\"\n };\n }\n\n return [\"required\"];\n },\n listValidators,\n canAccept(_, draggable) {\n return draggable.fieldType !== \"dynamicZone\" && draggable.fieldType !== \"ref\";\n },\n multipleValuesLabel: t`Use as a list of values`,\n createField() {\n return {\n type: this.type,\n listValidation: [{ name: \"dynamicZone\" }],\n settings: {\n templates: []\n },\n renderer: {\n name: \"dynamicZone\"\n }\n };\n },\n render() {\n return <DynamicZone />;\n },\n graphql: {\n queryField({ model, field }) {\n const prefix = `${model.singularApiName}_${createTypeName(field.fieldId)}`;\n const templates = field.settings?.templates || [];\n\n const fragments = templates.map(template => {\n return `...on ${prefix}_${template.gqlTypeName} {\n ${createFieldsList({ model, fields: template.fields || [] })}\n _templateId\n __typename\n }`;\n });\n return `{ ${fragments.join(\"\\n\")} }`;\n }\n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DiB,MAAM,oBAAG;MACL,oBAAO,6BAAC,wBAAW,OAAG;IAC1B,CAAC;IACDC,OAAO,EAAE;MACLC,UAAU,4BAAmB;QAAA;QAAA,IAAhBC,KAAK,QAALA,KAAK;UAAEnB,KAAK,QAALA,KAAK;QACrB,IAAMoB,MAAM,aAAMD,KAAK,CAACE,eAAe,cAAI,IAAAC,8BAAc,EAACtB,KAAK,CAACuB,OAAO,CAAC,CAAE;QAC1E,IAAMT,SAAS,GAAG,oBAAAd,KAAK,CAACa,QAAQ,oDAAd,gBAAgBC,SAAS,KAAI,EAAE;QAEjD,IAAMU,SAAS,GAAGV,SAAS,CAACW,GAAG,CAAC,UAAAC,QAAQ,EAAI;UACxC,uBAAgBN,MAAM,cAAIM,QAAQ,CAACC,WAAW,yCACxC,IAAAC,kCAAgB,EAAC;YAAET,KAAK,EAALA,KAAK;YAAEU,MAAM,EAAEH,QAAQ,CAACG,MAAM,IAAI;UAAG,CAAC,CAAC;QAIpE,CAAC,CAAC;QACF,mBAAYL,SAAS,CAACM,IAAI,CAAC,IAAI,CAAC;MACpC;IACJ;EACJ;AACJ,CAAC;AAAC"}
|
package/admin/plugins/routes.js
CHANGED
|
@@ -17,6 +17,7 @@ var _reactRouter = require("@webiny/react-router");
|
|
|
17
17
|
var _AdminLayout = require("@webiny/app-admin/components/AdminLayout");
|
|
18
18
|
var _i18n = require("@webiny/app/i18n");
|
|
19
19
|
var _ContentEntriesViewConfig = require("../views/contentEntries/experiment/ContentEntriesViewConfig");
|
|
20
|
+
var _ContentEntriesContainer = require("../views/contentEntries/ContentEntriesContainer");
|
|
20
21
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
21
22
|
var _excluded = ["children"];
|
|
22
23
|
var t = _i18n.i18n.ns("app-headless-cms/admin/routes");
|
|
@@ -63,7 +64,7 @@ var plugins = [{
|
|
|
63
64
|
render: function render() {
|
|
64
65
|
return /*#__PURE__*/_react.default.createElement(_components.SecureRoute, {
|
|
65
66
|
permission: "cms.contentModel"
|
|
66
|
-
}, /*#__PURE__*/_react.default.createElement(_AdminLayout.AdminLayout, null, /*#__PURE__*/_react.default.createElement(_reactHelmet.default, null, /*#__PURE__*/_react.default.createElement("title", null, t(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["Content"]))))), /*#__PURE__*/_react.default.createElement(_ContentEntriesViewConfig.ContentEntriesView, null)));
|
|
67
|
+
}, /*#__PURE__*/_react.default.createElement(_AdminLayout.AdminLayout, null, /*#__PURE__*/_react.default.createElement(_reactHelmet.default, null, /*#__PURE__*/_react.default.createElement("title", null, t(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["Content"]))))), /*#__PURE__*/_react.default.createElement(_ContentEntriesContainer.ContentEntriesContainer, null, /*#__PURE__*/_react.default.createElement(_ContentEntriesViewConfig.ContentEntriesView, null))));
|
|
67
68
|
}
|
|
68
69
|
})
|
|
69
70
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["t","i18n","ns","Loader","children","props","React","cloneElement","ContentModelEditor","lazy","ContentModelsView","ContentModelGroupsView","plugins","name","type","route"],"sources":["routes.tsx"],"sourcesContent":["import React, { Suspense, lazy } from \"react\";\nimport Helmet from \"react-helmet\";\nimport { SecureRoute } from \"@webiny/app-security/components\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\nimport { Route } from \"@webiny/react-router\";\nimport { AdminLayout } from \"@webiny/app-admin/components/AdminLayout\";\nimport { RoutePlugin } from \"@webiny/app/types\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { ContentEntriesView } from \"../views/contentEntries/experiment/ContentEntriesViewConfig\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/routes\");\n\nconst Loader: React.FC = ({ children, ...props }) => (\n <Suspense fallback={<CircularProgress />}>\n {React.cloneElement(children as unknown as React.ReactElement, props)}\n </Suspense>\n);\n\nconst ContentModelEditor = lazy(() => import(\"../views/contentModels/ContentModelEditor\"));\nconst ContentModelsView = lazy(() => import(\"../views/contentModels/ContentModels\"));\nconst ContentModelGroupsView = lazy(() => import(\"../views/contentModelGroups/ContentModelGroups\"));\n\nconst plugins: RoutePlugin[] = [\n {\n name: \"route-cms-content-models-groups\",\n type: \"route\",\n route: (\n <Route\n exact\n path={\"/cms/content-model-groups\"}\n render={() => (\n <SecureRoute permission={\"cms.contentModelGroup\"}>\n <AdminLayout>\n <Helmet>\n <title>{t`Content Model Groups`}</title>\n </Helmet>\n <Loader>\n <ContentModelGroupsView />\n </Loader>\n </AdminLayout>\n </SecureRoute>\n )}\n />\n )\n },\n {\n name: \"route-cms-content-models-manage\",\n type: \"route\",\n route: (\n <Route\n exact\n path={\"/cms/content-entries/:modelId\"}\n render={() => (\n <SecureRoute permission={\"cms.contentModel\"}>\n <AdminLayout>\n <Helmet>\n <title>{t`Content`}</title>\n </Helmet>\n <ContentEntriesView />\n </AdminLayout>\n </SecureRoute>\n )}\n />\n )\n },\n {\n name: \"route-cms-content-models-editor\",\n type: \"route\",\n route: (\n <Route\n exact\n path={\"/cms/content-models/:modelId\"}\n render={() => (\n <SecureRoute permission={\"cms.contentModel\"}>\n <Helmet>\n <title>{t`Edit Content Model`}</title>\n </Helmet>\n <Loader>\n <ContentModelEditor />\n </Loader>\n </SecureRoute>\n )}\n />\n )\n },\n {\n name: \"route-cms-content-models\",\n type: \"route\",\n route: (\n <Route\n exact\n path=\"/cms/content-models\"\n render={() => (\n <SecureRoute permission={\"cms.contentModel\"}>\n <AdminLayout>\n <Helmet title={t`Content Models`} />\n <Loader>\n <ContentModelsView />\n </Loader>\n </AdminLayout>\n </SecureRoute>\n )}\n />\n )\n }\n];\n\nexport default plugins;\n"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;
|
|
1
|
+
{"version":3,"names":["t","i18n","ns","Loader","children","props","React","cloneElement","ContentModelEditor","lazy","ContentModelsView","ContentModelGroupsView","plugins","name","type","route"],"sources":["routes.tsx"],"sourcesContent":["import React, { Suspense, lazy } from \"react\";\nimport Helmet from \"react-helmet\";\nimport { SecureRoute } from \"@webiny/app-security/components\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\nimport { Route } from \"@webiny/react-router\";\nimport { AdminLayout } from \"@webiny/app-admin/components/AdminLayout\";\nimport { RoutePlugin } from \"@webiny/app/types\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { ContentEntriesView } from \"../views/contentEntries/experiment/ContentEntriesViewConfig\";\nimport { ContentEntriesContainer } from \"~/admin/views/contentEntries/ContentEntriesContainer\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/routes\");\n\nconst Loader: React.FC = ({ children, ...props }) => (\n <Suspense fallback={<CircularProgress />}>\n {React.cloneElement(children as unknown as React.ReactElement, props)}\n </Suspense>\n);\n\nconst ContentModelEditor = lazy(() => import(\"../views/contentModels/ContentModelEditor\"));\nconst ContentModelsView = lazy(() => import(\"../views/contentModels/ContentModels\"));\nconst ContentModelGroupsView = lazy(() => import(\"../views/contentModelGroups/ContentModelGroups\"));\n\nconst plugins: RoutePlugin[] = [\n {\n name: \"route-cms-content-models-groups\",\n type: \"route\",\n route: (\n <Route\n exact\n path={\"/cms/content-model-groups\"}\n render={() => (\n <SecureRoute permission={\"cms.contentModelGroup\"}>\n <AdminLayout>\n <Helmet>\n <title>{t`Content Model Groups`}</title>\n </Helmet>\n <Loader>\n <ContentModelGroupsView />\n </Loader>\n </AdminLayout>\n </SecureRoute>\n )}\n />\n )\n },\n {\n name: \"route-cms-content-models-manage\",\n type: \"route\",\n route: (\n <Route\n exact\n path={\"/cms/content-entries/:modelId\"}\n render={() => (\n <SecureRoute permission={\"cms.contentModel\"}>\n <AdminLayout>\n <Helmet>\n <title>{t`Content`}</title>\n </Helmet>\n <ContentEntriesContainer>\n <ContentEntriesView />\n </ContentEntriesContainer>\n </AdminLayout>\n </SecureRoute>\n )}\n />\n )\n },\n {\n name: \"route-cms-content-models-editor\",\n type: \"route\",\n route: (\n <Route\n exact\n path={\"/cms/content-models/:modelId\"}\n render={() => (\n <SecureRoute permission={\"cms.contentModel\"}>\n <Helmet>\n <title>{t`Edit Content Model`}</title>\n </Helmet>\n <Loader>\n <ContentModelEditor />\n </Loader>\n </SecureRoute>\n )}\n />\n )\n },\n {\n name: \"route-cms-content-models\",\n type: \"route\",\n route: (\n <Route\n exact\n path=\"/cms/content-models\"\n render={() => (\n <SecureRoute permission={\"cms.contentModel\"}>\n <AdminLayout>\n <Helmet title={t`Content Models`} />\n <Loader>\n <ContentModelsView />\n </Loader>\n </AdminLayout>\n </SecureRoute>\n )}\n />\n )\n }\n];\n\nexport default plugins;\n"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAA+F;AAAA;AAE/F,IAAMA,CAAC,GAAGC,UAAI,CAACC,EAAE,CAAC,+BAA+B,CAAC;AAElD,IAAMC,MAAgB,GAAG,SAAnBA,MAAgB;EAAA,IAAMC,QAAQ,QAARA,QAAQ;IAAKC,KAAK;EAAA,oBAC1C,6BAAC,eAAQ;IAAC,QAAQ,eAAE,6BAAC,0BAAgB;EAAI,gBACpCC,cAAK,CAACC,YAAY,CAACH,QAAQ,EAAmCC,KAAK,CAAC,CAC9D;AAAA,CACd;AAED,IAAMG,kBAAkB,gBAAG,IAAAC,WAAI,EAAC;EAAA;IAAA;EAAA;AAAA,CAAyD,CAAC;AAC1F,IAAMC,iBAAiB,gBAAG,IAAAD,WAAI,EAAC;EAAA;IAAA;EAAA;AAAA,CAAoD,CAAC;AACpF,IAAME,sBAAsB,gBAAG,IAAAF,WAAI,EAAC;EAAA;IAAA;EAAA;AAAA,CAA8D,CAAC;AAEnG,IAAMG,OAAsB,GAAG,CAC3B;EACIC,IAAI,EAAE,iCAAiC;EACvCC,IAAI,EAAE,OAAO;EACbC,KAAK,eACD,6BAAC,kBAAK;IACF,KAAK;IACL,IAAI,EAAE,2BAA4B;IAClC,MAAM,EAAE;MAAA,oBACJ,6BAAC,uBAAW;QAAC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