@webiny/app-scheduler 6.5.0-beta.1 → 6.5.0-beta.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-scheduler",
3
- "version": "6.5.0-beta.1",
3
+ "version": "6.5.0-beta.10",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -16,30 +16,32 @@
16
16
  "@emotion/react": "11.14.0",
17
17
  "@emotion/styled": "11.14.1",
18
18
  "@material-design-icons/svg": "0.14.15",
19
- "@webiny/admin-ui": "6.5.0-beta.1",
20
- "@webiny/app": "6.5.0-beta.1",
21
- "@webiny/app-aco": "6.5.0-beta.1",
22
- "@webiny/app-admin": "6.5.0-beta.1",
23
- "@webiny/app-headless-cms-common": "6.5.0-beta.1",
24
- "@webiny/feature": "6.5.0-beta.1",
25
- "@webiny/form": "6.5.0-beta.1",
26
- "@webiny/icons": "6.5.0-beta.1",
27
- "@webiny/react-composition": "6.5.0-beta.1",
28
- "@webiny/react-properties": "6.5.0-beta.1",
29
- "@webiny/utils": "6.5.0-beta.1",
30
- "@webiny/validation": "6.5.0-beta.1",
19
+ "@webiny/admin-ui": "6.5.0-beta.10",
20
+ "@webiny/app": "6.5.0-beta.10",
21
+ "@webiny/app-aco": "6.5.0-beta.10",
22
+ "@webiny/app-admin": "6.5.0-beta.10",
23
+ "@webiny/app-headless-cms-common": "6.5.0-beta.10",
24
+ "@webiny/feature": "6.5.0-beta.10",
25
+ "@webiny/form": "6.5.0-beta.10",
26
+ "@webiny/icons": "6.5.0-beta.10",
27
+ "@webiny/react-composition": "6.5.0-beta.10",
28
+ "@webiny/react-properties": "6.5.0-beta.10",
29
+ "@webiny/utils": "6.5.0-beta.10",
30
+ "@webiny/validation": "6.5.0-beta.10",
31
31
  "lodash": "4.18.1",
32
- "mobx": "6.16.1",
33
- "mobx-react-lite": "4.1.1",
32
+ "mobx": "7.0.6",
33
+ "mobx-react-lite": "5.1.0",
34
34
  "react": "18.3.1",
35
35
  "react-dom": "18.3.1",
36
- "zod": "4.4.3"
36
+ "zod": "4.6.5"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/react": "18.3.31",
40
- "@webiny/build-tools": "6.5.0-beta.1",
40
+ "@webiny/build-tools": "6.5.0-beta.10",
41
+ "@webiny/di": "1.1.0",
41
42
  "rimraf": "6.1.3",
42
- "typescript": "7.0.2"
43
+ "typescript": "7.0.2",
44
+ "vitest": "5.0.3"
43
45
  },
44
46
  "publishConfig": {
45
47
  "access": "public"
@@ -1 +1 @@
1
- {"version":3,"file":"presentation/hooks/useCancelSchedulerItem.js","sources":["../../../src/presentation/hooks/useCancelSchedulerItem.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { useConfirmationDialog } from \"@webiny/app-admin\";\nimport type { SchedulerEntry } from \"~/types.js\";\nimport { useSchedulerListPresenter } from \"~/presentation/schedulerList/useSchedulerListPresenter.js\";\nimport { useToast } from \"@webiny/admin-ui\";\n\ninterface UseCancelScheduleItemParams {\n item: Pick<SchedulerEntry, \"id\" | \"title\" | \"actionType\">;\n}\n\nexport const useCancelSchedulerItem = ({ item }: UseCancelScheduleItemParams) => {\n const presenter = useSchedulerListPresenter();\n const toast = useToast();\n\n const { showConfirmation } = useConfirmationDialog({\n title: \"Cancel scheduled action?\",\n message: (\n <p>\n You are about to cancel scheduled action for this item!\n <br />\n Are you sure you want to cancel scheduled <strong>{item.actionType}</strong> for{\" \"}\n <strong>{item.title}</strong>?\n </p>\n )\n });\n\n const openDialogCancelSchedulerItem = useCallback(\n () =>\n showConfirmation(async () => {\n try {\n await presenter.cancelItem(item.id);\n toast.showSuccessToast({\n title: `Action on item \"${item.title}\" was canceled successfully!`\n });\n } catch (ex) {\n toast.showWarningToast({\n title: ex.message || `Error while canceling action for \"${item.title}\".`\n });\n }\n }),\n [item]\n );\n\n return { openDialogCancelSchedulerItem };\n};\n"],"names":["useCancelSchedulerItem","item","presenter","useSchedulerListPresenter","toast","useToast","showConfirmation","useConfirmationDialog","openDialogCancelSchedulerItem","useCallback","ex"],"mappings":";;;;AAUO,MAAMA,yBAAyB,CAAC,EAAEC,IAAI,EAA+B;IACxE,MAAMC,YAAYC;IAClB,MAAMC,QAAQC;IAEd,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,sBAAsB;QAC/C,OAAO;QACP,SAAS,WAAT,GACI,oBAAC,WAAE,yEAEC,oBAAC,aAAK,4DACoC,oBAAC,gBAAQN,KAAK,UAAU,GAAU,QAAK,mBACjF,oBAAC,gBAAQA,KAAK,KAAK,GAAU;IAGzC;IAEA,MAAMO,gCAAgCC,YAClC,IACIH,iBAAiB;YACb,IAAI;gBACA,MAAMJ,UAAU,UAAU,CAACD,KAAK,EAAE;gBAClCG,MAAM,gBAAgB,CAAC;oBACnB,OAAO,CAAC,gBAAgB,EAAEH,KAAK,KAAK,CAAC,4BAA4B,CAAC;gBACtE;YACJ,EAAE,OAAOS,IAAI;gBACTN,MAAM,gBAAgB,CAAC;oBACnB,OAAOM,GAAG,OAAO,IAAI,CAAC,kCAAkC,EAAET,KAAK,KAAK,CAAC,EAAE,CAAC;gBAC5E;YACJ;QACJ,IACJ;QAACA;KAAK;IAGV,OAAO;QAAEO;IAA8B;AAC3C"}
1
+ {"version":3,"file":"presentation/hooks/useCancelSchedulerItem.js","sources":["../../../src/presentation/hooks/useCancelSchedulerItem.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { useConfirmationDialog } from \"@webiny/app-admin\";\nimport type { SchedulerEntry } from \"~/types.js\";\nimport { useSchedulerListPresenter } from \"~/presentation/schedulerList/useSchedulerListPresenter.js\";\nimport { useToast } from \"@webiny/admin-ui\";\n\ninterface UseCancelScheduleItemParams {\n item: Pick<SchedulerEntry, \"id\" | \"title\" | \"actionType\">;\n}\n\nexport const useCancelSchedulerItem = ({ item }: UseCancelScheduleItemParams) => {\n const presenter = useSchedulerListPresenter();\n const toast = useToast();\n\n const { showConfirmation } = useConfirmationDialog({\n title: \"Cancel scheduled action?\",\n message: (\n <p>\n You are about to cancel scheduled action for this item!\n <br />\n Are you sure you want to cancel scheduled <strong>\n {item.actionType}\n </strong> for{\" \"}\n <strong>{item.title}</strong>?\n </p>\n )\n });\n\n const openDialogCancelSchedulerItem = useCallback(\n () =>\n showConfirmation(async () => {\n try {\n await presenter.cancelItem(item.id);\n toast.showSuccessToast({\n title: `Action on item \"${item.title}\" was canceled successfully!`\n });\n } catch (ex) {\n toast.showWarningToast({\n title: ex.message || `Error while canceling action for \"${item.title}\".`\n });\n }\n }),\n [item]\n );\n\n return { openDialogCancelSchedulerItem };\n};\n"],"names":["useCancelSchedulerItem","item","presenter","useSchedulerListPresenter","toast","useToast","showConfirmation","useConfirmationDialog","openDialogCancelSchedulerItem","useCallback","ex"],"mappings":";;;;AAUO,MAAMA,yBAAyB,CAAC,EAAEC,IAAI,EAA+B;IACxE,MAAMC,YAAYC;IAClB,MAAMC,QAAQC;IAEd,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,sBAAsB;QAC/C,OAAO;QACP,SAAS,WAAT,GACI,oBAAC,WAAE,yEAEC,oBAAC,aAAK,4DACoC,oBAAC,gBACtCN,KAAK,UAAU,GACX,QAAK,mBACd,oBAAC,gBAAQA,KAAK,KAAK,GAAU;IAGzC;IAEA,MAAMO,gCAAgCC,YAClC,IACIH,iBAAiB;YACb,IAAI;gBACA,MAAMJ,UAAU,UAAU,CAACD,KAAK,EAAE;gBAClCG,MAAM,gBAAgB,CAAC;oBACnB,OAAO,CAAC,gBAAgB,EAAEH,KAAK,KAAK,CAAC,4BAA4B,CAAC;gBACtE;YACJ,EAAE,OAAOS,IAAI;gBACTN,MAAM,gBAAgB,CAAC;oBACnB,OAAOM,GAAG,OAAO,IAAI,CAAC,kCAAkC,EAAET,KAAK,KAAK,CAAC,EAAE,CAAC;gBAC5E;YACJ;QACJ,IACJ;QAACA;KAAK;IAGV,OAAO;QAAEO;IAA8B;AAC3C"}
@@ -75,10 +75,11 @@ class ScheduleDialogPresenterImpl {
75
75
  this.entry = null;
76
76
  this.loading = false;
77
77
  });
78
- } catch {
78
+ } catch (error) {
79
79
  runInAction(()=>{
80
80
  this.loading = false;
81
81
  });
82
+ throw error;
82
83
  }
83
84
  }
84
85
  async cancel(params) {
@@ -89,10 +90,11 @@ class ScheduleDialogPresenterImpl {
89
90
  this.entry = null;
90
91
  this.loading = false;
91
92
  });
92
- } catch {
93
+ } catch (error) {
93
94
  runInAction(()=>{
94
95
  this.loading = false;
95
96
  });
97
+ throw error;
96
98
  }
97
99
  }
98
100
  reset() {
@@ -1 +1 @@
1
- {"version":3,"file":"presentation/scheduleDialog/ScheduleDialogPresenter.js","sources":["../../../src/presentation/scheduleDialog/ScheduleDialogPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport { GetScheduledActionGateway } from \"~/features/getScheduledAction/abstractions.js\";\nimport { CancelScheduledActionGateway } from \"~/features/cancelScheduledAction/abstractions.js\";\nimport { SchedulePublishActionGateway } from \"~/features/schedulePublishAction/abstractions.js\";\nimport { ScheduleUnpublishActionGateway } from \"~/features/scheduleUnpublishAction/abstractions.js\";\nimport { ScheduleActionType } from \"~/types.js\";\nimport type { SchedulerEntry } from \"~/types.js\";\nimport { DateFormatter } from \"@webiny/app-admin\";\nimport { formatUtcOffset } from \"@webiny/app-admin\";\nimport {\n ScheduleDialogPresenter as Abstraction,\n type IScheduleDialogPresenter,\n type IScheduleDialogPresenterViewModel,\n type IScheduleDialogRescheduling,\n type IScheduleDialogPresenterLoadParams,\n type IScheduleDialogPresenterScheduleParams,\n type IScheduleDialogPresenterCancelParams\n} from \"./abstractions.js\";\n\nclass ScheduleDialogPresenterImpl implements IScheduleDialogPresenter {\n private loading = false;\n private entry: SchedulerEntry | null = null;\n\n constructor(\n private readonly getGateway: GetScheduledActionGateway.Interface,\n private readonly cancelGateway: CancelScheduledActionGateway.Interface,\n private readonly publishGateway: SchedulePublishActionGateway.Interface,\n private readonly unpublishGateway: ScheduleUnpublishActionGateway.Interface,\n private readonly dateFormatter: DateFormatter.Interface\n ) {\n makeAutoObservable(this);\n }\n\n get vm(): IScheduleDialogPresenterViewModel {\n return {\n loading: this.loading,\n entry: this.entry,\n rescheduling: this.getRescheduling()\n };\n }\n\n private getRescheduling(): IScheduleDialogRescheduling | null {\n const entry = this.entry;\n if (!entry) {\n return null;\n }\n const scheduleOn = entry.publishOn || entry.unpublishOn;\n if (!scheduleOn) {\n return null;\n }\n const actionName =\n entry.actionType === ScheduleActionType.publish ? \"publish\" : \"unpublish\";\n return {\n actionName,\n scheduleOn: `${this.dateFormatter.format(scheduleOn)} (${formatUtcOffset()})`\n };\n }\n\n async load(params: IScheduleDialogPresenterLoadParams): Promise<void> {\n this.loading = true;\n\n try {\n const entry = await this.getGateway.execute(params);\n runInAction(() => {\n this.entry = entry;\n this.loading = false;\n });\n } catch {\n runInAction(() => {\n this.loading = false;\n });\n }\n }\n\n async schedule(params: IScheduleDialogPresenterScheduleParams): Promise<void> {\n const { targetId, namespace, scheduleOn, actionType } = params;\n this.loading = true;\n\n try {\n switch (actionType) {\n case ScheduleActionType.publish:\n await this.publishGateway.execute({ namespace, targetId, scheduleOn });\n break;\n case ScheduleActionType.unpublish:\n await this.unpublishGateway.execute({ namespace, targetId, scheduleOn });\n break;\n default:\n throw new Error(`Unsupported action type \"${actionType}\".`);\n }\n runInAction(() => {\n this.entry = null;\n this.loading = false;\n });\n } catch {\n runInAction(() => {\n this.loading = false;\n });\n }\n }\n\n async cancel(params: IScheduleDialogPresenterCancelParams): Promise<void> {\n this.loading = true;\n\n try {\n await this.cancelGateway.execute(params);\n runInAction(() => {\n this.entry = null;\n this.loading = false;\n });\n } catch {\n runInAction(() => {\n this.loading = false;\n });\n }\n }\n\n reset(): void {\n this.entry = null;\n this.loading = false;\n }\n}\n\nexport const ScheduleDialogPresenter = Abstraction.createImplementation({\n implementation: ScheduleDialogPresenterImpl,\n dependencies: [\n GetScheduledActionGateway,\n CancelScheduledActionGateway,\n SchedulePublishActionGateway,\n ScheduleUnpublishActionGateway,\n DateFormatter\n ]\n});\n"],"names":["ScheduleDialogPresenterImpl","getGateway","cancelGateway","publishGateway","unpublishGateway","dateFormatter","makeAutoObservable","entry","scheduleOn","actionName","ScheduleActionType","formatUtcOffset","params","runInAction","targetId","namespace","actionType","Error","ScheduleDialogPresenter","Abstraction","GetScheduledActionGateway","CancelScheduledActionGateway","SchedulePublishActionGateway","ScheduleUnpublishActionGateway","DateFormatter"],"mappings":";;;;;;;;AAmBA,MAAMA;IAIF,YACqBC,UAA+C,EAC/CC,aAAqD,EACrDC,cAAsD,EACtDC,gBAA0D,EAC1DC,aAAsC,CACzD;aALmBJ,UAAU,GAAVA;aACAC,aAAa,GAAbA;aACAC,cAAc,GAAdA;aACAC,gBAAgB,GAAhBA;aACAC,aAAa,GAAbA;aARb,OAAO,GAAG;aACV,KAAK,GAA0B;QASnCC,mBAAmB,IAAI;IAC3B;IAEA,IAAI,KAAwC;QACxC,OAAO;YACH,SAAS,IAAI,CAAC,OAAO;YACrB,OAAO,IAAI,CAAC,KAAK;YACjB,cAAc,IAAI,CAAC,eAAe;QACtC;IACJ;IAEQ,kBAAsD;QAC1D,MAAMC,QAAQ,IAAI,CAAC,KAAK;QACxB,IAAI,CAACA,OACD,OAAO;QAEX,MAAMC,aAAaD,MAAM,SAAS,IAAIA,MAAM,WAAW;QACvD,IAAI,CAACC,YACD,OAAO;QAEX,MAAMC,aACFF,MAAM,UAAU,KAAKG,mBAAmB,OAAO,GAAG,YAAY;QAClE,OAAO;YACHD;YACA,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAACD,YAAY,EAAE,EAAEG,kBAAkB,CAAC,CAAC;QACjF;IACJ;IAEA,MAAM,KAAKC,MAA0C,EAAiB;QAClE,IAAI,CAAC,OAAO,GAAG;QAEf,IAAI;YACA,MAAML,QAAQ,MAAM,IAAI,CAAC,UAAU,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pE,gBAAgBnB;IAChB,cAAc;QACVoB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"presentation/scheduleDialog/ScheduleDialogPresenter.js","sources":["../../../src/presentation/scheduleDialog/ScheduleDialogPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport { GetScheduledActionGateway } from \"~/features/getScheduledAction/abstractions.js\";\nimport { CancelScheduledActionGateway } from \"~/features/cancelScheduledAction/abstractions.js\";\nimport { SchedulePublishActionGateway } from \"~/features/schedulePublishAction/abstractions.js\";\nimport { ScheduleUnpublishActionGateway } from \"~/features/scheduleUnpublishAction/abstractions.js\";\nimport { ScheduleActionType } from \"~/types.js\";\nimport type { SchedulerEntry } from \"~/types.js\";\nimport { DateFormatter } from \"@webiny/app-admin\";\nimport { formatUtcOffset } from \"@webiny/app-admin\";\nimport {\n ScheduleDialogPresenter as Abstraction,\n type IScheduleDialogPresenter,\n type IScheduleDialogPresenterViewModel,\n type IScheduleDialogRescheduling,\n type IScheduleDialogPresenterLoadParams,\n type IScheduleDialogPresenterScheduleParams,\n type IScheduleDialogPresenterCancelParams\n} from \"./abstractions.js\";\n\nclass ScheduleDialogPresenterImpl implements IScheduleDialogPresenter {\n private loading = false;\n private entry: SchedulerEntry | null = null;\n\n constructor(\n private readonly getGateway: GetScheduledActionGateway.Interface,\n private readonly cancelGateway: CancelScheduledActionGateway.Interface,\n private readonly publishGateway: SchedulePublishActionGateway.Interface,\n private readonly unpublishGateway: ScheduleUnpublishActionGateway.Interface,\n private readonly dateFormatter: DateFormatter.Interface\n ) {\n makeAutoObservable(this);\n }\n\n get vm(): IScheduleDialogPresenterViewModel {\n return {\n loading: this.loading,\n entry: this.entry,\n rescheduling: this.getRescheduling()\n };\n }\n\n private getRescheduling(): IScheduleDialogRescheduling | null {\n const entry = this.entry;\n if (!entry) {\n return null;\n }\n const scheduleOn = entry.publishOn || entry.unpublishOn;\n if (!scheduleOn) {\n return null;\n }\n const actionName =\n entry.actionType === ScheduleActionType.publish ? \"publish\" : \"unpublish\";\n return {\n actionName,\n scheduleOn: `${this.dateFormatter.format(scheduleOn)} (${formatUtcOffset()})`\n };\n }\n\n async load(params: IScheduleDialogPresenterLoadParams): Promise<void> {\n this.loading = true;\n\n try {\n const entry = await this.getGateway.execute(params);\n runInAction(() => {\n this.entry = entry;\n this.loading = false;\n });\n } catch {\n runInAction(() => {\n this.loading = false;\n });\n }\n }\n\n async schedule(params: IScheduleDialogPresenterScheduleParams): Promise<void> {\n const { targetId, namespace, scheduleOn, actionType } = params;\n this.loading = true;\n\n try {\n switch (actionType) {\n case ScheduleActionType.publish:\n await this.publishGateway.execute({ namespace, targetId, scheduleOn });\n break;\n case ScheduleActionType.unpublish:\n await this.unpublishGateway.execute({ namespace, targetId, scheduleOn });\n break;\n default:\n throw new Error(`Unsupported action type \"${actionType}\".`);\n }\n runInAction(() => {\n this.entry = null;\n this.loading = false;\n });\n } catch (error) {\n runInAction(() => {\n this.loading = false;\n });\n // The caller shows a success toast and runs `onCompleted` when this resolves.\n throw error;\n }\n }\n\n async cancel(params: IScheduleDialogPresenterCancelParams): Promise<void> {\n this.loading = true;\n\n try {\n await this.cancelGateway.execute(params);\n runInAction(() => {\n this.entry = null;\n this.loading = false;\n });\n } catch (error) {\n runInAction(() => {\n this.loading = false;\n });\n throw error;\n }\n }\n\n reset(): void {\n this.entry = null;\n this.loading = false;\n }\n}\n\nexport const ScheduleDialogPresenter = Abstraction.createImplementation({\n implementation: ScheduleDialogPresenterImpl,\n dependencies: [\n GetScheduledActionGateway,\n CancelScheduledActionGateway,\n SchedulePublishActionGateway,\n ScheduleUnpublishActionGateway,\n DateFormatter\n ]\n});\n"],"names":["ScheduleDialogPresenterImpl","getGateway","cancelGateway","publishGateway","unpublishGateway","dateFormatter","makeAutoObservable","entry","scheduleOn","actionName","ScheduleActionType","formatUtcOffset","params","runInAction","targetId","namespace","actionType","Error","error","ScheduleDialogPresenter","Abstraction","GetScheduledActionGateway","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GAAGJ;QACxD,IAAI,CAAC,OAAO,GAAG;QAEf,IAAI;YACA,OAAQI;gBACJ,KAAKN,mBAAmB,OAAO;oBAC3B,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;wBAAEK;wBAAWD;wBAAUN;oBAAW;oBACpE;gBACJ,KAAKE,mBAAmB,SAAS;oBAC7B,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;wBAAEK;wBAAWD;wBAAUN;oBAAW;oBACtE;gBACJ;oBACI,MAAM,IAAIS,MAAM,CAAC,yBAAyB,EAAED,WAAW,EAAE,CAAC;YAClE;YACAH,YAAY;gBACR,IAAI,CAAC,KAAK,GAAG;gBACb,IAAI,CAAC,OAAO,GAAG;YACnB;QACJ,EAAE,OAAOK,OAAO;YACZL,YAAY;gBACR,IAAI,CAAC,OAAO,GAAG;YACnB;YAEA,MAAMK;QACV;IACJ;IAEA,MAAM,OAAON,MAA4C,EAAiB;QACtE,IAAI,CAAC,OAAO,GAAG;QAEf,IAAI;YACA,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAACA;YACjCC,YAAY;gBACR,IAAI,CAAC,KAAK,GAAG;gBACb,IAAI,CAAC,OAAO,GAAG;YACnB;QACJ,EAAE,OAAOK,OAAO;YACZL,YAAY;gBACR,IAAI,CAAC,OAAO,GAAG;YACnB;YACA,MAAMK;QACV;IACJ;IAEA,QAAc;QACV,IAAI,CAAC,KAAK,GAAG;QACb,IAAI,CAAC,OAAO,GAAG;IACnB;AACJ;AAEO,MAAMC,kDAA0BC,wBAAAA,oBAAgC,CAAC;IACpE,gBAAgBpB;IAChB,cAAc;QACVqB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -0,0 +1,77 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { Container } from "@webiny/di";
3
+ import { DateFormatter } from "@webiny/app-admin";
4
+ import { GetScheduledActionGateway } from "../../features/getScheduledAction/abstractions.js";
5
+ import { CancelScheduledActionGateway } from "../../features/cancelScheduledAction/abstractions.js";
6
+ import { SchedulePublishActionGateway } from "../../features/schedulePublishAction/abstractions.js";
7
+ import { ScheduleUnpublishActionGateway } from "../../features/scheduleUnpublishAction/abstractions.js";
8
+ import { ScheduleActionType } from "../../types.js";
9
+ import { ScheduleDialogPresenter } from "./abstractions.js";
10
+ import { ScheduleDialogPresenter as external_ScheduleDialogPresenter_js_ScheduleDialogPresenter } from "./ScheduleDialogPresenter.js";
11
+ const setup = (params)=>{
12
+ const execute = vi.fn(async ()=>{
13
+ if (params.fail) throw new Error("Could not schedule the action.");
14
+ return {
15
+ item: {}
16
+ };
17
+ });
18
+ const container = new Container();
19
+ container.registerInstance(GetScheduledActionGateway, {
20
+ execute: vi.fn()
21
+ });
22
+ container.registerInstance(CancelScheduledActionGateway, {
23
+ execute
24
+ });
25
+ container.registerInstance(SchedulePublishActionGateway, {
26
+ execute
27
+ });
28
+ container.registerInstance(ScheduleUnpublishActionGateway, {
29
+ execute
30
+ });
31
+ container.registerInstance(DateFormatter, {
32
+ format: ()=>""
33
+ });
34
+ container.register(external_ScheduleDialogPresenter_js_ScheduleDialogPresenter);
35
+ return container.resolve(ScheduleDialogPresenter);
36
+ };
37
+ const scheduleParams = (actionType)=>({
38
+ namespace: "cms/article",
39
+ targetId: "entry-1#0001",
40
+ scheduleOn: new Date("2030-01-01T10:00:00.000Z"),
41
+ actionType
42
+ });
43
+ describe("ScheduleDialogPresenter", ()=>{
44
+ it.each([
45
+ ScheduleActionType.publish,
46
+ ScheduleActionType.unpublish
47
+ ])("rejects when scheduling %s fails", async (actionType)=>{
48
+ const presenter = setup({
49
+ fail: true
50
+ });
51
+ await expect(presenter.schedule(scheduleParams(actionType))).rejects.toThrow("Could not schedule the action.");
52
+ expect(presenter.vm.loading).toBe(false);
53
+ });
54
+ it("rejects when cancelling fails", async ()=>{
55
+ const presenter = setup({
56
+ fail: true
57
+ });
58
+ await expect(presenter.cancel({
59
+ id: "action-1",
60
+ namespace: "cms/article"
61
+ })).rejects.toThrow("Could not schedule the action.");
62
+ expect(presenter.vm.loading).toBe(false);
63
+ });
64
+ it("resolves when scheduling and cancelling succeed", async ()=>{
65
+ const presenter = setup({
66
+ fail: false
67
+ });
68
+ await expect(presenter.schedule(scheduleParams(ScheduleActionType.publish))).resolves.toBeUndefined();
69
+ await expect(presenter.cancel({
70
+ id: "action-1",
71
+ namespace: "cms/article"
72
+ })).resolves.toBeUndefined();
73
+ expect(presenter.vm.loading).toBe(false);
74
+ });
75
+ });
76
+
77
+ //# sourceMappingURL=ScheduleDialogPresenter.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presentation/scheduleDialog/ScheduleDialogPresenter.test.js","sources":["../../../src/presentation/scheduleDialog/ScheduleDialogPresenter.test.ts"],"sourcesContent":["// @vitest-environment jsdom\nimport { describe, it, expect, vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { DateFormatter } from \"@webiny/app-admin\";\nimport { GetScheduledActionGateway } from \"~/features/getScheduledAction/abstractions.js\";\nimport { CancelScheduledActionGateway } from \"~/features/cancelScheduledAction/abstractions.js\";\nimport { SchedulePublishActionGateway } from \"~/features/schedulePublishAction/abstractions.js\";\nimport { ScheduleUnpublishActionGateway } from \"~/features/scheduleUnpublishAction/abstractions.js\";\nimport { ScheduleActionType } from \"~/types.js\";\nimport { ScheduleDialogPresenter as Abstraction } from \"./abstractions.js\";\nimport { ScheduleDialogPresenter } from \"./ScheduleDialogPresenter.js\";\n\n/*\n * `useScheduleDialog` shows a success toast and runs `onCompleted` once `schedule()` or\n * `cancel()` resolves, and shows the error when they reject. So a failed action must reject,\n * and the dialog must not be left loading.\n */\nconst setup = (params: { fail: boolean }) => {\n const execute = vi.fn(async () => {\n if (params.fail) {\n throw new Error(\"Could not schedule the action.\");\n }\n return { item: {} };\n });\n\n const container = new Container();\n container.registerInstance(GetScheduledActionGateway, { execute: vi.fn() } as any);\n container.registerInstance(CancelScheduledActionGateway, { execute } as any);\n container.registerInstance(SchedulePublishActionGateway, { execute } as any);\n container.registerInstance(ScheduleUnpublishActionGateway, { execute } as any);\n container.registerInstance(DateFormatter, { format: () => \"\" } as any);\n container.register(ScheduleDialogPresenter);\n\n return container.resolve(Abstraction);\n};\n\nconst scheduleParams = (actionType: ScheduleActionType) => ({\n namespace: \"cms/article\",\n targetId: \"entry-1#0001\",\n scheduleOn: new Date(\"2030-01-01T10:00:00.000Z\"),\n actionType\n});\n\ndescribe(\"ScheduleDialogPresenter\", () => {\n it.each([ScheduleActionType.publish, ScheduleActionType.unpublish])(\n \"rejects when scheduling %s fails\",\n async actionType => {\n const presenter = setup({ fail: true });\n\n await expect(presenter.schedule(scheduleParams(actionType))).rejects.toThrow(\n \"Could not schedule the action.\"\n );\n expect(presenter.vm.loading).toBe(false);\n }\n );\n\n it(\"rejects when cancelling fails\", async () => {\n const presenter = setup({ fail: true });\n\n await expect(\n presenter.cancel({ id: \"action-1\", namespace: \"cms/article\" })\n ).rejects.toThrow(\"Could not schedule the action.\");\n expect(presenter.vm.loading).toBe(false);\n });\n\n it(\"resolves when scheduling and cancelling succeed\", async () => {\n const presenter = setup({ fail: false });\n\n await expect(\n presenter.schedule(scheduleParams(ScheduleActionType.publish))\n ).resolves.toBeUndefined();\n await expect(\n presenter.cancel({ id: \"action-1\", namespace: \"cms/article\" })\n ).resolves.toBeUndefined();\n expect(presenter.vm.loading).toBe(false);\n });\n});\n"],"names":["setup","params","execute","vi","Error","container","Container","GetScheduledActionGateway","CancelScheduledActionGateway","SchedulePublishActionGateway","ScheduleUnpublishActionGateway","DateFormatter","ScheduleDialogPresenter","Abstraction","scheduleParams","actionType","Date","describe","it","ScheduleActionType","presenter","expect"],"mappings":";;;;;;;;;;AAiBA,MAAMA,QAAQ,CAACC;IACX,MAAMC,UAAUC,GAAG,EAAE,CAAC;QAClB,IAAIF,OAAO,IAAI,EACX,MAAM,IAAIG,MAAM;QAEpB,OAAO;YAAE,MAAM,CAAC;QAAE;IACtB;IAEA,MAAMC,YAAY,IAAIC;I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UAAU,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC;IACtC;AACJ"}
@@ -25,7 +25,9 @@ export interface IScheduleDialogPresenterCancelParams {
25
25
  export interface IScheduleDialogPresenter {
26
26
  get vm(): IScheduleDialogPresenterViewModel;
27
27
  load(params: IScheduleDialogPresenterLoadParams): Promise<void>;
28
+ /** Rejects when scheduling fails, so the caller can show the error. */
28
29
  schedule(params: IScheduleDialogPresenterScheduleParams): Promise<void>;
30
+ /** Rejects when cancelling fails, so the caller can show the error. */
29
31
  cancel(params: IScheduleDialogPresenterCancelParams): Promise<void>;
30
32
  reset(): void;
31
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"presentation/scheduleDialog/abstractions.js","sources":["../../../src/presentation/scheduleDialog/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { ScheduleActionType, SchedulerEntry } from \"~/types.js\";\n\nexport interface IScheduleDialogRescheduling {\n actionName: string;\n scheduleOn: string;\n}\n\nexport interface IScheduleDialogPresenterViewModel {\n loading: boolean;\n entry: SchedulerEntry | null;\n rescheduling: IScheduleDialogRescheduling | null;\n}\n\nexport interface IScheduleDialogPresenterLoadParams {\n namespace: string;\n id: string;\n}\n\nexport interface IScheduleDialogPresenterScheduleParams {\n targetId: string;\n namespace: string;\n scheduleOn: Date;\n actionType: ScheduleActionType;\n}\n\nexport interface IScheduleDialogPresenterCancelParams {\n id: string;\n namespace: string;\n}\n\nexport interface IScheduleDialogPresenter {\n get vm(): IScheduleDialogPresenterViewModel;\n load(params: IScheduleDialogPresenterLoadParams): Promise<void>;\n schedule(params: IScheduleDialogPresenterScheduleParams): Promise<void>;\n cancel(params: IScheduleDialogPresenterCancelParams): Promise<void>;\n reset(): void;\n}\n\nexport const ScheduleDialogPresenter = createAbstraction<IScheduleDialogPresenter>(\n \"Scheduler/ScheduleDialogPresenter\"\n);\n\nexport namespace ScheduleDialogPresenter {\n export type Interface = IScheduleDialogPresenter;\n}\n"],"names":["ScheduleDialogPresenter","createAbstraction"],"mappings":";AAuCO,MAAMA,0BAA0BC,kBACnC"}
1
+ {"version":3,"file":"presentation/scheduleDialog/abstractions.js","sources":["../../../src/presentation/scheduleDialog/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { ScheduleActionType, SchedulerEntry } from \"~/types.js\";\n\nexport interface IScheduleDialogRescheduling {\n actionName: string;\n scheduleOn: string;\n}\n\nexport interface IScheduleDialogPresenterViewModel {\n loading: boolean;\n entry: SchedulerEntry | null;\n rescheduling: IScheduleDialogRescheduling | null;\n}\n\nexport interface IScheduleDialogPresenterLoadParams {\n namespace: string;\n id: string;\n}\n\nexport interface IScheduleDialogPresenterScheduleParams {\n targetId: string;\n namespace: string;\n scheduleOn: Date;\n actionType: ScheduleActionType;\n}\n\nexport interface IScheduleDialogPresenterCancelParams {\n id: string;\n namespace: string;\n}\n\nexport interface IScheduleDialogPresenter {\n get vm(): IScheduleDialogPresenterViewModel;\n load(params: IScheduleDialogPresenterLoadParams): Promise<void>;\n /** Rejects when scheduling fails, so the caller can show the error. */\n schedule(params: IScheduleDialogPresenterScheduleParams): Promise<void>;\n /** Rejects when cancelling fails, so the caller can show the error. */\n cancel(params: IScheduleDialogPresenterCancelParams): Promise<void>;\n reset(): void;\n}\n\nexport const ScheduleDialogPresenter = createAbstraction<IScheduleDialogPresenter>(\n \"Scheduler/ScheduleDialogPresenter\"\n);\n\nexport namespace ScheduleDialogPresenter {\n export type Interface = IScheduleDialogPresenter;\n}\n"],"names":["ScheduleDialogPresenter","createAbstraction"],"mappings":";AAyCO,MAAMA,0BAA0BC,kBACnC"}
@@ -4,7 +4,7 @@ interface ICancelButtonComponentProps {
4
4
  presenter: IScheduleDialogPresenter;
5
5
  onCancel: () => Promise<void>;
6
6
  }
7
- export declare const CancelButtonComponent: (({ presenter, onCancel }: ICancelButtonComponentProps) => React.JSX.Element | null) & {
8
- displayName: string;
7
+ export declare const CancelButtonComponent: (({ presenter, onCancel }: ICancelButtonComponentProps) => React.JSX.Element | null) & React.NamedExoticComponent<ICancelButtonComponentProps> & {
8
+ readonly type: ({ presenter, onCancel }: ICancelButtonComponentProps) => React.JSX.Element | null;
9
9
  };
10
10
  export {};
@@ -3,7 +3,7 @@ import type { IScheduleDialogPresenter } from "../abstractions.js";
3
3
  interface FormComponentProps {
4
4
  presenter: IScheduleDialogPresenter;
5
5
  }
6
- export declare const FormComponent: (({ presenter }: FormComponentProps) => React.JSX.Element) & {
7
- displayName: string;
6
+ export declare const FormComponent: (({ presenter }: FormComponentProps) => React.JSX.Element) & React.NamedExoticComponent<FormComponentProps> & {
7
+ readonly type: ({ presenter }: FormComponentProps) => React.JSX.Element;
8
8
  };
9
9
  export {};
@@ -3,7 +3,7 @@ import type { ISchedulerListPresenter } from "../abstractions.js";
3
3
  interface BottomInfoBarProps {
4
4
  presenter: ISchedulerListPresenter;
5
5
  }
6
- export declare const BottomInfoBar: (({ presenter }: BottomInfoBarProps) => React.JSX.Element) & {
7
- displayName: string;
6
+ export declare const BottomInfoBar: (({ presenter }: BottomInfoBarProps) => React.JSX.Element) & React.NamedExoticComponent<BottomInfoBarProps> & {
7
+ readonly type: ({ presenter }: BottomInfoBarProps) => React.JSX.Element;
8
8
  };
9
9
  export {};
@@ -3,7 +3,7 @@ import type { ISchedulerListPresenter } from "../abstractions.js";
3
3
  interface EmptyProps {
4
4
  presenter: ISchedulerListPresenter;
5
5
  }
6
- export declare const Empty: (({ presenter }: EmptyProps) => React.JSX.Element) & {
7
- displayName: string;
6
+ export declare const Empty: (({ presenter }: EmptyProps) => React.JSX.Element) & React.NamedExoticComponent<EmptyProps> & {
7
+ readonly type: ({ presenter }: EmptyProps) => React.JSX.Element;
8
8
  };
9
9
  export {};
@@ -5,7 +5,7 @@ interface SchedulerOverlayProps {
5
5
  title: string;
6
6
  onExited: () => void;
7
7
  }
8
- export declare const SchedulerOverlay: (({ presenter, title, onExited }: SchedulerOverlayProps) => React.JSX.Element) & {
9
- displayName: string;
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
10
  };
11
11
  export {};
@@ -3,7 +3,7 @@ import type { ISchedulerListPresenter } from "../abstractions.js";
3
3
  interface SchedulerTableProps {
4
4
  presenter: ISchedulerListPresenter;
5
5
  }
6
- export declare const SchedulerTable: (({ presenter }: SchedulerTableProps) => React.JSX.Element) & {
7
- displayName: string;
6
+ export declare const SchedulerTable: (({ presenter }: SchedulerTableProps) => React.JSX.Element) & React.NamedExoticComponent<SchedulerTableProps> & {
7
+ readonly type: ({ presenter }: SchedulerTableProps) => React.JSX.Element;
8
8
  };
9
9
  export {};
@@ -3,7 +3,7 @@ import type { ISchedulerListPresenter } from "../abstractions.js";
3
3
  interface SearchInputProps {
4
4
  presenter: ISchedulerListPresenter;
5
5
  }
6
- export declare const SearchInput: (({ presenter }: SearchInputProps) => React.JSX.Element) & {
7
- displayName: string;
6
+ export declare const SearchInput: (({ presenter }: SearchInputProps) => React.JSX.Element) & React.NamedExoticComponent<SearchInputProps> & {
7
+ readonly type: ({ presenter }: SearchInputProps) => React.JSX.Element;
8
8
  };
9
9
  export {};