@webiny/app-headless-cms 6.5.0-beta.4 → 6.5.0-beta.5
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/mappers/DynamicZoneFieldMapper.js +1 -0
- package/features/formModel/mappers/DynamicZoneFieldMapper.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":"presentation/contentModels/components/ContentModelsDataList.js","sources":["../../../../src/presentation/contentModels/components/ContentModelsDataList.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport orderBy from \"lodash/orderBy.js\";\nimport { TimeAgo } from \"@webiny/admin-ui\";\nimport { SearchUI, useRouter, useSnackbar } from \"@webiny/app-admin\";\nimport { ReactComponent as AddIcon } from \"@webiny/icons/add.svg\";\nimport {\n ReactComponent as DownloadFileIcon,\n ReactComponent as ExportIcon\n} from \"@webiny/icons/file_download.svg\";\nimport { ReactComponent as UploadFileIcon } from \"@webiny/icons/file_upload.svg\";\nimport { ReactComponent as ListIcon } from \"@webiny/icons/list.svg\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as MoreVertIcon } from \"@webiny/icons/more_vert.svg\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as CloneIcon } from \"@webiny/icons/flip_to_front.svg\";\nimport { DataList, DataListModal, List } from \"@webiny/admin-ui\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport type { CmsModel } from \"~/types.js\";\nimport { usePermission } from \"~/admin/hooks/usePermission.js\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport type { IconProp } from \"@fortawesome/fontawesome-svg-core\";\nimport { ModelIsBeingDeleted } from \"./fullDelete/ModelIsBeingDeleted.js\";\nimport { FullyDeleteModelDialog } from \"./fullDelete/FullyDeleteModelDialog.js\";\nimport { Button, DropdownMenu, Icon, IconButton, Select, Tooltip } from \"@webiny/admin-ui\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/app-headless-cms-common\";\nimport { Routes } from \"~/routes.js\";\nimport { normalizeIcon } from \"~/utils/normalizeIcon.js\";\nimport { useContentModelsPresenter } from \"../useContentModelsPresenter.js\";\nimport { download } from \"../utils/download.js\";\n\nconst t = i18n.namespace(\"FormsApp.ContentModelsDataList\");\n\nconst SORTERS = [\n { label: \"Newest to oldest\", sorter: \"savedOn_DESC\" },\n { label: \"Oldest to newest\", sorter: \"savedOn_ASC\" },\n { label: \"Name A-Z\", sorter: \"name_ASC\" },\n { label: \"Name Z-A\", sorter: \"name_DESC\" }\n];\n\nconst deserializeSorters = (data: string): [string, \"asc\" | \"desc\"] => {\n const [field, order] = data.split(\"_\");\n return [field, order.toLowerCase() === \"asc\" ? \"asc\" : \"desc\"];\n};\n\ninterface ContentModelsDataListProps {\n canCreate: boolean;\n onCreate: () => void;\n onClone: (contentModel: CmsModel) => void;\n showImportModelModal: () => void;\n}\n\ninterface IconProps {\n model: Pick<CmsModel, \"icon\">;\n}\n\nconst DisplayIcon = ({ model }: IconProps) => {\n if (!model.icon) {\n return null;\n }\n return (\n <div className={\"text-neutral-muted\"}>\n <Icon\n size={\"lg\"}\n color={\"inherit\"}\n label={\"Content model icon\"}\n icon={<FontAwesomeIcon icon={normalizeIcon(model.icon) as IconProp} />}\n />\n </div>\n );\n};\n\nconst ContentModelsDataList = observer(\n ({ canCreate, onCreate, onClone, showImportModelModal }: ContentModelsDataListProps) => {\n const presenter = useContentModelsPresenter();\n const { goToRoute } = useRouter();\n const { showSnackbar } = useSnackbar();\n const { canDelete, canEdit } = usePermission();\n\n const [filter, setFilter] = useState(\"\");\n const [sort, setSort] = useState(SORTERS[0].sorter);\n const [modelToBeDeleted, setModelToBeDeleted] = useState<CmsModel | null>(null);\n\n const models = presenter.vm.models;\n const loading = presenter.vm.loading;\n\n const filteredData = useMemo(() => {\n if (filter === \"\") {\n return models;\n }\n const lc = filter.toLowerCase();\n return models.filter((m: CmsModel) => m.name.toLowerCase().includes(lc));\n }, [models, filter]);\n\n const sortedData = useMemo(() => {\n if (!sort) {\n return filteredData;\n }\n const [key, order] = deserializeSorters(sort);\n return orderBy(filteredData, [key], [order]);\n }, [filteredData, sort]);\n\n const editRecord = (contentModel: CmsModel): void => {\n goToRoute(Routes.ContentModels.Editor, { modelId: contentModel.modelId });\n };\n\n const viewContentEntries = useCallback((contentModel: Pick<CmsModel, \"modelId\">) => {\n return () => {\n goToRoute(Routes.ContentEntries.List, { modelId: contentModel.modelId });\n };\n }, []);\n\n const handleModelsExport = useCallback(\n (modelIds?: string[]) => {\n (async () => {\n try {\n const data = await presenter.exportModels(modelIds);\n if (!data || !data.models || data.models.length === 0) {\n showSnackbar(\"No data returned from the export query.\");\n return;\n }\n download(data);\n } catch (e: any) {\n showSnackbar(e.message);\n }\n })();\n },\n [presenter]\n );\n\n const handleModelExport = useCallback(\n (model: CmsModel) => {\n return () => {\n handleModelsExport([model.modelId]);\n };\n },\n [handleModelsExport]\n );\n\n return (\n <>\n <DataList\n loading={loading}\n data={sortedData}\n title={t`Content Models`}\n actions={\n <div className={\"flex items-center justify-end gap-xs\"}>\n <Tooltip\n content={\"Export all models\"}\n trigger={\n <IconButton\n icon={<DownloadFileIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n onClick={() => handleModelsExport()}\n />\n }\n />\n <Tooltip\n content={\"Import models\"}\n trigger={\n <IconButton\n icon={<UploadFileIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n onClick={() => showImportModelModal()}\n />\n }\n />\n {canCreate ? (\n <Button\n data-testid=\"new-record-button\"\n onClick={onCreate}\n text={t`New`}\n icon={<AddIcon />}\n size={\"sm\"}\n className={\"ml-xs\"}\n />\n ) : null}\n </div>\n }\n search={\n <SearchUI\n value={filter}\n onChange={setFilter}\n inputPlaceholder={t`Search content model...`}\n />\n }\n modalOverlay={\n <DataListModal.Content>\n <Select\n value={sort}\n onChange={setSort}\n label={t`Sort by`}\n options={SORTERS.map(({ label, sorter: value }) => ({\n label,\n value\n }))}\n />\n </DataListModal.Content>\n }\n modalOverlayAction={\n <DataListModal.Trigger data-testid={\"default-data-list.filter\"} />\n }\n refresh={null}\n >\n {({ data = [] }: { data: CmsModel[] }) => {\n return (\n <List data-testid=\"default-data-list\">\n {data.map(contentModel => {\n const disableViewContent = contentModel.fields.length === 0;\n const getMessage = () => {\n if (disableViewContent) {\n return \"To view the entries, you first need to add a field and save the model\";\n }\n if (contentModel.tags.includes(CMS_MODEL_SINGLETON_TAG)) {\n return \"View\";\n }\n return \"View entries\";\n };\n\n const canDeleteModel = canDelete(\n contentModel,\n \"cms.contentModel\"\n );\n const canEditModel = canEdit(contentModel, \"cms.contentModel\");\n\n return (\n <List.Item\n key={contentModel.modelId}\n className={\"group/item\"}\n icon={<DisplayIcon model={contentModel} />}\n title={contentModel.name}\n description={t`Last modified: {time}.`({\n time: contentModel.savedOn ? (\n <TimeAgo datetime={contentModel.savedOn} />\n ) : (\n \"N/A\"\n )\n })}\n actions={\n <>\n <ModelIsBeingDeleted model={contentModel}>\n <span\n className={\n \"invisible group-hover/item:visible\"\n }\n >\n <Tooltip\n side={\"top\"}\n content={getMessage()}\n trigger={\n <Button\n text={\"View entries\"}\n icon={<ListIcon />}\n variant={\"secondary\"}\n size={\"sm\"}\n data-testid={\n \"cms-view-content-model-button\"\n }\n onClick={viewContentEntries(\n contentModel\n )}\n disabled={\n disableViewContent\n }\n />\n }\n />\n </span>\n\n {canEditModel && (\n <span\n className={\n \"invisible group-hover/item:visible\"\n }\n >\n <Tooltip\n side={\"top\"}\n content={\n contentModel.plugin\n ? t`Content model is registered via a plugin.`\n : t`Edit content model`\n }\n trigger={\n <Button\n text={\"Edit\"}\n icon={<EditIcon />}\n variant={\"secondary\"}\n size={\"sm\"}\n disabled={\n contentModel.plugin\n }\n onClick={() =>\n editRecord(\n contentModel\n )\n }\n data-testid={\n \"cms-edit-content-model-button\"\n }\n />\n }\n />\n </span>\n )}\n\n <DropdownMenu\n trigger={\n <IconButton\n icon={<MoreVertIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n />\n }\n >\n {canEditModel && (\n <DropdownMenu.Item\n text={\"Clone\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Clone\"}\n element={<CloneIcon />}\n />\n }\n data-testid={\n \"cms-clone-content-model-button\"\n }\n onClick={() =>\n onClone(contentModel)\n }\n />\n )}\n\n <DropdownMenu.Item\n text={\"Export\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Export\"}\n element={<ExportIcon />}\n />\n }\n data-testid={\n \"cms-export-content-model-button\"\n }\n onClick={handleModelExport(\n contentModel\n )}\n />\n\n {canDeleteModel && (\n <DropdownMenu.Item\n text={\"Delete\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Delete\"}\n element={<DeleteIcon />}\n />\n }\n onClick={() => {\n setModelToBeDeleted(\n contentModel\n );\n }}\n data-testid={\n \"cms-delete-content-model-button\"\n }\n className={\n \"text-destructive-primary! [&_svg]:fill-destructive\"\n }\n />\n )}\n </DropdownMenu>\n </ModelIsBeingDeleted>\n </>\n }\n />\n );\n })}\n </List>\n );\n }}\n </DataList>\n {modelToBeDeleted ? (\n <FullyDeleteModelDialog\n model={modelToBeDeleted}\n onClose={() => {\n setModelToBeDeleted(null);\n }}\n />\n ) : null}\n </>\n );\n }\n);\n\nexport default ContentModelsDataList;\n"],"names":["t","i18n","SORTERS","deserializeSorters","data","field","order","DisplayIcon","model","Icon","FontAwesomeIcon","normalizeIcon","ContentModelsDataList","observer","canCreate","onCreate","onClone","showImportModelModal","presenter","useContentModelsPresenter","goToRoute","useRouter","showSnackbar","useSnackbar","canDelete","canEdit","usePermission","filter","setFilter","useState","sort","setSort","modelToBeDeleted","setModelToBeDeleted","models","loading","filteredData","useMemo","lc","m","sortedData","key","orderBy","editRecord","contentModel","Routes","viewContentEntries","useCallback","handleModelsExport","modelIds","download","e","handleModelExport","DataList","Tooltip","IconButton","DownloadFileIcon","UploadFileIcon","Button","AddIcon","SearchUI","DataListModal","Select","label","value","List","disableViewContent","getMessage","CMS_MODEL_SINGLETON_TAG","canDeleteModel","canEditModel","TimeAgo","ModelIsBeingDeleted","ListIcon","EditIcon","DropdownMenu","MoreVertIcon","CloneIcon","ExportIcon","DeleteIcon","FullyDeleteModelDialog"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAMA,IAAIC,KAAK,SAAS,CAAC;AAEzB,MAAMC,UAAU;IACZ;QAAE,OAAO;QAAoB,QAAQ;IAAe;IACpD;QAAE,OAAO;QAAoB,QAAQ;IAAc;IACnD;QAAE,OAAO;QAAY,QAAQ;IAAW;IACxC;QAAE,OAAO;QAAY,QAAQ;IAAY;CAC5C;AAED,MAAMC,qBAAqB,CAACC;IACxB,MAAM,CAACC,OAAOC,MAAM,GAAGF,KAAK,KAAK,CAAC;IAClC,OAAO;QAACC;QAA+B,UAAxBC,MAAM,WAAW,KAAe,QAAQ;KAAO;AAClE;AAaA,MAAMC,cAAc,CAAC,EAAEC,KAAK,EAAa;IACrC,IAAI,CAACA,MAAM,IAAI,EACX,OAAO;IAEX,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACC,MAAIA;QACD,MAAM;QACN,OAAO;QACP,OAAO;QACP,oBAAM,oBAACC,iBAAeA;YAAC,MAA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C,CAAC,CAAC,yCAAyC,CAAC,GAC5CA,CAAC,CAAC,kBAAkB,CAAC;oBAE/B,uBACI,oBAAC0D,QAAMA;wBACH,MAAM;wBACN,oBAAM,oBAACgB,yBAAQA;wBACf,SAAS;wBACT,MAAM;wBACN,UACI9B,aAAa,MAAM;wBAEvB,SAAS,IACLD,WACIC;wBAGR,eACI;;mCAQxB,oBAAC+B,cAAYA;oBACT,uBACI,oBAACpB,YAAUA;wBACP,oBAAM,oBAACqB,8BAAYA;wBACnB,MAAM;wBACN,SAAS;;mBAIhBN,gBAAgB,WAAhBA,GACG,oBAACK,aAAa,IAAI;oBACd,MAAM;oBACN,oBACI,oBAACA,aAAa,IAAI,CAAC,IAAI;wBACnB,OAAO;wBACP,uBAAS,oBAACE,kCAASA;;oBAG3B,eACI;oBAEJ,SAAS,IACL7D,QAAQ4B;kCAKpB,oBAAC+B,aAAa,IAAI;oBACd,MAAM;oBACN,oBACI,oBAACA,aAAa,IAAI,CAAC,IAAI;wBACnB,OAAO;wBACP,uBAAS,oBAACG,kCAAUA;;oBAG5B,eACI;oBAEJ,SAAS1B,kBACLR;oBAIPyB,kBAAkB,WAAlBA,GACG,oBAACM,aAAa,IAAI;oBACd,MAAM;oBACN,oBACI,oBAACA,aAAa,IAAI,CAAC,IAAI;wBACnB,OAAO;wBACP,uBAAS,oBAACI,2BAAUA;;oBAG5B,SAAS;wBACL9C,oBACIW;oBAER;oBACA,eACI;oBAEJ,WACI;;;QAUxC,MAKfZ,mBAAmB,WAAnBA,GACG,oBAACgD,wBAAsBA;QACnB,OAAOhD;QACP,SAAS;YACLC,oBAAoB;QACxB;SAEJ;AAGhB;AAGJ,yCAAerB"}
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/components/ContentModelsDataList.js","sources":["../../../../src/presentation/contentModels/components/ContentModelsDataList.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport orderBy from \"lodash/orderBy.js\";\nimport { TimeAgo } from \"@webiny/admin-ui\";\nimport { SearchUI, useRouter, useSnackbar } from \"@webiny/app-admin\";\nimport { ReactComponent as AddIcon } from \"@webiny/icons/add.svg\";\nimport {\n ReactComponent as DownloadFileIcon,\n ReactComponent as ExportIcon\n} from \"@webiny/icons/file_download.svg\";\nimport { ReactComponent as UploadFileIcon } from \"@webiny/icons/file_upload.svg\";\nimport { ReactComponent as ListIcon } from \"@webiny/icons/list.svg\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as MoreVertIcon } from \"@webiny/icons/more_vert.svg\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as CloneIcon } from \"@webiny/icons/flip_to_front.svg\";\nimport { DataList, DataListModal, List } from \"@webiny/admin-ui\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport type { CmsModel } from \"~/types.js\";\nimport { usePermission } from \"~/admin/hooks/usePermission.js\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport { ModelIsBeingDeleted } from \"./fullDelete/ModelIsBeingDeleted.js\";\nimport { FullyDeleteModelDialog } from \"./fullDelete/FullyDeleteModelDialog.js\";\nimport { Button, DropdownMenu, Icon, IconButton, Select, Tooltip } from \"@webiny/admin-ui\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/app-headless-cms-common\";\nimport { Routes } from \"~/routes.js\";\nimport { normalizeIcon } from \"~/utils/normalizeIcon.js\";\nimport { useContentModelsPresenter } from \"../useContentModelsPresenter.js\";\nimport { download } from \"../utils/download.js\";\n\nconst t = i18n.namespace(\"FormsApp.ContentModelsDataList\");\n\nconst SORTERS = [\n { label: \"Newest to oldest\", sorter: \"savedOn_DESC\" },\n { label: \"Oldest to newest\", sorter: \"savedOn_ASC\" },\n { label: \"Name A-Z\", sorter: \"name_ASC\" },\n { label: \"Name Z-A\", sorter: \"name_DESC\" }\n];\n\nconst deserializeSorters = (data: string): [string, \"asc\" | \"desc\"] => {\n const [field, order] = data.split(\"_\");\n return [field, order.toLowerCase() === \"asc\" ? \"asc\" : \"desc\"];\n};\n\ninterface ContentModelsDataListProps {\n canCreate: boolean;\n onCreate: () => void;\n onClone: (contentModel: CmsModel) => void;\n showImportModelModal: () => void;\n}\n\ninterface IconProps {\n model: Pick<CmsModel, \"icon\">;\n}\n\nconst DisplayIcon = ({ model }: IconProps) => {\n const icon = normalizeIcon(model.icon);\n if (!icon) {\n return null;\n }\n return (\n <div className={\"text-neutral-muted\"}>\n <Icon\n size={\"lg\"}\n color={\"inherit\"}\n label={\"Content model icon\"}\n icon={<FontAwesomeIcon icon={icon} />}\n />\n </div>\n );\n};\n\nconst ContentModelsDataList = observer(\n ({ canCreate, onCreate, onClone, showImportModelModal }: ContentModelsDataListProps) => {\n const presenter = useContentModelsPresenter();\n const { goToRoute } = useRouter();\n const { showSnackbar } = useSnackbar();\n const { canDelete, canEdit } = usePermission();\n\n const [filter, setFilter] = useState(\"\");\n const [sort, setSort] = useState(SORTERS[0].sorter);\n const [modelToBeDeleted, setModelToBeDeleted] = useState<CmsModel | null>(null);\n\n const models = presenter.vm.models;\n const loading = presenter.vm.loading;\n\n const filteredData = useMemo(() => {\n if (filter === \"\") {\n return models;\n }\n const lc = filter.toLowerCase();\n return models.filter((m: CmsModel) => m.name.toLowerCase().includes(lc));\n }, [models, filter]);\n\n const sortedData = useMemo(() => {\n if (!sort) {\n return filteredData;\n }\n const [key, order] = deserializeSorters(sort);\n return orderBy(filteredData, [key], [order]);\n }, [filteredData, sort]);\n\n const editRecord = (contentModel: CmsModel): void => {\n goToRoute(Routes.ContentModels.Editor, { modelId: contentModel.modelId });\n };\n\n const viewContentEntries = useCallback((contentModel: Pick<CmsModel, \"modelId\">) => {\n return () => {\n goToRoute(Routes.ContentEntries.List, { modelId: contentModel.modelId });\n };\n }, []);\n\n const handleModelsExport = useCallback(\n (modelIds?: string[]) => {\n (async () => {\n try {\n const data = await presenter.exportModels(modelIds);\n if (!data?.models?.length) {\n showSnackbar(\"No data returned from the export query.\");\n return;\n }\n download(data);\n } catch (ex: any) {\n showSnackbar(ex.message);\n }\n })();\n },\n [presenter]\n );\n\n const handleModelExport = useCallback(\n (model: CmsModel) => {\n return () => {\n handleModelsExport([model.modelId]);\n };\n },\n [handleModelsExport]\n );\n\n return (\n <>\n <DataList\n loading={loading}\n data={sortedData}\n title={t`Content Models`}\n actions={\n <div className={\"flex items-center justify-end gap-xs\"}>\n <Tooltip\n content={\"Export all models\"}\n trigger={\n <IconButton\n icon={<DownloadFileIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n onClick={() => handleModelsExport()}\n />\n }\n />\n <Tooltip\n content={\"Import models\"}\n trigger={\n <IconButton\n icon={<UploadFileIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n onClick={() => showImportModelModal()}\n />\n }\n />\n {canCreate ? (\n <Button\n data-testid=\"new-record-button\"\n onClick={onCreate}\n text={t`New`}\n icon={<AddIcon />}\n size={\"sm\"}\n className={\"ml-xs\"}\n />\n ) : null}\n </div>\n }\n search={\n <SearchUI\n value={filter}\n onChange={setFilter}\n inputPlaceholder={t`Search content model...`}\n />\n }\n modalOverlay={\n <DataListModal.Content>\n <Select\n value={sort}\n onChange={setSort}\n label={t`Sort by`}\n options={SORTERS.map(({ label, sorter: value }) => ({\n label,\n value\n }))}\n />\n </DataListModal.Content>\n }\n modalOverlayAction={\n <DataListModal.Trigger data-testid={\"default-data-list.filter\"} />\n }\n refresh={null}\n >\n {({ data = [] }: { data: CmsModel[] }) => {\n return (\n <List data-testid=\"default-data-list\">\n {data.map(contentModel => {\n const disableViewContent = contentModel.fields.length === 0;\n const getMessage = () => {\n if (disableViewContent) {\n return \"To view the entries, you first need to add a field and save the model\";\n }\n if (contentModel.tags.includes(CMS_MODEL_SINGLETON_TAG)) {\n return \"View\";\n }\n return \"View entries\";\n };\n\n const canDeleteModel = canDelete(\n contentModel,\n \"cms.contentModel\"\n );\n const canEditModel = canEdit(contentModel, \"cms.contentModel\");\n\n return (\n <List.Item\n key={contentModel.modelId}\n className={\"group/item\"}\n icon={<DisplayIcon model={contentModel} />}\n title={contentModel.name}\n description={t`Last modified: {time}.`({\n time: contentModel.savedOn ? (\n <TimeAgo datetime={contentModel.savedOn} />\n ) : (\n \"N/A\"\n )\n })}\n actions={\n <>\n <ModelIsBeingDeleted model={contentModel}>\n <span\n className={\n \"invisible group-hover/item:visible\"\n }\n >\n <Tooltip\n side={\"top\"}\n content={getMessage()}\n trigger={\n <Button\n text={\"View entries\"}\n icon={<ListIcon />}\n variant={\"secondary\"}\n size={\"sm\"}\n data-testid={\n \"cms-view-content-model-button\"\n }\n onClick={viewContentEntries(\n contentModel\n )}\n disabled={\n disableViewContent\n }\n />\n }\n />\n </span>\n\n {canEditModel && (\n <span\n className={\n \"invisible group-hover/item:visible\"\n }\n >\n <Tooltip\n side={\"top\"}\n content={\n contentModel.plugin\n ? t`Content model is registered via a plugin.`\n : t`Edit content model`\n }\n trigger={\n <Button\n text={\"Edit\"}\n icon={<EditIcon />}\n variant={\"secondary\"}\n size={\"sm\"}\n disabled={\n contentModel.plugin\n }\n onClick={() =>\n editRecord(\n contentModel\n )\n }\n data-testid={\n \"cms-edit-content-model-button\"\n }\n />\n }\n />\n </span>\n )}\n\n <DropdownMenu\n trigger={\n <IconButton\n icon={<MoreVertIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n />\n }\n >\n {canEditModel && (\n <DropdownMenu.Item\n text={\"Clone\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Clone\"}\n element={<CloneIcon />}\n />\n }\n data-testid={\n \"cms-clone-content-model-button\"\n }\n onClick={() =>\n onClone(contentModel)\n }\n />\n )}\n\n <DropdownMenu.Item\n text={\"Export\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Export\"}\n element={<ExportIcon />}\n />\n }\n data-testid={\n \"cms-export-content-model-button\"\n }\n onClick={handleModelExport(\n contentModel\n )}\n />\n\n {canDeleteModel && (\n <DropdownMenu.Item\n text={\"Delete\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Delete\"}\n element={<DeleteIcon />}\n />\n }\n onClick={() => {\n setModelToBeDeleted(\n contentModel\n );\n }}\n data-testid={\n \"cms-delete-content-model-button\"\n }\n className={\n \"text-destructive-primary! [&_svg]:fill-destructive\"\n }\n />\n )}\n </DropdownMenu>\n </ModelIsBeingDeleted>\n </>\n }\n />\n );\n })}\n </List>\n );\n }}\n </DataList>\n {modelToBeDeleted ? (\n <FullyDeleteModelDialog\n model={modelToBeDeleted}\n onClose={() => {\n setModelToBeDeleted(null);\n }}\n />\n ) : null}\n </>\n );\n }\n);\n\nexport default ContentModelsDataList;\n"],"names":["t","i18n","SORTERS","deserializeSorters","data","field","order","DisplayIcon","model","icon","normalizeIcon","Icon","FontAwesomeIcon","ContentModelsDataList","observer","canCreate","onCreate","onClone","showImportModelModal","presenter","useContentModelsPresenter","goToRoute","useRouter","showSnackbar","useSnackbar","canDelete","canEdit","usePermission","filter","setFilter","useState","sort","setSort","modelToBeDeleted","setModelToBeDeleted","models","loading","filteredData","useMemo","lc","m","sortedData","key","orderBy","editRecord","contentModel","Routes","viewContentEntries","useCallback","handleModelsExport","modelIds","download","ex","handleModelExport","DataList","Tooltip","IconButton","DownloadFileIcon","UploadFileIcon","Button","AddIcon","SearchUI","DataListModal","Select","label","value","List","disableViewContent","getMessage","CMS_MODEL_SINGLETON_TAG","canDeleteModel","canEditModel","TimeAgo","ModelIsBeingDeleted","ListIcon","EditIcon","DropdownMenu","MoreVertIcon","CloneIcon","ExportIcon","DeleteIcon","FullyDeleteModelDialog"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMA,IAAIC,KAAK,SAAS,CAAC;AAEzB,MAAMC,UAAU;IACZ;QAAE,OAAO;QAAoB,QAAQ;IAAe;IACpD;QAAE,OAAO;QAAoB,QAAQ;IAAc;IACnD;QAAE,OAAO;QAAY,QAAQ;IAAW;IACxC;QAAE,OAAO;QAAY,QA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BAEJ,WACI;;;QAUxC,MAKfZ,mBAAmB,WAAnBA,GACG,oBAACgD,wBAAsBA;QACnB,OAAOhD;QACP,SAAS;YACLC,oBAAoB;QACxB;SAEJ;AAGhB;AAGJ,yCAAerB"}
|
|
@@ -4,7 +4,7 @@ export interface NewContentModelDialogProps {
|
|
|
4
4
|
open: boolean;
|
|
5
5
|
onClose: DialogProps["onClose"];
|
|
6
6
|
}
|
|
7
|
-
declare const NewContentModelDialog: (({ open, onClose }: NewContentModelDialogProps) => React.JSX.Element) & {
|
|
8
|
-
|
|
7
|
+
declare const NewContentModelDialog: (({ open, onClose }: NewContentModelDialogProps) => React.JSX.Element) & React.NamedExoticComponent<NewContentModelDialogProps> & {
|
|
8
|
+
readonly type: ({ open, onClose }: NewContentModelDialogProps) => React.JSX.Element;
|
|
9
9
|
};
|
|
10
10
|
export default NewContentModelDialog;
|
|
@@ -6,10 +6,10 @@ import { OverlayLoader } from "@webiny/admin-ui";
|
|
|
6
6
|
import { Processed } from "./Processed.js";
|
|
7
7
|
const Content = ({ confirmation, setConfirmation, error, model, status })=>{
|
|
8
8
|
if (!model) return /*#__PURE__*/ react.createElement("p", null, "Model not found.");
|
|
9
|
-
if (status === FullyDeleteModelStateStatus.NONE) return /*#__PURE__*/ react.createElement(Information, {
|
|
9
|
+
else if (status === FullyDeleteModelStateStatus.NONE) return /*#__PURE__*/ react.createElement(Information, {
|
|
10
10
|
model: model
|
|
11
11
|
});
|
|
12
|
-
if (status === FullyDeleteModelStateStatus.PROCESSED) return /*#__PURE__*/ react.createElement(Processed, {
|
|
12
|
+
else if (status === FullyDeleteModelStateStatus.PROCESSED) return /*#__PURE__*/ react.createElement(Processed, {
|
|
13
13
|
model: model
|
|
14
14
|
});
|
|
15
15
|
return /*#__PURE__*/ react.createElement(react.Fragment, null, status === FullyDeleteModelStateStatus.CONFIRMED && /*#__PURE__*/ react.createElement(OverlayLoader, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentModels/components/fullDelete/dialog/Content.js","sources":["../../../../../../src/presentation/contentModels/components/fullDelete/dialog/Content.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { FullyDeleteModelStateStatus } from \"../types.js\";\nimport { Information } from \"./Information.js\";\nimport { Confirmation } from \"./Confirmation.js\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { Processed } from \"./Processed.js\";\n\nexport interface IContentProps {\n model: CmsModel | null;\n confirmation: string;\n setConfirmation: (value: string) => void;\n error: CmsErrorResponse | null;\n status: FullyDeleteModelStateStatus;\n}\n\nexport const Content = ({ confirmation, setConfirmation, error, model, status }: IContentProps) => {\n if (!model) {\n return <p>Model not found.</p>;\n } else if (status === FullyDeleteModelStateStatus.NONE) {\n return <Information model={model} />;\n } else if (status === FullyDeleteModelStateStatus.PROCESSED) {\n return <Processed model={model} />;\n }\n\n return (\n <>\n {status === FullyDeleteModelStateStatus.CONFIRMED && (\n <OverlayLoader text={\"Starting the deletion process...\"} />\n )}\n <Confirmation\n model={model}\n setConfirmation={setConfirmation}\n confirmation={confirmation}\n error={error}\n />\n </>\n );\n};\n"],"names":["Content","confirmation","setConfirmation","error","model","status","FullyDeleteModelStateStatus","Information","Processed","OverlayLoader","Confirmation"],"mappings":";;;;;;AAgBO,MAAMA,UAAU,CAAC,EAAEC,YAAY,EAAEC,eAAe,EAAEC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAiB;IAC1F,IAAI,CAACD,OACD,OAAO,WAAP,GAAO,oBAAC,WAAE;
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/components/fullDelete/dialog/Content.js","sources":["../../../../../../src/presentation/contentModels/components/fullDelete/dialog/Content.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { FullyDeleteModelStateStatus } from \"../types.js\";\nimport { Information } from \"./Information.js\";\nimport { Confirmation } from \"./Confirmation.js\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { Processed } from \"./Processed.js\";\n\nexport interface IContentProps {\n model: CmsModel | null;\n confirmation: string;\n setConfirmation: (value: string) => void;\n error: CmsErrorResponse | null;\n status: FullyDeleteModelStateStatus;\n}\n\nexport const Content = ({ confirmation, setConfirmation, error, model, status }: IContentProps) => {\n if (!model) {\n return <p>Model not found.</p>;\n } else if (status === FullyDeleteModelStateStatus.NONE) {\n return <Information model={model} />;\n } else if (status === FullyDeleteModelStateStatus.PROCESSED) {\n return <Processed model={model} />;\n }\n\n return (\n <>\n {status === FullyDeleteModelStateStatus.CONFIRMED && (\n <OverlayLoader text={\"Starting the deletion process...\"} />\n )}\n <Confirmation\n model={model}\n setConfirmation={setConfirmation}\n confirmation={confirmation}\n error={error}\n />\n </>\n );\n};\n"],"names":["Content","confirmation","setConfirmation","error","model","status","FullyDeleteModelStateStatus","Information","Processed","OverlayLoader","Confirmation"],"mappings":";;;;;;AAgBO,MAAMA,UAAU,CAAC,EAAEC,YAAY,EAAEC,eAAe,EAAEC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAiB;IAC1F,IAAI,CAACD,OACD,OAAO,WAAP,GAAO,oBAAC,WAAE;SACP,IAAIC,WAAWC,4BAA4B,IAAI,EAClD,OAAO,WAAP,GAAO,oBAACC,aAAWA;QAAC,OAAOH;;SACxB,IAAIC,WAAWC,4BAA4B,SAAS,EACvD,OAAO,WAAP,GAAO,oBAACE,WAASA;QAAC,OAAOJ;;IAG7B,OAAO,WAAP,GACI,0CACKC,WAAWC,4BAA4B,SAAS,IAAI,WAAJ,GAC7C,oBAACG,eAAaA;QAAC,MAAM;sBAEzB,oBAACC,cAAYA;QACT,OAAON;QACP,iBAAiBF;QACjB,cAAcD;QACd,OAAOE;;AAIvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentModels/components/fullDelete/types.js","sources":["../../../../../src/presentation/contentModels/components/fullDelete/types.ts"],"sourcesContent":["import type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport type { IDeleteCmsModelTask } from \"~/admin/viewsGraphql.js\";\n\nexport enum FullyDeleteModelStateStatus {\n NONE = 0,\n UNDERSTOOD = 1,\n CONFIRMED = 2,\n PROCESSED = 3,\n ERROR = 999\n}\n\nexport interface IFullyDeleteModelState {\n status: FullyDeleteModelStateStatus;\n confirmation: string;\n model: CmsModel;\n error: CmsErrorResponse | null;\n task: IDeleteCmsModelTask | null;\n}\n"],"names":["FullyDeleteModelStateStatus"],"mappings":"AAGO,IAAKA,oCAA2BA,WAAAA,GAAAA,SAA3BA,2BAA2B
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/components/fullDelete/types.js","sources":["../../../../../src/presentation/contentModels/components/fullDelete/types.ts"],"sourcesContent":["import type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport type { IDeleteCmsModelTask } from \"~/admin/viewsGraphql.js\";\n\nexport enum FullyDeleteModelStateStatus {\n NONE = 0,\n UNDERSTOOD = 1,\n CONFIRMED = 2,\n PROCESSED = 3,\n ERROR = 999\n}\n\nexport interface IFullyDeleteModelState {\n status: FullyDeleteModelStateStatus;\n confirmation: string;\n model: CmsModel;\n error: CmsErrorResponse | null;\n task: IDeleteCmsModelTask | null;\n}\n"],"names":["FullyDeleteModelStateStatus"],"mappings":"AAGO,IAAKA,oCAA2BA,WAAAA,GAAAA,SAA3BA,2BAA2B;sEAC5B;4EACM;2EACD;2EACA;uEACJ;WALAA"}
|
|
@@ -5,7 +5,7 @@ interface RefFieldOptionsProps {
|
|
|
5
5
|
onNewRecord: (modelId: string) => void;
|
|
6
6
|
onLinkExistingRecord: (modelId: string) => void;
|
|
7
7
|
}
|
|
8
|
-
export declare const RefFieldOptions: (({ models, onNewRecord, onLinkExistingRecord }: RefFieldOptionsProps) => React.JSX.Element) & {
|
|
9
|
-
|
|
8
|
+
export declare const RefFieldOptions: (({ models, onNewRecord, onLinkExistingRecord }: RefFieldOptionsProps) => React.JSX.Element) & React.NamedExoticComponent<RefFieldOptionsProps> & {
|
|
9
|
+
readonly type: ({ models, onNewRecord, onLinkExistingRecord }: RefFieldOptionsProps) => React.JSX.Element;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
|
@@ -11,9 +11,10 @@ const ModelListItem = ({ model, onClick: originalOnClick })=>{
|
|
|
11
11
|
}, [
|
|
12
12
|
originalOnClick
|
|
13
13
|
]);
|
|
14
|
-
const
|
|
14
|
+
const faIcon = normalizeIcon(model.icon);
|
|
15
|
+
const icon = faIcon ? /*#__PURE__*/ react.createElement(Icon, {
|
|
15
16
|
icon: /*#__PURE__*/ react.createElement(FontAwesomeIcon, {
|
|
16
|
-
icon:
|
|
17
|
+
icon: faIcon
|
|
17
18
|
}),
|
|
18
19
|
label: "Model icon",
|
|
19
20
|
size: "lg",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldRenderers/ref/components/RefFieldOptions.js","sources":["../../../../../src/presentation/fieldRenderers/ref/components/RefFieldOptions.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport type { CmsModel } from \"~/types.js\";\nimport { ReactComponent as AddIcon } from \"@webiny/icons/add.svg\";\nimport { ReactComponent as LinkIcon } from \"@webiny/icons/link.svg\";\nimport { Button, DropdownMenu, Text, Icon } from \"@webiny/admin-ui\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport
|
|
1
|
+
{"version":3,"file":"presentation/fieldRenderers/ref/components/RefFieldOptions.js","sources":["../../../../../src/presentation/fieldRenderers/ref/components/RefFieldOptions.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport type { CmsModel } from \"~/types.js\";\nimport { ReactComponent as AddIcon } from \"@webiny/icons/add.svg\";\nimport { ReactComponent as LinkIcon } from \"@webiny/icons/link.svg\";\nimport { Button, DropdownMenu, Text, Icon } from \"@webiny/admin-ui\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport { normalizeIcon } from \"~/utils/normalizeIcon.js\";\nimport { observer } from \"mobx-react-lite\";\n\ninterface ModelListItemProps {\n model: Pick<CmsModel, \"modelId\" | \"name\" | \"description\" | \"icon\">;\n onClick: (modelId: string) => void;\n}\n\nconst ModelListItem = ({ model, onClick: originalOnClick }: ModelListItemProps) => {\n const onClick = useCallback(() => {\n originalOnClick(model.modelId);\n }, [originalOnClick]);\n\n const faIcon = normalizeIcon(model.icon);\n const icon = faIcon ? (\n <Icon\n icon={<FontAwesomeIcon icon={faIcon} />}\n label={\"Model icon\"}\n size={\"lg\"}\n className={\"text-neutral-strong\"}\n />\n ) : undefined;\n\n return (\n <DropdownMenu.Item\n onClick={onClick}\n icon={icon}\n text={\n <div>\n <Text as={\"div\"}>{model.name}</Text>\n <Text as={\"div\"} size={\"sm\"} className={\"text-neutral-strong\"}>\n {model.description}\n </Text>\n </div>\n }\n />\n );\n};\n\ninterface RefFieldOptionsProps {\n models: CmsModel[];\n onNewRecord: (modelId: string) => void;\n onLinkExistingRecord: (modelId: string) => void;\n}\n\nexport const RefFieldOptions = observer(\n ({ models, onNewRecord, onLinkExistingRecord }: RefFieldOptionsProps) => {\n const hasMultipleModels = models.length > 1;\n\n const onSingleNewRecord = useCallback(() => {\n if (models.length === 0 || hasMultipleModels) {\n return;\n }\n onNewRecord(models[0].modelId);\n }, [models]);\n\n const onSingleExistingRecord = useCallback(() => {\n if (models.length === 0 || hasMultipleModels) {\n return;\n }\n onLinkExistingRecord(models[0].modelId);\n }, [models]);\n\n if (hasMultipleModels) {\n return (\n <div className={\"flex flex-wrap gap-sm\"}>\n <DropdownMenu\n trigger={\n <Button\n variant={\"tertiary\"}\n text=\"Create a new record\"\n icon={<AddIcon />}\n />\n }\n >\n {models.map(model => (\n <ModelListItem\n key={model.modelId}\n onClick={onNewRecord}\n model={model}\n />\n ))}\n </DropdownMenu>\n <DropdownMenu\n trigger={\n <Button\n variant={\"tertiary\"}\n text=\"Select an existing record\"\n icon={<LinkIcon />}\n />\n }\n >\n {models.map(model => (\n <ModelListItem\n key={model.modelId}\n onClick={onLinkExistingRecord}\n model={model}\n />\n ))}\n </DropdownMenu>\n </div>\n );\n }\n\n return (\n <div className={\"flex flex-wrap gap-sm\"}>\n <Button\n variant={\"tertiary\"}\n text=\"Create a new record\"\n icon={<AddIcon />}\n onClick={onSingleNewRecord}\n />\n <Button\n variant={\"tertiary\"}\n text=\"Select an existing record\"\n icon={<LinkIcon />}\n onClick={onSingleExistingRecord}\n />\n </div>\n );\n }\n);\n"],"names":["ModelListItem","model","originalOnClick","onClick","useCallback","faIcon","normalizeIcon","icon","Icon","FontAwesomeIcon","undefined","DropdownMenu","Text","RefFieldOptions","observer","models","onNewRecord","onLinkExistingRecord","hasMultipleModels","onSingleNewRecord","onSingleExistingRecord","Button","AddIcon","LinkIcon"],"mappings":";;;;;;;AAcA,MAAMA,gBAAgB,CAAC,EAAEC,KAAK,EAAE,SAASC,eAAe,EAAsB;IAC1E,MAAMC,UAAUC,YAAY;QACxBF,gBAAgBD,MAAM,OAAO;IACjC,GAAG;QAACC;KAAgB;IAEpB,MAAMG,SAASC,cAAcL,MAAM,IAAI;IACvC,MAAMM,OAAOF,SAAS,WAATA,GACT,oBAACG,MAAIA;QACD,oBAAM,oBAACC,iBAAeA;YAAC,MAAMJ;;QAC7B,OAAO;QACP,MAAM;QACN,WAAW;SAEfK;IAEJ,OAAO,WAAP,GACI,oBAACC,aAAa,IAAI;QACd,SAASR;QACT,MAAMI;QACN,oBACI,oBAAC,2BACG,oBAACK,MAAIA;YAAC,IAAI;WAAQX,MAAM,IAAI,iBAC5B,oBAACW,MAAIA;YAAC,IAAI;YAAO,MAAM;YAAM,WAAW;WACnCX,MAAM,WAAW;;AAM1C;AAQO,MAAMY,kBAAkBC,SAC3B,CAAC,EAAEC,MAAM,EAAEC,WAAW,EAAEC,oBAAoB,EAAwB;IAChE,MAAMC,oBAAoBH,OAAO,MAAM,GAAG;IAE1C,MAAMI,oBAAoBf,YAAY;QAClC,IAAIW,AAAkB,MAAlBA,OAAO,MAAM,IAAUG,mBACvB;QAEJF,YAAYD,MAAM,CAAC,EAAE,CAAC,OAAO;IACjC,GAAG;QAACA;KAAO;IAEX,MAAMK,yBAAyBhB,YAAY;QACvC,IAAIW,AAAkB,MAAlBA,OAAO,MAAM,IAAUG,mBACvB;QAEJD,qBAAqBF,MAAM,CAAC,EAAE,CAAC,OAAO;IAC1C,GAAG;QAACA;KAAO;IAEX,IAAIG,mBACA,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACP,cAAYA;QACT,uBACI,oBAACU,QAAMA;YACH,SAAS;YACT,MAAK;YACL,oBAAM,oBAACC,gBAAOA;;OAIrBP,OAAO,GAAG,CAACd,CAAAA,QAAAA,WAAAA,GACR,oBAACD,eAAaA;YACV,KAAKC,MAAM,OAAO;YAClB,SAASe;YACT,OAAOf;4BAInB,oBAACU,cAAYA;QACT,uBACI,oBAACU,QAAMA;YACH,SAAS;YACT,MAAK;YACL,oBAAM,oBAACE,yBAAQA;;OAItBR,OAAO,GAAG,CAACd,CAAAA,QAAAA,WAAAA,GACR,oBAACD,eAAaA;YACV,KAAKC,MAAM,OAAO;YAClB,SAASgB;YACT,OAAOhB;;IAQ/B,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACoB,QAAMA;QACH,SAAS;QACT,MAAK;QACL,oBAAM,oBAACC,gBAAOA;QACd,SAASH;sBAEb,oBAACE,QAAMA;QACH,SAAS;QACT,MAAK;QACL,oBAAM,oBAACE,yBAAQA;QACf,SAASH;;AAIzB"}
|
|
@@ -2,6 +2,6 @@ import React from "react";
|
|
|
2
2
|
export interface ImportContentModelsDialogProps {
|
|
3
3
|
onClose: () => void;
|
|
4
4
|
}
|
|
5
|
-
export declare const ImportContentModelsDialog: ((props: ImportContentModelsDialogProps) => React.JSX.Element) & {
|
|
6
|
-
|
|
5
|
+
export declare const ImportContentModelsDialog: ((props: ImportContentModelsDialogProps) => React.JSX.Element) & React.NamedExoticComponent<ImportContentModelsDialogProps> & {
|
|
6
|
+
readonly type: (props: ImportContentModelsDialogProps) => React.JSX.Element;
|
|
7
7
|
};
|
|
@@ -9,7 +9,7 @@ const createSelected = (params)=>{
|
|
|
9
9
|
for (const id of item.related){
|
|
10
10
|
const model = models.find((model)=>model.id === id);
|
|
11
11
|
if (!model) continue;
|
|
12
|
-
if (selected.has(model.id) || model.imported) continue;
|
|
12
|
+
else if (selected.has(model.id) || model.imported) continue;
|
|
13
13
|
const related = createSelected({
|
|
14
14
|
previous: selected,
|
|
15
15
|
models,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/importContentModels/ImportContentModelsPresenter.js","sources":["../../../src/presentation/importContentModels/ImportContentModelsPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport type { CmsGroup, CmsModel } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport type { ImportGroupData, ImportModelData } from \"./types.js\";\nimport { ImportAction } from \"./types.js\";\nimport type { ImportStructureVariablesGroup, ImportStructureVariablesModel } from \"./graphql.js\";\nimport { ValidateImportUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport { ImportModelsUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport {\n ImportContentModelsPresenter as Abstraction,\n type IImportContentModelsPresenter,\n type IImportContentModelsPresenterViewModel\n} from \"./abstractions.js\";\n\ninterface Data {\n groups: CmsGroup[];\n models: CmsModel[];\n}\n\ntype Selected = Map<string, string[]>;\n\ninterface CreateSelectedParams {\n previous: Selected;\n models: Pick<ImportModelData, \"id\" | \"related\" | \"imported\">[];\n item: Pick<ImportModelData, \"id\" | \"related\">;\n}\n\nconst createSelected = (params: CreateSelectedParams): Selected => {\n const { previous, models, item } = params;\n let selected = new Map(previous);\n\n selected.set(item.id, item.related);\n for (const id of item.related) {\n const model = models.find(model => model.id === id);\n if (!model) {\n continue;\n } else if (selected.has(model.id) || model.imported) {\n continue;\n }\n const related = createSelected({\n previous: selected,\n models,\n item: model\n });\n selected = new Map([...selected, ...related]);\n }\n\n return selected;\n};\n\ninterface DataToImportResult {\n groups: ImportStructureVariablesGroup[];\n models: ImportStructureVariablesModel[];\n}\n\nclass ImportContentModelsPresenterImpl implements IImportContentModelsPresenter {\n private data: Data | null = null;\n private loading = false;\n private groups: ImportGroupData[] = [];\n private models: ImportModelData[] = [];\n private file: File | null = null;\n private errors: string[] = [];\n private validated = false;\n private selected: Selected = new Map();\n\n constructor(\n private validateUseCase: ValidateImportUseCase.Interface,\n private importUseCase: ImportModelsUseCase.Interface\n ) {\n makeAutoObservable<ImportContentModelsPresenterImpl, \"validateUseCase\" | \"importUseCase\">(\n this,\n {\n validateUseCase: false,\n importUseCase: false\n }\n );\n }\n\n get vm(): IImportContentModelsPresenterViewModel {\n return {\n data: this.data,\n loading: this.loading,\n groups: this.groups,\n models: this.models,\n file: this.file,\n errors: this.errors,\n validated: this.validated\n };\n }\n\n hasSelected(): boolean {\n return this.selected.size > 0;\n }\n\n isModelSelected(item: Pick<ImportModelData, \"id\">): boolean {\n return this.selected.has(item.id);\n }\n\n isModelRelated({ id: target }: Pick<ImportModelData, \"id\">): boolean {\n for (const id of this.selected.keys()) {\n if (id === target) {\n continue;\n }\n const related = this.selected.get(id);\n if (related && related.includes(target)) {\n return true;\n }\n }\n return false;\n }\n\n onFile(file: File): void {\n const reader = new FileReader();\n reader.addEventListener(\"load\", event => {\n try {\n const data = this.parseFileContent(event.target?.result);\n runInAction(() => {\n this.models = [];\n this.groups = [];\n this.selected = new Map();\n this.errors = [];\n this.validated = false;\n this.file = file;\n this.data = data;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.file = file;\n this.selected = new Map();\n this.validated = false;\n this.groups = [];\n this.models = [];\n this.data = null;\n this.errors = [ex.message];\n });\n }\n });\n reader.readAsText(file);\n }\n\n onFileError(error: string): void {\n this.file = null;\n this.errors = [error];\n }\n\n toggleModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n this.removeModel(item);\n } else {\n this.addModel(item);\n }\n }\n\n async handleModelsValidation(): Promise<void> {\n if (!this.data) {\n return;\n }\n\n this.loading = true;\n\n try {\n const data = await this.validateUseCase.execute(this.data as any);\n\n runInAction(() => {\n this.loading = false;\n this.groups = data.groups.map(group => ({\n id: group.group.id,\n name: group.group.name,\n slug: group.group.slug,\n error: group.error,\n action: group.action\n }));\n this.models = data.models.map(model => ({\n id: model.model.modelId,\n name: model.model.name,\n group: model.model.group,\n related: model.related || [],\n error: model.error,\n action: model.action\n }));\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n async handleModelsImport(): Promise<void> {\n if (!this.data || !this.groups.length || !this.models.length || !this.selected.size) {\n return;\n }\n\n this.loading = true;\n\n const dataToImport = this.getDataToImport();\n\n try {\n const data = await this.importUseCase.execute(dataToImport);\n\n runInAction(() => {\n this.loading = false;\n this.selected = new Map();\n this.groups = this.groups.map(group => {\n const result = data.groups.find(item => item.group.id === group.id);\n return {\n id: result?.group.id || group.id,\n name: result?.group.name || group.name,\n slug: result?.group.slug || group.slug,\n error: result?.error || group.error,\n imported: result ? result.imported : group.imported\n };\n });\n this.models = this.models.map(model => {\n const result = data.models.find(item => item.model.modelId === model.id);\n return {\n id: result?.model.modelId || model.id,\n name: result?.model.name || model.name,\n group: result?.model.group || model.group,\n related: result?.related || model.related || [],\n action: result?.action || model.action,\n error: result?.error || model.error,\n imported: result ? result.imported : model.imported\n };\n });\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n reset(): void {\n this.data = null;\n this.loading = false;\n this.groups = [];\n this.models = [];\n this.file = null;\n this.errors = [];\n this.validated = false;\n this.selected = new Map();\n }\n\n private addModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n return;\n }\n this.selected = createSelected({\n previous: this.selected,\n models: this.models,\n item\n });\n }\n\n private removeModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelRelated(item)) {\n return;\n }\n const selected = new Map(this.selected);\n selected.delete(item.id);\n this.selected = selected;\n }\n\n private getDataToImport(): DataToImportResult {\n const selected = Array.from(this.selected.keys());\n const groups: Map<string, ImportStructureVariablesGroup> = new Map();\n const models: Map<string, ImportStructureVariablesModel> = new Map();\n const noAction = [ImportAction.CODE, ImportAction.NONE];\n\n for (const id of selected) {\n const validatedModel = this.models.find(model => model.id === id);\n if (\n !validatedModel?.action ||\n validatedModel.error ||\n noAction.includes(validatedModel.action)\n ) {\n continue;\n }\n const validatedGroup = this.groups.find(group => group.slug === validatedModel.group);\n if (!validatedGroup?.action || validatedGroup.error) {\n continue;\n }\n\n const model = this.data?.models?.find(model => model.modelId === id);\n if (!model) {\n continue;\n }\n models.set(id, {\n ...model,\n layout: model.layout || [],\n titleFieldId: model.titleFieldId || \"id\",\n descriptionFieldId: model.descriptionFieldId || \"\",\n imageFieldId: model.imageFieldId || \"\",\n group: validatedModel.group\n });\n\n if (noAction.includes(validatedGroup.action)) {\n continue;\n }\n\n const group = this.data?.groups?.find(group => group.slug === validatedModel.group);\n if (!group) {\n continue;\n }\n groups.set(group.id, group);\n }\n\n return {\n groups: Array.from(groups.values()),\n models: Array.from(models.values())\n };\n }\n\n private parseFileContent(content?: string | ArrayBuffer | null): Data {\n if (!content) {\n throw new Error(\"Missing data in uploaded file.\");\n }\n const raw =\n content instanceof ArrayBuffer ? Buffer.from(content).toString(\"utf8\") : content;\n\n let data: Record<string, any> = {};\n try {\n data = JSON.parse(raw);\n } catch {\n throw new Error(\"Could not parse the uploaded file. Make sure it's a valid JSON file.\");\n }\n if (!data.groups?.length && !data.models?.length) {\n throw new Error(\"No groups and models in the uploaded file.\");\n } else if (data.groups.length === 0) {\n throw new Error(\"No groups in the uploaded file. There must be at least one group.\");\n }\n return {\n groups: data.groups,\n models: data.models\n };\n }\n}\n\nexport const ImportContentModelsPresenter = Abstraction.createImplementation({\n implementation: ImportContentModelsPresenterImpl,\n dependencies: [ValidateImportUseCase, ImportModelsUseCase]\n});\n"],"names":["createSelected","params","previous","models","item","selected","Map","id","model","related","ImportContentModelsPresenterImpl","validateUseCase","importUseCase","makeAutoObservable","target","file","reader","FileReader","event","data","runInAction","ex","error","group","dataToImport","result","Array","groups","noAction","ImportAction","validatedModel","validatedGroup","content","Error","raw","ArrayBuffer","Buffer","JSON","ImportContentModelsPresenter","Abstraction","ValidateImportUseCase","ImportModelsUseCase"],"mappings":";;;;AA0BA,MAAMA,iBAAiB,CAACC;IACpB,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IACnC,IAAII,WAAW,IAAIC,IAAIJ;IAEvBG,SAAS,GAAG,CAACD,KAAK,EAAE,EAAEA,KAAK,OAAO;IAClC,KAAK,MAAMG,MAAMH,KAAK,OAAO,CAAE;QAC3B,MAAMI,QAAQL,OAAO,IAAI,CAACK,CAAAA,QAASA,MAAM,EAAE,KAAKD;QAChD,IAAI,CAACC,OACD;QACG,IAAIH,SAAS,GAAG,CAACG,MAAM,EAAE,KAAKA,MAAM,QAAQ,EAC/C;QAEJ,MAAMC,UAAUT,eAAe;YAC3B,UAAUK;YACVF;YACA,MAAMK;QACV;QACAH,WAAW,IAAIC,IAAI;eAAID;eAAaI;SAAQ;IAChD;IAEA,OAAOJ;AACX;AAOA,MAAMK;IAUF,YACYC,eAAgD,EAChDC,aAA4C,CACtD;aAFUD,eAAe,GAAfA;aACAC,aAAa,GAAbA;aAXJ,IAAI,GAAgB;aACpB,OAAO,GAAG;aACV,MAAM,GAAsB,EAAE;aAC9B,MAAM,GAAsB,EAAE;aAC9B,IAAI,GAAgB;aACpB,MAAM,GAAa,EAAE;aACrB,SAAS,GAAG;aACZ,QAAQ,GAAa,IAAIN;QAM7BO,mBACI,IAAI,EACJ;YACI,iBAAiB;YACjB,eAAe;QACnB;IAER;IAEA,IAAI,KAA6C;QAC7C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AAM;QACpC;IACJ;IAEQ,iBAAiB6B,OAAqC,EAAQ;QAClE,IAAI,CAACA,SACD,MAAM,IAAIC,MAAM;QAEpB,MAAMC,MACFF,mBAAmBG,cAAcC,OAAO,IAAI,CAACJ,SAAS,QAAQ,CAAC,UAAUA;QAE7E,IAAIb,OAA4B,CAAC;QACjC,IAAI;YACAA,OAAOkB,KAAK,KAAK,CAACH;QACtB,EAAE,OAAM;YACJ,MAAM,IAAID,MAAM;QACpB;QACA,IAAI,AAACd,KAAK,MAAM,EAAE,UAAWA,KAAK,MAAM,EAAE,QAEnC;YAAA,IAAIA,AAAuB,MAAvBA,KAAK,MAAM,CAAC,MAAM,EACzB,MAAM,IAAIc,MAAM;QACpB,OAHI,MAAM,IAAIA,MAAM;QAIpB,OAAO;YACH,QAAQd,KAAK,MAAM;YACnB,QAAQA,KAAK,MAAM;QACvB;IACJ;AACJ;AAEO,MAAMmB,4DAA+BC,6BAAAA,oBAAgC,CAAC;IACzE,gBAAgB7B;IAChB,cAAc;QAAC8B;QAAuBC;KAAoB;AAC9D"}
|
|
1
|
+
{"version":3,"file":"presentation/importContentModels/ImportContentModelsPresenter.js","sources":["../../../src/presentation/importContentModels/ImportContentModelsPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport type { CmsGroup, CmsModel } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport type { ImportGroupData, ImportModelData } from \"./types.js\";\nimport { ImportAction } from \"./types.js\";\nimport type { ImportStructureVariablesGroup, ImportStructureVariablesModel } from \"./graphql.js\";\nimport { ValidateImportUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport { ImportModelsUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport {\n ImportContentModelsPresenter as Abstraction,\n type IImportContentModelsPresenter,\n type IImportContentModelsPresenterViewModel\n} from \"./abstractions.js\";\n\ninterface Data {\n groups: CmsGroup[];\n models: CmsModel[];\n}\n\ntype Selected = Map<string, string[]>;\n\ninterface CreateSelectedParams {\n previous: Selected;\n models: Pick<ImportModelData, \"id\" | \"related\" | \"imported\">[];\n item: Pick<ImportModelData, \"id\" | \"related\">;\n}\n\nconst createSelected = (params: CreateSelectedParams): Selected => {\n const { previous, models, item } = params;\n let selected = new Map(previous);\n\n selected.set(item.id, item.related);\n for (const id of item.related) {\n const model = models.find(model => model.id === id);\n if (!model) {\n continue;\n } else if (selected.has(model.id) || model.imported) {\n continue;\n }\n const related = createSelected({\n previous: selected,\n models,\n item: model\n });\n selected = new Map([...selected, ...related]);\n }\n\n return selected;\n};\n\ninterface DataToImportResult {\n groups: ImportStructureVariablesGroup[];\n models: ImportStructureVariablesModel[];\n}\n\nclass ImportContentModelsPresenterImpl implements IImportContentModelsPresenter {\n private data: Data | null = null;\n private loading = false;\n private groups: ImportGroupData[] = [];\n private models: ImportModelData[] = [];\n private file: File | null = null;\n private errors: string[] = [];\n private validated = false;\n private selected: Selected = new Map();\n\n constructor(\n private validateUseCase: ValidateImportUseCase.Interface,\n private importUseCase: ImportModelsUseCase.Interface\n ) {\n makeAutoObservable<ImportContentModelsPresenterImpl, \"validateUseCase\" | \"importUseCase\">(\n this,\n {\n validateUseCase: false,\n importUseCase: false\n }\n );\n }\n\n get vm(): IImportContentModelsPresenterViewModel {\n return {\n data: this.data,\n loading: this.loading,\n groups: this.groups,\n models: this.models,\n file: this.file,\n errors: this.errors,\n validated: this.validated\n };\n }\n\n hasSelected(): boolean {\n return this.selected.size > 0;\n }\n\n isModelSelected(item: Pick<ImportModelData, \"id\">): boolean {\n return this.selected.has(item.id);\n }\n\n isModelRelated({ id: target }: Pick<ImportModelData, \"id\">): boolean {\n for (const id of this.selected.keys()) {\n if (id === target) {\n continue;\n }\n const related = this.selected.get(id);\n if (related && related.includes(target)) {\n return true;\n }\n }\n return false;\n }\n\n onFile(file: File): void {\n const reader = new FileReader();\n reader.addEventListener(\"load\", event => {\n try {\n const data = this.parseFileContent(event.target?.result);\n runInAction(() => {\n this.models = [];\n this.groups = [];\n this.selected = new Map();\n this.errors = [];\n this.validated = false;\n this.file = file;\n this.data = data;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.file = file;\n this.selected = new Map();\n this.validated = false;\n this.groups = [];\n this.models = [];\n this.data = null;\n this.errors = [ex.message];\n });\n }\n });\n reader.readAsText(file);\n }\n\n onFileError(error: string): void {\n this.file = null;\n this.errors = [error];\n }\n\n toggleModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n this.removeModel(item);\n } else {\n this.addModel(item);\n }\n }\n\n async handleModelsValidation(): Promise<void> {\n if (!this.data) {\n return;\n }\n\n this.loading = true;\n\n try {\n const data = await this.validateUseCase.execute(this.data as any);\n\n runInAction(() => {\n this.loading = false;\n this.groups = data.groups.map(group => ({\n id: group.group.id,\n name: group.group.name,\n slug: group.group.slug,\n error: group.error,\n action: group.action\n }));\n this.models = data.models.map(model => ({\n id: model.model.modelId,\n name: model.model.name,\n group: model.model.group,\n related: model.related || [],\n error: model.error,\n action: model.action\n }));\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n async handleModelsImport(): Promise<void> {\n if (!this.data || !this.groups.length || !this.models.length || !this.selected.size) {\n return;\n }\n\n this.loading = true;\n\n const dataToImport = this.getDataToImport();\n\n try {\n const data = await this.importUseCase.execute(dataToImport);\n\n runInAction(() => {\n this.loading = false;\n this.selected = new Map();\n this.groups = this.groups.map(group => {\n const result = data.groups.find(item => item.group.id === group.id);\n return {\n id: result?.group.id || group.id,\n name: result?.group.name || group.name,\n slug: result?.group.slug || group.slug,\n error: result?.error || group.error,\n imported: result ? result.imported : group.imported\n };\n });\n this.models = this.models.map(model => {\n const result = data.models.find(item => item.model.modelId === model.id);\n return {\n id: result?.model.modelId || model.id,\n name: result?.model.name || model.name,\n group: result?.model.group || model.group,\n related: result?.related || model.related || [],\n action: result?.action || model.action,\n error: result?.error || model.error,\n imported: result ? result.imported : model.imported\n };\n });\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n reset(): void {\n this.data = null;\n this.loading = false;\n this.groups = [];\n this.models = [];\n this.file = null;\n this.errors = [];\n this.validated = false;\n this.selected = new Map();\n }\n\n private addModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n return;\n }\n this.selected = createSelected({\n previous: this.selected,\n models: this.models,\n item\n });\n }\n\n private removeModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelRelated(item)) {\n return;\n }\n const selected = new Map(this.selected);\n selected.delete(item.id);\n this.selected = selected;\n }\n\n private getDataToImport(): DataToImportResult {\n const selected = Array.from(this.selected.keys());\n const groups: Map<string, ImportStructureVariablesGroup> = new Map();\n const models: Map<string, ImportStructureVariablesModel> = new Map();\n const noAction = [ImportAction.CODE, ImportAction.NONE];\n\n for (const id of selected) {\n const validatedModel = this.models.find(model => model.id === id);\n if (\n !validatedModel?.action ||\n validatedModel.error ||\n noAction.includes(validatedModel.action)\n ) {\n continue;\n }\n const validatedGroup = this.groups.find(group => group.slug === validatedModel.group);\n if (!validatedGroup?.action || validatedGroup.error) {\n continue;\n }\n\n const model = this.data?.models?.find(model => model.modelId === id);\n if (!model) {\n continue;\n }\n models.set(id, {\n ...model,\n layout: model.layout || [],\n titleFieldId: model.titleFieldId || \"id\",\n descriptionFieldId: model.descriptionFieldId || \"\",\n imageFieldId: model.imageFieldId || \"\",\n group: validatedModel.group\n });\n\n if (noAction.includes(validatedGroup.action)) {\n continue;\n }\n\n const group = this.data?.groups?.find(group => group.slug === validatedModel.group);\n if (!group) {\n continue;\n }\n groups.set(group.id, group);\n }\n\n return {\n groups: Array.from(groups.values()),\n models: Array.from(models.values())\n };\n }\n\n private parseFileContent(content?: string | ArrayBuffer | null): Data {\n if (!content) {\n throw new Error(\"Missing data in uploaded file.\");\n }\n const raw =\n content instanceof ArrayBuffer ? Buffer.from(content).toString(\"utf8\") : content;\n\n let data: Record<string, any> = {};\n try {\n data = JSON.parse(raw);\n } catch {\n throw new Error(\"Could not parse the uploaded file. Make sure it's a valid JSON file.\");\n }\n if (!data.groups?.length && !data.models?.length) {\n throw new Error(\"No groups and models in the uploaded file.\");\n } else if (data.groups.length === 0) {\n throw new Error(\"No groups in the uploaded file. There must be at least one group.\");\n }\n return {\n groups: data.groups,\n models: data.models\n };\n }\n}\n\nexport const ImportContentModelsPresenter = Abstraction.createImplementation({\n implementation: ImportContentModelsPresenterImpl,\n dependencies: [ValidateImportUseCase, ImportModelsUseCase]\n});\n"],"names":["createSelected","params","previous","models","item","selected","Map","id","model","related","ImportContentModelsPresenterImpl","validateUseCase","importUseCase","makeAutoObservable","target","file","reader","FileReader","event","data","runInAction","ex","error","group","dataToImport","result","Array","groups","noAction","ImportAction","validatedModel","validatedGroup","content","Error","raw","ArrayBuffer","Buffer","JSON","ImportContentModelsPresenter","Abstraction","ValidateImportUseCase","ImportModelsUseCase"],"mappings":";;;;AA0BA,MAAMA,iBAAiB,CAACC;IACpB,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IACnC,IAAII,WAAW,IAAIC,IAAIJ;IAEvBG,SAAS,GAAG,CAACD,KAAK,EAAE,EAAEA,KAAK,OAAO;IAClC,KAAK,MAAMG,MAAMH,KAAK,OAAO,CAAE;QAC3B,MAAMI,QAAQL,OAAO,IAAI,CAACK,CAAAA,QAASA,MAAM,EAAE,KAAKD;QAChD,IAAI,CAACC,OACD;aACG,IAAIH,SAAS,GAAG,CAACG,MAAM,EAAE,KAAKA,MAAM,QAAQ,EAC/C;QAEJ,MAAMC,UAAUT,eAAe;YAC3B,UAAUK;YACVF;YACA,MAAMK;QACV;QACAH,WAAW,IAAIC,IAAI;eAAID;eAAaI;SAAQ;IAChD;IAEA,OAAOJ;AACX;AAOA,MAAMK;IAUF,YACYC,eAAgD,EAChDC,aAA4C,C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A,IAAIF,SAAS,QAAQ,CAACG,eAAe,MAAM,GACvC;YAGJ,MAAMR,QAAQ,IAAI,CAAC,IAAI,EAAE,QAAQ,KAAKA,CAAAA,QAASA,MAAM,IAAI,KAAKO,eAAe,KAAK;YAClF,IAAKP,OAGLI,OAAO,GAAG,CAACJ,MAAM,EAAE,EAAEA;QACzB;QAEA,OAAO;YACH,QAAQG,MAAM,IAAI,CAACC,OAAO,MAAM;YAChC,QAAQD,MAAM,IAAI,CAACvB,OAAO,MAAM;QACpC;IACJ;IAEQ,iBAAiB6B,OAAqC,EAAQ;QAClE,IAAI,CAACA,SACD,MAAM,IAAIC,MAAM;QAEpB,MAAMC,MACFF,mBAAmBG,cAAcC,OAAO,IAAI,CAACJ,SAAS,QAAQ,CAAC,UAAUA;QAE7E,IAAIb,OAA4B,CAAC;QACjC,IAAI;YACAA,OAAOkB,KAAK,KAAK,CAACH;QACtB,EAAE,OAAM;YACJ,MAAM,IAAID,MAAM;QACpB;QACA,IAAI,AAACd,KAAK,MAAM,EAAE,UAAWA,KAAK,MAAM,EAAE,QAEnC;YAAA,IAAIA,AAAuB,MAAvBA,KAAK,MAAM,CAAC,MAAM,EACzB,MAAM,IAAIc,MAAM;QACpB,OAHI,MAAM,IAAIA,MAAM;QAIpB,OAAO;YACH,QAAQd,KAAK,MAAM;YACnB,QAAQA,KAAK,MAAM;QACvB;IACJ;AACJ;AAEO,MAAMmB,4DAA+BC,6BAAAA,oBAAgC,CAAC;IACzE,gBAAgB7B;IAChB,cAAc;QAAC8B;QAAuBC;KAAoB;AAC9D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const DataList: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const DataList: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/importContentModels/components/FileUpload.js","sources":["../../../../src/presentation/importContentModels/components/FileUpload.tsx"],"sourcesContent":["import React from \"react\";\nimport { BrowserFilePicker } from \"@webiny/app-admin/presentation/browserFilePicker/index.js\";\nimport { Text } from \"@webiny/admin-ui\";\nimport { getError } from \"./Errors.js\";\nimport { observer } from \"mobx-react-lite\";\nimport { useImportContentModelsPresenter } from \"../useImportContentModelsPresenter.js\";\n\nexport const FileUpload = observer(() => {\n const presenter = useImportContentModelsPresenter();\n const onFile = (file: File) => presenter.onFile(file);\n const onFileError = (error: string) => presenter.onFileError(error);\n const fileName = presenter.vm.file?.name;\n\n return (\n <BrowserFilePicker\n accept={[\"application/json\"]}\n maxSize={\"
|
|
1
|
+
{"version":3,"file":"presentation/importContentModels/components/FileUpload.js","sources":["../../../../src/presentation/importContentModels/components/FileUpload.tsx"],"sourcesContent":["import React from \"react\";\nimport { BrowserFilePicker } from \"@webiny/app-admin/presentation/browserFilePicker/index.js\";\nimport { Text } from \"@webiny/admin-ui\";\nimport { getError } from \"./Errors.js\";\nimport { observer } from \"mobx-react-lite\";\nimport { useImportContentModelsPresenter } from \"../useImportContentModelsPresenter.js\";\n\nexport const FileUpload = observer(() => {\n const presenter = useImportContentModelsPresenter();\n const onFile = (file: File) => presenter.onFile(file);\n const onFileError = (error: string) => presenter.onFileError(error);\n const fileName = presenter.vm.file?.name;\n\n return (\n <BrowserFilePicker\n accept={[\"application/json\"]}\n maxSize={\"10mb\"}\n onSuccess={files => {\n const file = files.find(f => f.src.file);\n const uploadedFile = file?.src?.file;\n if (!uploadedFile) {\n onFileError(\n \"File is not valid. Please make sure you are uploading a valid JSON file.\"\n );\n return;\n }\n onFile(uploadedFile);\n }}\n onError={err => {\n const errors = err.map(er => {\n return getError(er);\n });\n if (errors.length === 0) {\n return;\n }\n onFileError(errors[0]);\n }}\n multiple={false}\n >\n {({ browseFiles, getDropZoneProps }) => {\n return (\n <>\n <div\n className={\n \"w-full mx-auto my-0 border-sm border-dashed cursor-pointer border-neutral-muted bg-neutral-base text-center p-md \"\n }\n onClick={() => browseFiles()}\n {...getDropZoneProps()}\n >\n <Text>{fileName || \"Drop a file here, or click to select one.\"}</Text>\n </div>\n </>\n );\n }}\n </BrowserFilePicker>\n );\n});\n"],"names":["FileUpload","observer","presenter","useImportContentModelsPresenter","onFile","file","onFileError","error","fileName","BrowserFilePicker","files","f","uploadedFile","err","errors","er","getError","browseFiles","getDropZoneProps","Text"],"mappings":";;;;;;AAOO,MAAMA,aAAaC,SAAS;IAC/B,MAAMC,YAAYC;IAClB,MAAMC,SAAS,CAACC,OAAeH,UAAU,MAAM,CAACG;IAChD,MAAMC,cAAc,CAACC,QAAkBL,UAAU,WAAW,CAACK;IAC7D,MAAMC,WAAWN,UAAU,EAAE,CAAC,IAAI,EAAE;IAEpC,OAAO,WAAP,GACI,oBAACO,mBAAiBA;QACd,QAAQ;YAAC;SAAmB;QAC5B,SAAS;QACT,WAAWC,CAAAA;YACP,MAAML,OAAOK,MAAM,IAAI,CAACC,CAAAA,IAAKA,EAAE,GAAG,CAAC,IAAI;YACvC,MAAMC,eAAeP,MAAM,KAAK;YAChC,IAAI,CAACO,cAAc,YACfN,YACI;YAIRF,OAAOQ;QACX;QACA,SAASC,CAAAA;YACL,MAAMC,SAASD,IAAI,GAAG,CAACE,CAAAA,KACZC,SAASD;YAEpB,IAAID,AAAkB,MAAlBA,OAAO,MAAM,EACb;YAEJR,YAAYQ,MAAM,CAAC,EAAE;QACzB;QACA,UAAU;OAET,CAAC,EAAEG,WAAW,EAAEC,gBAAgB,EAAE,GACxB,WAAP,GACI,wDACI,oBAAC;YACG,WACI;YAEJ,SAAS,IAAMD;YACd,GAAGC,kBAAkB;yBAEtB,oBAACC,MAAIA,MAAEX,YAAY;AAO/C"}
|
|
@@ -72,9 +72,9 @@ const Checkbox = ({ model, toggle, selected })=>{
|
|
|
72
72
|
};
|
|
73
73
|
const Container = ({ model, children })=>{
|
|
74
74
|
if (model.imported) return /*#__PURE__*/ react.createElement(ContainerImported, null, children);
|
|
75
|
-
if ("create" === model.action) return /*#__PURE__*/ react.createElement(ContainerCreate, null, children);
|
|
76
|
-
if ("update" === model.action) return /*#__PURE__*/ react.createElement(ContainerUpdate, null, children);
|
|
77
|
-
if (model.error) return /*#__PURE__*/ react.createElement(ContainerError, null, children);
|
|
75
|
+
else if ("create" === model.action) return /*#__PURE__*/ react.createElement(ContainerCreate, null, children);
|
|
76
|
+
else if ("update" === model.action) return /*#__PURE__*/ react.createElement(ContainerUpdate, null, children);
|
|
77
|
+
else if (model.error) return /*#__PURE__*/ react.createElement(ContainerError, null, children);
|
|
78
78
|
return /*#__PURE__*/ react.createElement(ContainerBase, null, children);
|
|
79
79
|
};
|
|
80
80
|
const DataListModelItem = ({ model, toggle, selected })=>/*#__PURE__*/ react.createElement(Container, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItem.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItem.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\nimport { DataListModelItemError } from \"./DataListModelItemError.js\";\nimport { DataListModelItemInfo } from \"./DataListModelItemInfo.js\";\n\ntype ToggleModelCb = (item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">) => void;\n\nconst ContainerBase = styled(\"div\")(() => {\n return {\n width: \"100%\",\n padding: \"0px 5px 15px 5px\",\n margin: \"0\",\n boxSizing: \"border-box\" as const,\n \"&:last-child\": {\n paddingBottom: \"2px\"\n }\n };\n});\nconst ContainerCreate = styled(ContainerBase)(() => {\n return {\n // backgroundColor: \"var(--mdc-theme-secondary)\"\n };\n});\nconst ContainerImported = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerUpdate = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerError = styled(ContainerBase)(() => {\n return {};\n});\n\nconst ModelContainer = styled(\"div\")({\n display: \"flex\",\n width: \"100%\",\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"space-between\"\n});\nconst Name = styled(\"h4\")({\n fontSize: \"12px\",\n flex: \"1 0 auto\",\n lineHeight: \"18px\"\n});\nconst CheckboxContainer = styled(\"div\")({\n width: \"120px\",\n textAlign: \"right\",\n verticalAlign: \"middle\"\n});\n\nconst Button = styled(\"button\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n cursor: \"pointer\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-background)\",\n \"&.selected\": {\n border: \"1px solid var(--mdc-theme-secondary)\"\n }\n});\n\nconst ImportedText = styled(\"div\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-secondary)\",\n color: \"#FFF\"\n});\n\nconst Imported = () => {\n return (\n <CheckboxContainer>\n <ImportedText>Imported.</ImportedText>\n </CheckboxContainer>\n );\n};\n\ninterface CheckboxProps {\n model: Pick<ImportModelData, \"id\" | \"name\" | \"error\" | \"related\">;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nconst Checkbox = ({ model, toggle, selected }: CheckboxProps) => {\n const onClick = useCallback(() => {\n toggle(model);\n }, [toggle]);\n if (model.error) {\n return null;\n }\n return (\n <CheckboxContainer>\n <Button onClick={onClick} className={selected ? \"selected\" : \"\"}>\n {selected ? \"Model will be imported\" : \"Model will be skipped\"}\n </Button>\n </CheckboxContainer>\n );\n};\n\ninterface ContainerProps {\n model: Pick<ImportModelData, \"action\" | \"error\" | \"imported\">;\n children: React.ReactNode;\n}\n\nconst Container = ({ model, children }: ContainerProps) => {\n if (model.imported) {\n return <ContainerImported>{children}</ContainerImported>;\n } else if (model.action === \"create\") {\n return <ContainerCreate>{children}</ContainerCreate>;\n } else if (model.action === \"update\") {\n return <ContainerUpdate>{children}</ContainerUpdate>;\n } else if (model.error) {\n return <ContainerError>{children}</ContainerError>;\n }\n return <ContainerBase>{children}</ContainerBase>;\n};\n\ninterface DataListModelItemProps {\n model: ImportModelData;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nexport const DataListModelItem = ({ model, toggle, selected }: DataListModelItemProps) => {\n return (\n <Container model={model}>\n <ModelContainer>\n <div>\n <Name>{model.name || model.id}</Name>\n {model.error ? (\n <DataListModelItemError error={model.error} />\n ) : (\n <DataListModelItemInfo model={model} />\n )}\n </div>\n {model.imported ? (\n <Imported />\n ) : (\n <Checkbox model={model} toggle={toggle} selected={selected} />\n )}\n </ModelContainer>\n </Container>\n );\n};\n"],"names":["ContainerBase","styled","ContainerCreate","ContainerImported","ContainerUpdate","ContainerError","ModelContainer","Name","CheckboxContainer","Button","ImportedText","Imported","Checkbox","model","toggle","selected","onClick","useCallback","Container","children","DataListModelItem","DataListModelItemError","DataListModelItemInfo"],"mappings":";;;;AAQA,MAAMA,gBAAgBC,OAAO,OAAO,IACzB;QACH,OAAO;QACP,SAAS;QACT,QAAQ;QACR,WAAW;QACX,gBAAgB;YACZ,eAAe;QACnB;IACJ;AAEJ,MAAMC,kBAAkBD,OAAOD,eAAe,IACnC,EAEP;AAEJ,MAAMG,oBAAoBF,OAAOD,eAAe,IACrC,EAAC;AAEZ,MAAMI,kBAAkBH,OAAOD,eAAe,IACnC,EAAC;AAEZ,MAAMK,iBAAiBJ,OAAOD,eAAe,IAClC,EAAC;AAGZ,MAAMM,iBAAiBL,OAAO,OAAO;IACjC,SAAS;IACT,OAAO;IACP,eAAe;IACf,YAAY;IACZ,gBAAgB;AACpB;AACA,MAAMM,OAAON,OAAO,MAAM;IACtB,UAAU;IACV,MAAM;IACN,YAAY;AAChB;AACA,MAAMO,oBAAoBP,OAAO,OAAO;IACpC,OAAO;IACP,WAAW;IACX,eAAe;AACnB;AAEA,MAAMQ,SAASR,OAAO,UAAU;IAC5B,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,iBAAiB;IACjB,cAAc;QACV,QAAQ;IACZ;AACJ;AAEA,MAAMS,eAAeT,OAAO,OAAO;IAC/B,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,SAAS;IACT,iBAAiB;IACjB,OAAO;AACX;AAEA,MAAMU,WAAW,IACN,WAAP,GACI,oBAACH,mBAAiBA,MAAAA,WAAAA,GACd,oBAACE,cAAYA,MAAC;AAW1B,MAAME,WAAW,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAiB;IACxD,MAAMC,UAAUC,YAAY;QACxBH,OAAOD;IACX,GAAG;QAACC;KAAO;IACX,IAAID,MAAM,KAAK,EACX,OAAO;IAEX,OAAO,WAAP,GACI,oBAACL,mBAAiBA,MAAAA,WAAAA,GACd,oBAACC,QAAMA;QAAC,SAASO;QAAS,WAAWD,WAAW,aAAa;OACxDA,WAAW,2BAA2B;AAIvD;AAOA,MAAMG,YAAY,CAAC,EAAEL,KAAK,EAAEM,QAAQ,EAAkB;IAClD,IAAIN,MAAM,QAAQ,EACd,OAAO,WAAP,GAAO,oBAACV,mBAAiBA,MAAEgB;
|
|
1
|
+
{"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItem.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItem.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\nimport { DataListModelItemError } from \"./DataListModelItemError.js\";\nimport { DataListModelItemInfo } from \"./DataListModelItemInfo.js\";\n\ntype ToggleModelCb = (item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">) => void;\n\nconst ContainerBase = styled(\"div\")(() => {\n return {\n width: \"100%\",\n padding: \"0px 5px 15px 5px\",\n margin: \"0\",\n boxSizing: \"border-box\" as const,\n \"&:last-child\": {\n paddingBottom: \"2px\"\n }\n };\n});\nconst ContainerCreate = styled(ContainerBase)(() => {\n return {\n // backgroundColor: \"var(--mdc-theme-secondary)\"\n };\n});\nconst ContainerImported = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerUpdate = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerError = styled(ContainerBase)(() => {\n return {};\n});\n\nconst ModelContainer = styled(\"div\")({\n display: \"flex\",\n width: \"100%\",\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"space-between\"\n});\nconst Name = styled(\"h4\")({\n fontSize: \"12px\",\n flex: \"1 0 auto\",\n lineHeight: \"18px\"\n});\nconst CheckboxContainer = styled(\"div\")({\n width: \"120px\",\n textAlign: \"right\",\n verticalAlign: \"middle\"\n});\n\nconst Button = styled(\"button\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n cursor: \"pointer\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-background)\",\n \"&.selected\": {\n border: \"1px solid var(--mdc-theme-secondary)\"\n }\n});\n\nconst ImportedText = styled(\"div\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-secondary)\",\n color: \"#FFF\"\n});\n\nconst Imported = () => {\n return (\n <CheckboxContainer>\n <ImportedText>Imported.</ImportedText>\n </CheckboxContainer>\n );\n};\n\ninterface CheckboxProps {\n model: Pick<ImportModelData, \"id\" | \"name\" | \"error\" | \"related\">;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nconst Checkbox = ({ model, toggle, selected }: CheckboxProps) => {\n const onClick = useCallback(() => {\n toggle(model);\n }, [toggle]);\n if (model.error) {\n return null;\n }\n return (\n <CheckboxContainer>\n <Button onClick={onClick} className={selected ? \"selected\" : \"\"}>\n {selected ? \"Model will be imported\" : \"Model will be skipped\"}\n </Button>\n </CheckboxContainer>\n );\n};\n\ninterface ContainerProps {\n model: Pick<ImportModelData, \"action\" | \"error\" | \"imported\">;\n children: React.ReactNode;\n}\n\nconst Container = ({ model, children }: ContainerProps) => {\n if (model.imported) {\n return <ContainerImported>{children}</ContainerImported>;\n } else if (model.action === \"create\") {\n return <ContainerCreate>{children}</ContainerCreate>;\n } else if (model.action === \"update\") {\n return <ContainerUpdate>{children}</ContainerUpdate>;\n } else if (model.error) {\n return <ContainerError>{children}</ContainerError>;\n }\n return <ContainerBase>{children}</ContainerBase>;\n};\n\ninterface DataListModelItemProps {\n model: ImportModelData;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nexport const DataListModelItem = ({ model, toggle, selected }: DataListModelItemProps) => {\n return (\n <Container model={model}>\n <ModelContainer>\n <div>\n <Name>{model.name || model.id}</Name>\n {model.error ? (\n <DataListModelItemError error={model.error} />\n ) : (\n <DataListModelItemInfo model={model} />\n )}\n </div>\n {model.imported ? (\n <Imported />\n ) : (\n <Checkbox model={model} toggle={toggle} selected={selected} />\n )}\n </ModelContainer>\n </Container>\n );\n};\n"],"names":["ContainerBase","styled","ContainerCreate","ContainerImported","ContainerUpdate","ContainerError","ModelContainer","Name","CheckboxContainer","Button","ImportedText","Imported","Checkbox","model","toggle","selected","onClick","useCallback","Container","children","DataListModelItem","DataListModelItemError","DataListModelItemInfo"],"mappings":";;;;AAQA,MAAMA,gBAAgBC,OAAO,OAAO,IACzB;QACH,OAAO;QACP,SAAS;QACT,QAAQ;QACR,WAAW;QACX,gBAAgB;YACZ,eAAe;QACnB;IACJ;AAEJ,MAAMC,kBAAkBD,OAAOD,eAAe,IACnC,EAEP;AAEJ,MAAMG,oBAAoBF,OAAOD,eAAe,IACrC,EAAC;AAEZ,MAAMI,kBAAkBH,OAAOD,eA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AACX,iBAAeA,MAAEiB;SACtB,IAAIN,AAAiB,aAAjBA,MAAM,MAAM,EACnB,OAAO,WAAP,GAAO,oBAACT,iBAAeA,MAAEe;SACtB,IAAIN,MAAM,KAAK,EAClB,OAAO,WAAP,GAAO,oBAACR,gBAAcA,MAAEc;IAE5B,OAAO,WAAP,GAAO,oBAACnB,eAAaA,MAAEmB;AAC3B;AAQO,MAAMC,oBAAoB,CAAC,EAAEP,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAA0B,GAC1E,WAAP,GACI,oBAACG,WAASA;QAAC,OAAOL;qBACd,oBAACP,gBAAcA,MAAAA,WAAAA,GACX,oBAAC,2BACG,oBAACC,MAAIA,MAAEM,MAAM,IAAI,IAAIA,MAAM,EAAE,GAC5BA,MAAM,KAAK,GAAG,WAAH,GACR,oBAACQ,wBAAsBA;QAAC,OAAOR,MAAM,KAAK;uBAE1C,oBAACS,uBAAqBA;QAAC,OAAOT;SAGrCA,MAAM,QAAQ,GAAG,WAAH,GACX,oBAACF,UAAQA,QAAAA,WAAAA,GAET,oBAACC,UAAQA;QAAC,OAAOC;QAAO,QAAQC;QAAQ,UAAUC"}
|
|
@@ -9,8 +9,8 @@ const Text = styled("p")({
|
|
|
9
9
|
});
|
|
10
10
|
const getText = (action)=>{
|
|
11
11
|
if ("create" === action) return "Model will be created.";
|
|
12
|
-
if ("update" === action) return "Model will be updated.";
|
|
13
|
-
if ("code" === action) return "Model cannot be updated because it was created via code.";
|
|
12
|
+
else if ("update" === action) return "Model will be updated.";
|
|
13
|
+
else if ("code" === action) return "Model cannot be updated because it was created via code.";
|
|
14
14
|
return `Unknown action: ${action}`;
|
|
15
15
|
};
|
|
16
16
|
const DataListModelItemInfo = ({ model })=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItemInfo.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItemInfo.tsx"],"sourcesContent":["import React from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\n\nconst Text = styled(\"p\")({\n fontSize: \"9px\",\n lineHeight: \"10px\",\n display: \"block\",\n padding: \"0\",\n margin: \"0\"\n});\n\nconst getText = (action?: string | null) => {\n if (action === \"create\") {\n return `Model will be created.`;\n } else if (action === \"update\") {\n return `Model will be updated.`;\n } else if (action === \"code\") {\n return \"Model cannot be updated because it was created via code.\";\n }\n return `Unknown action: ${action}`;\n};\n\ninterface DataListModelItemInfoProps {\n model: ImportModelData;\n}\n\nexport const DataListModelItemInfo = ({ model }: DataListModelItemInfoProps) => {\n const { action } = model;\n\n return <Text>{getText(action)}</Text>;\n};\n"],"names":["Text","styled","getText","action","DataListModelItemInfo","model"],"mappings":";;AAIA,MAAMA,OAAOC,OAAO,KAAK;IACrB,UAAU;IACV,YAAY;IACZ,SAAS;IACT,SAAS;IACT,QAAQ;AACZ;AAEA,MAAMC,UAAU,CAACC;IACb,IAAIA,AAAW,aAAXA,QACA,OAAO;
|
|
1
|
+
{"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItemInfo.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItemInfo.tsx"],"sourcesContent":["import React from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\n\nconst Text = styled(\"p\")({\n fontSize: \"9px\",\n lineHeight: \"10px\",\n display: \"block\",\n padding: \"0\",\n margin: \"0\"\n});\n\nconst getText = (action?: string | null) => {\n if (action === \"create\") {\n return `Model will be created.`;\n } else if (action === \"update\") {\n return `Model will be updated.`;\n } else if (action === \"code\") {\n return \"Model cannot be updated because it was created via code.\";\n }\n return `Unknown action: ${action}`;\n};\n\ninterface DataListModelItemInfoProps {\n model: ImportModelData;\n}\n\nexport const DataListModelItemInfo = ({ model }: DataListModelItemInfoProps) => {\n const { action } = model;\n\n return <Text>{getText(action)}</Text>;\n};\n"],"names":["Text","styled","getText","action","DataListModelItemInfo","model"],"mappings":";;AAIA,MAAMA,OAAOC,OAAO,KAAK;IACrB,UAAU;IACV,YAAY;IACZ,SAAS;IACT,SAAS;IACT,QAAQ;AACZ;AAEA,MAAMC,UAAU,CAACC;IACb,IAAIA,AAAW,aAAXA,QACA,OAAO;SACJ,IAAIA,AAAW,aAAXA,QACP,OAAO;SACJ,IAAIA,AAAW,WAAXA,QACP,OAAO;IAEX,OAAO,CAAC,gBAAgB,EAAEA,QAAQ;AACtC;AAMO,MAAMC,wBAAwB,CAAC,EAAEC,KAAK,EAA8B;IACvE,MAAM,EAAEF,MAAM,EAAE,GAAGE;IAEnB,OAAO,WAAP,GAAO,oBAACL,MAAIA,MAAEE,QAAQC;AAC1B"}
|
|
@@ -3,7 +3,7 @@ import type { ImportModelData } from "../../types.js";
|
|
|
3
3
|
interface DataListModelsProps {
|
|
4
4
|
models: ImportModelData[];
|
|
5
5
|
}
|
|
6
|
-
export declare const DataListModels: (({ models }: DataListModelsProps) => React.JSX.Element) & {
|
|
7
|
-
|
|
6
|
+
export declare const DataListModels: (({ models }: DataListModelsProps) => React.JSX.Element) & React.NamedExoticComponent<DataListModelsProps> & {
|
|
7
|
+
readonly type: ({ models }: DataListModelsProps) => React.JSX.Element;
|
|
8
8
|
};
|
|
9
9
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const ContentGroupsMenuItems: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const ContentGroupsMenuItems: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|