@webiny/app-scheduler 6.3.0 → 6.4.0-beta.0

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 (353) hide show
  1. package/Domain/Models/SchedulerItem/SchedulerItem.js +15 -14
  2. package/Domain/Models/SchedulerItem/SchedulerItem.js.map +1 -1
  3. package/Domain/Models/SchedulerItem/index.js +0 -2
  4. package/Domain/Models/index.js +0 -2
  5. package/Domain/Repositories/SchedulerItems/ISchedulerItemsRepository.js +0 -3
  6. package/Domain/Repositories/SchedulerItems/SchedulerItemsRepository.js +107 -116
  7. package/Domain/Repositories/SchedulerItems/SchedulerItemsRepository.js.map +1 -1
  8. package/Domain/Repositories/SchedulerItems/SchedulerItemsRepositoryFactory.js +13 -12
  9. package/Domain/Repositories/SchedulerItems/SchedulerItemsRepositoryFactory.js.map +1 -1
  10. package/Domain/Repositories/SchedulerItems/SchedulerItemsRepositoryWithLoading.js +34 -33
  11. package/Domain/Repositories/SchedulerItems/SchedulerItemsRepositoryWithLoading.js.map +1 -1
  12. package/Domain/Repositories/SchedulerItems/index.js +0 -2
  13. package/Domain/Repositories/Search/ISearchRepository.js +0 -3
  14. package/Domain/Repositories/Search/SearchRepository.js +12 -11
  15. package/Domain/Repositories/Search/SearchRepository.js.map +1 -1
  16. package/Domain/Repositories/Search/SearchRepositoryFactory.js +13 -12
  17. package/Domain/Repositories/Search/SearchRepositoryFactory.js.map +1 -1
  18. package/Domain/Repositories/Search/index.js +0 -2
  19. package/Domain/Repositories/SelectedItems/ISelectedItemsRepository.js +0 -3
  20. package/Domain/Repositories/SelectedItems/SelectedItemsRepository.js +24 -23
  21. package/Domain/Repositories/SelectedItems/SelectedItemsRepository.js.map +1 -1
  22. package/Domain/Repositories/SelectedItems/SelectedItemsRepositoryFactory.js +13 -12
  23. package/Domain/Repositories/SelectedItems/SelectedItemsRepositoryFactory.js.map +1 -1
  24. package/Domain/Repositories/SelectedItems/index.js +0 -2
  25. package/Domain/Repositories/Sorting/SortingRepositoryWithDefaults.js +16 -17
  26. package/Domain/Repositories/Sorting/SortingRepositoryWithDefaults.js.map +1 -1
  27. package/Domain/Repositories/Sorting/index.js +0 -2
  28. package/Domain/Repositories/index.js +0 -2
  29. package/Domain/index.js +0 -2
  30. package/Gateways/SchedulerCancelGraphQLGateway.js +23 -29
  31. package/Gateways/SchedulerCancelGraphQLGateway.js.map +1 -1
  32. package/Gateways/SchedulerGetGraphQLGateway.js +41 -45
  33. package/Gateways/SchedulerGetGraphQLGateway.js.map +1 -1
  34. package/Gateways/SchedulerListGraphQLGateway.js +42 -48
  35. package/Gateways/SchedulerListGraphQLGateway.js.map +1 -1
  36. package/Gateways/SchedulerPublishGraphQLGateway.js +31 -39
  37. package/Gateways/SchedulerPublishGraphQLGateway.js.map +1 -1
  38. package/Gateways/SchedulerUnpublishGraphQLGateway.js +35 -41
  39. package/Gateways/SchedulerUnpublishGraphQLGateway.js.map +1 -1
  40. package/Gateways/abstractions/CancelScheduledActionGateway.js +0 -3
  41. package/Gateways/abstractions/GetScheduledActionGateway.js +0 -3
  42. package/Gateways/abstractions/ListScheduledActionsGateway.js +0 -3
  43. package/Gateways/abstractions/SchedulePublishActionGateway.js +0 -3
  44. package/Gateways/abstractions/ScheduleUnpublishActionGateway.js +0 -3
  45. package/Gateways/graphql/fields.js +2 -3
  46. package/Gateways/graphql/fields.js.map +1 -1
  47. package/Gateways/index.js +0 -3
  48. package/Gateways/schema/schedulerEntry.js +13 -16
  49. package/Gateways/schema/schedulerEntry.js.map +1 -1
  50. package/Presentation/Scheduler/Scheduler.js +69 -58
  51. package/Presentation/Scheduler/Scheduler.js.map +1 -1
  52. package/Presentation/Scheduler/SchedulerControllers.js +49 -67
  53. package/Presentation/Scheduler/SchedulerControllers.js.map +1 -1
  54. package/Presentation/Scheduler/SchedulerPresenter.js +39 -38
  55. package/Presentation/Scheduler/SchedulerPresenter.js.map +1 -1
  56. package/Presentation/Scheduler/controllers/CancelItem/CancelItemController.js +9 -8
  57. package/Presentation/Scheduler/controllers/CancelItem/CancelItemController.js.map +1 -1
  58. package/Presentation/Scheduler/controllers/CancelItem/ICancelItemController.js +0 -3
  59. package/Presentation/Scheduler/controllers/CancelItem/index.js +0 -2
  60. package/Presentation/Scheduler/controllers/GetItem/GetItemController.js +9 -8
  61. package/Presentation/Scheduler/controllers/GetItem/GetItemController.js.map +1 -1
  62. package/Presentation/Scheduler/controllers/GetItem/IGetItemController.js +0 -3
  63. package/Presentation/Scheduler/controllers/GetItem/index.js +0 -2
  64. package/Presentation/Scheduler/controllers/ListItems/IListItemsController.js +0 -3
  65. package/Presentation/Scheduler/controllers/ListItems/ListItemsController.js +9 -8
  66. package/Presentation/Scheduler/controllers/ListItems/ListItemsController.js.map +1 -1
  67. package/Presentation/Scheduler/controllers/ListItems/index.js +0 -2
  68. package/Presentation/Scheduler/controllers/ListMoreItems/IListMoreItemsController.js +0 -3
  69. package/Presentation/Scheduler/controllers/ListMoreItems/ListMoreItemsController.js +9 -8
  70. package/Presentation/Scheduler/controllers/ListMoreItems/ListMoreItemsController.js.map +1 -1
  71. package/Presentation/Scheduler/controllers/ListMoreItems/index.js +0 -2
  72. package/Presentation/Scheduler/controllers/PublishItem/IPublishItemController.js +0 -3
  73. package/Presentation/Scheduler/controllers/PublishItem/PublishItemController.js +9 -8
  74. package/Presentation/Scheduler/controllers/PublishItem/PublishItemController.js.map +1 -1
  75. package/Presentation/Scheduler/controllers/PublishItem/index.js +0 -2
  76. package/Presentation/Scheduler/controllers/SearchItems/ISearchItemsController.js +0 -3
  77. package/Presentation/Scheduler/controllers/SearchItems/SearchItemsController.js +12 -11
  78. package/Presentation/Scheduler/controllers/SearchItems/SearchItemsController.js.map +1 -1
  79. package/Presentation/Scheduler/controllers/SearchItems/index.js +0 -2
  80. package/Presentation/Scheduler/controllers/SelectAllItems/ISelectAllItemsController.js +0 -3
  81. package/Presentation/Scheduler/controllers/SelectAllItems/SelectAllItemsController.js +9 -8
  82. package/Presentation/Scheduler/controllers/SelectAllItems/SelectAllItemsController.js.map +1 -1
  83. package/Presentation/Scheduler/controllers/SelectAllItems/index.js +0 -2
  84. package/Presentation/Scheduler/controllers/SelectItems/ISelectItemsController.js +0 -3
  85. package/Presentation/Scheduler/controllers/SelectItems/SelectItemsController.js +10 -9
  86. package/Presentation/Scheduler/controllers/SelectItems/SelectItemsController.js.map +1 -1
  87. package/Presentation/Scheduler/controllers/SelectItems/index.js +0 -2
  88. package/Presentation/Scheduler/controllers/SortItems/ISortItemsController.d.ts +2 -2
  89. package/Presentation/Scheduler/controllers/SortItems/ISortItemsController.js +0 -3
  90. package/Presentation/Scheduler/controllers/SortItems/SortItemsController.d.ts +2 -2
  91. package/Presentation/Scheduler/controllers/SortItems/SortItemsController.js +13 -14
  92. package/Presentation/Scheduler/controllers/SortItems/SortItemsController.js.map +1 -1
  93. package/Presentation/Scheduler/controllers/SortItems/index.js +0 -2
  94. package/Presentation/Scheduler/controllers/UnpublishItem/IUnpublishItemController.js +0 -3
  95. package/Presentation/Scheduler/controllers/UnpublishItem/UnpublishItemController.js +9 -8
  96. package/Presentation/Scheduler/controllers/UnpublishItem/UnpublishItemController.js.map +1 -1
  97. package/Presentation/Scheduler/controllers/UnpublishItem/index.js +0 -2
  98. package/Presentation/Scheduler/controllers/UnselectAllItems/IUnselectAllItemsController.js +0 -3
  99. package/Presentation/Scheduler/controllers/UnselectAllItems/UnselectAllItemsController.js +9 -8
  100. package/Presentation/Scheduler/controllers/UnselectAllItems/UnselectAllItemsController.js.map +1 -1
  101. package/Presentation/Scheduler/controllers/UnselectAllItems/index.js +0 -2
  102. package/Presentation/Scheduler/controllers/index.js +0 -2
  103. package/Presentation/Scheduler/index.js +0 -2
  104. package/Presentation/SchedulerConfigs/SchedulerConfigs.js +48 -51
  105. package/Presentation/SchedulerConfigs/SchedulerConfigs.js.map +1 -1
  106. package/Presentation/SchedulerConfigs/index.js +0 -2
  107. package/Presentation/SchedulerRenderer/SchedulerRenderer.js +10 -15
  108. package/Presentation/SchedulerRenderer/SchedulerRenderer.js.map +1 -1
  109. package/Presentation/SchedulerRenderer/index.js +0 -2
  110. package/Presentation/abstractions/ISchedulerControllers.js +0 -3
  111. package/Presentation/abstractions/ISchedulerPresenter.js +0 -3
  112. package/Presentation/abstractions/index.js +0 -3
  113. package/Presentation/components/Actions/CancelItem/CancelItem.js +14 -19
  114. package/Presentation/components/Actions/CancelItem/CancelItem.js.map +1 -1
  115. package/Presentation/components/Actions/CancelItem/index.js +0 -2
  116. package/Presentation/components/Actions/index.js +0 -2
  117. package/Presentation/components/BottomInfoBar/BottomInfoBar.js +11 -12
  118. package/Presentation/components/BottomInfoBar/BottomInfoBar.js.map +1 -1
  119. package/Presentation/components/BottomInfoBar/BottomInfoBar.styled.js +41 -67
  120. package/Presentation/components/BottomInfoBar/BottomInfoBar.styled.js.map +1 -1
  121. package/Presentation/components/BottomInfoBar/ListMeta.js +6 -9
  122. package/Presentation/components/BottomInfoBar/ListMeta.js.map +1 -1
  123. package/Presentation/components/BottomInfoBar/ListStatus.js +8 -12
  124. package/Presentation/components/BottomInfoBar/ListStatus.js.map +1 -1
  125. package/Presentation/components/BottomInfoBar/index.js +0 -2
  126. package/Presentation/components/Cells/CellActions/CellActions.js +12 -17
  127. package/Presentation/components/Cells/CellActions/CellActions.js.map +1 -1
  128. package/Presentation/components/Cells/CellActions/index.js +0 -2
  129. package/Presentation/components/Cells/CellRevision/CellRevision.js +9 -14
  130. package/Presentation/components/Cells/CellRevision/CellRevision.js.map +1 -1
  131. package/Presentation/components/Cells/CellRevision/CellRevision.styled.d.ts +1 -1
  132. package/Presentation/components/Cells/CellRevision/CellRevision.styled.js +16 -42
  133. package/Presentation/components/Cells/CellRevision/CellRevision.styled.js.map +1 -1
  134. package/Presentation/components/Cells/CellRevision/index.js +0 -2
  135. package/Presentation/components/Cells/CellScheduledBy/CellScheduledBy.js +6 -9
  136. package/Presentation/components/Cells/CellScheduledBy/CellScheduledBy.js.map +1 -1
  137. package/Presentation/components/Cells/CellScheduledBy/index.js +0 -2
  138. package/Presentation/components/Cells/CellScheduledOn/CellScheduledOn.js +11 -18
  139. package/Presentation/components/Cells/CellScheduledOn/CellScheduledOn.js.map +1 -1
  140. package/Presentation/components/Cells/CellScheduledOn/index.js +0 -2
  141. package/Presentation/components/Cells/CellTitle/CellTitle.js +9 -12
  142. package/Presentation/components/Cells/CellTitle/CellTitle.js.map +1 -1
  143. package/Presentation/components/Cells/CellTitle/CellTitle.styled.d.ts +1 -1
  144. package/Presentation/components/Cells/CellTitle/CellTitle.styled.js +16 -42
  145. package/Presentation/components/Cells/CellTitle/CellTitle.styled.js.map +1 -1
  146. package/Presentation/components/Cells/CellTitle/index.js +0 -2
  147. package/Presentation/components/Cells/CellType/CellActionType.js +10 -13
  148. package/Presentation/components/Cells/CellType/CellActionType.js.map +1 -1
  149. package/Presentation/components/Cells/CellType/CellActionType.styled.d.ts +1 -1
  150. package/Presentation/components/Cells/CellType/CellActionType.styled.js +16 -42
  151. package/Presentation/components/Cells/CellType/CellActionType.styled.js.map +1 -1
  152. package/Presentation/components/Cells/CellType/index.js +0 -2
  153. package/Presentation/components/Cells/index.js +0 -2
  154. package/Presentation/components/Empty/Empty.js +15 -16
  155. package/Presentation/components/Empty/Empty.js.map +1 -1
  156. package/Presentation/components/Empty/Empty.styled.js +14 -28
  157. package/Presentation/components/Empty/Empty.styled.js.map +1 -1
  158. package/Presentation/components/Empty/index.js +0 -2
  159. package/Presentation/components/ScheduleDialog/IScheduleDialogPresenter.js +0 -3
  160. package/Presentation/components/ScheduleDialog/ScheduleDialogPresenter.js +75 -79
  161. package/Presentation/components/ScheduleDialog/ScheduleDialogPresenter.js.map +1 -1
  162. package/Presentation/components/ScheduleDialog/index.js +0 -2
  163. package/Presentation/components/ScheduleDialog/types.js +0 -3
  164. package/Presentation/components/ScheduleDialog/useScheduleDialog.js +165 -207
  165. package/Presentation/components/ScheduleDialog/useScheduleDialog.js.map +1 -1
  166. package/Presentation/components/SchedulerOverlay/SchedulerOverlay.js +19 -25
  167. package/Presentation/components/SchedulerOverlay/SchedulerOverlay.js.map +1 -1
  168. package/Presentation/components/SchedulerOverlay/index.js +0 -2
  169. package/Presentation/components/SearchInput/SearchInput.js +25 -32
  170. package/Presentation/components/SearchInput/SearchInput.js.map +1 -1
  171. package/Presentation/components/SearchInput/index.js +0 -2
  172. package/Presentation/components/Table/Table.js +23 -28
  173. package/Presentation/components/Table/Table.js.map +1 -1
  174. package/Presentation/components/Table/index.js +0 -2
  175. package/Presentation/components/Title/Title.js +7 -12
  176. package/Presentation/components/Title/Title.js.map +1 -1
  177. package/Presentation/components/Title/Title.styled.d.ts +1 -2
  178. package/Presentation/components/Title/Title.styled.js +11 -16
  179. package/Presentation/components/Title/Title.styled.js.map +1 -1
  180. package/Presentation/components/Title/index.js +0 -2
  181. package/Presentation/configs/index.js +0 -2
  182. package/Presentation/configs/list/Browser/EntryAction.js +8 -11
  183. package/Presentation/configs/list/Browser/EntryAction.js.map +1 -1
  184. package/Presentation/configs/list/Browser/Table/Column.js +7 -10
  185. package/Presentation/configs/list/Browser/Table/Column.js.map +1 -1
  186. package/Presentation/configs/list/Browser/Table/Sorting.js +4 -7
  187. package/Presentation/configs/list/Browser/Table/Sorting.js.map +1 -1
  188. package/Presentation/configs/list/Browser/Table/index.js +4 -3
  189. package/Presentation/configs/list/Browser/Table/index.js.map +1 -1
  190. package/Presentation/configs/list/Browser/index.js +4 -3
  191. package/Presentation/configs/list/Browser/index.js.map +1 -1
  192. package/Presentation/configs/list/SchedulerListConfig.js +20 -21
  193. package/Presentation/configs/list/SchedulerListConfig.js.map +1 -1
  194. package/Presentation/configs/list/index.js +0 -2
  195. package/Presentation/hooks/index.js +0 -2
  196. package/Presentation/hooks/useCancelSchedulerItem.js +22 -27
  197. package/Presentation/hooks/useCancelSchedulerItem.js.map +1 -1
  198. package/Presentation/hooks/useScheduler.js +62 -46
  199. package/Presentation/hooks/useScheduler.js.map +1 -1
  200. package/Presentation/hooks/useSchedulerItem.js +4 -6
  201. package/Presentation/hooks/useSchedulerItem.js.map +1 -1
  202. package/Presentation/index.js +35 -42
  203. package/Presentation/index.js.map +1 -1
  204. package/UseCases/CancelItem/CancelItemUseCase.js +9 -8
  205. package/UseCases/CancelItem/CancelItemUseCase.js.map +1 -1
  206. package/UseCases/CancelItem/ICancelItemUseCase.js +0 -3
  207. package/UseCases/CancelItem/index.js +0 -2
  208. package/UseCases/GetItem/GetItemUseCase.js +9 -8
  209. package/UseCases/GetItem/GetItemUseCase.js.map +1 -1
  210. package/UseCases/GetItem/IGetItemUseCase.js +0 -3
  211. package/UseCases/GetItem/index.js +0 -2
  212. package/UseCases/GetScheduledItem/GetScheduledItemUseCase.js +10 -9
  213. package/UseCases/GetScheduledItem/GetScheduledItemUseCase.js.map +1 -1
  214. package/UseCases/GetScheduledItem/IGetScheduledItemUseCase.js +0 -3
  215. package/UseCases/GetScheduledItem/index.js +0 -2
  216. package/UseCases/ListItems/IListItemsUseCase.js +0 -3
  217. package/UseCases/ListItems/ListItemsUseCase.js +9 -8
  218. package/UseCases/ListItems/ListItemsUseCase.js.map +1 -1
  219. package/UseCases/ListItems/ListItemsUseCaseWithSearch.js +19 -18
  220. package/UseCases/ListItems/ListItemsUseCaseWithSearch.js.map +1 -1
  221. package/UseCases/ListItems/ListItemsUseCaseWithSorting.js +16 -17
  222. package/UseCases/ListItems/ListItemsUseCaseWithSorting.js.map +1 -1
  223. package/UseCases/ListItems/index.js +0 -2
  224. package/UseCases/ListMoreItems/IListMoreItemsUseCase.js +0 -3
  225. package/UseCases/ListMoreItems/ListMoreItemsUseCase.js +9 -8
  226. package/UseCases/ListMoreItems/ListMoreItemsUseCase.js.map +1 -1
  227. package/UseCases/ListMoreItems/index.js +0 -2
  228. package/UseCases/PublishItem/IPublishItemUseCase.js +0 -3
  229. package/UseCases/PublishItem/PublishItemUseCase.js +9 -8
  230. package/UseCases/PublishItem/PublishItemUseCase.js.map +1 -1
  231. package/UseCases/PublishItem/index.js +0 -2
  232. package/UseCases/SearchItems/ISearchItemsUseCase.js +0 -3
  233. package/UseCases/SearchItems/SearchItemsUseCase.js +9 -8
  234. package/UseCases/SearchItems/SearchItemsUseCase.js.map +1 -1
  235. package/UseCases/SearchItems/index.js +0 -2
  236. package/UseCases/SelectAllItems/ISelectAllItemsUseCase.js +0 -3
  237. package/UseCases/SelectAllItems/SelectAllItemsUseCase.js +9 -8
  238. package/UseCases/SelectAllItems/SelectAllItemsUseCase.js.map +1 -1
  239. package/UseCases/SelectAllItems/index.js +0 -2
  240. package/UseCases/SelectItems/ISelectItemsUseCase.js +0 -3
  241. package/UseCases/SelectItems/SelectItemsUseCase.js +9 -8
  242. package/UseCases/SelectItems/SelectItemsUseCase.js.map +1 -1
  243. package/UseCases/SelectItems/index.js +0 -2
  244. package/UseCases/SortItems/ISortItemsUseCase.js +0 -3
  245. package/UseCases/SortItems/SortItemsUseCase.js +9 -8
  246. package/UseCases/SortItems/SortItemsUseCase.js.map +1 -1
  247. package/UseCases/SortItems/index.js +0 -2
  248. package/UseCases/UnSelectAllItems/IUnselectAllItemsUseCase.js +0 -3
  249. package/UseCases/UnSelectAllItems/UnselectAllItemsUseCase.js +9 -8
  250. package/UseCases/UnSelectAllItems/UnselectAllItemsUseCase.js.map +1 -1
  251. package/UseCases/UnSelectAllItems/index.js +0 -2
  252. package/UseCases/UnpublishItem/IUnpublishItemUseCase.js +0 -3
  253. package/UseCases/UnpublishItem/UnpublishItemUseCase.js +9 -8
  254. package/UseCases/UnpublishItem/UnpublishItemUseCase.js.map +1 -1
  255. package/UseCases/UnpublishItem/index.js +0 -2
  256. package/UseCases/index.js +0 -2
  257. package/index.js +1 -3
  258. package/package.json +16 -18
  259. package/types.js +12 -11
  260. package/types.js.map +1 -1
  261. package/Domain/Models/SchedulerItem/index.js.map +0 -1
  262. package/Domain/Models/index.js.map +0 -1
  263. package/Domain/Repositories/SchedulerItems/ISchedulerItemsRepository.js.map +0 -1
  264. package/Domain/Repositories/SchedulerItems/index.js.map +0 -1
  265. package/Domain/Repositories/Search/ISearchRepository.js.map +0 -1
  266. package/Domain/Repositories/Search/index.js.map +0 -1
  267. package/Domain/Repositories/SelectedItems/ISelectedItemsRepository.js.map +0 -1
  268. package/Domain/Repositories/SelectedItems/index.js.map +0 -1
  269. package/Domain/Repositories/Sorting/index.js.map +0 -1
  270. package/Domain/Repositories/index.js.map +0 -1
  271. package/Domain/index.js.map +0 -1
  272. package/Gateways/abstractions/CancelScheduledActionGateway.js.map +0 -1
  273. package/Gateways/abstractions/GetScheduledActionGateway.js.map +0 -1
  274. package/Gateways/abstractions/ListScheduledActionsGateway.js.map +0 -1
  275. package/Gateways/abstractions/SchedulePublishActionGateway.js.map +0 -1
  276. package/Gateways/abstractions/ScheduleUnpublishActionGateway.js.map +0 -1
  277. package/Gateways/index.js.map +0 -1
  278. package/Presentation/Scheduler/controllers/CancelItem/ICancelItemController.js.map +0 -1
  279. package/Presentation/Scheduler/controllers/CancelItem/index.js.map +0 -1
  280. package/Presentation/Scheduler/controllers/GetItem/IGetItemController.js.map +0 -1
  281. package/Presentation/Scheduler/controllers/GetItem/index.js.map +0 -1
  282. package/Presentation/Scheduler/controllers/ListItems/IListItemsController.js.map +0 -1
  283. package/Presentation/Scheduler/controllers/ListItems/index.js.map +0 -1
  284. package/Presentation/Scheduler/controllers/ListMoreItems/IListMoreItemsController.js.map +0 -1
  285. package/Presentation/Scheduler/controllers/ListMoreItems/index.js.map +0 -1
  286. package/Presentation/Scheduler/controllers/PublishItem/IPublishItemController.js.map +0 -1
  287. package/Presentation/Scheduler/controllers/PublishItem/index.js.map +0 -1
  288. package/Presentation/Scheduler/controllers/SearchItems/ISearchItemsController.js.map +0 -1
  289. package/Presentation/Scheduler/controllers/SearchItems/index.js.map +0 -1
  290. package/Presentation/Scheduler/controllers/SelectAllItems/ISelectAllItemsController.js.map +0 -1
  291. package/Presentation/Scheduler/controllers/SelectAllItems/index.js.map +0 -1
  292. package/Presentation/Scheduler/controllers/SelectItems/ISelectItemsController.js.map +0 -1
  293. package/Presentation/Scheduler/controllers/SelectItems/index.js.map +0 -1
  294. package/Presentation/Scheduler/controllers/SortItems/ISortItemsController.js.map +0 -1
  295. package/Presentation/Scheduler/controllers/SortItems/index.js.map +0 -1
  296. package/Presentation/Scheduler/controllers/UnpublishItem/IUnpublishItemController.js.map +0 -1
  297. package/Presentation/Scheduler/controllers/UnpublishItem/index.js.map +0 -1
  298. package/Presentation/Scheduler/controllers/UnselectAllItems/IUnselectAllItemsController.js.map +0 -1
  299. package/Presentation/Scheduler/controllers/UnselectAllItems/index.js.map +0 -1
  300. package/Presentation/Scheduler/controllers/index.js.map +0 -1
  301. package/Presentation/Scheduler/index.js.map +0 -1
  302. package/Presentation/SchedulerConfigs/index.js.map +0 -1
  303. package/Presentation/SchedulerRenderer/index.js.map +0 -1
  304. package/Presentation/abstractions/ISchedulerControllers.js.map +0 -1
  305. package/Presentation/abstractions/ISchedulerPresenter.js.map +0 -1
  306. package/Presentation/abstractions/index.js.map +0 -1
  307. package/Presentation/components/Actions/CancelItem/index.js.map +0 -1
  308. package/Presentation/components/Actions/index.js.map +0 -1
  309. package/Presentation/components/BottomInfoBar/index.js.map +0 -1
  310. package/Presentation/components/Cells/CellActions/index.js.map +0 -1
  311. package/Presentation/components/Cells/CellRevision/index.js.map +0 -1
  312. package/Presentation/components/Cells/CellScheduledBy/index.js.map +0 -1
  313. package/Presentation/components/Cells/CellScheduledOn/index.js.map +0 -1
  314. package/Presentation/components/Cells/CellTitle/index.js.map +0 -1
  315. package/Presentation/components/Cells/CellType/index.js.map +0 -1
  316. package/Presentation/components/Cells/index.js.map +0 -1
  317. package/Presentation/components/Empty/index.js.map +0 -1
  318. package/Presentation/components/ScheduleDialog/IScheduleDialogPresenter.js.map +0 -1
  319. package/Presentation/components/ScheduleDialog/index.js.map +0 -1
  320. package/Presentation/components/ScheduleDialog/types.js.map +0 -1
  321. package/Presentation/components/SchedulerOverlay/index.js.map +0 -1
  322. package/Presentation/components/SearchInput/index.js.map +0 -1
  323. package/Presentation/components/Table/index.js.map +0 -1
  324. package/Presentation/components/Title/index.js.map +0 -1
  325. package/Presentation/configs/index.js.map +0 -1
  326. package/Presentation/configs/list/index.js.map +0 -1
  327. package/Presentation/hooks/index.js.map +0 -1
  328. package/UseCases/CancelItem/ICancelItemUseCase.js.map +0 -1
  329. package/UseCases/CancelItem/index.js.map +0 -1
  330. package/UseCases/GetItem/IGetItemUseCase.js.map +0 -1
  331. package/UseCases/GetItem/index.js.map +0 -1
  332. package/UseCases/GetScheduledItem/IGetScheduledItemUseCase.js.map +0 -1
  333. package/UseCases/GetScheduledItem/index.js.map +0 -1
  334. package/UseCases/ListItems/IListItemsUseCase.js.map +0 -1
  335. package/UseCases/ListItems/index.js.map +0 -1
  336. package/UseCases/ListMoreItems/IListMoreItemsUseCase.js.map +0 -1
  337. package/UseCases/ListMoreItems/index.js.map +0 -1
  338. package/UseCases/PublishItem/IPublishItemUseCase.js.map +0 -1
  339. package/UseCases/PublishItem/index.js.map +0 -1
  340. package/UseCases/SearchItems/ISearchItemsUseCase.js.map +0 -1
  341. package/UseCases/SearchItems/index.js.map +0 -1
  342. package/UseCases/SelectAllItems/ISelectAllItemsUseCase.js.map +0 -1
  343. package/UseCases/SelectAllItems/index.js.map +0 -1
  344. package/UseCases/SelectItems/ISelectItemsUseCase.js.map +0 -1
  345. package/UseCases/SelectItems/index.js.map +0 -1
  346. package/UseCases/SortItems/ISortItemsUseCase.js.map +0 -1
  347. package/UseCases/SortItems/index.js.map +0 -1
  348. package/UseCases/UnSelectAllItems/IUnselectAllItemsUseCase.js.map +0 -1
  349. package/UseCases/UnSelectAllItems/index.js.map +0 -1
  350. package/UseCases/UnpublishItem/IUnpublishItemUseCase.js.map +0 -1
  351. package/UseCases/UnpublishItem/index.js.map +0 -1
  352. package/UseCases/index.js.map +0 -1
  353. package/index.js.map +0 -1
@@ -1,234 +1,192 @@
1
- import React, { useCallback, useMemo, useRef } from "react";
1
+ import react, { useCallback, useMemo, useRef } from "react";
2
2
  import { Alert, Button, Grid, Input } from "@webiny/admin-ui";
3
- import { ReactComponent as DeleteIcon } from "@webiny/icons/delete.svg";
3
+ import { ReactComponent } from "@webiny/icons/delete.svg";
4
4
  import { useDialogs, useSnackbar } from "@webiny/app-admin";
5
5
  import { Bind } from "@webiny/form";
6
6
  import { validation } from "@webiny/validation";
7
7
  import { ScheduleActionType } from "../../../types.js";
8
- import ValidationError from "@webiny/validation/validationError.js";
8
+ import validationError from "@webiny/validation/validationError.js";
9
9
  import { makeDecoratable } from "@webiny/react-composition";
10
10
  import { SchedulerCancelGraphQLGateway } from "../../../Gateways/SchedulerCancelGraphQLGateway.js";
11
11
  import { SchedulerPublishGraphQLGateway } from "../../../Gateways/SchedulerPublishGraphQLGateway.js";
12
12
  import { SchedulerUnpublishGraphQLGateway } from "../../../Gateways/SchedulerUnpublishGraphQLGateway.js";
13
13
  import { SchedulerGetGraphQLGateway } from "../../../Gateways/SchedulerGetGraphQLGateway.js";
14
14
  import { ScheduleDialogPresenter } from "./ScheduleDialogPresenter.js";
15
- const dateToLocaleStringFormatter = new Intl.DateTimeFormat(undefined, {
16
- year: "numeric",
17
- month: "2-digit",
18
- day: "2-digit",
19
- hour: "2-digit",
20
- minute: "2-digit",
21
- second: undefined,
22
- hour12: false
15
+ const dateToLocaleStringFormatter = new Intl.DateTimeFormat(void 0, {
16
+ year: "numeric",
17
+ month: "2-digit",
18
+ day: "2-digit",
19
+ hour: "2-digit",
20
+ minute: "2-digit",
21
+ second: void 0,
22
+ hour12: false
23
23
  });
24
- const ReschedulingAlert = ({
25
- scheduleOn,
26
- actionType
27
- }) => {
28
- if (!scheduleOn || !actionType) {
29
- return null;
30
- }
31
- const actionName = actionType === ScheduleActionType.publish ? "publish" : "unpublish";
32
- return /*#__PURE__*/React.createElement(Alert, {
33
- type: "danger"
34
- }, /*#__PURE__*/React.createElement(React.Fragment, null, "A ", actionName, " is already scheduled at", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("strong", null, dateToLocaleStringFormatter.format(scheduleOn)), "."));
24
+ const ReschedulingAlert = ({ scheduleOn, actionType })=>{
25
+ if (!scheduleOn || !actionType) return null;
26
+ const actionName = actionType === ScheduleActionType.publish ? "publish" : "unpublish";
27
+ return /*#__PURE__*/ react.createElement(Alert, {
28
+ type: "danger"
29
+ }, /*#__PURE__*/ react.createElement(react.Fragment, null, "A ", actionName, " is already scheduled at", /*#__PURE__*/ react.createElement("br", null), /*#__PURE__*/ react.createElement("strong", null, dateToLocaleStringFormatter.format(scheduleOn)), "."));
35
30
  };
36
- /**
37
- * DO NOT use a library for this!
38
- */
39
- const padLeft = num => {
40
- return String(num).padStart(2, "0");
31
+ const padLeft = (num)=>String(num).padStart(2, "0");
32
+ const formatDateForDateTimeLocal = (date)=>{
33
+ if (!date) return;
34
+ if ("string" == typeof date) date = new Date(date);
35
+ const year = date.getFullYear();
36
+ const month = padLeft(date.getMonth() + 1);
37
+ const day = padLeft(date.getDate());
38
+ const hours = padLeft(date.getHours());
39
+ const minutes = padLeft(date.getMinutes());
40
+ return `${year}-${month}-${day}T${hours}:${minutes}`;
41
41
  };
42
- const formatDateForDateTimeLocal = date => {
43
- if (!date) {
44
- return undefined;
45
- } else if (typeof date === "string") {
46
- date = new Date(date);
47
- }
48
- const year = date.getFullYear();
49
- const month = padLeft(date.getMonth() + 1);
50
- const day = padLeft(date.getDate());
51
- const hours = padLeft(date.getHours());
52
- const minutes = padLeft(date.getMinutes());
53
- return `${year}-${month}-${day}T${hours}:${minutes}`;
54
- };
55
- const minDateValidator = input => {
56
- const value = new Date(input);
57
- const minDate = new Date(new Date().getTime() + 120 * 1000);
58
- if (minDate < value) {
59
- return;
60
- }
61
- throw new ValidationError(`The date must be at least 2 minutes in the future. Current minimum date is ${dateToLocaleStringFormatter.format(minDate)}.`);
42
+ const minDateValidator = (input)=>{
43
+ const value = new Date(input);
44
+ const minDate = new Date(new Date().getTime() + 120000);
45
+ if (minDate < value) return;
46
+ throw new validationError(`The date must be at least 2 minutes in the future. Current minimum date is ${dateToLocaleStringFormatter.format(minDate)}.`);
62
47
  };
63
48
  minDateValidator.validatorName = "minDateValidator";
64
- const CancelButtonComponent = ({
65
- enabled,
66
- onCancel
67
- }) => {
68
- if (!enabled) {
69
- return null;
70
- }
71
- return /*#__PURE__*/React.createElement(Button, {
72
- variant: "ghost",
73
- onClick: onCancel,
74
- text: "Cancel Schedule",
75
- size: "md",
76
- icon: /*#__PURE__*/React.createElement(DeleteIcon, null),
77
- iconPosition: "start"
78
- });
79
- };
80
- export const SchedulerDialogFormComponentDateTimeInput = makeDecoratable("SchedulerDialogFormComponentDateTimeInput", props => {
81
- const {
82
- bind
83
- } = props;
84
- return /*#__PURE__*/React.createElement(Input, Object.assign({}, bind, {
85
- value: formatDateForDateTimeLocal(bind.value),
86
- title: "Schedule On",
87
- label: "Schedule On",
88
- size: "lg",
89
- type: "datetime-local",
90
- required: true,
91
- autoFocus: true
92
- }));
93
- });
94
- const FormComponent = ({
95
- scheduleOn,
96
- actionType
97
- }) => {
98
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReschedulingAlert, {
99
- actionType: actionType,
100
- scheduleOn: scheduleOn
101
- }), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Grid.Column, {
102
- span: 12
103
- }, /*#__PURE__*/React.createElement(Bind, {
104
- name: "scheduleOn",
105
- validators: [validation.create("required"), minDateValidator]
106
- }, bind => {
107
- return /*#__PURE__*/React.createElement(SchedulerDialogFormComponentDateTimeInput, {
108
- bind: bind
49
+ const CancelButtonComponent = ({ enabled, onCancel })=>{
50
+ if (!enabled) return null;
51
+ return /*#__PURE__*/ react.createElement(Button, {
52
+ variant: "ghost",
53
+ onClick: onCancel,
54
+ text: "Cancel Schedule",
55
+ size: "md",
56
+ icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
57
+ iconPosition: "start"
109
58
  });
110
- }))));
111
59
  };
112
- export const useScheduleDialog = props => {
113
- const {
114
- client,
115
- target,
116
- namespace
117
- } = props;
118
- const dialog = useDialogs();
119
- const {
120
- showSnackbar
121
- } = useSnackbar();
122
- const presenter = useMemo(() => {
123
- return new ScheduleDialogPresenter({
124
- getGateway: new SchedulerGetGraphQLGateway(client),
125
- cancelGateway: new SchedulerCancelGraphQLGateway(client),
126
- publishGateway: new SchedulerPublishGraphQLGateway(client),
127
- unpublishGateway: new SchedulerUnpublishGraphQLGateway(client)
60
+ const SchedulerDialogFormComponentDateTimeInput = makeDecoratable("SchedulerDialogFormComponentDateTimeInput", (props)=>{
61
+ const { bind } = props;
62
+ return /*#__PURE__*/ react.createElement(Input, {
63
+ ...bind,
64
+ value: formatDateForDateTimeLocal(bind.value),
65
+ title: "Schedule On",
66
+ label: "Schedule On",
67
+ size: "lg",
68
+ type: "datetime-local",
69
+ required: true,
70
+ autoFocus: true
128
71
  });
129
- }, [client]);
130
- const dialogClose = useRef(() => {
131
- return;
132
- });
133
- const onAccept = useCallback(async params => {
134
- const {
135
- scheduleOn,
136
- actionType
137
- } = params;
138
- try {
139
- await presenter.schedule({
140
- targetId: target.id,
141
- namespace,
142
- scheduleOn,
143
- actionType
144
- });
145
- showSnackbar(`Scheduled ${actionType} action for "${target.title}"!`);
146
- } catch (error) {
147
- showSnackbar(error.message);
148
- console.error(error);
149
- }
150
- }, [presenter.vm]);
151
- const onCancel = useCallback(async () => {
152
- const entry = presenter.vm.entry;
153
- if (!entry) {
154
- showSnackbar(`No scheduled action found for "${target.title}"!`);
155
- if (dialogClose.current) {
156
- dialogClose.current();
157
- dialogClose.current = null;
158
- }
159
- return;
160
- }
161
- try {
162
- await presenter.cancel({
163
- id: entry.id,
164
- namespace: entry.namespace
165
- });
166
- showSnackbar(`Canceled scheduled ${entry.actionType} on "${entry.title}"!`);
167
- } catch (error) {
168
- showSnackbar(error.message);
169
- }
170
- if (!dialogClose.current) {
171
- return;
172
- }
173
- dialogClose.current();
174
- dialogClose.current = null;
175
- }, [presenter.vm]);
176
- const showDialog = async () => {
177
- await presenter.load({
178
- namespace,
179
- id: target.id
180
- });
181
- const isPublished = target.status === "published";
182
- const entry = presenter.vm.entry;
183
- const scheduleOn = entry?.publishOn || entry?.unpublishOn;
184
- dialogClose.current = dialog.showDialog({
185
- title: `Schedule "${target.title}"`,
186
- content: /*#__PURE__*/React.createElement(FormComponent, {
187
- actionType: entry?.actionType,
72
+ });
73
+ const FormComponent = ({ scheduleOn, actionType })=>/*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(ReschedulingAlert, {
74
+ actionType: actionType,
188
75
  scheduleOn: scheduleOn
189
- }),
190
- formData: {
191
- scheduleOn
192
- },
193
- acceptLabel: isPublished ? "Schedule Unpublish" : "Schedule Publish",
194
- cancelLabel: "Discard",
195
- loadingLabel: "Scheduling...",
196
- info: /*#__PURE__*/React.createElement(CancelButtonComponent, {
197
- enabled: !!scheduleOn,
198
- onCancel: onCancel
199
- }),
200
- onAccept: data => {
201
- if (!data.scheduleOn) {
202
- showSnackbar(`Missing "Schedule On" date!`);
203
- return;
76
+ }), /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
77
+ span: 12
78
+ }, /*#__PURE__*/ react.createElement(Bind, {
79
+ name: "scheduleOn",
80
+ validators: [
81
+ validation.create("required"),
82
+ minDateValidator
83
+ ]
84
+ }, (bind)=>/*#__PURE__*/ react.createElement(SchedulerDialogFormComponentDateTimeInput, {
85
+ bind: bind
86
+ })))));
87
+ const useScheduleDialog = (props)=>{
88
+ const { client, target, namespace } = props;
89
+ const dialog = useDialogs();
90
+ const { showSnackbar } = useSnackbar();
91
+ const presenter = useMemo(()=>new ScheduleDialogPresenter({
92
+ getGateway: new SchedulerGetGraphQLGateway(client),
93
+ cancelGateway: new SchedulerCancelGraphQLGateway(client),
94
+ publishGateway: new SchedulerPublishGraphQLGateway(client),
95
+ unpublishGateway: new SchedulerUnpublishGraphQLGateway(client)
96
+ }), [
97
+ client
98
+ ]);
99
+ const dialogClose = useRef(()=>{});
100
+ const onAccept = useCallback(async (params)=>{
101
+ const { scheduleOn, actionType } = params;
102
+ try {
103
+ await presenter.schedule({
104
+ targetId: target.id,
105
+ namespace,
106
+ scheduleOn,
107
+ actionType
108
+ });
109
+ showSnackbar(`Scheduled ${actionType} action for "${target.title}"!`);
110
+ } catch (error) {
111
+ showSnackbar(error.message);
112
+ console.error(error);
113
+ }
114
+ }, [
115
+ presenter.vm
116
+ ]);
117
+ const onCancel = useCallback(async ()=>{
118
+ const entry = presenter.vm.entry;
119
+ if (!entry) {
120
+ showSnackbar(`No scheduled action found for "${target.title}"!`);
121
+ if (dialogClose.current) {
122
+ dialogClose.current();
123
+ dialogClose.current = null;
124
+ }
125
+ return;
204
126
  }
205
- /**
206
- * We need to convert scheduleOn from local string to the ISO String (UTC) format.
207
- * This is important because the date will be stored in the database in UTC format.
208
- *
209
- * We display the date (in the UI) in users timezone time.
210
- */
211
- let scheduleOn;
212
127
  try {
213
- scheduleOn = new Date(data.scheduleOn);
214
- } catch (ex) {
215
- showSnackbar(`Invalid "Schedule On" date!`, {
216
- value: data.scheduleOn
217
- });
218
- console.error(ex);
219
- return;
128
+ await presenter.cancel({
129
+ id: entry.id,
130
+ namespace: entry.namespace
131
+ });
132
+ showSnackbar(`Canceled scheduled ${entry.actionType} on "${entry.title}"!`);
133
+ } catch (error) {
134
+ showSnackbar(error.message);
220
135
  }
221
- const actionType = isPublished ? ScheduleActionType.unpublish : ScheduleActionType.publish;
222
- return onAccept({
223
- scheduleOn,
224
- actionType
136
+ if (!dialogClose.current) return;
137
+ dialogClose.current();
138
+ dialogClose.current = null;
139
+ }, [
140
+ presenter.vm
141
+ ]);
142
+ const showDialog = async ()=>{
143
+ await presenter.load({
144
+ namespace,
145
+ id: target.id
225
146
  });
226
- }
227
- });
228
- };
229
- return {
230
- showDialog
231
- };
147
+ const isPublished = "published" === target.status;
148
+ const entry = presenter.vm.entry;
149
+ const scheduleOn = entry?.publishOn || entry?.unpublishOn;
150
+ dialogClose.current = dialog.showDialog({
151
+ title: `Schedule "${target.title}"`,
152
+ content: /*#__PURE__*/ react.createElement(FormComponent, {
153
+ actionType: entry?.actionType,
154
+ scheduleOn: scheduleOn
155
+ }),
156
+ formData: {
157
+ scheduleOn
158
+ },
159
+ acceptLabel: isPublished ? "Schedule Unpublish" : "Schedule Publish",
160
+ cancelLabel: "Discard",
161
+ loadingLabel: "Scheduling...",
162
+ info: /*#__PURE__*/ react.createElement(CancelButtonComponent, {
163
+ enabled: !!scheduleOn,
164
+ onCancel: onCancel
165
+ }),
166
+ onAccept: (data)=>{
167
+ if (!data.scheduleOn) return void showSnackbar('Missing "Schedule On" date!');
168
+ let scheduleOn;
169
+ try {
170
+ scheduleOn = new Date(data.scheduleOn);
171
+ } catch (ex) {
172
+ showSnackbar('Invalid "Schedule On" date!', {
173
+ value: data.scheduleOn
174
+ });
175
+ console.error(ex);
176
+ return;
177
+ }
178
+ const actionType = isPublished ? ScheduleActionType.unpublish : ScheduleActionType.publish;
179
+ return onAccept({
180
+ scheduleOn,
181
+ actionType
182
+ });
183
+ }
184
+ });
185
+ };
186
+ return {
187
+ showDialog
188
+ };
232
189
  };
190
+ export { SchedulerDialogFormComponentDateTimeInput, useScheduleDialog };
233
191
 
234
192
  //# sourceMappingURL=useScheduleDialog.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useCallback","useMemo","useRef","Alert","Button","Grid","Input","ReactComponent","DeleteIcon","useDialogs","useSnackbar","Bind","validation","ScheduleActionType","ValidationError","makeDecoratable","SchedulerCancelGraphQLGateway","SchedulerPublishGraphQLGateway","SchedulerUnpublishGraphQLGateway","SchedulerGetGraphQLGateway","ScheduleDialogPresenter","dateToLocaleStringFormatter","Intl","DateTimeFormat","undefined","year","month","day","hour","minute","second","hour12","ReschedulingAlert","scheduleOn","actionType","actionName","publish","createElement","type","Fragment","format","padLeft","num","String","padStart","formatDateForDateTimeLocal","date","Date","getFullYear","getMonth","getDate","hours","getHours","minutes","getMinutes","minDateValidator","input","value","minDate","getTime","validatorName","CancelButtonComponent","enabled","onCancel","variant","onClick","text","size","icon","iconPosition","SchedulerDialogFormComponentDateTimeInput","props","bind","Object","assign","title","label","required","autoFocus","FormComponent","Column","span","name","validators","create","useScheduleDialog","client","target","namespace","dialog","showSnackbar","presenter","getGateway","cancelGateway","publishGateway","unpublishGateway","dialogClose","onAccept","params","schedule","targetId","id","error","message","console","vm","entry","current","cancel","showDialog","load","isPublished","status","publishOn","unpublishOn","content","formData","acceptLabel","cancelLabel","loadingLabel","info","data","ex","unpublish"],"sources":["useScheduleDialog.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useRef } from \"react\";\nimport { Alert, Button, Grid, Input } from \"@webiny/admin-ui\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { useDialogs, useSnackbar } from \"@webiny/app-admin\";\nimport { Bind, type BindComponentRenderProp } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { ScheduleActionType } from \"~/types.js\";\nimport type { Validator } from \"@webiny/validation/types.js\";\nimport ValidationError from \"@webiny/validation/validationError.js\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport ApolloClient from \"apollo-client/ApolloClient.js\";\nimport { SchedulerCancelGraphQLGateway } from \"~/Gateways/SchedulerCancelGraphQLGateway.js\";\nimport { SchedulerPublishGraphQLGateway } from \"~/Gateways/SchedulerPublishGraphQLGateway.js\";\nimport { SchedulerUnpublishGraphQLGateway } from \"~/Gateways/SchedulerUnpublishGraphQLGateway.js\";\nimport { SchedulerGetGraphQLGateway } from \"~/Gateways/SchedulerGetGraphQLGateway.js\";\nimport { ScheduleDialogPresenter } from \"./ScheduleDialogPresenter.js\";\n\nexport type ShowDialogParamsEntryStatus = \"published\" | \"unpublished\" | \"draft\" | string;\n\nexport interface IShowDialogParamsEntry {\n id: string;\n status: ShowDialogParamsEntryStatus;\n title: string;\n}\n\ninterface UseShowScheduleDialogResponse {\n showDialog: () => void;\n}\n\ninterface FormComponentProps {\n scheduleOn: Date | undefined;\n actionType: ScheduleActionType | undefined;\n}\n\nconst dateToLocaleStringFormatter = new Intl.DateTimeFormat(undefined, {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: undefined,\n hour12: false\n});\n\ninterface IReschedulingAlertProps {\n scheduleOn: Date | undefined;\n actionType: ScheduleActionType | undefined;\n}\n\nconst ReschedulingAlert = ({ scheduleOn, actionType }: IReschedulingAlertProps) => {\n if (!scheduleOn || !actionType) {\n return null;\n }\n const actionName = actionType === ScheduleActionType.publish ? \"publish\" : \"unpublish\";\n return (\n <Alert type={\"danger\"}>\n <>\n A {actionName} is already scheduled at\n <br />\n <strong>{dateToLocaleStringFormatter.format(scheduleOn)}</strong>.\n </>\n </Alert>\n );\n};\n/**\n * DO NOT use a library for this!\n */\nconst padLeft = (num: number) => {\n return String(num).padStart(2, \"0\");\n};\n\nconst formatDateForDateTimeLocal = (date?: Date | string): string | undefined => {\n if (!date) {\n return undefined;\n } else if (typeof date === \"string\") {\n date = new Date(date);\n }\n\n const year = date.getFullYear();\n const month = padLeft(date.getMonth() + 1);\n const day = padLeft(date.getDate());\n const hours = padLeft(date.getHours());\n const minutes = padLeft(date.getMinutes());\n\n return `${year}-${month}-${day}T${hours}:${minutes}`;\n};\n\nconst minDateValidator: Validator = (input: string) => {\n const value = new Date(input);\n const minDate = new Date(new Date().getTime() + 120 * 1000);\n if (minDate < value) {\n return;\n }\n throw new ValidationError(\n `The date must be at least 2 minutes in the future. Current minimum date is ${dateToLocaleStringFormatter.format(\n minDate\n )}.`\n );\n};\n\nminDateValidator.validatorName = \"minDateValidator\";\n\nexport interface ISchedulerDialogFormComponentDateTimeInputProps {\n bind: BindComponentRenderProp<Date>;\n}\n\ninterface ICancelButtonComponentProps {\n enabled: boolean;\n onCancel: OnCancelCallable;\n}\nconst CancelButtonComponent = ({ enabled, onCancel }: ICancelButtonComponentProps) => {\n if (!enabled) {\n return null;\n }\n return (\n <Button\n variant=\"ghost\"\n onClick={onCancel}\n text={\"Cancel Schedule\"}\n size=\"md\"\n icon={<DeleteIcon />}\n iconPosition=\"start\"\n />\n );\n};\n\nexport const SchedulerDialogFormComponentDateTimeInput = makeDecoratable(\n \"SchedulerDialogFormComponentDateTimeInput\",\n (props: ISchedulerDialogFormComponentDateTimeInputProps) => {\n const { bind } = props;\n\n return (\n <Input\n {...bind}\n value={formatDateForDateTimeLocal(bind.value)}\n title={\"Schedule On\"}\n label={\"Schedule On\"}\n size={\"lg\"}\n type={\"datetime-local\"}\n required\n autoFocus\n />\n );\n }\n);\n\nconst FormComponent = ({ scheduleOn, actionType }: FormComponentProps) => {\n return (\n <>\n {<ReschedulingAlert actionType={actionType} scheduleOn={scheduleOn} />}\n <Grid>\n <Grid.Column span={12}>\n <Bind\n name={\"scheduleOn\"}\n validators={[validation.create(\"required\"), minDateValidator]}\n >\n {bind => {\n return <SchedulerDialogFormComponentDateTimeInput bind={bind} />;\n }}\n </Bind>\n </Grid.Column>\n </Grid>\n </>\n );\n};\n\ninterface ScheduleFormData {\n scheduleOn?: string;\n}\n\ninterface IOnAcceptParams {\n scheduleOn: Date;\n actionType: ScheduleActionType;\n}\n\ninterface OnCancelCallable {\n (): Promise<void>;\n}\n\nexport interface IUseScheduleDialogProps {\n client: ApolloClient<object>;\n namespace: string;\n target: IShowDialogParamsEntry;\n}\n\nexport const useScheduleDialog = (\n props: IUseScheduleDialogProps\n): UseShowScheduleDialogResponse => {\n const { client, target, namespace } = props;\n const dialog = useDialogs();\n const { showSnackbar } = useSnackbar();\n\n const presenter = useMemo(() => {\n return new ScheduleDialogPresenter({\n getGateway: new SchedulerGetGraphQLGateway(client),\n cancelGateway: new SchedulerCancelGraphQLGateway(client),\n publishGateway: new SchedulerPublishGraphQLGateway(client),\n unpublishGateway: new SchedulerUnpublishGraphQLGateway(client)\n });\n }, [client]);\n\n const dialogClose = useRef<null | (() => void)>(() => {\n return;\n });\n\n const onAccept = useCallback(\n async (params: IOnAcceptParams) => {\n const { scheduleOn, actionType } = params;\n\n try {\n await presenter.schedule({\n targetId: target.id,\n namespace,\n scheduleOn,\n actionType\n });\n showSnackbar(`Scheduled ${actionType} action for \"${target.title}\"!`);\n } catch (error) {\n showSnackbar(error.message);\n console.error(error);\n }\n },\n [presenter.vm]\n );\n\n const onCancel = useCallback(async () => {\n const entry = presenter.vm.entry;\n if (!entry) {\n showSnackbar(`No scheduled action found for \"${target.title}\"!`);\n if (dialogClose.current) {\n dialogClose.current();\n dialogClose.current = null;\n }\n return;\n }\n try {\n await presenter.cancel({\n id: entry.id,\n namespace: entry.namespace\n });\n showSnackbar(`Canceled scheduled ${entry.actionType} on \"${entry.title}\"!`);\n } catch (error) {\n showSnackbar(error.message);\n }\n if (!dialogClose.current) {\n return;\n }\n dialogClose.current();\n dialogClose.current = null;\n }, [presenter.vm]);\n\n const showDialog = async () => {\n await presenter.load({ namespace, id: target.id });\n\n const isPublished = target.status === \"published\";\n const entry = presenter.vm.entry;\n const scheduleOn = entry?.publishOn || entry?.unpublishOn;\n\n dialogClose.current = dialog.showDialog({\n title: `Schedule \"${target.title}\"`,\n content: <FormComponent actionType={entry?.actionType} scheduleOn={scheduleOn} />,\n formData: {\n scheduleOn\n },\n acceptLabel: isPublished ? \"Schedule Unpublish\" : \"Schedule Publish\",\n cancelLabel: \"Discard\",\n loadingLabel: \"Scheduling...\",\n info: <CancelButtonComponent enabled={!!scheduleOn} onCancel={onCancel} />,\n onAccept: (data: Partial<ScheduleFormData>) => {\n if (!data.scheduleOn) {\n showSnackbar(`Missing \"Schedule On\" date!`);\n return;\n }\n /**\n * We need to convert scheduleOn from local string to the ISO String (UTC) format.\n * This is important because the date will be stored in the database in UTC format.\n *\n * We display the date (in the UI) in users timezone time.\n */\n let scheduleOn: Date;\n try {\n scheduleOn = new Date(data.scheduleOn);\n } catch (ex) {\n showSnackbar(`Invalid \"Schedule On\" date!`, {\n value: data.scheduleOn\n });\n console.error(ex);\n return;\n }\n\n const actionType = isPublished\n ? ScheduleActionType.unpublish\n : ScheduleActionType.publish;\n\n return onAccept({\n scheduleOn,\n actionType\n });\n }\n });\n };\n\n return {\n showDialog\n };\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC3D,SAASC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,QAAQ,kBAAkB;AAC7D,SAASC,cAAc,IAAIC,UAAU,QAAQ,0BAA0B;AACvE,SAASC,UAAU,EAAEC,WAAW,QAAQ,mBAAmB;AAC3D,SAASC,IAAI,QAAsC,cAAc;AACjE,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,kBAAkB;AAE3B,OAAOC,eAAe,MAAM,uCAAuC;AACnE,SAASC,eAAe,QAAQ,2BAA2B;AAE3D,SAASC,6BAA6B;AACtC,SAASC,8BAA8B;AACvC,SAASC,gCAAgC;AACzC,SAASC,0BAA0B;AACnC,SAASC,uBAAuB;AAmBhC,MAAMC,2BAA2B,GAAG,IAAIC,IAAI,CAACC,cAAc,CAACC,SAAS,EAAE;EACnEC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,SAAS;EAChBC,GAAG,EAAE,SAAS;EACdC,IAAI,EAAE,SAAS;EACfC,MAAM,EAAE,SAAS;EACjBC,MAAM,EAAEN,SAAS;EACjBO,MAAM,EAAE;AACZ,CAAC,CAAC;AAOF,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC,UAAU;EAAEC;AAAoC,CAAC,KAAK;EAC/E,IAAI,CAACD,UAAU,IAAI,CAACC,UAAU,EAAE;IAC5B,OAAO,IAAI;EACf;EACA,MAAMC,UAAU,GAAGD,UAAU,KAAKrB,kBAAkB,CAACuB,OAAO,GAAG,SAAS,GAAG,WAAW;EACtF,oBACIrC,KAAA,CAAAsC,aAAA,CAAClC,KAAK;IAACmC,IAAI,EAAE;EAAS,gB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C;QAC1C,CAAC,CAAC,OAAOyF,EAAE,EAAE;UACThC,YAAY,CAAC,6BAA6B,EAAE;YACxCjC,KAAK,EAAEgE,IAAI,CAACxF;UAChB,CAAC,CAAC;UACFuE,OAAO,CAACF,KAAK,CAACoB,EAAE,CAAC;UACjB;QACJ;QAEA,MAAMxF,UAAU,GAAG6E,WAAW,GACxBlG,kBAAkB,CAAC8G,SAAS,GAC5B9G,kBAAkB,CAACuB,OAAO;QAEhC,OAAO6D,QAAQ,CAAC;UACZhE,UAAU;UACVC;QACJ,CAAC,CAAC;MACN;IACJ,CAAC,CAAC;EACN,CAAC;EAED,OAAO;IACH2E;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Presentation/components/ScheduleDialog/useScheduleDialog.js","sources":["../../../../src/Presentation/components/ScheduleDialog/useScheduleDialog.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useRef } from \"react\";\nimport { Alert, Button, Grid, Input } from \"@webiny/admin-ui\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { useDialogs, useSnackbar } from \"@webiny/app-admin\";\nimport { Bind, type BindComponentRenderProp } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { ScheduleActionType } from \"~/types.js\";\nimport type { Validator } from \"@webiny/validation/types.js\";\nimport ValidationError from \"@webiny/validation/validationError.js\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport ApolloClient from \"apollo-client/ApolloClient.js\";\nimport { SchedulerCancelGraphQLGateway } from \"~/Gateways/SchedulerCancelGraphQLGateway.js\";\nimport { SchedulerPublishGraphQLGateway } from \"~/Gateways/SchedulerPublishGraphQLGateway.js\";\nimport { SchedulerUnpublishGraphQLGateway } from \"~/Gateways/SchedulerUnpublishGraphQLGateway.js\";\nimport { SchedulerGetGraphQLGateway } from \"~/Gateways/SchedulerGetGraphQLGateway.js\";\nimport { ScheduleDialogPresenter } from \"./ScheduleDialogPresenter.js\";\n\nexport type ShowDialogParamsEntryStatus = \"published\" | \"unpublished\" | \"draft\" | string;\n\nexport interface IShowDialogParamsEntry {\n id: string;\n status: ShowDialogParamsEntryStatus;\n title: string;\n}\n\ninterface UseShowScheduleDialogResponse {\n showDialog: () => void;\n}\n\ninterface FormComponentProps {\n scheduleOn: Date | undefined;\n actionType: ScheduleActionType | undefined;\n}\n\nconst dateToLocaleStringFormatter = new Intl.DateTimeFormat(undefined, {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: undefined,\n hour12: false\n});\n\ninterface IReschedulingAlertProps {\n scheduleOn: Date | undefined;\n actionType: ScheduleActionType | undefined;\n}\n\nconst ReschedulingAlert = ({ scheduleOn, actionType }: IReschedulingAlertProps) => {\n if (!scheduleOn || !actionType) {\n return null;\n }\n const actionName = actionType === ScheduleActionType.publish ? \"publish\" : \"unpublish\";\n return (\n <Alert type={\"danger\"}>\n <>\n A {actionName} is already scheduled at\n <br />\n <strong>{dateToLocaleStringFormatter.format(scheduleOn)}</strong>.\n </>\n </Alert>\n );\n};\n/**\n * DO NOT use a library for this!\n */\nconst padLeft = (num: number) => {\n return String(num).padStart(2, \"0\");\n};\n\nconst formatDateForDateTimeLocal = (date?: Date | string): string | undefined => {\n if (!date) {\n return undefined;\n } else if (typeof date === \"string\") {\n date = new Date(date);\n }\n\n const year = date.getFullYear();\n const month = padLeft(date.getMonth() + 1);\n const day = padLeft(date.getDate());\n const hours = padLeft(date.getHours());\n const minutes = padLeft(date.getMinutes());\n\n return `${year}-${month}-${day}T${hours}:${minutes}`;\n};\n\nconst minDateValidator: Validator = (input: string) => {\n const value = new Date(input);\n const minDate = new Date(new Date().getTime() + 120 * 1000);\n if (minDate < value) {\n return;\n }\n throw new ValidationError(\n `The date must be at least 2 minutes in the future. Current minimum date is ${dateToLocaleStringFormatter.format(\n minDate\n )}.`\n );\n};\n\nminDateValidator.validatorName = \"minDateValidator\";\n\nexport interface ISchedulerDialogFormComponentDateTimeInputProps {\n bind: BindComponentRenderProp<Date>;\n}\n\ninterface ICancelButtonComponentProps {\n enabled: boolean;\n onCancel: OnCancelCallable;\n}\nconst CancelButtonComponent = ({ enabled, onCancel }: ICancelButtonComponentProps) => {\n if (!enabled) {\n return null;\n }\n return (\n <Button\n variant=\"ghost\"\n onClick={onCancel}\n text={\"Cancel Schedule\"}\n size=\"md\"\n icon={<DeleteIcon />}\n iconPosition=\"start\"\n />\n );\n};\n\nexport const SchedulerDialogFormComponentDateTimeInput = makeDecoratable(\n \"SchedulerDialogFormComponentDateTimeInput\",\n (props: ISchedulerDialogFormComponentDateTimeInputProps) => {\n const { bind } = props;\n\n return (\n <Input\n {...bind}\n value={formatDateForDateTimeLocal(bind.value)}\n title={\"Schedule On\"}\n label={\"Schedule On\"}\n size={\"lg\"}\n type={\"datetime-local\"}\n required\n autoFocus\n />\n );\n }\n);\n\nconst FormComponent = ({ scheduleOn, actionType }: FormComponentProps) => {\n return (\n <>\n {<ReschedulingAlert actionType={actionType} scheduleOn={scheduleOn} />}\n <Grid>\n <Grid.Column span={12}>\n <Bind\n name={\"scheduleOn\"}\n validators={[validation.create(\"required\"), minDateValidator]}\n >\n {bind => {\n return <SchedulerDialogFormComponentDateTimeInput bind={bind} />;\n }}\n </Bind>\n </Grid.Column>\n </Grid>\n </>\n );\n};\n\ninterface ScheduleFormData {\n scheduleOn?: string;\n}\n\ninterface IOnAcceptParams {\n scheduleOn: Date;\n actionType: ScheduleActionType;\n}\n\ninterface OnCancelCallable {\n (): Promise<void>;\n}\n\nexport interface IUseScheduleDialogProps {\n client: ApolloClient<object>;\n namespace: string;\n target: IShowDialogParamsEntry;\n}\n\nexport const useScheduleDialog = (\n props: IUseScheduleDialogProps\n): UseShowScheduleDialogResponse => {\n const { client, target, namespace } = props;\n const dialog = useDialogs();\n const { showSnackbar } = useSnackbar();\n\n const presenter = useMemo(() => {\n return new ScheduleDialogPresenter({\n getGateway: new SchedulerGetGraphQLGateway(client),\n cancelGateway: new SchedulerCancelGraphQLGateway(client),\n publishGateway: new SchedulerPublishGraphQLGateway(client),\n unpublishGateway: new SchedulerUnpublishGraphQLGateway(client)\n });\n }, [client]);\n\n const dialogClose = useRef<null | (() => void)>(() => {\n return;\n });\n\n const onAccept = useCallback(\n async (params: IOnAcceptParams) => {\n const { scheduleOn, actionType } = params;\n\n try {\n await presenter.schedule({\n targetId: target.id,\n namespace,\n scheduleOn,\n actionType\n });\n showSnackbar(`Scheduled ${actionType} action for \"${target.title}\"!`);\n } catch (error) {\n showSnackbar(error.message);\n console.error(error);\n }\n },\n [presenter.vm]\n );\n\n const onCancel = useCallback(async () => {\n const entry = presenter.vm.entry;\n if (!entry) {\n showSnackbar(`No scheduled action found for \"${target.title}\"!`);\n if (dialogClose.current) {\n dialogClose.current();\n dialogClose.current = null;\n }\n return;\n }\n try {\n await presenter.cancel({\n id: entry.id,\n namespace: entry.namespace\n });\n showSnackbar(`Canceled scheduled ${entry.actionType} on \"${entry.title}\"!`);\n } catch (error) {\n showSnackbar(error.message);\n }\n if (!dialogClose.current) {\n return;\n }\n dialogClose.current();\n dialogClose.current = null;\n }, [presenter.vm]);\n\n const showDialog = async () => {\n await presenter.load({ namespace, id: target.id });\n\n const isPublished = target.status === \"published\";\n const entry = presenter.vm.entry;\n const scheduleOn = entry?.publishOn || entry?.unpublishOn;\n\n dialogClose.current = dialog.showDialog({\n title: `Schedule \"${target.title}\"`,\n content: <FormComponent actionType={entry?.actionType} scheduleOn={scheduleOn} />,\n formData: {\n scheduleOn\n },\n acceptLabel: isPublished ? \"Schedule Unpublish\" : \"Schedule Publish\",\n cancelLabel: \"Discard\",\n loadingLabel: \"Scheduling...\",\n info: <CancelButtonComponent enabled={!!scheduleOn} onCancel={onCancel} />,\n onAccept: (data: Partial<ScheduleFormData>) => {\n if (!data.scheduleOn) {\n showSnackbar(`Missing \"Schedule On\" date!`);\n return;\n }\n /**\n * We need to convert scheduleOn from local string to the ISO String (UTC) format.\n * This is important because the date will be stored in the database in UTC format.\n *\n * We display the date (in the UI) in users timezone time.\n */\n let scheduleOn: Date;\n try {\n scheduleOn = new Date(data.scheduleOn);\n } catch (ex) {\n showSnackbar(`Invalid \"Schedule On\" date!`, {\n value: data.scheduleOn\n });\n console.error(ex);\n return;\n }\n\n const actionType = isPublished\n ? ScheduleActionType.unpublish\n : ScheduleActionType.publish;\n\n return onAccept({\n scheduleOn,\n actionType\n });\n }\n });\n };\n\n return {\n showDialog\n };\n};\n"],"names":["dateToLocaleStringFormatter","Intl","undefined","ReschedulingAlert","scheduleOn","actionType","actionName","ScheduleActionType","Alert","padLeft","num","String","formatDateForDateTimeLocal","date","Date","year","month","day","hours","minutes","minDateValidator","input","value","minDate","ValidationError","CancelButtonComponent","enabled","onCancel","Button","DeleteIcon","SchedulerDialogFormComponentDateTimeInput","makeDecoratable","props","bind","Input","FormComponent","Grid","Bind","validation","useScheduleDialog","client","target","namespace","dialog","useDialogs","showSnackbar","useSnackbar","presenter","useMemo","ScheduleDialogPresenter","SchedulerGetGraphQLGateway","SchedulerCancelGraphQLGateway","SchedulerPublishGraphQLGateway","SchedulerUnpublishGraphQLGateway","dialogClose","useRef","onAccept","useCallback","params","error","console","entry","showDialog","isPublished","data","ex"],"mappings":";;;;;;;;;;;;;;AAkCA,MAAMA,8BAA8B,IAAIC,KAAK,cAAc,CAACC,QAAW;IACnE,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQA;IACR,QAAQ;AACZ;AAOA,MAAMC,oBAAoB,CAAC,EAAEC,UAAU,EAAEC,UAAU,EAA2B;IAC1E,IAAI,CAACD,cAAc,CAACC,YAChB,OAAO;IAEX,MAAMC,aAAaD,eAAeE,mBAAmB,OAAO,GAAG,YAAY;IAC3E,OAAO,WAAP,GACI,oBAACC,OAAKA;QAAC,MAAM;qBACT,0CAAE,MACKF,YAAW,0CACd,oBAAC,2BACD,oBAAC,gBAAQN,4BAA4B,MAAM,CAACI,cAAqB;AAIjF;AAIA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,IAAI;oBACTpB,aAAa,+BAA+B;wBACxC,OAAOmB,KAAK,UAAU;oBAC1B;oBACAJ,QAAQ,KAAK,CAACK;oBACd;gBACJ;gBAEA,MAAM5D,aAAa0D,cACbxD,mBAAmB,SAAS,GAC5BA,mBAAmB,OAAO;gBAEhC,OAAOiD,SAAS;oBACZpD;oBACAC;gBACJ;YACJ;QACJ;IACJ;IAEA,OAAO;QACHyD;IACJ;AACJ"}
@@ -1,36 +1,30 @@
1
- import React from "react";
1
+ import react from "react";
2
2
  import debounce from "lodash/debounce.js";
3
3
  import { OverlayLayout } from "@webiny/app-admin";
4
- import { Scrollbar } from "@webiny/ui/Scrollbar/index.js";
4
+ import { Scrollbar } from "@webiny/admin-ui";
5
5
  import { Title } from "../Title/index.js";
6
6
  import { SearchInput } from "../SearchInput/index.js";
7
7
  import { Empty } from "../Empty/index.js";
8
8
  import { Table } from "../Table/index.js";
9
9
  import { BottomInfoBar } from "../BottomInfoBar/index.js";
10
10
  import { useScheduler } from "../../hooks/index.js";
11
- export const SchedulerOverlay = props => {
12
- const {
13
- listMoreItems,
14
- vm
15
- } = useScheduler();
16
- const onTableScroll = debounce(async ({
17
- scrollFrame
18
- }) => {
19
- if (scrollFrame.top > 0.8) {
20
- await listMoreItems();
21
- }
22
- }, 200);
23
- return /*#__PURE__*/React.createElement(OverlayLayout, {
24
- onExited: props.onExited,
25
- barLeft: /*#__PURE__*/React.createElement(Title, {
26
- title: props.title
27
- }),
28
- barMiddle: /*#__PURE__*/React.createElement(SearchInput, null)
29
- }, /*#__PURE__*/React.createElement(Scrollbar, {
30
- onScrollFrame: scrollFrame => onTableScroll({
31
- scrollFrame
32
- })
33
- }, vm.isEmptyView ? /*#__PURE__*/React.createElement(Empty, null) : /*#__PURE__*/React.createElement(Table, null)), /*#__PURE__*/React.createElement(BottomInfoBar, null));
11
+ const SchedulerOverlay = (props)=>{
12
+ const { listMoreItems, vm } = useScheduler();
13
+ const onTableScroll = debounce(async ({ scrollFrame })=>{
14
+ if (scrollFrame.top > 0.8) await listMoreItems();
15
+ }, 200);
16
+ return /*#__PURE__*/ react.createElement(OverlayLayout, {
17
+ onExited: props.onExited,
18
+ barLeft: /*#__PURE__*/ react.createElement(Title, {
19
+ title: props.title
20
+ }),
21
+ barMiddle: /*#__PURE__*/ react.createElement(SearchInput, null)
22
+ }, /*#__PURE__*/ react.createElement(Scrollbar, {
23
+ onScrollFrame: (scrollFrame)=>onTableScroll({
24
+ scrollFrame
25
+ })
26
+ }, vm.isEmptyView ? /*#__PURE__*/ react.createElement(Empty, null) : /*#__PURE__*/ react.createElement(Table, null)), /*#__PURE__*/ react.createElement(BottomInfoBar, null));
34
27
  };
28
+ export { SchedulerOverlay };
35
29
 
36
30
  //# sourceMappingURL=SchedulerOverlay.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","debounce","OverlayLayout","Scrollbar","Title","SearchInput","Empty","Table","BottomInfoBar","useScheduler","SchedulerOverlay","props","listMoreItems","vm","onTableScroll","scrollFrame","top","createElement","onExited","barLeft","title","barMiddle","onScrollFrame","isEmptyView"],"sources":["SchedulerOverlay.tsx"],"sourcesContent":["import React from \"react\";\nimport debounce from \"lodash/debounce.js\";\nimport { OverlayLayout } from \"@webiny/app-admin\";\nimport { Scrollbar } from \"@webiny/ui/Scrollbar/index.js\";\nimport { Title } from \"~/Presentation/components/Title/index.js\";\nimport { SearchInput } from \"~/Presentation/components/SearchInput/index.js\";\nimport { Empty } from \"~/Presentation/components/Empty/index.js\";\nimport { Table } from \"~/Presentation/components/Table/index.js\";\nimport { BottomInfoBar } from \"~/Presentation/components/BottomInfoBar/index.js\";\nimport { useScheduler } from \"~/Presentation/hooks/index.js\";\n\ninterface SchedulerOverlayProps {\n title: string;\n onExited: () => void;\n}\n\nexport const SchedulerOverlay = (props: SchedulerOverlayProps) => {\n const { listMoreItems, vm } = useScheduler();\n\n const onTableScroll = debounce(async ({ scrollFrame }) => {\n if (scrollFrame.top > 0.8) {\n await listMoreItems();\n }\n }, 200);\n\n return (\n <OverlayLayout\n onExited={props.onExited}\n barLeft={<Title title={props.title} />}\n barMiddle={<SearchInput />}\n >\n <Scrollbar onScrollFrame={scrollFrame => onTableScroll({ scrollFrame })}>\n {vm.isEmptyView ? <Empty /> : <Table />}\n </Scrollbar>\n <BottomInfoBar />\n </OverlayLayout>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,QAAQ,MAAM,oBAAoB;AACzC,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,SAAS,QAAQ,+BAA+B;AACzD,SAASC,KAAK;AACd,SAASC,WAAW;AACpB,SAASC,KAAK;AACd,SAASC,KAAK;AACd,SAASC,aAAa;AACtB,SAASC,YAAY;AAOrB,OAAO,MAAMC,gBAAgB,GAAIC,KAA4B,IAAK;EAC9D,MAAM;IAAEC,aAAa;IAAEC;EAAG,CAAC,GAAGJ,YAAY,CAAC,CAAC;EAE5C,MAAMK,aAAa,GAAGb,QAAQ,CAAC,OAAO;IAAEc;EAAY,CAAC,KAAK;IACtD,IAAIA,WAAW,CAACC,GAAG,GAAG,GAAG,EAAE;MACvB,MAAMJ,aAAa,CAAC,CAAC;IACzB;EACJ,CAAC,EAAE,GAAG,CAAC;EAEP,oBACIZ,KAAA,CAAAiB,aAAA,CAACf,aAAa;IACVgB,QAAQ,EAAEP,KAAK,CAACO,QAAS;IACzBC,OAAO,eAAEnB,KAAA,CAAAiB,aAAA,CAACb,KAAK;MAACgB,KAAK,EAAET,KAAK,CAACS;IAAM,CAAE,CAAE;IACvCC,SAAS,eAAErB,KAAA,CAAAiB,aAAA,CAACZ,WAAW,MAAE;EAAE,gBAE3BL,KAAA,CAAAiB,aAAA,CAACd,SAAS;IAACmB,aAAa,EAAEP,WAAW,IAAID,aAAa,CAAC;MAAEC;IAAY,CAAC;EAAE,GACnEF,EAAE,CAACU,WAAW,gBAAGvB,KAAA,CAAAiB,aAAA,CAACX,KAAK,MAAE,CAAC,gBAAGN,KAAA,CAAAiB,aAAA,CAACV,KAAK,MAAE,CAC/B,CAAC,eACZP,KAAA,CAAAiB,aAAA,CAACT,aAAa,MAAE,CACL,CAAC;AAExB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Presentation/components/SchedulerOverlay/SchedulerOverlay.js","sources":["../../../../src/Presentation/components/SchedulerOverlay/SchedulerOverlay.tsx"],"sourcesContent":["import React from \"react\";\nimport debounce from \"lodash/debounce.js\";\nimport { OverlayLayout } from \"@webiny/app-admin\";\nimport { Scrollbar } from \"@webiny/admin-ui\";\nimport { Title } from \"~/Presentation/components/Title/index.js\";\nimport { SearchInput } from \"~/Presentation/components/SearchInput/index.js\";\nimport { Empty } from \"~/Presentation/components/Empty/index.js\";\nimport { Table } from \"~/Presentation/components/Table/index.js\";\nimport { BottomInfoBar } from \"~/Presentation/components/BottomInfoBar/index.js\";\nimport { useScheduler } from \"~/Presentation/hooks/index.js\";\n\ninterface SchedulerOverlayProps {\n title: string;\n onExited: () => void;\n}\n\nexport const SchedulerOverlay = (props: SchedulerOverlayProps) => {\n const { listMoreItems, vm } = useScheduler();\n\n const onTableScroll = debounce(async ({ scrollFrame }) => {\n if (scrollFrame.top > 0.8) {\n await listMoreItems();\n }\n }, 200);\n\n return (\n <OverlayLayout\n onExited={props.onExited}\n barLeft={<Title title={props.title} />}\n barMiddle={<SearchInput />}\n >\n <Scrollbar onScrollFrame={scrollFrame => onTableScroll({ scrollFrame })}>\n {vm.isEmptyView ? <Empty /> : <Table />}\n </Scrollbar>\n <BottomInfoBar />\n </OverlayLayout>\n );\n};\n"],"names":["SchedulerOverlay","props","listMoreItems","vm","useScheduler","onTableScroll","debounce","scrollFrame","OverlayLayout","Title","SearchInput","Scrollbar","Empty","Table","BottomInfoBar"],"mappings":";;;;;;;;;;AAgBO,MAAMA,mBAAmB,CAACC;IAC7B,MAAM,EAAEC,aAAa,EAAEC,EAAE,EAAE,GAAGC;IAE9B,MAAMC,gBAAgBC,SAAS,OAAO,EAAEC,WAAW,EAAE;QACjD,IAAIA,YAAY,GAAG,GAAG,KAClB,MAAML;IAEd,GAAG;IAEH,OAAO,WAAP,GACI,oBAACM,eAAaA;QACV,UAAUP,MAAM,QAAQ;QACxB,uBAAS,oBAACQ,OAAKA;YAAC,OAAOR,MAAM,KAAK;;QAClC,yBAAW,oBAACS,aAAWA;qBAEvB,oBAACC,WAASA;QAAC,eAAeJ,CAAAA,cAAeF,cAAc;gBAAEE;YAAY;OAChEJ,GAAG,WAAW,GAAG,WAAH,GAAG,oBAACS,OAAKA,QAAAA,WAAAA,GAAM,oBAACC,OAAKA,QAAAA,WAAAA,GAExC,oBAACC,eAAaA;AAG1B"}
@@ -1,3 +1 @@
1
1
  export * from "./SchedulerOverlay.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,37 +1,30 @@
1
- import React from "react";
2
- import { ReactComponent as SearchIcon } from "@webiny/icons/search.svg";
1
+ import react from "react";
2
+ import { ReactComponent } from "@webiny/icons/search.svg";
3
3
  import { DelayedOnChange, Icon, Input } from "@webiny/admin-ui";
4
4
  import { useScheduler } from "../../hooks/index.js";
5
- export const SearchInput = () => {
6
- const {
7
- vm,
8
- searchItems
9
- } = useScheduler();
10
- return /*#__PURE__*/React.createElement(DelayedOnChange, {
11
- value: vm.searchQuery,
12
- onChange: value => {
13
- if (value === vm.searchQuery) {
14
- return;
15
- }
16
- searchItems(value);
17
- }
18
- }, ({
19
- value,
20
- onChange
21
- }) => /*#__PURE__*/React.createElement(Input, {
22
- id: "scheduler__search-input",
23
- value: value,
24
- onChange: e => onChange(e.target.value),
25
- forwardEventOnChange: true,
26
- placeholder: vm.searchLabel,
27
- "data-testid": "scheduler.search-input",
28
- startIcon: /*#__PURE__*/React.createElement(Icon, {
29
- icon: /*#__PURE__*/React.createElement(SearchIcon, null),
30
- label: "Search"
31
- }),
32
- size: "md",
33
- variant: "ghost"
34
- }));
5
+ const SearchInput = ()=>{
6
+ const { vm, searchItems } = useScheduler();
7
+ return /*#__PURE__*/ react.createElement(DelayedOnChange, {
8
+ value: vm.searchQuery,
9
+ onChange: (value)=>{
10
+ if (value === vm.searchQuery) return;
11
+ searchItems(value);
12
+ }
13
+ }, ({ value, onChange })=>/*#__PURE__*/ react.createElement(Input, {
14
+ id: "scheduler__search-input",
15
+ value: value,
16
+ onChange: (e)=>onChange(e.target.value),
17
+ forwardEventOnChange: true,
18
+ placeholder: vm.searchLabel,
19
+ "data-testid": "scheduler.search-input",
20
+ startIcon: /*#__PURE__*/ react.createElement(Icon, {
21
+ icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
22
+ label: "Search"
23
+ }),
24
+ size: "md",
25
+ variant: "ghost"
26
+ }));
35
27
  };
28
+ export { SearchInput };
36
29
 
37
30
  //# sourceMappingURL=SearchInput.js.map