@webiny/app-headless-cms 6.5.0-beta.3 → 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.
Files changed (154) hide show
  1. package/ContentEntriesModule.js +9 -2
  2. package/ContentEntriesModule.js.map +1 -1
  3. package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
  4. package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
  5. package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
  6. package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
  7. package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
  8. package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
  9. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
  10. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
  11. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.d.ts +2 -0
  12. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js +34 -0
  13. package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js.map +1 -0
  14. package/admin/components/ContentEntries/Table/Actions/index.d.ts +1 -0
  15. package/admin/components/ContentEntries/Table/Actions/index.js +1 -0
  16. package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
  17. package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
  18. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.d.ts +2 -0
  19. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js +22 -0
  20. package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js.map +1 -0
  21. package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
  22. package/admin/components/FieldEditor/Field.js +4 -4
  23. package/admin/components/FieldEditor/Field.js.map +1 -1
  24. package/features/contentEntry/CmsEntryError.d.ts +10 -0
  25. package/features/contentEntry/CmsEntryError.js +11 -0
  26. package/features/contentEntry/CmsEntryError.js.map +1 -0
  27. package/features/contentEntry/createEntry/CreateEntryGateway.d.ts +0 -1
  28. package/features/contentEntry/createEntry/CreateEntryGateway.js +3 -10
  29. package/features/contentEntry/createEntry/CreateEntryGateway.js.map +1 -1
  30. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.d.ts +3 -1
  31. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js +8 -3
  32. package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js.map +1 -1
  33. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.d.ts +14 -0
  34. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js +43 -0
  35. package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js.map +1 -0
  36. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.d.ts +15 -0
  37. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js +34 -0
  38. package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js.map +1 -0
  39. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.d.ts +11 -0
  40. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js +18 -0
  41. package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js.map +1 -0
  42. package/features/contentEntry/duplicateEntry/abstractions.d.ts +26 -0
  43. package/features/contentEntry/duplicateEntry/abstractions.js +7 -0
  44. package/features/contentEntry/duplicateEntry/abstractions.js.map +1 -0
  45. package/features/contentEntry/duplicateEntry/feature.d.ts +3 -0
  46. package/features/contentEntry/duplicateEntry/feature.js +21 -0
  47. package/features/contentEntry/duplicateEntry/feature.js.map +1 -0
  48. package/features/contentEntry/entryValueGateways.test.d.ts +1 -0
  49. package/features/contentEntry/entryValueGateways.test.js +106 -0
  50. package/features/contentEntry/entryValueGateways.test.js.map +1 -0
  51. package/features/contentEntry/feature.js +2 -0
  52. package/features/contentEntry/feature.js.map +1 -1
  53. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.d.ts +0 -1
  54. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js +3 -10
  55. package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js.map +1 -1
  56. package/features/contentEntry/updateEntry/UpdateEntryGateway.d.ts +0 -1
  57. package/features/contentEntry/updateEntry/UpdateEntryGateway.js +3 -10
  58. package/features/contentEntry/updateEntry/UpdateEntryGateway.js.map +1 -1
  59. package/features/contentEntry/valueTransformers/EntryDataPreparer.d.ts +9 -0
  60. package/features/contentEntry/valueTransformers/EntryDataPreparer.js +8 -0
  61. package/features/contentEntry/valueTransformers/EntryDataPreparer.js.map +1 -1
  62. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.d.ts +1 -0
  63. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js +113 -0
  64. package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js.map +1 -0
  65. package/features/contentEntry/valueTransformers/entryValueFixtures.d.ts +146 -0
  66. package/features/contentEntry/valueTransformers/entryValueFixtures.js +171 -0
  67. package/features/contentEntry/valueTransformers/entryValueFixtures.js.map +1 -0
  68. package/features/formModel/CmsFormModelBuilder.d.ts +8 -0
  69. package/features/formModel/CmsFormModelBuilder.js +25 -2
  70. package/features/formModel/CmsFormModelBuilder.js.map +1 -1
  71. package/features/formModel/CmsFormModelBuilder.test.d.ts +1 -0
  72. package/features/formModel/CmsFormModelBuilder.test.js +111 -0
  73. package/features/formModel/CmsFormModelBuilder.test.js.map +1 -0
  74. package/features/formModel/mappers/DynamicZoneFieldMapper.js +1 -0
  75. package/features/formModel/mappers/DynamicZoneFieldMapper.js.map +1 -1
  76. package/features/model/exportModels/ExportModelsGateway.d.ts +1 -1
  77. package/features/model/exportModels/ExportModelsGateway.js.map +1 -1
  78. package/features/model/exportModels/ExportModelsUseCase.js +7 -1
  79. package/features/model/exportModels/ExportModelsUseCase.js.map +1 -1
  80. package/features/model/exportModels/abstractions.d.ts +8 -2
  81. package/features/model/exportModels/abstractions.js.map +1 -1
  82. package/package.json +26 -26
  83. package/presentation/contentEntries/form/ContentEntryFormPresenter.js +3 -1
  84. package/presentation/contentEntries/form/ContentEntryFormPresenter.js.map +1 -1
  85. package/presentation/contentEntries/form/toFormErrors.d.ts +7 -0
  86. package/presentation/contentEntries/form/toFormErrors.js +49 -0
  87. package/presentation/contentEntries/form/toFormErrors.js.map +1 -0
  88. package/presentation/contentEntries/form/toFormErrors.test.d.ts +1 -0
  89. package/presentation/contentEntries/form/toFormErrors.test.js +175 -0
  90. package/presentation/contentEntries/form/toFormErrors.test.js.map +1 -0
  91. package/presentation/contentEntries/list/ContentEntriesPresenter.d.ts +6 -2
  92. package/presentation/contentEntries/list/ContentEntriesPresenter.js +27 -2
  93. package/presentation/contentEntries/list/ContentEntriesPresenter.js.map +1 -1
  94. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +58 -1
  95. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
  96. package/presentation/contentEntries/list/abstractions.d.ts +12 -0
  97. package/presentation/contentEntries/list/abstractions.js.map +1 -1
  98. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js +3 -1
  99. package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js.map +1 -1
  100. package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
  101. package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
  102. package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
  103. package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
  104. package/presentation/contentEntries/views/OlderRevisionAlert.d.ts +2 -2
  105. package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
  106. package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
  107. package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
  108. package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
  109. package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
  110. package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
  111. package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
  112. package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
  113. package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
  114. package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
  115. package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
  116. package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
  117. package/presentation/contentModels/ContentModelsPresenter.d.ts +5 -5
  118. package/presentation/contentModels/ContentModelsPresenter.js +1 -1
  119. package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
  120. package/presentation/contentModels/abstractions.d.ts +7 -2
  121. package/presentation/contentModels/abstractions.js.map +1 -1
  122. package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
  123. package/presentation/contentModels/components/ContentModels.d.ts +2 -2
  124. package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
  125. package/presentation/contentModels/components/ContentModelsDataList.js +6 -5
  126. package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
  127. package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
  128. package/presentation/contentModels/components/fullDelete/dialog/Content.js +2 -2
  129. package/presentation/contentModels/components/fullDelete/dialog/Content.js.map +1 -1
  130. package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
  131. package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
  132. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js +3 -2
  133. package/presentation/fieldRenderers/ref/components/RefFieldOptions.js.map +1 -1
  134. package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
  135. package/presentation/importContentModels/ImportContentModelsPresenter.js +1 -1
  136. package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
  137. package/presentation/importContentModels/components/DataList.d.ts +2 -2
  138. package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
  139. package/presentation/importContentModels/components/FileUpload.js +1 -1
  140. package/presentation/importContentModels/components/FileUpload.js.map +1 -1
  141. package/presentation/importContentModels/components/Model/DataListModelItem.js +3 -3
  142. package/presentation/importContentModels/components/Model/DataListModelItem.js.map +1 -1
  143. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js +2 -2
  144. package/presentation/importContentModels/components/Model/DataListModelItemInfo.js.map +1 -1
  145. package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
  146. package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
  147. package/presentation/modelGroup/ModelGroupPresenter.js +1 -2
  148. package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
  149. package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
  150. package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
  151. package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
  152. package/utils/normalizeIcon.d.ts +4 -0
  153. package/utils/normalizeIcon.js +9 -6
  154. package/utils/normalizeIcon.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"presentation/modelGroup/ModelGroupPresenter.js","sources":["../../../src/presentation/modelGroup/ModelGroupPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction, computed } from \"mobx\";\nimport slugify from \"slugify\";\nimport { ListPresenter } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport { FormModelFactory } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { IFormModel } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { ModelGroupDto } from \"~/features/modelGroup/listModelGroups/abstractions.js\";\nimport { ListModelGroupsUseCase } from \"~/features/modelGroup/listModelGroups/abstractions.js\";\nimport { GetModelGroupUseCase } from \"~/features/modelGroup/getModelGroup/abstractions.js\";\nimport { CreateModelGroupUseCase } from \"~/features/modelGroup/createModelGroup/abstractions.js\";\nimport { UpdateModelGroupUseCase } from \"~/features/modelGroup/updateModelGroup/abstractions.js\";\nimport { DeleteModelGroupUseCase } from \"~/features/modelGroup/deleteModelGroup/abstractions.js\";\nimport { ModelGroupsCache } from \"~/features/modelGroup/abstractions.js\";\nimport {\n ModelGroupPresenter as Abstraction,\n type IModelGroupPresenter,\n type IModelGroupPresenterViewModel\n} from \"./abstractions.js\";\nimport { ModelGroupDataSource } from \"./ModelGroupDataSource.js\";\n\nfunction extractIconName(icon: unknown): string {\n if (icon !== null && typeof icon === \"object\" && \"name\" in icon) {\n return (icon as { name: string }).name;\n }\n if (typeof icon === \"string\") {\n return icon;\n }\n return \"\";\n}\n\nfunction toIconValue(name: string): { type: string; name: string } {\n return { type: \"icon\", name };\n}\n\nclass ModelGroupPresenterImpl implements IModelGroupPresenter {\n private selectedGroup: ModelGroupDto | null = null;\n private loading = false;\n private saving = false;\n private showForm = false;\n private form: IFormModel;\n\n constructor(\n private listPresenter: ListPresenter.Interface<ModelGroupDto>,\n private formModelFactory: FormModelFactory.Interface,\n private listModelGroupsUseCase: ListModelGroupsUseCase.Interface,\n private getRoleUseCase: GetModelGroupUseCase.Interface,\n private createModelGroupUseCase: CreateModelGroupUseCase.Interface,\n private updateModelGroupUseCase: UpdateModelGroupUseCase.Interface,\n private deleteModelGroupUseCase: DeleteModelGroupUseCase.Interface,\n private cache: ModelGroupsCache.Interface\n ) {\n this.form = this.buildForm(false, false);\n makeAutoObservable<\n ModelGroupPresenterImpl,\n | \"formModelFactory\"\n | \"listModelGroupsUseCase\"\n | \"getRoleUseCase\"\n | \"createModelGroupUseCase\"\n | \"updateModelGroupUseCase\"\n | \"deleteModelGroupUseCase\"\n | \"cache\"\n >(this, {\n formModelFactory: false,\n listModelGroupsUseCase: false,\n getRoleUseCase: false,\n createModelGroupUseCase: false,\n updateModelGroupUseCase: false,\n deleteModelGroupUseCase: false,\n cache: false,\n vm: computed\n });\n }\n\n get vm(): IModelGroupPresenterViewModel {\n const group = this.selectedGroup;\n const isPluginGroup = group !== null && (group.plugin ?? false);\n\n return {\n selectedGroup: this.selectedGroup,\n loading: this.loading,\n saving: this.saving,\n showForm: this.showForm,\n canModify: !isPluginGroup,\n isPluginGroup,\n form: this.form.vm\n };\n }\n\n get list(): ListPresenter.Interface<ModelGroupDto> {\n return this.listPresenter;\n }\n\n init(): void {\n const dataSource = new ModelGroupDataSource(this.listModelGroupsUseCase, this.cache);\n\n this.listPresenter.init({\n dataSource,\n initialSort: { field: \"createdOn\", direction: \"DESC\" },\n limit: 1000\n });\n }\n\n async selectGroup(id: string): Promise<void> {\n runInAction(() => {\n this.loading = true;\n this.showForm = true;\n });\n\n try {\n const group = await this.getRoleUseCase.execute(id);\n const isPluginGroup = group.plugin ?? false;\n const canModify = !isPluginGroup;\n\n runInAction(() => {\n this.selectedGroup = group;\n this.form = this.buildForm(false, canModify);\n this.form.setData({\n name: group.name,\n slug: group.slug,\n description: group.description,\n icon: extractIconName(group.icon)\n });\n });\n } finally {\n runInAction(() => {\n this.loading = false;\n });\n }\n }\n\n createNew(): void {\n this.selectedGroup = null;\n this.form = this.buildForm(true, true);\n this.form.setData({ icon: \"fas/star\", description: \"\" });\n this.showForm = true;\n }\n\n deselect(): void {\n this.selectedGroup = null;\n this.showForm = false;\n }\n\n async save(): Promise<ModelGroupDto | null> {\n const data = await this.form.submit<ModelGroupDto>();\n if (!data) {\n return null;\n }\n\n runInAction(() => {\n this.saving = true;\n });\n\n try {\n const isUpdate = this.selectedGroup !== null && this.selectedGroup.createdOn;\n\n const iconValue = toIconValue(data.icon as unknown as string);\n\n if (isUpdate) {\n const group = await this.updateModelGroupUseCase.execute({\n id: this.selectedGroup!.id,\n name: data.name as unknown as string,\n slug: this.selectedGroup!.slug,\n description: data.description as unknown as string,\n icon: iconValue as unknown as string\n });\n runInAction(() => {\n this.selectedGroup = group;\n });\n return group;\n } else {\n const group = await this.createModelGroupUseCase.execute({\n name: data.name as unknown as string,\n slug: data.slug as unknown as string,\n description: data.description as unknown as string,\n icon: iconValue as unknown as string\n });\n runInAction(() => {\n this.selectedGroup = group;\n this.form = this.buildForm(false, true);\n this.form.setData({\n name: group.name,\n slug: group.slug,\n description: group.description,\n icon: extractIconName(group.icon)\n });\n });\n return group;\n }\n } catch {\n return null;\n } finally {\n runInAction(() => {\n this.saving = false;\n });\n }\n }\n\n async deleteGroup(id: string): Promise<void> {\n await this.deleteModelGroupUseCase.execute(id);\n\n runInAction(() => {\n if (this.selectedGroup !== null && this.selectedGroup.id === id) {\n this.selectedGroup = null;\n this.showForm = false;\n }\n });\n }\n\n private buildForm(isNew: boolean, canModify: boolean): IFormModel {\n return this.formModelFactory.create({\n fields: fields => ({\n name: fields\n .text()\n .label(\"Name\")\n .required(\"Name is required.\")\n .disabled(!canModify)\n .onBlur((value, { form }) => {\n const slugValue = form.field(\"slug\").getValue();\n if (slugValue || !value) {\n return;\n }\n form.field(\"slug\").setValue(\n slugify(String(value), {\n replacement: \"-\",\n lower: true,\n remove: /[*#?<>_{}[\\]+~.()'\"!:;@]/g,\n trim: false\n })\n );\n }),\n slug: fields\n .text()\n .label(\"Slug\")\n .required(\"Slug is required.\")\n .disabled(!isNew || !canModify),\n icon: fields\n .text()\n .label(\"Group icon\")\n .required(\"Icon is required.\")\n .disabled(!canModify)\n .renderer(\"cmsIconPicker\"),\n description: fields\n .text()\n .label(\"Description\")\n .defaultValue(\"\")\n .renderer(\"textarea\")\n .disabled(!canModify)\n }),\n layout: layout => [\n layout.row(\"name\"),\n layout.row(\"slug\"),\n layout.row(\"icon\"),\n layout.row(\"description\")\n ]\n });\n }\n}\n\nexport const ModelGroupPresenter = Abstraction.createImplementation({\n implementation: ModelGroupPresenterImpl,\n dependencies: [\n ListPresenter,\n FormModelFactory,\n ListModelGroupsUseCase,\n GetModelGroupUseCase,\n CreateModelGroupUseCase,\n UpdateModelGroupUseCase,\n DeleteModelGroupUseCase,\n ModelGroupsCache\n ]\n});\n"],"names":["extractIconName","icon","toIconValue","name","ModelGroupPresenterImpl","listPresenter","formModelFactory","listModelGroupsUseCase","getRoleUseCase","createModelGroupUseCase","updateModelGroupUseCase","deleteModelGroupUseCase","cache","makeAutoObservable","computed","group","isPluginGroup","dataSource","ModelGroupDataSource","id","runInAction","canModify","data","isUpdate","iconValue","isNew","fields","value","form","slugValue","slugify","String","layout","ModelGroupPresenter","Abstraction","ListPresenter","FormModelFactory","ListModelGroupsUseCase","GetModelGroupUseCase","CreateModelGroupUseCase","UpdateModelGroupUseCase","DeleteModelGroupUseCase","ModelGroupsCache"],"mappings":";;;;;;;;;;;;AAmBA,SAASA,gBAAgBC,IAAa;IAClC,IAAIA,AAAS,SAATA,QAAiB,AAAgB,YAAhB,OAAOA,QAAqB,UAAUA,MACvD,OAAQA,KAA0B,IAAI;IAE1C,IAAI,AAAgB,YAAhB,OAAOA,MACP,OAAOA;IAEX,OAAO;AACX;AAEA,SAASC,YAAYC,IAAY;IAC7B,OAAO;QAAE,MAAM;QAAQA;IAAK;AAChC;AAEA,MAAMC;IAOF,YACYC,aAAqD,EACrDC,gBAA4C,EAC5CC,sBAAwD,EACxDC,cAA8C,EAC9CC,uBAA0D,EAC1DC,uBAA0D,EAC1DC,uBAA0D,EAC1DC,KAAiC,CAC3C;aARUP,aAAa,GAAbA;aACAC,gBAAgB,GAAhBA;aACAC,sBAAsB,GAAtBA;aACAC,cAAc,GAAdA;aACAC,uBAAuB,GAAvBA;aACAC,uBAAuB,GAAvBA;aACAC,uBAAuB,GAAvBA;aACAC,KAAK,GAALA;aAdJ,aAAa,GAAyB;aACtC,OAAO,GAAG;aACV,MAAM,GAAG;aACT,QAAQ,GAAG;QAaf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO;QAClCC,mBASE,IAAI,EAAE;YACJ,kBAAkB;YAClB,wBAAwB;YACxB,gBAAgB;YAChB,yBAAyB;YACzB,yBAAyB;YACzB,yBAAyB;YACzB,OAAO;YACP,IAAIC;QACR;IACJ;IAEA,IAAI,KAAoC;QACpC,MAAMC,QAAQ,IAAI,CAAC,aAAa;QAChC,MAAMC,gBAAgBD,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O,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;iBACd;QACL;IACJ;AACJ;AAEO,MAAMC,0CAAsBC,oBAAAA,oBAAgC,CAAC;IAChE,gBAAgB9B;IAChB,cAAc;QACV+B;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"presentation/modelGroup/ModelGroupPresenter.js","sources":["../../../src/presentation/modelGroup/ModelGroupPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction, computed } from \"mobx\";\nimport slugify from \"slugify\";\nimport { ListPresenter } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport { FormModelFactory } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { IFormModel } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport type { ModelGroupDto } from \"~/features/modelGroup/listModelGroups/abstractions.js\";\nimport { ListModelGroupsUseCase } from \"~/features/modelGroup/listModelGroups/abstractions.js\";\nimport { GetModelGroupUseCase } from \"~/features/modelGroup/getModelGroup/abstractions.js\";\nimport { CreateModelGroupUseCase } from \"~/features/modelGroup/createModelGroup/abstractions.js\";\nimport { UpdateModelGroupUseCase } from \"~/features/modelGroup/updateModelGroup/abstractions.js\";\nimport { DeleteModelGroupUseCase } from \"~/features/modelGroup/deleteModelGroup/abstractions.js\";\nimport { ModelGroupsCache } from \"~/features/modelGroup/abstractions.js\";\nimport {\n ModelGroupPresenter as Abstraction,\n type IModelGroupPresenter,\n type IModelGroupPresenterViewModel\n} from \"./abstractions.js\";\nimport { ModelGroupDataSource } from \"./ModelGroupDataSource.js\";\n\nfunction extractIconName(icon: unknown): string {\n if (icon !== null && typeof icon === \"object\" && \"name\" in icon) {\n return (icon as { name: string }).name;\n }\n if (typeof icon === \"string\") {\n return icon;\n }\n return \"\";\n}\n\nfunction toIconValue(name: string): { type: string; name: string } {\n return { type: \"icon\", name };\n}\n\nclass ModelGroupPresenterImpl implements IModelGroupPresenter {\n private selectedGroup: ModelGroupDto | null = null;\n private loading = false;\n private saving = false;\n private showForm = false;\n private form: IFormModel;\n\n constructor(\n private listPresenter: ListPresenter.Interface<ModelGroupDto>,\n private formModelFactory: FormModelFactory.Interface,\n private listModelGroupsUseCase: ListModelGroupsUseCase.Interface,\n private getRoleUseCase: GetModelGroupUseCase.Interface,\n private createModelGroupUseCase: CreateModelGroupUseCase.Interface,\n private updateModelGroupUseCase: UpdateModelGroupUseCase.Interface,\n private deleteModelGroupUseCase: DeleteModelGroupUseCase.Interface,\n private cache: ModelGroupsCache.Interface\n ) {\n this.form = this.buildForm(false, false);\n makeAutoObservable<\n ModelGroupPresenterImpl,\n | \"formModelFactory\"\n | \"listModelGroupsUseCase\"\n | \"getRoleUseCase\"\n | \"createModelGroupUseCase\"\n | \"updateModelGroupUseCase\"\n | \"deleteModelGroupUseCase\"\n | \"cache\"\n >(this, {\n formModelFactory: false,\n listModelGroupsUseCase: false,\n getRoleUseCase: false,\n createModelGroupUseCase: false,\n updateModelGroupUseCase: false,\n deleteModelGroupUseCase: false,\n cache: false,\n vm: computed\n });\n }\n\n get vm(): IModelGroupPresenterViewModel {\n const group = this.selectedGroup;\n const isPluginGroup = group !== null && (group.plugin ?? false);\n\n return {\n selectedGroup: this.selectedGroup,\n loading: this.loading,\n saving: this.saving,\n showForm: this.showForm,\n canModify: !isPluginGroup,\n isPluginGroup,\n form: this.form.vm\n };\n }\n\n get list(): ListPresenter.Interface<ModelGroupDto> {\n return this.listPresenter;\n }\n\n init(): void {\n const dataSource = new ModelGroupDataSource(this.listModelGroupsUseCase, this.cache);\n\n this.listPresenter.init({\n dataSource,\n initialSort: { field: \"createdOn\", direction: \"DESC\" },\n limit: 1000\n });\n }\n\n async selectGroup(id: string): Promise<void> {\n runInAction(() => {\n this.loading = true;\n this.showForm = true;\n });\n\n try {\n const group = await this.getRoleUseCase.execute(id);\n const isPluginGroup = group.plugin ?? false;\n const canModify = !isPluginGroup;\n\n runInAction(() => {\n this.selectedGroup = group;\n this.form = this.buildForm(false, canModify);\n this.form.setData({\n name: group.name,\n slug: group.slug,\n description: group.description,\n icon: extractIconName(group.icon)\n });\n });\n } finally {\n runInAction(() => {\n this.loading = false;\n });\n }\n }\n\n createNew(): void {\n this.selectedGroup = null;\n this.form = this.buildForm(true, true);\n this.form.setData({ icon: \"fas/star\", description: \"\" });\n this.showForm = true;\n }\n\n deselect(): void {\n this.selectedGroup = null;\n this.showForm = false;\n }\n\n async save(): Promise<ModelGroupDto | null> {\n const data = await this.form.submit<ModelGroupDto>();\n if (!data) {\n return null;\n }\n\n runInAction(() => {\n this.saving = true;\n });\n\n try {\n const isUpdate = this.selectedGroup !== null && this.selectedGroup.createdOn;\n\n const iconValue = toIconValue(data.icon as unknown as string);\n\n if (isUpdate) {\n const group = await this.updateModelGroupUseCase.execute({\n id: this.selectedGroup!.id,\n name: data.name as unknown as string,\n slug: this.selectedGroup!.slug,\n description: data.description as unknown as string,\n icon: iconValue as unknown as string\n });\n runInAction(() => {\n this.selectedGroup = group;\n });\n return group;\n } else {\n const group = await this.createModelGroupUseCase.execute({\n name: data.name as unknown as string,\n slug: data.slug as unknown as string,\n description: data.description as unknown as string,\n icon: iconValue as unknown as string\n });\n runInAction(() => {\n this.selectedGroup = group;\n this.form = this.buildForm(false, true);\n this.form.setData({\n name: group.name,\n slug: group.slug,\n description: group.description,\n icon: extractIconName(group.icon)\n });\n });\n return group;\n }\n } catch {\n return null;\n } finally {\n runInAction(() => {\n this.saving = false;\n });\n }\n }\n\n async deleteGroup(id: string): Promise<void> {\n await this.deleteModelGroupUseCase.execute(id);\n\n runInAction(() => {\n if (this.selectedGroup !== null && this.selectedGroup.id === id) {\n this.selectedGroup = null;\n this.showForm = false;\n }\n });\n }\n\n private buildForm(isNew: boolean, canModify: boolean): IFormModel {\n return this.formModelFactory.create({\n fields: fields => ({\n name: fields\n .text()\n .label(\"Name\")\n .required(\"Name is required.\")\n .disabled(!canModify)\n .onBlur((value, { form }) => {\n const slugValue = form.field(\"slug\").getValue();\n if (slugValue || !value) {\n return;\n }\n form.field(\"slug\").setValue(\n slugify(String(value), {\n replacement: \"-\",\n lower: true,\n remove: /[*#?<>_{}[\\]+~.()'\"!:;@]/g,\n trim: false\n })\n );\n }),\n slug: fields\n .text()\n .label(\"Slug\")\n .required(\"Slug is required.\")\n .disabled(!isNew || !canModify),\n icon: fields\n .text()\n .label(\"Group icon\")\n .required(\"Icon is required.\")\n .disabled(!canModify)\n .renderer(\"cmsIconPicker\"),\n description: fields\n .text()\n .label(\"Description\")\n .defaultValue(\"\")\n .renderer(\"textarea\")\n .disabled(!canModify)\n }),\n layout: layout => [\n layout.row(\"name\"),\n layout.row(\"slug\"),\n layout.row(\"icon\"),\n layout.row(\"description\")\n ]\n });\n }\n}\n\nexport const ModelGroupPresenter = Abstraction.createImplementation({\n implementation: ModelGroupPresenterImpl,\n dependencies: [\n ListPresenter,\n FormModelFactory,\n ListModelGroupsUseCase,\n GetModelGroupUseCase,\n CreateModelGroupUseCase,\n UpdateModelGroupUseCase,\n DeleteModelGroupUseCase,\n ModelGroupsCache\n ]\n});\n"],"names":["extractIconName","icon","toIconValue","name","ModelGroupPresenterImpl","listPresenter","formModelFactory","listModelGroupsUseCase","getRoleUseCase","createModelGroupUseCase","updateModelGroupUseCase","deleteModelGroupUseCase","cache","makeAutoObservable","computed","group","isPluginGroup","dataSource","ModelGroupDataSource","id","runInAction","canModify","data","isUpdate","iconValue","isNew","fields","value","form","slugValue","slugify","String","layout","ModelGroupPresenter","Abstraction","ListPresenter","FormModelFactory","ListModelGroupsUseCase","GetModelGroupUseCase","CreateModelGroupUseCase","UpdateModelGroupUseCase","DeleteModelGroupUseCase","ModelGroupsCache"],"mappings":";;;;;;;;;;;;AAmBA,SAASA,gBAAgBC,IAAa;IAClC,IAAIA,AAAS,SAATA,QAAiB,AAAgB,YAAhB,OAAOA,QAAqB,UAAUA,MACvD,OAAQA,KAA0B,IAAI;I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,UAAUM,KAAc,EAAEJ,SAAkB,EAAc;QAC9D,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;YAChC,QAAQK,CAAAA,SAAW;oBACf,MAAMA,OACD,IAAI,GACJ,KAAK,CAAC,QACN,QAAQ,CAAC,qBACT,QAAQ,CAAC,CAACL,WACV,MAAM,CAAC,CAACM,OAAO,EAAEC,IAAI,EAAE;wBACpB,MAAMC,YAAYD,KAAK,KAAK,CAAC,QAAQ,QAAQ;wBAC7C,IAAIC,aAAa,CAACF,OACd;wBAEJC,KAAK,KAAK,CAAC,QAAQ,QAAQ,CACvBE,QAAQC,OAAOJ,QAAQ;4BACnB,aAAa;4BACb,OAAO;4BACP,QAAQ;4BACR,MAAM;wBACV;oBAER;oBACJ,MAAMD,OACD,IAAI,GACJ,KAAK,CAAC,QACN,QAAQ,CAAC,qBACT,QAAQ,CAAC,CAACD,SAAS,CAACJ;oBACzB,MAAMK,OACD,IAAI,GACJ,KAAK,CAAC,cACN,QAAQ,CAAC,qBACT,QAAQ,CAAC,CAACL,WACV,QAAQ,CAAC;oBACd,aAAaK,OACR,IAAI,GACJ,KAAK,CAAC,eACN,YAAY,CAAC,IACb,QAAQ,CAAC,YACT,QAAQ,CAAC,CAACL;gBACnB;YACA,QAAQW,CAAAA,SAAU;oBACdA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;oBACXA,OAAO,GAAG,CAAC;iBACd;QACL;IACJ;AACJ;AAEO,MAAMC,0CAAsBC,oBAAAA,oBAAgC,CAAC;IAChE,gBAAgB9B;IAChB,cAAc;QACV+B;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- declare const ContentModelGroups: (() => React.JSX.Element) & {
3
- displayName: string;
2
+ declare const ContentModelGroups: (() => React.JSX.Element) & React.NamedExoticComponent<unknown> & {
3
+ readonly type: () => React.JSX.Element;
4
4
  };
5
5
  export default ContentModelGroups;
@@ -1,6 +1,10 @@
1
1
  import React from "react";
2
2
  export declare const ContentModelGroupsDataList: (({ activeId }: {
3
3
  activeId: string | undefined;
4
- }) => React.JSX.Element) & {
5
- displayName: string;
4
+ }) => React.JSX.Element) & React.NamedExoticComponent<{
5
+ activeId: string | undefined;
6
+ }> & {
7
+ readonly type: ({ activeId }: {
8
+ activeId: string | undefined;
9
+ }) => React.JSX.Element;
6
10
  };
@@ -2,6 +2,12 @@ import React from "react";
2
2
  export declare const ContentModelGroupsForm: (({ newEntry, id }: {
3
3
  newEntry: boolean;
4
4
  id: string | undefined;
5
- }) => React.JSX.Element) & {
6
- displayName: string;
5
+ }) => React.JSX.Element) & React.NamedExoticComponent<{
6
+ newEntry: boolean;
7
+ id: string | undefined;
8
+ }> & {
9
+ readonly type: ({ newEntry, id }: {
10
+ newEntry: boolean;
11
+ id: string | undefined;
12
+ }) => React.JSX.Element;
7
13
  };
@@ -1,3 +1,7 @@
1
1
  import type { IconProp } from "@fortawesome/fontawesome-svg-core";
2
2
  import type { CmsIcon } from "@webiny/app-headless-cms-common/types/index.js";
3
+ /**
4
+ * Converts a stored icon ("prefix/name") into a FontAwesome icon tuple.
5
+ * Returns undefined when the value is missing or not in the "prefix/name" format.
6
+ */
3
7
  export declare const normalizeIcon: (icon: string | CmsIcon | undefined) => IconProp | undefined;
@@ -1,10 +1,13 @@
1
1
  const normalizeIcon = (icon)=>{
2
- let iconName;
3
- if (icon) {
4
- const name = "string" == typeof icon ? icon : icon.name;
5
- iconName = name.split("/");
6
- }
7
- return iconName;
2
+ if (!icon) return;
3
+ const name = "string" == typeof icon ? icon : icon.name;
4
+ if (!name) return;
5
+ const [prefix, iconName, ...rest] = name.split("/");
6
+ if (!prefix || !iconName || rest.length > 0) return;
7
+ return [
8
+ prefix,
9
+ iconName
10
+ ];
8
11
  };
9
12
  export { normalizeIcon };
10
13
 
@@ -1 +1 @@
1
- {"version":3,"file":"utils/normalizeIcon.js","sources":["../../src/utils/normalizeIcon.ts"],"sourcesContent":["import type { IconProp } from \"@fortawesome/fontawesome-svg-core\";\nimport type { CmsIcon } from \"@webiny/app-headless-cms-common/types/index.js\";\n\nexport const normalizeIcon = (icon: string | CmsIcon | undefined) => {\n let iconName: IconProp | undefined = undefined;\n if (icon) {\n const name = typeof icon === \"string\" ? icon : icon.name;\n iconName = name.split(\"/\") as IconProp;\n }\n return iconName;\n};\n"],"names":["normalizeIcon","icon","iconName","name"],"mappings":"AAGO,MAAMA,gBAAgB,CAACC;IAC1B,IAAIC;IACJ,IAAID,MAAM;QACN,MAAME,OAAO,AAAgB,YAAhB,OAAOF,OAAoBA,OAAOA,KAAK,IAAI;QACxDC,WAAWC,KAAK,KAAK,CAAC;IAC1B;IACA,OAAOD;AACX"}
1
+ {"version":3,"file":"utils/normalizeIcon.js","sources":["../../src/utils/normalizeIcon.ts"],"sourcesContent":["import type { IconProp } from \"@fortawesome/fontawesome-svg-core\";\nimport type { CmsIcon } from \"@webiny/app-headless-cms-common/types/index.js\";\n\n/**\n * Converts a stored icon (\"prefix/name\") into a FontAwesome icon tuple.\n * Returns undefined when the value is missing or not in the \"prefix/name\" format.\n */\nexport const normalizeIcon = (icon: string | CmsIcon | undefined): IconProp | undefined => {\n if (!icon) {\n return undefined;\n }\n const name = typeof icon === \"string\" ? icon : icon.name;\n if (!name) {\n return undefined;\n }\n const [prefix, iconName, ...rest] = name.split(\"/\");\n if (!prefix || !iconName || rest.length > 0) {\n return undefined;\n }\n return [prefix, iconName] as IconProp;\n};\n"],"names":["normalizeIcon","icon","name","prefix","iconName","rest"],"mappings":"AAOO,MAAMA,gBAAgB,CAACC;IAC1B,IAAI,CAACA,MACD;IAEJ,MAAMC,OAAO,AAAgB,YAAhB,OAAOD,OAAoBA,OAAOA,KAAK,IAAI;IACxD,IAAI,CAACC,MACD;IAEJ,MAAM,CAACC,QAAQC,UAAU,GAAGC,KAAK,GAAGH,KAAK,KAAK,CAAC;IAC/C,IAAI,CAACC,UAAU,CAACC,YAAYC,KAAK,MAAM,GAAG,GACtC;IAEJ,OAAO;QAACF;QAAQC;KAAS;AAC7B"}