@webiny/app-website-builder-workflows 0.0.0-unstable.3fddf667ea → 0.0.0-unstable.48a4e5b6c1
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/Components/ContentReviews/WbContentReviews.js.map +1 -1
- package/Components/ContentReviews/WbContentReviews.smoke.test.js +1 -1
- package/Components/ContentReviews/WbContentReviews.smoke.test.js.map +1 -1
- package/Components/ContentReviews/WbContentReviewsSidebarItem.js +17 -7
- package/Components/ContentReviews/WbContentReviewsSidebarItem.js.map +1 -1
- package/Components/ContentReviews/WbContentReviewsSidebarItem.test.js +122 -11
- package/Components/ContentReviews/WbContentReviewsSidebarItem.test.js.map +1 -1
- package/Components/PageEditor/PageBasePublishDecorator.js +1 -1
- package/Components/PageEditor/PageBasePublishDecorator.js.map +1 -1
- package/Components/PageEditor/PageEditorAutoSave.js +1 -1
- package/Components/PageEditor/PageEditorAutoSave.js.map +1 -1
- package/Components/PageEditor/PageEditorAutoSave.test.js +1 -1
- package/Components/PageEditor/PageEditorAutoSave.test.js.map +1 -1
- package/Components/PageEditor/PageEditorLayout.js +1 -1
- package/Components/PageEditor/PageEditorLayout.js.map +1 -1
- package/Components/PageEditor/PageEditorLayout.test.js +1 -1
- package/Components/PageEditor/PageEditorLayout.test.js.map +1 -1
- package/Components/PageEditor/PageEditorTopBar.js +1 -1
- package/Components/PageEditor/PageEditorTopBar.js.map +1 -1
- package/Components/PageEditor/PageEditorTopBar.test.js +1 -1
- package/Components/PageEditor/PageEditorTopBar.test.js.map +1 -1
- package/Components/PageEditor/PageNewRevisionDecorator.js +1 -1
- package/Components/PageEditor/PageNewRevisionDecorator.js.map +1 -1
- package/Components/PageEditor/PageNewRevisionDecorator.test.js +1 -1
- package/Components/PageEditor/PageNewRevisionDecorator.test.js.map +1 -1
- package/Components/PageEditor/PageReviewPublishAction.js +1 -1
- package/Components/PageEditor/PageReviewPublishAction.js.map +1 -1
- package/Components/PageEditor/PageScheduleDecorator.js +6 -2
- package/Components/PageEditor/PageScheduleDecorator.js.map +1 -1
- package/Components/PageEditor/PageScheduleDecorator.test.js +13 -3
- package/Components/PageEditor/PageScheduleDecorator.test.js.map +1 -1
- package/Components/PageEditor/getPageReadOnlyReason.js +1 -7
- package/Components/PageEditor/getPageReadOnlyReason.js.map +1 -1
- package/Components/PageEditor/getPageReadOnlyReason.test.js +4 -6
- package/Components/PageEditor/getPageReadOnlyReason.test.js.map +1 -1
- package/Components/PageEditor/pageReviewMatrix.test.js +5 -7
- package/Components/PageEditor/pageReviewMatrix.test.js.map +1 -1
- package/Components/PageEditor/publishMatrix.test.js +1 -1
- package/Components/PageEditor/publishMatrix.test.js.map +1 -1
- package/Components/PagesList/PageBulkPublishBlocked.d.ts +5 -0
- package/Components/PagesList/PageBulkPublishBlocked.js +23 -0
- package/Components/PagesList/PageBulkPublishBlocked.js.map +1 -0
- package/Components/PagesList/PageBulkPublishGate.d.ts +7 -0
- package/Components/PagesList/PageBulkPublishGate.js +33 -0
- package/Components/PagesList/PageBulkPublishGate.js.map +1 -0
- package/Components/PagesList/PageBulkPublishGate.test.d.ts +1 -0
- package/Components/PagesList/PageBulkPublishGate.test.js +148 -0
- package/Components/PagesList/PageBulkPublishGate.test.js.map +1 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.d.ts +2 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.js +16 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.js.map +1 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.test.d.ts +1 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.test.js +44 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.test.js.map +1 -0
- package/Components/PagesList/PageListReviewGatedActions.js +11 -15
- package/Components/PagesList/PageListReviewGatedActions.js.map +1 -1
- package/Components/PagesList/PageListReviewGatedActions.test.js +141 -27
- package/Components/PagesList/PageListReviewGatedActions.test.js.map +1 -1
- package/Components/PagesList/PageListReviewMoveAction.d.ts +2 -0
- package/Components/PagesList/PageListReviewMoveAction.js +16 -0
- package/Components/PagesList/PageListReviewMoveAction.js.map +1 -0
- package/Components/PagesList/PageListReviewMoveAction.test.d.ts +1 -0
- package/Components/PagesList/PageListReviewMoveAction.test.js +102 -0
- package/Components/PagesList/PageListReviewMoveAction.test.js.map +1 -0
- package/Components/PagesList/PageMoveBlocked.d.ts +2 -0
- package/Components/PagesList/PageMoveBlocked.js +26 -0
- package/Components/PagesList/PageMoveBlocked.js.map +1 -0
- package/Components/PagesList/PageMoveGate.d.ts +5 -0
- package/Components/PagesList/PageMoveGate.js +12 -0
- package/Components/PagesList/PageMoveGate.js.map +1 -0
- package/Components/PagesList/PagePublishBlocked.d.ts +5 -0
- package/Components/PagesList/PagePublishBlocked.js +26 -0
- package/Components/PagesList/PagePublishBlocked.js.map +1 -0
- package/Components/PagesList/PagePublishGate.d.ts +7 -0
- package/Components/PagesList/PagePublishGate.js +21 -0
- package/Components/PagesList/PagePublishGate.js.map +1 -0
- package/Components/PagesList/PageScheduleGate.d.ts +7 -0
- package/Components/PagesList/PageScheduleGate.js +13 -0
- package/Components/PagesList/PageScheduleGate.js.map +1 -0
- package/Components/PagesList/PagesList.js +3 -1
- package/Components/PagesList/PagesList.js.map +1 -1
- package/Components/PagesList/PagesList.test.js +18 -0
- package/Components/PagesList/PagesList.test.js.map +1 -1
- package/Components/PagesList/ignoreAction.d.ts +1 -0
- package/Components/PagesList/ignoreAction.js +4 -0
- package/Components/PagesList/ignoreAction.js.map +1 -0
- package/Components/PagesList/toListPublishRow.d.ts +8 -0
- package/Components/PagesList/toListPublishRow.js +10 -0
- package/Components/PagesList/toListPublishRow.js.map +1 -0
- package/Components/PagesList/toListPublishRow.test.d.ts +1 -0
- package/Components/PagesList/toListPublishRow.test.js +38 -0
- package/Components/PagesList/toListPublishRow.test.js.map +1 -0
- package/Components/PagesList/usePageRowPublishDisabledReason.d.ts +1 -0
- package/Components/PagesList/usePageRowPublishDisabledReason.js +25 -0
- package/Components/PagesList/usePageRowPublishDisabledReason.js.map +1 -0
- package/Routes/WebsiteBuilderWorkflowsMenu.test.js +6 -3
- package/Routes/WebsiteBuilderWorkflowsMenu.test.js.map +1 -1
- package/editorGlue.wiring.test.js +1 -1
- package/editorGlue.wiring.test.js.map +1 -1
- package/features/editorGateway/WbWorkflowEditorGateway/WbWorkflowEditorGateway.test.js +8 -0
- package/features/editorGateway/WbWorkflowEditorGateway/WbWorkflowEditorGateway.test.js.map +1 -1
- package/features/editorGateway/feature.test.js +1 -0
- package/features/editorGateway/feature.test.js.map +1 -1
- package/features/gateway/WbReviewGateway/WbReviewGateway.js +2 -3
- package/features/gateway/WbReviewGateway/WbReviewGateway.js.map +1 -1
- package/features/gateway/WbReviewGateway/WbReviewGateway.test.js +7 -10
- package/features/gateway/WbReviewGateway/WbReviewGateway.test.js.map +1 -1
- package/features/gateway/contentReviewsBindings.test.js +2 -2
- package/features/gateway/contentReviewsBindings.test.js.map +1 -1
- package/features/gateway/graphql/listWebsiteBuilderPageReviews.d.ts +1 -1
- package/features/gateway/graphql/listWebsiteBuilderPageReviews.js +2 -2
- package/features/gateway/graphql/listWebsiteBuilderPageReviews.js.map +1 -1
- package/features/gateway/graphql/listWebsiteBuilderPageWorkflows.d.ts +1 -1
- package/package.json +18 -18
- package/pageListChangeStatus.wiring.test.js +53 -15
- package/pageListChangeStatus.wiring.test.js.map +1 -1
- package/publishAutosave.wiring.test.js +1 -1
- package/publishAutosave.wiring.test.js.map +1 -1
- package/routes.d.ts +2 -1
- package/routes.js +2 -1
- package/routes.js.map +1 -1
- package/testing/WbEditorHarness.js +1 -1
- package/testing/WbEditorHarness.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageNewRevisionDecorator.js","sources":["../../../src/Components/PageEditor/PageNewRevisionDecorator.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReviewFeature } from \"~/features/editorReview/feature.js\";\n\nconst { Ui } = PageEditorConfig;\n\ninterface NewRevisionGateProps {\n element?: React.ReactElement | null;\n}\n\nconst NewRevisionGate = createReactiveComponent((props: NewRevisionGateProps) => {\n const { session } = useFeature(WbPageReviewFeature);\n const { vm } = session.presenter;\n\n /*\n * Hidden while the status is unknown (R225) and while a review is in progress (Q17). Shown\n * for a rejected, an approved and an unpublished page (Q19) and where there is no workflow.\n */\n if (vm.status === \"loading\" || vm.status === \"failed\" || vm.reviewKind === \"inProgress\") {\n return null;\n }\n\n return props.element ?? null;\n});\n\n/*\n * The one decoration of the base `buttonNewRevision` (A78); every other action passes through.\n */\nexport const PageNewRevisionDecorator = Ui.TopBar.Action.createDecorator(Original => {\n return function PageNewRevisionDecoratorAction(props) {\n if (props.name === \"buttonNewRevision\") {\n return <Original {...props} element={<NewRevisionGate element={props.element} />} />;\n }\n return <Original {...props} />;\n };\n});\n"],"names":["Ui","PageEditorConfig","NewRevisionGate","createReactiveComponent","props","session","useFeature","WbPageReviewFeature","vm","PageNewRevisionDecorator","Original"],"mappings":";;;;;AAMA,MAAM,EAAEA,
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageNewRevisionDecorator.js","sources":["../../../src/Components/PageEditor/PageNewRevisionDecorator.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReviewFeature } from \"~/features/editorReview/feature.js\";\n\nconst { Ui } = PageEditorConfig;\n\ninterface NewRevisionGateProps {\n element?: React.ReactElement | null;\n}\n\nconst NewRevisionGate = createReactiveComponent((props: NewRevisionGateProps) => {\n const { session } = useFeature(WbPageReviewFeature);\n const { vm } = session.presenter;\n\n /*\n * Hidden while the status is unknown (R225) and while a review is in progress (Q17). Shown\n * for a rejected, an approved and an unpublished page (Q19) and where there is no workflow.\n */\n if (vm.status === \"loading\" || vm.status === \"failed\" || vm.reviewKind === \"inProgress\") {\n return null;\n }\n\n return props.element ?? null;\n});\n\n/*\n * The one decoration of the base `buttonNewRevision` (A78); every other action passes through.\n */\nexport const PageNewRevisionDecorator = Ui.TopBar.Action.createDecorator(Original => {\n return function PageNewRevisionDecoratorAction(props) {\n if (props.name === \"buttonNewRevision\") {\n return <Original {...props} element={<NewRevisionGate element={props.element} />} />;\n }\n return <Original {...props} />;\n };\n});\n"],"names":["Ui","PageEditorConfig","NewRevisionGate","createReactiveComponent","props","session","useFeature","WbPageReviewFeature","vm","PageNewRevisionDecorator","Original"],"mappings":";;;;;AAMA,MAAM,EAAEA,EAAE,EAAE,GAAGC;AAMf,MAAMC,kBAAkBC,wBAAwB,CAACC;IAC7C,MAAM,EAAEC,OAAO,EAAE,GAAGC,WAAWC;IAC/B,MAAM,EAAEC,EAAE,EAAE,GAAGH,QAAQ,SAAS;IAMhC,IAAIG,AAAc,cAAdA,GAAG,MAAM,IAAkBA,AAAc,aAAdA,GAAG,MAAM,IAAiBA,AAAkB,iBAAlBA,GAAG,UAAU,EAClE,OAAO;IAGX,OAAOJ,MAAM,OAAO,IAAI;AAC5B;AAKO,MAAMK,2BAA2BT,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAACU,CAAAA,WAC9D,SAAwCN,KAAK;QAChD,IAAIA,AAAe,wBAAfA,MAAM,IAAI,EACV,OAAO,WAAP,GAAO,oBAACM,UAAAA;YAAU,GAAGN,KAAK;YAAE,uBAAS,oBAACF,iBAAAA;gBAAgB,SAASE,MAAM,OAAO;;;QAEhF,OAAO,WAAP,GAAO,oBAACM,UAAaN;IACzB"}
|
|
@@ -8,7 +8,7 @@ import { WbEditorHarness } from "../../testing/WbEditorHarness.js";
|
|
|
8
8
|
import { createFakeSession } from "../../testing/createFakeSession.js";
|
|
9
9
|
import { createPageEditor } from "../../testing/createPageEditor.js";
|
|
10
10
|
import { PageNewRevisionDecorator } from "./PageNewRevisionDecorator.js";
|
|
11
|
-
const { Ui
|
|
11
|
+
const { Ui } = PageEditorConfig;
|
|
12
12
|
const mountNewRevision = (kind, isUnpublished = false)=>{
|
|
13
13
|
const handle = createFakeSession(kind, isUnpublished);
|
|
14
14
|
const container = new Container();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageNewRevisionDecorator.test.js","sources":["../../../src/Components/PageEditor/PageNewRevisionDecorator.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { act } from \"@testing-library/react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { waitFor } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { InternalPageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageNewRevisionDecorator } from \"./PageNewRevisionDecorator.js\";\n\nconst { Ui } = PageEditorConfig;\n\nconst mountNewRevision = (kind: FakeReviewKind, isUnpublished: boolean = false) => {\n const handle = createFakeSession(kind, isUnpublished);\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n const editor = createPageEditor(isUnpublished ? \"unpublished\" : \"published\");\n\n render(\n <WbEditorHarness container={container} editor={editor} groups={[\"actions\"]}>\n <PageNewRevisionDecorator />\n <InternalPageEditorConfig>\n <Ui.TopBar.Action name={\"sentinel\"} element={<span data-testid={\"sentinel\"} />} />\n <Ui.TopBar.Action\n name={\"buttonNewRevision\"}\n element={<span data-testid={\"new-revision\"} />}\n />\n <Ui.TopBar.Action\n name={\"buttonSettings\"}\n element={<span data-testid={\"other-action\"} />}\n />\n </InternalPageEditorConfig>\n </WbEditorHarness>\n );\n\n return handle;\n};\n\ninterface NewRevisionCase {\n kind: FakeReviewKind;\n shown: boolean;\n}\n\nconst CASES: NewRevisionCase[] = [\n { kind: \"loading\", shown: false },\n { kind: \"failed\", shown: false },\n { kind: \"noWorkflow\", shown: true },\n { kind: \"none\", shown: true },\n { kind: \"inProgress\", shown: false },\n { kind: \"approved\", shown: true },\n { kind: \"rejected\", shown: true }\n];\n\ndescribe(\"PageNewRevisionDecorator\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it.each(CASES)(\"$kind review: New Revision shown is $shown\", async ({ kind, shown }) => {\n mountNewRevision(kind);\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"new-revision\")).toHaveLength(shown ? 1 : 0);\n });\n });\n\n it(\"an unpublished page with no review shows New Revision (Q19)\", async () => {\n mountNewRevision(\"none\", true);\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"new-revision\")).toHaveLength(1);\n });\n });\n\n it(\"leaves every other top bar action alone\", async () => {\n mountNewRevision(\"inProgress\");\n await screen.findByTestId(\"sentinel\");\n\n expect(screen.queryAllByTestId(\"other-action\")).toHaveLength(1);\n });\n\n it(\"follows the review while the editor is open: hidden in progress, shown once rejected (Q17)\", async () => {\n const { setKind } = mountNewRevision(\"inProgress\");\n await screen.findByTestId(\"sentinel\");\n expect(screen.queryAllByTestId(\"new-revision\")).toHaveLength(0);\n\n act(() => {\n setKind(\"rejected\");\n });\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"new-revision\")).toHaveLength(1);\n });\n });\n});\n"],"names":["Ui","PageEditorConfig","mountNewRevision","kind","isUnpublished","handle","createFakeSession","container","Container","WbPageReview","editor","createPageEditor","render","WbEditorHarness","PageNewRevisionDecorator","InternalPageEditorConfig","CASES","describe","afterEach","cleanup","it","shown","screen","waitFor","expect","setKind","act"],"mappings":";;;;;;;;;;AAoBA,MAAM,EAAEA,
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageNewRevisionDecorator.test.js","sources":["../../../src/Components/PageEditor/PageNewRevisionDecorator.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { act } from \"@testing-library/react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { waitFor } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { InternalPageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageNewRevisionDecorator } from \"./PageNewRevisionDecorator.js\";\n\nconst { Ui } = PageEditorConfig;\n\nconst mountNewRevision = (kind: FakeReviewKind, isUnpublished: boolean = false) => {\n const handle = createFakeSession(kind, isUnpublished);\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n const editor = createPageEditor(isUnpublished ? \"unpublished\" : \"published\");\n\n render(\n <WbEditorHarness container={container} editor={editor} groups={[\"actions\"]}>\n <PageNewRevisionDecorator />\n <InternalPageEditorConfig>\n <Ui.TopBar.Action name={\"sentinel\"} element={<span data-testid={\"sentinel\"} />} />\n <Ui.TopBar.Action\n name={\"buttonNewRevision\"}\n element={<span data-testid={\"new-revision\"} />}\n />\n <Ui.TopBar.Action\n name={\"buttonSettings\"}\n element={<span data-testid={\"other-action\"} />}\n />\n </InternalPageEditorConfig>\n </WbEditorHarness>\n );\n\n return handle;\n};\n\ninterface NewRevisionCase {\n kind: FakeReviewKind;\n shown: boolean;\n}\n\nconst CASES: NewRevisionCase[] = [\n { kind: \"loading\", shown: false },\n { kind: \"failed\", shown: false },\n { kind: \"noWorkflow\", shown: true },\n { kind: \"none\", shown: true },\n { kind: \"inProgress\", shown: false },\n { kind: \"approved\", shown: true },\n { kind: \"rejected\", shown: true }\n];\n\ndescribe(\"PageNewRevisionDecorator\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it.each(CASES)(\"$kind review: New Revision shown is $shown\", async ({ kind, shown }) => {\n mountNewRevision(kind);\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"new-revision\")).toHaveLength(shown ? 1 : 0);\n });\n });\n\n it(\"an unpublished page with no review shows New Revision (Q19)\", async () => {\n mountNewRevision(\"none\", true);\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"new-revision\")).toHaveLength(1);\n });\n });\n\n it(\"leaves every other top bar action alone\", async () => {\n mountNewRevision(\"inProgress\");\n await screen.findByTestId(\"sentinel\");\n\n expect(screen.queryAllByTestId(\"other-action\")).toHaveLength(1);\n });\n\n it(\"follows the review while the editor is open: hidden in progress, shown once rejected (Q17)\", async () => {\n const { setKind } = mountNewRevision(\"inProgress\");\n await screen.findByTestId(\"sentinel\");\n expect(screen.queryAllByTestId(\"new-revision\")).toHaveLength(0);\n\n act(() => {\n setKind(\"rejected\");\n });\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"new-revision\")).toHaveLength(1);\n });\n });\n});\n"],"names":["Ui","PageEditorConfig","mountNewRevision","kind","isUnpublished","handle","createFakeSession","container","Container","WbPageReview","editor","createPageEditor","render","WbEditorHarness","PageNewRevisionDecorator","InternalPageEditorConfig","CASES","describe","afterEach","cleanup","it","shown","screen","waitFor","expect","setKind","act"],"mappings":";;;;;;;;;;AAoBA,MAAM,EAAEA,EAAE,EAAE,GAAGC;AAEf,MAAMC,mBAAmB,CAACC,MAAsBC,gBAAyB,KAAK;IAC1E,MAAMC,SAASC,kBAAkBH,MAAMC;IACvC,MAAMG,YAAY,IAAIC;IACtBD,UAAU,gBAAgB,CAACE,cAAcJ,OAAO,OAAO;IACvD,MAAMK,SAASC,iBAAiBP,gBAAgB,gBAAgB;IAEhEQ,OAAO,WAADA,GACF,oBAACC,iBAAeA;QAAC,WAAWN;QAAW,QAAQG;QAAQ,QAAQ;YAAC;SAAU;qBACtE,oBAACI,0BAAwBA,OAAAA,WAAAA,GACzB,oBAACC,0BAAwBA,MAAAA,WAAAA,GACrB,oBAACf,GAAG,MAAM,CAAC,MAAM;QAAC,MAAM;QAAY,uBAAS,oBAAC;YAAK,eAAa;;sBAChE,oBAACA,GAAG,MAAM,CAAC,MAAM;QACb,MAAM;QACN,uBAAS,oBAAC;YAAK,eAAa;;sBAEhC,oBAACA,GAAG,MAAM,CAAC,MAAM;QACb,MAAM;QACN,uBAAS,oBAAC;YAAK,eAAa;;;IAM5C,OAAOK;AACX;AAOA,MAAMW,QAA2B;IAC7B;QAAE,MAAM;QAAW,OAAO;IAAM;IAChC;QAAE,MAAM;QAAU,OAAO;IAAM;IAC/B;QAAE,MAAM;QAAc,OAAO;IAAK;IAClC;QAAE,MAAM;QAAQ,OAAO;IAAK;IAC5B;QAAE,MAAM;QAAc,OAAO;IAAM;IACnC;QAAE,MAAM;QAAY,OAAO;IAAK;IAChC;QAAE,MAAM;QAAY,OAAO;IAAK;CACnC;AAEDC,SAAS,4BAA4B;IACjCC,UAAU;QACNC;IACJ;IAEAC,GAAG,IAAI,CAACJ,OAAO,8CAA8C,OAAO,EAAEb,IAAI,EAAEkB,KAAK,EAAE;QAC/EnB,iBAAiBC;QACjB,MAAMmB,OAAO,YAAY,CAAC;QAE1B,MAAMC,QAAQ;YACVC,OAAOF,OAAO,gBAAgB,CAAC,iBAAiB,YAAY,CAACD,QAAQ,IAAI;QAC7E;IACJ;IAEAD,GAAG,+DAA+D;QAC9DlB,iBAAiB,QAAQ;QACzB,MAAMoB,OAAO,YAAY,CAAC;QAE1B,MAAMC,QAAQ;YACVC,OAAOF,OAAO,gBAAgB,CAAC,iBAAiB,YAAY,CAAC;QACjE;IACJ;IAEAF,GAAG,2CAA2C;QAC1ClB,iBAAiB;QACjB,MAAMoB,OAAO,YAAY,CAAC;QAE1BE,OAAOF,OAAO,gBAAgB,CAAC,iBAAiB,YAAY,CAAC;IACjE;IAEAF,GAAG,8FAA8F;QAC7F,MAAM,EAAEK,OAAO,EAAE,GAAGvB,iBAAiB;QACrC,MAAMoB,OAAO,YAAY,CAAC;QAC1BE,OAAOF,OAAO,gBAAgB,CAAC,iBAAiB,YAAY,CAAC;QAE7DI,IAAI;YACAD,QAAQ;QACZ;QAEA,MAAMF,QAAQ;YACVC,OAAOF,OAAO,gBAAgB,CAAC,iBAAiB,YAAY,CAAC;QACjE;IACJ;AACJ"}
|
|
@@ -2,7 +2,7 @@ import react from "react";
|
|
|
2
2
|
import { PageEditorConfig } from "@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js";
|
|
3
3
|
import { HasPermission } from "@webiny/app-website-builder/presentation/security/HasPermission.js";
|
|
4
4
|
import { PageReviewPublishButton } from "./PageReviewPublishButton.js";
|
|
5
|
-
const { Ui
|
|
5
|
+
const { Ui } = PageEditorConfig;
|
|
6
6
|
const PageReviewPublishAction = ()=>/*#__PURE__*/ react.createElement(Ui.TopBar.Action, {
|
|
7
7
|
name: "buttonWorkflowPublish",
|
|
8
8
|
element: /*#__PURE__*/ react.createElement(HasPermission, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageReviewPublishAction.js","sources":["../../../src/Components/PageEditor/PageReviewPublishAction.tsx"],"sourcesContent":["import React from \"react\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { HasPermission } from \"@webiny/app-website-builder/presentation/security/HasPermission.js\";\nimport { PageReviewPublishButton } from \"./PageReviewPublishButton.js\";\n\nconst { Ui } = PageEditorConfig;\n\n/*\n * Registered outside `Ui.IsNotReadOnly` on purpose: the base Publish is mounted only while the\n * canvas is editable, and an approved revision is read-only (A73).\n */\nexport const PageReviewPublishAction = () => {\n return (\n <Ui.TopBar.Action\n name={\"buttonWorkflowPublish\"}\n element={\n <HasPermission entity={\"page\"} action={\"publish\"}>\n <PageReviewPublishButton />\n </HasPermission>\n }\n />\n );\n};\n"],"names":["Ui","PageEditorConfig","PageReviewPublishAction","HasPermission","PageReviewPublishButton"],"mappings":";;;;AAKA,MAAM,EAAEA,
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageReviewPublishAction.js","sources":["../../../src/Components/PageEditor/PageReviewPublishAction.tsx"],"sourcesContent":["import React from \"react\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { HasPermission } from \"@webiny/app-website-builder/presentation/security/HasPermission.js\";\nimport { PageReviewPublishButton } from \"./PageReviewPublishButton.js\";\n\nconst { Ui } = PageEditorConfig;\n\n/*\n * Registered outside `Ui.IsNotReadOnly` on purpose: the base Publish is mounted only while the\n * canvas is editable, and an approved revision is read-only (A73).\n */\nexport const PageReviewPublishAction = () => {\n return (\n <Ui.TopBar.Action\n name={\"buttonWorkflowPublish\"}\n element={\n <HasPermission entity={\"page\"} action={\"publish\"}>\n <PageReviewPublishButton />\n </HasPermission>\n }\n />\n );\n};\n"],"names":["Ui","PageEditorConfig","PageReviewPublishAction","HasPermission","PageReviewPublishButton"],"mappings":";;;;AAKA,MAAM,EAAEA,EAAE,EAAE,GAAGC;AAMR,MAAMC,0BAA0B,IAC5B,WAAP,GACI,oBAACF,GAAG,MAAM,CAAC,MAAM;QACb,MAAM;QACN,uBACI,oBAACG,eAAaA;YAAC,QAAQ;YAAQ,QAAQ;yBACnC,oBAACC,yBAAuBA"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import react from "react";
|
|
2
2
|
import { useFeature } from "@webiny/app";
|
|
3
3
|
import { createReactiveComponent } from "@webiny/app-admin";
|
|
4
|
+
import { useSelectFromDocument } from "@webiny/app-website-builder/BaseEditor/hooks/useSelectFromDocument.js";
|
|
5
|
+
import { WbPageStatus } from "@webiny/app-website-builder/constants.js";
|
|
4
6
|
import { PageEditorConfig } from "@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js";
|
|
5
7
|
import { WbPageReviewFeature } from "../../features/editorReview/feature.js";
|
|
6
|
-
const { Ui
|
|
8
|
+
const { Ui } = PageEditorConfig;
|
|
9
|
+
const selectStatus = (doc)=>doc.status || WbPageStatus.Draft;
|
|
7
10
|
const ScheduleGate = createReactiveComponent((props)=>{
|
|
8
11
|
const { session } = useFeature(WbPageReviewFeature);
|
|
9
|
-
|
|
12
|
+
const pageStatus = useSelectFromDocument(selectStatus);
|
|
13
|
+
if (pageStatus !== WbPageStatus.Published && !session.presenter.vm.allowsPublishing) return null;
|
|
10
14
|
return props.element ?? null;
|
|
11
15
|
});
|
|
12
16
|
const PageScheduleDecorator = Ui.TopBar.DropdownAction.createDecorator((Original)=>function(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageScheduleDecorator.js","sources":["../../../src/Components/PageEditor/PageScheduleDecorator.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReviewFeature } from \"~/features/editorReview/feature.js\";\n\nconst { Ui } = PageEditorConfig;\n\ninterface ScheduleGateProps {\n element?: React.ReactElement | null;\n}\n\nconst ScheduleGate = createReactiveComponent((props: ScheduleGateProps) => {\n const { session } = useFeature(WbPageReviewFeature);\n\n if (!session.presenter.vm.allowsPublishing) {\n return null;\n }\n\n return props.element ?? null;\n});\n\n/*\n * Scheduling a publish needs what publishing needs, so the scheduler's \"Schedule\" dropdown\n *
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageScheduleDecorator.js","sources":["../../../src/Components/PageEditor/PageScheduleDecorator.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { useSelectFromDocument } from \"@webiny/app-website-builder/BaseEditor/hooks/useSelectFromDocument.js\";\nimport { WbPageStatus } from \"@webiny/app-website-builder/constants.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReviewFeature } from \"~/features/editorReview/feature.js\";\nimport type { IPageEditorDocument } from \"./pageEditorDocument.js\";\n\nconst { Ui } = PageEditorConfig;\n\ninterface ScheduleGateProps {\n element?: React.ReactElement | null;\n}\n\nconst selectStatus = (doc: IPageEditorDocument): WbStatus => {\n return doc.status || WbPageStatus.Draft;\n};\n\nconst ScheduleGate = createReactiveComponent((props: ScheduleGateProps) => {\n const { session } = useFeature(WbPageReviewFeature);\n const pageStatus = useSelectFromDocument<WbStatus, IPageEditorDocument>(selectStatus);\n\n // A published page schedules an unpublish, which no review blocks.\n if (pageStatus !== WbPageStatus.Published && !session.presenter.vm.allowsPublishing) {\n return null;\n }\n\n return props.element ?? null;\n});\n\n/*\n * Scheduling a publish needs what publishing needs (the API refuses the schedule with\n * `Workflows/Review/PublishBlocked` otherwise), so the scheduler's \"Schedule\" dropdown action\n * (only present when the scheduler is installed) is hidden unless the review allows publishing or\n * the page is published (the dialog then schedules an unpublish); every other dropdown action\n * passes through.\n */\nexport const PageScheduleDecorator = Ui.TopBar.DropdownAction.createDecorator(Original => {\n return function PageScheduleDecoratorAction(props) {\n if (props.name === \"scheduler\") {\n return <Original {...props} element={<ScheduleGate element={props.element} />} />;\n }\n return <Original {...props} />;\n };\n});\n"],"names":["Ui","PageEditorConfig","selectStatus","doc","WbPageStatus","ScheduleGate","createReactiveComponent","props","session","useFeature","WbPageReviewFeature","pageStatus","useSelectFromDocument","PageScheduleDecorator","Original"],"mappings":";;;;;;;AAUA,MAAM,EAAEA,EAAE,EAAE,GAAGC;AAMf,MAAMC,eAAe,CAACC,MACXA,IAAI,MAAM,IAAIC,aAAa,KAAK;AAG3C,MAAMC,eAAeC,wBAAwB,CAACC;IAC1C,MAAM,EAAEC,OAAO,EAAE,GAAGC,WAAWC;IAC/B,MAAMC,aAAaC,sBAAqDV;IAGxE,IAAIS,eAAeP,aAAa,SAAS,IAAI,CAACI,QAAQ,SAAS,CAAC,EAAE,CAAC,gBAAgB,EAC/E,OAAO;IAGX,OAAOD,MAAM,OAAO,IAAI;AAC5B;AASO,MAAMM,wBAAwBb,GAAG,MAAM,CAAC,cAAc,CAAC,eAAe,CAACc,CAAAA,WACnE,SAAqCP,KAAK;QAC7C,IAAIA,AAAe,gBAAfA,MAAM,IAAI,EACV,OAAO,WAAP,GAAO,oBAACO,UAAAA;YAAU,GAAGP,KAAK;YAAE,uBAAS,oBAACF,cAAAA;gBAAa,SAASE,MAAM,OAAO;;;QAE7E,OAAO,WAAP,GAAO,oBAACO,UAAaP;IACzB"}
|
|
@@ -8,14 +8,14 @@ import { WbEditorHarness } from "../../testing/WbEditorHarness.js";
|
|
|
8
8
|
import { createFakeSession } from "../../testing/createFakeSession.js";
|
|
9
9
|
import { createPageEditor } from "../../testing/createPageEditor.js";
|
|
10
10
|
import { PageScheduleDecorator } from "./PageScheduleDecorator.js";
|
|
11
|
-
const { Ui
|
|
12
|
-
const mountSchedule = (kind)=>{
|
|
11
|
+
const { Ui } = PageEditorConfig;
|
|
12
|
+
const mountSchedule = (kind, pageStatus = "draft")=>{
|
|
13
13
|
const handle = createFakeSession(kind);
|
|
14
14
|
const container = new Container();
|
|
15
15
|
container.registerInstance(WbPageReview, handle.session);
|
|
16
16
|
render(/*#__PURE__*/ react.createElement(WbEditorHarness, {
|
|
17
17
|
container: container,
|
|
18
|
-
editor: createPageEditor(
|
|
18
|
+
editor: createPageEditor(pageStatus),
|
|
19
19
|
groups: [
|
|
20
20
|
"dropdownActions"
|
|
21
21
|
]
|
|
@@ -70,6 +70,16 @@ describe("PageScheduleDecorator", ()=>{
|
|
|
70
70
|
await screen.findByTestId("other-action");
|
|
71
71
|
expect(screen.queryAllByTestId("schedule")).toHaveLength(shown ? 1 : 0);
|
|
72
72
|
});
|
|
73
|
+
it.each([
|
|
74
|
+
"none",
|
|
75
|
+
"inProgress",
|
|
76
|
+
"rejected",
|
|
77
|
+
"loading"
|
|
78
|
+
])("%s review: keeps Schedule (unpublish) of a published page", async (kind)=>{
|
|
79
|
+
mountSchedule(kind, "published");
|
|
80
|
+
await screen.findByTestId("other-action");
|
|
81
|
+
expect(screen.queryAllByTestId("schedule")).toHaveLength(1);
|
|
82
|
+
});
|
|
73
83
|
});
|
|
74
84
|
|
|
75
85
|
//# sourceMappingURL=PageScheduleDecorator.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageScheduleDecorator.test.js","sources":["../../../src/Components/PageEditor/PageScheduleDecorator.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { InternalPageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageScheduleDecorator } from \"./PageScheduleDecorator.js\";\n\nconst { Ui } = PageEditorConfig;\n\nconst mountSchedule = (kind: FakeReviewKind) => {\n const handle = createFakeSession(kind);\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n\n render(\n <WbEditorHarness\n container={container}\n editor={createPageEditor(
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageScheduleDecorator.test.js","sources":["../../../src/Components/PageEditor/PageScheduleDecorator.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { InternalPageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { PageScheduleDecorator } from \"./PageScheduleDecorator.js\";\n\nconst { Ui } = PageEditorConfig;\n\nconst mountSchedule = (kind: FakeReviewKind, pageStatus: WbStatus = \"draft\") => {\n const handle = createFakeSession(kind);\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n\n render(\n <WbEditorHarness\n container={container}\n editor={createPageEditor(pageStatus)}\n groups={[\"dropdownActions\"]}\n >\n <PageScheduleDecorator />\n <InternalPageEditorConfig>\n <Ui.TopBar.DropdownAction\n name={\"scheduler\"}\n element={<span data-testid={\"schedule\"} />}\n />\n <Ui.TopBar.DropdownAction\n name={\"other\"}\n element={<span data-testid={\"other-action\"} />}\n />\n </InternalPageEditorConfig>\n </WbEditorHarness>\n );\n};\n\ninterface ScheduleCase {\n kind: FakeReviewKind;\n shown: boolean;\n}\n\nconst CASES: ScheduleCase[] = [\n { kind: \"loading\", shown: false },\n { kind: \"failed\", shown: false },\n { kind: \"noWorkflow\", shown: true },\n { kind: \"none\", shown: false },\n { kind: \"inProgress\", shown: false },\n { kind: \"approved\", shown: true },\n { kind: \"rejected\", shown: false }\n];\n\ndescribe(\"PageScheduleDecorator\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it.each(CASES)(\"$kind review: Schedule shown is $shown\", async ({ kind, shown }) => {\n mountSchedule(kind);\n // The other action renders in the same pass, so the Schedule count is settled.\n await screen.findByTestId(\"other-action\");\n\n expect(screen.queryAllByTestId(\"schedule\")).toHaveLength(shown ? 1 : 0);\n });\n\n it.each([\"none\", \"inProgress\", \"rejected\", \"loading\"] as FakeReviewKind[])(\n \"%s review: keeps Schedule (unpublish) of a published page\",\n async kind => {\n mountSchedule(kind, \"published\");\n await screen.findByTestId(\"other-action\");\n\n expect(screen.queryAllByTestId(\"schedule\")).toHaveLength(1);\n }\n );\n});\n"],"names":["Ui","PageEditorConfig","mountSchedule","kind","pageStatus","handle","createFakeSession","container","Container","WbPageReview","render","WbEditorHarness","createPageEditor","PageScheduleDecorator","InternalPageEditorConfig","CASES","describe","afterEach","cleanup","it","shown","screen","expect"],"mappings":";;;;;;;;;;AAmBA,MAAM,EAAEA,EAAE,EAAE,GAAGC;AAEf,MAAMC,gBAAgB,CAACC,MAAsBC,aAAuB,OAAO;IACvE,MAAMC,SAASC,kBAAkBH;IACjC,MAA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
2
2
|
const NOT_LOADED = "Read-only until the review status loads.";
|
|
3
3
|
const PUBLISHED = "Read-only. The Website Builder only edits draft revisions. Create a new revision to make changes.";
|
|
4
|
-
const APPROVED = "Read-only: this revision has an approved review. Create a new revision to make changes; it needs a new review.";
|
|
5
|
-
const REJECTED = "Read-only: this revision was rejected. Create a new revision to fix it.";
|
|
6
4
|
function getPageReadOnlyReason(vm, pageStatus) {
|
|
7
5
|
if ("loading" === vm.status || "failed" === vm.status) return NOT_LOADED;
|
|
8
6
|
if ("noWorkflow" === vm.status) return null;
|
|
9
7
|
if (pageStatus === WbPageStatus.Published) return PUBLISHED;
|
|
10
|
-
if ("active" === vm.status)
|
|
11
|
-
if ("approved" === vm.reviewKind) return APPROVED;
|
|
12
|
-
if ("rejected" === vm.reviewKind) return REJECTED;
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
8
|
+
if ("active" === vm.status) return null;
|
|
15
9
|
if (pageStatus !== WbPageStatus.Draft) return PUBLISHED;
|
|
16
10
|
return null;
|
|
17
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/getPageReadOnlyReason.js","sources":["../../../src/Components/PageEditor/getPageReadOnlyReason.ts"],"sourcesContent":["import { WbPageStatus } from \"@webiny/app-website-builder/constants.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport type { TargetReviewPresenter } from \"@webiny/app-workflows/review/presentation/targetReview/abstractions.js\";\n\nexport type PageReadOnlyReasonVm = Pick<TargetReviewPresenter.ViewModel, \"status\" | \"reviewKind\">;\n\nconst NOT_LOADED = \"Read-only until the review status loads.\";\nconst PUBLISHED =\n \"Read-only. The Website Builder only edits draft revisions. Create a new revision to make changes.\";\
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/getPageReadOnlyReason.js","sources":["../../../src/Components/PageEditor/getPageReadOnlyReason.ts"],"sourcesContent":["import { WbPageStatus } from \"@webiny/app-website-builder/constants.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport type { TargetReviewPresenter } from \"@webiny/app-workflows/review/presentation/targetReview/abstractions.js\";\n\nexport type PageReadOnlyReasonVm = Pick<TargetReviewPresenter.ViewModel, \"status\" | \"reviewKind\">;\n\nconst NOT_LOADED = \"Read-only until the review status loads.\";\nconst PUBLISHED =\n \"Read-only. The Website Builder only edits draft revisions. Create a new revision to make changes.\";\n\n/*\n * The canvas note of the Website Builder design frames (QBZ-23), switched on `vm.status` and\n * `vm.reviewKind` (R240), never on label text.\n */\nexport function getPageReadOnlyReason(\n vm: PageReadOnlyReasonVm,\n pageStatus: WbStatus\n): string | null {\n if (vm.status === \"loading\" || vm.status === \"failed\") {\n return NOT_LOADED;\n }\n\n if (vm.status === \"noWorkflow\") {\n return null;\n }\n\n if (pageStatus === WbPageStatus.Published) {\n return PUBLISHED;\n }\n\n if (vm.status === \"active\") {\n // The strip's lock line is the read-only reason in every review state.\n return null;\n }\n\n if (pageStatus !== WbPageStatus.Draft) {\n return PUBLISHED;\n }\n\n return null;\n}\n"],"names":["NOT_LOADED","PUBLISHED","getPageReadOnlyReason","vm","pageStatus","WbPageStatus"],"mappings":";AAMA,MAAMA,aAAa;AACnB,MAAMC,YACF;AAMG,SAASC,sBACZC,EAAwB,EACxBC,UAAoB;IAEpB,IAAID,AAAc,cAAdA,GAAG,MAAM,IAAkBA,AAAc,aAAdA,GAAG,MAAM,EACpC,OAAOH;IAGX,IAAIG,AAAc,iBAAdA,GAAG,MAAM,EACT,OAAO;IAGX,IAAIC,eAAeC,aAAa,SAAS,EACrC,OAAOJ;IAGX,IAAIE,AAAc,aAAdA,GAAG,MAAM,EAET,OAAO;IAGX,IAAIC,eAAeC,aAAa,KAAK,EACjC,OAAOJ;IAGX,OAAO;AACX"}
|
|
@@ -3,8 +3,6 @@ import { createFakeVm } from "../../testing/createFakeVm.js";
|
|
|
3
3
|
import { getPageReadOnlyReason } from "./getPageReadOnlyReason.js";
|
|
4
4
|
const NOT_LOADED = "Read-only until the review status loads.";
|
|
5
5
|
const PUBLISHED = "Read-only. The Website Builder only edits draft revisions. Create a new revision to make changes.";
|
|
6
|
-
const APPROVED = "Read-only: this revision has an approved review. Create a new revision to make changes; it needs a new review.";
|
|
7
|
-
const REJECTED = "Read-only: this revision was rejected. Create a new revision to fix it.";
|
|
8
6
|
const CASES = [
|
|
9
7
|
{
|
|
10
8
|
kind: "loading",
|
|
@@ -84,7 +82,7 @@ const CASES = [
|
|
|
84
82
|
{
|
|
85
83
|
kind: "approved",
|
|
86
84
|
page: "draft",
|
|
87
|
-
reason:
|
|
85
|
+
reason: null
|
|
88
86
|
},
|
|
89
87
|
{
|
|
90
88
|
kind: "approved",
|
|
@@ -94,12 +92,12 @@ const CASES = [
|
|
|
94
92
|
{
|
|
95
93
|
kind: "approved",
|
|
96
94
|
page: "unpublished",
|
|
97
|
-
reason:
|
|
95
|
+
reason: null
|
|
98
96
|
},
|
|
99
97
|
{
|
|
100
98
|
kind: "rejected",
|
|
101
99
|
page: "draft",
|
|
102
|
-
reason:
|
|
100
|
+
reason: null
|
|
103
101
|
},
|
|
104
102
|
{
|
|
105
103
|
kind: "rejected",
|
|
@@ -109,7 +107,7 @@ const CASES = [
|
|
|
109
107
|
{
|
|
110
108
|
kind: "rejected",
|
|
111
109
|
page: "unpublished",
|
|
112
|
-
reason:
|
|
110
|
+
reason: null
|
|
113
111
|
}
|
|
114
112
|
];
|
|
115
113
|
describe("getPageReadOnlyReason", ()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/getPageReadOnlyReason.test.js","sources":["../../../src/Components/PageEditor/getPageReadOnlyReason.test.ts"],"sourcesContent":["import { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { createFakeVm } from \"~/testing/createFakeVm.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { getPageReadOnlyReason } from \"./getPageReadOnlyReason.js\";\n\nconst NOT_LOADED = \"Read-only until the review status loads.\";\nconst PUBLISHED =\n \"Read-only. The Website Builder only edits draft revisions. Create a new revision to make changes.\";\
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/getPageReadOnlyReason.test.js","sources":["../../../src/Components/PageEditor/getPageReadOnlyReason.test.ts"],"sourcesContent":["import { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { createFakeVm } from \"~/testing/createFakeVm.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { getPageReadOnlyReason } from \"./getPageReadOnlyReason.js\";\n\nconst NOT_LOADED = \"Read-only until the review status loads.\";\nconst PUBLISHED =\n \"Read-only. The Website Builder only edits draft revisions. Create a new revision to make changes.\";\n\ninterface ReasonCase {\n kind: FakeReviewKind;\n page: WbStatus;\n reason: string | null;\n}\n\nconst CASES: ReasonCase[] = [\n { kind: \"loading\", page: \"draft\", reason: NOT_LOADED },\n { kind: \"loading\", page: \"published\", reason: NOT_LOADED },\n { kind: \"loading\", page: \"unpublished\", reason: NOT_LOADED },\n { kind: \"failed\", page: \"draft\", reason: NOT_LOADED },\n { kind: \"failed\", page: \"published\", reason: NOT_LOADED },\n { kind: \"failed\", page: \"unpublished\", reason: NOT_LOADED },\n { kind: \"noWorkflow\", page: \"draft\", reason: null },\n { kind: \"noWorkflow\", page: \"published\", reason: null },\n { kind: \"noWorkflow\", page: \"unpublished\", reason: null },\n { kind: \"none\", page: \"draft\", reason: null },\n { kind: \"none\", page: \"published\", reason: PUBLISHED },\n { kind: \"none\", page: \"unpublished\", reason: PUBLISHED },\n { kind: \"inProgress\", page: \"draft\", reason: null },\n { kind: \"inProgress\", page: \"published\", reason: PUBLISHED },\n { kind: \"inProgress\", page: \"unpublished\", reason: null },\n { kind: \"approved\", page: \"draft\", reason: null },\n { kind: \"approved\", page: \"published\", reason: PUBLISHED },\n { kind: \"approved\", page: \"unpublished\", reason: null },\n { kind: \"rejected\", page: \"draft\", reason: null },\n { kind: \"rejected\", page: \"published\", reason: PUBLISHED },\n { kind: \"rejected\", page: \"unpublished\", reason: null }\n];\n\ndescribe(\"getPageReadOnlyReason\", () => {\n it.each(CASES)(\"$kind review on a $page page\", ({ kind, page, reason }) => {\n const vm = createFakeVm(kind);\n\n expect(getPageReadOnlyReason(vm, page)).toBe(reason);\n });\n});\n"],"names":["NOT_LOADED","PUBLISHED","CASES","describe","it","kind","page","reason","vm","createFakeVm","expect","getPageReadOnlyReason"],"mappings":";;;AAQA,MAAMA,aAAa;AACnB,MAAMC,YACF;AAQJ,MAAMC,QAAsB;IACxB;QAAE,MAAM;QAAW,MAAM;QAAS,QAAQF;IAAW;IACrD;QAAE,MAAM;QAAW,MAAM;QAAa,QAAQA;IAAW;IACzD;QAAE,MAAM;QAAW,MAAM;QAAe,QAAQA;IAAW;IAC3D;QAAE,MAAM;QAAU,MAAM;QAAS,QAAQA;IAAW;IACpD;QAAE,MAAM;QAAU,MAAM;QAAa,QAAQA;IAAW;IACxD;QAAE,MAAM;QAAU,MAAM;QAAe,QAAQA;IAAW;IAC1D;QAAE,MAAM;QAAc,MAAM;QAAS,QAAQ;IAAK;IAClD;QAAE,MAAM;QAAc,MAAM;QAAa,QAAQ;IAAK;IACtD;QAAE,MAAM;QAAc,MAAM;QAAe,QAAQ;IAAK;IACxD;QAAE,MAAM;QAAQ,MAAM;QAAS,QAAQ;IAAK;IAC5C;QAAE,MAAM;QAAQ,MAAM;QAAa,QAAQC;IAAU;IACrD;QAAE,MAAM;QAAQ,MAAM;QAAe,QAAQA;IAAU;IACvD;QAAE,MAAM;QAAc,MAAM;QAAS,QAAQ;IAAK;IAClD;QAAE,MAAM;QAAc,MAAM;QAAa,QAAQA;IAAU;IAC3D;QAAE,MAAM;QAAc,MAAM;QAAe,QAAQ;IAAK;IACxD;QAAE,MAAM;QAAY,MAAM;QAAS,QAAQ;IAAK;IAChD;QAAE,MAAM;QAAY,MAAM;QAAa,QAAQA;IAAU;IACzD;QAAE,MAAM;QAAY,MAAM;QAAe,QAAQ;IAAK;IACtD;QAAE,MAAM;QAAY,MAAM;QAAS,QAAQ;IAAK;IAChD;QAAE,MAAM;QAAY,MAAM;QAAa,QAAQA;IAAU;IACzD;QAAE,MAAM;QAAY,MAAM;QAAe,QAAQ;IAAK;CACzD;AAEDE,SAAS,yBAAyB;IAC9BC,GAAG,IAAI,CAACF,OAAO,gCAAgC,CAAC,EAAEG,IAAI,EAAEC,IAAI,EAAEC,MAAM,EAAE;QAClE,MAAMC,KAAKC,aAAaJ;QAExBK,OAAOC,sBAAsBH,IAAIF,OAAO,IAAI,CAACC;IACjD;AACJ"}
|
|
@@ -43,11 +43,9 @@ vi.mock("@webiny/app-workflows/review/editor/components/EditorReviewBar.js", asy
|
|
|
43
43
|
EditorReviewBar
|
|
44
44
|
};
|
|
45
45
|
});
|
|
46
|
-
const { Ui
|
|
46
|
+
const { Ui } = PageEditorConfig;
|
|
47
47
|
const NOT_LOADED = "Read-only until the review status loads.";
|
|
48
48
|
const PUBLISHED = "Read-only. The Website Builder only edits draft revisions. Create a new revision to make changes.";
|
|
49
|
-
const APPROVED = "Read-only: this revision has an approved review. Create a new revision to make changes; it needs a new review.";
|
|
50
|
-
const REJECTED = "Read-only: this revision was rejected. Create a new revision to fix it.";
|
|
51
49
|
const MATRIX = [
|
|
52
50
|
{
|
|
53
51
|
kind: "loading",
|
|
@@ -158,7 +156,7 @@ const MATRIX = [
|
|
|
158
156
|
kind: "approved",
|
|
159
157
|
page: "draft",
|
|
160
158
|
bar: true,
|
|
161
|
-
note:
|
|
159
|
+
note: null,
|
|
162
160
|
readOnly: true
|
|
163
161
|
},
|
|
164
162
|
{
|
|
@@ -172,14 +170,14 @@ const MATRIX = [
|
|
|
172
170
|
kind: "approved",
|
|
173
171
|
page: "unpublished",
|
|
174
172
|
bar: true,
|
|
175
|
-
note:
|
|
173
|
+
note: null,
|
|
176
174
|
readOnly: true
|
|
177
175
|
},
|
|
178
176
|
{
|
|
179
177
|
kind: "rejected",
|
|
180
178
|
page: "draft",
|
|
181
179
|
bar: true,
|
|
182
|
-
note:
|
|
180
|
+
note: null,
|
|
183
181
|
readOnly: true
|
|
184
182
|
},
|
|
185
183
|
{
|
|
@@ -193,7 +191,7 @@ const MATRIX = [
|
|
|
193
191
|
kind: "rejected",
|
|
194
192
|
page: "unpublished",
|
|
195
193
|
bar: true,
|
|
196
|
-
note:
|
|
194
|
+
note: null,
|
|
197
195
|
readOnly: true
|
|
198
196
|
}
|
|
199
197
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/pageReviewMatrix.test.js","sources":["../../../src/Components/PageEditor/pageReviewMatrix.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport { registerPageContent } from \"~/testing/registerPageContent.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageEditorLayout } from \"./PageEditorLayout.js\";\nimport { PageEditorTopBar } from \"./PageEditorTopBar.js\";\n\nvi.mock(\"@webiny/icons/info.svg\", () => {\n return { ReactComponent: () => null };\n});\n\nvi.mock(\"@webiny/app-website-builder/BaseEditor/config/Layout.js\", async () => {\n const React = await import(\"react\");\n const { makeDecoratable } = await import(\"@webiny/react-composition\");\n const Layout = makeDecoratable(\"EditorLayout\", () => {\n return React.createElement(\"div\", { \"data-testid\": \"base-layout\" });\n });\n return { Layout };\n});\n\nvi.mock(\"@webiny/app-website-builder/BaseEditor/config/TopBar/Layout.js\", async () => {\n const React = await import(\"react\");\n const { makeDecoratable } = await import(\"@webiny/react-composition\");\n const Layout = makeDecoratable(\"TopBarLayout\", () => {\n return React.createElement(\"div\", { \"data-testid\": \"base-top-bar\" });\n });\n return { Layout, TopBarOptionsMenu: () => null };\n});\n\nvi.mock(\"@webiny/app-workflows/review/editor/components/EditorReviewBar.js\", async () => {\n const React = await import(\"react\");\n const EditorReviewBar = () => {\n return React.createElement(\"div\", { \"data-testid\": \"review-bar\" });\n };\n return { EditorReviewBar };\n});\n\nconst { Ui } = PageEditorConfig;\n\nconst NOT_LOADED = \"Read-only until the review status loads.\";\nconst PUBLISHED =\n \"Read-only. The Website Builder only edits draft revisions. Create a new revision to make changes.\";\
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/pageReviewMatrix.test.js","sources":["../../../src/Components/PageEditor/pageReviewMatrix.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport { registerPageContent } from \"~/testing/registerPageContent.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageEditorLayout } from \"./PageEditorLayout.js\";\nimport { PageEditorTopBar } from \"./PageEditorTopBar.js\";\n\nvi.mock(\"@webiny/icons/info.svg\", () => {\n return { ReactComponent: () => null };\n});\n\nvi.mock(\"@webiny/app-website-builder/BaseEditor/config/Layout.js\", async () => {\n const React = await import(\"react\");\n const { makeDecoratable } = await import(\"@webiny/react-composition\");\n const Layout = makeDecoratable(\"EditorLayout\", () => {\n return React.createElement(\"div\", { \"data-testid\": \"base-layout\" });\n });\n return { Layout };\n});\n\nvi.mock(\"@webiny/app-website-builder/BaseEditor/config/TopBar/Layout.js\", async () => {\n const React = await import(\"react\");\n const { makeDecoratable } = await import(\"@webiny/react-composition\");\n const Layout = makeDecoratable(\"TopBarLayout\", () => {\n return React.createElement(\"div\", { \"data-testid\": \"base-top-bar\" });\n });\n return { Layout, TopBarOptionsMenu: () => null };\n});\n\nvi.mock(\"@webiny/app-workflows/review/editor/components/EditorReviewBar.js\", async () => {\n const React = await import(\"react\");\n const EditorReviewBar = () => {\n return React.createElement(\"div\", { \"data-testid\": \"review-bar\" });\n };\n return { EditorReviewBar };\n});\n\nconst { Ui } = PageEditorConfig;\n\nconst NOT_LOADED = \"Read-only until the review status loads.\";\nconst PUBLISHED =\n \"Read-only. The Website Builder only edits draft revisions. Create a new revision to make changes.\";\n\ninterface MatrixCase {\n kind: FakeReviewKind;\n page: WbStatus;\n bar: boolean;\n note: string | null;\n readOnly: boolean;\n}\n\nconst MATRIX: MatrixCase[] = [\n { kind: \"loading\", page: \"draft\", bar: true, note: NOT_LOADED, readOnly: true },\n { kind: \"loading\", page: \"published\", bar: true, note: NOT_LOADED, readOnly: true },\n { kind: \"loading\", page: \"unpublished\", bar: true, note: NOT_LOADED, readOnly: true },\n { kind: \"failed\", page: \"draft\", bar: true, note: NOT_LOADED, readOnly: true },\n { kind: \"failed\", page: \"published\", bar: true, note: NOT_LOADED, readOnly: true },\n { kind: \"failed\", page: \"unpublished\", bar: true, note: NOT_LOADED, readOnly: true },\n { kind: \"noWorkflow\", page: \"draft\", bar: false, note: null, readOnly: false },\n { kind: \"noWorkflow\", page: \"published\", bar: false, note: null, readOnly: true },\n { kind: \"noWorkflow\", page: \"unpublished\", bar: false, note: null, readOnly: true },\n { kind: \"none\", page: \"draft\", bar: true, note: null, readOnly: false },\n { kind: \"none\", page: \"published\", bar: true, note: PUBLISHED, readOnly: true },\n { kind: \"none\", page: \"unpublished\", bar: true, note: PUBLISHED, readOnly: true },\n { kind: \"inProgress\", page: \"draft\", bar: true, note: null, readOnly: true },\n { kind: \"inProgress\", page: \"published\", bar: true, note: PUBLISHED, readOnly: true },\n { kind: \"inProgress\", page: \"unpublished\", bar: true, note: null, readOnly: true },\n { kind: \"approved\", page: \"draft\", bar: true, note: null, readOnly: true },\n { kind: \"approved\", page: \"published\", bar: true, note: PUBLISHED, readOnly: true },\n { kind: \"approved\", page: \"unpublished\", bar: true, note: null, readOnly: true },\n { kind: \"rejected\", page: \"draft\", bar: true, note: null, readOnly: true },\n { kind: \"rejected\", page: \"published\", bar: true, note: PUBLISHED, readOnly: true },\n { kind: \"rejected\", page: \"unpublished\", bar: true, note: null, readOnly: true }\n];\n\ndescribe(\"review status x page status (bar, note and canvas)\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it.each(MATRIX)(\"$kind review on a $page page\", ({ kind, page, bar, note, readOnly }) => {\n const handle = createFakeSession(kind, page === \"unpublished\");\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n registerPageContent(container);\n const editor = createPageEditor(page);\n\n render(\n <WbEditorHarness container={container} editor={editor}>\n <PageEditorTopBar />\n <PageEditorLayout />\n <Ui.Layout />\n <Ui.TopBar.Layout />\n </WbEditorHarness>\n );\n\n const bars = screen.queryAllByTestId(\"review-bar\");\n expect(bars).toHaveLength(bar ? 1 : 0);\n const alert = screen.queryByRole(\"alert\");\n if (note === null) {\n expect(alert).toBeNull();\n } else {\n expect(alert?.textContent).toContain(note);\n }\n expect(editor.getEditorState().read().isReadOnly).toBe(readOnly);\n });\n});\n"],"names":["vi","React","makeDecoratable","Layout","EditorReviewBar","Ui","PageEditorConfig","NOT_LOADED","PUBLISHED","MATRIX","describe","afterEach","cleanup","it","kind","page","bar","note","readOnly","handle","createFakeSession","container","Container","WbPageReview","registerPageContent","editor","createPageEditor","render","WbEditorHarness","PageEditorTopBar","PageEditorLayout","bars","screen","expect","alert"],"mappings":";;;;;;;;;;;;AAqBAA,GAAG,IAAI,CAAC,0BAA0B,IACvB;QAAE,gBAAgB,IAAM;IAAK;AAGxCA,GAAG,IAAI,CAAC,2DAA2D;IAC/D,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAC3B,MAAM,EAAEC,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC;IACzC,MAAMC,SAASD,gBAAgB,gBAAgB,IACpCD,MAAM,aAAa,CAAC,OAAO;YAAE,eAAe;QAAc;IAErE,OAAO;QAAEE;IAAO;AACpB;AAEAH,GAAG,IAAI,CAAC,kEAAkE;IACtE,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAC3B,MAAM,EAAEC,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC;IACzC,MAAMC,SAASD,gBAAgB,gBAAgB,IACpCD,MAAM,aAAa,CAAC,OAAO;YAAE,eAAe;QAAe;IAEtE,OAAO;QAAEE;QAAQ,mBAAmB,IAAM;IAAK;AACnD;AAEAH,GAAG,IAAI,CAAC,qEAAqE;IACzE,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAC3B,MAAMG,kBAAkB,IACbH,MAAM,aAAa,CAAC,OAAO;YAAE,eAAe;QAAa;IAEpE,OAAO;QAAEG;IAAgB;AAC7B;AAEA,MAAM,EAAEC,EAAE,EAAE,GAAGC;AAEf,MAAMC,aAAa;AACnB,MAAMC,YACF;AAUJ,MAAMC,SAAuB;IACzB;QAAE,MAAM;QAAW,MAAM;QAAS,KAAK;QAAM,MAAMF;QAAY,UAAU;IAAK;IAC9E;QA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IAAK;IAC/E;QAAE,MAAM;QAAY,MAAM;QAAS,KAAK;QAAM,MAAM;QAAM,UAAU;IAAK;IACzE;QAAE,MAAM;QAAY,MAAM;QAAa,KAAK;QAAM,MAAMA;QAAW,UAAU;IAAK;IAClF;QAAE,MAAM;QAAY,MAAM;QAAe,KAAK;QAAM,MAAM;QAAM,UAAU;IAAK;CAClF;AAEDE,SAAS,sDAAsD;IAC3DC,UAAU;QACNC;IACJ;IAEAC,GAAG,IAAI,CAACJ,QAAQ,gCAAgC,CAAC,EAAEK,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,IAAI,EAAEC,QAAQ,EAAE;QAChF,MAAMC,SAASC,kBAAkBN,MAAMC,AAAS,kBAATA;QACvC,MAAMM,YAAY,IAAIC;QACtBD,UAAU,gBAAgB,CAACE,cAAcJ,OAAO,OAAO;QACvDK,oBAAoBH;QACpB,MAAMI,SAASC,iBAAiBX;QAEhCY,OAAO,WAADA,GACF,oBAACC,iBAAeA;YAAC,WAAWP;YAAW,QAAQI;yBAC3C,oBAACI,kBAAgBA,OAAAA,WAAAA,GACjB,oBAACC,kBAAgBA,OAAAA,WAAAA,GACjB,oBAACzB,GAAG,MAAM,uBACV,oBAACA,GAAG,MAAM,CAAC,MAAM;QAIzB,MAAM0B,OAAOC,OAAO,gBAAgB,CAAC;QACrCC,OAAOF,MAAM,YAAY,CAACf,MAAM,IAAI;QACpC,MAAMkB,QAAQF,OAAO,WAAW,CAAC;QACjC,IAAIf,AAAS,SAATA,MACAgB,OAAOC,OAAO,QAAQ;aAEtBD,OAAOC,OAAO,aAAa,SAAS,CAACjB;QAEzCgB,OAAOR,OAAO,cAAc,GAAG,IAAI,GAAG,UAAU,EAAE,IAAI,CAACP;IAC3D;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/publishMatrix.test.js","sources":["../../../src/Components/PageEditor/publishMatrix.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { act } from \"@testing-library/react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { waitFor } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { InternalPageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageBasePublishDecorator } from \"./PageBasePublishDecorator.js\";\nimport { PageEditorLayout } from \"./PageEditorLayout.js\";\nimport { PageReviewPublishAction } from \"./PageReviewPublishAction.js\";\n\nvi.mock(\"@webiny/icons/publish.svg\", () => {\n return { ReactComponent: () => null };\n});\n\nvi.mock(\n \"@webiny/app-website-builder/presentation/pages/PageEditor/TopBar/PublishButton.js\",\n async () => {\n const React = await import(\"react\");\n const PublishButton = () => {\n return React.createElement(\"button\", { \"data-testid\": \"enabled-publish\" }, \"Publish\");\n };\n return { PublishButton };\n }\n);\n\nvi.mock(\n \"@webiny/app-workflows/review/presentation/targetReview/components/ReviewTooltip.js\",\n async () => {\n const React = await import(\"react\");\n interface StubProps {\n presenter: { vm: { publishDisabledReason: string | null } };\n children: (describedBy: string) => React.ReactNode;\n }\n const ReviewTooltip = (props: StubProps) => {\n const reason = props.presenter.vm.publishDisabledReason ?? \"\";\n return React.createElement(\n \"span\",\n { \"data-testid\": \"review-tooltip\", \"data-reason\": reason },\n props.children(\"tooltip-description\")\n );\n };\n return { ReviewTooltip };\n }\n);\n\ninterface PermissionRequest {\n entity: string;\n action: string;\n}\n\nconst permission = vi.hoisted(() => {\n return { allowed: true, requests: [] as PermissionRequest[] };\n});\n\nvi.mock(\"@webiny/app-website-builder/presentation/security/HasPermission.js\", async () => {\n const React = await import(\"react\");\n interface PermissionGateProps {\n entity: string;\n action: string;\n children: React.ReactNode;\n }\n const HasPermission = (props: PermissionGateProps) => {\n permission.requests.push({ entity: props.entity, action: props.action });\n if (!permission.allowed) {\n return null;\n }\n return React.createElement(React.Fragment, null, props.children);\n };\n return { HasPermission };\n});\n\nvi.mock(\"@webiny/app-website-builder/BaseEditor/config/Layout.js\", async () => {\n const React = await import(\"react\");\n const { makeDecoratable } = await import(\"@webiny/react-composition\");\n const Layout = makeDecoratable(\"EditorLayout\", () => {\n return React.createElement(\"div\", { \"data-testid\": \"base-layout\" });\n });\n return { Layout };\n});\n\nconst { Ui } = PageEditorConfig;\n\ninterface PublishCase {\n kind: FakeReviewKind;\n page: WbStatus;\n base: boolean;\n enabled: boolean;\n disabled: boolean;\n}\n\n/**\n * `base` is the base Publish (only for a workflow-less namespace on an editable canvas), `enabled` the\n * workflows Publish that publishes, `disabled` the focusable disabled one. The reasons are not\n * repeated here: they come from the real `getEditorRules` through the fixture and are pinned by Task 13.\n */\nconst MATRIX: PublishCase[] = [\n { kind: \"loading\", page: \"draft\", base: false, enabled: false, disabled: true },\n { kind: \"loading\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"loading\", page: \"unpublished\", base: false, enabled: false, disabled: true },\n { kind: \"failed\", page: \"draft\", base: false, enabled: false, disabled: true },\n { kind: \"failed\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"failed\", page: \"unpublished\", base: false, enabled: false, disabled: true },\n { kind: \"noWorkflow\", page: \"draft\", base: true, enabled: false, disabled: false },\n { kind: \"noWorkflow\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"noWorkflow\", page: \"unpublished\", base: false, enabled: false, disabled: false },\n { kind: \"none\", page: \"draft\", base: false, enabled: false, disabled: true },\n { kind: \"none\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"none\", page: \"unpublished\", base: false, enabled: true, disabled: false },\n { kind: \"inProgress\", page: \"draft\", base: false, enabled: false, disabled: true },\n { kind: \"inProgress\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"inProgress\", page: \"unpublished\", base: false, enabled: false, disabled: true },\n { kind: \"approved\", page: \"draft\", base: false, enabled: true, disabled: false },\n { kind: \"approved\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"approved\", page: \"unpublished\", base: false, enabled: true, disabled: false },\n { kind: \"rejected\", page: \"draft\", base: false, enabled: false, disabled: true },\n { kind: \"rejected\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"rejected\", page: \"unpublished\", base: false, enabled: false, disabled: true }\n];\n\nconst mountPublish = (pageStatus: WbStatus, kind: FakeReviewKind) => {\n const handle = createFakeSession(kind, pageStatus === \"unpublished\");\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n const editor = createPageEditor(pageStatus);\n\n render(\n <WbEditorHarness container={container} editor={editor} groups={[\"actions\"]}>\n <PageEditorLayout />\n <Ui.Layout />\n <PageBasePublishDecorator />\n <InternalPageEditorConfig>\n <Ui.TopBar.Action name={\"sentinel\"} element={<span data-testid={\"sentinel\"} />} />\n <Ui.IsNotReadOnly>\n <Ui.TopBar.Action\n name={\"buttonPublish\"}\n element={<span data-testid={\"base-publish\"} />}\n />\n </Ui.IsNotReadOnly>\n </InternalPageEditorConfig>\n <PageEditorConfig>\n <PageReviewPublishAction />\n </PageEditorConfig>\n </WbEditorHarness>\n );\n\n return { ...handle, editor };\n};\n\nconst getDisabledButtons = (): HTMLElement[] => {\n return Array.from(document.querySelectorAll<HTMLElement>(\"button[aria-disabled='true']\"));\n};\n\ndescribe(\"Publish by review status and page status\", () => {\n afterEach(() => {\n cleanup();\n permission.allowed = true;\n permission.requests = [];\n });\n\n it.each(MATRIX)(\n \"$kind review on a $page page\",\n async ({ kind, page, base, enabled, disabled }) => {\n const { presenter } = mountPublish(page, kind);\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"base-publish\")).toHaveLength(base ? 1 : 0);\n expect(screen.queryAllByTestId(\"enabled-publish\")).toHaveLength(enabled ? 1 : 0);\n expect(getDisabledButtons()).toHaveLength(disabled ? 1 : 0);\n });\n\n if (disabled) {\n const button = getDisabledButtons()[0];\n const tooltip = button.closest(\"[data-testid='review-tooltip']\");\n const reason = presenter.vm.publishDisabledReason;\n expect(reason).not.toBeNull();\n expect(tooltip?.getAttribute(\"data-reason\")).toBe(reason);\n }\n }\n );\n\n it(\"an approved, unpublished page shows an enabled Publish although the canvas is read-only\", async () => {\n const { editor } = mountPublish(\"unpublished\", \"approved\");\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"enabled-publish\")).toHaveLength(1);\n });\n expect(editor.getEditorState().read().isReadOnly).toBe(true);\n expect(screen.queryAllByTestId(\"base-publish\")).toHaveLength(0);\n });\n\n it(\"an unpublished page with no review shows an enabled Publish: it was reviewed before it was published (Q19)\", async () => {\n const { editor } = mountPublish(\"unpublished\", \"none\");\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"enabled-publish\")).toHaveLength(1);\n });\n expect(editor.getEditorState().read().isReadOnly).toBe(true);\n expect(getDisabledButtons()).toHaveLength(0);\n expect(screen.queryAllByTestId(\"base-publish\")).toHaveLength(0);\n });\n\n it(\"follows the review while the editor is open: approval turns the disabled Publish on\", async () => {\n const { setKind } = mountPublish(\"draft\", \"inProgress\");\n await screen.findByTestId(\"sentinel\");\n await waitFor(() => {\n expect(getDisabledButtons()).toHaveLength(1);\n });\n\n act(() => {\n setKind(\"approved\");\n });\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"enabled-publish\")).toHaveLength(1);\n });\n expect(getDisabledButtons()).toHaveLength(0);\n });\n\n it(\"shows no workflows Publish to a user without the page publish permission\", async () => {\n permission.allowed = false;\n mountPublish(\"draft\", \"approved\");\n await screen.findByTestId(\"sentinel\");\n await act(async () => {});\n\n expect(permission.requests).toContainEqual({ entity: \"page\", action: \"publish\" });\n expect(screen.queryAllByTestId(\"enabled-publish\")).toHaveLength(0);\n expect(getDisabledButtons()).toHaveLength(0);\n });\n});\n"],"names":["vi","React","PublishButton","ReviewTooltip","props","reason","permission","HasPermission","makeDecoratable","Layout","Ui","PageEditorConfig","MATRIX","mountPublish","pageStatus","kind","handle","createFakeSession","container","Container","WbPageReview","editor","createPageEditor","render","WbEditorHarness","PageEditorLayout","PageBasePublishDecorator","InternalPageEditorConfig","PageReviewPublishAction","getDisabledButtons","Array","document","describe","afterEach","cleanup","it","page","base","enabled","disabled","presenter","screen","waitFor","expect","button","tooltip","setKind","act"],"mappings":";;;;;;;;;;;;AAwBAA,GAAG,IAAI,CAAC,6BAA6B,IAC1B;QAAE,gBAAgB,IAAM;IAAK;AAGxCA,GAAG,IAAI,CACH,qFACA;IACI,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAC3B,MAAMC,gBAAgB,IACXD,MAAM,aAAa,CAAC,UAAU;YAAE,eAAe;QAAkB,GAAG;IAE/E,OAAO;QAAEC;IAAc;AAC3B;AAGJF,GAAG,IAAI,CACH,sFACA;IACI,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAK3B,MAAME,gBAAgB,CAACC;QACnB,MAAMC,SAASD,MAAM,SAAS,CAAC,EAAE,CAAC,qBAAqB,IAAI;QAC3D,OAAOH,MAAM,aAAa,CACtB,QACA;YAAE,eAAe;YAAkB,eAAeI;QAAO,GACzDD,MAAM,QAAQ,CAAC;IAEvB;IACA,OAAO;QAAED;IAAc;AAC3B;AAQJ,MAAMG,aAAaN,GAAG,OAAO,CAAC,IACnB;QAAE,SAAS;QAAM,UAAU,EAAE;IAAwB;AAGhEA,GAAG,IAAI,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AAC;YAAE,QAAQ;YAAQ,QAAQ;QAAU;QAC/EqC,OAAOF,OAAO,gBAAgB,CAAC,oBAAoB,YAAY,CAAC;QAChEE,OAAOd,sBAAsB,YAAY,CAAC;IAC9C;AACJ"}
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/publishMatrix.test.js","sources":["../../../src/Components/PageEditor/publishMatrix.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { act } from \"@testing-library/react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { waitFor } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { InternalPageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageBasePublishDecorator } from \"./PageBasePublishDecorator.js\";\nimport { PageEditorLayout } from \"./PageEditorLayout.js\";\nimport { PageReviewPublishAction } from \"./PageReviewPublishAction.js\";\n\nvi.mock(\"@webiny/icons/publish.svg\", () => {\n return { ReactComponent: () => null };\n});\n\nvi.mock(\n \"@webiny/app-website-builder/presentation/pages/PageEditor/TopBar/PublishButton.js\",\n async () => {\n const React = await import(\"react\");\n const PublishButton = () => {\n return React.createElement(\"button\", { \"data-testid\": \"enabled-publish\" }, \"Publish\");\n };\n return { PublishButton };\n }\n);\n\nvi.mock(\n \"@webiny/app-workflows/review/presentation/targetReview/components/ReviewTooltip.js\",\n async () => {\n const React = await import(\"react\");\n interface StubProps {\n presenter: { vm: { publishDisabledReason: string | null } };\n children: (describedBy: string) => React.ReactNode;\n }\n const ReviewTooltip = (props: StubProps) => {\n const reason = props.presenter.vm.publishDisabledReason ?? \"\";\n return React.createElement(\n \"span\",\n { \"data-testid\": \"review-tooltip\", \"data-reason\": reason },\n props.children(\"tooltip-description\")\n );\n };\n return { ReviewTooltip };\n }\n);\n\ninterface PermissionRequest {\n entity: string;\n action: string;\n}\n\nconst permission = vi.hoisted(() => {\n return { allowed: true, requests: [] as PermissionRequest[] };\n});\n\nvi.mock(\"@webiny/app-website-builder/presentation/security/HasPermission.js\", async () => {\n const React = await import(\"react\");\n interface PermissionGateProps {\n entity: string;\n action: string;\n children: React.ReactNode;\n }\n const HasPermission = (props: PermissionGateProps) => {\n permission.requests.push({ entity: props.entity, action: props.action });\n if (!permission.allowed) {\n return null;\n }\n return React.createElement(React.Fragment, null, props.children);\n };\n return { HasPermission };\n});\n\nvi.mock(\"@webiny/app-website-builder/BaseEditor/config/Layout.js\", async () => {\n const React = await import(\"react\");\n const { makeDecoratable } = await import(\"@webiny/react-composition\");\n const Layout = makeDecoratable(\"EditorLayout\", () => {\n return React.createElement(\"div\", { \"data-testid\": \"base-layout\" });\n });\n return { Layout };\n});\n\nconst { Ui } = PageEditorConfig;\n\ninterface PublishCase {\n kind: FakeReviewKind;\n page: WbStatus;\n base: boolean;\n enabled: boolean;\n disabled: boolean;\n}\n\n/**\n * `base` is the base Publish (only for a workflow-less namespace on an editable canvas), `enabled` the\n * workflows Publish that publishes, `disabled` the focusable disabled one. The reasons are not\n * repeated here: they come from the real `getEditorRules` through the fixture and are pinned by Task 13.\n */\nconst MATRIX: PublishCase[] = [\n { kind: \"loading\", page: \"draft\", base: false, enabled: false, disabled: true },\n { kind: \"loading\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"loading\", page: \"unpublished\", base: false, enabled: false, disabled: true },\n { kind: \"failed\", page: \"draft\", base: false, enabled: false, disabled: true },\n { kind: \"failed\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"failed\", page: \"unpublished\", base: false, enabled: false, disabled: true },\n { kind: \"noWorkflow\", page: \"draft\", base: true, enabled: false, disabled: false },\n { kind: \"noWorkflow\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"noWorkflow\", page: \"unpublished\", base: false, enabled: false, disabled: false },\n { kind: \"none\", page: \"draft\", base: false, enabled: false, disabled: true },\n { kind: \"none\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"none\", page: \"unpublished\", base: false, enabled: true, disabled: false },\n { kind: \"inProgress\", page: \"draft\", base: false, enabled: false, disabled: true },\n { kind: \"inProgress\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"inProgress\", page: \"unpublished\", base: false, enabled: false, disabled: true },\n { kind: \"approved\", page: \"draft\", base: false, enabled: true, disabled: false },\n { kind: \"approved\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"approved\", page: \"unpublished\", base: false, enabled: true, disabled: false },\n { kind: \"rejected\", page: \"draft\", base: false, enabled: false, disabled: true },\n { kind: \"rejected\", page: \"published\", base: false, enabled: false, disabled: false },\n { kind: \"rejected\", page: \"unpublished\", base: false, enabled: false, disabled: true }\n];\n\nconst mountPublish = (pageStatus: WbStatus, kind: FakeReviewKind) => {\n const handle = createFakeSession(kind, pageStatus === \"unpublished\");\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n const editor = createPageEditor(pageStatus);\n\n render(\n <WbEditorHarness container={container} editor={editor} groups={[\"actions\"]}>\n <PageEditorLayout />\n <Ui.Layout />\n <PageBasePublishDecorator />\n <InternalPageEditorConfig>\n <Ui.TopBar.Action name={\"sentinel\"} element={<span data-testid={\"sentinel\"} />} />\n <Ui.IsNotReadOnly>\n <Ui.TopBar.Action\n name={\"buttonPublish\"}\n element={<span data-testid={\"base-publish\"} />}\n />\n </Ui.IsNotReadOnly>\n </InternalPageEditorConfig>\n <PageEditorConfig>\n <PageReviewPublishAction />\n </PageEditorConfig>\n </WbEditorHarness>\n );\n\n return { ...handle, editor };\n};\n\nconst getDisabledButtons = (): HTMLElement[] => {\n return Array.from(document.querySelectorAll<HTMLElement>(\"button[aria-disabled='true']\"));\n};\n\ndescribe(\"Publish by review status and page status\", () => {\n afterEach(() => {\n cleanup();\n permission.allowed = true;\n permission.requests = [];\n });\n\n it.each(MATRIX)(\n \"$kind review on a $page page\",\n async ({ kind, page, base, enabled, disabled }) => {\n const { presenter } = mountPublish(page, kind);\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"base-publish\")).toHaveLength(base ? 1 : 0);\n expect(screen.queryAllByTestId(\"enabled-publish\")).toHaveLength(enabled ? 1 : 0);\n expect(getDisabledButtons()).toHaveLength(disabled ? 1 : 0);\n });\n\n if (disabled) {\n const button = getDisabledButtons()[0];\n const tooltip = button.closest(\"[data-testid='review-tooltip']\");\n const reason = presenter.vm.publishDisabledReason;\n expect(reason).not.toBeNull();\n expect(tooltip?.getAttribute(\"data-reason\")).toBe(reason);\n }\n }\n );\n\n it(\"an approved, unpublished page shows an enabled Publish although the canvas is read-only\", async () => {\n const { editor } = mountPublish(\"unpublished\", \"approved\");\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"enabled-publish\")).toHaveLength(1);\n });\n expect(editor.getEditorState().read().isReadOnly).toBe(true);\n expect(screen.queryAllByTestId(\"base-publish\")).toHaveLength(0);\n });\n\n it(\"an unpublished page with no review shows an enabled Publish: it was reviewed before it was published (Q19)\", async () => {\n const { editor } = mountPublish(\"unpublished\", \"none\");\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"enabled-publish\")).toHaveLength(1);\n });\n expect(editor.getEditorState().read().isReadOnly).toBe(true);\n expect(getDisabledButtons()).toHaveLength(0);\n expect(screen.queryAllByTestId(\"base-publish\")).toHaveLength(0);\n });\n\n it(\"follows the review while the editor is open: approval turns the disabled Publish on\", async () => {\n const { setKind } = mountPublish(\"draft\", \"inProgress\");\n await screen.findByTestId(\"sentinel\");\n await waitFor(() => {\n expect(getDisabledButtons()).toHaveLength(1);\n });\n\n act(() => {\n setKind(\"approved\");\n });\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"enabled-publish\")).toHaveLength(1);\n });\n expect(getDisabledButtons()).toHaveLength(0);\n });\n\n it(\"shows no workflows Publish to a user without the page publish permission\", async () => {\n permission.allowed = false;\n mountPublish(\"draft\", \"approved\");\n await screen.findByTestId(\"sentinel\");\n await act(async () => {});\n\n expect(permission.requests).toContainEqual({ entity: \"page\", action: \"publish\" });\n expect(screen.queryAllByTestId(\"enabled-publish\")).toHaveLength(0);\n expect(getDisabledButtons()).toHaveLength(0);\n });\n});\n"],"names":["vi","React","PublishButton","ReviewTooltip","props","reason","permission","HasPermission","makeDecoratable","Layout","Ui","PageEditorConfig","MATRIX","mountPublish","pageStatus","kind","handle","createFakeSession","container","Container","WbPageReview","editor","createPageEditor","render","WbEditorHarness","PageEditorLayout","PageBasePublishDecorator","InternalPageEditorConfig","PageReviewPublishAction","getDisabledButtons","Array","document","describe","afterEach","cleanup","it","page","base","enabled","disabled","presenter","screen","waitFor","expect","button","tooltip","setKind","act"],"mappings":";;;;;;;;;;;;AAwBAA,GAAG,IAAI,CAAC,6BAA6B,IAC1B;QAAE,gBAAgB,IAAM;IAAK;AAGxCA,GAAG,IAAI,CACH,qFACA;IACI,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAC3B,MAAMC,gBAAgB,IACXD,MAAM,aAAa,CAAC,UAAU;YAAE,eAAe;QAAkB,GAAG;IAE/E,OAAO;QAAEC;IAAc;AAC3B;AAGJF,GAAG,IAAI,CACH,sFACA;IACI,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAK3B,MAAME,gBAAgB,CAACC;QACnB,MAAMC,SAASD,MAAM,SAAS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OF,OAAO,gBAAgB,CAAC,oBAAoB,YAAY,CAAC;QACpE;QACAE,OAAOd,sBAAsB,YAAY,CAAC;IAC9C;IAEAM,GAAG,4EAA4E;QAC3E7B,WAAW,OAAO,GAAG;QACrBO,aAAa,SAAS;QACtB,MAAM4B,OAAO,YAAY,CAAC;QAC1B,MAAMM,IAAI,WAAa;QAEvBJ,OAAOrC,WAAW,QAAQ,EAAE,cAAc,CAAC;YAAE,QAAQ;YAAQ,QAAQ;QAAU;QAC/EqC,OAAOF,OAAO,gBAAgB,CAAC,oBAAoB,YAAY,CAAC;QAChEE,OAAOd,sBAAsB,YAAY,CAAC;IAC9C;AACJ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import react, { useId } from "react";
|
|
2
|
+
import { BulkActionButton } from "@webiny/app-admin/components/BulkActions/index.js";
|
|
3
|
+
import { ReactComponent } from "@webiny/icons/visibility.svg";
|
|
4
|
+
import { ignoreAction } from "./ignoreAction.js";
|
|
5
|
+
const PageBulkPublishBlocked = ({ reason })=>{
|
|
6
|
+
const descriptionId = useId();
|
|
7
|
+
return /*#__PURE__*/ react.createElement("span", {
|
|
8
|
+
"aria-describedby": descriptionId
|
|
9
|
+
}, /*#__PURE__*/ react.createElement(BulkActionButton, {
|
|
10
|
+
text: "Publish",
|
|
11
|
+
tooltipContent: reason,
|
|
12
|
+
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
13
|
+
disabled: true,
|
|
14
|
+
onClick: ignoreAction,
|
|
15
|
+
"data-testid": "wb.page-list.bulk.publish.blocked"
|
|
16
|
+
}), /*#__PURE__*/ react.createElement("span", {
|
|
17
|
+
id: descriptionId,
|
|
18
|
+
className: "sr-only"
|
|
19
|
+
}, reason));
|
|
20
|
+
};
|
|
21
|
+
export { PageBulkPublishBlocked };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=PageBulkPublishBlocked.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Components/PagesList/PageBulkPublishBlocked.js","sources":["../../../src/Components/PagesList/PageBulkPublishBlocked.tsx"],"sourcesContent":["import React, { useId } from \"react\";\nimport { BulkActionButton } from \"@webiny/app-admin/components/BulkActions/index.js\";\nimport { ReactComponent as PublishIcon } from \"@webiny/icons/visibility.svg\";\nimport { ignoreAction } from \"./ignoreAction.js\";\n\nexport interface PageBulkPublishBlockedProps {\n reason: string;\n}\n\n/*\n * The bulk \"Publish\" shown disabled, with the reason as its tooltip and for assistive technology.\n */\nexport const PageBulkPublishBlocked = ({ reason }: PageBulkPublishBlockedProps) => {\n const descriptionId = useId();\n\n return (\n <span aria-describedby={descriptionId}>\n <BulkActionButton\n text=\"Publish\"\n tooltipContent={reason}\n icon={<PublishIcon />}\n disabled={true}\n onClick={ignoreAction}\n data-testid={\"wb.page-list.bulk.publish.blocked\"}\n />\n <span id={descriptionId} className={\"sr-only\"}>\n {reason}\n </span>\n </span>\n );\n};\n"],"names":["PageBulkPublishBlocked","reason","descriptionId","useId","BulkActionButton","PublishIcon","ignoreAction"],"mappings":";;;;AAYO,MAAMA,yBAAyB,CAAC,EAAEC,MAAM,EAA+B;IAC1E,MAAMC,gBAAgBC;IAEtB,OAAO,WAAP,GACI,oBAAC;QAAK,oBAAkBD;qBACpB,oBAACE,kBAAgBA;QACb,MAAK;QACL,gBAAgBH;QAChB,oBAAM,oBAACI,gBAAWA;QAClB,UAAU;QACV,SAASC;QACT,eAAa;sBAEjB,oBAAC;QAAK,IAAIJ;QAAe,WAAW;OAC/BD;AAIjB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface PageBulkPublishGateProps {
|
|
3
|
+
element: React.ReactElement | undefined;
|
|
4
|
+
}
|
|
5
|
+
export declare const PageBulkPublishGate: ((props: PageBulkPublishGateProps) => React.JSX.Element | null) & React.NamedExoticComponent<PageBulkPublishGateProps> & {
|
|
6
|
+
readonly type: (props: PageBulkPublishGateProps) => React.JSX.Element | null;
|
|
7
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import react, { useEffect } from "react";
|
|
2
|
+
import { useFeature } from "@webiny/app";
|
|
3
|
+
import { createReactiveComponent } from "@webiny/app-admin";
|
|
4
|
+
import { usePageListPresenter } from "@webiny/app-website-builder/presentation/pages/PageList/PageListPresenterProvider.js";
|
|
5
|
+
import { BoundWorkflowFeature } from "@webiny/app-workflows/review/presentation/boundWorkflow/feature.js";
|
|
6
|
+
import { getSelectionPublishDisabledReason } from "@webiny/app-workflows/review/presentation/listActions/getSelectionPublishDisabledReason.js";
|
|
7
|
+
import { WB_PAGE_APP } from "../../constants.js";
|
|
8
|
+
import { PageBulkPublishBlocked } from "./PageBulkPublishBlocked.js";
|
|
9
|
+
import { toListPublishRow } from "./toListPublishRow.js";
|
|
10
|
+
const PageBulkPublishGate = createReactiveComponent((props)=>{
|
|
11
|
+
const listPresenter = usePageListPresenter();
|
|
12
|
+
const { presenter } = useFeature(BoundWorkflowFeature);
|
|
13
|
+
useEffect(()=>{
|
|
14
|
+
presenter.load(WB_PAGE_APP);
|
|
15
|
+
}, [
|
|
16
|
+
presenter
|
|
17
|
+
]);
|
|
18
|
+
const { rows, selection, pagination } = listPresenter.list.vm;
|
|
19
|
+
const selectedRows = rows.filter((row)=>selection.selectedIds.has(row.entryId)).map(toListPublishRow);
|
|
20
|
+
const reason = getSelectionPublishDisabledReason({
|
|
21
|
+
workflowStatus: presenter.vm.status,
|
|
22
|
+
rows: selectedRows,
|
|
23
|
+
allSelected: selection.allSelected,
|
|
24
|
+
hasMore: pagination.hasMore
|
|
25
|
+
});
|
|
26
|
+
if (null === reason) return props.element ?? null;
|
|
27
|
+
return /*#__PURE__*/ react.createElement(PageBulkPublishBlocked, {
|
|
28
|
+
reason: reason
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
export { PageBulkPublishGate };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=PageBulkPublishGate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Components/PagesList/PageBulkPublishGate.js","sources":["../../../src/Components/PagesList/PageBulkPublishGate.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { usePageListPresenter } from \"@webiny/app-website-builder/presentation/pages/PageList/PageListPresenterProvider.js\";\nimport { BoundWorkflowFeature } from \"@webiny/app-workflows/review/presentation/boundWorkflow/feature.js\";\nimport { getSelectionPublishDisabledReason } from \"@webiny/app-workflows/review/presentation/listActions/getSelectionPublishDisabledReason.js\";\nimport { WB_PAGE_APP } from \"~/constants.js\";\nimport { PageBulkPublishBlocked } from \"./PageBulkPublishBlocked.js\";\nimport { toListPublishRow } from \"./toListPublishRow.js\";\n\nexport interface PageBulkPublishGateProps {\n element: React.ReactElement | undefined;\n}\n\n/*\n * Shows the bulk \"Publish\" disabled with the reason when the API would refuse a selected page\n * (the row rule of `PagePublishGate`), instead of running and failing. The base action is only\n * configured for users who may publish.\n */\nexport const PageBulkPublishGate = createReactiveComponent((props: PageBulkPublishGateProps) => {\n const listPresenter = usePageListPresenter();\n const { presenter } = useFeature(BoundWorkflowFeature);\n\n useEffect(() => {\n void presenter.load(WB_PAGE_APP);\n }, [presenter]);\n\n const { rows, selection, pagination } = listPresenter.list.vm;\n const selectedRows = rows\n .filter(row => {\n return selection.selectedIds.has(row.entryId);\n })\n .map(toListPublishRow);\n const reason = getSelectionPublishDisabledReason({\n workflowStatus: presenter.vm.status,\n rows: selectedRows,\n allSelected: selection.allSelected,\n hasMore: pagination.hasMore\n });\n\n if (reason === null) {\n return props.element ?? null;\n }\n\n return <PageBulkPublishBlocked reason={reason} />;\n});\n"],"names":["PageBulkPublishGate","createReactiveComponent","props","listPresenter","usePageListPresenter","presenter","useFeature","BoundWorkflowFeature","useEffect","WB_PAGE_APP","rows","selection","pagination","selectedRows","row","toListPublishRow","reason","getSelectionPublishDisabledReason","PageBulkPublishBlocked"],"mappings":";;;;;;;;;AAmBO,MAAMA,sBAAsBC,wBAAwB,CAACC;IACxD,MAAMC,gBAAgBC;IACtB,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IAEjCC,UAAU;QACDH,UAAU,IAAI,CAACI;IACxB,GAAG;QAACJ;KAAU;IAEd,MAAM,EAAEK,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGT,cAAc,IAAI,CAAC,EAAE;IAC7D,MAAMU,eAAeH,KAChB,MAAM,CAACI,CAAAA,MACGH,UAAU,WAAW,CAAC,GAAG,CAACG,IAAI,OAAO,GAE/C,GAAG,CAACC;IACT,MAAMC,SAASC,kCAAkC;QAC7C,gBAAgBZ,UAAU,EAAE,CAAC,MAAM;QACnC,MAAMQ;QACN,aAAaF,UAAU,WAAW;QAClC,SAASC,WAAW,OAAO;IAC/B;IAEA,IAAII,AAAW,SAAXA,QACA,OAAOd,MAAM,OAAO,IAAI;IAG5B,OAAO,WAAP,GAAO,oBAACgB,wBAAsBA;QAAC,QAAQF;;AAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "~/types.js";
|