@webiny/app-scheduler 0.0.0-unstable.0d717d18dd
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/LICENSE +21 -0
- package/README.md +11 -0
- package/domain/schedulerEntry.d.ts +16 -0
- package/domain/schedulerEntry.js +19 -0
- package/domain/schedulerEntry.js.map +1 -0
- package/features/cancelScheduledAction/CancelScheduledActionGateway.d.ts +11 -0
- package/features/cancelScheduledAction/CancelScheduledActionGateway.js +41 -0
- package/features/cancelScheduledAction/CancelScheduledActionGateway.js.map +1 -0
- package/features/cancelScheduledAction/abstractions.d.ts +11 -0
- package/features/cancelScheduledAction/abstractions.js +5 -0
- package/features/cancelScheduledAction/abstractions.js.map +1 -0
- package/features/cancelScheduledAction/feature.d.ts +1 -0
- package/features/cancelScheduledAction/feature.js +11 -0
- package/features/cancelScheduledAction/feature.js.map +1 -0
- package/features/feature.d.ts +1 -0
- package/features/feature.js +19 -0
- package/features/feature.js.map +1 -0
- package/features/getScheduledAction/GetScheduledActionGateway.d.ts +11 -0
- package/features/getScheduledAction/GetScheduledActionGateway.js +57 -0
- package/features/getScheduledAction/GetScheduledActionGateway.js.map +1 -0
- package/features/getScheduledAction/abstractions.d.ts +13 -0
- package/features/getScheduledAction/abstractions.js +5 -0
- package/features/getScheduledAction/abstractions.js.map +1 -0
- package/features/getScheduledAction/feature.d.ts +1 -0
- package/features/getScheduledAction/feature.js +11 -0
- package/features/getScheduledAction/feature.js.map +1 -0
- package/features/graphqlFields.d.ts +2 -0
- package/features/graphqlFields.js +23 -0
- package/features/graphqlFields.js.map +1 -0
- package/features/listScheduledActions/ListScheduledActionsGateway.d.ts +11 -0
- package/features/listScheduledActions/ListScheduledActionsGateway.js +84 -0
- package/features/listScheduledActions/ListScheduledActionsGateway.js.map +1 -0
- package/features/listScheduledActions/abstractions.d.ts +30 -0
- package/features/listScheduledActions/abstractions.js +5 -0
- package/features/listScheduledActions/abstractions.js.map +1 -0
- package/features/listScheduledActions/feature.d.ts +1 -0
- package/features/listScheduledActions/feature.js +11 -0
- package/features/listScheduledActions/feature.js.map +1 -0
- package/features/schedulePublishAction/SchedulePublishActionGateway.d.ts +11 -0
- package/features/schedulePublishAction/SchedulePublishActionGateway.js +67 -0
- package/features/schedulePublishAction/SchedulePublishActionGateway.js.map +1 -0
- package/features/schedulePublishAction/abstractions.d.ts +16 -0
- package/features/schedulePublishAction/abstractions.js +5 -0
- package/features/schedulePublishAction/abstractions.js.map +1 -0
- package/features/schedulePublishAction/feature.d.ts +1 -0
- package/features/schedulePublishAction/feature.js +11 -0
- package/features/schedulePublishAction/feature.js.map +1 -0
- package/features/scheduleUnpublishAction/ScheduleUnpublishActionGateway.d.ts +11 -0
- package/features/scheduleUnpublishAction/ScheduleUnpublishActionGateway.js +71 -0
- package/features/scheduleUnpublishAction/ScheduleUnpublishActionGateway.js.map +1 -0
- package/features/scheduleUnpublishAction/abstractions.d.ts +16 -0
- package/features/scheduleUnpublishAction/abstractions.js +5 -0
- package/features/scheduleUnpublishAction/abstractions.js.map +1 -0
- package/features/scheduleUnpublishAction/feature.d.ts +1 -0
- package/features/scheduleUnpublishAction/feature.js +11 -0
- package/features/scheduleUnpublishAction/feature.js.map +1 -0
- package/index.d.ts +9 -0
- package/index.js +17 -0
- package/index.js.map +1 -0
- package/package.json +56 -0
- package/presentation/SchedulerConfigs/SchedulerConfigs.d.ts +2 -0
- package/presentation/SchedulerConfigs/SchedulerConfigs.js +52 -0
- package/presentation/SchedulerConfigs/SchedulerConfigs.js.map +1 -0
- package/presentation/SchedulerConfigs/index.d.ts +1 -0
- package/presentation/SchedulerConfigs/index.js +1 -0
- package/presentation/components/Actions/CancelItem/CancelItem.d.ts +2 -0
- package/presentation/components/Actions/CancelItem/CancelItem.js +18 -0
- package/presentation/components/Actions/CancelItem/CancelItem.js.map +1 -0
- package/presentation/components/Actions/CancelItem/index.d.ts +1 -0
- package/presentation/components/Actions/CancelItem/index.js +1 -0
- package/presentation/components/Actions/index.d.ts +1 -0
- package/presentation/components/Actions/index.js +1 -0
- package/presentation/components/BottomInfoBar/BottomInfoBar.styled.d.ts +20 -0
- package/presentation/components/BottomInfoBar/BottomInfoBar.styled.js +43 -0
- package/presentation/components/BottomInfoBar/BottomInfoBar.styled.js.map +1 -0
- package/presentation/components/BottomInfoBar/ListMeta.d.ts +7 -0
- package/presentation/components/BottomInfoBar/ListMeta.js +9 -0
- package/presentation/components/BottomInfoBar/ListMeta.js.map +1 -0
- package/presentation/components/BottomInfoBar/ListStatus.d.ts +5 -0
- package/presentation/components/BottomInfoBar/ListStatus.js +12 -0
- package/presentation/components/BottomInfoBar/ListStatus.js.map +1 -0
- package/presentation/components/Cells/CellActions/CellActions.d.ts +2 -0
- package/presentation/components/Cells/CellActions/CellActions.js +18 -0
- package/presentation/components/Cells/CellActions/CellActions.js.map +1 -0
- package/presentation/components/Cells/CellActions/index.d.ts +1 -0
- package/presentation/components/Cells/CellActions/index.js +1 -0
- package/presentation/components/Cells/CellRevision/CellRevision.d.ts +2 -0
- package/presentation/components/Cells/CellRevision/CellRevision.js +15 -0
- package/presentation/components/Cells/CellRevision/CellRevision.js.map +1 -0
- package/presentation/components/Cells/CellRevision/CellRevision.styled.d.ts +11 -0
- package/presentation/components/Cells/CellRevision/CellRevision.styled.js +18 -0
- package/presentation/components/Cells/CellRevision/CellRevision.styled.js.map +1 -0
- package/presentation/components/Cells/CellRevision/index.d.ts +1 -0
- package/presentation/components/Cells/CellRevision/index.js +1 -0
- package/presentation/components/Cells/CellScheduledBy/CellScheduledBy.d.ts +2 -0
- package/presentation/components/Cells/CellScheduledBy/CellScheduledBy.js +10 -0
- package/presentation/components/Cells/CellScheduledBy/CellScheduledBy.js.map +1 -0
- package/presentation/components/Cells/CellScheduledBy/index.d.ts +1 -0
- package/presentation/components/Cells/CellScheduledBy/index.js +1 -0
- package/presentation/components/Cells/CellScheduledOn/CellScheduledOn.d.ts +24 -0
- package/presentation/components/Cells/CellScheduledOn/CellScheduledOn.js +19 -0
- package/presentation/components/Cells/CellScheduledOn/CellScheduledOn.js.map +1 -0
- package/presentation/components/Cells/CellScheduledOn/index.d.ts +1 -0
- package/presentation/components/Cells/CellScheduledOn/index.js +1 -0
- package/presentation/components/Cells/CellTitle/CellTitle.d.ts +2 -0
- package/presentation/components/Cells/CellTitle/CellTitle.js +14 -0
- package/presentation/components/Cells/CellTitle/CellTitle.js.map +1 -0
- package/presentation/components/Cells/CellTitle/CellTitle.styled.d.ts +11 -0
- package/presentation/components/Cells/CellTitle/CellTitle.styled.js +18 -0
- package/presentation/components/Cells/CellTitle/CellTitle.styled.js.map +1 -0
- package/presentation/components/Cells/CellTitle/index.d.ts +1 -0
- package/presentation/components/Cells/CellTitle/index.js +1 -0
- package/presentation/components/Cells/CellType/CellActionType.d.ts +2 -0
- package/presentation/components/Cells/CellType/CellActionType.js +15 -0
- package/presentation/components/Cells/CellType/CellActionType.js.map +1 -0
- package/presentation/components/Cells/CellType/CellActionType.styled.d.ts +11 -0
- package/presentation/components/Cells/CellType/CellActionType.styled.js +18 -0
- package/presentation/components/Cells/CellType/CellActionType.styled.js.map +1 -0
- package/presentation/components/Cells/CellType/index.d.ts +1 -0
- package/presentation/components/Cells/CellType/index.js +1 -0
- package/presentation/components/Cells/index.d.ts +6 -0
- package/presentation/components/Cells/index.js +6 -0
- package/presentation/components/Empty/Empty.styled.d.ts +8 -0
- package/presentation/components/Empty/Empty.styled.js +16 -0
- package/presentation/components/Empty/Empty.styled.js.map +1 -0
- package/presentation/components/Title/Title.d.ts +5 -0
- package/presentation/components/Title/Title.js +10 -0
- package/presentation/components/Title/Title.js.map +1 -0
- package/presentation/components/Title/Title.styled.d.ts +3 -0
- package/presentation/components/Title/Title.styled.js +13 -0
- package/presentation/components/Title/Title.styled.js.map +1 -0
- package/presentation/components/Title/index.d.ts +1 -0
- package/presentation/components/Title/index.js +1 -0
- package/presentation/configs/index.d.ts +1 -0
- package/presentation/configs/index.js +1 -0
- package/presentation/configs/list/Browser/EntryAction.d.ts +8 -0
- package/presentation/configs/list/Browser/EntryAction.js +13 -0
- package/presentation/configs/list/Browser/EntryAction.js.map +1 -0
- package/presentation/configs/list/Browser/Table/Column.d.ts +15 -0
- package/presentation/configs/list/Browser/Table/Column.js +11 -0
- package/presentation/configs/list/Browser/Table/Column.js.map +1 -0
- package/presentation/configs/list/Browser/Table/Sorting.d.ts +5 -0
- package/presentation/configs/list/Browser/Table/Sorting.js +7 -0
- package/presentation/configs/list/Browser/Table/Sorting.js.map +1 -0
- package/presentation/configs/list/Browser/Table/index.d.ts +19 -0
- package/presentation/configs/list/Browser/Table/index.js +9 -0
- package/presentation/configs/list/Browser/Table/index.js.map +1 -0
- package/presentation/configs/list/Browser/index.d.ts +23 -0
- package/presentation/configs/list/Browser/index.js +9 -0
- package/presentation/configs/list/Browser/index.js.map +1 -0
- package/presentation/configs/list/SchedulerListConfig.d.ts +35 -0
- package/presentation/configs/list/SchedulerListConfig.js +30 -0
- package/presentation/configs/list/SchedulerListConfig.js.map +1 -0
- package/presentation/configs/list/index.d.ts +1 -0
- package/presentation/configs/list/index.js +1 -0
- package/presentation/hooks/index.d.ts +2 -0
- package/presentation/hooks/index.js +2 -0
- package/presentation/hooks/useCancelSchedulerItem.d.ts +8 -0
- package/presentation/hooks/useCancelSchedulerItem.js +32 -0
- package/presentation/hooks/useCancelSchedulerItem.js.map +1 -0
- package/presentation/hooks/useSchedulerItem.d.ts +11 -0
- package/presentation/hooks/useSchedulerItem.js +7 -0
- package/presentation/hooks/useSchedulerItem.js.map +1 -0
- package/presentation/scheduleDialog/ScheduleDialogPresenter.d.ts +26 -0
- package/presentation/scheduleDialog/ScheduleDialogPresenter.js +115 -0
- package/presentation/scheduleDialog/ScheduleDialogPresenter.js.map +1 -0
- package/presentation/scheduleDialog/abstractions.d.ts +35 -0
- package/presentation/scheduleDialog/abstractions.js +5 -0
- package/presentation/scheduleDialog/abstractions.js.map +1 -0
- package/presentation/scheduleDialog/components/CancelButtonComponent.d.ts +10 -0
- package/presentation/scheduleDialog/components/CancelButtonComponent.js +20 -0
- package/presentation/scheduleDialog/components/CancelButtonComponent.js.map +1 -0
- package/presentation/scheduleDialog/components/FormComponent.d.ts +9 -0
- package/presentation/scheduleDialog/components/FormComponent.js +32 -0
- package/presentation/scheduleDialog/components/FormComponent.js.map +1 -0
- package/presentation/scheduleDialog/components/ReschedulingAlert.d.ts +7 -0
- package/presentation/scheduleDialog/components/ReschedulingAlert.js +14 -0
- package/presentation/scheduleDialog/components/ReschedulingAlert.js.map +1 -0
- package/presentation/scheduleDialog/components/SchedulerDialogFormComponentDateTimeInput.d.ts +24 -0
- package/presentation/scheduleDialog/components/SchedulerDialogFormComponentDateTimeInput.js +15 -0
- package/presentation/scheduleDialog/components/SchedulerDialogFormComponentDateTimeInput.js.map +1 -0
- package/presentation/scheduleDialog/createMinDateValidator.d.ts +7 -0
- package/presentation/scheduleDialog/createMinDateValidator.js +14 -0
- package/presentation/scheduleDialog/createMinDateValidator.js.map +1 -0
- package/presentation/scheduleDialog/feature.d.ts +3 -0
- package/presentation/scheduleDialog/feature.js +17 -0
- package/presentation/scheduleDialog/feature.js.map +1 -0
- package/presentation/scheduleDialog/useScheduleDialog.d.ts +20 -0
- package/presentation/scheduleDialog/useScheduleDialog.js +128 -0
- package/presentation/scheduleDialog/useScheduleDialog.js.map +1 -0
- package/presentation/schedulerList/Scheduler.d.ts +18 -0
- package/presentation/schedulerList/Scheduler.js +28 -0
- package/presentation/schedulerList/Scheduler.js.map +1 -0
- package/presentation/schedulerList/SchedulerListDataSource.d.ts +15 -0
- package/presentation/schedulerList/SchedulerListDataSource.js +41 -0
- package/presentation/schedulerList/SchedulerListDataSource.js.map +1 -0
- package/presentation/schedulerList/SchedulerListPresenter.d.ts +21 -0
- package/presentation/schedulerList/SchedulerListPresenter.js +47 -0
- package/presentation/schedulerList/SchedulerListPresenter.js.map +1 -0
- package/presentation/schedulerList/abstractions.d.ts +13 -0
- package/presentation/schedulerList/abstractions.js +5 -0
- package/presentation/schedulerList/abstractions.js.map +1 -0
- package/presentation/schedulerList/components/BottomInfoBar.d.ts +9 -0
- package/presentation/schedulerList/components/BottomInfoBar.js +18 -0
- package/presentation/schedulerList/components/BottomInfoBar.js.map +1 -0
- package/presentation/schedulerList/components/Empty.d.ts +9 -0
- package/presentation/schedulerList/components/Empty.js +21 -0
- package/presentation/schedulerList/components/Empty.js.map +1 -0
- package/presentation/schedulerList/components/SchedulerListView.d.ts +8 -0
- package/presentation/schedulerList/components/SchedulerListView.js +40 -0
- package/presentation/schedulerList/components/SchedulerListView.js.map +1 -0
- package/presentation/schedulerList/components/SchedulerOverlay.d.ts +11 -0
- package/presentation/schedulerList/components/SchedulerOverlay.js +38 -0
- package/presentation/schedulerList/components/SchedulerOverlay.js.map +1 -0
- package/presentation/schedulerList/components/SchedulerTable.d.ts +9 -0
- package/presentation/schedulerList/components/SchedulerTable.js +48 -0
- package/presentation/schedulerList/components/SchedulerTable.js.map +1 -0
- package/presentation/schedulerList/components/SearchInput.d.ts +9 -0
- package/presentation/schedulerList/components/SearchInput.js +30 -0
- package/presentation/schedulerList/components/SearchInput.js.map +1 -0
- package/presentation/schedulerList/feature.d.ts +3 -0
- package/presentation/schedulerList/feature.js +17 -0
- package/presentation/schedulerList/feature.js.map +1 -0
- package/presentation/schedulerList/useSchedulerListPresenter.d.ts +1 -0
- package/presentation/schedulerList/useSchedulerListPresenter.js +6 -0
- package/presentation/schedulerList/useSchedulerListPresenter.js.map +1 -0
- package/types.d.ts +30 -0
- package/types.js +8 -0
- package/types.js.map +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ShowDialogParamsEntryStatus = "published" | "unpublished" | "draft" | string;
|
|
2
|
+
export interface IShowDialogParamsEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
status: ShowDialogParamsEntryStatus;
|
|
5
|
+
title: string;
|
|
6
|
+
}
|
|
7
|
+
interface UseShowScheduleDialogResponse {
|
|
8
|
+
showDialog: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface IUseScheduleDialogProps {
|
|
11
|
+
namespace: string;
|
|
12
|
+
target: IShowDialogParamsEntry;
|
|
13
|
+
/**
|
|
14
|
+
* Called after a scheduled action is successfully created/updated or cancelled. Use it to
|
|
15
|
+
* refresh anything that displays the scheduled state (e.g. list cells, form banners).
|
|
16
|
+
*/
|
|
17
|
+
onCompleted?: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const useScheduleDialog: (props: IUseScheduleDialogProps) => UseShowScheduleDialogResponse;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import react, { useCallback, useMemo, useRef } from "react";
|
|
2
|
+
import { useContainer } from "@webiny/app";
|
|
3
|
+
import { useToast } from "@webiny/admin-ui";
|
|
4
|
+
import { useDialogs } from "@webiny/app-admin";
|
|
5
|
+
import { ScheduleActionType } from "../../types.js";
|
|
6
|
+
import { ScheduleDialogPresenter } from "./abstractions.js";
|
|
7
|
+
import { FormComponent } from "./components/FormComponent.js";
|
|
8
|
+
import { CancelButtonComponent } from "./components/CancelButtonComponent.js";
|
|
9
|
+
const useScheduleDialog = (props)=>{
|
|
10
|
+
const { target, namespace, onCompleted } = props;
|
|
11
|
+
const container = useContainer();
|
|
12
|
+
const dialog = useDialogs();
|
|
13
|
+
const toast = useToast();
|
|
14
|
+
const presenter = useMemo(()=>container.resolve(ScheduleDialogPresenter), [
|
|
15
|
+
container
|
|
16
|
+
]);
|
|
17
|
+
const dialogClose = useRef(()=>{});
|
|
18
|
+
const onAccept = useCallback(async (params)=>{
|
|
19
|
+
const { scheduleOn, actionType } = params;
|
|
20
|
+
try {
|
|
21
|
+
await presenter.schedule({
|
|
22
|
+
targetId: target.id,
|
|
23
|
+
namespace,
|
|
24
|
+
scheduleOn,
|
|
25
|
+
actionType
|
|
26
|
+
});
|
|
27
|
+
toast.showSuccessToast({
|
|
28
|
+
title: `Scheduled ${actionType} action for "${target.title}"!`
|
|
29
|
+
});
|
|
30
|
+
onCompleted?.();
|
|
31
|
+
} catch (error) {
|
|
32
|
+
toast.showWarningToast({
|
|
33
|
+
title: error.message
|
|
34
|
+
});
|
|
35
|
+
console.error(error);
|
|
36
|
+
}
|
|
37
|
+
}, [
|
|
38
|
+
presenter.vm
|
|
39
|
+
]);
|
|
40
|
+
const onCancel = useCallback(async ()=>{
|
|
41
|
+
const entry = presenter.vm.entry;
|
|
42
|
+
if (!entry) {
|
|
43
|
+
toast.showWarningToast({
|
|
44
|
+
title: `No scheduled action found for "${target.title}"!`
|
|
45
|
+
});
|
|
46
|
+
if (dialogClose.current) {
|
|
47
|
+
dialogClose.current();
|
|
48
|
+
dialogClose.current = null;
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (dialogClose.current) {
|
|
53
|
+
dialogClose.current();
|
|
54
|
+
dialogClose.current = null;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
await presenter.cancel({
|
|
58
|
+
id: entry.id,
|
|
59
|
+
namespace: entry.namespace
|
|
60
|
+
});
|
|
61
|
+
toast.showSuccessToast({
|
|
62
|
+
title: `Canceled scheduled ${entry.actionType} on "${entry.title}"!`
|
|
63
|
+
});
|
|
64
|
+
onCompleted?.();
|
|
65
|
+
} catch (error) {
|
|
66
|
+
toast.showWarningToast({
|
|
67
|
+
title: error.message
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}, [
|
|
71
|
+
presenter.vm
|
|
72
|
+
]);
|
|
73
|
+
const showDialog = async ()=>{
|
|
74
|
+
const isPublished = "published" === target.status;
|
|
75
|
+
dialogClose.current = dialog.showDialog({
|
|
76
|
+
title: `Schedule "${target.title}"`,
|
|
77
|
+
content: /*#__PURE__*/ react.createElement(FormComponent, {
|
|
78
|
+
presenter: presenter
|
|
79
|
+
}),
|
|
80
|
+
formData: async ()=>{
|
|
81
|
+
await presenter.load({
|
|
82
|
+
namespace,
|
|
83
|
+
id: target.id
|
|
84
|
+
});
|
|
85
|
+
const entry = presenter.vm.entry;
|
|
86
|
+
const scheduleOn = entry?.publishOn || entry?.unpublishOn;
|
|
87
|
+
return {
|
|
88
|
+
scheduleOn
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
acceptLabel: isPublished ? "Schedule Unpublish" : "Schedule Publish",
|
|
92
|
+
cancelLabel: "Discard",
|
|
93
|
+
loadingLabel: "Scheduling...",
|
|
94
|
+
dataLoadingLabel: "Checking schedule...",
|
|
95
|
+
info: /*#__PURE__*/ react.createElement(CancelButtonComponent, {
|
|
96
|
+
presenter: presenter,
|
|
97
|
+
onCancel: onCancel
|
|
98
|
+
}),
|
|
99
|
+
dismissible: false,
|
|
100
|
+
onAccept: (data)=>{
|
|
101
|
+
if (!data.scheduleOn) return void toast.showWarningToast({
|
|
102
|
+
title: 'Missing "Schedule On" date!'
|
|
103
|
+
});
|
|
104
|
+
let scheduleOn;
|
|
105
|
+
try {
|
|
106
|
+
scheduleOn = new Date(data.scheduleOn);
|
|
107
|
+
} catch (ex) {
|
|
108
|
+
toast.showWarningToast({
|
|
109
|
+
title: 'Invalid "Schedule On" date!'
|
|
110
|
+
});
|
|
111
|
+
console.error(ex);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const actionType = isPublished ? ScheduleActionType.unpublish : ScheduleActionType.publish;
|
|
115
|
+
return onAccept({
|
|
116
|
+
scheduleOn,
|
|
117
|
+
actionType
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
showDialog
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export { useScheduleDialog };
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=useScheduleDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/scheduleDialog/useScheduleDialog.js","sources":["../../../src/presentation/scheduleDialog/useScheduleDialog.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useRef } from \"react\";\nimport { useContainer } from \"@webiny/app\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useDialogs } from \"@webiny/app-admin\";\nimport { ScheduleActionType } from \"~/types.js\";\nimport { ScheduleDialogPresenter } from \"./abstractions.js\";\nimport { FormComponent } from \"./components/FormComponent.js\";\nimport { CancelButtonComponent } from \"./components/CancelButtonComponent.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 ScheduleFormData {\n scheduleOn?: string;\n}\n\ninterface IOnAcceptParams {\n scheduleOn: Date;\n actionType: ScheduleActionType;\n}\n\nexport interface IUseScheduleDialogProps {\n namespace: string;\n target: IShowDialogParamsEntry;\n /**\n * Called after a scheduled action is successfully created/updated or cancelled. Use it to\n * refresh anything that displays the scheduled state (e.g. list cells, form banners).\n */\n onCompleted?: () => void;\n}\n\nexport const useScheduleDialog = (\n props: IUseScheduleDialogProps\n): UseShowScheduleDialogResponse => {\n const { target, namespace, onCompleted } = props;\n const container = useContainer();\n const dialog = useDialogs();\n const toast = useToast();\n\n const presenter = useMemo(() => {\n return container.resolve(ScheduleDialogPresenter);\n }, [container]);\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 toast.showSuccessToast({\n title: `Scheduled ${actionType} action for \"${target.title}\"!`\n });\n onCompleted?.();\n } catch (error) {\n toast.showWarningToast({ title: 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 toast.showWarningToast({ title: `No scheduled action found for \"${target.title}\"!` });\n if (dialogClose.current) {\n dialogClose.current();\n dialogClose.current = null;\n }\n return;\n }\n\n if (dialogClose.current) {\n dialogClose.current();\n dialogClose.current = null;\n }\n\n try {\n await presenter.cancel({\n id: entry.id,\n namespace: entry.namespace\n });\n toast.showSuccessToast({\n title: `Canceled scheduled ${entry.actionType} on \"${entry.title}\"!`\n });\n onCompleted?.();\n } catch (error) {\n toast.showWarningToast({ title: error.message });\n }\n }, [presenter.vm]);\n\n const showDialog = async () => {\n const isPublished = target.status === \"published\";\n\n dialogClose.current = dialog.showDialog({\n title: `Schedule \"${target.title}\"`,\n content: <FormComponent presenter={presenter} />,\n formData: async () => {\n await presenter.load({ namespace, id: target.id });\n\n const entry = presenter.vm.entry;\n const scheduleOn = entry?.publishOn || entry?.unpublishOn;\n\n return { scheduleOn };\n },\n acceptLabel: isPublished ? \"Schedule Unpublish\" : \"Schedule Publish\",\n cancelLabel: \"Discard\",\n loadingLabel: \"Scheduling...\",\n dataLoadingLabel: \"Checking schedule...\",\n info: <CancelButtonComponent presenter={presenter} onCancel={onCancel} />,\n dismissible: false,\n onAccept: (data: Partial<ScheduleFormData>) => {\n if (!data.scheduleOn) {\n toast.showWarningToast({ title: `Missing \"Schedule On\" date!` });\n return;\n }\n let scheduleOn: Date;\n try {\n scheduleOn = new Date(data.scheduleOn);\n } catch (ex) {\n toast.showWarningToast({ title: `Invalid \"Schedule On\" date!` });\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":["useScheduleDialog","props","target","namespace","onCompleted","container","useContainer","dialog","useDialogs","toast","useToast","presenter","useMemo","ScheduleDialogPresenter","dialogClose","useRef","onAccept","useCallback","params","scheduleOn","actionType","error","console","onCancel","entry","showDialog","isPublished","FormComponent","CancelButtonComponent","data","Date","ex","ScheduleActionType"],"mappings":";;;;;;;;AAwCO,MAAMA,oBAAoB,CAC7BC;IAEA,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAEC,WAAW,EAAE,GAAGH;IAC3C,MAAMI,YAAYC;IAClB,MAAMC,SAASC;IACf,MAAMC,QAAQC;IAEd,MAAMC,YAAYC,QAAQ,IACfP,UAAU,OAAO,CAACQ,0BAC1B;QAACR;KAAU;IAEd,MAAMS,cAAcC,OAA4B,KAEhD;IAEA,MAAMC,WAAWC,YACb,OAAOC;QACH,MAAM,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGF;QAEnC,IAAI;YACA,MAAMP,UAAU,QAAQ,CAAC;gBACrB,UAAUT,OAAO,EAAE;gBACnBC;gBACAgB;gBACAC;YACJ;YACAX,MAAM,gBAAgB,CAAC;gBACnB,OAAO,CAAC,UAAU,EAAEW,WAAW,aAAa,EAAElB,OAAO,KAAK,CAAC,EAAE,CAAC;YAClE;YACAE;QACJ,EAAE,OAAOiB,OAAO;YACZZ,MAAM,gBAAgB,CAAC;gBAAE,OAAOY,MAAM,OAAO;YAAC;YAC9CC,QAAQ,KAAK,CAACD;QAClB;IACJ,GACA;QAACV,UAAU,EAAE;KAAC;IAGlB,MAAMY,WAAWN,YAAY;QACzB,MAAMO,QAAQb,UAAU,EAAE,CAAC,KAAK;QAChC,IAAI,CAACa,OAAO;YACRf,MAAM,gBAAgB,CAAC;gBAAE,OAAO,CAAC,+BAA+B,EAAEP,OAAO,KAAK,CAAC,EAAE,CAAC;YAAC;YACnF,IAAIY,YAAY,OAAO,EAAE;gBACrBA,YAAY,OAAO;gBACnBA,YAAY,OAAO,GAAG;YAC1B;YACA;QACJ;QAEA,IAAIA,YAAY,OAAO,EAAE;YACrBA,YAAY,OAAO;YACnBA,YAAY,OAAO,GAAG;QAC1B;QAEA,IAAI;YACA,MAAMH,UAAU,MAAM,CAAC;gBACnB,IAAIa,MAAM,EAAE;gBACZ,WAAWA,MAAM,SAAS;YAC9B;YACAf,MAAM,gBAAgB,CAAC;gBACnB,OAAO,CAAC,mBAAmB,EAAEe,MAAM,UAAU,CAAC,KAAK,EAAEA,MAAM,KAAK,CAAC,EAAE,CAAC;YACxE;YACApB;QACJ,EAAE,OAAOiB,OAAO;YACZZ,MAAM,gBAAgB,CAAC;gBAAE,OAAOY,MAAM,OAAO;YAAC;QAClD;IACJ,GAAG;QAACV,UAAU,EAAE;KAAC;IAEjB,MAAMc,aAAa;QACf,MAAMC,cAAcxB,AAAkB,gBAAlBA,OAAO,MAAM;QAEjCY,YAAY,OAAO,GAAGP,OAAO,UAAU,CAAC;YACpC,OAAO,CAAC,UAAU,EAAEL,OAAO,KAAK,CAAC,CAAC,CAAC;YACnC,SAAS,WAAT,GAAS,oBAACyB,eAAaA;gBAAC,WAAWhB;;YACnC,UAAU;gBACN,MAAMA,UAAU,IAAI,CAAC;oBAAER;oBAAW,IAAID,OAAO,EAAE;gBAAC;gBAEhD,MAAMsB,QAAQb,UAAU,EAAE,CAAC,KAAK;gBAChC,MAAMQ,aAAaK,OAAO,aAAaA,OAAO;gBAE9C,OAAO;oBAAEL;gBAAW;YACxB;YACA,aAAaO,cAAc,uBAAuB;YAClD,aAAa;YACb,cAAc;YACd,kBAAkB;YAClB,MAAM,WAAN,GAAM,oBAACE,uBAAqBA;gBAAC,WAAWjB;gBAAW,UAAUY;;YAC7D,aAAa;YACb,UAAU,CAACM;gBACP,IAAI,CAACA,KAAK,UAAU,EAAE,YAClBpB,MAAM,gBAAgB,CAAC;oBAAE,OAAO;gBAA8B;gBAGlE,IAAIU;gBACJ,IAAI;oBACAA,aAAa,IAAIW,KAAKD,KAAK,UAAU;gBACzC,EAAE,OAAOE,IAAI;oBACTtB,MAAM,gBAAgB,CAAC;wBAAE,OAAO;oBAA8B;oBAC9Da,QAAQ,KAAK,CAACS;oBACd;gBACJ;gBAEA,MAAMX,aAAaM,cACbM,mBAAmB,SAAS,GAC5BA,mBAAmB,OAAO;gBAEhC,OAAOhB,SAAS;oBACZG;oBACAC;gBACJ;YACJ;QACJ;IACJ;IAEA,OAAO;QACHK;IACJ;AACJ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface SchedulerRenderPropParams {
|
|
3
|
+
showScheduler: () => void;
|
|
4
|
+
}
|
|
5
|
+
interface SchedulerRenderProps {
|
|
6
|
+
(params: SchedulerRenderPropParams): React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export interface SchedulerProps {
|
|
9
|
+
namespace: string;
|
|
10
|
+
render: SchedulerRenderProps;
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
show?: boolean;
|
|
13
|
+
title?: string;
|
|
14
|
+
canPublish: boolean;
|
|
15
|
+
canUnpublish: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const Scheduler: ({ render, show: initialShow, ...rest }: SchedulerProps) => React.JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import react, { useCallback, useState } from "react";
|
|
2
|
+
import { CompositionScope } from "@webiny/react-composition";
|
|
3
|
+
import { SchedulerListWithConfig } from "../configs/index.js";
|
|
4
|
+
import { SchedulerListView } from "./components/SchedulerListView.js";
|
|
5
|
+
const Scheduler = ({ render, show: initialShow, ...rest })=>{
|
|
6
|
+
const [show, setShow] = useState(initialShow ?? false);
|
|
7
|
+
const showScheduler = useCallback(()=>{
|
|
8
|
+
setShow(true);
|
|
9
|
+
}, []);
|
|
10
|
+
const onClose = useCallback(()=>{
|
|
11
|
+
if ("function" == typeof rest.onClose) rest.onClose();
|
|
12
|
+
setShow(false);
|
|
13
|
+
}, [
|
|
14
|
+
rest.onClose
|
|
15
|
+
]);
|
|
16
|
+
return /*#__PURE__*/ react.createElement(react.Fragment, null, show ? /*#__PURE__*/ react.createElement(CompositionScope, {
|
|
17
|
+
name: "scheduler"
|
|
18
|
+
}, /*#__PURE__*/ react.createElement(SchedulerListWithConfig, null, /*#__PURE__*/ react.createElement(SchedulerListView, {
|
|
19
|
+
namespace: rest.namespace,
|
|
20
|
+
onClose: onClose,
|
|
21
|
+
title: rest.title ?? "Scheduler"
|
|
22
|
+
}))) : null, render ? render({
|
|
23
|
+
showScheduler
|
|
24
|
+
}) : null);
|
|
25
|
+
};
|
|
26
|
+
export { Scheduler };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=Scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/schedulerList/Scheduler.js","sources":["../../../src/presentation/schedulerList/Scheduler.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport { CompositionScope } from \"@webiny/react-composition\";\nimport { SchedulerListWithConfig } from \"~/presentation/configs/index.js\";\nimport { SchedulerListView } from \"./components/SchedulerListView.js\";\n\nexport interface SchedulerRenderPropParams {\n showScheduler: () => void;\n}\n\ninterface SchedulerRenderProps {\n (params: SchedulerRenderPropParams): React.ReactNode;\n}\n\nexport interface SchedulerProps {\n namespace: string;\n render: SchedulerRenderProps;\n onClose?: () => void;\n show?: boolean;\n title?: string;\n canPublish: boolean;\n canUnpublish: boolean;\n}\n\nexport const Scheduler = ({ render, show: initialShow, ...rest }: SchedulerProps) => {\n const [show, setShow] = useState(initialShow ?? false);\n\n const showScheduler = useCallback(() => {\n setShow(true);\n }, []);\n\n const onClose = useCallback(() => {\n if (typeof rest.onClose === \"function\") {\n rest.onClose();\n }\n setShow(false);\n }, [rest.onClose]);\n\n return (\n <>\n {show ? (\n <CompositionScope name={\"scheduler\"}>\n <SchedulerListWithConfig>\n <SchedulerListView\n namespace={rest.namespace}\n onClose={onClose}\n title={rest.title ?? \"Scheduler\"}\n />\n </SchedulerListWithConfig>\n </CompositionScope>\n ) : null}\n {render ? render({ showScheduler }) : null}\n </>\n );\n};\n"],"names":["Scheduler","render","initialShow","rest","show","setShow","useState","showScheduler","useCallback","onClose","CompositionScope","SchedulerListWithConfig","SchedulerListView"],"mappings":";;;;AAuBO,MAAMA,YAAY,CAAC,EAAEC,MAAM,EAAE,MAAMC,WAAW,EAAE,GAAGC,MAAsB;IAC5E,MAAM,CAACC,MAAMC,QAAQ,GAAGC,SAASJ,eAAe;IAEhD,MAAMK,gBAAgBC,YAAY;QAC9BH,QAAQ;IACZ,GAAG,EAAE;IAEL,MAAMI,UAAUD,YAAY;QACxB,IAAI,AAAwB,cAAxB,OAAOL,KAAK,OAAO,EACnBA,KAAK,OAAO;QAEhBE,QAAQ;IACZ,GAAG;QAACF,KAAK,OAAO;KAAC;IAEjB,OAAO,WAAP,GACI,0CACKC,OAAO,WAAPA,GACG,oBAACM,kBAAgBA;QAAC,MAAM;qBACpB,oBAACC,yBAAuBA,MAAAA,WAAAA,GACpB,oBAACC,mBAAiBA;QACd,WAAWT,KAAK,SAAS;QACzB,SAASM;QACT,OAAON,KAAK,KAAK,IAAI;WAIjC,MACHF,SAASA,OAAO;QAAEM;IAAc,KAAK;AAGlD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SimpleDataSource } from "@webiny/app-admin/presentation/listPresenter/SimpleDataSource.js";
|
|
2
|
+
import type { FetchResult } from "@webiny/app-admin/presentation/listPresenter/FolderAwareDataSource.js";
|
|
3
|
+
import type { IDataSourceQuery } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
|
|
4
|
+
import type { ListScheduledActionsGateway } from "../../features/listScheduledActions/abstractions.js";
|
|
5
|
+
import type { SchedulerEntry } from "../../types.js";
|
|
6
|
+
export declare class SchedulerListDataSource extends SimpleDataSource<SchedulerEntry> {
|
|
7
|
+
private readonly gateway;
|
|
8
|
+
private readonly namespace;
|
|
9
|
+
private _rows;
|
|
10
|
+
constructor(gateway: ListScheduledActionsGateway.Interface, namespace: string);
|
|
11
|
+
get rows(): SchedulerEntry[];
|
|
12
|
+
fetch(params: IDataSourceQuery): Promise<FetchResult<SchedulerEntry>>;
|
|
13
|
+
onQueryResult(data: SchedulerEntry[]): void;
|
|
14
|
+
onLoadMoreResult(data: SchedulerEntry[]): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { makeObservable, observable } from "mobx";
|
|
2
|
+
import { SimpleDataSource } from "@webiny/app-admin/presentation/listPresenter/SimpleDataSource.js";
|
|
3
|
+
class SchedulerListDataSource extends SimpleDataSource {
|
|
4
|
+
constructor(gateway, namespace){
|
|
5
|
+
super(), this.gateway = gateway, this.namespace = namespace, this._rows = [];
|
|
6
|
+
makeObservable(this, {
|
|
7
|
+
_rows: observable
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
get rows() {
|
|
11
|
+
return this._rows;
|
|
12
|
+
}
|
|
13
|
+
async fetch(params) {
|
|
14
|
+
const sort = params.sort ? [
|
|
15
|
+
`${params.sort.field}_${params.sort.direction}`
|
|
16
|
+
] : void 0;
|
|
17
|
+
const result = await this.gateway.execute({
|
|
18
|
+
namespace: this.namespace,
|
|
19
|
+
where: params.filters,
|
|
20
|
+
sort: sort,
|
|
21
|
+
limit: params.limit,
|
|
22
|
+
after: params.cursor
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
data: result.items,
|
|
26
|
+
meta: result.meta
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
onQueryResult(data) {
|
|
30
|
+
this._rows = data;
|
|
31
|
+
}
|
|
32
|
+
onLoadMoreResult(data) {
|
|
33
|
+
this._rows = [
|
|
34
|
+
...this._rows,
|
|
35
|
+
...data
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export { SchedulerListDataSource };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=SchedulerListDataSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/schedulerList/SchedulerListDataSource.js","sources":["../../../src/presentation/schedulerList/SchedulerListDataSource.ts"],"sourcesContent":["import { makeObservable, observable } from \"mobx\";\nimport { SimpleDataSource } from \"@webiny/app-admin/presentation/listPresenter/SimpleDataSource.js\";\nimport type { FetchResult } from \"@webiny/app-admin/presentation/listPresenter/FolderAwareDataSource.js\";\nimport type { IDataSourceQuery } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport type { ListScheduledActionsGateway } from \"~/features/listScheduledActions/abstractions.js\";\nimport type { SchedulerEntry } from \"~/types.js\";\n\nexport class SchedulerListDataSource extends SimpleDataSource<SchedulerEntry> {\n private _rows: SchedulerEntry[] = [];\n\n constructor(\n private readonly gateway: ListScheduledActionsGateway.Interface,\n private readonly namespace: string\n ) {\n super();\n makeObservable<SchedulerListDataSource, \"_rows\">(this, {\n _rows: observable\n });\n }\n\n get rows(): SchedulerEntry[] {\n return this._rows;\n }\n\n async fetch(params: IDataSourceQuery): Promise<FetchResult<SchedulerEntry>> {\n const sort = params.sort ? [`${params.sort.field}_${params.sort.direction}`] : undefined;\n\n const result = await this.gateway.execute({\n namespace: this.namespace,\n where: params.filters as Record<string, any> | undefined,\n sort: sort as any,\n limit: params.limit,\n after: params.cursor\n });\n\n return {\n data: result.items,\n meta: result.meta\n };\n }\n\n override onQueryResult(data: SchedulerEntry[]): void {\n this._rows = data;\n }\n\n override onLoadMoreResult(data: SchedulerEntry[]): void {\n this._rows = [...this._rows, ...data];\n }\n}\n"],"names":["SchedulerListDataSource","SimpleDataSource","gateway","namespace","makeObservable","observable","params","sort","undefined","result","data"],"mappings":";;AAOO,MAAMA,gCAAgCC;IAGzC,YACqBC,OAA8C,EAC9CC,SAAiB,CACpC;QACE,KAAK,SAHYD,OAAO,GAAPA,SAAAA,IAAAA,CACAC,SAAS,GAATA,WAAAA,IAAAA,CAJb,KAAK,GAAqB,EAAE;QAOhCC,eAAiD,IAAI,EAAE;YACnD,OAAOC;QACX;IACJ;IAEA,IAAI,OAAyB;QACzB,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,MAAM,MAAMC,MAAwB,EAAwC;QACxE,MAAMC,OAAOD,OAAO,IAAI,GAAG;YAAC,GAAGA,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAEA,OAAO,IAAI,CAAC,SAAS,EAAE;SAAC,GAAGE;QAE/E,MAAMC,SAAS,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;YACtC,WAAW,IAAI,CAAC,SAAS;YACzB,OAAOH,OAAO,OAAO;YACrB,MAAMC;YACN,OAAOD,OAAO,KAAK;YACnB,OAAOA,OAAO,MAAM;QACxB;QAEA,OAAO;YACH,MAAMG,OAAO,KAAK;YAClB,MAAMA,OAAO,IAAI;QACrB;IACJ;IAES,cAAcC,IAAsB,EAAQ;QACjD,IAAI,CAAC,KAAK,GAAGA;IACjB;IAES,iBAAiBA,IAAsB,EAAQ;QACpD,IAAI,CAAC,KAAK,GAAG;eAAI,IAAI,CAAC,KAAK;eAAKA;SAAK;IACzC;AACJ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ListPresenter } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
|
|
2
|
+
import { ListScheduledActionsGateway } from "../../features/listScheduledActions/abstractions.js";
|
|
3
|
+
import { CancelScheduledActionGateway } from "../../features/cancelScheduledAction/abstractions.js";
|
|
4
|
+
import { type ISchedulerListPresenter } from "./abstractions.js";
|
|
5
|
+
import type { SchedulerEntry } from "../../types.js";
|
|
6
|
+
declare class SchedulerListPresenterImpl implements ISchedulerListPresenter {
|
|
7
|
+
private readonly _listPresenter;
|
|
8
|
+
private readonly listGateway;
|
|
9
|
+
private readonly cancelGateway;
|
|
10
|
+
private _namespace;
|
|
11
|
+
constructor(_listPresenter: ListPresenter.Interface<SchedulerEntry>, listGateway: ListScheduledActionsGateway.Interface, cancelGateway: CancelScheduledActionGateway.Interface);
|
|
12
|
+
get list(): ListPresenter.Interface<SchedulerEntry>;
|
|
13
|
+
init(params: {
|
|
14
|
+
namespace: string;
|
|
15
|
+
}): void;
|
|
16
|
+
cancelItem(id: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare const SchedulerListPresenter: typeof SchedulerListPresenterImpl & {
|
|
19
|
+
__abstraction: import("@webiny/di").Abstraction<ISchedulerListPresenter>;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { makeAutoObservable } from "mobx";
|
|
2
|
+
import { ListPresenter } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
|
|
3
|
+
import { ListScheduledActionsGateway } from "../../features/listScheduledActions/abstractions.js";
|
|
4
|
+
import { CancelScheduledActionGateway } from "../../features/cancelScheduledAction/abstractions.js";
|
|
5
|
+
import { SchedulerListPresenter } from "./abstractions.js";
|
|
6
|
+
import { SchedulerListDataSource } from "./SchedulerListDataSource.js";
|
|
7
|
+
class SchedulerListPresenterImpl {
|
|
8
|
+
constructor(_listPresenter, listGateway, cancelGateway){
|
|
9
|
+
this._listPresenter = _listPresenter;
|
|
10
|
+
this.listGateway = listGateway;
|
|
11
|
+
this.cancelGateway = cancelGateway;
|
|
12
|
+
makeAutoObservable(this);
|
|
13
|
+
}
|
|
14
|
+
get list() {
|
|
15
|
+
return this._listPresenter;
|
|
16
|
+
}
|
|
17
|
+
init(params) {
|
|
18
|
+
this._namespace = params.namespace;
|
|
19
|
+
const dataSource = new SchedulerListDataSource(this.listGateway, params.namespace);
|
|
20
|
+
this._listPresenter.init({
|
|
21
|
+
dataSource,
|
|
22
|
+
initialSort: {
|
|
23
|
+
field: "scheduledFor",
|
|
24
|
+
direction: "DESC"
|
|
25
|
+
},
|
|
26
|
+
limit: 50
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async cancelItem(id) {
|
|
30
|
+
await this.cancelGateway.execute({
|
|
31
|
+
namespace: this._namespace,
|
|
32
|
+
id
|
|
33
|
+
});
|
|
34
|
+
await this._listPresenter.actions.refresh();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const SchedulerListPresenter_SchedulerListPresenter = SchedulerListPresenter.createImplementation({
|
|
38
|
+
implementation: SchedulerListPresenterImpl,
|
|
39
|
+
dependencies: [
|
|
40
|
+
ListPresenter,
|
|
41
|
+
ListScheduledActionsGateway,
|
|
42
|
+
CancelScheduledActionGateway
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
export { SchedulerListPresenter_SchedulerListPresenter as SchedulerListPresenter };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=SchedulerListPresenter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/schedulerList/SchedulerListPresenter.js","sources":["../../../src/presentation/schedulerList/SchedulerListPresenter.ts"],"sourcesContent":["import { makeAutoObservable } from \"mobx\";\nimport { ListPresenter } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport { ListScheduledActionsGateway } from \"~/features/listScheduledActions/abstractions.js\";\nimport { CancelScheduledActionGateway } from \"~/features/cancelScheduledAction/abstractions.js\";\nimport {\n SchedulerListPresenter as Abstraction,\n type ISchedulerListPresenter\n} from \"./abstractions.js\";\nimport { SchedulerListDataSource } from \"./SchedulerListDataSource.js\";\nimport type { SchedulerEntry } from \"~/types.js\";\n\nclass SchedulerListPresenterImpl implements ISchedulerListPresenter {\n private _namespace!: string;\n\n constructor(\n private readonly _listPresenter: ListPresenter.Interface<SchedulerEntry>,\n private readonly listGateway: ListScheduledActionsGateway.Interface,\n private readonly cancelGateway: CancelScheduledActionGateway.Interface\n ) {\n makeAutoObservable(this);\n }\n\n get list(): ListPresenter.Interface<SchedulerEntry> {\n return this._listPresenter;\n }\n\n init(params: { namespace: string }) {\n this._namespace = params.namespace;\n const dataSource = new SchedulerListDataSource(this.listGateway, params.namespace);\n this._listPresenter.init({\n dataSource,\n initialSort: { field: \"scheduledFor\", direction: \"DESC\" },\n limit: 50\n });\n }\n\n async cancelItem(id: string) {\n await this.cancelGateway.execute({ namespace: this._namespace, id });\n await this._listPresenter.actions.refresh();\n }\n}\n\nexport const SchedulerListPresenter = Abstraction.createImplementation({\n implementation: SchedulerListPresenterImpl,\n dependencies: [ListPresenter, ListScheduledActionsGateway, CancelScheduledActionGateway]\n});\n"],"names":["SchedulerListPresenterImpl","_listPresenter","listGateway","cancelGateway","makeAutoObservable","params","dataSource","SchedulerListDataSource","id","SchedulerListPresenter","Abstraction","ListPresenter","ListScheduledActionsGateway","CancelScheduledActionGateway"],"mappings":";;;;;;AAWA,MAAMA;IAGF,YACqBC,cAAuD,EACvDC,WAAkD,EAClDC,aAAqD,CACxE;aAHmBF,cAAc,GAAdA;aACAC,WAAW,GAAXA;aACAC,aAAa,GAAbA;QAEjBC,mBAAmB,IAAI;IAC3B;IAEA,IAAI,OAAgD;QAChD,OAAO,IAAI,CAAC,cAAc;IAC9B;IAEA,KAAKC,MAA6B,EAAE;QAChC,IAAI,CAAC,UAAU,GAAGA,OAAO,SAAS;QAClC,MAAMC,aAAa,IAAIC,wBAAwB,IAAI,CAAC,WAAW,EAAEF,OAAO,SAAS;QACjF,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;YACrBC;YACA,aAAa;gBAAE,OAAO;gBAAgB,WAAW;YAAO;YACxD,OAAO;QACX;IACJ;IAEA,MAAM,WAAWE,EAAU,EAAE;QACzB,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;YAAE,WAAW,IAAI,CAAC,UAAU;YAAEA;QAAG;QAClE,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO;IAC7C;AACJ;AAEO,MAAMC,gDAAyBC,uBAAAA,oBAAgC,CAAC;IACnE,gBAAgBV;IAChB,cAAc;QAACW;QAAeC;QAA6BC;KAA6B;AAC5F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ListPresenter } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
|
|
2
|
+
import type { SchedulerEntry } from "../../types.js";
|
|
3
|
+
export interface ISchedulerListPresenter {
|
|
4
|
+
readonly list: ListPresenter.Interface<SchedulerEntry>;
|
|
5
|
+
init(params: {
|
|
6
|
+
namespace: string;
|
|
7
|
+
}): void;
|
|
8
|
+
cancelItem(id: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const SchedulerListPresenter: import("@webiny/di").Abstraction<ISchedulerListPresenter>;
|
|
11
|
+
export declare namespace SchedulerListPresenter {
|
|
12
|
+
type Interface = ISchedulerListPresenter;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/schedulerList/abstractions.js","sources":["../../../src/presentation/schedulerList/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { ListPresenter } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport type { SchedulerEntry } from \"~/types.js\";\n\nexport interface ISchedulerListPresenter {\n readonly list: ListPresenter.Interface<SchedulerEntry>;\n init(params: { namespace: string }): void;\n cancelItem(id: string): Promise<void>;\n}\n\nexport const SchedulerListPresenter =\n createAbstraction<ISchedulerListPresenter>(\"Scheduler/ListPresenter\");\n\nexport namespace SchedulerListPresenter {\n export type Interface = ISchedulerListPresenter;\n}\n"],"names":["SchedulerListPresenter","createAbstraction"],"mappings":";AAUO,MAAMA,yBACTC,kBAA2C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ISchedulerListPresenter } from "../abstractions.js";
|
|
3
|
+
interface BottomInfoBarProps {
|
|
4
|
+
presenter: ISchedulerListPresenter;
|
|
5
|
+
}
|
|
6
|
+
export declare const BottomInfoBar: (({ presenter }: BottomInfoBarProps) => React.JSX.Element) & React.NamedExoticComponent<BottomInfoBarProps> & {
|
|
7
|
+
readonly type: ({ presenter }: BottomInfoBarProps) => React.JSX.Element;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { observer } from "mobx-react-lite";
|
|
3
|
+
import { ListMeta } from "../../components/BottomInfoBar/ListMeta.js";
|
|
4
|
+
import { ListStatus } from "../../components/BottomInfoBar/ListStatus.js";
|
|
5
|
+
import { BottomInfoBarInner, BottomInfoBarWrapper } from "../../components/BottomInfoBar/BottomInfoBar.styled.js";
|
|
6
|
+
const BottomInfoBar = observer(({ presenter })=>{
|
|
7
|
+
const { vm } = presenter.list;
|
|
8
|
+
return /*#__PURE__*/ react.createElement(BottomInfoBarWrapper, null, /*#__PURE__*/ react.createElement(BottomInfoBarInner, null, /*#__PURE__*/ react.createElement(ListMeta, {
|
|
9
|
+
loading: vm.pagination.loading,
|
|
10
|
+
totalCount: vm.pagination.totalCount,
|
|
11
|
+
currentCount: vm.pagination.currentCount
|
|
12
|
+
}), /*#__PURE__*/ react.createElement(ListStatus, {
|
|
13
|
+
loading: vm.pagination.loadingMore
|
|
14
|
+
})));
|
|
15
|
+
});
|
|
16
|
+
export { BottomInfoBar };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=BottomInfoBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/schedulerList/components/BottomInfoBar.js","sources":["../../../../src/presentation/schedulerList/components/BottomInfoBar.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { ListMeta } from \"~/presentation/components/BottomInfoBar/ListMeta.js\";\nimport { ListStatus } from \"~/presentation/components/BottomInfoBar/ListStatus.js\";\nimport {\n BottomInfoBarInner,\n BottomInfoBarWrapper\n} from \"~/presentation/components/BottomInfoBar/BottomInfoBar.styled.js\";\nimport type { ISchedulerListPresenter } from \"../abstractions.js\";\n\ninterface BottomInfoBarProps {\n presenter: ISchedulerListPresenter;\n}\n\nexport const BottomInfoBar = observer(({ presenter }: BottomInfoBarProps) => {\n const { vm } = presenter.list;\n\n return (\n <BottomInfoBarWrapper>\n <BottomInfoBarInner>\n <ListMeta\n loading={vm.pagination.loading}\n totalCount={vm.pagination.totalCount}\n currentCount={vm.pagination.currentCount}\n />\n <ListStatus loading={vm.pagination.loadingMore} />\n </BottomInfoBarInner>\n </BottomInfoBarWrapper>\n );\n});\n"],"names":["BottomInfoBar","observer","presenter","vm","BottomInfoBarWrapper","BottomInfoBarInner","ListMeta","ListStatus"],"mappings":";;;;;AAcO,MAAMA,gBAAgBC,SAAS,CAAC,EAAEC,SAAS,EAAsB;IACpE,MAAM,EAAEC,EAAE,EAAE,GAAGD,UAAU,IAAI;IAE7B,OAAO,WAAP,GACI,oBAACE,sBAAoBA,MAAAA,WAAAA,GACjB,oBAACC,oBAAkBA,MAAAA,WAAAA,GACf,oBAACC,UAAQA;QACL,SAASH,GAAG,UAAU,CAAC,OAAO;QAC9B,YAAYA,GAAG,UAAU,CAAC,UAAU;QACpC,cAAcA,GAAG,UAAU,CAAC,YAAY;sBAE5C,oBAACI,YAAUA;QAAC,SAASJ,GAAG,UAAU,CAAC,WAAW;;AAI9D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ISchedulerListPresenter } from "../abstractions.js";
|
|
3
|
+
interface EmptyProps {
|
|
4
|
+
presenter: ISchedulerListPresenter;
|
|
5
|
+
}
|
|
6
|
+
export declare const Empty: (({ presenter }: EmptyProps) => React.JSX.Element) & React.NamedExoticComponent<EmptyProps> & {
|
|
7
|
+
readonly type: ({ presenter }: EmptyProps) => React.JSX.Element;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { observer } from "mobx-react-lite";
|
|
3
|
+
import { ReactComponent } from "@material-design-icons/svg/outlined/search.svg";
|
|
4
|
+
import { ReactComponent as view_list_svg_ReactComponent } from "@material-design-icons/svg/outlined/view_list.svg";
|
|
5
|
+
import { EmptyView } from "@webiny/app-admin";
|
|
6
|
+
import { EmptyOuter, EmptyWrapper } from "../../components/Empty/Empty.styled.js";
|
|
7
|
+
const Empty = observer(({ presenter })=>{
|
|
8
|
+
const { vm } = presenter.list;
|
|
9
|
+
return /*#__PURE__*/ react.createElement(EmptyWrapper, null, /*#__PURE__*/ react.createElement(EmptyOuter, null, vm.emptyWithFilters ? /*#__PURE__*/ react.createElement(EmptyView, {
|
|
10
|
+
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
11
|
+
title: "No items found.",
|
|
12
|
+
action: null
|
|
13
|
+
}) : /*#__PURE__*/ react.createElement(EmptyView, {
|
|
14
|
+
icon: /*#__PURE__*/ react.createElement(view_list_svg_ReactComponent, null),
|
|
15
|
+
title: "No scheduled items.",
|
|
16
|
+
action: null
|
|
17
|
+
})));
|
|
18
|
+
});
|
|
19
|
+
export { Empty };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=Empty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/schedulerList/components/Empty.js","sources":["../../../../src/presentation/schedulerList/components/Empty.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { ReactComponent as SearchIcon } from \"@material-design-icons/svg/outlined/search.svg\";\nimport { ReactComponent as ListIcon } from \"@material-design-icons/svg/outlined/view_list.svg\";\nimport { EmptyView } from \"@webiny/app-admin\";\nimport { EmptyOuter, EmptyWrapper } from \"~/presentation/components/Empty/Empty.styled.js\";\nimport type { ISchedulerListPresenter } from \"../abstractions.js\";\n\ninterface EmptyProps {\n presenter: ISchedulerListPresenter;\n}\n\nexport const Empty = observer(({ presenter }: EmptyProps) => {\n const { vm } = presenter.list;\n\n return (\n <EmptyWrapper>\n <EmptyOuter>\n {vm.emptyWithFilters ? (\n <EmptyView icon={<SearchIcon />} title={\"No items found.\"} action={null} />\n ) : (\n <EmptyView icon={<ListIcon />} title={`No scheduled items.`} action={null} />\n )}\n </EmptyOuter>\n </EmptyWrapper>\n );\n});\n"],"names":["Empty","observer","presenter","vm","EmptyWrapper","EmptyOuter","EmptyView","SearchIcon","ListIcon"],"mappings":";;;;;;AAYO,MAAMA,QAAQC,SAAS,CAAC,EAAEC,SAAS,EAAc;IACpD,MAAM,EAAEC,EAAE,EAAE,GAAGD,UAAU,IAAI;IAE7B,OAAO,WAAP,GACI,oBAACE,cAAYA,MAAAA,WAAAA,GACT,oBAACC,YAAUA,MACNF,GAAG,gBAAgB,GAAG,WAAH,GAChB,oBAACG,WAASA;QAAC,oBAAM,oBAACC,gBAAUA;QAAK,OAAO;QAAmB,QAAQ;uBAEnE,oBAACD,WAASA;QAAC,oBAAM,oBAACE,8BAAQA;QAAK,OAAO;QAAuB,QAAQ;;AAKzF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import react, { useEffect, useMemo } from "react";
|
|
2
|
+
import { observer } from "mobx-react-lite";
|
|
3
|
+
import { DiContainerProvider, useContainer } from "@webiny/app";
|
|
4
|
+
import { SchedulerListPresenterFeature } from "../feature.js";
|
|
5
|
+
import { useSchedulerListPresenter } from "../useSchedulerListPresenter.js";
|
|
6
|
+
import { ListScheduledActionsFeature } from "../../../features/listScheduledActions/feature.js";
|
|
7
|
+
import { CancelScheduledActionFeature } from "../../../features/cancelScheduledAction/feature.js";
|
|
8
|
+
import { SchedulerOverlay } from "./SchedulerOverlay.js";
|
|
9
|
+
const SchedulerListView_SchedulerListViewInner = observer(function(props) {
|
|
10
|
+
const presenter = useSchedulerListPresenter();
|
|
11
|
+
useEffect(()=>{
|
|
12
|
+
presenter.init({
|
|
13
|
+
namespace: props.namespace
|
|
14
|
+
});
|
|
15
|
+
}, [
|
|
16
|
+
presenter,
|
|
17
|
+
props.namespace
|
|
18
|
+
]);
|
|
19
|
+
return /*#__PURE__*/ react.createElement(SchedulerOverlay, {
|
|
20
|
+
presenter: presenter,
|
|
21
|
+
onExited: props.onClose,
|
|
22
|
+
title: props.title
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
const SchedulerListView = (props)=>{
|
|
26
|
+
const container = useContainer();
|
|
27
|
+
const scopedContainer = useMemo(()=>{
|
|
28
|
+
const child = container.createChildContainer();
|
|
29
|
+
ListScheduledActionsFeature.register(child);
|
|
30
|
+
CancelScheduledActionFeature.register(child);
|
|
31
|
+
SchedulerListPresenterFeature.register(child);
|
|
32
|
+
return child;
|
|
33
|
+
}, []);
|
|
34
|
+
return /*#__PURE__*/ react.createElement(DiContainerProvider, {
|
|
35
|
+
container: scopedContainer
|
|
36
|
+
}, /*#__PURE__*/ react.createElement(SchedulerListView_SchedulerListViewInner, props));
|
|
37
|
+
};
|
|
38
|
+
export { SchedulerListView };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=SchedulerListView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/schedulerList/components/SchedulerListView.js","sources":["../../../../src/presentation/schedulerList/components/SchedulerListView.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer } from \"@webiny/app\";\nimport { SchedulerListPresenterFeature } from \"../feature.js\";\nimport { useSchedulerListPresenter } from \"../useSchedulerListPresenter.js\";\nimport { ListScheduledActionsFeature } from \"~/features/listScheduledActions/feature.js\";\nimport { CancelScheduledActionFeature } from \"~/features/cancelScheduledAction/feature.js\";\nimport { SchedulerOverlay } from \"./SchedulerOverlay.js\";\n\ninterface SchedulerListViewProps {\n namespace: string;\n onClose: () => void;\n title: string;\n}\n\nconst SchedulerListViewInner = observer(function SchedulerListViewInner(\n props: SchedulerListViewProps\n) {\n const presenter = useSchedulerListPresenter();\n\n useEffect(() => {\n presenter.init({ namespace: props.namespace });\n }, [presenter, props.namespace]);\n\n return <SchedulerOverlay presenter={presenter} onExited={props.onClose} title={props.title} />;\n});\n\nexport const SchedulerListView = (props: SchedulerListViewProps) => {\n const container = useContainer();\n\n const scopedContainer = useMemo(() => {\n const child = container.createChildContainer();\n ListScheduledActionsFeature.register(child);\n CancelScheduledActionFeature.register(child);\n SchedulerListPresenterFeature.register(child);\n return child;\n }, []);\n\n return (\n <DiContainerProvider container={scopedContainer}>\n <SchedulerListViewInner {...props} />\n </DiContainerProvider>\n );\n};\n"],"names":["SchedulerListViewInner","observer","props","presenter","useSchedulerListPresenter","useEffect","SchedulerOverlay","SchedulerListView","container","useContainer","scopedContainer","useMemo","child","ListScheduledActionsFeature","CancelScheduledActionFeature","SchedulerListPresenterFeature","DiContainerProvider"],"mappings":";;;;;;;;AAeA,MAAMA,2CAAyBC,SAAS,SACpCC,KAA6B;IAE7B,MAAMC,YAAYC;IAElBC,UAAU;QACNF,UAAU,IAAI,CAAC;YAAE,WAAWD,MAAM,SAAS;QAAC;IAChD,GAAG;QAACC;QAAWD,MAAM,SAAS;KAAC;IAE/B,OAAO,WAAP,GAAO,oBAACI,kBAAgBA;QAAC,WAAWH;QAAW,UAAUD,MAAM,OAAO;QAAE,OAAOA,MAAM,KAAK;;AAC9F;AAEO,MAAMK,oBAAoB,CAACL;IAC9B,MAAMM,YAAYC;IAElB,MAAMC,kBAAkBC,QAAQ;QAC5B,MAAMC,QAAQJ,UAAU,oBAAoB;QAC5CK,4BAA4B,QAAQ,CAACD;QACrCE,6BAA6B,QAAQ,CAACF;QACtCG,8BAA8B,QAAQ,CAACH;QACvC,OAAOA;IACX,GAAG,EAAE;IAEL,OAAO,WAAP,GACI,oBAACI,qBAAmBA;QAAC,WAAWN;qBAC5B,oBAACV,0CAA2BE;AAGxC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ISchedulerListPresenter } from "../abstractions.js";
|
|
3
|
+
interface SchedulerOverlayProps {
|
|
4
|
+
presenter: ISchedulerListPresenter;
|
|
5
|
+
title: string;
|
|
6
|
+
onExited: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const SchedulerOverlay: (({ presenter, title, onExited }: SchedulerOverlayProps) => React.JSX.Element) & React.NamedExoticComponent<SchedulerOverlayProps> & {
|
|
9
|
+
readonly type: ({ presenter, title, onExited }: SchedulerOverlayProps) => React.JSX.Element;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { observer } from "mobx-react-lite";
|
|
3
|
+
import debounce from "lodash/debounce.js";
|
|
4
|
+
import { OverlayLayout } from "@webiny/app-admin";
|
|
5
|
+
import { Scrollbar } from "@webiny/admin-ui";
|
|
6
|
+
import { Title } from "../../components/Title/index.js";
|
|
7
|
+
import { SearchInput } from "./SearchInput.js";
|
|
8
|
+
import { Empty } from "./Empty.js";
|
|
9
|
+
import { SchedulerTable } from "./SchedulerTable.js";
|
|
10
|
+
import { BottomInfoBar } from "./BottomInfoBar.js";
|
|
11
|
+
const SchedulerOverlay = observer(({ presenter, title, onExited })=>{
|
|
12
|
+
const { vm } = presenter.list;
|
|
13
|
+
const onTableScroll = debounce(async ({ scrollFrame })=>{
|
|
14
|
+
if (scrollFrame.top > 0.8) await presenter.list.actions.loadMore();
|
|
15
|
+
}, 200);
|
|
16
|
+
return /*#__PURE__*/ react.createElement(OverlayLayout, {
|
|
17
|
+
onExited: onExited,
|
|
18
|
+
barLeft: /*#__PURE__*/ react.createElement(Title, {
|
|
19
|
+
title: title
|
|
20
|
+
}),
|
|
21
|
+
barMiddle: /*#__PURE__*/ react.createElement(SearchInput, {
|
|
22
|
+
presenter: presenter
|
|
23
|
+
})
|
|
24
|
+
}, /*#__PURE__*/ react.createElement(Scrollbar, {
|
|
25
|
+
onScrollFrame: (scrollFrame)=>onTableScroll({
|
|
26
|
+
scrollFrame
|
|
27
|
+
})
|
|
28
|
+
}, vm.empty ? /*#__PURE__*/ react.createElement(Empty, {
|
|
29
|
+
presenter: presenter
|
|
30
|
+
}) : /*#__PURE__*/ react.createElement(SchedulerTable, {
|
|
31
|
+
presenter: presenter
|
|
32
|
+
})), /*#__PURE__*/ react.createElement(BottomInfoBar, {
|
|
33
|
+
presenter: presenter
|
|
34
|
+
}));
|
|
35
|
+
});
|
|
36
|
+
export { SchedulerOverlay };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=SchedulerOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/schedulerList/components/SchedulerOverlay.js","sources":["../../../../src/presentation/schedulerList/components/SchedulerOverlay.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\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 \"./SearchInput.js\";\nimport { Empty } from \"./Empty.js\";\nimport { SchedulerTable } from \"./SchedulerTable.js\";\nimport { BottomInfoBar } from \"./BottomInfoBar.js\";\nimport type { ISchedulerListPresenter } from \"../abstractions.js\";\n\ninterface SchedulerOverlayProps {\n presenter: ISchedulerListPresenter;\n title: string;\n onExited: () => void;\n}\n\nexport const SchedulerOverlay = observer(\n ({ presenter, title, onExited }: SchedulerOverlayProps) => {\n const { vm } = presenter.list;\n\n const onTableScroll = debounce(async ({ scrollFrame }) => {\n if (scrollFrame.top > 0.8) {\n await presenter.list.actions.loadMore();\n }\n }, 200);\n\n return (\n <OverlayLayout\n onExited={onExited}\n barLeft={<Title title={title} />}\n barMiddle={<SearchInput presenter={presenter} />}\n >\n <Scrollbar onScrollFrame={scrollFrame => onTableScroll({ scrollFrame })}>\n {vm.empty ? (\n <Empty presenter={presenter} />\n ) : (\n <SchedulerTable presenter={presenter} />\n )}\n </Scrollbar>\n <BottomInfoBar presenter={presenter} />\n </OverlayLayout>\n );\n }\n);\n"],"names":["SchedulerOverlay","observer","presenter","title","onExited","vm","onTableScroll","debounce","scrollFrame","OverlayLayout","Title","SearchInput","Scrollbar","Empty","SchedulerTable","BottomInfoBar"],"mappings":";;;;;;;;;;AAkBO,MAAMA,mBAAmBC,SAC5B,CAAC,EAAEC,SAAS,EAAEC,KAAK,EAAEC,QAAQ,EAAyB;IAClD,MAAM,EAAEC,EAAE,EAAE,GAAGH,UAAU,IAAI;IAE7B,MAAMI,gBAAgBC,SAAS,OAAO,EAAEC,WAAW,EAAE;QACjD,IAAIA,YAAY,GAAG,GAAG,KAClB,MAAMN,UAAU,IAAI,CAAC,OAAO,CAAC,QAAQ;IAE7C,GAAG;IAEH,OAAO,WAAP,GACI,oBAACO,eAAaA;QACV,UAAUL;QACV,uBAAS,oBAACM,OAAKA;YAAC,OAAOP;;QACvB,yBAAW,oBAACQ,aAAWA;YAAC,WAAWT;;qBAEnC,oBAACU,WAASA;QAAC,eAAeJ,CAAAA,cAAeF,cAAc;gBAAEE;YAAY;OAChEH,GAAG,KAAK,GAAG,WAAH,GACL,oBAACQ,OAAKA;QAAC,WAAWX;uBAElB,oBAACY,gBAAcA;QAAC,WAAWZ;uBAGnC,oBAACa,eAAaA;QAAC,WAAWb;;AAGtC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ISchedulerListPresenter } from "../abstractions.js";
|
|
3
|
+
interface SchedulerTableProps {
|
|
4
|
+
presenter: ISchedulerListPresenter;
|
|
5
|
+
}
|
|
6
|
+
export declare const SchedulerTable: (({ presenter }: SchedulerTableProps) => React.JSX.Element) & React.NamedExoticComponent<SchedulerTableProps> & {
|
|
7
|
+
readonly type: ({ presenter }: SchedulerTableProps) => React.JSX.Element;
|
|
8
|
+
};
|
|
9
|
+
export {};
|