@webiny/app-headless-cms 6.5.0-beta.4 → 6.5.0-beta.6
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/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
- package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
- package/admin/components/FieldEditor/Field.js +4 -4
- package/admin/components/FieldEditor/Field.js.map +1 -1
- package/features/contentEntry/createEntry/CreateEntryGateway.d.ts +0 -1
- package/features/contentEntry/createEntry/CreateEntryGateway.js +1 -9
- package/features/contentEntry/createEntry/CreateEntryGateway.js.map +1 -1
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.d.ts +3 -1
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js +6 -2
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js.map +1 -1
- package/features/contentEntry/entryValueGateways.test.d.ts +1 -0
- package/features/contentEntry/entryValueGateways.test.js +106 -0
- package/features/contentEntry/entryValueGateways.test.js.map +1 -0
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.d.ts +0 -1
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js +1 -9
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js.map +1 -1
- package/features/contentEntry/updateEntry/UpdateEntryGateway.d.ts +0 -1
- package/features/contentEntry/updateEntry/UpdateEntryGateway.js +1 -9
- package/features/contentEntry/updateEntry/UpdateEntryGateway.js.map +1 -1
- package/features/contentEntry/valueTransformers/EntryDataPreparer.d.ts +9 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.js +8 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.js.map +1 -1
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.d.ts +1 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js +113 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js.map +1 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.d.ts +146 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.js +171 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.js.map +1 -0
- package/features/formModel/CmsFormModelBuilder.d.ts +1 -1
- package/features/formModel/CmsFormModelBuilder.js +1 -13
- package/features/formModel/CmsFormModelBuilder.js.map +1 -1
- package/features/formModel/CmsFormModelBuilder.test.js +141 -0
- package/features/formModel/CmsFormModelBuilder.test.js.map +1 -1
- package/features/formModel/CmsLayoutMapper.d.ts +8 -1
- package/features/formModel/CmsLayoutMapper.js +23 -1
- package/features/formModel/CmsLayoutMapper.js.map +1 -1
- package/features/formModel/mappers/DynamicZoneFieldMapper.js +4 -0
- package/features/formModel/mappers/DynamicZoneFieldMapper.js.map +1 -1
- package/features/formModel/mappers/ObjectFieldMapper.js +11 -6
- package/features/formModel/mappers/ObjectFieldMapper.js.map +1 -1
- package/features/model/exportModels/ExportModelsGateway.d.ts +1 -1
- package/features/model/exportModels/ExportModelsGateway.js.map +1 -1
- package/features/model/exportModels/ExportModelsUseCase.js +7 -1
- package/features/model/exportModels/ExportModelsUseCase.js.map +1 -1
- package/features/model/exportModels/abstractions.d.ts +8 -2
- package/features/model/exportModels/abstractions.js.map +1 -1
- package/package.json +26 -26
- package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
- package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
- package/presentation/contentEntries/views/OlderRevisionAlert.d.ts +2 -2
- package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
- package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
- package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
- package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
- package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
- package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
- package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
- package/presentation/contentModels/ContentModelsPresenter.d.ts +5 -5
- package/presentation/contentModels/ContentModelsPresenter.js +1 -1
- package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
- package/presentation/contentModels/abstractions.d.ts +7 -2
- package/presentation/contentModels/abstractions.js.map +1 -1
- package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
- package/presentation/contentModels/components/ContentModels.d.ts +2 -2
- package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
- package/presentation/contentModels/components/ContentModelsDataList.js +6 -5
- package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
- package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
- package/presentation/contentModels/components/fullDelete/dialog/Content.js +2 -2
- package/presentation/contentModels/components/fullDelete/dialog/Content.js.map +1 -1
- package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.js +3 -2
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.js.map +1 -1
- package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
- package/presentation/importContentModels/ImportContentModelsPresenter.js +1 -1
- package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
- package/presentation/importContentModels/components/DataList.d.ts +2 -2
- package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
- package/presentation/importContentModels/components/FileUpload.js +1 -1
- package/presentation/importContentModels/components/FileUpload.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModelItem.js +3 -3
- package/presentation/importContentModels/components/Model/DataListModelItem.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModelItemInfo.js +2 -2
- package/presentation/importContentModels/components/Model/DataListModelItemInfo.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
- package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
- package/presentation/modelGroup/ModelGroupPresenter.js +1 -2
- package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
- package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
- package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
- package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
- package/utils/normalizeIcon.d.ts +4 -0
- package/utils/normalizeIcon.js +9 -6
- package/utils/normalizeIcon.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/components/ContentEntries/BulkActions/ActionDelete.js","sources":["../../../../../src/admin/components/ContentEntries/BulkActions/ActionDelete.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport { BulkDeleteFeature } from \"~/presentation/contentEntries/bulkActions/feature.js\";\nimport {\n BulkActionButton,\n useBulkActionDialog\n} from \"@webiny/app-admin/components/BulkActions/index.js\";\nimport { useContentEntriesPresenter } from \"~/presentation/contentEntries/list/useContentEntriesPresenter.js\";\n\nexport const ActionDelete = observer(() => {\n const toast = useToast();\n const presenter = useContentEntriesPresenter();\n const { showConfirmationDialog, showResultsDialog } = useBulkActionDialog();\n const { presenter: bulkDelete } = useFeature(BulkDeleteFeature);\n\n const selection = presenter.list.vm.selection;\n const selectedItems = presenter.list.vm.rows.filter(row => {\n return selection.selectedIds.has(row.id);\n });\n\n const openDeleteEntriesDialog = () =>\n showConfirmationDialog({\n title: \"Trash entries\",\n message: `You are about to move ${selection.label} to trash. Are you sure you want to continue?`,\n loadingLabel: `Processing ${selection.label}`,\n execute: async () => {\n await bulkDelete.execute(selectedItems, selection.allSelected);\n presenter.list.actions.selection.deselectAll();\n\n if (selection.allSelected) {\n toast.showSuccessToast({\n title: \"Entries will be trashed in the background\",\n description:\n \"All entries will be moved to trash. This process will be carried out in the background and may take some time. You can safely navigate away from this page while the process is running.\",\n dismissible: true,\n duration: Infinity\n });\n return;\n }\n\n showResultsDialog({\n results: bulkDelete.vm.results,\n title: \"Trash entries\",\n message: \"Finished moving entries to trash! See full report below:\"\n });\n }\n });\n\n return (\n <BulkActionButton\n text=\"Trash\"\n tooltipContent={`Trash ${selection.label}`}\n icon={<DeleteIcon />}\n onClick={openDeleteEntriesDialog}\n />\n );\n});\n"],"names":["ActionDelete","observer","toast","useToast","presenter","useContentEntriesPresenter","showConfirmationDialog","showResultsDialog","useBulkActionDialog","bulkDelete","useFeature","BulkDeleteFeature","selection","selectedItems","row","openDeleteEntriesDialog","Infinity","BulkActionButton","DeleteIcon"],"mappings":";;;;;;;;AAYO,MAAMA,eAAeC,SAAS;IACjC,MAAMC,QAAQC;IACd,MAAMC,YAAYC;IAClB,MAAM,EAAEC,sBAAsB,EAAEC,iBAAiB,EAAE,GAAGC;IACtD,MAAM,EAAE,WAAWC,UAAU,EAAE,GAAGC,WAAWC;IAE7C,MAAMC,YAAYR,UAAU,IAAI,CAAC,EAAE,CAAC,SAAS;IAC7C,MAAMS,gBAAgBT,UAAU,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAACU,CAAAA,MACzCF,UAAU,WAAW,CAAC,GAAG,CAACE,IAAI,EAAE;IAG3C,MAAMC,0BAA0B,IAC5BT,uBAAuB;YACnB,OAAO;YACP,SAAS,CAAC,sBAAsB,EAAEM,UAAU,KAAK,CAAC,6CAA6C,CAAC;YAChG,cAAc,CAAC,WAAW,EAAEA,UAAU,KAAK,EAAE;YAC7C,SAAS;gBACL,MAAMH,WAAW,OAAO,CAACI,eAAeD,UAAU,WAAW;gBAC7DR,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW;gBAE5C,IAAIQ,UAAU,WAAW,EAAE,YACvBV,MAAM,gBAAgB,CAAC;oBACnB,OAAO;oBACP,aACI;oBACJ,aAAa;oBACb,UAAUc;
|
|
1
|
+
{"version":3,"file":"admin/components/ContentEntries/BulkActions/ActionDelete.js","sources":["../../../../../src/admin/components/ContentEntries/BulkActions/ActionDelete.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport { BulkDeleteFeature } from \"~/presentation/contentEntries/bulkActions/feature.js\";\nimport {\n BulkActionButton,\n useBulkActionDialog\n} from \"@webiny/app-admin/components/BulkActions/index.js\";\nimport { useContentEntriesPresenter } from \"~/presentation/contentEntries/list/useContentEntriesPresenter.js\";\n\nexport const ActionDelete = observer(() => {\n const toast = useToast();\n const presenter = useContentEntriesPresenter();\n const { showConfirmationDialog, showResultsDialog } = useBulkActionDialog();\n const { presenter: bulkDelete } = useFeature(BulkDeleteFeature);\n\n const selection = presenter.list.vm.selection;\n const selectedItems = presenter.list.vm.rows.filter(row => {\n return selection.selectedIds.has(row.id);\n });\n\n const openDeleteEntriesDialog = () =>\n showConfirmationDialog({\n title: \"Trash entries\",\n message: `You are about to move ${selection.label} to trash. Are you sure you want to continue?`,\n loadingLabel: `Processing ${selection.label}`,\n execute: async () => {\n await bulkDelete.execute(selectedItems, selection.allSelected);\n presenter.list.actions.selection.deselectAll();\n\n if (selection.allSelected) {\n toast.showSuccessToast({\n title: \"Entries will be trashed in the background\",\n description:\n \"All entries will be moved to trash. This process will be carried out in the background and may take some time. You can safely navigate away from this page while the process is running.\",\n dismissible: true,\n duration: Infinity\n });\n return;\n }\n\n showResultsDialog({\n results: bulkDelete.vm.results,\n title: \"Trash entries\",\n message: \"Finished moving entries to trash! See full report below:\"\n });\n }\n });\n\n return (\n <BulkActionButton\n text=\"Trash\"\n tooltipContent={`Trash ${selection.label}`}\n icon={<DeleteIcon />}\n onClick={openDeleteEntriesDialog}\n />\n );\n});\n"],"names":["ActionDelete","observer","toast","useToast","presenter","useContentEntriesPresenter","showConfirmationDialog","showResultsDialog","useBulkActionDialog","bulkDelete","useFeature","BulkDeleteFeature","selection","selectedItems","row","openDeleteEntriesDialog","Infinity","BulkActionButton","DeleteIcon"],"mappings":";;;;;;;;AAYO,MAAMA,eAAeC,SAAS;IACjC,MAAMC,QAAQC;IACd,MAAMC,YAAYC;IAClB,MAAM,EAAEC,sBAAsB,EAAEC,iBAAiB,EAAE,GAAGC;IACtD,MAAM,EAAE,WAAWC,UAAU,EAAE,GAAGC,WAAWC;IAE7C,MAAMC,YAAYR,UAAU,IAAI,CAAC,EAAE,CAAC,SAAS;IAC7C,MAAMS,gBAAgBT,UAAU,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAACU,CAAAA,MACzCF,UAAU,WAAW,CAAC,GAAG,CAACE,IAAI,EAAE;IAG3C,MAAMC,0BAA0B,IAC5BT,uBAAuB;YACnB,OAAO;YACP,SAAS,CAAC,sBAAsB,EAAEM,UAAU,KAAK,CAAC,6CAA6C,CAAC;YAChG,cAAc,CAAC,WAAW,EAAEA,UAAU,KAAK,EAAE;YAC7C,SAAS;gBACL,MAAMH,WAAW,OAAO,CAACI,eAAeD,UAAU,WAAW;gBAC7DR,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW;gBAE5C,IAAIQ,UAAU,WAAW,EAAE,YACvBV,MAAM,gBAAgB,CAAC;oBACnB,OAAO;oBACP,aACI;oBACJ,aAAa;oBACb,UAAUc,KAAQ;gBACtB;gBAIJT,kBAAkB;oBACd,SAASE,WAAW,EAAE,CAAC,OAAO;oBAC9B,OAAO;oBACP,SAAS;gBACb;YACJ;QACJ;IAEJ,OAAO,WAAP,GACI,oBAACQ,kBAAgBA;QACb,MAAK;QACL,gBAAgB,CAAC,MAAM,EAAEL,UAAU,KAAK,EAAE;QAC1C,oBAAM,oBAACM,gBAAUA;QACjB,SAASH;;AAGrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/components/ContentEntries/BulkActions/ActionMove.js","sources":["../../../../../src/admin/components/ContentEntries/BulkActions/ActionMove.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { ReactComponent as MoveIcon } from \"@webiny/icons/exit_to_app.svg\";\nimport { useMoveToFolderDialog } from \"@webiny/app-aco\";\nimport type { NodeDto } from \"@webiny/admin-ui\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport {\n BulkActionButton,\n useBulkActionDialog\n} from \"@webiny/app-admin/components/BulkActions/index.js\";\nimport { ROOT_FOLDER } from \"~/admin/constants.js\";\nimport { BulkMoveFeature } from \"~/presentation/contentEntries/bulkActions/feature.js\";\nimport { useContentEntriesPresenter } from \"~/presentation/contentEntries/list/useContentEntriesPresenter.js\";\n\nexport const ActionMove = observer(() => {\n const presenter = useContentEntriesPresenter();\n const { presenter: bulkMove } = useFeature(BulkMoveFeature);\n const toast = useToast();\n const { showConfirmationDialog, showResultsDialog } = useBulkActionDialog();\n const { showDialog: showMoveDialog } = useMoveToFolderDialog();\n\n const selection = presenter.list.vm.selection;\n const currentFolderId = presenter.folders.vm.currentFolderId;\n const selectedItems = presenter.list.vm.rows.filter(row => {\n return selection.selectedIds.has(row.id);\n });\n\n const openWorkerDialog = useCallback(\n (folder: NodeDto) => {\n showConfirmationDialog({\n title: \"Move entries\",\n message: `You are about to move ${selection.label} to ${folder.label}. Are you sure you want to continue?`,\n loadingLabel: `Processing ${selection.label}`,\n execute: async () => {\n await bulkMove.execute(selectedItems, selection.allSelected, folder.id);\n presenter.list.actions.selection.deselectAll();\n\n if (selection.allSelected) {\n toast.showSuccessToast({\n title: \"Entries will be moved in the background\",\n description: `All entries will be moved to ${folder.label}. This process will be carried out in the background and may take some time. You can safely navigate away from this page while the process is running.`,\n dismissible: true,\n duration: Infinity\n });\n\n return;\n }\n\n showResultsDialog({\n results: bulkMove.vm.results,\n title: \"Move entries\",\n message: \"Finished moving entries! See full report below:\"\n });\n }\n });\n },\n [selection.label, selection.allSelected, selectedItems]\n );\n\n const openMoveEntriesDialog = () =>\n showMoveDialog({\n title: \"Select folder\",\n message: \"Select a new location for selected entries:\",\n loadingLabel: `Processing ${selection.label}`,\n acceptLabel: \"Move\",\n focusedFolderId: currentFolderId || ROOT_FOLDER,\n async onAccept({ folder }) {\n openWorkerDialog(folder);\n }\n });\n\n return (\n <BulkActionButton\n text=\"Move\"\n tooltipContent={`Move ${selection.label}`}\n icon={<MoveIcon />}\n onClick={openMoveEntriesDialog}\n />\n );\n});\n"],"names":["ActionMove","observer","presenter","useContentEntriesPresenter","bulkMove","useFeature","BulkMoveFeature","toast","useToast","showConfirmationDialog","showResultsDialog","useBulkActionDialog","showMoveDialog","useMoveToFolderDialog","selection","currentFolderId","selectedItems","row","openWorkerDialog","useCallback","folder","Infinity","openMoveEntriesDialog","ROOT_FOLDER","BulkActionButton","MoveIcon"],"mappings":";;;;;;;;;;AAeO,MAAMA,aAAaC,SAAS;IAC/B,MAAMC,YAAYC;IAClB,MAAM,EAAE,WAAWC,QAAQ,EAAE,GAAGC,WAAWC;IAC3C,MAAMC,QAAQC;IACd,MAAM,EAAEC,sBAAsB,EAAEC,iBAAiB,EAAE,GAAGC;IACtD,MAAM,EAAE,YAAYC,cAAc,EAAE,GAAGC;IAEvC,MAAMC,YAAYZ,UAAU,IAAI,CAAC,EAAE,CAAC,SAAS;IAC7C,MAAMa,kBAAkBb,UAAU,OAAO,CAAC,EAAE,CAAC,eAAe;IAC5D,MAAMc,gBAAgBd,UAAU,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAACe,CAAAA,MACzCH,UAAU,WAAW,CAAC,GAAG,CAACG,IAAI,EAAE;IAG3C,MAAMC,mBAAmBC,YACrB,CAACC;QACGX,uBAAuB;YACnB,OAAO;YACP,SAAS,CAAC,sBAAsB,EAAEK,UAAU,KAAK,CAAC,IAAI,EAAEM,OAAO,KAAK,CAAC,oCAAoC,CAAC;YAC1G,cAAc,CAAC,WAAW,EAAEN,UAAU,KAAK,EAAE;YAC7C,SAAS;gBACL,MAAMV,SAAS,OAAO,CAACY,eAAeF,UAAU,WAAW,EAAEM,OAAO,EAAE;gBACtElB,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW;gBAE5C,IAAIY,UAAU,WAAW,EAAE,YACvBP,MAAM,gBAAgB,CAAC;oBACnB,OAAO;oBACP,aAAa,CAAC,6BAA6B,EAAEa,OAAO,KAAK,CAAC,sJAAsJ,CAAC;oBACjN,aAAa;oBACb,UAAUC;
|
|
1
|
+
{"version":3,"file":"admin/components/ContentEntries/BulkActions/ActionMove.js","sources":["../../../../../src/admin/components/ContentEntries/BulkActions/ActionMove.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { ReactComponent as MoveIcon } from \"@webiny/icons/exit_to_app.svg\";\nimport { useMoveToFolderDialog } from \"@webiny/app-aco\";\nimport type { NodeDto } from \"@webiny/admin-ui\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport {\n BulkActionButton,\n useBulkActionDialog\n} from \"@webiny/app-admin/components/BulkActions/index.js\";\nimport { ROOT_FOLDER } from \"~/admin/constants.js\";\nimport { BulkMoveFeature } from \"~/presentation/contentEntries/bulkActions/feature.js\";\nimport { useContentEntriesPresenter } from \"~/presentation/contentEntries/list/useContentEntriesPresenter.js\";\n\nexport const ActionMove = observer(() => {\n const presenter = useContentEntriesPresenter();\n const { presenter: bulkMove } = useFeature(BulkMoveFeature);\n const toast = useToast();\n const { showConfirmationDialog, showResultsDialog } = useBulkActionDialog();\n const { showDialog: showMoveDialog } = useMoveToFolderDialog();\n\n const selection = presenter.list.vm.selection;\n const currentFolderId = presenter.folders.vm.currentFolderId;\n const selectedItems = presenter.list.vm.rows.filter(row => {\n return selection.selectedIds.has(row.id);\n });\n\n const openWorkerDialog = useCallback(\n (folder: NodeDto) => {\n showConfirmationDialog({\n title: \"Move entries\",\n message: `You are about to move ${selection.label} to ${folder.label}. Are you sure you want to continue?`,\n loadingLabel: `Processing ${selection.label}`,\n execute: async () => {\n await bulkMove.execute(selectedItems, selection.allSelected, folder.id);\n presenter.list.actions.selection.deselectAll();\n\n if (selection.allSelected) {\n toast.showSuccessToast({\n title: \"Entries will be moved in the background\",\n description: `All entries will be moved to ${folder.label}. This process will be carried out in the background and may take some time. You can safely navigate away from this page while the process is running.`,\n dismissible: true,\n duration: Infinity\n });\n\n return;\n }\n\n showResultsDialog({\n results: bulkMove.vm.results,\n title: \"Move entries\",\n message: \"Finished moving entries! See full report below:\"\n });\n }\n });\n },\n [selection.label, selection.allSelected, selectedItems]\n );\n\n const openMoveEntriesDialog = () =>\n showMoveDialog({\n title: \"Select folder\",\n message: \"Select a new location for selected entries:\",\n loadingLabel: `Processing ${selection.label}`,\n acceptLabel: \"Move\",\n focusedFolderId: currentFolderId || ROOT_FOLDER,\n async onAccept({ folder }) {\n openWorkerDialog(folder);\n }\n });\n\n return (\n <BulkActionButton\n text=\"Move\"\n tooltipContent={`Move ${selection.label}`}\n icon={<MoveIcon />}\n onClick={openMoveEntriesDialog}\n />\n );\n});\n"],"names":["ActionMove","observer","presenter","useContentEntriesPresenter","bulkMove","useFeature","BulkMoveFeature","toast","useToast","showConfirmationDialog","showResultsDialog","useBulkActionDialog","showMoveDialog","useMoveToFolderDialog","selection","currentFolderId","selectedItems","row","openWorkerDialog","useCallback","folder","Infinity","openMoveEntriesDialog","ROOT_FOLDER","BulkActionButton","MoveIcon"],"mappings":";;;;;;;;;;AAeO,MAAMA,aAAaC,SAAS;IAC/B,MAAMC,YAAYC;IAClB,MAAM,EAAE,WAAWC,QAAQ,EAAE,GAAGC,WAAWC;IAC3C,MAAMC,QAAQC;IACd,MAAM,EAAEC,sBAAsB,EAAEC,iBAAiB,EAAE,GAAGC;IACtD,MAAM,EAAE,YAAYC,cAAc,EAAE,GAAGC;IAEvC,MAAMC,YAAYZ,UAAU,IAAI,CAAC,EAAE,CAAC,SAAS;IAC7C,MAAMa,kBAAkBb,UAAU,OAAO,CAAC,EAAE,CAAC,eAAe;IAC5D,MAAMc,gBAAgBd,UAAU,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAACe,CAAAA,MACzCH,UAAU,WAAW,CAAC,GAAG,CAACG,IAAI,EAAE;IAG3C,MAAMC,mBAAmBC,YACrB,CAACC;QACGX,uBAAuB;YACnB,OAAO;YACP,SAAS,CAAC,sBAAsB,EAAEK,UAAU,KAAK,CAAC,IAAI,EAAEM,OAAO,KAAK,CAAC,oCAAoC,CAAC;YAC1G,cAAc,CAAC,WAAW,EAAEN,UAAU,KAAK,EAAE;YAC7C,SAAS;gBACL,MAAMV,SAAS,OAAO,CAACY,eAAeF,UAAU,WAAW,EAAEM,OAAO,EAAE;gBACtElB,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW;gBAE5C,IAAIY,UAAU,WAAW,EAAE,YACvBP,MAAM,gBAAgB,CAAC;oBACnB,OAAO;oBACP,aAAa,CAAC,6BAA6B,EAAEa,OAAO,KAAK,CAAC,sJAAsJ,CAAC;oBACjN,aAAa;oBACb,UAAUC,KAAQ;gBACtB;gBAKJX,kBAAkB;oBACd,SAASN,SAAS,EAAE,CAAC,OAAO;oBAC5B,OAAO;oBACP,SAAS;gBACb;YACJ;QACJ;IACJ,GACA;QAACU,UAAU,KAAK;QAAEA,UAAU,WAAW;QAAEE;KAAc;IAG3D,MAAMM,wBAAwB,IAC1BV,eAAe;YACX,OAAO;YACP,SAAS;YACT,cAAc,CAAC,WAAW,EAAEE,UAAU,KAAK,EAAE;YAC7C,aAAa;YACb,iBAAiBC,mBAAmBQ;YACpC,MAAM,UAAS,EAAEH,MAAM,EAAE;gBACrBF,iBAAiBE;YACrB;QACJ;IAEJ,OAAO,WAAP,GACI,oBAACI,kBAAgBA;QACb,MAAK;QACL,gBAAgB,CAAC,KAAK,EAAEV,UAAU,KAAK,EAAE;QACzC,oBAAM,oBAACW,gBAAQA;QACf,SAASH;;AAGrB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const ActionPublish: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const ActionPublish: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/components/ContentEntries/BulkActions/ActionPublish.js","sources":["../../../../../src/admin/components/ContentEntries/BulkActions/ActionPublish.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport { ReactComponent as PublishIcon } from \"@webiny/icons/visibility.svg\";\nimport {\n BulkActionButton,\n useBulkActionDialog\n} from \"@webiny/app-admin/components/BulkActions/index.js\";\nimport { usePermission } from \"~/admin/hooks/index.js\";\nimport { BulkPublishFeature } from \"~/presentation/contentEntries/bulkActions/feature.js\";\nimport { useContentEntriesPresenter } from \"~/presentation/contentEntries/list/useContentEntriesPresenter.js\";\n\nexport const ActionPublish = observer(() => {\n const { canPublish } = usePermission();\n const presenter = useContentEntriesPresenter();\n const toast = useToast();\n const { showConfirmationDialog, showResultsDialog } = useBulkActionDialog();\n const { presenter: bulkPublish } = useFeature(BulkPublishFeature);\n\n const selection = presenter.list.vm.selection;\n const selectedItems = presenter.list.vm.rows.filter(row => {\n return selection.selectedIds.has(row.id);\n });\n\n const openPublishEntriesDialog = () =>\n showConfirmationDialog({\n title: \"Publish entries\",\n message: `You are about to publish ${selection.label}. Are you sure you want to continue?`,\n loadingLabel: `Processing ${selection.label}`,\n execute: async () => {\n await bulkPublish.execute(selectedItems, selection.allSelected);\n presenter.list.actions.selection.deselectAll();\n\n if (selection.allSelected) {\n toast.showSuccessToast({\n title: \"Publishing of entries started in the background\",\n description:\n \"All entries will be published. This process will be carried out in the background and may take some time. You can safely navigate away from this page while the process is running.\",\n dismissible: true,\n duration: Infinity\n });\n return;\n }\n\n showResultsDialog({\n results: bulkPublish.vm.results,\n title: \"Publish entries\",\n message: \"Finished publishing entries! See full report below:\"\n });\n }\n });\n\n if (!canPublish(\"cms.contentEntry\")) {\n return null;\n }\n\n return (\n <BulkActionButton\n text=\"Publish\"\n tooltipContent={`Publish ${selection.label}`}\n icon={<PublishIcon />}\n onClick={openPublishEntriesDialog}\n />\n );\n});\n"],"names":["ActionPublish","observer","canPublish","usePermission","presenter","useContentEntriesPresenter","toast","useToast","showConfirmationDialog","showResultsDialog","useBulkActionDialog","bulkPublish","useFeature","BulkPublishFeature","selection","selectedItems","row","openPublishEntriesDialog","Infinity","BulkActionButton","PublishIcon"],"mappings":";;;;;;;;;AAaO,MAAMA,gBAAgBC,SAAS;IAClC,MAAM,EAAEC,UAAU,EAAE,GAAGC;IACvB,MAAMC,YAAYC;IAClB,MAAMC,QAAQC;IACd,MAAM,EAAEC,sBAAsB,EAAEC,iBAAiB,EAAE,GAAGC;IACtD,MAAM,EAAE,WAAWC,WAAW,EAAE,GAAGC,WAAWC;IAE9C,MAAMC,YAAYV,UAAU,IAAI,CAAC,EAAE,CAAC,SAAS;IAC7C,MAAMW,gBAAgBX,UAAU,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAACY,CAAAA,MACzCF,UAAU,WAAW,CAAC,GAAG,CAACE,IAAI,EAAE;IAG3C,MAAMC,2BAA2B,IAC7BT,uBAAuB;YACnB,OAAO;YACP,SAAS,CAAC,yBAAyB,EAAEM,UAAU,KAAK,CAAC,oCAAoC,CAAC;YAC1F,cAAc,CAAC,WAAW,EAAEA,UAAU,KAAK,EAAE;YAC7C,SAAS;gBACL,MAAMH,YAAY,OAAO,CAACI,eAAeD,UAAU,WAAW;gBAC9DV,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW;gBAE5C,IAAIU,UAAU,WAAW,EAAE,YACvBR,MAAM,gBAAgB,CAAC;oBACnB,OAAO;oBACP,aACI;oBACJ,aAAa;oBACb,UAAUY;
|
|
1
|
+
{"version":3,"file":"admin/components/ContentEntries/BulkActions/ActionPublish.js","sources":["../../../../../src/admin/components/ContentEntries/BulkActions/ActionPublish.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport { ReactComponent as PublishIcon } from \"@webiny/icons/visibility.svg\";\nimport {\n BulkActionButton,\n useBulkActionDialog\n} from \"@webiny/app-admin/components/BulkActions/index.js\";\nimport { usePermission } from \"~/admin/hooks/index.js\";\nimport { BulkPublishFeature } from \"~/presentation/contentEntries/bulkActions/feature.js\";\nimport { useContentEntriesPresenter } from \"~/presentation/contentEntries/list/useContentEntriesPresenter.js\";\n\nexport const ActionPublish = observer(() => {\n const { canPublish } = usePermission();\n const presenter = useContentEntriesPresenter();\n const toast = useToast();\n const { showConfirmationDialog, showResultsDialog } = useBulkActionDialog();\n const { presenter: bulkPublish } = useFeature(BulkPublishFeature);\n\n const selection = presenter.list.vm.selection;\n const selectedItems = presenter.list.vm.rows.filter(row => {\n return selection.selectedIds.has(row.id);\n });\n\n const openPublishEntriesDialog = () =>\n showConfirmationDialog({\n title: \"Publish entries\",\n message: `You are about to publish ${selection.label}. Are you sure you want to continue?`,\n loadingLabel: `Processing ${selection.label}`,\n execute: async () => {\n await bulkPublish.execute(selectedItems, selection.allSelected);\n presenter.list.actions.selection.deselectAll();\n\n if (selection.allSelected) {\n toast.showSuccessToast({\n title: \"Publishing of entries started in the background\",\n description:\n \"All entries will be published. This process will be carried out in the background and may take some time. You can safely navigate away from this page while the process is running.\",\n dismissible: true,\n duration: Infinity\n });\n return;\n }\n\n showResultsDialog({\n results: bulkPublish.vm.results,\n title: \"Publish entries\",\n message: \"Finished publishing entries! See full report below:\"\n });\n }\n });\n\n if (!canPublish(\"cms.contentEntry\")) {\n return null;\n }\n\n return (\n <BulkActionButton\n text=\"Publish\"\n tooltipContent={`Publish ${selection.label}`}\n icon={<PublishIcon />}\n onClick={openPublishEntriesDialog}\n />\n );\n});\n"],"names":["ActionPublish","observer","canPublish","usePermission","presenter","useContentEntriesPresenter","toast","useToast","showConfirmationDialog","showResultsDialog","useBulkActionDialog","bulkPublish","useFeature","BulkPublishFeature","selection","selectedItems","row","openPublishEntriesDialog","Infinity","BulkActionButton","PublishIcon"],"mappings":";;;;;;;;;AAaO,MAAMA,gBAAgBC,SAAS;IAClC,MAAM,EAAEC,UAAU,EAAE,GAAGC;IACvB,MAAMC,YAAYC;IAClB,MAAMC,QAAQC;IACd,MAAM,EAAEC,sBAAsB,EAAEC,iBAAiB,EAAE,GAAGC;IACtD,MAAM,EAAE,WAAWC,WAAW,EAAE,GAAGC,WAAWC;IAE9C,MAAMC,YAAYV,UAAU,IAAI,CAAC,EAAE,CAAC,SAAS;IAC7C,MAAMW,gBAAgBX,UAAU,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAACY,CAAAA,MACzCF,UAAU,WAAW,CAAC,GAAG,CAACE,IAAI,EAAE;IAG3C,MAAMC,2BAA2B,IAC7BT,uBAAuB;YACnB,OAAO;YACP,SAAS,CAAC,yBAAyB,EAAEM,UAAU,KAAK,CAAC,oCAAoC,CAAC;YAC1F,cAAc,CAAC,WAAW,EAAEA,UAAU,KAAK,EAAE;YAC7C,SAAS;gBACL,MAAMH,YAAY,OAAO,CAACI,eAAeD,UAAU,WAAW;gBAC9DV,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW;gBAE5C,IAAIU,UAAU,WAAW,EAAE,YACvBR,MAAM,gBAAgB,CAAC;oBACnB,OAAO;oBACP,aACI;oBACJ,aAAa;oBACb,UAAUY,KAAQ;gBACtB;gBAIJT,kBAAkB;oBACd,SAASE,YAAY,EAAE,CAAC,OAAO;oBAC/B,OAAO;oBACP,SAAS;gBACb;YACJ;QACJ;IAEJ,IAAI,CAACT,WAAW,qBACZ,OAAO;IAGX,OAAO,WAAP,GACI,oBAACiB,kBAAgBA;QACb,MAAK;QACL,gBAAgB,CAAC,QAAQ,EAAEL,UAAU,KAAK,EAAE;QAC5C,oBAAM,oBAACM,gBAAWA;QAClB,SAASH;;AAGrB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const ActionUnpublish: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const ActionUnpublish: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/components/ContentEntries/BulkActions/ActionUnpublish.js","sources":["../../../../../src/admin/components/ContentEntries/BulkActions/ActionUnpublish.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { ReactComponent as UnpublishIcon } from \"@webiny/icons/visibility_off.svg\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport {\n BulkActionButton,\n useBulkActionDialog\n} from \"@webiny/app-admin/components/BulkActions/index.js\";\nimport { usePermission } from \"~/admin/hooks/index.js\";\nimport { BulkUnpublishFeature } from \"~/presentation/contentEntries/bulkActions/feature.js\";\nimport { useContentEntriesPresenter } from \"~/presentation/contentEntries/list/useContentEntriesPresenter.js\";\n\nexport const ActionUnpublish = observer(() => {\n const { canUnpublish } = usePermission();\n const presenter = useContentEntriesPresenter();\n const { presenter: bulkUnpublish } = useFeature(BulkUnpublishFeature);\n const toast = useToast();\n const { showConfirmationDialog, showResultsDialog } = useBulkActionDialog();\n\n const selection = presenter.list.vm.selection;\n const selectedItems = presenter.list.vm.rows.filter(row => {\n return selection.selectedIds.has(row.id);\n });\n\n const openUnpublishEntriesDialog = () => {\n showConfirmationDialog({\n title: \"Unpublish entries\",\n message: `You are about to unpublish ${selection.label}. Are you sure you want to continue?`,\n loadingLabel: `Processing ${selection.label}`,\n execute: async () => {\n await bulkUnpublish.execute(selectedItems, selection.allSelected);\n presenter.list.actions.selection.deselectAll();\n\n if (selection.allSelected) {\n toast.showSuccessToast({\n title: \"Entries will be unpublished in the background\",\n description:\n \"All entries will be unpublished. This process will be carried out in the background and may take some time. You can safely navigate away from this page while the process is running.\",\n dismissible: true,\n duration: Infinity\n });\n\n return;\n }\n\n showResultsDialog({\n results: bulkUnpublish.vm.results,\n title: \"Unpublish entries\",\n message: \"Finished unpublishing entries! See full report below:\"\n });\n }\n });\n };\n\n if (!canUnpublish(\"cms.contentEntry\")) {\n return null;\n }\n\n return (\n <BulkActionButton\n text=\"Unpublish\"\n tooltipContent={`Unpublish ${selection.label}`}\n icon={<UnpublishIcon />}\n onClick={openUnpublishEntriesDialog}\n />\n );\n});\n"],"names":["ActionUnpublish","observer","canUnpublish","usePermission","presenter","useContentEntriesPresenter","bulkUnpublish","useFeature","BulkUnpublishFeature","toast","useToast","showConfirmationDialog","showResultsDialog","useBulkActionDialog","selection","selectedItems","row","openUnpublishEntriesDialog","Infinity","BulkActionButton","UnpublishIcon"],"mappings":";;;;;;;;;AAaO,MAAMA,kBAAkBC,SAAS;IACpC,MAAM,EAAEC,YAAY,EAAE,GAAGC;IACzB,MAAMC,YAAYC;IAClB,MAAM,EAAE,WAAWC,aAAa,EAAE,GAAGC,WAAWC;IAChD,MAAMC,QAAQC;IACd,MAAM,EAAEC,sBAAsB,EAAEC,iBAAiB,EAAE,GAAGC;IAEtD,MAAMC,YAAYV,UAAU,IAAI,CAAC,EAAE,CAAC,SAAS;IAC7C,MAAMW,gBAAgBX,UAAU,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAACY,CAAAA,MACzCF,UAAU,WAAW,CAAC,GAAG,CAACE,IAAI,EAAE;IAG3C,MAAMC,6BAA6B;QAC/BN,uBAAuB;YACnB,OAAO;YACP,SAAS,CAAC,2BAA2B,EAAEG,UAAU,KAAK,CAAC,oCAAoC,CAAC;YAC5F,cAAc,CAAC,WAAW,EAAEA,UAAU,KAAK,EAAE;YAC7C,SAAS;gBACL,MAAMR,cAAc,OAAO,CAACS,eAAeD,UAAU,WAAW;gBAChEV,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW;gBAE5C,IAAIU,UAAU,WAAW,EAAE,YACvBL,MAAM,gBAAgB,CAAC;oBACnB,OAAO;oBACP,aACI;oBACJ,aAAa;oBACb,UAAUS;
|
|
1
|
+
{"version":3,"file":"admin/components/ContentEntries/BulkActions/ActionUnpublish.js","sources":["../../../../../src/admin/components/ContentEntries/BulkActions/ActionUnpublish.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { ReactComponent as UnpublishIcon } from \"@webiny/icons/visibility_off.svg\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport {\n BulkActionButton,\n useBulkActionDialog\n} from \"@webiny/app-admin/components/BulkActions/index.js\";\nimport { usePermission } from \"~/admin/hooks/index.js\";\nimport { BulkUnpublishFeature } from \"~/presentation/contentEntries/bulkActions/feature.js\";\nimport { useContentEntriesPresenter } from \"~/presentation/contentEntries/list/useContentEntriesPresenter.js\";\n\nexport const ActionUnpublish = observer(() => {\n const { canUnpublish } = usePermission();\n const presenter = useContentEntriesPresenter();\n const { presenter: bulkUnpublish } = useFeature(BulkUnpublishFeature);\n const toast = useToast();\n const { showConfirmationDialog, showResultsDialog } = useBulkActionDialog();\n\n const selection = presenter.list.vm.selection;\n const selectedItems = presenter.list.vm.rows.filter(row => {\n return selection.selectedIds.has(row.id);\n });\n\n const openUnpublishEntriesDialog = () => {\n showConfirmationDialog({\n title: \"Unpublish entries\",\n message: `You are about to unpublish ${selection.label}. Are you sure you want to continue?`,\n loadingLabel: `Processing ${selection.label}`,\n execute: async () => {\n await bulkUnpublish.execute(selectedItems, selection.allSelected);\n presenter.list.actions.selection.deselectAll();\n\n if (selection.allSelected) {\n toast.showSuccessToast({\n title: \"Entries will be unpublished in the background\",\n description:\n \"All entries will be unpublished. This process will be carried out in the background and may take some time. You can safely navigate away from this page while the process is running.\",\n dismissible: true,\n duration: Infinity\n });\n\n return;\n }\n\n showResultsDialog({\n results: bulkUnpublish.vm.results,\n title: \"Unpublish entries\",\n message: \"Finished unpublishing entries! See full report below:\"\n });\n }\n });\n };\n\n if (!canUnpublish(\"cms.contentEntry\")) {\n return null;\n }\n\n return (\n <BulkActionButton\n text=\"Unpublish\"\n tooltipContent={`Unpublish ${selection.label}`}\n icon={<UnpublishIcon />}\n onClick={openUnpublishEntriesDialog}\n />\n );\n});\n"],"names":["ActionUnpublish","observer","canUnpublish","usePermission","presenter","useContentEntriesPresenter","bulkUnpublish","useFeature","BulkUnpublishFeature","toast","useToast","showConfirmationDialog","showResultsDialog","useBulkActionDialog","selection","selectedItems","row","openUnpublishEntriesDialog","Infinity","BulkActionButton","UnpublishIcon"],"mappings":";;;;;;;;;AAaO,MAAMA,kBAAkBC,SAAS;IACpC,MAAM,EAAEC,YAAY,EAAE,GAAGC;IACzB,MAAMC,YAAYC;IAClB,MAAM,EAAE,WAAWC,aAAa,EAAE,GAAGC,WAAWC;IAChD,MAAMC,QAAQC;IACd,MAAM,EAAEC,sBAAsB,EAAEC,iBAAiB,EAAE,GAAGC;IAEtD,MAAMC,YAAYV,UAAU,IAAI,CAAC,EAAE,CAAC,SAAS;IAC7C,MAAMW,gBAAgBX,UAAU,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAACY,CAAAA,MACzCF,UAAU,WAAW,CAAC,GAAG,CAACE,IAAI,EAAE;IAG3C,MAAMC,6BAA6B;QAC/BN,uBAAuB;YACnB,OAAO;YACP,SAAS,CAAC,2BAA2B,EAAEG,UAAU,KAAK,CAAC,oCAAoC,CAAC;YAC5F,cAAc,CAAC,WAAW,EAAEA,UAAU,KAAK,EAAE;YAC7C,SAAS;gBACL,MAAMR,cAAc,OAAO,CAACS,eAAeD,UAAU,WAAW;gBAChEV,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW;gBAE5C,IAAIU,UAAU,WAAW,EAAE,YACvBL,MAAM,gBAAgB,CAAC;oBACnB,OAAO;oBACP,aACI;oBACJ,aAAa;oBACb,UAAUS,KAAQ;gBACtB;gBAKJN,kBAAkB;oBACd,SAASN,cAAc,EAAE,CAAC,OAAO;oBACjC,OAAO;oBACP,SAAS;gBACb;YACJ;QACJ;IACJ;IAEA,IAAI,CAACJ,aAAa,qBACd,OAAO;IAGX,OAAO,WAAP,GACI,oBAACiB,kBAAgBA;QACb,MAAK;QACL,gBAAgB,CAAC,UAAU,EAAEL,UAAU,KAAK,EAAE;QAC9C,oBAAM,oBAACM,gBAAaA;QACpB,SAASH;;AAGrB"}
|
|
@@ -68,7 +68,7 @@ const ContentModelEditor = makeDecoratable("ContentModelEditor", ()=>{
|
|
|
68
68
|
if (!data) return /*#__PURE__*/ react.createElement(OverlayLoader, {
|
|
69
69
|
text: "Loading content model..."
|
|
70
70
|
});
|
|
71
|
-
if (data.isBeingDeleted) return /*#__PURE__*/ react.createElement(ModelIsBeingDeletedError, {
|
|
71
|
+
else if (data.isBeingDeleted) return /*#__PURE__*/ react.createElement(ModelIsBeingDeletedError, {
|
|
72
72
|
model: data
|
|
73
73
|
});
|
|
74
74
|
return /*#__PURE__*/ react.createElement("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/components/ContentModelEditor/ContentModelEditor.js","sources":["../../../../src/admin/components/ContentModelEditor/ContentModelEditor.tsx"],"sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport { makeDecoratable, useDialogs } from \"@webiny/app-admin\";\nimport { useRouter } from \"@webiny/app\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { IconButton, OverlayLoader, SegmentedControlPrimitive, Tag, Text } from \"@webiny/admin-ui\";\nimport { ReactComponent as ExpandSidebarIcon } from \"@webiny/icons/left_panel_open.svg\";\nimport { ReactComponent as ViewCompactAltIcon } from \"@webiny/icons/view_compact_alt.svg\";\nimport { ReactComponent as ViewDayIcon } from \"@webiny/icons/view_day.svg\";\nimport { FieldsSidebar } from \"./FieldsSidebar.js\";\n\nconst VIEW_ITEMS = [\n { id: \"compact\", value: \"compact\", label: \"\", icon: <ViewCompactAltIcon /> },\n { id: \"full\", value: \"full\", label: \"\", icon: <ViewDayIcon /> }\n];\nimport { FieldEditor } from \"../FieldEditor/index.js\";\nimport { PreviewTab } from \"./PreviewTab.js\";\nimport Header from \"./Header.js\";\nimport DragPreview from \"../DragPreview.js\";\nimport { useModelEditor } from \"./useModelEditor.js\";\nimport type { CmsEditorFieldsLayout, CmsModelField } from \"~/types.js\";\nimport { ContentEntryEditorWithConfig } from \"~/admin/config/contentEntries/index.js\";\nimport { ModelIsBeingDeletedError } from \"~/admin/components/ContentModelEditor/ModelIsBeingDeletedError/index.js\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/editor\");\n\nconst prompt = t`There are some unsaved changes! Are you sure you want to navigate away and discard all changes?`;\n\ninterface OnChangeParams {\n fields: CmsModelField[];\n layout: CmsEditorFieldsLayout;\n}\n\nexport const ContentModelEditor = makeDecoratable(\"ContentModelEditor\", () => {\n const { data, setData, isPristine } = useModelEditor();\n const router = useRouter();\n const dialogs = useDialogs();\n\n // Add a class to <body> to trigger global styles while this component is active\n useEffect(() => {\n document.body.classList.add(\"overflow-hidden\");\n\n return () => {\n document.body.classList.remove(\"overflow-hidden\");\n };\n }, []);\n\n const isPristineRef = React.useRef(isPristine);\n isPristineRef.current = isPristine;\n\n useEffect(() => {\n return router.addTransitionGuard({\n guard: () => !isPristineRef.current,\n onBlocked: () => {\n dialogs.showDialog({\n title: \"Confirm Navigation\",\n content: prompt,\n acceptLabel: \"Yes!\",\n cancelLabel: \"No, stay here.\",\n onAccept: () => router.confirmTransition(),\n onClose: () => router.cancelTransition()\n });\n }\n });\n }, []);\n\n const [activeTab, setActiveTab] = useState<string>(\"edit\");\n const [isSidebarOpen, setIsSidebarOpen] = useState(true);\n const [activeView, setActiveView] = useState(\"compact\");\n\n const onChange = ({ fields, layout }: OnChangeParams) => {\n setData(data => ({ ...data, fields, layout }));\n };\n\n if (!data) {\n return <OverlayLoader text={\"Loading content model...\"} />;\n } else if (data.isBeingDeleted) {\n return <ModelIsBeingDeletedError model={data} />;\n }\n\n return (\n <div className={\"content-model-editor flex-1\"}>\n <Header activeTab={activeTab} onTabChange={setActiveTab} />\n <div className={\"w-full overflow-y-auto h-main-content\"}>\n <div className={\"flex h-full\"}>\n <div\n className={\n \"shrink-0 bg-neutral-base border-r border-neutral-dimmed overflow-hidden h-main-content relative transition-[width] duration-200 ease-in-out\"\n }\n style={{ width: isSidebarOpen ? 200 : 45 }}\n >\n {/* Expanded content */}\n <div\n className={\n \"transition-opacity duration-150 \" +\n (isSidebarOpen\n ? \"opacity-100 delay-75\"\n : \"opacity-0 pointer-events-none\")\n }\n >\n <FieldsSidebar\n onFieldDragStart={() => setActiveTab(\"edit\")}\n onCollapse={() => setIsSidebarOpen(false)}\n />\n </div>\n {/* Collapsed strip */}\n <div\n className={\n \"absolute inset-0 flex flex-col items-center pt-md gap-md transition-opacity duration-150 \" +\n (!isSidebarOpen\n ? \"opacity-100 delay-75\"\n : \"opacity-0 pointer-events-none\")\n }\n >\n <IconButton\n variant={\"ghost\"}\n size={\"xs\"}\n icon={<ExpandSidebarIcon />}\n onClick={() => setIsSidebarOpen(true)}\n />\n <span\n className={\n \"text-sm font-semibold text-neutral-strong [writing-mode:vertical-rl]\"\n }\n >\n Fields\n </span>\n </div>\n </div>\n <div\n className={\n \"flex-1 overflow-y-scroll h-main-content \" +\n (activeTab === \"edit\" ? \"fill-grid\" : \"bg-neutral-subtle\")\n }\n >\n <div\n className={\n \"sticky top-0 left-0 z-10 p-md flex items-center justify-between\"\n }\n >\n <div>\n {activeTab === \"edit\" && (\n <Text\n as=\"div\"\n size={\"sm\"}\n className={\"font-semibold text-neutral-primary\"}\n >\n Model editor\n </Text>\n )}\n {activeTab === \"preview\" && (\n <Tag content={\"Preview\"} variant={\"warning\"} />\n )}\n </div>\n <SegmentedControlPrimitive\n variant={\"light\"}\n value={activeView}\n onChange={setActiveView}\n items={VIEW_ITEMS}\n />\n </div>\n <div className={\"pb-lg\"}>\n <div\n className={\" transition-[width] duration-200 ease-in-out\"}\n style={{\n width: activeView === \"compact\" ? \"704px\" : \"90%\",\n marginLeft: \"auto\",\n marginRight: \"auto\"\n }}\n >\n {activeTab === \"edit\" && (\n <div className={\"relative\"} data-testid={\"cms.editor.tab.edit\"}>\n <FieldEditor\n fields={data.fields}\n layout={data.layout || []}\n onChange={onChange}\n />\n </div>\n )}\n {activeTab === \"preview\" && (\n <div\n className={\"px-xxl py-lg\"}\n data-testid={\"cms.editor.tab.preview\"}\n >\n <ContentEntryEditorWithConfig>\n <PreviewTab\n activeTab={true}\n onSwitchToEdit={() => setActiveTab(\"edit\")}\n />\n </ContentEntryEditorWithConfig>\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n <DragPreview />\n </div>\n </div>\n );\n});\n"],"names":["VIEW_ITEMS","ViewCompactAltIcon","ViewDayIcon","t","i18n","prompt","ContentModelEditor","makeDecoratable","data","setData","isPristine","useModelEditor","router","useRouter","dialogs","useDialogs","useEffect","document","isPristineRef","React","activeTab","setActiveTab","useState","isSidebarOpen","setIsSidebarOpen","activeView","setActiveView","onChange","fields","layout","OverlayLoader","ModelIsBeingDeletedError","Header","FieldsSidebar","IconButton","ExpandSidebarIcon","Text","Tag","SegmentedControlPrimitive","FieldEditor","ContentEntryEditorWithConfig","PreviewTab","DragPreview"],"mappings":";;;;;;;;;;;;;;;;AAUA,MAAMA,aAAa;IACf;QAAE,IAAI;QAAW,OAAO;QAAW,OAAO;QAAI,MAAM,WAAN,GAAM,oBAACC,qCAAkBA;IAAI;IAC3E;QAAE,IAAI;QAAQ,OAAO;QAAQ,OAAO;QAAI,MAAM,WAAN,GAAM,oBAACC,6BAAWA;IAAI;CACjE;AAUD,MAAMC,IAAIC,KAAK,EAAE,CAAC;AAElB,MAAMC,4BAASF,CAAC,CAAC,+FAA+F,CAAC;AAO1G,MAAMG,qBAAqBC,gBAAgB,sBAAsB;IACpE,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,UAAU,EAAE,GAAGC;IACtC,MAAMC,SAASC;IACf,MAAMC,UAAUC;IAGhBC,UAAU;QACNC,SAAS,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;QAE5B,OAAO;YACHA,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;QACnC;IACJ,GAAG,EAAE;IAEL,MAAMC,gBAAgBC,MAAAA,MAAY,CAACT;IACnCQ,cAAc,OAAO,GAAGR;IAExBM,UAAU,IACCJ,OAAO,kBAAkB,CAAC;YAC7B,OAAO,IAAM,CAACM,cAAc,OAAO;YACnC,WAAW;gBACPJ,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D,oBAAC;QACG,WACI;qBAGJ,oBAAC,aACIA,AAAc,WAAdA,aAAwB,WAAV,GACX,oBAACgB,MAAIA;QACD,IAAG;QACH,MAAM;QACN,WAAW;OACd,iBAIJhB,AAAc,cAAdA,aAA2B,WAAb,GACX,oBAACiB,KAAGA;QAAC,SAAS;QAAW,SAAS;uBAG1C,oBAACC,2BAAyBA;QACtB,SAAS;QACT,OAAOb;QACP,UAAUC;QACV,OAAO1B;uBAGf,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QACG,WAAW;QACX,OAAO;YACH,OAAOyB,AAAe,cAAfA,aAA2B,UAAU;YAC5C,YAAY;YACZ,aAAa;QACjB;OAECL,AAAc,WAAdA,aAAwB,WAAV,GACX,oBAAC;QAAI,WAAW;QAAY,eAAa;qBACrC,oBAACmB,aAAWA;QACR,QAAQ/B,KAAK,MAAM;QACnB,QAAQA,KAAK,MAAM,IAAI,EAAE;QACzB,UAAUmB;SAIrBP,AAAc,cAAdA,aAA2B,WAAb,GACX,oBAAC;QACG,WAAW;QACX,eAAa;qBAEb,oBAACoB,8BAA4BA,MAAAA,WAAAA,GACzB,oBAACC,YAAUA;QACP,WAAW;QACX,gBAAgB,IAAMpB,aAAa;4BASnE,oBAACqB,aAAWA;AAI5B"}
|
|
1
|
+
{"version":3,"file":"admin/components/ContentModelEditor/ContentModelEditor.js","sources":["../../../../src/admin/components/ContentModelEditor/ContentModelEditor.tsx"],"sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport { makeDecoratable, useDialogs } from \"@webiny/app-admin\";\nimport { useRouter } from \"@webiny/app\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { IconButton, OverlayLoader, SegmentedControlPrimitive, Tag, Text } from \"@webiny/admin-ui\";\nimport { ReactComponent as ExpandSidebarIcon } from \"@webiny/icons/left_panel_open.svg\";\nimport { ReactComponent as ViewCompactAltIcon } from \"@webiny/icons/view_compact_alt.svg\";\nimport { ReactComponent as ViewDayIcon } from \"@webiny/icons/view_day.svg\";\nimport { FieldsSidebar } from \"./FieldsSidebar.js\";\n\nconst VIEW_ITEMS = [\n { id: \"compact\", value: \"compact\", label: \"\", icon: <ViewCompactAltIcon /> },\n { id: \"full\", value: \"full\", label: \"\", icon: <ViewDayIcon /> }\n];\nimport { FieldEditor } from \"../FieldEditor/index.js\";\nimport { PreviewTab } from \"./PreviewTab.js\";\nimport Header from \"./Header.js\";\nimport DragPreview from \"../DragPreview.js\";\nimport { useModelEditor } from \"./useModelEditor.js\";\nimport type { CmsEditorFieldsLayout, CmsModelField } from \"~/types.js\";\nimport { ContentEntryEditorWithConfig } from \"~/admin/config/contentEntries/index.js\";\nimport { ModelIsBeingDeletedError } from \"~/admin/components/ContentModelEditor/ModelIsBeingDeletedError/index.js\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/editor\");\n\nconst prompt = t`There are some unsaved changes! Are you sure you want to navigate away and discard all changes?`;\n\ninterface OnChangeParams {\n fields: CmsModelField[];\n layout: CmsEditorFieldsLayout;\n}\n\nexport const ContentModelEditor = makeDecoratable(\"ContentModelEditor\", () => {\n const { data, setData, isPristine } = useModelEditor();\n const router = useRouter();\n const dialogs = useDialogs();\n\n // Add a class to <body> to trigger global styles while this component is active\n useEffect(() => {\n document.body.classList.add(\"overflow-hidden\");\n\n return () => {\n document.body.classList.remove(\"overflow-hidden\");\n };\n }, []);\n\n const isPristineRef = React.useRef(isPristine);\n isPristineRef.current = isPristine;\n\n useEffect(() => {\n return router.addTransitionGuard({\n guard: () => !isPristineRef.current,\n onBlocked: () => {\n dialogs.showDialog({\n title: \"Confirm Navigation\",\n content: prompt,\n acceptLabel: \"Yes!\",\n cancelLabel: \"No, stay here.\",\n onAccept: () => router.confirmTransition(),\n onClose: () => router.cancelTransition()\n });\n }\n });\n }, []);\n\n const [activeTab, setActiveTab] = useState<string>(\"edit\");\n const [isSidebarOpen, setIsSidebarOpen] = useState(true);\n const [activeView, setActiveView] = useState(\"compact\");\n\n const onChange = ({ fields, layout }: OnChangeParams) => {\n setData(data => ({ ...data, fields, layout }));\n };\n\n if (!data) {\n return <OverlayLoader text={\"Loading content model...\"} />;\n } else if (data.isBeingDeleted) {\n return <ModelIsBeingDeletedError model={data} />;\n }\n\n return (\n <div className={\"content-model-editor flex-1\"}>\n <Header activeTab={activeTab} onTabChange={setActiveTab} />\n <div className={\"w-full overflow-y-auto h-main-content\"}>\n <div className={\"flex h-full\"}>\n <div\n className={\n \"shrink-0 bg-neutral-base border-r border-neutral-dimmed overflow-hidden h-main-content relative transition-[width] duration-200 ease-in-out\"\n }\n style={{ width: isSidebarOpen ? 200 : 45 }}\n >\n {/* Expanded content */}\n <div\n className={\n \"transition-opacity duration-150 \" +\n (isSidebarOpen\n ? \"opacity-100 delay-75\"\n : \"opacity-0 pointer-events-none\")\n }\n >\n <FieldsSidebar\n onFieldDragStart={() => setActiveTab(\"edit\")}\n onCollapse={() => setIsSidebarOpen(false)}\n />\n </div>\n {/* Collapsed strip */}\n <div\n className={\n \"absolute inset-0 flex flex-col items-center pt-md gap-md transition-opacity duration-150 \" +\n (!isSidebarOpen\n ? \"opacity-100 delay-75\"\n : \"opacity-0 pointer-events-none\")\n }\n >\n <IconButton\n variant={\"ghost\"}\n size={\"xs\"}\n icon={<ExpandSidebarIcon />}\n onClick={() => setIsSidebarOpen(true)}\n />\n <span\n className={\n \"text-sm font-semibold text-neutral-strong [writing-mode:vertical-rl]\"\n }\n >\n Fields\n </span>\n </div>\n </div>\n <div\n className={\n \"flex-1 overflow-y-scroll h-main-content \" +\n (activeTab === \"edit\" ? \"fill-grid\" : \"bg-neutral-subtle\")\n }\n >\n <div\n className={\n \"sticky top-0 left-0 z-10 p-md flex items-center justify-between\"\n }\n >\n <div>\n {activeTab === \"edit\" && (\n <Text\n as=\"div\"\n size={\"sm\"}\n className={\"font-semibold text-neutral-primary\"}\n >\n Model editor\n </Text>\n )}\n {activeTab === \"preview\" && (\n <Tag content={\"Preview\"} variant={\"warning\"} />\n )}\n </div>\n <SegmentedControlPrimitive\n variant={\"light\"}\n value={activeView}\n onChange={setActiveView}\n items={VIEW_ITEMS}\n />\n </div>\n <div className={\"pb-lg\"}>\n <div\n className={\" transition-[width] duration-200 ease-in-out\"}\n style={{\n width: activeView === \"compact\" ? \"704px\" : \"90%\",\n marginLeft: \"auto\",\n marginRight: \"auto\"\n }}\n >\n {activeTab === \"edit\" && (\n <div className={\"relative\"} data-testid={\"cms.editor.tab.edit\"}>\n <FieldEditor\n fields={data.fields}\n layout={data.layout || []}\n onChange={onChange}\n />\n </div>\n )}\n {activeTab === \"preview\" && (\n <div\n className={\"px-xxl py-lg\"}\n data-testid={\"cms.editor.tab.preview\"}\n >\n <ContentEntryEditorWithConfig>\n <PreviewTab\n activeTab={true}\n onSwitchToEdit={() => setActiveTab(\"edit\")}\n />\n </ContentEntryEditorWithConfig>\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n <DragPreview />\n </div>\n </div>\n );\n});\n"],"names":["VIEW_ITEMS","ViewCompactAltIcon","ViewDayIcon","t","i18n","prompt","ContentModelEditor","makeDecoratable","data","setData","isPristine","useModelEditor","router","useRouter","dialogs","useDialogs","useEffect","document","isPristineRef","React","activeTab","setActiveTab","useState","isSidebarOpen","setIsSidebarOpen","activeView","setActiveView","onChange","fields","layout","OverlayLoader","ModelIsBeingDeletedError","Header","FieldsSidebar","IconButton","ExpandSidebarIcon","Text","Tag","SegmentedControlPrimitive","FieldEditor","ContentEntryEditorWithConfig","PreviewTab","DragPreview"],"mappings":";;;;;;;;;;;;;;;;AAUA,MAAMA,aAAa;IACf;QAAE,IAAI;QAAW,OAAO;QAAW,OAAO;QAAI,MAAM,WAAN,GAAM,oBAACC,qCAAkBA;IAAI;IAC3E;QAAE,IAAI;QAAQ,OAAO;QAAQ,OAAO;QAAI,MAAM,WAAN,GAAM,oBAACC,6BAAWA;IAAI;CACjE;AAUD,MAAMC,IAAIC,KAAK,EAAE,CAAC;AAElB,MAAMC,4BAASF,CAAC,CAAC,+FAA+F,CAAC;AAO1G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5B"}
|
|
@@ -4,7 +4,7 @@ interface EditFieldDialogProps {
|
|
|
4
4
|
onClose: () => void;
|
|
5
5
|
onSubmit: (data: CmsModelField) => void;
|
|
6
6
|
}
|
|
7
|
-
declare const EditFieldDialog: ((props: EditFieldDialogProps) => React.JSX.Element) & {
|
|
8
|
-
|
|
7
|
+
declare const EditFieldDialog: ((props: EditFieldDialogProps) => React.JSX.Element) & React.NamedExoticComponent<EditFieldDialogProps> & {
|
|
8
|
+
readonly type: (props: EditFieldDialogProps) => React.JSX.Element;
|
|
9
9
|
};
|
|
10
10
|
export default EditFieldDialog;
|
|
@@ -17,18 +17,18 @@ const allowedTitleFieldTypes = [
|
|
|
17
17
|
];
|
|
18
18
|
const isFieldAllowedToBeTitle = (model, field, parent)=>{
|
|
19
19
|
if (field.list || parent) return false;
|
|
20
|
-
if (false === allowedTitleFieldTypes.includes(field.type)) return false;
|
|
21
|
-
if (model.titleFieldId === field.fieldId) return false;
|
|
20
|
+
else if (false === allowedTitleFieldTypes.includes(field.type)) return false;
|
|
21
|
+
else if (model.titleFieldId === field.fieldId) return false;
|
|
22
22
|
return true;
|
|
23
23
|
};
|
|
24
24
|
const isFieldAllowedToBeDescription = (model, field, parent)=>{
|
|
25
25
|
if (field.list || parent) return false;
|
|
26
|
-
if (model.descriptionFieldId === field.fieldId) return false;
|
|
26
|
+
else if (model.descriptionFieldId === field.fieldId) return false;
|
|
27
27
|
return "long-text" === field.type;
|
|
28
28
|
};
|
|
29
29
|
const isFieldAllowedToBeImage = (model, field, parent)=>{
|
|
30
30
|
if (field.list || parent) return false;
|
|
31
|
-
if (model.imageFieldId === field.fieldId) return false;
|
|
31
|
+
else if (model.imageFieldId === field.fieldId) return false;
|
|
32
32
|
return "file" === field.type && field.settings?.imagesOnly;
|
|
33
33
|
};
|
|
34
34
|
const getFieldTypeName = (model, field, parent)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/components/FieldEditor/Field.js","sources":["../../../../src/admin/components/FieldEditor/Field.tsx"],"sourcesContent":["import React, { Fragment, useCallback, useMemo } from \"react\";\nimport capitalize from \"lodash/capitalize.js\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as TitleIcon } from \"@webiny/icons/title.svg\";\nimport { ReactComponent as MoreVerticalIcon } from \"@webiny/icons/more_vert.svg\";\nimport { plugins } from \"@webiny/plugins\";\nimport type { CmsModelField, CmsEditorFieldOptionPlugin, CmsModel } from \"~/types.js\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { useModelEditor } from \"~/admin/hooks/index.js\";\nimport { useModelFieldEditor } from \"~/admin/components/FieldEditor/useModelFieldEditor.js\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { Icon, IconButton, Text, DropdownMenu, Tag } from \"@webiny/admin-ui\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/components/editor/field\");\n\nconst allowedTitleFieldTypes: string[] = [\"text\", \"number\"];\n\nconst isFieldAllowedToBeTitle = (model: CmsModel, field: CmsModelField, parent?: CmsModelField) => {\n if (field.list || parent) {\n return false;\n } else if (allowedTitleFieldTypes.includes(field.type) === false) {\n return false;\n } else if (model.titleFieldId === field.fieldId) {\n return false;\n }\n return true;\n};\nconst isFieldAllowedToBeDescription = (\n model: CmsModel,\n field: CmsModelField,\n parent?: CmsModelField\n) => {\n if (field.list || parent) {\n return false;\n } else if (model.descriptionFieldId === field.fieldId) {\n return false;\n }\n return field.type === \"long-text\";\n};\n\nconst isFieldAllowedToBeImage = (model: CmsModel, field: CmsModelField, parent?: CmsModelField) => {\n if (field.list || parent) {\n return false;\n } else if (model.imageFieldId === field.fieldId) {\n return false;\n }\n return field.type === \"file\" && field.settings?.imagesOnly;\n};\n\nconst getFieldTypeName = (\n model: CmsModel,\n field: CmsModelField,\n parent?: CmsModelField\n): string | null => {\n if (parent) {\n return null;\n }\n const isTitleField = field.fieldId === model?.titleFieldId && !parent;\n const isDescriptionField = field.fieldId === model?.descriptionFieldId && !parent;\n const isImageField = field.fieldId === model?.imageFieldId && !parent;\n\n return (\n [\n isTitleField ? \"entry title\" : null,\n isDescriptionField ? \"entry description\" : null,\n isImageField ? \"entry image\" : null\n ]\n .filter(Boolean)\n .join(\"\") || null\n );\n};\n\nexport interface FieldProps {\n field: CmsModelField;\n onDelete: (field: CmsModelField) => void;\n onEdit: (field: CmsModelField) => void;\n parent?: CmsModelField;\n}\n\nconst Field = (props: FieldProps) => {\n const { field, onEdit, parent } = props;\n const { showSnackbar, showErrorSnackbar } = useSnackbar();\n const { setData: setModel, data: model } = useModelEditor();\n const { getFieldType, getFieldRenderer } = useModelFieldEditor();\n\n const removeFieldFromSelected = useCallback(async () => {\n if (model.titleFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n titleFieldId: null\n };\n });\n } else if (model.descriptionFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n descriptionFieldId: null\n };\n });\n } else if (model.imageFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n imageFieldId: null\n };\n });\n }\n }, [field.id, setModel, model]);\n\n const onDelete = useCallback(async () => {\n await removeFieldFromSelected();\n props.onDelete(field);\n return;\n }, [field.fieldId]);\n\n const setAsTitle = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, titleFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Title field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const setAsDescription = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, descriptionFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Description field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const setAsImage = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, imageFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Image field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const fieldType = getFieldType(field);\n const editorFieldOptionPlugins =\n plugins.byType<CmsEditorFieldOptionPlugin>(\"cms-editor-field-option\");\n\n if (!fieldType) {\n return null;\n }\n\n const renderer = getFieldRenderer(field.renderer.name);\n const canEdit = fieldType.canEditSettings !== false;\n\n const defaultInformationRenderer = useMemo(() => {\n const fieldTypeName = getFieldTypeName(model, field, parent);\n const fn = () => {\n if (!fieldTypeName) {\n return null;\n }\n return <Tag content={capitalize(fieldTypeName)} variant={\"neutral-light\"} />;\n };\n\n fn.displayName = \"FieldTypeRenderer\";\n\n return fn;\n }, [field.id]);\n\n const fieldInformationRenderer = fieldType.renderInfo;\n\n const info = [renderer?.name, field.list ? \"multiple values\" : null].filter(Boolean).join(\", \");\n\n return (\n <Fragment>\n <div className={\"flex items-center justify-between gap-sm-extra\"}>\n <div className={\"flex items-center gap-sm-extra flex-1 min-w-0\"}>\n <Icon\n icon={fieldType.icon}\n label={fieldType.label}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n <div className={\"flex flex-col gap-xxs min-w-0\"}>\n <span\n className={\n \"text-md font-semibold text-neutral-primary truncate leading-5\"\n }\n >\n {field.label}\n </span>\n <Text size={\"sm\"} className={\"text-neutral-muted truncate\"}>\n {fieldType.label}\n {info && <span> / {info}</span>}\n </Text>\n </div>\n </div>\n <div className={\"flex items-center justify-end gap-xs shrink-0\"}>\n {fieldInformationRenderer\n ? fieldInformationRenderer({ model, field })\n : defaultInformationRenderer()}\n <DropdownMenu\n trigger={\n <IconButton icon={<MoreVerticalIcon />} variant={\"ghost\"} size={\"sm\"} />\n }\n >\n {canEdit && (\n <DropdownMenu.Item\n onClick={() => onEdit(field)}\n text={t`Edit`}\n icon={\n <DropdownMenu.Item.Icon\n element={<EditIcon />}\n label={t`Edit field`}\n />\n }\n />\n )}\n {editorFieldOptionPlugins.map(pl =>\n React.cloneElement(pl.render(), { key: pl.name })\n )}\n {/* We only allow this action for top-level fields. */}\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeTitle(model, field, parent)}\n onClick={setAsTitle}\n text={t`Use as title`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as title`}\n />\n }\n />\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeDescription(model, field, parent)}\n onClick={setAsDescription}\n text={t`Use as description`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as description`}\n />\n }\n />\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeImage(model, field, parent)}\n onClick={setAsImage}\n text={t`Use as image`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as image`}\n />\n }\n />\n <DropdownMenu.Item\n onClick={onDelete}\n text={t`Delete`}\n icon={\n <DropdownMenu.Item.Icon\n element={<DeleteIcon />}\n label={t`Delete`}\n />\n }\n variant={\"destructive\"}\n />\n </DropdownMenu>\n </div>\n </div>\n {fieldType.renderEditor && (\n <div className={\"pt-md\"}>{fieldType.renderEditor({ field, model })}</div>\n )}\n </Fragment>\n );\n};\n\nexport default React.memo(Field);\n"],"names":["t","i18n","allowedTitleFieldTypes","isFieldAllowedToBeTitle","model","field","parent","isFieldAllowedToBeDescription","isFieldAllowedToBeImage","getFieldTypeName","isTitleField","isDescriptionField","isImageField","Boolean","Field","props","onEdit","showSnackbar","showErrorSnackbar","useSnackbar","setModel","useModelEditor","getFieldType","getFieldRenderer","useModelFieldEditor","removeFieldFromSelected","useCallback","data","onDelete","setAsTitle","response","setAsDescription","setAsImage","fieldType","editorFieldOptionPlugins","plugins","renderer","canEdit","defaultInformationRenderer","useMemo","fieldTypeName","fn","Tag","capitalize","fieldInformationRenderer","info","Fragment","Icon","Text","DropdownMenu","IconButton","MoreVerticalIcon","EditIcon","pl","React","TitleIcon","DeleteIcon"],"mappings":";;;;;;;;;;;;AAcA,MAAMA,IAAIC,KAAK,EA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CAAC,CAAC,YAAY,CAAC;QACrB,oBACI,oBAACiD,aAAa,IAAI,CAAC,IAAI;YACnB,uBAAS,oBAACM,0BAASA;YACnB,OAAOvD,CAAC,CAAC,YAAY,CAAC;;sBAIlC,oBAACiD,aAAa,IAAI;QACd,SAASrB;QACT,MAAM5B,CAAC,CAAC,MAAM,CAAC;QACf,oBACI,oBAACiD,aAAa,IAAI,CAAC,IAAI;YACnB,uBAAS,oBAACO,2BAAUA;YACpB,OAAOxD,CAAC,CAAC,MAAM,CAAC;;QAGxB,SAAS;WAKxBiC,UAAU,YAAY,IAAI,WAAJ,GACnB,oBAAC;QAAI,WAAW;OAAUA,UAAU,YAAY,CAAC;QAAE5B;QAAOD;IAAM;AAIhF;AAEA,wCAAekD,MAAAA,IAAU,CAACxC"}
|
|
1
|
+
{"version":3,"file":"admin/components/FieldEditor/Field.js","sources":["../../../../src/admin/components/FieldEditor/Field.tsx"],"sourcesContent":["import React, { Fragment, useCallback, useMemo } from \"react\";\nimport capitalize from \"lodash/capitalize.js\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as TitleIcon } from \"@webiny/icons/title.svg\";\nimport { ReactComponent as MoreVerticalIcon } from \"@webiny/icons/more_vert.svg\";\nimport { plugins } from \"@webiny/plugins\";\nimport type { CmsModelField, CmsEditorFieldOptionPlugin, CmsModel } from \"~/types.js\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { useModelEditor } from \"~/admin/hooks/index.js\";\nimport { useModelFieldEditor } from \"~/admin/components/FieldEditor/useModelFieldEditor.js\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { Icon, IconButton, Text, DropdownMenu, Tag } from \"@webiny/admin-ui\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/components/editor/field\");\n\nconst allowedTitleFieldTypes: string[] = [\"text\", \"number\"];\n\nconst isFieldAllowedToBeTitle = (model: CmsModel, field: CmsModelField, parent?: CmsModelField) => {\n if (field.list || parent) {\n return false;\n } else if (allowedTitleFieldTypes.includes(field.type) === false) {\n return false;\n } else if (model.titleFieldId === field.fieldId) {\n return false;\n }\n return true;\n};\nconst isFieldAllowedToBeDescription = (\n model: CmsModel,\n field: CmsModelField,\n parent?: CmsModelField\n) => {\n if (field.list || parent) {\n return false;\n } else if (model.descriptionFieldId === field.fieldId) {\n return false;\n }\n return field.type === \"long-text\";\n};\n\nconst isFieldAllowedToBeImage = (model: CmsModel, field: CmsModelField, parent?: CmsModelField) => {\n if (field.list || parent) {\n return false;\n } else if (model.imageFieldId === field.fieldId) {\n return false;\n }\n return field.type === \"file\" && field.settings?.imagesOnly;\n};\n\nconst getFieldTypeName = (\n model: CmsModel,\n field: CmsModelField,\n parent?: CmsModelField\n): string | null => {\n if (parent) {\n return null;\n }\n const isTitleField = field.fieldId === model?.titleFieldId && !parent;\n const isDescriptionField = field.fieldId === model?.descriptionFieldId && !parent;\n const isImageField = field.fieldId === model?.imageFieldId && !parent;\n\n return (\n [\n isTitleField ? \"entry title\" : null,\n isDescriptionField ? \"entry description\" : null,\n isImageField ? \"entry image\" : null\n ]\n .filter(Boolean)\n .join(\"\") || null\n );\n};\n\nexport interface FieldProps {\n field: CmsModelField;\n onDelete: (field: CmsModelField) => void;\n onEdit: (field: CmsModelField) => void;\n parent?: CmsModelField;\n}\n\nconst Field = (props: FieldProps) => {\n const { field, onEdit, parent } = props;\n const { showSnackbar, showErrorSnackbar } = useSnackbar();\n const { setData: setModel, data: model } = useModelEditor();\n const { getFieldType, getFieldRenderer } = useModelFieldEditor();\n\n const removeFieldFromSelected = useCallback(async () => {\n if (model.titleFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n titleFieldId: null\n };\n });\n } else if (model.descriptionFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n descriptionFieldId: null\n };\n });\n } else if (model.imageFieldId === field.fieldId) {\n await setModel(data => {\n return {\n ...data,\n imageFieldId: null\n };\n });\n }\n }, [field.id, setModel, model]);\n\n const onDelete = useCallback(async () => {\n await removeFieldFromSelected();\n props.onDelete(field);\n return;\n }, [field.fieldId]);\n\n const setAsTitle = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, titleFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Title field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const setAsDescription = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, descriptionFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Description field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const setAsImage = useCallback(async (): Promise<void> => {\n const response = await setModel(data => {\n return { ...data, imageFieldId: field.fieldId };\n });\n\n if (response && response.error) {\n return showErrorSnackbar(response.error.message);\n }\n\n showSnackbar(t`Image field set successfully.`);\n }, [field.fieldId, setModel]);\n\n const fieldType = getFieldType(field);\n const editorFieldOptionPlugins =\n plugins.byType<CmsEditorFieldOptionPlugin>(\"cms-editor-field-option\");\n\n if (!fieldType) {\n return null;\n }\n\n const renderer = getFieldRenderer(field.renderer.name);\n const canEdit = fieldType.canEditSettings !== false;\n\n const defaultInformationRenderer = useMemo(() => {\n const fieldTypeName = getFieldTypeName(model, field, parent);\n const fn = () => {\n if (!fieldTypeName) {\n return null;\n }\n return <Tag content={capitalize(fieldTypeName)} variant={\"neutral-light\"} />;\n };\n\n fn.displayName = \"FieldTypeRenderer\";\n\n return fn;\n }, [field.id]);\n\n const fieldInformationRenderer = fieldType.renderInfo;\n\n const info = [renderer?.name, field.list ? \"multiple values\" : null].filter(Boolean).join(\", \");\n\n return (\n <Fragment>\n <div className={\"flex items-center justify-between gap-sm-extra\"}>\n <div className={\"flex items-center gap-sm-extra flex-1 min-w-0\"}>\n <Icon\n icon={fieldType.icon}\n label={fieldType.label}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n <div className={\"flex flex-col gap-xxs min-w-0\"}>\n <span\n className={\n \"text-md font-semibold text-neutral-primary truncate leading-5\"\n }\n >\n {field.label}\n </span>\n <Text size={\"sm\"} className={\"text-neutral-muted truncate\"}>\n {fieldType.label}\n {info && <span> / {info}</span>}\n </Text>\n </div>\n </div>\n <div className={\"flex items-center justify-end gap-xs shrink-0\"}>\n {fieldInformationRenderer\n ? fieldInformationRenderer({ model, field })\n : defaultInformationRenderer()}\n <DropdownMenu\n trigger={\n <IconButton icon={<MoreVerticalIcon />} variant={\"ghost\"} size={\"sm\"} />\n }\n >\n {canEdit && (\n <DropdownMenu.Item\n onClick={() => onEdit(field)}\n text={t`Edit`}\n icon={\n <DropdownMenu.Item.Icon\n element={<EditIcon />}\n label={t`Edit field`}\n />\n }\n />\n )}\n {editorFieldOptionPlugins.map(pl =>\n React.cloneElement(pl.render(), { key: pl.name })\n )}\n {/* We only allow this action for top-level fields. */}\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeTitle(model, field, parent)}\n onClick={setAsTitle}\n text={t`Use as title`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as title`}\n />\n }\n />\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeDescription(model, field, parent)}\n onClick={setAsDescription}\n text={t`Use as description`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as description`}\n />\n }\n />\n <DropdownMenu.Item\n disabled={!isFieldAllowedToBeImage(model, field, parent)}\n onClick={setAsImage}\n text={t`Use as image`}\n icon={\n <DropdownMenu.Item.Icon\n element={<TitleIcon />}\n label={t`Use as image`}\n />\n }\n />\n <DropdownMenu.Item\n onClick={onDelete}\n text={t`Delete`}\n icon={\n <DropdownMenu.Item.Icon\n element={<DeleteIcon />}\n label={t`Delete`}\n />\n }\n variant={\"destructive\"}\n />\n </DropdownMenu>\n </div>\n </div>\n {fieldType.renderEditor && (\n <div className={\"pt-md\"}>{fieldType.renderEditor({ field, model })}</div>\n )}\n </Fragment>\n );\n};\n\nexport default React.memo(Field);\n"],"names":["t","i18n","allowedTitleFieldTypes","isFieldAllowedToBeTitle","model","field","parent","isFieldAllowedToBeDescription","isFieldAllowedToBeImage","getFieldTypeName","isTitleField","isDescriptionField","isImageField","Boolean","Field","props","onEdit","showSnackbar","showErrorSnackbar","useSnackbar","setModel","useModelEditor","getFieldType","getFieldRenderer","useModelFieldEditor","removeFieldFromSelected","useCallback","data","onDelete","setAsTitle","response","setAsDescription","setAsImage","fieldType","editorFieldOptionPlugins","plugins","renderer","canEdit","defaultInformationRenderer","useMemo","fieldTypeName","fn","Tag","capitalize","fieldInformationRenderer","info","Fragment","Icon","Text","DropdownMenu","IconButton","MoreVerticalIcon","EditIcon","pl","React","TitleIcon","DeleteIcon"],"mappings":";;;;;;;;;;;;AAcA,MAAMA,IAAIC,KAAK,EAAE,CAAC;AAElB,MAAMC,yBAAmC;IAAC;IAAQ;CAAS;AAE3D,MAAMC,0BAA0B,CAACC,OAAiBC,OAAsBC;IACpE,IAAID,MAAM,IAAI,IAAIC,QACd,OAAO;SACJ,IAAIJ,AAAgD,UAAhDA,uBAAuB,QAAQ,CAACG,MAAM,IAAI,GACjD,OAAO;SACJ,IAAID,MAAM,YAAY,KAAKC,MAAM,OAAO,EAC3C,OAAO;IAEX,OAAO;AACX;AACA,MAAME,gCAAgC,CAClCH,OACAC,OACAC;IAEA,IAAID,MAAM,IAAI,IAAIC,QACd,OAAO;SACJ,IAAIF,MAAM,kBAAkB,KAAKC,MAAM,OAAO,EACjD,OAAO;IAEX,OAAOA,AAAe,gBAAfA,MAAM,IAAI;AACrB;AAEA,MAAMG,0BAA0B,CAACJ,OAAiBC,OAAsBC;IACpE,IAAID,MAAM,IAAI,IAAIC,QACd,OAAO;SACJ,IAAIF,MAAM,YAAY,KAAKC,MAAM,OAAO,EAC3C,OAAO;IAEX,OAAOA,AAAe,WAAfA,MAAM,IAAI,IAAeA,MAAM,QAAQ,EAAE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AI;QACd,UAAU,CAAC9C,wBAAwBC,OAAOC,OAAOC;QACjD,SAASuB;QACT,MAAM7B,CAAC,CAAC,YAAY,CAAC;QACrB,oBACI,oBAACiD,aAAa,IAAI,CAAC,IAAI;YACnB,uBAAS,oBAACM,0BAASA;YACnB,OAAOvD,CAAC,CAAC,YAAY,CAAC;;sBAIlC,oBAACiD,aAAa,IAAI;QACd,UAAU,CAAC1C,8BAA8BH,OAAOC,OAAOC;QACvD,SAASyB;QACT,MAAM/B,CAAC,CAAC,kBAAkB,CAAC;QAC3B,oBACI,oBAACiD,aAAa,IAAI,CAAC,IAAI;YACnB,uBAAS,oBAACM,0BAASA;YACnB,OAAOvD,CAAC,CAAC,kBAAkB,CAAC;;sBAIxC,oBAACiD,aAAa,IAAI;QACd,UAAU,CAACzC,wBAAwBJ,OAAOC,OAAOC;QACjD,SAAS0B;QACT,MAAMhC,CAAC,CAAC,YAAY,CAAC;QACrB,oBACI,oBAACiD,aAAa,IAAI,CAAC,IAAI;YACnB,uBAAS,oBAACM,0BAASA;YACnB,OAAOvD,CAAC,CAAC,YAAY,CAAC;;sBAIlC,oBAACiD,aAAa,IAAI;QACd,SAASrB;QACT,MAAM5B,CAAC,CAAC,MAAM,CAAC;QACf,oBACI,oBAACiD,aAAa,IAAI,CAAC,IAAI;YACnB,uBAAS,oBAACO,2BAAUA;YACpB,OAAOxD,CAAC,CAAC,MAAM,CAAC;;QAGxB,SAAS;WAKxBiC,UAAU,YAAY,IAAI,WAAJ,GACnB,oBAAC;QAAI,WAAW;OAAUA,UAAU,YAAY,CAAC;QAAE5B;QAAOD;IAAM;AAIhF;AAEA,wCAAekD,MAAAA,IAAU,CAACxC"}
|
|
@@ -9,7 +9,6 @@ declare class CreateEntryGatewayImpl implements GatewayAbstraction.Interface {
|
|
|
9
9
|
private fields;
|
|
10
10
|
constructor(client: CmsGraphQLClient.Interface, preparer: EntryDataPreparer.Interface, fields: EntryGraphQLFields.Interface);
|
|
11
11
|
execute({ model, data, options }: ICreateEntryGatewayParams): Promise<CmsContentEntry<import("@webiny/app/types.js").GenericRecord>>;
|
|
12
|
-
private prepareData;
|
|
13
12
|
}
|
|
14
13
|
export declare const CreateEntryGateway: typeof CreateEntryGatewayImpl & {
|
|
15
14
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ICreateEntryGateway>;
|
|
@@ -23,7 +23,7 @@ class CreateEntryGatewayImpl {
|
|
|
23
23
|
this.fields = fields;
|
|
24
24
|
}
|
|
25
25
|
async execute({ model, data, options }) {
|
|
26
|
-
const preparedData = this.
|
|
26
|
+
const preparedData = this.preparer.prepareEntryData(data, model.fields);
|
|
27
27
|
const response = await this.client.execute({
|
|
28
28
|
query: createMutation(model, this.fields),
|
|
29
29
|
variables: {
|
|
@@ -35,14 +35,6 @@ class CreateEntryGatewayImpl {
|
|
|
35
35
|
if (!entry) throw new CmsEntryError(error, "Could not create entry");
|
|
36
36
|
return entry;
|
|
37
37
|
}
|
|
38
|
-
prepareData(data, fields) {
|
|
39
|
-
const values = data.values;
|
|
40
|
-
if (!values || "object" != typeof values) return data;
|
|
41
|
-
return {
|
|
42
|
-
...data,
|
|
43
|
-
values: this.preparer.prepare(values, fields)
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
38
|
}
|
|
47
39
|
const CreateEntryGateway_CreateEntryGateway = CreateEntryGateway.createImplementation({
|
|
48
40
|
implementation: CreateEntryGatewayImpl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/createEntry/CreateEntryGateway.js","sources":["../../../../src/features/contentEntry/createEntry/CreateEntryGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel
|
|
1
|
+
{"version":3,"file":"features/contentEntry/createEntry/CreateEntryGateway.js","sources":["../../../../src/features/contentEntry/createEntry/CreateEntryGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { EntryGraphQLFields } from \"../abstractions.js\";\nimport {\n CreateEntryGateway as GatewayAbstraction,\n type ICreateEntryGatewayParams\n} from \"./abstractions.js\";\nimport { EntryDataPreparer } from \"~/features/contentEntry/valueTransformers/EntryDataPreparer.js\";\nimport { CmsEntryError } from \"~/features/contentEntry/CmsEntryError.js\";\n\ninterface CreateEntryResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel, fields: EntryGraphQLFields.Interface) {\n return /* GraphQL */ `\n mutation CmsEntriesCreate${model.singularApiName}($data: ${model.singularApiName}Input!, $options: CreateCmsEntryOptionsInput) {\n content: create${model.singularApiName}(data: $data, options: $options) {\n data {\n ${fields.getSystemFields(model)}\n ${fields.getValuesBlock(model)}\n }\n error { message code data }\n }\n }\n `;\n}\n\nclass CreateEntryGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: CmsGraphQLClient.Interface,\n private preparer: EntryDataPreparer.Interface,\n private fields: EntryGraphQLFields.Interface\n ) {}\n\n async execute({ model, data, options }: ICreateEntryGatewayParams) {\n const preparedData = this.preparer.prepareEntryData(data, model.fields);\n\n const response = await this.client.execute<CreateEntryResponse>({\n query: createMutation(model, this.fields),\n variables: { data: preparedData, options }\n });\n\n const { data: entry, error } = response.content;\n\n if (!entry) {\n throw new CmsEntryError(error, \"Could not create entry\");\n }\n\n return entry;\n }\n}\n\nexport const CreateEntryGateway = GatewayAbstraction.createImplementation({\n implementation: CreateEntryGatewayImpl,\n dependencies: [CmsGraphQLClient, EntryDataPreparer, EntryGraphQLFields]\n});\n"],"names":["createMutation","model","fields","CreateEntryGatewayImpl","client","preparer","data","options","preparedData","response","entry","error","CmsEntryError","CreateEntryGateway","GatewayAbstraction","CmsGraphQLClient","EntryDataPreparer","EntryGraphQLFields"],"mappings":";;;;;AAiBA,SAASA,eAAeC,KAAe,EAAEC,MAAoC;IACzE,OAAqB,CAAC;iCACO,EAAED,MAAM,eAAe,CAAC,QAAQ,EAAEA,MAAM,eAAe,CAAC;2BAC9D,EAAEA,MAAM,eAAe,CAAC;;oBAE/B,EAAEC,OAAO,eAAe,CAACD,OAAO;oBAChC,EAAEC,OAAO,cAAc,CAACD,OAAO;;;;;IAK/C,CAAC;AACL;AAEA,MAAME;IACF,YACYC,MAAkC,EAClCC,QAAqC,EACrCH,MAAoC,CAC9C;aAHUE,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAH,MAAM,GAANA;IACT;IAEH,MAAM,QAAQ,EAAED,KAAK,EAAEK,IAAI,EAAEC,OAAO,EAA6B,EAAE;QAC/D,MAAMC,eAAe,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAACF,MAAML,MAAM,MAAM;QAEtE,MAAMQ,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsB;YAC5D,OAAOT,eAAeC,OAAO,IAAI,CAAC,MAAM;YACxC,WAAW;gBAAE,MAAMO;gBAAcD;YAAQ;QAC7C;QAEA,MAAM,EAAE,MAAMG,KAAK,EAAEC,KAAK,EAAE,GAAGF,SAAS,OAAO;QAE/C,IAAI,CAACC,OACD,MAAM,IAAIE,cAAcD,OAAO;QAGnC,OAAOD;IACX;AACJ;AAEO,MAAMG,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBX;IAChB,cAAc;QAACY;QAAkBC;QAAmBC;KAAmB;AAC3E"}
|
|
@@ -2,10 +2,12 @@ import { CmsGraphQLClient } from "../../../features/graphQLClient/abstractions.j
|
|
|
2
2
|
import type { CmsContentEntry } from "../../../types.js";
|
|
3
3
|
import { EntryGraphQLFields } from "../abstractions.js";
|
|
4
4
|
import { CreateRevisionFromGateway as GatewayAbstraction, type ICreateRevisionFromParams } from "./abstractions.js";
|
|
5
|
+
import { EntryDataPreparer } from "../../../features/contentEntry/valueTransformers/EntryDataPreparer.js";
|
|
5
6
|
declare class CreateRevisionFromGatewayImpl implements GatewayAbstraction.Interface {
|
|
6
7
|
private client;
|
|
8
|
+
private preparer;
|
|
7
9
|
private fields;
|
|
8
|
-
constructor(client: CmsGraphQLClient.Interface, fields: EntryGraphQLFields.Interface);
|
|
10
|
+
constructor(client: CmsGraphQLClient.Interface, preparer: EntryDataPreparer.Interface, fields: EntryGraphQLFields.Interface);
|
|
9
11
|
execute({ model, revisionId, data, options }: ICreateRevisionFromParams): Promise<CmsContentEntry<import("@webiny/app/types.js").GenericRecord>>;
|
|
10
12
|
}
|
|
11
13
|
export declare const CreateRevisionFromGateway: typeof CreateRevisionFromGatewayImpl & {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CmsGraphQLClient } from "../../graphQLClient/abstractions.js";
|
|
2
2
|
import { EntryGraphQLFields } from "../abstractions.js";
|
|
3
3
|
import { CreateRevisionFromGateway } from "./abstractions.js";
|
|
4
|
+
import { EntryDataPreparer } from "../valueTransformers/EntryDataPreparer.js";
|
|
4
5
|
import { CmsEntryError } from "../CmsEntryError.js";
|
|
5
6
|
function createMutation(model, fields) {
|
|
6
7
|
return `
|
|
@@ -15,16 +16,18 @@ function createMutation(model, fields) {
|
|
|
15
16
|
}`;
|
|
16
17
|
}
|
|
17
18
|
class CreateRevisionFromGatewayImpl {
|
|
18
|
-
constructor(client, fields){
|
|
19
|
+
constructor(client, preparer, fields){
|
|
19
20
|
this.client = client;
|
|
21
|
+
this.preparer = preparer;
|
|
20
22
|
this.fields = fields;
|
|
21
23
|
}
|
|
22
24
|
async execute({ model, revisionId, data, options }) {
|
|
25
|
+
const preparedData = data ? this.preparer.prepareEntryData(data, model.fields) : data;
|
|
23
26
|
const response = await this.client.execute({
|
|
24
27
|
query: createMutation(model, this.fields),
|
|
25
28
|
variables: {
|
|
26
29
|
revision: revisionId,
|
|
27
|
-
data,
|
|
30
|
+
data: preparedData,
|
|
28
31
|
options
|
|
29
32
|
}
|
|
30
33
|
});
|
|
@@ -37,6 +40,7 @@ const CreateRevisionFromGateway_CreateRevisionFromGateway = CreateRevisionFromGa
|
|
|
37
40
|
implementation: CreateRevisionFromGatewayImpl,
|
|
38
41
|
dependencies: [
|
|
39
42
|
CmsGraphQLClient,
|
|
43
|
+
EntryDataPreparer,
|
|
40
44
|
EntryGraphQLFields
|
|
41
45
|
]
|
|
42
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js","sources":["../../../../src/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { EntryGraphQLFields } from \"../abstractions.js\";\nimport {\n CreateRevisionFromGateway as GatewayAbstraction,\n type ICreateRevisionFromParams\n} from \"./abstractions.js\";\nimport { CmsEntryError } from \"~/features/contentEntry/CmsEntryError.js\";\n\ninterface CreateRevisionFromResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel, fields: EntryGraphQLFields.Interface) {\n return /* GraphQL */ `\n mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${model.singularApiName}Input, $options: CreateRevisionCmsEntryOptionsInput) {\n content: create${model.singularApiName}From(revision: $revision, data: $data, options: $options) {\n data {\n ${fields.getSystemFields(model)}\n ${fields.getValuesBlock(model)}\n }\n error { message code data }\n }\n }`;\n}\n\nclass CreateRevisionFromGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: CmsGraphQLClient.Interface,\n private fields: EntryGraphQLFields.Interface\n ) {}\n\n async execute({ model, revisionId, data, options }: ICreateRevisionFromParams) {\n const response = await this.client.execute<CreateRevisionFromResponse>({\n query: createMutation(model, this.fields),\n variables: { revision: revisionId, data, options }\n });\n\n const { data: entry, error } = response.content;\n\n if (!entry) {\n throw new CmsEntryError(error, \"Could not create revision\");\n }\n\n return entry;\n }\n}\n\nexport const CreateRevisionFromGateway = GatewayAbstraction.createImplementation({\n implementation: CreateRevisionFromGatewayImpl,\n dependencies: [CmsGraphQLClient, EntryGraphQLFields]\n});\n"],"names":["createMutation","model","fields","CreateRevisionFromGatewayImpl","client","revisionId","data","options","response","entry","error","CmsEntryError","CreateRevisionFromGateway","GatewayAbstraction","CmsGraphQLClient","EntryGraphQLFields"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js","sources":["../../../../src/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.ts"],"sourcesContent":["import { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport type { CmsContentEntry, CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { EntryGraphQLFields } from \"../abstractions.js\";\nimport {\n CreateRevisionFromGateway as GatewayAbstraction,\n type ICreateRevisionFromParams\n} from \"./abstractions.js\";\nimport { EntryDataPreparer } from \"~/features/contentEntry/valueTransformers/EntryDataPreparer.js\";\nimport { CmsEntryError } from \"~/features/contentEntry/CmsEntryError.js\";\n\ninterface CreateRevisionFromResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nfunction createMutation(model: CmsModel, fields: EntryGraphQLFields.Interface) {\n return /* GraphQL */ `\n mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${model.singularApiName}Input, $options: CreateRevisionCmsEntryOptionsInput) {\n content: create${model.singularApiName}From(revision: $revision, data: $data, options: $options) {\n data {\n ${fields.getSystemFields(model)}\n ${fields.getValuesBlock(model)}\n }\n error { message code data }\n }\n }`;\n}\n\nclass CreateRevisionFromGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: CmsGraphQLClient.Interface,\n private preparer: EntryDataPreparer.Interface,\n private fields: EntryGraphQLFields.Interface\n ) {}\n\n async execute({ model, revisionId, data, options }: ICreateRevisionFromParams) {\n const preparedData = data ? this.preparer.prepareEntryData(data, model.fields) : data;\n\n const response = await this.client.execute<CreateRevisionFromResponse>({\n query: createMutation(model, this.fields),\n variables: { revision: revisionId, data: preparedData, options }\n });\n\n const { data: entry, error } = response.content;\n\n if (!entry) {\n throw new CmsEntryError(error, \"Could not create revision\");\n }\n\n return entry;\n }\n}\n\nexport const CreateRevisionFromGateway = GatewayAbstraction.createImplementation({\n implementation: CreateRevisionFromGatewayImpl,\n dependencies: [CmsGraphQLClient, EntryDataPreparer, EntryGraphQLFields]\n});\n"],"names":["createMutation","model","fields","CreateRevisionFromGatewayImpl","client","preparer","revisionId","data","options","preparedData","response","entry","error","CmsEntryError","CreateRevisionFromGateway","GatewayAbstraction","CmsGraphQLClient","EntryDataPreparer","EntryGraphQLFields"],"mappings":";;;;;AAiBA,SAASA,eAAeC,KAAe,EAAEC,MAAoC;IACzE,OAAqB,CAAC;0BACA,EAAED,MAAM,eAAe,CAAC,4BAA4B,EAAEA,MAAM,eAAe,CAAC;2BAC3E,EAAEA,MAAM,eAAe,CAAC;;oBAE/B,EAAEC,OAAO,eAAe,CAACD,OAAO;oBAChC,EAAEC,OAAO,cAAc,CAACD,OAAO;;;;SAI1C,CAAC;AACV;AAEA,MAAME;IACF,YACYC,MAAkC,EAClCC,QAAqC,EACrCH,MAAoC,CAC9C;aAHUE,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAH,MAAM,GAANA;IACT;IAEH,MAAM,QAAQ,EAAED,KAAK,EAAEK,UAAU,EAAEC,IAAI,EAAEC,OAAO,EAA6B,EAAE;QAC3E,MAAMC,eAAeF,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAACA,MAAMN,MAAM,MAAM,IAAIM;QAEjF,MAAMG,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA6B;YACnE,OAAOV,eAAeC,OAAO,IAAI,CAAC,MAAM;YACxC,WAAW;gBAAE,UAAUK;gBAAY,MAAMG;gBAAcD;YAAQ;QACnE;QAEA,MAAM,EAAE,MAAMG,KAAK,EAAEC,KAAK,EAAE,GAAGF,SAAS,OAAO;QAE/C,IAAI,CAACC,OACD,MAAM,IAAIE,cAAcD,OAAO;QAGnC,OAAOD;IACX;AACJ;AAEO,MAAMG,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBZ;IAChB,cAAc;QAACa;QAAkBC;QAAmBC;KAAmB;AAC3E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { Container } from "@webiny/di";
|
|
3
|
+
import { CmsGraphQLClient } from "../graphQLClient/abstractions.js";
|
|
4
|
+
import { EntryGraphQLFields } from "./abstractions.js";
|
|
5
|
+
import { ValueTransformersFeature } from "./valueTransformers/feature.js";
|
|
6
|
+
import { formValues, graphQLInputValues, pageModel } from "./valueTransformers/entryValueFixtures.js";
|
|
7
|
+
import { CreateEntryGateway } from "./createEntry/abstractions.js";
|
|
8
|
+
import { CreateEntryGateway as CreateEntryGateway_js_CreateEntryGateway } from "./createEntry/CreateEntryGateway.js";
|
|
9
|
+
import { UpdateEntryGateway } from "./updateEntry/abstractions.js";
|
|
10
|
+
import { UpdateEntryGateway as UpdateEntryGateway_js_UpdateEntryGateway } from "./updateEntry/UpdateEntryGateway.js";
|
|
11
|
+
import { UpdateSingletonEntryGateway } from "./singletonEntry/abstractions.js";
|
|
12
|
+
import { UpdateSingletonEntryGateway as UpdateSingletonEntryGateway_js_UpdateSingletonEntryGateway } from "./singletonEntry/UpdateSingletonEntryGateway.js";
|
|
13
|
+
import { CreateRevisionFromGateway } from "./createRevisionFrom/abstractions.js";
|
|
14
|
+
import { CreateRevisionFromGateway as CreateRevisionFromGateway_js_CreateRevisionFromGateway } from "./createRevisionFrom/CreateRevisionFromGateway.js";
|
|
15
|
+
const ENTRY = {
|
|
16
|
+
id: "entry-1#0001",
|
|
17
|
+
entryId: "entry-1",
|
|
18
|
+
values: {}
|
|
19
|
+
};
|
|
20
|
+
const cases = [
|
|
21
|
+
{
|
|
22
|
+
name: "CreateEntryGateway",
|
|
23
|
+
register: (container)=>container.register(CreateEntryGateway_js_CreateEntryGateway),
|
|
24
|
+
execute: (container, data)=>container.resolve(CreateEntryGateway).execute({
|
|
25
|
+
model: pageModel,
|
|
26
|
+
data
|
|
27
|
+
})
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "UpdateEntryGateway",
|
|
31
|
+
register: (container)=>container.register(UpdateEntryGateway_js_UpdateEntryGateway),
|
|
32
|
+
execute: (container, data)=>container.resolve(UpdateEntryGateway).execute({
|
|
33
|
+
model: pageModel,
|
|
34
|
+
revisionId: ENTRY.id,
|
|
35
|
+
data
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "UpdateSingletonEntryGateway",
|
|
40
|
+
register: (container)=>container.register(UpdateSingletonEntryGateway_js_UpdateSingletonEntryGateway),
|
|
41
|
+
execute: (container, data)=>container.resolve(UpdateSingletonEntryGateway).execute({
|
|
42
|
+
model: pageModel,
|
|
43
|
+
data
|
|
44
|
+
})
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "CreateRevisionFromGateway",
|
|
48
|
+
register: (container)=>container.register(CreateRevisionFromGateway_js_CreateRevisionFromGateway),
|
|
49
|
+
execute: (container, data)=>container.resolve(CreateRevisionFromGateway).execute({
|
|
50
|
+
model: pageModel,
|
|
51
|
+
revisionId: ENTRY.id,
|
|
52
|
+
data
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
describe.each(cases)("$name", ({ register, execute })=>{
|
|
57
|
+
let container;
|
|
58
|
+
let client;
|
|
59
|
+
beforeEach(()=>{
|
|
60
|
+
container = new Container();
|
|
61
|
+
client = {
|
|
62
|
+
execute: vi.fn().mockResolvedValue({
|
|
63
|
+
content: {
|
|
64
|
+
data: ENTRY,
|
|
65
|
+
error: null
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
};
|
|
69
|
+
ValueTransformersFeature.register(container);
|
|
70
|
+
container.registerInstance(CmsGraphQLClient, client);
|
|
71
|
+
container.registerInstance(EntryGraphQLFields, {
|
|
72
|
+
getSystemFields: ()=>"id",
|
|
73
|
+
getValuesBlock: ()=>""
|
|
74
|
+
});
|
|
75
|
+
register(container);
|
|
76
|
+
});
|
|
77
|
+
it("should send dynamic zone values in the GraphQL input shape", async ()=>{
|
|
78
|
+
await execute(container, {
|
|
79
|
+
values: formValues
|
|
80
|
+
});
|
|
81
|
+
expect(client.execute).toHaveBeenCalledTimes(1);
|
|
82
|
+
const { variables } = client.execute.mock.calls[0][0];
|
|
83
|
+
expect(variables.data).toEqual({
|
|
84
|
+
values: graphQLInputValues
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
it("should keep keys other than values in the payload", async ()=>{
|
|
88
|
+
await execute(container, {
|
|
89
|
+
values: formValues,
|
|
90
|
+
wbyAco_location: {
|
|
91
|
+
folderId: "root"
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const { variables } = client.execute.mock.calls[0][0];
|
|
95
|
+
expect(variables.data.wbyAco_location).toEqual({
|
|
96
|
+
folderId: "root"
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
it("should return the entry from the API response", async ()=>{
|
|
100
|
+
await expect(execute(container, {
|
|
101
|
+
values: formValues
|
|
102
|
+
})).resolves.toEqual(ENTRY);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=entryValueGateways.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/contentEntry/entryValueGateways.test.js","sources":["../../../src/features/contentEntry/entryValueGateways.test.ts"],"sourcesContent":["import { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport type { CmsContentEntry } from \"~/types.js\";\nimport { CmsGraphQLClient } from \"~/features/graphQLClient/abstractions.js\";\nimport { EntryGraphQLFields } from \"./abstractions.js\";\nimport { ValueTransformersFeature } from \"./valueTransformers/feature.js\";\nimport {\n formValues,\n graphQLInputValues,\n pageModel\n} from \"./valueTransformers/entryValueFixtures.js\";\nimport { CreateEntryGateway as CreateEntryGatewayAbstraction } from \"./createEntry/abstractions.js\";\nimport { CreateEntryGateway } from \"./createEntry/CreateEntryGateway.js\";\nimport { UpdateEntryGateway as UpdateEntryGatewayAbstraction } from \"./updateEntry/abstractions.js\";\nimport { UpdateEntryGateway } from \"./updateEntry/UpdateEntryGateway.js\";\nimport { UpdateSingletonEntryGateway as UpdateSingletonEntryGatewayAbstraction } from \"./singletonEntry/abstractions.js\";\nimport { UpdateSingletonEntryGateway } from \"./singletonEntry/UpdateSingletonEntryGateway.js\";\nimport { CreateRevisionFromGateway as CreateRevisionFromGatewayAbstraction } from \"./createRevisionFrom/abstractions.js\";\nimport { CreateRevisionFromGateway } from \"./createRevisionFrom/CreateRevisionFromGateway.js\";\n\n/**\n * Every gateway that sends entry values to the API must convert them from the form\n * shape into the GraphQL input shape. A gateway that skips this step breaks saving\n * entries with dynamic zone fields (\"Field ... is not defined by type <Model>_<Field>Input\").\n *\n * When you add a new gateway that sends entry values, add it to this list.\n */\n\nconst ENTRY = { id: \"entry-1#0001\", entryId: \"entry-1\", values: {} } as unknown as CmsContentEntry;\n\ninterface GatewayCase {\n name: string;\n register: (container: Container) => void;\n execute: (container: Container, data: Record<string, unknown>) => Promise<unknown>;\n}\n\nconst cases: GatewayCase[] = [\n {\n name: \"CreateEntryGateway\",\n register: container => container.register(CreateEntryGateway),\n execute: (container, data) =>\n container.resolve(CreateEntryGatewayAbstraction).execute({ model: pageModel, data })\n },\n {\n name: \"UpdateEntryGateway\",\n register: container => container.register(UpdateEntryGateway),\n execute: (container, data) =>\n container\n .resolve(UpdateEntryGatewayAbstraction)\n .execute({ model: pageModel, revisionId: ENTRY.id, data })\n },\n {\n name: \"UpdateSingletonEntryGateway\",\n register: container => container.register(UpdateSingletonEntryGateway),\n execute: (container, data) =>\n container\n .resolve(UpdateSingletonEntryGatewayAbstraction)\n .execute({ model: pageModel, data })\n },\n {\n name: \"CreateRevisionFromGateway\",\n register: container => container.register(CreateRevisionFromGateway),\n execute: (container, data) =>\n container\n .resolve(CreateRevisionFromGatewayAbstraction)\n .execute({ model: pageModel, revisionId: ENTRY.id, data })\n }\n];\n\ndescribe.each(cases)(\"$name\", ({ register, execute }) => {\n let container: Container;\n let client: { execute: ReturnType<typeof vi.fn> };\n\n beforeEach(() => {\n container = new Container();\n client = {\n execute: vi.fn().mockResolvedValue({ content: { data: ENTRY, error: null } })\n };\n\n ValueTransformersFeature.register(container);\n container.registerInstance(\n CmsGraphQLClient,\n client as unknown as CmsGraphQLClient.Interface\n );\n container.registerInstance(EntryGraphQLFields, {\n getSystemFields: () => \"id\",\n getValuesBlock: () => \"\"\n } as unknown as EntryGraphQLFields.Interface);\n register(container);\n });\n\n it(\"should send dynamic zone values in the GraphQL input shape\", async () => {\n await execute(container, { values: formValues });\n\n expect(client.execute).toHaveBeenCalledTimes(1);\n const { variables } = client.execute.mock.calls[0][0];\n expect(variables.data).toEqual({ values: graphQLInputValues });\n });\n\n it(\"should keep keys other than values in the payload\", async () => {\n await execute(container, {\n values: formValues,\n wbyAco_location: { folderId: \"root\" }\n });\n\n const { variables } = client.execute.mock.calls[0][0];\n expect(variables.data.wbyAco_location).toEqual({ folderId: \"root\" });\n });\n\n it(\"should return the entry from the API response\", async () => {\n await expect(execute(container, { values: formValues })).resolves.toEqual(ENTRY);\n });\n});\n"],"names":["ENTRY","cases","container","CreateEntryGateway","data","CreateEntryGatewayAbstraction","pageModel","UpdateEntryGateway","UpdateEntryGatewayAbstraction","UpdateSingletonEntryGateway","UpdateSingletonEntryGatewayAbstraction","CreateRevisionFromGateway","CreateRevisionFromGatewayAbstraction","describe","register","execute","client","beforeEach","Container","vi","ValueTransformersFeature","CmsGraphQLClient","EntryGraphQLFields","it","formValues","expect","variables","graphQLInputValues"],"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