@webiny/app-scheduler 6.3.0 → 6.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Domain/Models/SchedulerItem/SchedulerItem.js +15 -14
- package/Domain/Models/SchedulerItem/SchedulerItem.js.map +1 -1
- package/Domain/Models/SchedulerItem/index.js +0 -2
- package/Domain/Models/index.js +0 -2
- package/Domain/Repositories/SchedulerItems/ISchedulerItemsRepository.js +0 -3
- package/Domain/Repositories/SchedulerItems/SchedulerItemsRepository.js +107 -116
- package/Domain/Repositories/SchedulerItems/SchedulerItemsRepository.js.map +1 -1
- package/Domain/Repositories/SchedulerItems/SchedulerItemsRepositoryFactory.js +13 -12
- package/Domain/Repositories/SchedulerItems/SchedulerItemsRepositoryFactory.js.map +1 -1
- package/Domain/Repositories/SchedulerItems/SchedulerItemsRepositoryWithLoading.js +34 -33
- package/Domain/Repositories/SchedulerItems/SchedulerItemsRepositoryWithLoading.js.map +1 -1
- package/Domain/Repositories/SchedulerItems/index.js +0 -2
- package/Domain/Repositories/Search/ISearchRepository.js +0 -3
- package/Domain/Repositories/Search/SearchRepository.js +12 -11
- package/Domain/Repositories/Search/SearchRepository.js.map +1 -1
- package/Domain/Repositories/Search/SearchRepositoryFactory.js +13 -12
- package/Domain/Repositories/Search/SearchRepositoryFactory.js.map +1 -1
- package/Domain/Repositories/Search/index.js +0 -2
- package/Domain/Repositories/SelectedItems/ISelectedItemsRepository.js +0 -3
- package/Domain/Repositories/SelectedItems/SelectedItemsRepository.js +24 -23
- package/Domain/Repositories/SelectedItems/SelectedItemsRepository.js.map +1 -1
- package/Domain/Repositories/SelectedItems/SelectedItemsRepositoryFactory.js +13 -12
- package/Domain/Repositories/SelectedItems/SelectedItemsRepositoryFactory.js.map +1 -1
- package/Domain/Repositories/SelectedItems/index.js +0 -2
- package/Domain/Repositories/Sorting/SortingRepositoryWithDefaults.js +16 -17
- package/Domain/Repositories/Sorting/SortingRepositoryWithDefaults.js.map +1 -1
- package/Domain/Repositories/Sorting/index.js +0 -2
- package/Domain/Repositories/index.js +0 -2
- package/Domain/index.js +0 -2
- package/Gateways/SchedulerCancelGraphQLGateway.js +23 -29
- package/Gateways/SchedulerCancelGraphQLGateway.js.map +1 -1
- package/Gateways/SchedulerGetGraphQLGateway.js +41 -45
- package/Gateways/SchedulerGetGraphQLGateway.js.map +1 -1
- package/Gateways/SchedulerListGraphQLGateway.js +42 -48
- package/Gateways/SchedulerListGraphQLGateway.js.map +1 -1
- package/Gateways/SchedulerPublishGraphQLGateway.js +31 -39
- package/Gateways/SchedulerPublishGraphQLGateway.js.map +1 -1
- package/Gateways/SchedulerUnpublishGraphQLGateway.js +35 -41
- package/Gateways/SchedulerUnpublishGraphQLGateway.js.map +1 -1
- package/Gateways/abstractions/CancelScheduledActionGateway.js +0 -3
- package/Gateways/abstractions/GetScheduledActionGateway.js +0 -3
- package/Gateways/abstractions/ListScheduledActionsGateway.js +0 -3
- package/Gateways/abstractions/SchedulePublishActionGateway.js +0 -3
- package/Gateways/abstractions/ScheduleUnpublishActionGateway.js +0 -3
- package/Gateways/graphql/fields.js +2 -3
- package/Gateways/graphql/fields.js.map +1 -1
- package/Gateways/index.js +0 -3
- package/Gateways/schema/schedulerEntry.js +13 -16
- package/Gateways/schema/schedulerEntry.js.map +1 -1
- package/Presentation/Scheduler/Scheduler.js +69 -58
- package/Presentation/Scheduler/Scheduler.js.map +1 -1
- package/Presentation/Scheduler/SchedulerControllers.js +49 -67
- package/Presentation/Scheduler/SchedulerControllers.js.map +1 -1
- package/Presentation/Scheduler/SchedulerPresenter.js +39 -38
- package/Presentation/Scheduler/SchedulerPresenter.js.map +1 -1
- package/Presentation/Scheduler/controllers/CancelItem/CancelItemController.js +9 -8
- package/Presentation/Scheduler/controllers/CancelItem/CancelItemController.js.map +1 -1
- package/Presentation/Scheduler/controllers/CancelItem/ICancelItemController.js +0 -3
- package/Presentation/Scheduler/controllers/CancelItem/index.js +0 -2
- package/Presentation/Scheduler/controllers/GetItem/GetItemController.js +9 -8
- package/Presentation/Scheduler/controllers/GetItem/GetItemController.js.map +1 -1
- package/Presentation/Scheduler/controllers/GetItem/IGetItemController.js +0 -3
- package/Presentation/Scheduler/controllers/GetItem/index.js +0 -2
- package/Presentation/Scheduler/controllers/ListItems/IListItemsController.js +0 -3
- package/Presentation/Scheduler/controllers/ListItems/ListItemsController.js +9 -8
- package/Presentation/Scheduler/controllers/ListItems/ListItemsController.js.map +1 -1
- package/Presentation/Scheduler/controllers/ListItems/index.js +0 -2
- package/Presentation/Scheduler/controllers/ListMoreItems/IListMoreItemsController.js +0 -3
- package/Presentation/Scheduler/controllers/ListMoreItems/ListMoreItemsController.js +9 -8
- package/Presentation/Scheduler/controllers/ListMoreItems/ListMoreItemsController.js.map +1 -1
- package/Presentation/Scheduler/controllers/ListMoreItems/index.js +0 -2
- package/Presentation/Scheduler/controllers/PublishItem/IPublishItemController.js +0 -3
- package/Presentation/Scheduler/controllers/PublishItem/PublishItemController.js +9 -8
- package/Presentation/Scheduler/controllers/PublishItem/PublishItemController.js.map +1 -1
- package/Presentation/Scheduler/controllers/PublishItem/index.js +0 -2
- package/Presentation/Scheduler/controllers/SearchItems/ISearchItemsController.js +0 -3
- package/Presentation/Scheduler/controllers/SearchItems/SearchItemsController.js +12 -11
- package/Presentation/Scheduler/controllers/SearchItems/SearchItemsController.js.map +1 -1
- package/Presentation/Scheduler/controllers/SearchItems/index.js +0 -2
- package/Presentation/Scheduler/controllers/SelectAllItems/ISelectAllItemsController.js +0 -3
- package/Presentation/Scheduler/controllers/SelectAllItems/SelectAllItemsController.js +9 -8
- package/Presentation/Scheduler/controllers/SelectAllItems/SelectAllItemsController.js.map +1 -1
- package/Presentation/Scheduler/controllers/SelectAllItems/index.js +0 -2
- package/Presentation/Scheduler/controllers/SelectItems/ISelectItemsController.js +0 -3
- package/Presentation/Scheduler/controllers/SelectItems/SelectItemsController.js +10 -9
- package/Presentation/Scheduler/controllers/SelectItems/SelectItemsController.js.map +1 -1
- package/Presentation/Scheduler/controllers/SelectItems/index.js +0 -2
- package/Presentation/Scheduler/controllers/SortItems/ISortItemsController.d.ts +2 -2
- package/Presentation/Scheduler/controllers/SortItems/ISortItemsController.js +0 -3
- package/Presentation/Scheduler/controllers/SortItems/SortItemsController.d.ts +2 -2
- package/Presentation/Scheduler/controllers/SortItems/SortItemsController.js +13 -14
- package/Presentation/Scheduler/controllers/SortItems/SortItemsController.js.map +1 -1
- package/Presentation/Scheduler/controllers/SortItems/index.js +0 -2
- package/Presentation/Scheduler/controllers/UnpublishItem/IUnpublishItemController.js +0 -3
- package/Presentation/Scheduler/controllers/UnpublishItem/UnpublishItemController.js +9 -8
- package/Presentation/Scheduler/controllers/UnpublishItem/UnpublishItemController.js.map +1 -1
- package/Presentation/Scheduler/controllers/UnpublishItem/index.js +0 -2
- package/Presentation/Scheduler/controllers/UnselectAllItems/IUnselectAllItemsController.js +0 -3
- package/Presentation/Scheduler/controllers/UnselectAllItems/UnselectAllItemsController.js +9 -8
- package/Presentation/Scheduler/controllers/UnselectAllItems/UnselectAllItemsController.js.map +1 -1
- package/Presentation/Scheduler/controllers/UnselectAllItems/index.js +0 -2
- package/Presentation/Scheduler/controllers/index.js +0 -2
- package/Presentation/Scheduler/index.js +0 -2
- package/Presentation/SchedulerConfigs/SchedulerConfigs.js +48 -51
- package/Presentation/SchedulerConfigs/SchedulerConfigs.js.map +1 -1
- package/Presentation/SchedulerConfigs/index.js +0 -2
- package/Presentation/SchedulerRenderer/SchedulerRenderer.js +10 -15
- package/Presentation/SchedulerRenderer/SchedulerRenderer.js.map +1 -1
- package/Presentation/SchedulerRenderer/index.js +0 -2
- package/Presentation/abstractions/ISchedulerControllers.js +0 -3
- package/Presentation/abstractions/ISchedulerPresenter.js +0 -3
- package/Presentation/abstractions/index.js +0 -3
- package/Presentation/components/Actions/CancelItem/CancelItem.js +14 -19
- package/Presentation/components/Actions/CancelItem/CancelItem.js.map +1 -1
- package/Presentation/components/Actions/CancelItem/index.js +0 -2
- package/Presentation/components/Actions/index.js +0 -2
- package/Presentation/components/BottomInfoBar/BottomInfoBar.js +11 -12
- package/Presentation/components/BottomInfoBar/BottomInfoBar.js.map +1 -1
- package/Presentation/components/BottomInfoBar/BottomInfoBar.styled.js +41 -67
- package/Presentation/components/BottomInfoBar/BottomInfoBar.styled.js.map +1 -1
- package/Presentation/components/BottomInfoBar/ListMeta.js +6 -9
- package/Presentation/components/BottomInfoBar/ListMeta.js.map +1 -1
- package/Presentation/components/BottomInfoBar/ListStatus.js +8 -12
- package/Presentation/components/BottomInfoBar/ListStatus.js.map +1 -1
- package/Presentation/components/BottomInfoBar/index.js +0 -2
- package/Presentation/components/Cells/CellActions/CellActions.js +12 -17
- package/Presentation/components/Cells/CellActions/CellActions.js.map +1 -1
- package/Presentation/components/Cells/CellActions/index.js +0 -2
- package/Presentation/components/Cells/CellRevision/CellRevision.js +9 -14
- package/Presentation/components/Cells/CellRevision/CellRevision.js.map +1 -1
- package/Presentation/components/Cells/CellRevision/CellRevision.styled.d.ts +1 -1
- package/Presentation/components/Cells/CellRevision/CellRevision.styled.js +16 -42
- package/Presentation/components/Cells/CellRevision/CellRevision.styled.js.map +1 -1
- package/Presentation/components/Cells/CellRevision/index.js +0 -2
- package/Presentation/components/Cells/CellScheduledBy/CellScheduledBy.js +6 -9
- package/Presentation/components/Cells/CellScheduledBy/CellScheduledBy.js.map +1 -1
- package/Presentation/components/Cells/CellScheduledBy/index.js +0 -2
- package/Presentation/components/Cells/CellScheduledOn/CellScheduledOn.js +11 -18
- package/Presentation/components/Cells/CellScheduledOn/CellScheduledOn.js.map +1 -1
- package/Presentation/components/Cells/CellScheduledOn/index.js +0 -2
- package/Presentation/components/Cells/CellTitle/CellTitle.js +9 -12
- package/Presentation/components/Cells/CellTitle/CellTitle.js.map +1 -1
- package/Presentation/components/Cells/CellTitle/CellTitle.styled.d.ts +1 -1
- package/Presentation/components/Cells/CellTitle/CellTitle.styled.js +16 -42
- package/Presentation/components/Cells/CellTitle/CellTitle.styled.js.map +1 -1
- package/Presentation/components/Cells/CellTitle/index.js +0 -2
- package/Presentation/components/Cells/CellType/CellActionType.js +10 -13
- package/Presentation/components/Cells/CellType/CellActionType.js.map +1 -1
- package/Presentation/components/Cells/CellType/CellActionType.styled.d.ts +1 -1
- package/Presentation/components/Cells/CellType/CellActionType.styled.js +16 -42
- package/Presentation/components/Cells/CellType/CellActionType.styled.js.map +1 -1
- package/Presentation/components/Cells/CellType/index.js +0 -2
- package/Presentation/components/Cells/index.js +0 -2
- package/Presentation/components/Empty/Empty.js +15 -16
- package/Presentation/components/Empty/Empty.js.map +1 -1
- package/Presentation/components/Empty/Empty.styled.js +14 -28
- package/Presentation/components/Empty/Empty.styled.js.map +1 -1
- package/Presentation/components/Empty/index.js +0 -2
- package/Presentation/components/ScheduleDialog/IScheduleDialogPresenter.js +0 -3
- package/Presentation/components/ScheduleDialog/ScheduleDialogPresenter.js +75 -79
- package/Presentation/components/ScheduleDialog/ScheduleDialogPresenter.js.map +1 -1
- package/Presentation/components/ScheduleDialog/index.js +0 -2
- package/Presentation/components/ScheduleDialog/types.js +0 -3
- package/Presentation/components/ScheduleDialog/useScheduleDialog.js +165 -207
- package/Presentation/components/ScheduleDialog/useScheduleDialog.js.map +1 -1
- package/Presentation/components/SchedulerOverlay/SchedulerOverlay.js +19 -25
- package/Presentation/components/SchedulerOverlay/SchedulerOverlay.js.map +1 -1
- package/Presentation/components/SchedulerOverlay/index.js +0 -2
- package/Presentation/components/SearchInput/SearchInput.js +25 -32
- package/Presentation/components/SearchInput/SearchInput.js.map +1 -1
- package/Presentation/components/SearchInput/index.js +0 -2
- package/Presentation/components/Table/Table.js +23 -28
- package/Presentation/components/Table/Table.js.map +1 -1
- package/Presentation/components/Table/index.js +0 -2
- package/Presentation/components/Title/Title.js +7 -12
- package/Presentation/components/Title/Title.js.map +1 -1
- package/Presentation/components/Title/Title.styled.d.ts +1 -2
- package/Presentation/components/Title/Title.styled.js +11 -16
- package/Presentation/components/Title/Title.styled.js.map +1 -1
- package/Presentation/components/Title/index.js +0 -2
- package/Presentation/configs/index.js +0 -2
- package/Presentation/configs/list/Browser/EntryAction.js +8 -11
- package/Presentation/configs/list/Browser/EntryAction.js.map +1 -1
- package/Presentation/configs/list/Browser/Table/Column.js +7 -10
- package/Presentation/configs/list/Browser/Table/Column.js.map +1 -1
- package/Presentation/configs/list/Browser/Table/Sorting.js +4 -7
- package/Presentation/configs/list/Browser/Table/Sorting.js.map +1 -1
- package/Presentation/configs/list/Browser/Table/index.js +4 -3
- package/Presentation/configs/list/Browser/Table/index.js.map +1 -1
- package/Presentation/configs/list/Browser/index.js +4 -3
- package/Presentation/configs/list/Browser/index.js.map +1 -1
- package/Presentation/configs/list/SchedulerListConfig.js +20 -21
- package/Presentation/configs/list/SchedulerListConfig.js.map +1 -1
- package/Presentation/configs/list/index.js +0 -2
- package/Presentation/hooks/index.js +0 -2
- package/Presentation/hooks/useCancelSchedulerItem.js +22 -27
- package/Presentation/hooks/useCancelSchedulerItem.js.map +1 -1
- package/Presentation/hooks/useScheduler.js +62 -46
- package/Presentation/hooks/useScheduler.js.map +1 -1
- package/Presentation/hooks/useSchedulerItem.js +4 -6
- package/Presentation/hooks/useSchedulerItem.js.map +1 -1
- package/Presentation/index.js +35 -42
- package/Presentation/index.js.map +1 -1
- package/UseCases/CancelItem/CancelItemUseCase.js +9 -8
- package/UseCases/CancelItem/CancelItemUseCase.js.map +1 -1
- package/UseCases/CancelItem/ICancelItemUseCase.js +0 -3
- package/UseCases/CancelItem/index.js +0 -2
- package/UseCases/GetItem/GetItemUseCase.js +9 -8
- package/UseCases/GetItem/GetItemUseCase.js.map +1 -1
- package/UseCases/GetItem/IGetItemUseCase.js +0 -3
- package/UseCases/GetItem/index.js +0 -2
- package/UseCases/GetScheduledItem/GetScheduledItemUseCase.js +10 -9
- package/UseCases/GetScheduledItem/GetScheduledItemUseCase.js.map +1 -1
- package/UseCases/GetScheduledItem/IGetScheduledItemUseCase.js +0 -3
- package/UseCases/GetScheduledItem/index.js +0 -2
- package/UseCases/ListItems/IListItemsUseCase.js +0 -3
- package/UseCases/ListItems/ListItemsUseCase.js +9 -8
- package/UseCases/ListItems/ListItemsUseCase.js.map +1 -1
- package/UseCases/ListItems/ListItemsUseCaseWithSearch.js +19 -18
- package/UseCases/ListItems/ListItemsUseCaseWithSearch.js.map +1 -1
- package/UseCases/ListItems/ListItemsUseCaseWithSorting.js +16 -17
- package/UseCases/ListItems/ListItemsUseCaseWithSorting.js.map +1 -1
- package/UseCases/ListItems/index.js +0 -2
- package/UseCases/ListMoreItems/IListMoreItemsUseCase.js +0 -3
- package/UseCases/ListMoreItems/ListMoreItemsUseCase.js +9 -8
- package/UseCases/ListMoreItems/ListMoreItemsUseCase.js.map +1 -1
- package/UseCases/ListMoreItems/index.js +0 -2
- package/UseCases/PublishItem/IPublishItemUseCase.js +0 -3
- package/UseCases/PublishItem/PublishItemUseCase.js +9 -8
- package/UseCases/PublishItem/PublishItemUseCase.js.map +1 -1
- package/UseCases/PublishItem/index.js +0 -2
- package/UseCases/SearchItems/ISearchItemsUseCase.js +0 -3
- package/UseCases/SearchItems/SearchItemsUseCase.js +9 -8
- package/UseCases/SearchItems/SearchItemsUseCase.js.map +1 -1
- package/UseCases/SearchItems/index.js +0 -2
- package/UseCases/SelectAllItems/ISelectAllItemsUseCase.js +0 -3
- package/UseCases/SelectAllItems/SelectAllItemsUseCase.js +9 -8
- package/UseCases/SelectAllItems/SelectAllItemsUseCase.js.map +1 -1
- package/UseCases/SelectAllItems/index.js +0 -2
- package/UseCases/SelectItems/ISelectItemsUseCase.js +0 -3
- package/UseCases/SelectItems/SelectItemsUseCase.js +9 -8
- package/UseCases/SelectItems/SelectItemsUseCase.js.map +1 -1
- package/UseCases/SelectItems/index.js +0 -2
- package/UseCases/SortItems/ISortItemsUseCase.js +0 -3
- package/UseCases/SortItems/SortItemsUseCase.js +9 -8
- package/UseCases/SortItems/SortItemsUseCase.js.map +1 -1
- package/UseCases/SortItems/index.js +0 -2
- package/UseCases/UnSelectAllItems/IUnselectAllItemsUseCase.js +0 -3
- package/UseCases/UnSelectAllItems/UnselectAllItemsUseCase.js +9 -8
- package/UseCases/UnSelectAllItems/UnselectAllItemsUseCase.js.map +1 -1
- package/UseCases/UnSelectAllItems/index.js +0 -2
- package/UseCases/UnpublishItem/IUnpublishItemUseCase.js +0 -3
- package/UseCases/UnpublishItem/UnpublishItemUseCase.js +9 -8
- package/UseCases/UnpublishItem/UnpublishItemUseCase.js.map +1 -1
- package/UseCases/UnpublishItem/index.js +0 -2
- package/UseCases/index.js +0 -2
- package/index.js +1 -3
- package/package.json +16 -18
- package/types.js +12 -11
- package/types.js.map +1 -1
- package/Domain/Models/SchedulerItem/index.js.map +0 -1
- package/Domain/Models/index.js.map +0 -1
- package/Domain/Repositories/SchedulerItems/ISchedulerItemsRepository.js.map +0 -1
- package/Domain/Repositories/SchedulerItems/index.js.map +0 -1
- package/Domain/Repositories/Search/ISearchRepository.js.map +0 -1
- package/Domain/Repositories/Search/index.js.map +0 -1
- package/Domain/Repositories/SelectedItems/ISelectedItemsRepository.js.map +0 -1
- package/Domain/Repositories/SelectedItems/index.js.map +0 -1
- package/Domain/Repositories/Sorting/index.js.map +0 -1
- package/Domain/Repositories/index.js.map +0 -1
- package/Domain/index.js.map +0 -1
- package/Gateways/abstractions/CancelScheduledActionGateway.js.map +0 -1
- package/Gateways/abstractions/GetScheduledActionGateway.js.map +0 -1
- package/Gateways/abstractions/ListScheduledActionsGateway.js.map +0 -1
- package/Gateways/abstractions/SchedulePublishActionGateway.js.map +0 -1
- package/Gateways/abstractions/ScheduleUnpublishActionGateway.js.map +0 -1
- package/Gateways/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/CancelItem/ICancelItemController.js.map +0 -1
- package/Presentation/Scheduler/controllers/CancelItem/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/GetItem/IGetItemController.js.map +0 -1
- package/Presentation/Scheduler/controllers/GetItem/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/ListItems/IListItemsController.js.map +0 -1
- package/Presentation/Scheduler/controllers/ListItems/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/ListMoreItems/IListMoreItemsController.js.map +0 -1
- package/Presentation/Scheduler/controllers/ListMoreItems/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/PublishItem/IPublishItemController.js.map +0 -1
- package/Presentation/Scheduler/controllers/PublishItem/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/SearchItems/ISearchItemsController.js.map +0 -1
- package/Presentation/Scheduler/controllers/SearchItems/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/SelectAllItems/ISelectAllItemsController.js.map +0 -1
- package/Presentation/Scheduler/controllers/SelectAllItems/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/SelectItems/ISelectItemsController.js.map +0 -1
- package/Presentation/Scheduler/controllers/SelectItems/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/SortItems/ISortItemsController.js.map +0 -1
- package/Presentation/Scheduler/controllers/SortItems/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/UnpublishItem/IUnpublishItemController.js.map +0 -1
- package/Presentation/Scheduler/controllers/UnpublishItem/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/UnselectAllItems/IUnselectAllItemsController.js.map +0 -1
- package/Presentation/Scheduler/controllers/UnselectAllItems/index.js.map +0 -1
- package/Presentation/Scheduler/controllers/index.js.map +0 -1
- package/Presentation/Scheduler/index.js.map +0 -1
- package/Presentation/SchedulerConfigs/index.js.map +0 -1
- package/Presentation/SchedulerRenderer/index.js.map +0 -1
- package/Presentation/abstractions/ISchedulerControllers.js.map +0 -1
- package/Presentation/abstractions/ISchedulerPresenter.js.map +0 -1
- package/Presentation/abstractions/index.js.map +0 -1
- package/Presentation/components/Actions/CancelItem/index.js.map +0 -1
- package/Presentation/components/Actions/index.js.map +0 -1
- package/Presentation/components/BottomInfoBar/index.js.map +0 -1
- package/Presentation/components/Cells/CellActions/index.js.map +0 -1
- package/Presentation/components/Cells/CellRevision/index.js.map +0 -1
- package/Presentation/components/Cells/CellScheduledBy/index.js.map +0 -1
- package/Presentation/components/Cells/CellScheduledOn/index.js.map +0 -1
- package/Presentation/components/Cells/CellTitle/index.js.map +0 -1
- package/Presentation/components/Cells/CellType/index.js.map +0 -1
- package/Presentation/components/Cells/index.js.map +0 -1
- package/Presentation/components/Empty/index.js.map +0 -1
- package/Presentation/components/ScheduleDialog/IScheduleDialogPresenter.js.map +0 -1
- package/Presentation/components/ScheduleDialog/index.js.map +0 -1
- package/Presentation/components/ScheduleDialog/types.js.map +0 -1
- package/Presentation/components/SchedulerOverlay/index.js.map +0 -1
- package/Presentation/components/SearchInput/index.js.map +0 -1
- package/Presentation/components/Table/index.js.map +0 -1
- package/Presentation/components/Title/index.js.map +0 -1
- package/Presentation/configs/index.js.map +0 -1
- package/Presentation/configs/list/index.js.map +0 -1
- package/Presentation/hooks/index.js.map +0 -1
- package/UseCases/CancelItem/ICancelItemUseCase.js.map +0 -1
- package/UseCases/CancelItem/index.js.map +0 -1
- package/UseCases/GetItem/IGetItemUseCase.js.map +0 -1
- package/UseCases/GetItem/index.js.map +0 -1
- package/UseCases/GetScheduledItem/IGetScheduledItemUseCase.js.map +0 -1
- package/UseCases/GetScheduledItem/index.js.map +0 -1
- package/UseCases/ListItems/IListItemsUseCase.js.map +0 -1
- package/UseCases/ListItems/index.js.map +0 -1
- package/UseCases/ListMoreItems/IListMoreItemsUseCase.js.map +0 -1
- package/UseCases/ListMoreItems/index.js.map +0 -1
- package/UseCases/PublishItem/IPublishItemUseCase.js.map +0 -1
- package/UseCases/PublishItem/index.js.map +0 -1
- package/UseCases/SearchItems/ISearchItemsUseCase.js.map +0 -1
- package/UseCases/SearchItems/index.js.map +0 -1
- package/UseCases/SelectAllItems/ISelectAllItemsUseCase.js.map +0 -1
- package/UseCases/SelectAllItems/index.js.map +0 -1
- package/UseCases/SelectItems/ISelectItemsUseCase.js.map +0 -1
- package/UseCases/SelectItems/index.js.map +0 -1
- package/UseCases/SortItems/ISortItemsUseCase.js.map +0 -1
- package/UseCases/SortItems/index.js.map +0 -1
- package/UseCases/UnSelectAllItems/IUnselectAllItemsUseCase.js.map +0 -1
- package/UseCases/UnSelectAllItems/index.js.map +0 -1
- package/UseCases/UnpublishItem/IUnpublishItemUseCase.js.map +0 -1
- package/UseCases/UnpublishItem/index.js.map +0 -1
- package/UseCases/index.js.map +0 -1
- package/index.js.map +0 -1
|
@@ -1,234 +1,192 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react, { useCallback, useMemo, useRef } from "react";
|
|
2
2
|
import { Alert, Button, Grid, Input } from "@webiny/admin-ui";
|
|
3
|
-
import { ReactComponent
|
|
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
|
|
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(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
230
|
-
|
|
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,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gB,IAAIzD,UAAgB;QACpB,IAAI;UACAA,UAAU,GAAG,IAAIc,IAAI,CAAC0E,IAAI,CAACxF,UAAU,CAAC;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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ClBnB,aAAa;gBASjB,IAAIzC;gBACJ,IAAI;oBACAA,aAAa,IAAIU,KAAKkD,KAAK,UAAU;gBACzC,EAAE,OAAOC,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
|
|
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
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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,"
|
|
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,37 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ReactComponent
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|