@webiny/app-aco 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.7c2def32a7

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 (243) hide show
  1. package/app.js +5 -1
  2. package/app.js.map +1 -1
  3. package/components/Actions/DeleteFolder/DeleteFolder.js +1 -1
  4. package/components/Actions/DeleteFolder/DeleteFolder.js.map +1 -1
  5. package/components/AdvancedSearch/AdvancedSearch.d.ts +2 -2
  6. package/components/AdvancedSearch/AdvancedSearch.js +1 -1
  7. package/components/AdvancedSearch/AdvancedSearch.js.map +1 -1
  8. package/components/AdvancedSearch/QueryBuilderDrawer/QueryBuilder/components/OperationSelector.js +2 -2
  9. package/components/AdvancedSearch/QueryBuilderDrawer/QueryBuilder/components/OperationSelector.js.map +1 -1
  10. package/components/AdvancedSearch/QueryBuilderDrawer/QueryBuilderDrawer.d.ts +2 -2
  11. package/components/AdvancedSearch/SelectedFilter/SelectedFilter.js +1 -1
  12. package/components/AdvancedSearch/SelectedFilter/SelectedFilter.js.map +1 -1
  13. package/components/AdvancedSearch/domain/Filter.d.ts +1 -1
  14. package/components/AdvancedSearch/domain/FilterRepositoryFactory.d.ts +2 -2
  15. package/components/AdvancedSearch/domain/FilterRepositoryFactory.js.map +1 -1
  16. package/components/AdvancedSearch/gateways/FiltersGraphQLGateway.d.ts +2 -2
  17. package/components/AdvancedSearch/gateways/FiltersGraphQLGateway.js +9 -10
  18. package/components/AdvancedSearch/gateways/FiltersGraphQLGateway.js.map +1 -1
  19. package/components/AdvancedSearch/gateways/filters.gql.d.ts +5 -5
  20. package/components/AdvancedSearch/gateways/filters.gql.js +5 -6
  21. package/components/AdvancedSearch/gateways/filters.gql.js.map +1 -1
  22. package/components/AdvancedSearch/useFilterRepository.js +7 -2
  23. package/components/AdvancedSearch/useFilterRepository.js.map +1 -1
  24. package/components/FolderTree/List/List.js +14 -6
  25. package/components/FolderTree/List/List.js.map +1 -1
  26. package/components/Table/cells/CellAuthor.d.ts +2 -0
  27. package/components/Table/cells/CellAuthor.js +10 -0
  28. package/components/Table/cells/CellAuthor.js.map +1 -0
  29. package/components/Table/cells/CellCreated.d.ts +2 -0
  30. package/components/Table/cells/CellCreated.js +13 -0
  31. package/components/Table/cells/CellCreated.js.map +1 -0
  32. package/components/Table/cells/CellModified.d.ts +2 -0
  33. package/components/Table/cells/CellModified.js +13 -0
  34. package/components/Table/cells/CellModified.js.map +1 -0
  35. package/components/Table/cells/index.d.ts +3 -0
  36. package/components/Table/cells/index.js +3 -0
  37. package/components/Table/components/Table/TableInner.d.ts +2 -2
  38. package/components/Table/createTableData.d.ts +7 -5
  39. package/components/Table/createTableData.js +22 -7
  40. package/components/Table/createTableData.js.map +1 -1
  41. package/components/Table/index.d.ts +2 -2
  42. package/components/Table/index.js +2 -2
  43. package/components/index.d.ts +0 -1
  44. package/components/index.js +0 -1
  45. package/config/AcoConfig.d.ts +8 -12
  46. package/config/advanced-search/FieldRenderer.d.ts +3 -1
  47. package/config/folder/Action.d.ts +1 -1
  48. package/config/folder/index.d.ts +3 -2
  49. package/config/index.d.ts +0 -1
  50. package/config/index.js +0 -1
  51. package/config/record/Action.d.ts +1 -1
  52. package/config/record/index.d.ts +1 -1
  53. package/config/table/Column.d.ts +8 -39
  54. package/config/table/Column.js +4 -67
  55. package/config/table/Column.js.map +1 -1
  56. package/config/table/Sorting.d.ts +2 -11
  57. package/config/table/Sorting.js +1 -28
  58. package/config/table/index.d.ts +5 -9
  59. package/contexts/index.d.ts +0 -3
  60. package/contexts/index.js +0 -3
  61. package/dialogs/DialogSetPermissions/UsersTeamsSelection/ListItemMeta.js +5 -0
  62. package/dialogs/DialogSetPermissions/UsersTeamsSelection/ListItemMeta.js.map +1 -1
  63. package/dialogs/DialogSetPermissions/graphql.d.ts +1 -1
  64. package/dialogs/DialogSetPermissions/graphql.js +1 -2
  65. package/dialogs/DialogSetPermissions/graphql.js.map +1 -1
  66. package/dialogs/useConfirmMoveFolderDialog.d.ts +1 -0
  67. package/dialogs/useConfirmMoveFolderDialog.js +3 -2
  68. package/dialogs/useConfirmMoveFolderDialog.js.map +1 -1
  69. package/dialogs/useCreateDialog.js +5 -9
  70. package/dialogs/useCreateDialog.js.map +1 -1
  71. package/dialogs/useEditDialog.js +2 -2
  72. package/dialogs/useEditDialog.js.map +1 -1
  73. package/dialogs/useSetPermissionsDialog.js +16 -4
  74. package/dialogs/useSetPermissionsDialog.js.map +1 -1
  75. package/domain/folder/Folder.d.ts +2 -1
  76. package/domain/folder/Folder.js.map +1 -1
  77. package/features/folders/cache/FoldersCacheFactory.d.ts +3 -1
  78. package/features/folders/cache/FoldersCacheFactory.js +5 -0
  79. package/features/folders/cache/FoldersCacheFactory.js.map +1 -1
  80. package/features/folders/cache/updateDescendantPermissions.d.ts +12 -0
  81. package/features/folders/cache/updateDescendantPermissions.js +27 -0
  82. package/features/folders/cache/updateDescendantPermissions.js.map +1 -0
  83. package/features/folders/createFolder/CreateFolderGqlGateway.d.ts +3 -3
  84. package/features/folders/createFolder/CreateFolderGqlGateway.js +15 -16
  85. package/features/folders/createFolder/CreateFolderGqlGateway.js.map +1 -1
  86. package/features/folders/deleteFolder/DeleteFolderGqlGateway.d.ts +3 -3
  87. package/features/folders/deleteFolder/DeleteFolderGqlGateway.js +5 -6
  88. package/features/folders/deleteFolder/DeleteFolderGqlGateway.js.map +1 -1
  89. package/features/folders/folderEvents/AddCreatedFolderToCache.d.ts +22 -0
  90. package/features/folders/folderEvents/AddCreatedFolderToCache.js +24 -0
  91. package/features/folders/folderEvents/AddCreatedFolderToCache.js.map +1 -0
  92. package/features/folders/folderEvents/FolderCreatedEvent.d.ts +14 -0
  93. package/features/folders/folderEvents/FolderCreatedEvent.js +13 -0
  94. package/features/folders/folderEvents/FolderCreatedEvent.js.map +1 -0
  95. package/features/folders/folderEvents/FolderDeletedEvent.d.ts +9 -0
  96. package/features/folders/folderEvents/FolderDeletedEvent.js +13 -0
  97. package/features/folders/folderEvents/FolderDeletedEvent.js.map +1 -0
  98. package/features/folders/folderEvents/FolderEvents.test.d.ts +1 -0
  99. package/features/folders/folderEvents/FolderEvents.test.js +238 -0
  100. package/features/folders/folderEvents/FolderEvents.test.js.map +1 -0
  101. package/features/folders/folderEvents/FolderUpdatedEvent.d.ts +12 -0
  102. package/features/folders/folderEvents/FolderUpdatedEvent.js +13 -0
  103. package/features/folders/folderEvents/FolderUpdatedEvent.js.map +1 -0
  104. package/features/folders/folderEvents/FolderWebsocketMessages.d.ts +15 -0
  105. package/features/folders/folderEvents/FolderWebsocketMessages.js +48 -0
  106. package/features/folders/folderEvents/FolderWebsocketMessages.js.map +1 -0
  107. package/features/folders/folderEvents/RefreshUpdatedFolderInCache.d.ts +19 -0
  108. package/features/folders/folderEvents/RefreshUpdatedFolderInCache.js +27 -0
  109. package/features/folders/folderEvents/RefreshUpdatedFolderInCache.js.map +1 -0
  110. package/features/folders/folderEvents/RemoveDeletedFolderFromCache.d.ts +13 -0
  111. package/features/folders/folderEvents/RemoveDeletedFolderFromCache.js +15 -0
  112. package/features/folders/folderEvents/RemoveDeletedFolderFromCache.js.map +1 -0
  113. package/features/folders/folderEvents/abstractions.d.ts +28 -0
  114. package/features/folders/folderEvents/abstractions.js +7 -0
  115. package/features/folders/folderEvents/abstractions.js.map +1 -0
  116. package/features/folders/folderEvents/feature.d.ts +9 -0
  117. package/features/folders/folderEvents/feature.js +21 -0
  118. package/features/folders/folderEvents/feature.js.map +1 -0
  119. package/features/folders/folderEvents/index.d.ts +5 -0
  120. package/features/folders/folderEvents/index.js +5 -0
  121. package/features/folders/folderModelProvider/FolderModelProvider.js +30 -31
  122. package/features/folders/folderModelProvider/FolderModelProvider.js.map +1 -1
  123. package/features/folders/folderModelProvider/GetFolderModelGqlGateway.d.ts +3 -3
  124. package/features/folders/folderModelProvider/GetFolderModelGqlGateway.js +5 -7
  125. package/features/folders/folderModelProvider/GetFolderModelGqlGateway.js.map +1 -1
  126. package/features/folders/getFolder/GetFolderGqlGateway.d.ts +3 -3
  127. package/features/folders/getFolder/GetFolderGqlGateway.js +5 -7
  128. package/features/folders/getFolder/GetFolderGqlGateway.js.map +1 -1
  129. package/features/folders/getFolderExtensionsFields/GetFolderExtensionsFieldsUseCase.d.ts +4 -3
  130. package/features/folders/getFolderExtensionsFields/useFolderExtensionsFields.d.ts +4 -3
  131. package/features/folders/getFolderLevelPermission/GetFolderLevelPermission.test.js +12 -16
  132. package/features/folders/getFolderLevelPermission/GetFolderLevelPermission.test.js.map +1 -1
  133. package/features/folders/getFolderLevelPermission/decorators/GetFolderLevelPermissionWithFlpDecorator.d.ts +3 -3
  134. package/features/folders/getFolderLevelPermission/decorators/GetFolderLevelPermissionWithFlpDecorator.js +5 -5
  135. package/features/folders/getFolderLevelPermission/decorators/GetFolderLevelPermissionWithFlpDecorator.js.map +1 -1
  136. package/features/folders/listFolders/ListFoldersGqlGateway.d.ts +1 -1
  137. package/features/folders/listFolders/ListFoldersGqlGateway.js +1 -2
  138. package/features/folders/listFolders/ListFoldersGqlGateway.js.map +1 -1
  139. package/features/folders/listFolders/useListFolders.d.ts +1 -1
  140. package/features/folders/listFoldersByParentIds/ListFoldersByParentIdsGqlGateway.d.ts +3 -3
  141. package/features/folders/listFoldersByParentIds/ListFoldersByParentIdsGqlGateway.js +5 -7
  142. package/features/folders/listFoldersByParentIds/ListFoldersByParentIdsGqlGateway.js.map +1 -1
  143. package/features/folders/listFoldersByParentIds/useListFoldersByParentIds.d.ts +2 -2
  144. package/features/folders/loadFolderHierarchy/useLoadFolderHierarchy.d.ts +2 -2
  145. package/features/folders/updateFolder/UpdateFolderGqlGateway.d.ts +3 -3
  146. package/features/folders/updateFolder/UpdateFolderGqlGateway.js +6 -7
  147. package/features/folders/updateFolder/UpdateFolderGqlGateway.js.map +1 -1
  148. package/features/folders/updateFolder/decorators/RepositoryWithPermissionsChange.d.ts +1 -4
  149. package/features/folders/updateFolder/decorators/RepositoryWithPermissionsChange.js +3 -30
  150. package/features/folders/updateFolder/decorators/RepositoryWithPermissionsChange.js.map +1 -1
  151. package/features/folders/updateFolder/decorators/{UseCaseWithoutInheritedPermissions.d.ts → UseCaseWithoutReadOnlyPermissions.d.ts} +2 -2
  152. package/features/folders/updateFolder/decorators/{UseCaseWithoutInheritedPermissions.js → UseCaseWithoutReadOnlyPermissions.js} +6 -6
  153. package/features/folders/updateFolder/decorators/UseCaseWithoutReadOnlyPermissions.js.map +1 -0
  154. package/features/folders/updateFolder/feature.js +2 -2
  155. package/features/folders/updateFolder/feature.js.map +1 -1
  156. package/hooks/index.d.ts +0 -6
  157. package/hooks/index.js +0 -6
  158. package/index.d.ts +3 -2
  159. package/index.js +2 -2
  160. package/package.json +23 -29
  161. package/presentation/folderTree/FolderTree.js +13 -5
  162. package/presentation/folderTree/FolderTree.js.map +1 -1
  163. package/presentation/folderTree/FolderTreePresenter.d.ts +5 -1
  164. package/presentation/folderTree/FolderTreePresenter.js +49 -31
  165. package/presentation/folderTree/FolderTreePresenter.js.map +1 -1
  166. package/presentation/folderTree/FolderTreePresenter.test.js +111 -7
  167. package/presentation/folderTree/FolderTreePresenter.test.js.map +1 -1
  168. package/table.types.d.ts +2 -9
  169. package/types.d.ts +5 -26
  170. package/types.js.map +1 -1
  171. package/components/Extensions/Extensions.d.ts +0 -2
  172. package/components/Extensions/Extensions.js +0 -30
  173. package/components/Extensions/Extensions.js.map +0 -1
  174. package/components/Extensions/index.d.ts +0 -1
  175. package/components/Extensions/index.js +0 -1
  176. package/config/folder/createFolderFieldDecoratorFactory.d.ts +0 -13
  177. package/config/folder/createFolderFieldDecoratorFactory.js +0 -17
  178. package/config/folder/createFolderFieldDecoratorFactory.js.map +0 -1
  179. package/config/table/Sorting.js.map +0 -1
  180. package/contexts/acoList.d.ts +0 -49
  181. package/contexts/acoList.js +0 -303
  182. package/contexts/acoList.js.map +0 -1
  183. package/contexts/app.d.ts +0 -33
  184. package/contexts/app.js +0 -47
  185. package/contexts/app.js.map +0 -1
  186. package/contexts/folders.d.ts +0 -12
  187. package/contexts/folders.js +0 -32
  188. package/contexts/folders.js.map +0 -1
  189. package/contexts/navigateFolder.d.ts +0 -17
  190. package/contexts/navigateFolder.js +0 -54
  191. package/contexts/navigateFolder.js.map +0 -1
  192. package/contexts/records.d.ts +0 -31
  193. package/contexts/records.js +0 -316
  194. package/contexts/records.js.map +0 -1
  195. package/exports/admin/aco.d.ts +0 -2
  196. package/exports/admin/aco.js +0 -2
  197. package/features/folders/updateFolder/decorators/UseCaseWithoutInheritedPermissions.js.map +0 -1
  198. package/graphql/app.gql.d.ts +0 -17
  199. package/graphql/app.gql.js +0 -22
  200. package/graphql/app.gql.js.map +0 -1
  201. package/graphql/records/common.d.ts +0 -4
  202. package/graphql/records/common.js +0 -57
  203. package/graphql/records/common.js.map +0 -1
  204. package/graphql/records/getRecord.d.ts +0 -2
  205. package/graphql/records/getRecord.js +0 -5
  206. package/graphql/records/getRecord.js.map +0 -1
  207. package/graphql/records/listRecords.d.ts +0 -2
  208. package/graphql/records/listRecords.js +0 -26
  209. package/graphql/records/listRecords.js.map +0 -1
  210. package/graphql/records/moveRecord.d.ts +0 -2
  211. package/graphql/records/moveRecord.js +0 -16
  212. package/graphql/records/moveRecord.js.map +0 -1
  213. package/graphql/records/types.d.ts +0 -108
  214. package/graphql/records/types.js +0 -0
  215. package/graphql/records.gql.d.ts +0 -3
  216. package/graphql/records.gql.js +0 -3
  217. package/handlers.d.ts +0 -23
  218. package/handlers.js +0 -22
  219. package/handlers.js.map +0 -1
  220. package/hooks/useAcoApp.d.ts +0 -2
  221. package/hooks/useAcoApp.js +0 -16
  222. package/hooks/useAcoApp.js.map +0 -1
  223. package/hooks/useAcoList.d.ts +0 -3
  224. package/hooks/useAcoList.js +0 -10
  225. package/hooks/useAcoList.js.map +0 -1
  226. package/hooks/useFolderModel.d.ts +0 -2
  227. package/hooks/useFolderModel.js +0 -16
  228. package/hooks/useFolderModel.js.map +0 -1
  229. package/hooks/useFoldersType.d.ts +0 -1
  230. package/hooks/useFoldersType.js +0 -12
  231. package/hooks/useFoldersType.js.map +0 -1
  232. package/hooks/useNavigateFolder.d.ts +0 -2
  233. package/hooks/useNavigateFolder.js +0 -10
  234. package/hooks/useNavigateFolder.js.map +0 -1
  235. package/hooks/useRecords.d.ts +0 -62
  236. package/hooks/useRecords.js +0 -64
  237. package/hooks/useRecords.js.map +0 -1
  238. package/hooks/useTags.d.ts +0 -14
  239. package/hooks/useTags.js +0 -27
  240. package/hooks/useTags.js.map +0 -1
  241. package/sorting.d.ts +0 -9
  242. package/sorting.js +0 -31
  243. package/sorting.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"dialogs/useCreateDialog.js","sources":["../../src/dialogs/useCreateDialog.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport slugify from \"slugify\";\nimport { Grid, Input } from \"@webiny/admin-ui\";\nimport { useDialogs, useSnackbar } from \"@webiny/app-admin\";\nimport type { GenericFormData } from \"@webiny/form\";\nimport { Bind, useForm } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { Extensions, FolderTree } from \"~/components/index.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport type { FolderDto } from \"~/domain/folder/FolderDto.js\";\nimport { useCreateFolder } from \"~/features/folders/createFolder/index.js\";\nimport { ParentFolderField } from \"./ParentFolderField.js\";\n\ninterface ShowDialogParams {\n currentParentId?: string | null;\n}\n\ninterface UseCreateDialogResponse {\n showDialog: (params?: ShowDialogParams) => void;\n}\n\ninterface FormComponentProps {\n currentParentId?: string | null;\n}\n\nconst FormComponent = ({ currentParentId = null }: FormComponentProps) => {\n const [parentId, setParentId] = useState<string | null>(currentParentId);\n const form = useForm();\n\n const generateSlug = () => {\n if (form.data.slug || !form.data.title) {\n return;\n }\n\n // We want to update slug only when the folder is first being created.\n form.setValue(\n \"slug\",\n slugify(form.data.title, {\n replacement: \"-\",\n lower: true,\n remove: /[*#?<>_{}[\\]+~.()'\"!:;@]/g,\n trim: false\n })\n );\n };\n\n return (\n <>\n <Grid>\n <Grid.Column span={12}>\n <Bind name={\"title\"} validators={validation.create(\"required\")}>\n {bind => (\n <Input\n {...bind}\n label={\"Title\"}\n onBlur={generateSlug}\n size={\"lg\"}\n required\n autoFocus={true}\n />\n )}\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"slug\"} validators={validation.create(\"required,slug\")}>\n <Input label={\"Slug\"} size={\"lg\"} required />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <ParentFolderField>\n <Bind name={\"parentId\"} defaultValue={parentId}>\n {({ onChange }) => (\n <FolderTree\n focusedFolderId={parentId || ROOT_FOLDER}\n onFolderClick={folder => {\n setParentId(folder.id);\n onChange(folder.id === ROOT_FOLDER ? null : folder.id);\n }}\n />\n )}\n </Bind>\n </ParentFolderField>\n </Grid.Column>\n </Grid>\n <Extensions />\n </>\n );\n};\n\nexport const useCreateDialog = (): UseCreateDialogResponse => {\n const dialogs = useDialogs();\n const { createFolder } = useCreateFolder();\n const { showSnackbar } = useSnackbar();\n\n const onAccept = useCallback(async (data: FolderDto) => {\n try {\n await createFolder({\n ...data,\n parentId: data.parentId === ROOT_FOLDER ? null : data.parentId\n });\n showSnackbar(\"Folder created successfully!\");\n } catch (error) {\n showSnackbar(error.message);\n }\n }, []);\n\n const showDialog = (params?: ShowDialogParams) => {\n const { currentParentId = null } = params ?? {};\n\n dialogs.showDialog({\n title: \"Create a new folder\",\n content: <FormComponent currentParentId={currentParentId} />,\n acceptLabel: \"Create folder\",\n cancelLabel: \"Cancel\",\n loadingLabel: \"Creating folder...\",\n /**\n * We need to cast as there are no generics to pass for the onAccept function.\n */\n onAccept: onAccept as (data: GenericFormData) => Promise<void>\n });\n };\n\n return {\n showDialog\n };\n};\n"],"names":["FormComponent","currentParentId","parentId","setParentId","useState","form","useForm","generateSlug","slugify","Grid","Bind","validation","bind","Input","ParentFolderField","onChange","FolderTree","ROOT_FOLDER","folder","Extensions","useCreateDialog","dialogs","useDialogs","createFolder","useCreateFolder","showSnackbar","useSnackbar","onAccept","useCallback","data","error","showDialog","params"],"mappings":";;;;;;;;;;AAyBA,MAAMA,gBAAgB,CAAC,EAAEC,kBAAkB,IAAI,EAAsB;IACjE,MAAM,CAACC,UAAUC,YAAY,GAAGC,SAAwBH;IACxD,MAAMI,OAAOC;IAEb,MAAMC,eAAe;QACjB,IAAIF,KAAK,IAAI,CAAC,IAAI,IAAI,CAACA,KAAK,IAAI,CAAC,KAAK,EAClC;QAIJA,KAAK,QAAQ,CACT,QACAG,QAAQH,KAAK,IAAI,CAAC,KAAK,EAAE;YACrB,aAAa;YACb,OAAO;YACP,QAAQ;YACR,MAAM;QACV;IAER;IAEA,OAAO,WAAP,GACI,wDACI,oBAACI,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QAAC,MAAM;QAAS,YAAYC,WAAW,MAAM,CAAC;OAC9CC,CAAAA,OAAAA,WAAAA,GACG,oBAACC,OAAKA;YACD,GAAGD,IAAI;YACR,OAAO;YACP,QAAQL;YACR,MAAM;YACN;YACA,WAAW;4BAK3B,oBAACE,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QAAC,MAAM;QAAQ,YAAYC,WAAW,MAAM,CAAC;qBAC9C,oBAACE,OAAKA;QAAC,OAAO;QAAQ,MAAM;QAAM;wBAG1C,oBAACJ,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACK,mBAAiBA,MAAAA,WAAAA,GACd,oBAACJ,MAAIA;QAAC,MAAM;QAAY,cAAcR;OACjC,CAAC,EAAEa,QAAQ,EAAE,iBACV,oBAACC,YAAUA;YACP,iBAAiBd,YAAYe;YAC7B,eAAeC,CAAAA;gBACXf,YAAYe,OAAO,EAAE;gBACrBH,SAASG,OAAO,EAAE,KAAKD,cAAc,OAAOC,OAAO,EAAE;YACzD;8BAOxB,oBAACC,YAAUA;AAGvB;AAEO,MAAMC,kBAAkB;IAC3B,MAAMC,UAAUC;IAChB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IACzB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAMC,WAAWC,YAAY,OAAOC;QAChC,IAAI;YACA,MAAMN,aAAa;gBACf,GAAGM,IAAI;gBACP,UAAUA,KAAK,QAAQ,KAAKZ,cAAc,OAAOY,KAAK,QAAQ;YAClE;YACAJ,aAAa;QACjB,EAAE,OAAOK,OAAO;YACZL,aAAaK,MAAM,OAAO;QAC9B;IACJ,GAAG,EAAE;IAEL,MAAMC,aAAa,CAACC;QAChB,MAAM,EAAE/B,kBAAkB,IAAI,EAAE,GAAG+B,UAAU,CAAC;QAE9CX,QAAQ,UAAU,CAAC;YACf,OAAO;YACP,SAAS,WAAT,GAAS,oBAACrB,eAAaA;gBAAC,iBAAiBC;;YACzC,aAAa;YACb,aAAa;YACb,cAAc;YAId,UAAU0B;QACd;IACJ;IAEA,OAAO;QACHI;IACJ;AACJ"}
1
+ {"version":3,"file":"dialogs/useCreateDialog.js","sources":["../../src/dialogs/useCreateDialog.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport { useStringFormatter } from \"@webiny/app-admin/features/stringFormatter/useStringFormatter.js\";\nimport { Grid, Input } from \"@webiny/admin-ui\";\nimport { useDialogs, useSnackbar } from \"@webiny/app-admin\";\nimport type { GenericFormData } from \"@webiny/form\";\nimport { Bind, useForm } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { FolderTree } from \"~/components/index.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport type { FolderDto } from \"~/domain/folder/FolderDto.js\";\nimport { useCreateFolder } from \"~/features/folders/createFolder/index.js\";\nimport { ParentFolderField } from \"./ParentFolderField.js\";\n\ninterface ShowDialogParams {\n currentParentId?: string | null;\n}\n\ninterface UseCreateDialogResponse {\n showDialog: (params?: ShowDialogParams) => void;\n}\n\ninterface FormComponentProps {\n currentParentId?: string | null;\n}\n\nconst FormComponent = ({ currentParentId = null }: FormComponentProps) => {\n const [parentId, setParentId] = useState<string | null>(currentParentId);\n const form = useForm();\n const stringFormatter = useStringFormatter();\n\n const generateSlug = () => {\n if (form.data.slug || !form.data.title) {\n return;\n }\n\n // We want to update slug only when the folder is first being created.\n form.setValue(\"slug\", stringFormatter.slugify(form.data.title));\n };\n\n return (\n <>\n <Grid>\n <Grid.Column span={12}>\n <Bind name={\"title\"} validators={validation.create(\"required\")}>\n {bind => (\n <Input\n {...bind}\n label={\"Title\"}\n onBlur={generateSlug}\n size={\"lg\"}\n required\n autoFocus={true}\n />\n )}\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"slug\"} validators={validation.create(\"required,slug\")}>\n <Input label={\"Slug\"} size={\"lg\"} required />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <ParentFolderField>\n <Bind name={\"parentId\"} defaultValue={parentId}>\n {({ onChange }) => (\n <FolderTree\n focusedFolderId={parentId || ROOT_FOLDER}\n onFolderClick={folder => {\n setParentId(folder.id);\n onChange(folder.id === ROOT_FOLDER ? null : folder.id);\n }}\n />\n )}\n </Bind>\n </ParentFolderField>\n </Grid.Column>\n </Grid>\n </>\n );\n};\n\nexport const useCreateDialog = (): UseCreateDialogResponse => {\n const dialogs = useDialogs();\n const { createFolder } = useCreateFolder();\n const { showSnackbar } = useSnackbar();\n\n const onAccept = useCallback(async (data: FolderDto) => {\n try {\n await createFolder({\n ...data,\n parentId: data.parentId === ROOT_FOLDER ? null : data.parentId\n });\n showSnackbar(\"Folder created successfully!\");\n } catch (error) {\n showSnackbar(error.message);\n }\n }, []);\n\n const showDialog = (params?: ShowDialogParams) => {\n const { currentParentId = null } = params ?? {};\n\n dialogs.showDialog({\n title: \"Create a new folder\",\n content: <FormComponent currentParentId={currentParentId} />,\n acceptLabel: \"Create folder\",\n cancelLabel: \"Cancel\",\n loadingLabel: \"Creating folder...\",\n /**\n * We need to cast as there are no generics to pass for the onAccept function.\n */\n onAccept: onAccept as (data: GenericFormData) => Promise<void>\n });\n };\n\n return {\n showDialog\n };\n};\n"],"names":["FormComponent","currentParentId","parentId","setParentId","useState","form","useForm","stringFormatter","useStringFormatter","generateSlug","Grid","Bind","validation","bind","Input","ParentFolderField","onChange","FolderTree","ROOT_FOLDER","folder","useCreateDialog","dialogs","useDialogs","createFolder","useCreateFolder","showSnackbar","useSnackbar","onAccept","useCallback","data","error","showDialog","params"],"mappings":";;;;;;;;;;AAyBA,MAAMA,gBAAgB,CAAC,EAAEC,kBAAkB,IAAI,EAAsB;IACjE,MAAM,CAACC,UAAUC,YAAY,GAAGC,SAAwBH;IACxD,MAAMI,OAAOC;IACb,MAAMC,kBAAkBC;IAExB,MAAMC,eAAe;QACjB,IAAIJ,KAAK,IAAI,CAAC,IAAI,IAAI,CAACA,KAAK,IAAI,CAAC,KAAK,EAClC;QAIJA,KAAK,QAAQ,CAAC,QAAQE,gBAAgB,OAAO,CAACF,KAAK,IAAI,CAAC,KAAK;IACjE;IAEA,OAAO,WAAP,GACI,wDACI,oBAACK,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QAAC,MAAM;QAAS,YAAYC,WAAW,MAAM,CAAC;OAC9CC,CAAAA,OAAAA,WAAAA,GACG,oBAACC,OAAKA;YACD,GAAGD,IAAI;YACR,OAAO;YACP,QAAQJ;YACR,MAAM;YACN;YACA,WAAW;4BAK3B,oBAACC,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QAAC,MAAM;QAAQ,YAAYC,WAAW,MAAM,CAAC;qBAC9C,oBAACE,OAAKA;QAAC,OAAO;QAAQ,MAAM;QAAM;wBAG1C,oBAACJ,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACK,mBAAiBA,MAAAA,WAAAA,GACd,oBAACJ,MAAIA;QAAC,MAAM;QAAY,cAAcT;OACjC,CAAC,EAAEc,QAAQ,EAAE,iBACV,oBAACC,YAAUA;YACP,iBAAiBf,YAAYgB;YAC7B,eAAeC,CAAAA;gBACXhB,YAAYgB,OAAO,EAAE;gBACrBH,SAASG,OAAO,EAAE,KAAKD,cAAc,OAAOC,OAAO,EAAE;YACzD;;AASpC;AAEO,MAAMC,kBAAkB;IAC3B,MAAMC,UAAUC;IAChB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IACzB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAMC,WAAWC,YAAY,OAAOC;QAChC,IAAI;YACA,MAAMN,aAAa;gBACf,GAAGM,IAAI;gBACP,UAAUA,KAAK,QAAQ,KAAKX,cAAc,OAAOW,KAAK,QAAQ;YAClE;YACAJ,aAAa;QACjB,EAAE,OAAOK,OAAO;YACZL,aAAaK,MAAM,OAAO;QAC9B;IACJ,GAAG,EAAE;IAEL,MAAMC,aAAa,CAACC;QAChB,MAAM,EAAE/B,kBAAkB,IAAI,EAAE,GAAG+B,UAAU,CAAC;QAE9CX,QAAQ,UAAU,CAAC;YACf,OAAO;YACP,SAAS,WAAT,GAAS,oBAACrB,eAAaA;gBAAC,iBAAiBC;;YACzC,aAAa;YACb,aAAa;YACb,cAAc;YAId,UAAU0B;QACd;IACJ;IAEA,OAAO;QACHI;IACJ;AACJ"}
@@ -3,7 +3,7 @@ import { Grid, Input } from "@webiny/admin-ui";
3
3
  import { useDialogs, useSnackbar } from "@webiny/app-admin";
4
4
  import { Bind } from "@webiny/form";
5
5
  import { validation } from "@webiny/validation";
6
- import { Extensions, FolderTree } from "../components/index.js";
6
+ import { FolderTree } from "../components/index.js";
7
7
  import { ROOT_FOLDER } from "../constants.js";
8
8
  import { useUpdateFolder } from "../features/folders/updateFolder/index.js";
9
9
  import { ParentFolderField } from "./ParentFolderField.js";
@@ -49,7 +49,7 @@ const FormComponent = ({ folder })=>{
49
49
  onChange(folder.id === ROOT_FOLDER ? null : folder.id);
50
50
  },
51
51
  enableCreate: true
52
- }))))), /*#__PURE__*/ react.createElement(Extensions, null));
52
+ }))))));
53
53
  };
54
54
  const useEditDialog = ()=>{
55
55
  const dialog = useDialogs();
@@ -1 +1 @@
1
- {"version":3,"file":"dialogs/useEditDialog.js","sources":["../../src/dialogs/useEditDialog.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport { Grid, Input } from \"@webiny/admin-ui\";\nimport { useSnackbar, useDialogs } from \"@webiny/app-admin\";\nimport type { GenericFormData } from \"@webiny/form\";\nimport { Bind } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { Extensions, FolderTree } from \"~/components/index.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport type { FolderDto } from \"~/domain/folder/FolderDto.js\";\nimport { useUpdateFolder } from \"~/features/folders/updateFolder/index.js\";\nimport { ParentFolderField } from \"./ParentFolderField.js\";\n\ninterface ShowDialogParams {\n folder: FolderDto;\n}\n\ninterface UseEditDialogResponse {\n showDialog: (params: ShowDialogParams) => void;\n}\n\ninterface FormComponentProps {\n folder: FolderDto;\n}\n\nconst FormComponent = ({ folder }: FormComponentProps) => {\n const [parentId, setParentId] = useState<string | null>(folder.parentId);\n\n return (\n <>\n <Grid>\n <Grid.Column span={12}>\n <Bind\n name={\"title\"}\n defaultValue={folder.title}\n validators={[validation.create(\"required\")]}\n >\n <Input label={\"Title\"} size={\"lg\"} required autoFocus />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name={\"slug\"}\n defaultValue={folder.slug}\n validators={[validation.create(\"required,slug\")]}\n >\n <Input label={\"Slug\"} size={\"lg\"} required />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <ParentFolderField>\n <Bind name={\"parentId\"} defaultValue={parentId}>\n {({ onChange }) => (\n <FolderTree\n focusedFolderId={parentId || ROOT_FOLDER}\n hiddenFolderIds={[folder.id]}\n onFolderClick={folder => {\n setParentId(folder.id);\n onChange(folder.id === ROOT_FOLDER ? null : folder.id);\n }}\n enableCreate={true}\n />\n )}\n </Bind>\n </ParentFolderField>\n </Grid.Column>\n </Grid>\n <Extensions />\n </>\n );\n};\n\nexport const useEditDialog = (): UseEditDialogResponse => {\n const dialog = useDialogs();\n const { updateFolder } = useUpdateFolder();\n const { showSnackbar } = useSnackbar();\n\n const onAccept = useCallback(async (folder: FolderDto, data: GenericFormData) => {\n try {\n await updateFolder({\n ...folder,\n ...data\n });\n showSnackbar(`The folder \"${data.title}\" was updated successfully!`);\n } catch (error) {\n showSnackbar(error.message);\n }\n }, []);\n\n const showDialog = ({ folder }: ShowDialogParams) => {\n dialog.showDialog({\n title: \"Edit folder\",\n content: <FormComponent folder={folder} />,\n formData: folder,\n acceptLabel: \"Edit folder\",\n cancelLabel: \"Cancel\",\n loadingLabel: \"Editing folder...\",\n onAccept: (data: GenericFormData) => onAccept(folder, data)\n });\n };\n\n return {\n showDialog\n };\n};\n"],"names":["FormComponent","folder","parentId","setParentId","useState","Grid","Bind","validation","Input","ParentFolderField","onChange","FolderTree","ROOT_FOLDER","Extensions","useEditDialog","dialog","useDialogs","updateFolder","useUpdateFolder","showSnackbar","useSnackbar","onAccept","useCallback","data","error","showDialog"],"mappings":";;;;;;;;;AAwBA,MAAMA,gBAAgB,CAAC,EAAEC,MAAM,EAAsB;IACjD,MAAM,CAACC,UAAUC,YAAY,GAAGC,SAAwBH,OAAO,QAAQ;IAEvE,OAAO,WAAP,GACI,wDACI,oBAACI,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QACD,MAAM;QACN,cAAcL,OAAO,KAAK;QAC1B,YAAY;YAACM,WAAW,MAAM,CAAC;SAAY;qBAE3C,oBAACC,OAAKA;QAAC,OAAO;QAAS,MAAM;QAAM;QAAS;wBAGpD,oBAACH,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QACD,MAAM;QACN,cAAcL,OAAO,IAAI;QACzB,YAAY;YAACM,WAAW,MAAM,CAAC;SAAiB;qBAEhD,oBAACC,OAAKA;QAAC,OAAO;QAAQ,MAAM;QAAM;wBAG1C,oBAACH,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACI,mBAAiBA,MAAAA,WAAAA,GACd,oBAACH,MAAIA;QAAC,MAAM;QAAY,cAAcJ;OACjC,CAAC,EAAEQ,QAAQ,EAAE,iBACV,oBAACC,YAAUA;YACP,iBAAiBT,YAAYU;YAC7B,iBAAiB;gBAACX,OAAO,EAAE;aAAC;YAC5B,eAAeA,CAAAA;gBACXE,YAAYF,OAAO,EAAE;gBACrBS,SAAST,OAAO,EAAE,KAAKW,cAAc,OAAOX,OAAO,EAAE;YACzD;YACA,cAAc;8BAOtC,oBAACY,YAAUA;AAGvB;AAEO,MAAMC,gBAAgB;IACzB,MAAMC,SAASC;IACf,MAAM,EAAEC,YAAY,EAAE,GAAGC;IACzB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAMC,WAAWC,YAAY,OAAOrB,QAAmBsB;QACnD,IAAI;YACA,MAAMN,aAAa;gBACf,GAAGhB,MAAM;gBACT,GAAGsB,IAAI;YACX;YACAJ,aAAa,CAAC,YAAY,EAAEI,KAAK,KAAK,CAAC,2BAA2B,CAAC;QACvE,EAAE,OAAOC,OAAO;YACZL,aAAaK,MAAM,OAAO;QAC9B;IACJ,GAAG,EAAE;IAEL,MAAMC,aAAa,CAAC,EAAExB,MAAM,EAAoB;QAC5Cc,OAAO,UAAU,CAAC;YACd,OAAO;YACP,SAAS,WAAT,GAAS,oBAACf,eAAaA;gBAAC,QAAQC;;YAChC,UAAUA;YACV,aAAa;YACb,aAAa;YACb,cAAc;YACd,UAAU,CAACsB,OAA0BF,SAASpB,QAAQsB;QAC1D;IACJ;IAEA,OAAO;QACHE;IACJ;AACJ"}
1
+ {"version":3,"file":"dialogs/useEditDialog.js","sources":["../../src/dialogs/useEditDialog.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport { Grid, Input } from \"@webiny/admin-ui\";\nimport { useSnackbar, useDialogs } from \"@webiny/app-admin\";\nimport type { GenericFormData } from \"@webiny/form\";\nimport { Bind } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { FolderTree } from \"~/components/index.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport type { FolderDto } from \"~/domain/folder/FolderDto.js\";\nimport { useUpdateFolder } from \"~/features/folders/updateFolder/index.js\";\nimport { ParentFolderField } from \"./ParentFolderField.js\";\n\ninterface ShowDialogParams {\n folder: FolderDto;\n}\n\ninterface UseEditDialogResponse {\n showDialog: (params: ShowDialogParams) => void;\n}\n\ninterface FormComponentProps {\n folder: FolderDto;\n}\n\nconst FormComponent = ({ folder }: FormComponentProps) => {\n const [parentId, setParentId] = useState<string | null>(folder.parentId);\n\n return (\n <>\n <Grid>\n <Grid.Column span={12}>\n <Bind\n name={\"title\"}\n defaultValue={folder.title}\n validators={[validation.create(\"required\")]}\n >\n <Input label={\"Title\"} size={\"lg\"} required autoFocus />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name={\"slug\"}\n defaultValue={folder.slug}\n validators={[validation.create(\"required,slug\")]}\n >\n <Input label={\"Slug\"} size={\"lg\"} required />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <ParentFolderField>\n <Bind name={\"parentId\"} defaultValue={parentId}>\n {({ onChange }) => (\n <FolderTree\n focusedFolderId={parentId || ROOT_FOLDER}\n hiddenFolderIds={[folder.id]}\n onFolderClick={folder => {\n setParentId(folder.id);\n onChange(folder.id === ROOT_FOLDER ? null : folder.id);\n }}\n enableCreate={true}\n />\n )}\n </Bind>\n </ParentFolderField>\n </Grid.Column>\n </Grid>\n </>\n );\n};\n\nexport const useEditDialog = (): UseEditDialogResponse => {\n const dialog = useDialogs();\n const { updateFolder } = useUpdateFolder();\n const { showSnackbar } = useSnackbar();\n\n const onAccept = useCallback(async (folder: FolderDto, data: GenericFormData) => {\n try {\n await updateFolder({\n ...folder,\n ...data\n });\n showSnackbar(`The folder \"${data.title}\" was updated successfully!`);\n } catch (error) {\n showSnackbar(error.message);\n }\n }, []);\n\n const showDialog = ({ folder }: ShowDialogParams) => {\n dialog.showDialog({\n title: \"Edit folder\",\n content: <FormComponent folder={folder} />,\n formData: folder,\n acceptLabel: \"Edit folder\",\n cancelLabel: \"Cancel\",\n loadingLabel: \"Editing folder...\",\n onAccept: (data: GenericFormData) => onAccept(folder, data)\n });\n };\n\n return {\n showDialog\n };\n};\n"],"names":["FormComponent","folder","parentId","setParentId","useState","Grid","Bind","validation","Input","ParentFolderField","onChange","FolderTree","ROOT_FOLDER","useEditDialog","dialog","useDialogs","updateFolder","useUpdateFolder","showSnackbar","useSnackbar","onAccept","useCallback","data","error","showDialog"],"mappings":";;;;;;;;;AAwBA,MAAMA,gBAAgB,CAAC,EAAEC,MAAM,EAAsB;IACjD,MAAM,CAACC,UAAUC,YAAY,GAAGC,SAAwBH,OAAO,QAAQ;IAEvE,OAAO,WAAP,GACI,wDACI,oBAACI,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QACD,MAAM;QACN,cAAcL,OAAO,KAAK;QAC1B,YAAY;YAACM,WAAW,MAAM,CAAC;SAAY;qBAE3C,oBAACC,OAAKA;QAAC,OAAO;QAAS,MAAM;QAAM;QAAS;wBAGpD,oBAACH,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QACD,MAAM;QACN,cAAcL,OAAO,IAAI;QACzB,YAAY;YAACM,WAAW,MAAM,CAAC;SAAiB;qBAEhD,oBAACC,OAAKA;QAAC,OAAO;QAAQ,MAAM;QAAM;wBAG1C,oBAACH,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACI,mBAAiBA,MAAAA,WAAAA,GACd,oBAACH,MAAIA;QAAC,MAAM;QAAY,cAAcJ;OACjC,CAAC,EAAEQ,QAAQ,EAAE,iBACV,oBAACC,YAAUA;YACP,iBAAiBT,YAAYU;YAC7B,iBAAiB;gBAACX,OAAO,EAAE;aAAC;YAC5B,eAAeA,CAAAA;gBACXE,YAAYF,OAAO,EAAE;gBACrBS,SAAST,OAAO,EAAE,KAAKW,cAAc,OAAOX,OAAO,EAAE;YACzD;YACA,cAAc;;AASlD;AAEO,MAAMY,gBAAgB;IACzB,MAAMC,SAASC;IACf,MAAM,EAAEC,YAAY,EAAE,GAAGC;IACzB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAMC,WAAWC,YAAY,OAAOpB,QAAmBqB;QACnD,IAAI;YACA,MAAMN,aAAa;gBACf,GAAGf,MAAM;gBACT,GAAGqB,IAAI;YACX;YACAJ,aAAa,CAAC,YAAY,EAAEI,KAAK,KAAK,CAAC,2BAA2B,CAAC;QACvE,EAAE,OAAOC,OAAO;YACZL,aAAaK,MAAM,OAAO;QAC9B;IACJ,GAAG,EAAE;IAEL,MAAMC,aAAa,CAAC,EAAEvB,MAAM,EAAoB;QAC5Ca,OAAO,UAAU,CAAC;YACd,OAAO;YACP,SAAS,WAAT,GAAS,oBAACd,eAAaA;gBAAC,QAAQC;;YAChC,UAAUA;YACV,aAAa;YACb,aAAa;YACb,cAAc;YACd,UAAU,CAACqB,OAA0BF,SAASnB,QAAQqB;QAC1D;IACJ;IAEA,OAAO;QACHE;IACJ;AACJ"}
@@ -1,5 +1,6 @@
1
- import react, { useCallback, useEffect, useState } from "react";
2
- import { useQuery } from "@apollo/react-hooks";
1
+ import react, { useCallback, useEffect, useMemo, useState } from "react";
2
+ import { useContainer } from "@webiny/app";
3
+ import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient/index.js";
3
4
  import { Grid } from "@webiny/admin-ui";
4
5
  import { useDialogs, useSnackbar } from "@webiny/app-admin";
5
6
  import { useBind } from "@webiny/form";
@@ -9,8 +10,19 @@ import { UsersTeamsSelection } from "./DialogSetPermissions/UsersTeamsSelection.
9
10
  import { LIST_FOLDER_LEVEL_PERMISSIONS_TARGETS } from "./DialogSetPermissions/graphql.js";
10
11
  const FormComponent = ({ folder })=>{
11
12
  const [permissions, setPermissions] = useState(folder.permissions || []);
12
- const listTargetsQuery = useQuery(LIST_FOLDER_LEVEL_PERMISSIONS_TARGETS);
13
- const targetsList = listTargetsQuery.data?.aco.listFolderLevelPermissionsTargets.data || [];
13
+ const container = useContainer();
14
+ const client = useMemo(()=>container.resolve(MainGraphQLClient), [
15
+ container
16
+ ]);
17
+ const [targetsList, setTargetsList] = useState([]);
18
+ useEffect(()=>{
19
+ client.execute({
20
+ query: LIST_FOLDER_LEVEL_PERMISSIONS_TARGETS
21
+ }).then((response)=>{
22
+ const data = response.aco.listFolderLevelPermissionsTargets.data;
23
+ setTargetsList(data || []);
24
+ }).catch(console.error);
25
+ }, []);
14
26
  const bind = useBind({
15
27
  name: "permissions"
16
28
  });
@@ -1 +1 @@
1
- {"version":3,"file":"dialogs/useSetPermissionsDialog.js","sources":["../../src/dialogs/useSetPermissionsDialog.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\nimport { useQuery } from \"@apollo/react-hooks\";\nimport { Grid } from \"@webiny/admin-ui\";\nimport { useDialogs, useSnackbar } from \"@webiny/app-admin\";\nimport type { GenericFormData } from \"@webiny/form\";\nimport { useBind } from \"@webiny/form\";\nimport type { FolderDto } from \"~/domain/folder/FolderDto.js\";\nimport { useUpdateFolder } from \"~/features/folders/updateFolder/index.js\";\nimport { UsersTeamsMultiAutocomplete } from \"./DialogSetPermissions/UsersTeamsMultiAutocomplete.js\";\nimport { UsersTeamsSelection } from \"./DialogSetPermissions/UsersTeamsSelection.js\";\nimport { LIST_FOLDER_LEVEL_PERMISSIONS_TARGETS } from \"./DialogSetPermissions/graphql.js\";\nimport type { FolderLevelPermissionsTarget, FolderPermission } from \"~/types.js\";\n\ninterface ShowDialogParams {\n folder: FolderDto;\n}\n\ninterface UseSetPermissionsDialogResponse {\n showDialog: (params: ShowDialogParams) => void;\n}\n\ninterface FormComponentProps {\n folder: FolderDto;\n}\n\ninterface UpdatePermissionCallableParams {\n permission: FolderPermission;\n}\n\ninterface UpdatePermissionCallable {\n (params: UpdatePermissionCallableParams): void;\n}\n\ninterface RemoveUserTeamCallableParams {\n permission: FolderPermission;\n}\n\ninterface RemoveUserTeamCallable {\n (params: RemoveUserTeamCallableParams): void;\n}\n\nconst FormComponent = ({ folder }: FormComponentProps) => {\n const [permissions, setPermissions] = useState<FolderPermission[]>(folder.permissions || []); // Moved useState outside showDialog\n const listTargetsQuery = useQuery(LIST_FOLDER_LEVEL_PERMISSIONS_TARGETS);\n const targetsList: FolderLevelPermissionsTarget[] =\n listTargetsQuery.data?.aco.listFolderLevelPermissionsTargets.data || [];\n\n const bind = useBind({\n name: \"permissions\"\n });\n\n useEffect(() => {\n bind.onChange(permissions);\n }, [permissions]);\n\n const addPermission = useCallback(\n (value: FolderPermission[\"target\"][]) => {\n const selectedUserOrTeam = value[value.length - 1];\n const newPermission: FolderPermission = {\n target: selectedUserOrTeam,\n level: \"viewer\"\n };\n\n // We want to add the new permission to the 2nd position in the array.\n // The 1st position is reserved for the \"current user\" permission.\n setPermissions([permissions[0], newPermission, ...permissions.slice(1)]);\n },\n [permissions]\n );\n\n const updatePermission = useCallback<UpdatePermissionCallable>(\n ({ permission: updatedPermission }) => {\n setPermissions(\n permissions.map(permission => {\n if (permission.target === updatedPermission.target) {\n return updatedPermission;\n }\n return permission;\n })\n );\n },\n [permissions]\n );\n\n const removeUserTeam = useCallback<RemoveUserTeamCallable>(\n item => {\n setPermissions(\n permissions.filter(permission => permission.target !== item.permission.target)\n );\n },\n [permissions]\n );\n\n return (\n <Grid>\n <Grid.Column span={12}>\n <UsersTeamsMultiAutocomplete\n options={targetsList}\n value={permissions.map(permission => permission.target)}\n onChange={addPermission}\n />\n </Grid.Column>\n <Grid.Column span={12}>\n <UsersTeamsSelection\n permissions={permissions}\n targetsList={targetsList}\n onRemoveAccess={removeUserTeam}\n onUpdatePermission={updatePermission}\n />\n </Grid.Column>\n </Grid>\n );\n};\n\nexport const useSetPermissionsDialog = (): UseSetPermissionsDialogResponse => {\n const dialogs = useDialogs();\n const { updateFolder } = useUpdateFolder();\n const { showSnackbar } = useSnackbar();\n\n const onAccept = useCallback(async (folder: FolderDto, data: Partial<FolderDto>) => {\n const updateData = { ...folder, ...data };\n\n try {\n await updateFolder(updateData);\n showSnackbar(\"Folder permissions updated successfully!\");\n } catch (error) {\n showSnackbar(error.message);\n }\n }, []);\n\n const showDialog = ({ folder }: ShowDialogParams) => {\n dialogs.showDialog({\n title: `Manage permissions - ${folder.title}`,\n content: <FormComponent folder={folder} />,\n acceptLabel: \"Save\",\n cancelLabel: \"Cancel\",\n loadingLabel: \"Updating permissions...\",\n onAccept: (data: GenericFormData) => onAccept(folder, data)\n });\n };\n\n return {\n showDialog\n };\n};\n"],"names":["FormComponent","folder","permissions","setPermissions","useState","listTargetsQuery","useQuery","LIST_FOLDER_LEVEL_PERMISSIONS_TARGETS","targetsList","bind","useBind","useEffect","addPermission","useCallback","value","selectedUserOrTeam","newPermission","updatePermission","updatedPermission","permission","removeUserTeam","item","Grid","UsersTeamsMultiAutocomplete","UsersTeamsSelection","useSetPermissionsDialog","dialogs","useDialogs","updateFolder","useUpdateFolder","showSnackbar","useSnackbar","onAccept","data","updateData","error","showDialog"],"mappings":";;;;;;;;;AAyCA,MAAMA,gBAAgB,CAAC,EAAEC,MAAM,EAAsB;IACjD,MAAM,CAACC,aAAaC,eAAe,GAAGC,SAA6BH,OAAO,WAAW,IAAI,EAAE;IAC3F,MAAMI,mBAAmBC,SAASC;IAClC,MAAMC,cACFH,iBAAiB,IAAI,EAAE,IAAI,kCAAkC,QAAQ,EAAE;IAE3E,MAAMI,OAAOC,QAAQ;QACjB,MAAM;IACV;IAEAC,UAAU;QACNF,KAAK,QAAQ,CAACP;IAClB,GAAG;QAACA;KAAY;IAEhB,MAAMU,gBAAgBC,YAClB,CAACC;QACG,MAAMC,qBAAqBD,KAAK,CAACA,MAAM,MAAM,GAAG,EAAE;QAClD,MAAME,gBAAkC;YACpC,QAAQD;YACR,OAAO;QACX;QAIAZ,eAAe;YAACD,WAAW,CAAC,EAAE;YAAEc;eAAkBd,YAAY,KAAK,CAAC;SAAG;IAC3E,GACA;QAACA;KAAY;IAGjB,MAAMe,mBAAmBJ,YACrB,CAAC,EAAE,YAAYK,iBAAiB,EAAE;QAC9Bf,eACID,YAAY,GAAG,CAACiB,CAAAA;YACZ,IAAIA,WAAW,MAAM,KAAKD,kBAAkB,MAAM,EAC9C,OAAOA;YAEX,OAAOC;QACX;IAER,GACA;QAACjB;KAAY;IAGjB,MAAMkB,iBAAiBP,YACnBQ,CAAAA;QACIlB,eACID,YAAY,MAAM,CAACiB,CAAAA,aAAcA,WAAW,MAAM,KAAKE,KAAK,UAAU,CAAC,MAAM;IAErF,GACA;QAACnB;KAAY;IAGjB,OAAO,WAAP,GACI,oBAACoB,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,6BAA2BA;QACxB,SAASf;QACT,OAAON,YAAY,GAAG,CAACiB,CAAAA,aAAcA,WAAW,MAAM;QACtD,UAAUP;uBAGlB,oBAACU,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACE,qBAAmBA;QAChB,aAAatB;QACb,aAAaM;QACb,gBAAgBY;QAChB,oBAAoBH;;AAKxC;AAEO,MAAMQ,0BAA0B;IACnC,MAAMC,UAAUC;IAChB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IACzB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAMC,WAAWnB,YAAY,OAAOZ,QAAmBgC;QACnD,MAAMC,aAAa;YAAE,GAAGjC,MAAM;YAAE,GAAGgC,IAAI;QAAC;QAExC,IAAI;YACA,MAAML,aAAaM;YACnBJ,aAAa;QACjB,EAAE,OAAOK,OAAO;YACZL,aAAaK,MAAM,OAAO;QAC9B;IACJ,GAAG,EAAE;IAEL,MAAMC,aAAa,CAAC,EAAEnC,MAAM,EAAoB;QAC5CyB,QAAQ,UAAU,CAAC;YACf,OAAO,CAAC,qBAAqB,EAAEzB,OAAO,KAAK,EAAE;YAC7C,SAAS,WAAT,GAAS,oBAACD,eAAaA;gBAAC,QAAQC;;YAChC,aAAa;YACb,aAAa;YACb,cAAc;YACd,UAAU,CAACgC,OAA0BD,SAAS/B,QAAQgC;QAC1D;IACJ;IAEA,OAAO;QACHG;IACJ;AACJ"}
1
+ {"version":3,"file":"dialogs/useSetPermissionsDialog.js","sources":["../../src/dialogs/useSetPermissionsDialog.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { useContainer } from \"@webiny/app\";\nimport { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient/index.js\";\nimport { Grid } from \"@webiny/admin-ui\";\nimport { useDialogs, useSnackbar } from \"@webiny/app-admin\";\nimport type { GenericFormData } from \"@webiny/form\";\nimport { useBind } from \"@webiny/form\";\nimport type { FolderDto } from \"~/domain/folder/FolderDto.js\";\nimport { useUpdateFolder } from \"~/features/folders/updateFolder/index.js\";\nimport { UsersTeamsMultiAutocomplete } from \"./DialogSetPermissions/UsersTeamsMultiAutocomplete.js\";\nimport { UsersTeamsSelection } from \"./DialogSetPermissions/UsersTeamsSelection.js\";\nimport { LIST_FOLDER_LEVEL_PERMISSIONS_TARGETS } from \"./DialogSetPermissions/graphql.js\";\nimport type { FolderLevelPermissionsTarget, FolderPermission } from \"~/types.js\";\n\ninterface ShowDialogParams {\n folder: FolderDto;\n}\n\ninterface UseSetPermissionsDialogResponse {\n showDialog: (params: ShowDialogParams) => void;\n}\n\ninterface FormComponentProps {\n folder: FolderDto;\n}\n\ninterface UpdatePermissionCallableParams {\n permission: FolderPermission;\n}\n\ninterface UpdatePermissionCallable {\n (params: UpdatePermissionCallableParams): void;\n}\n\ninterface RemoveUserTeamCallableParams {\n permission: FolderPermission;\n}\n\ninterface RemoveUserTeamCallable {\n (params: RemoveUserTeamCallableParams): void;\n}\n\ninterface ListFolderPermissionsTargetsResponse {\n aco: {\n listFolderLevelPermissionsTargets: {\n data: FolderLevelPermissionsTarget[] | null;\n error: { code: string; data: unknown; message: string } | null;\n };\n };\n}\n\nconst FormComponent = ({ folder }: FormComponentProps) => {\n const [permissions, setPermissions] = useState<FolderPermission[]>(folder.permissions || []);\n const container = useContainer();\n const client = useMemo(() => container.resolve(MainGraphQLClient), [container]);\n const [targetsList, setTargetsList] = useState<FolderLevelPermissionsTarget[]>([]);\n\n useEffect(() => {\n client\n .execute<ListFolderPermissionsTargetsResponse>({\n query: LIST_FOLDER_LEVEL_PERMISSIONS_TARGETS\n })\n .then(response => {\n const data = response.aco.listFolderLevelPermissionsTargets.data;\n setTargetsList(data || []);\n })\n .catch(console.error);\n }, []);\n\n const bind = useBind({\n name: \"permissions\"\n });\n\n useEffect(() => {\n bind.onChange(permissions);\n }, [permissions]);\n\n const addPermission = useCallback(\n (value: FolderPermission[\"target\"][]) => {\n const selectedUserOrTeam = value[value.length - 1];\n const newPermission: FolderPermission = {\n target: selectedUserOrTeam,\n level: \"viewer\"\n };\n\n setPermissions([permissions[0], newPermission, ...permissions.slice(1)]);\n },\n [permissions]\n );\n\n const updatePermission = useCallback<UpdatePermissionCallable>(\n ({ permission: updatedPermission }) => {\n setPermissions(\n permissions.map(permission => {\n if (permission.target === updatedPermission.target) {\n return updatedPermission;\n }\n return permission;\n })\n );\n },\n [permissions]\n );\n\n const removeUserTeam = useCallback<RemoveUserTeamCallable>(\n item => {\n setPermissions(\n permissions.filter(permission => permission.target !== item.permission.target)\n );\n },\n [permissions]\n );\n\n return (\n <Grid>\n <Grid.Column span={12}>\n <UsersTeamsMultiAutocomplete\n options={targetsList}\n value={permissions.map(permission => permission.target)}\n onChange={addPermission}\n />\n </Grid.Column>\n <Grid.Column span={12}>\n <UsersTeamsSelection\n permissions={permissions}\n targetsList={targetsList}\n onRemoveAccess={removeUserTeam}\n onUpdatePermission={updatePermission}\n />\n </Grid.Column>\n </Grid>\n );\n};\n\nexport const useSetPermissionsDialog = (): UseSetPermissionsDialogResponse => {\n const dialogs = useDialogs();\n const { updateFolder } = useUpdateFolder();\n const { showSnackbar } = useSnackbar();\n\n const onAccept = useCallback(async (folder: FolderDto, data: Partial<FolderDto>) => {\n const updateData = { ...folder, ...data };\n\n try {\n await updateFolder(updateData);\n showSnackbar(\"Folder permissions updated successfully!\");\n } catch (error) {\n showSnackbar(error.message);\n }\n }, []);\n\n const showDialog = ({ folder }: ShowDialogParams) => {\n dialogs.showDialog({\n title: `Manage permissions - ${folder.title}`,\n content: <FormComponent folder={folder} />,\n acceptLabel: \"Save\",\n cancelLabel: \"Cancel\",\n loadingLabel: \"Updating permissions...\",\n onAccept: (data: GenericFormData) => onAccept(folder, data)\n });\n };\n\n return {\n showDialog\n };\n};\n"],"names":["FormComponent","folder","permissions","setPermissions","useState","container","useContainer","client","useMemo","MainGraphQLClient","targetsList","setTargetsList","useEffect","LIST_FOLDER_LEVEL_PERMISSIONS_TARGETS","response","data","console","bind","useBind","addPermission","useCallback","value","selectedUserOrTeam","newPermission","updatePermission","updatedPermission","permission","removeUserTeam","item","Grid","UsersTeamsMultiAutocomplete","UsersTeamsSelection","useSetPermissionsDialog","dialogs","useDialogs","updateFolder","useUpdateFolder","showSnackbar","useSnackbar","onAccept","updateData","error","showDialog"],"mappings":";;;;;;;;;;AAmDA,MAAMA,gBAAgB,CAAC,EAAEC,MAAM,EAAsB;IACjD,MAAM,CAACC,aAAaC,eAAe,GAAGC,SAA6BH,OAAO,WAAW,IAAI,EAAE;IAC3F,MAAMI,YAAYC;IAClB,MAAMC,SAASC,QAAQ,IAAMH,UAAU,OAAO,CAACI,oBAAoB;QAACJ;KAAU;IAC9E,MAAM,CAACK,aAAaC,eAAe,GAAGP,SAAyC,EAAE;IAEjFQ,UAAU;QACNL,OACK,OAAO,CAAuC;YAC3C,OAAOM;QACX,GACC,IAAI,CAACC,CAAAA;YACF,MAAMC,OAAOD,SAAS,GAAG,CAAC,iCAAiC,CAAC,IAAI;YAChEH,eAAeI,QAAQ,EAAE;QAC7B,GACC,KAAK,CAACC,QAAQ,KAAK;IAC5B,GAAG,EAAE;IAEL,MAAMC,OAAOC,QAAQ;QACjB,MAAM;IACV;IAEAN,UAAU;QACNK,KAAK,QAAQ,CAACf;IAClB,GAAG;QAACA;KAAY;IAEhB,MAAMiB,gBAAgBC,YAClB,CAACC;QACG,MAAMC,qBAAqBD,KAAK,CAACA,MAAM,MAAM,GAAG,EAAE;QAClD,MAAME,gBAAkC;YACpC,QAAQD;YACR,OAAO;QACX;QAEAnB,eAAe;YAACD,WAAW,CAAC,EAAE;YAAEqB;eAAkBrB,YAAY,KAAK,CAAC;SAAG;IAC3E,GACA;QAACA;KAAY;IAGjB,MAAMsB,mBAAmBJ,YACrB,CAAC,EAAE,YAAYK,iBAAiB,EAAE;QAC9BtB,eACID,YAAY,GAAG,CAACwB,CAAAA;YACZ,IAAIA,WAAW,MAAM,KAAKD,kBAAkB,MAAM,EAC9C,OAAOA;YAEX,OAAOC;QACX;IAER,GACA;QAACxB;KAAY;IAGjB,MAAMyB,iBAAiBP,YACnBQ,CAAAA;QACIzB,eACID,YAAY,MAAM,CAACwB,CAAAA,aAAcA,WAAW,MAAM,KAAKE,KAAK,UAAU,CAAC,MAAM;IAErF,GACA;QAAC1B;KAAY;IAGjB,OAAO,WAAP,GACI,oBAAC2B,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,6BAA2BA;QACxB,SAASpB;QACT,OAAOR,YAAY,GAAG,CAACwB,CAAAA,aAAcA,WAAW,MAAM;QACtD,UAAUP;uBAGlB,oBAACU,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACE,qBAAmBA;QAChB,aAAa7B;QACb,aAAaQ;QACb,gBAAgBiB;QAChB,oBAAoBH;;AAKxC;AAEO,MAAMQ,0BAA0B;IACnC,MAAMC,UAAUC;IAChB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IACzB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAMC,WAAWnB,YAAY,OAAOnB,QAAmBc;QACnD,MAAMyB,aAAa;YAAE,GAAGvC,MAAM;YAAE,GAAGc,IAAI;QAAC;QAExC,IAAI;YACA,MAAMoB,aAAaK;YACnBH,aAAa;QACjB,EAAE,OAAOI,OAAO;YACZJ,aAAaI,MAAM,OAAO;QAC9B;IACJ,GAAG,EAAE;IAEL,MAAMC,aAAa,CAAC,EAAEzC,MAAM,EAAoB;QAC5CgC,QAAQ,UAAU,CAAC;YACf,OAAO,CAAC,qBAAqB,EAAEhC,OAAO,KAAK,EAAE;YAC7C,SAAS,WAAT,GAAS,oBAACD,eAAaA;gBAAC,QAAQC;;YAChC,aAAa;YACb,aAAa;YACb,cAAc;YACd,UAAU,CAACc,OAA0BwB,SAAStC,QAAQc;QAC1D;IACJ;IAEA,OAAO;QACH2B;IACJ;AACJ"}
@@ -1,4 +1,5 @@
1
- import type { CmsIdentity, FolderPermission } from "../../types.js";
1
+ import type { FolderPermission } from "../../types.js";
2
+ import type { CmsIdentity } from "../../types.js";
2
3
  export interface FolderData {
3
4
  id?: string;
4
5
  title: string;
@@ -1 +1 @@
1
- {"version":3,"file":"domain/folder/Folder.js","sources":["../../../src/domain/folder/Folder.ts"],"sourcesContent":["import type { CmsIdentity, FolderPermission } from \"~/types.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\n\nexport interface FolderData {\n id?: string;\n title: string;\n slug: string;\n type: string;\n parentId: string | null;\n path?: string;\n permissions: FolderPermission[];\n hasNonInheritedPermissions?: boolean;\n canManagePermissions?: boolean;\n canManageStructure?: boolean;\n canManageContent?: boolean;\n createdBy?: CmsIdentity;\n createdOn?: string;\n savedBy?: CmsIdentity;\n savedOn?: string;\n modifiedBy?: CmsIdentity | null;\n modifiedOn?: string | null;\n extensions?: Record<string, any>;\n}\n\nexport class Folder {\n public id: string;\n public title: string;\n public slug: string;\n public type: string;\n public parentId: string | null;\n public path: string;\n public permissions: FolderPermission[];\n public hasNonInheritedPermissions?: boolean;\n public canManagePermissions?: boolean;\n public canManageStructure?: boolean;\n public canManageContent?: boolean;\n public createdBy?: CmsIdentity;\n public createdOn?: string;\n public savedBy?: CmsIdentity;\n public savedOn?: string;\n public modifiedBy?: CmsIdentity | null;\n public modifiedOn?: string | null;\n public extensions: Record<string, any>;\n\n protected constructor(folder: FolderData) {\n this.id = folder.id ?? \"\";\n this.title = folder.title;\n this.slug = folder.slug;\n this.type = folder.type;\n this.parentId = folder.parentId;\n this.path = folder.path ?? `${ROOT_FOLDER}/${folder.slug}`;\n this.permissions = folder.permissions;\n this.hasNonInheritedPermissions = folder.hasNonInheritedPermissions;\n this.canManagePermissions = folder.canManagePermissions;\n this.canManageStructure = folder.canManageStructure;\n this.canManageContent = folder.canManageContent;\n this.createdBy = folder.createdBy;\n this.createdOn = folder.createdOn;\n this.savedBy = folder.savedBy;\n this.savedOn = folder.savedOn;\n this.modifiedBy = folder.modifiedBy;\n this.modifiedOn = folder.modifiedOn;\n this.extensions = folder.extensions ?? {};\n }\n\n static create(folder: FolderData) {\n return new Folder(folder);\n }\n}\n"],"names":["Folder","folder","ROOT_FOLDER"],"mappings":";AAwBO,MAAMA;IAoBT,YAAsBC,MAAkB,CAAE;QACtC,IAAI,CAAC,EAAE,GAAGA,OAAO,EAAE,IAAI;QACvB,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI;QACvB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI;QACvB,IAAI,CAAC,QAAQ,GAAGA,OAAO,QAAQ;QAC/B,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI,IAAI,GAAGC,YAAY,CAAC,EAAED,OAAO,IAAI,EAAE;QAC1D,IAAI,CAAC,WAAW,GAAGA,OAAO,WAAW;QACrC,IAAI,CAAC,0BAA0B,GAAGA,OAAO,0BAA0B;QACnE,IAAI,CAAC,oBAAoB,GAAGA,OAAO,oBAAoB;QACvD,IAAI,CAAC,kBAAkB,GAAGA,OAAO,kBAAkB;QACnD,IAAI,CAAC,gBAAgB,GAAGA,OAAO,gBAAgB;QAC/C,IAAI,CAAC,SAAS,GAAGA,OAAO,SAAS;QACjC,IAAI,CAAC,SAAS,GAAGA,OAAO,SAAS;QACjC,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,UAAU,GAAGA,OAAO,UAAU;QACnC,IAAI,CAAC,UAAU,GAAGA,OAAO,UAAU;QACnC,IAAI,CAAC,UAAU,GAAGA,OAAO,UAAU,IAAI,CAAC;IAC5C;IAEA,OAAO,OAAOA,MAAkB,EAAE;QAC9B,OAAO,IAAID,OAAOC;IACtB;AACJ"}
1
+ {"version":3,"file":"domain/folder/Folder.js","sources":["../../../src/domain/folder/Folder.ts"],"sourcesContent":["import type { FolderPermission } from \"~/types.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport type { CmsIdentity } from \"~/types.js\";\n\nexport interface FolderData {\n id?: string;\n title: string;\n slug: string;\n type: string;\n parentId: string | null;\n path?: string;\n permissions: FolderPermission[];\n hasNonInheritedPermissions?: boolean;\n canManagePermissions?: boolean;\n canManageStructure?: boolean;\n canManageContent?: boolean;\n createdBy?: CmsIdentity;\n createdOn?: string;\n savedBy?: CmsIdentity;\n savedOn?: string;\n modifiedBy?: CmsIdentity | null;\n modifiedOn?: string | null;\n extensions?: Record<string, any>;\n}\n\nexport class Folder {\n public id: string;\n public title: string;\n public slug: string;\n public type: string;\n public parentId: string | null;\n public path: string;\n public permissions: FolderPermission[];\n public hasNonInheritedPermissions?: boolean;\n public canManagePermissions?: boolean;\n public canManageStructure?: boolean;\n public canManageContent?: boolean;\n public createdBy?: CmsIdentity;\n public createdOn?: string;\n public savedBy?: CmsIdentity;\n public savedOn?: string;\n public modifiedBy?: CmsIdentity | null;\n public modifiedOn?: string | null;\n public extensions: Record<string, any>;\n\n protected constructor(folder: FolderData) {\n this.id = folder.id ?? \"\";\n this.title = folder.title;\n this.slug = folder.slug;\n this.type = folder.type;\n this.parentId = folder.parentId;\n this.path = folder.path ?? `${ROOT_FOLDER}/${folder.slug}`;\n this.permissions = folder.permissions;\n this.hasNonInheritedPermissions = folder.hasNonInheritedPermissions;\n this.canManagePermissions = folder.canManagePermissions;\n this.canManageStructure = folder.canManageStructure;\n this.canManageContent = folder.canManageContent;\n this.createdBy = folder.createdBy;\n this.createdOn = folder.createdOn;\n this.savedBy = folder.savedBy;\n this.savedOn = folder.savedOn;\n this.modifiedBy = folder.modifiedBy;\n this.modifiedOn = folder.modifiedOn;\n this.extensions = folder.extensions ?? {};\n }\n\n static create(folder: FolderData) {\n return new Folder(folder);\n }\n}\n"],"names":["Folder","folder","ROOT_FOLDER"],"mappings":";AAyBO,MAAMA;IAoBT,YAAsBC,MAAkB,CAAE;QACtC,IAAI,CAAC,EAAE,GAAGA,OAAO,EAAE,IAAI;QACvB,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI;QACvB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI;QACvB,IAAI,CAAC,QAAQ,GAAGA,OAAO,QAAQ;QAC/B,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI,IAAI,GAAGC,YAAY,CAAC,EAAED,OAAO,IAAI,EAAE;QAC1D,IAAI,CAAC,WAAW,GAAGA,OAAO,WAAW;QACrC,IAAI,CAAC,0BAA0B,GAAGA,OAAO,0BAA0B;QACnE,IAAI,CAAC,oBAAoB,GAAGA,OAAO,oBAAoB;QACvD,IAAI,CAAC,kBAAkB,GAAGA,OAAO,kBAAkB;QACnD,IAAI,CAAC,gBAAgB,GAAGA,OAAO,gBAAgB;QAC/C,IAAI,CAAC,SAAS,GAAGA,OAAO,SAAS;QACjC,IAAI,CAAC,SAAS,GAAGA,OAAO,SAAS;QACjC,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,UAAU,GAAGA,OAAO,UAAU;QACnC,IAAI,CAAC,UAAU,GAAGA,OAAO,UAAU;QACnC,IAAI,CAAC,UAAU,GAAGA,OAAO,UAAU,IAAI,CAAC;IAC5C;IAEA,OAAO,OAAOA,MAAkB,EAAE;QAC9B,OAAO,IAAID,OAAOC;IACtB;AACJ"}
@@ -1,8 +1,10 @@
1
1
  import type { Folder } from "../../../domain/folder/Folder.js";
2
- import { ListCache } from "../../../features/folders/cache/ListCache.js";
2
+ import { type IListCache, ListCache } from "../../../features/folders/cache/ListCache.js";
3
3
  export declare class FoldersCacheFactory {
4
4
  private cache;
5
5
  getCache(namespace: string): ListCache<Folder>;
6
+ /** Every folder type's cache created so far. */
7
+ getCaches(): IListCache<Folder>[];
6
8
  private getCacheKey;
7
9
  }
8
10
  export declare const folderCacheFactory: FoldersCacheFactory;
@@ -5,6 +5,11 @@ class FoldersCacheFactory {
5
5
  if (!this.cache.has(cacheKey)) this.cache.set(cacheKey, new ListCache());
6
6
  return this.cache.get(cacheKey);
7
7
  }
8
+ getCaches() {
9
+ return [
10
+ ...this.cache.values()
11
+ ];
12
+ }
8
13
  getCacheKey(namespace) {
9
14
  return namespace;
10
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/folders/cache/FoldersCacheFactory.js","sources":["../../../../src/features/folders/cache/FoldersCacheFactory.ts"],"sourcesContent":["import type { Folder } from \"~/domain/folder/Folder.js\";\nimport { type IListCache, ListCache } from \"~/features/folders/cache/ListCache.js\";\n\nexport class FoldersCacheFactory {\n private cache: Map<string, IListCache<Folder>> = new Map();\n\n getCache(namespace: string) {\n const cacheKey = this.getCacheKey(namespace);\n\n if (!this.cache.has(cacheKey)) {\n this.cache.set(cacheKey, new ListCache<Folder>());\n }\n\n return this.cache.get(cacheKey) as ListCache<Folder>;\n }\n\n private getCacheKey(namespace: string) {\n return namespace;\n }\n}\n\nexport const folderCacheFactory = new FoldersCacheFactory();\n"],"names":["FoldersCacheFactory","namespace","cacheKey","ListCache","Map","folderCacheFactory"],"mappings":";AAGO,MAAMA;IAGT,SAASC,SAAiB,EAAE;QACxB,MAAMC,WAAW,IAAI,CAAC,WAAW,CAACD;QAElC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAACC,WAChB,IAAI,CAAC,KAAK,CAAC,GAAG,CAACA,UAAU,IAAIC;QAGjC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAACD;IAC1B;IAEQ,YAAYD,SAAiB,EAAE;QACnC,OAAOA;IACX;;aAdQ,KAAK,GAAoC,IAAIG;;AAezD;AAEO,MAAMC,qBAAqB,IAAIL"}
1
+ {"version":3,"file":"features/folders/cache/FoldersCacheFactory.js","sources":["../../../../src/features/folders/cache/FoldersCacheFactory.ts"],"sourcesContent":["import type { Folder } from \"~/domain/folder/Folder.js\";\nimport { type IListCache, ListCache } from \"~/features/folders/cache/ListCache.js\";\n\nexport class FoldersCacheFactory {\n private cache: Map<string, IListCache<Folder>> = new Map();\n\n getCache(namespace: string) {\n const cacheKey = this.getCacheKey(namespace);\n\n if (!this.cache.has(cacheKey)) {\n this.cache.set(cacheKey, new ListCache<Folder>());\n }\n\n return this.cache.get(cacheKey) as ListCache<Folder>;\n }\n\n /** Every folder type's cache created so far. */\n getCaches() {\n return [...this.cache.values()];\n }\n\n private getCacheKey(namespace: string) {\n return namespace;\n }\n}\n\nexport const folderCacheFactory = new FoldersCacheFactory();\n"],"names":["FoldersCacheFactory","namespace","cacheKey","ListCache","Map","folderCacheFactory"],"mappings":";AAGO,MAAMA;IAGT,SAASC,SAAiB,EAAE;QACxB,MAAMC,WAAW,IAAI,CAAC,WAAW,CAACD;QAElC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAACC,WAChB,IAAI,CAAC,KAAK,CAAC,GAAG,CAACA,UAAU,IAAIC;QAGjC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAACD;IAC1B;IAGA,YAAY;QACR,OAAO;eAAI,IAAI,CAAC,KAAK,CAAC,MAAM;SAAG;IACnC;IAEQ,YAAYD,SAAiB,EAAE;QACnC,OAAOA;IACX;;aAnBQ,KAAK,GAAoC,IAAIG;;AAoBzD;AAEO,MAAMC,qBAAqB,IAAIL"}
@@ -0,0 +1,12 @@
1
+ import { Folder } from "../../../domain/folder/Folder.js";
2
+ import type { IListCache } from "./ListCache.js";
3
+ /**
4
+ * Re-derives the inherited permissions of one cached folder from its parent, and returns it.
5
+ */
6
+ export declare const updateFolderPermissions: (cache: IListCache<Folder>, folderId: string, parentFolder: Folder | undefined) => Folder;
7
+ /**
8
+ * Folders inherit their parent's permissions, and the cache holds each folder's resolved list. So
9
+ * when a folder's permissions change, every cached folder below it is stale too. This walks the
10
+ * cached descendants and re-derives theirs, the same way the server resolves them on read.
11
+ */
12
+ export declare const updateDescendantPermissions: (cache: IListCache<Folder>, folder: Folder) => void;
@@ -0,0 +1,27 @@
1
+ import { Permissions } from "@webiny/shared-aco";
2
+ import { Folder } from "../../../domain/folder/Folder.js";
3
+ const listDirectChildren = (cache, folder)=>cache.getItems().filter((f)=>f.parentId === folder.id);
4
+ const updateFolderPermissions = (cache, folderId, parentFolder)=>{
5
+ let updatedFolder;
6
+ cache.updateItems((f)=>{
7
+ if (f.id === folderId) {
8
+ const permissions = Permissions.create(f.permissions, parentFolder);
9
+ updatedFolder = Folder.create({
10
+ ...f,
11
+ permissions
12
+ });
13
+ return updatedFolder;
14
+ }
15
+ return f;
16
+ });
17
+ return updatedFolder;
18
+ };
19
+ const updateDescendantPermissions = (cache, folder)=>{
20
+ for (const child of listDirectChildren(cache, folder)){
21
+ const updatedChild = updateFolderPermissions(cache, child.id, folder);
22
+ updateDescendantPermissions(cache, updatedChild);
23
+ }
24
+ };
25
+ export { updateDescendantPermissions, updateFolderPermissions };
26
+
27
+ //# sourceMappingURL=updateDescendantPermissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/folders/cache/updateDescendantPermissions.js","sources":["../../../../src/features/folders/cache/updateDescendantPermissions.ts"],"sourcesContent":["import { Permissions } from \"@webiny/shared-aco\";\nimport { Folder } from \"~/domain/folder/Folder.js\";\nimport type { IListCache } from \"./ListCache.js\";\n\nconst listDirectChildren = (cache: IListCache<Folder>, folder: Folder) => {\n return cache.getItems().filter(f => f.parentId === folder.id);\n};\n\n/**\n * Re-derives the inherited permissions of one cached folder from its parent, and returns it.\n */\nexport const updateFolderPermissions = (\n cache: IListCache<Folder>,\n folderId: string,\n parentFolder: Folder | undefined\n): Folder => {\n let updatedFolder: Folder | undefined;\n cache.updateItems(f => {\n if (f.id === folderId) {\n const permissions = Permissions.create(f.permissions, parentFolder);\n updatedFolder = Folder.create({ ...f, permissions });\n return updatedFolder;\n }\n return f;\n });\n\n return updatedFolder!;\n};\n\n/**\n * Folders inherit their parent's permissions, and the cache holds each folder's resolved list. So\n * when a folder's permissions change, every cached folder below it is stale too. This walks the\n * cached descendants and re-derives theirs, the same way the server resolves them on read.\n */\nexport const updateDescendantPermissions = (cache: IListCache<Folder>, folder: Folder) => {\n for (const child of listDirectChildren(cache, folder)) {\n const updatedChild = updateFolderPermissions(cache, child.id, folder);\n updateDescendantPermissions(cache, updatedChild);\n }\n};\n"],"names":["listDirectChildren","cache","folder","f","updateFolderPermissions","folderId","parentFolder","updatedFolder","permissions","Permissions","Folder","updateDescendantPermissions","child","updatedChild"],"mappings":";;AAIA,MAAMA,qBAAqB,CAACC,OAA2BC,SAC5CD,MAAM,QAAQ,GAAG,MAAM,CAACE,CAAAA,IAAKA,EAAE,QAAQ,KAAKD,OAAO,EAAE;AAMzD,MAAME,0BAA0B,CACnCH,OACAI,UACAC;IAEA,IAAIC;IACJN,MAAM,WAAW,CAACE,CAAAA;QACd,IAAIA,EAAE,EAAE,KAAKE,UAAU;YACnB,MAAMG,cAAcC,YAAY,MAAM,CAACN,EAAE,WAAW,EAAEG;YACtDC,gBAAgBG,OAAO,MAAM,CAAC;gBAAE,GAAGP,CAAC;gBAAEK;YAAY;YAClD,OAAOD;QACX;QACA,OAAOJ;IACX;IAEA,OAAOI;AACX;AAOO,MAAMI,8BAA8B,CAACV,OAA2BC;IACnE,KAAK,MAAMU,SAASZ,mBAAmBC,OAAOC,QAAS;QACnD,MAAMW,eAAeT,wBAAwBH,OAAOW,MAAM,EAAE,EAAEV;QAC9DS,4BAA4BV,OAAOY;IACvC;AACJ"}
@@ -1,4 +1,4 @@
1
- import { ApolloClient } from "@webiny/app-admin/features/apolloClient/abstraction.js";
1
+ import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient/index.js";
2
2
  import type { FolderDto } from "../../../domain/folder/FolderDto.js";
3
3
  import { FolderModelProvider } from "../../../features/folders/abstractions.js";
4
4
  import type { FolderGatewayDto } from "./abstractions.js";
@@ -15,11 +15,11 @@ export interface CreateFolderResponse {
15
15
  export interface CreateFolderVariables {
16
16
  data: Omit<FolderDto, "id" | "path" | "createdOn" | "createdBy" | "savedOn" | "savedBy" | "modifiedOn" | "modifiedBy" | "hasNonInheritedPermissions" | "canManageContent" | "canManagePermissions" | "canManageStructure">;
17
17
  }
18
- export declare const CREATE_FOLDER: (FOLDER_FIELDS: string) => import("graphql").DocumentNode;
18
+ export declare const CREATE_FOLDER: (FOLDER_FIELDS: string) => string;
19
19
  declare class CreateFolderGqlGatewayImpl implements GatewayAbstraction.Interface {
20
20
  private client;
21
21
  private folderModelProvider;
22
- constructor(client: ApolloClient.Interface, folderModelProvider: FolderModelProvider.Interface);
22
+ constructor(client: MainGraphQLClient.Interface, folderModelProvider: FolderModelProvider.Interface);
23
23
  execute(folder: FolderGatewayDto): Promise<FolderDto>;
24
24
  }
25
25
  export declare const CreateFolderGqlGateway: typeof CreateFolderGqlGatewayImpl & {
@@ -1,21 +1,20 @@
1
- import graphql_tag from "graphql-tag";
2
- import { ApolloClient } from "@webiny/app-admin/features/apolloClient/abstraction.js";
1
+ import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient/index.js";
3
2
  import { FolderModelProvider } from "../abstractions.js";
4
3
  import { CreateFolderGateway } from "./abstractions.js";
5
- const CREATE_FOLDER = (FOLDER_FIELDS)=>graphql_tag`
6
- mutation CreateFolder($data: FolderCreateInput!) {
7
- aco {
8
- createFolder(data: $data) {
9
- data ${FOLDER_FIELDS}
10
- error {
11
- code
12
- data
13
- message
14
- }
4
+ const CREATE_FOLDER = (FOLDER_FIELDS)=>`
5
+ mutation CreateFolder($data: FolderCreateInput!) {
6
+ aco {
7
+ createFolder(data: $data) {
8
+ data ${FOLDER_FIELDS}
9
+ error {
10
+ code
11
+ data
12
+ message
15
13
  }
16
14
  }
17
15
  }
18
- `;
16
+ }
17
+ `;
19
18
  class CreateFolderGqlGatewayImpl {
20
19
  constructor(client, folderModelProvider){
21
20
  this.client = client;
@@ -23,8 +22,8 @@ class CreateFolderGqlGatewayImpl {
23
22
  }
24
23
  async execute(folder) {
25
24
  const fields = await this.folderModelProvider.getGraphQLSelection();
26
- const { data: response } = await this.client.mutate({
27
- mutation: CREATE_FOLDER(fields),
25
+ const response = await this.client.execute({
26
+ query: CREATE_FOLDER(fields),
28
27
  variables: {
29
28
  data: {
30
29
  ...folder
@@ -40,7 +39,7 @@ class CreateFolderGqlGatewayImpl {
40
39
  const CreateFolderGqlGateway = CreateFolderGateway.createImplementation({
41
40
  implementation: CreateFolderGqlGatewayImpl,
42
41
  dependencies: [
43
- ApolloClient,
42
+ MainGraphQLClient,
44
43
  FolderModelProvider
45
44
  ]
46
45
  });
@@ -1 +1 @@
1
- {"version":3,"file":"features/folders/createFolder/CreateFolderGqlGateway.js","sources":["../../../../src/features/folders/createFolder/CreateFolderGqlGateway.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport { ApolloClient } from \"@webiny/app-admin/features/apolloClient/abstraction.js\";\nimport type { FolderDto } from \"~/domain/folder/FolderDto.js\";\nimport { FolderModelProvider } from \"~/features/folders/abstractions.js\";\nimport type { FolderGatewayDto } from \"./abstractions.js\";\nimport { CreateFolderGateway as GatewayAbstraction } from \"./abstractions.js\";\nimport type { AcoError } from \"~/types.js\";\n\nexport interface CreateFolderResponse {\n aco: {\n createFolder: {\n data: FolderDto;\n error: AcoError | null;\n };\n };\n}\n\nexport interface CreateFolderVariables {\n data: Omit<\n FolderDto,\n | \"id\"\n | \"path\"\n | \"createdOn\"\n | \"createdBy\"\n | \"savedOn\"\n | \"savedBy\"\n | \"modifiedOn\"\n | \"modifiedBy\"\n | \"hasNonInheritedPermissions\"\n | \"canManageContent\"\n | \"canManagePermissions\"\n | \"canManageStructure\"\n >;\n}\n\nexport const CREATE_FOLDER = (FOLDER_FIELDS: string) => gql`\n mutation CreateFolder($data: FolderCreateInput!) {\n aco {\n createFolder(data: $data) {\n data ${FOLDER_FIELDS}\n error {\n code\n data\n message\n }\n }\n }\n }\n `;\n\nclass CreateFolderGqlGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: ApolloClient.Interface,\n private folderModelProvider: FolderModelProvider.Interface\n ) {}\n\n async execute(folder: FolderGatewayDto) {\n const fields = await this.folderModelProvider.getGraphQLSelection();\n\n const { data: response } = await this.client.mutate<\n CreateFolderResponse,\n CreateFolderVariables\n >({\n mutation: CREATE_FOLDER(fields),\n variables: {\n data: {\n ...folder\n }\n }\n });\n\n if (!response) {\n throw new Error(\"Network error while creating folder.\");\n }\n\n const { data, error } = response.aco.createFolder;\n\n if (!data) {\n throw new Error(error?.message || \"Could not create folder\");\n }\n\n return data;\n }\n}\n\nexport const CreateFolderGqlGateway = GatewayAbstraction.createImplementation({\n implementation: CreateFolderGqlGatewayImpl,\n dependencies: [ApolloClient, FolderModelProvider]\n});\n"],"names":["CREATE_FOLDER","FOLDER_FIELDS","gql","CreateFolderGqlGatewayImpl","client","folderModelProvider","folder","fields","response","Error","data","error","CreateFolderGqlGateway","GatewayAbstraction","ApolloClient","FolderModelProvider"],"mappings":";;;;AAmCO,MAAMA,gBAAgB,CAACC,gBAA0BC,WAAG,CAAC;;;;yBAInC,EAAED,cAAc;;;;;;;;;IASrC,CAAC;AAEL,MAAME;IACF,YACYC,MAA8B,EAC9BC,mBAAkD,CAC5D;aAFUD,MAAM,GAANA;aACAC,mBAAmB,GAAnBA;IACT;IAEH,MAAM,QAAQC,MAAwB,EAAE;QACpC,MAAMC,SAAS,MAAM,IAAI,CAAC,mBAAmB,CAAC,mBAAmB;QAEjE,MAAM,EAAE,MAAMC,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAGjD;YACE,UAAUR,cAAcO;YACxB,WAAW;gBACP,MAAM;oBACF,GAAGD,MAAM;gBACb;YACJ;QACJ;QAEA,IAAI,CAACE,UACD,MAAM,IAAIC,MAAM;QAGpB,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGH,SAAS,GAAG,CAAC,YAAY;QAEjD,IAAI,CAACE,MACD,MAAM,IAAID,MAAME,OAAO,WAAW;QAGtC,OAAOD;IACX;AACJ;AAEO,MAAME,yBAAyBC,oBAAAA,oBAAuC,CAAC;IAC1E,gBAAgBV;IAChB,cAAc;QAACW;QAAcC;KAAoB;AACrD"}
1
+ {"version":3,"file":"features/folders/createFolder/CreateFolderGqlGateway.js","sources":["../../../../src/features/folders/createFolder/CreateFolderGqlGateway.ts"],"sourcesContent":["import { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient/index.js\";\nimport type { FolderDto } from \"~/domain/folder/FolderDto.js\";\nimport { FolderModelProvider } from \"~/features/folders/abstractions.js\";\nimport type { FolderGatewayDto } from \"./abstractions.js\";\nimport { CreateFolderGateway as GatewayAbstraction } from \"./abstractions.js\";\nimport type { AcoError } from \"~/types.js\";\n\nexport interface CreateFolderResponse {\n aco: {\n createFolder: {\n data: FolderDto;\n error: AcoError | null;\n };\n };\n}\n\nexport interface CreateFolderVariables {\n data: Omit<\n FolderDto,\n | \"id\"\n | \"path\"\n | \"createdOn\"\n | \"createdBy\"\n | \"savedOn\"\n | \"savedBy\"\n | \"modifiedOn\"\n | \"modifiedBy\"\n | \"hasNonInheritedPermissions\"\n | \"canManageContent\"\n | \"canManagePermissions\"\n | \"canManageStructure\"\n >;\n}\n\nexport const CREATE_FOLDER = (FOLDER_FIELDS: string) => /* GraphQL */ `\n mutation CreateFolder($data: FolderCreateInput!) {\n aco {\n createFolder(data: $data) {\n data ${FOLDER_FIELDS}\n error {\n code\n data\n message\n }\n }\n }\n }\n`;\n\nclass CreateFolderGqlGatewayImpl implements GatewayAbstraction.Interface {\n constructor(\n private client: MainGraphQLClient.Interface,\n private folderModelProvider: FolderModelProvider.Interface\n ) {}\n\n async execute(folder: FolderGatewayDto) {\n const fields = await this.folderModelProvider.getGraphQLSelection();\n\n const response = await this.client.execute<CreateFolderResponse, CreateFolderVariables>({\n query: CREATE_FOLDER(fields),\n variables: {\n data: {\n ...folder\n }\n }\n });\n\n if (!response) {\n throw new Error(\"Network error while creating folder.\");\n }\n\n const { data, error } = response.aco.createFolder;\n\n if (!data) {\n throw new Error(error?.message || \"Could not create folder\");\n }\n\n return data;\n }\n}\n\nexport const CreateFolderGqlGateway = GatewayAbstraction.createImplementation({\n implementation: CreateFolderGqlGatewayImpl,\n dependencies: [MainGraphQLClient, FolderModelProvider]\n});\n"],"names":["CREATE_FOLDER","FOLDER_FIELDS","CreateFolderGqlGatewayImpl","client","folderModelProvider","folder","fields","response","Error","data","error","CreateFolderGqlGateway","GatewayAbstraction","MainGraphQLClient","FolderModelProvider"],"mappings":";;;AAkCO,MAAMA,gBAAgB,CAACC,gBAAwC,CAAC;;;;qBAIlD,EAAEA,cAAc;;;;;;;;;AASrC,CAAC;AAED,MAAMC;IACF,YACYC,MAAmC,EACnCC,mBAAkD,CAC5D;aAFUD,MAAM,GAANA;aACAC,mBAAmB,GAAnBA;IACT;IAEH,MAAM,QAAQC,MAAwB,EAAE;QACpC,MAAMC,SAAS,MAAM,IAAI,CAAC,mBAAmB,CAAC,mBAAmB;QAEjE,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA8C;YACpF,OAAOP,cAAcM;YACrB,WAAW;gBACP,MAAM;oBACF,GAAGD,MAAM;gBACb;YACJ;QACJ;QAEA,IAAI,CAACE,UACD,MAAM,IAAIC,MAAM;QAGpB,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGH,SAAS,GAAG,CAAC,YAAY;QAEjD,IAAI,CAACE,MACD,MAAM,IAAID,MAAME,OAAO,WAAW;QAGtC,OAAOD;IACX;AACJ;AAEO,MAAME,yBAAyBC,oBAAAA,oBAAuC,CAAC;IAC1E,gBAAgBV;IAChB,cAAc;QAACW;QAAmBC;KAAoB;AAC1D"}
@@ -1,4 +1,4 @@
1
- import { ApolloClient } from "@webiny/app-admin/features/apolloClient/abstraction.js";
1
+ import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient/index.js";
2
2
  import { DeleteFolderGateway as GatewayAbstraction } from "./abstractions.js";
3
3
  import type { AcoError } from "../../../types.js";
4
4
  export interface DeleteFolderVariables {
@@ -12,10 +12,10 @@ export interface DeleteFolderResponse {
12
12
  };
13
13
  };
14
14
  }
15
- export declare const DELETE_FOLDER: import("graphql").DocumentNode;
15
+ export declare const DELETE_FOLDER = "\n mutation DeleteFolder($id: ID!) {\n aco {\n deleteFolder(id: $id) {\n data\n error {\n code\n data\n message\n }\n }\n }\n }\n";
16
16
  declare class DeleteFolderGqlGatewayImpl implements GatewayAbstraction.Interface {
17
17
  private client;
18
- constructor(client: ApolloClient.Interface);
18
+ constructor(client: MainGraphQLClient.Interface);
19
19
  execute(id: string): Promise<void>;
20
20
  }
21
21
  export declare const DeleteFolderGqlGateway: typeof DeleteFolderGqlGatewayImpl & {
@@ -1,7 +1,6 @@
1
- import graphql_tag from "graphql-tag";
2
- import { ApolloClient } from "@webiny/app-admin/features/apolloClient/abstraction.js";
1
+ import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient/index.js";
3
2
  import { DeleteFolderGateway } from "./abstractions.js";
4
- const DELETE_FOLDER = graphql_tag`
3
+ const DELETE_FOLDER = `
5
4
  mutation DeleteFolder($id: ID!) {
6
5
  aco {
7
6
  deleteFolder(id: $id) {
@@ -20,8 +19,8 @@ class DeleteFolderGqlGatewayImpl {
20
19
  this.client = client;
21
20
  }
22
21
  async execute(id) {
23
- const { data: response } = await this.client.mutate({
24
- mutation: DELETE_FOLDER,
22
+ const response = await this.client.execute({
23
+ query: DELETE_FOLDER,
25
24
  variables: {
26
25
  id
27
26
  }
@@ -34,7 +33,7 @@ class DeleteFolderGqlGatewayImpl {
34
33
  const DeleteFolderGqlGateway = DeleteFolderGateway.createImplementation({
35
34
  implementation: DeleteFolderGqlGatewayImpl,
36
35
  dependencies: [
37
- ApolloClient
36
+ MainGraphQLClient
38
37
  ]
39
38
  });
40
39
  export { DELETE_FOLDER, DeleteFolderGqlGateway };
@@ -1 +1 @@
1
- {"version":3,"file":"features/folders/deleteFolder/DeleteFolderGqlGateway.js","sources":["../../../../src/features/folders/deleteFolder/DeleteFolderGqlGateway.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport { ApolloClient } from \"@webiny/app-admin/features/apolloClient/abstraction.js\";\nimport { DeleteFolderGateway as GatewayAbstraction } from \"./abstractions.js\";\nimport type { AcoError } from \"~/types.js\";\n\nexport interface DeleteFolderVariables {\n id: string;\n}\n\nexport interface DeleteFolderResponse {\n aco: {\n deleteFolder: {\n data: boolean;\n error: AcoError | null;\n };\n };\n}\n\nexport const DELETE_FOLDER = gql`\n mutation DeleteFolder($id: ID!) {\n aco {\n deleteFolder(id: $id) {\n data\n error {\n code\n data\n message\n }\n }\n }\n }\n`;\n\nclass DeleteFolderGqlGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: ApolloClient.Interface) {}\n\n async execute(id: string) {\n const { data: response } = await this.client.mutate<\n DeleteFolderResponse,\n DeleteFolderVariables\n >({\n mutation: DELETE_FOLDER,\n variables: {\n id\n }\n });\n\n if (!response) {\n throw new Error(\"Network error while deleting folder\");\n }\n\n const { data, error } = response.aco.deleteFolder;\n\n if (!data) {\n throw new Error(error?.message || \"Could not delete folder\");\n }\n\n return;\n }\n}\n\nexport const DeleteFolderGqlGateway = GatewayAbstraction.createImplementation({\n implementation: DeleteFolderGqlGatewayImpl,\n dependencies: [ApolloClient]\n});\n"],"names":["DELETE_FOLDER","gql","DeleteFolderGqlGatewayImpl","client","id","response","Error","data","error","DeleteFolderGqlGateway","GatewayAbstraction","ApolloClient"],"mappings":";;;AAkBO,MAAMA,gBAAgBC,WAAG,CAAC;;;;;;;;;;;;;AAajC,CAAC;AAED,MAAMC;IACF,YAAoBC,MAA8B,CAAE;aAAhCA,MAAM,GAANA;IAAiC;IAErD,MAAM,QAAQC,EAAU,EAAE;QACtB,MAAM,EAAE,MAAMC,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAGjD;YACE,UAAUL;YACV,WAAW;gBACPI;YACJ;QACJ;QAEA,IAAI,CAACC,UACD,MAAM,IAAIC,MAAM;QAGpB,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGH,SAAS,GAAG,CAAC,YAAY;QAEjD,IAAI,CAACE,MACD,MAAM,IAAID,MAAME,OAAO,WAAW;IAI1C;AACJ;AAEO,MAAMC,yBAAyBC,oBAAAA,oBAAuC,CAAC;IAC1E,gBAAgBR;IAChB,cAAc;QAACS;KAAa;AAChC"}
1
+ {"version":3,"file":"features/folders/deleteFolder/DeleteFolderGqlGateway.js","sources":["../../../../src/features/folders/deleteFolder/DeleteFolderGqlGateway.ts"],"sourcesContent":["import { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient/index.js\";\nimport { DeleteFolderGateway as GatewayAbstraction } from \"./abstractions.js\";\nimport type { AcoError } from \"~/types.js\";\n\nexport interface DeleteFolderVariables {\n id: string;\n}\n\nexport interface DeleteFolderResponse {\n aco: {\n deleteFolder: {\n data: boolean;\n error: AcoError | null;\n };\n };\n}\n\nexport const DELETE_FOLDER = /* GraphQL */ `\n mutation DeleteFolder($id: ID!) {\n aco {\n deleteFolder(id: $id) {\n data\n error {\n code\n data\n message\n }\n }\n }\n }\n`;\n\nclass DeleteFolderGqlGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: MainGraphQLClient.Interface) {}\n\n async execute(id: string) {\n const response = await this.client.execute<DeleteFolderResponse, DeleteFolderVariables>({\n query: DELETE_FOLDER,\n variables: {\n id\n }\n });\n\n if (!response) {\n throw new Error(\"Network error while deleting folder\");\n }\n\n const { data, error } = response.aco.deleteFolder;\n\n if (!data) {\n throw new Error(error?.message || \"Could not delete folder\");\n }\n\n return;\n }\n}\n\nexport const DeleteFolderGqlGateway = GatewayAbstraction.createImplementation({\n implementation: DeleteFolderGqlGatewayImpl,\n dependencies: [MainGraphQLClient]\n});\n"],"names":["DELETE_FOLDER","DeleteFolderGqlGatewayImpl","client","id","response","Error","data","error","DeleteFolderGqlGateway","GatewayAbstraction","MainGraphQLClient"],"mappings":";;AAiBO,MAAMA,gBAA8B,CAAC;;;;;;;;;;;;;AAa5C,CAAC;AAED,MAAMC;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,QAAQC,EAAU,EAAE;QACtB,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA8C;YACpF,OAAOJ;YACP,WAAW;gBACPG;YACJ;QACJ;QAEA,IAAI,CAACC,UACD,MAAM,IAAIC,MAAM;QAGpB,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGH,SAAS,GAAG,CAAC,YAAY;QAEjD,IAAI,CAACE,MACD,MAAM,IAAID,MAAME,OAAO,WAAW;IAI1C;AACJ;AAEO,MAAMC,yBAAyBC,oBAAAA,oBAAuC,CAAC;IAC1E,gBAAgBR;IAChB,cAAc;QAACS;KAAkB;AACrC"}
@@ -0,0 +1,22 @@
1
+ import { GetFolderGateway } from "../../../features/folders/getFolder/abstractions.js";
2
+ import { FolderCreatedEventHandler } from "./abstractions.js";
3
+ /**
4
+ * Reads the folder back and puts it in the cache for its type, so every open folder tree of that
5
+ * type shows it.
6
+ *
7
+ * Read back rather than taken from the event, so the folder has the same fields and the same
8
+ * permission checks as any other the admin loads. `addItems` replaces by id, so an event that
9
+ * arrives twice, or for a folder already loaded, changes nothing.
10
+ *
11
+ * The cache is reached through `folderCacheFactory` rather than injected, because this runs in the
12
+ * root container and each folder type's cache is registered in its own view's child container.
13
+ */
14
+ declare class AddCreatedFolderToCacheImpl implements FolderCreatedEventHandler.Interface {
15
+ private getFolder;
16
+ constructor(getFolder: GetFolderGateway.Interface);
17
+ handle(event: FolderCreatedEventHandler.Event): Promise<void>;
18
+ }
19
+ export declare const AddCreatedFolderToCache: typeof AddCreatedFolderToCacheImpl & {
20
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/app/features/eventPublisher/abstractions.js").IEventHandler<import("./FolderCreatedEvent.js").FolderCreatedEvent>>;
21
+ };
22
+ export {};
@@ -0,0 +1,24 @@
1
+ import { GetFolderGateway } from "../getFolder/abstractions.js";
2
+ import { folderCacheFactory } from "../cache/index.js";
3
+ import { Folder } from "../../../domain/folder/Folder.js";
4
+ import { FolderCreatedEventHandler } from "./abstractions.js";
5
+ class AddCreatedFolderToCacheImpl {
6
+ constructor(getFolder){
7
+ this.getFolder = getFolder;
8
+ }
9
+ async handle(event) {
10
+ const folder = Folder.create(await this.getFolder.execute(event.payload.id));
11
+ folderCacheFactory.getCache(folder.type).addItems([
12
+ folder
13
+ ]);
14
+ }
15
+ }
16
+ const AddCreatedFolderToCache = FolderCreatedEventHandler.createImplementation({
17
+ implementation: AddCreatedFolderToCacheImpl,
18
+ dependencies: [
19
+ GetFolderGateway
20
+ ]
21
+ });
22
+ export { AddCreatedFolderToCache };
23
+
24
+ //# sourceMappingURL=AddCreatedFolderToCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/folders/folderEvents/AddCreatedFolderToCache.js","sources":["../../../../src/features/folders/folderEvents/AddCreatedFolderToCache.ts"],"sourcesContent":["import { GetFolderGateway } from \"~/features/folders/getFolder/abstractions.js\";\nimport { folderCacheFactory } from \"~/features/folders/cache/index.js\";\nimport { Folder } from \"~/domain/folder/Folder.js\";\nimport { FolderCreatedEventHandler } from \"./abstractions.js\";\n\n/**\n * Reads the folder back and puts it in the cache for its type, so every open folder tree of that\n * type shows it.\n *\n * Read back rather than taken from the event, so the folder has the same fields and the same\n * permission checks as any other the admin loads. `addItems` replaces by id, so an event that\n * arrives twice, or for a folder already loaded, changes nothing.\n *\n * The cache is reached through `folderCacheFactory` rather than injected, because this runs in the\n * root container and each folder type's cache is registered in its own view's child container.\n */\nclass AddCreatedFolderToCacheImpl implements FolderCreatedEventHandler.Interface {\n constructor(private getFolder: GetFolderGateway.Interface) {}\n\n async handle(event: FolderCreatedEventHandler.Event): Promise<void> {\n const folder = Folder.create(await this.getFolder.execute(event.payload.id));\n\n folderCacheFactory.getCache(folder.type).addItems([folder]);\n }\n}\n\nexport const AddCreatedFolderToCache = FolderCreatedEventHandler.createImplementation({\n implementation: AddCreatedFolderToCacheImpl,\n dependencies: [GetFolderGateway]\n});\n"],"names":["AddCreatedFolderToCacheImpl","getFolder","event","folder","Folder","folderCacheFactory","AddCreatedFolderToCache","FolderCreatedEventHandler","GetFolderGateway"],"mappings":";;;;AAgBA,MAAMA;IACF,YAAoBC,SAAqC,CAAE;aAAvCA,SAAS,GAATA;IAAwC;IAE5D,MAAM,OAAOC,KAAsC,EAAiB;QAChE,MAAMC,SAASC,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACF,MAAM,OAAO,CAAC,EAAE;QAE1EG,mBAAmB,QAAQ,CAACF,OAAO,IAAI,EAAE,QAAQ,CAAC;YAACA;SAAO;IAC9D;AACJ;AAEO,MAAMG,0BAA0BC,0BAA0B,oBAAoB,CAAC;IAClF,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC"}
@@ -0,0 +1,14 @@
1
+ import { BaseEvent } from "@webiny/app/features/eventPublisher/index.js";
2
+ export interface FolderCreatedPayload {
3
+ id: string;
4
+ }
5
+ /**
6
+ * A folder now exists that the admin's cache may not have.
7
+ *
8
+ * Deliberately says nothing about where the news came from. The websocket is one source today; the
9
+ * palette or a background task can publish the same event, and the handlers do not change.
10
+ */
11
+ export declare class FolderCreatedEvent extends BaseEvent<FolderCreatedPayload> {
12
+ readonly eventType: "Aco/FolderCreated";
13
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/app/features/eventPublisher/abstractions.js").IEventHandler<FolderCreatedEvent>>;
14
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseEvent } from "@webiny/app/features/eventPublisher/index.js";
2
+ import { FolderCreatedEventHandler } from "./abstractions.js";
3
+ class FolderCreatedEvent extends BaseEvent {
4
+ getHandlerAbstraction() {
5
+ return FolderCreatedEventHandler;
6
+ }
7
+ constructor(...args){
8
+ super(...args), this.eventType = "Aco/FolderCreated";
9
+ }
10
+ }
11
+ export { FolderCreatedEvent };
12
+
13
+ //# sourceMappingURL=FolderCreatedEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/folders/folderEvents/FolderCreatedEvent.js","sources":["../../../../src/features/folders/folderEvents/FolderCreatedEvent.ts"],"sourcesContent":["import { BaseEvent } from \"@webiny/app/features/eventPublisher/index.js\";\nimport { FolderCreatedEventHandler } from \"./abstractions.js\";\n\nexport interface FolderCreatedPayload {\n id: string;\n}\n\n/**\n * A folder now exists that the admin's cache may not have.\n *\n * Deliberately says nothing about where the news came from. The websocket is one source today; the\n * palette or a background task can publish the same event, and the handlers do not change.\n */\nexport class FolderCreatedEvent extends BaseEvent<FolderCreatedPayload> {\n readonly eventType = \"Aco/FolderCreated\" as const;\n\n getHandlerAbstraction() {\n return FolderCreatedEventHandler;\n }\n}\n"],"names":["FolderCreatedEvent","BaseEvent","FolderCreatedEventHandler"],"mappings":";;AAaO,MAAMA,2BAA2BC;IAGpC,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACM,SAAS,GAAG;;AAKzB"}
@@ -0,0 +1,9 @@
1
+ import { BaseEvent } from "@webiny/app/features/eventPublisher/index.js";
2
+ export interface FolderDeletedPayload {
3
+ id: string;
4
+ }
5
+ /** A folder no longer exists, and the admin's cache may still hold it. */
6
+ export declare class FolderDeletedEvent extends BaseEvent<FolderDeletedPayload> {
7
+ readonly eventType: "Aco/FolderDeleted";
8
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/app/features/eventPublisher/abstractions.js").IEventHandler<FolderDeletedEvent>>;
9
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseEvent } from "@webiny/app/features/eventPublisher/index.js";
2
+ import { FolderDeletedEventHandler } from "./abstractions.js";
3
+ class FolderDeletedEvent extends BaseEvent {
4
+ getHandlerAbstraction() {
5
+ return FolderDeletedEventHandler;
6
+ }
7
+ constructor(...args){
8
+ super(...args), this.eventType = "Aco/FolderDeleted";
9
+ }
10
+ }
11
+ export { FolderDeletedEvent };
12
+
13
+ //# sourceMappingURL=FolderDeletedEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/folders/folderEvents/FolderDeletedEvent.js","sources":["../../../../src/features/folders/folderEvents/FolderDeletedEvent.ts"],"sourcesContent":["import { BaseEvent } from \"@webiny/app/features/eventPublisher/index.js\";\nimport { FolderDeletedEventHandler } from \"./abstractions.js\";\n\nexport interface FolderDeletedPayload {\n id: string;\n}\n\n/** A folder no longer exists, and the admin's cache may still hold it. */\nexport class FolderDeletedEvent extends BaseEvent<FolderDeletedPayload> {\n readonly eventType = \"Aco/FolderDeleted\" as const;\n\n getHandlerAbstraction() {\n return FolderDeletedEventHandler;\n }\n}\n"],"names":["FolderDeletedEvent","BaseEvent","FolderDeletedEventHandler"],"mappings":";;AAQO,MAAMA,2BAA2BC;IAGpC,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACM,SAAS,GAAG;;AAKzB"}