@webiny/app-website-builder-workflows 6.4.12-beta.2 → 6.4.12-beta.4
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/PageEditor/PageEditorConfig.js +3 -3
- package/Components/PageEditor/PageEditorConfig.js.map +1 -1
- package/Components/PageEditor/ToggleEditorMode.js +5 -4
- package/Components/PageEditor/ToggleEditorMode.js.map +1 -1
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/package.json +9 -9
- package/presentation/page/RevisionList/RevisionListPresenterDecorator.d.ts +21 -0
- package/presentation/page/RevisionList/RevisionListPresenterDecorator.js +28 -0
- package/presentation/page/RevisionList/RevisionListPresenterDecorator.js.map +1 -0
- package/presentation/page/RevisionList/feature.d.ts +1 -0
- package/presentation/page/RevisionList/feature.js +11 -0
- package/presentation/page/RevisionList/feature.js.map +1 -0
- package/Components/PageEditor/PageEditorLayout.d.ts +0 -2
- package/Components/PageEditor/PageEditorLayout.js +0 -43
- package/Components/PageEditor/PageEditorLayout.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import react from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Plugins } from "@webiny/app";
|
|
3
3
|
import { PageFormWorkflowStateTooltip } from "./PageFormWorkflowStateTooltip.js";
|
|
4
4
|
import { PageFormWorkflowStatePublishButton } from "./PageFormWorkflowStatePublishButton.js";
|
|
5
5
|
import { PageEditorTopBar } from "./PageEditorTopBar.js";
|
|
6
|
-
const
|
|
7
|
-
export {
|
|
6
|
+
const PageEditorConfig = ()=>/*#__PURE__*/ react.createElement(Plugins, null, /*#__PURE__*/ react.createElement(PageEditorTopBar, null), /*#__PURE__*/ react.createElement(PageFormWorkflowStateTooltip, null), /*#__PURE__*/ react.createElement(PageFormWorkflowStatePublishButton, null));
|
|
7
|
+
export { PageEditorConfig };
|
|
8
8
|
|
|
9
9
|
//# sourceMappingURL=PageEditorConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageEditorConfig.js","sources":["../../../src/Components/PageEditor/PageEditorConfig.tsx"],"sourcesContent":["import React from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageEditorConfig.js","sources":["../../../src/Components/PageEditor/PageEditorConfig.tsx"],"sourcesContent":["import React from \"react\";\nimport { Plugins } from \"@webiny/app\";\nimport { PageFormWorkflowStateTooltip } from \"./PageFormWorkflowStateTooltip.js\";\nimport { PageFormWorkflowStatePublishButton } from \"./PageFormWorkflowStatePublishButton.js\";\nimport { PageEditorTopBar } from \"./PageEditorTopBar.js\";\n\nexport const PageEditorConfig = () => {\n return (\n <Plugins>\n {/* Toggle editor \"readonly\" mode, and add workflow alerts */}\n <PageEditorTopBar />\n {/* Should add a button with list of steps and their states + comment button in each row */}\n <PageFormWorkflowStateTooltip />\n {/* should remove publish button from the form */}\n <PageFormWorkflowStatePublishButton />\n </Plugins>\n );\n};\n"],"names":["PageEditorConfig","Plugins","PageEditorTopBar","PageFormWorkflowStateTooltip","PageFormWorkflowStatePublishButton"],"mappings":";;;;;AAMO,MAAMA,mBAAmB,IACrB,WAAP,GACI,oBAACC,SAAOA,MAAAA,WAAAA,GAEJ,oBAACC,kBAAgBA,OAAAA,WAAAA,GAEjB,oBAACC,8BAA4BA,OAAAA,WAAAA,GAE7B,oBAACC,oCAAkCA"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
import { observer } from "mobx-react-lite";
|
|
3
|
-
import { useWorkflowState } from "@webiny/app-workflows";
|
|
3
|
+
import { WorkflowStateValue, useWorkflowState } from "@webiny/app-workflows";
|
|
4
4
|
import { useDocumentEditor } from "@webiny/app-website-builder/DocumentEditor/index.js";
|
|
5
5
|
const ToggleEditorMode = observer(()=>{
|
|
6
6
|
const { presenter } = useWorkflowState();
|
|
7
7
|
const editor = useDocumentEditor();
|
|
8
|
-
const
|
|
8
|
+
const state = presenter.vm.state?.state;
|
|
9
|
+
const isUnderReview = !!state && state !== WorkflowStateValue.approved;
|
|
9
10
|
useEffect(()=>{
|
|
10
11
|
const options = editor.getEditorOptions();
|
|
11
12
|
editor.updateEditor((state)=>{
|
|
12
|
-
state.isReadOnly = options.isReadOnly ||
|
|
13
|
+
state.isReadOnly = options.isReadOnly || isUnderReview;
|
|
13
14
|
});
|
|
14
15
|
}, [
|
|
15
|
-
|
|
16
|
+
isUnderReview
|
|
16
17
|
]);
|
|
17
18
|
return null;
|
|
18
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/ToggleEditorMode.js","sources":["../../../src/Components/PageEditor/ToggleEditorMode.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useWorkflowState } from \"@webiny/app-workflows\";\nimport { useDocumentEditor } from \"@webiny/app-website-builder/DocumentEditor/index.js\";\n\nexport const ToggleEditorMode = observer(() => {\n const { presenter } = useWorkflowState();\n const editor = useDocumentEditor();\n\n const
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/ToggleEditorMode.js","sources":["../../../src/Components/PageEditor/ToggleEditorMode.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useWorkflowState, WorkflowStateValue } from \"@webiny/app-workflows\";\nimport { useDocumentEditor } from \"@webiny/app-website-builder/DocumentEditor/index.js\";\n\nexport const ToggleEditorMode = observer(() => {\n const { presenter } = useWorkflowState();\n const editor = useDocumentEditor();\n\n const state = presenter.vm.state?.state;\n\n /**\n * A page is locked for the duration of the review. Once the review is approved the page can\n * be published, so the editor has to become writable again - otherwise the top bar keeps\n * offering \"New Revision\" instead of \"Publish\".\n */\n const isUnderReview = !!state && state !== WorkflowStateValue.approved;\n\n useEffect(() => {\n const options = editor.getEditorOptions();\n editor.updateEditor(state => {\n state.isReadOnly = options.isReadOnly || isUnderReview;\n });\n }, [isUnderReview]);\n\n return null;\n});\n"],"names":["ToggleEditorMode","observer","presenter","useWorkflowState","editor","useDocumentEditor","state","isUnderReview","WorkflowStateValue","useEffect","options"],"mappings":";;;;AAKO,MAAMA,mBAAmBC,SAAS;IACrC,MAAM,EAAEC,SAAS,EAAE,GAAGC;IACtB,MAAMC,SAASC;IAEf,MAAMC,QAAQJ,UAAU,EAAE,CAAC,KAAK,EAAE;IAOlC,MAAMK,gBAAgB,CAAC,CAACD,SAASA,UAAUE,mBAAmB,QAAQ;IAEtEC,UAAU;QACN,MAAMC,UAAUN,OAAO,gBAAgB;QACvCA,OAAO,YAAY,CAACE,CAAAA;YAChBA,MAAM,UAAU,GAAGI,QAAQ,UAAU,IAAIH;QAC7C;IACJ,GAAG;QAACA;KAAc;IAElB,OAAO;AACX"}
|
package/index.js
CHANGED
|
@@ -4,10 +4,13 @@ import { WebsiteBuilderWorkflowsMenu } from "./Routes/index.js";
|
|
|
4
4
|
import { ListOpenInNewWindow, PageEditorConfig, PagesList } from "./Components/index.js";
|
|
5
5
|
import { PageListWorkflowsFeature } from "./presentation/page/PageList/feature.js";
|
|
6
6
|
import { PageGetWorkflowsFeature } from "./presentation/page/PageGet/feature.js";
|
|
7
|
+
import { RevisionListWorkflowsFeature } from "./presentation/page/RevisionList/feature.js";
|
|
7
8
|
const WebsiteBuilderWorkflows = ()=>/*#__PURE__*/ react.createElement(Wcp.CanUseWorkflows, null, /*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
8
9
|
feature: PageListWorkflowsFeature
|
|
9
10
|
}), /*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
10
11
|
feature: PageGetWorkflowsFeature
|
|
12
|
+
}), /*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
13
|
+
feature: RevisionListWorkflowsFeature
|
|
11
14
|
}), /*#__PURE__*/ react.createElement(WebsiteBuilderWorkflowsMenu, null), /*#__PURE__*/ react.createElement(PageEditorConfig, null), /*#__PURE__*/ react.createElement(PagesList, null), /*#__PURE__*/ react.createElement(ListOpenInNewWindow, null));
|
|
12
15
|
export { WebsiteBuilderWorkflows };
|
|
13
16
|
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport { RegisterFeature, Wcp } from \"@webiny/app-admin\";\nimport { WebsiteBuilderWorkflowsMenu } from \"~/Routes/index.js\";\nimport { ListOpenInNewWindow, PageEditorConfig, PagesList } from \"~/Components/index.js\";\nimport { PageListWorkflowsFeature } from \"~/presentation/page/PageList/feature.js\";\nimport { PageGetWorkflowsFeature } from \"~/presentation/page/PageGet/feature.js\";\n\nexport const WebsiteBuilderWorkflows = () => {\n return (\n <Wcp.CanUseWorkflows>\n <RegisterFeature feature={PageListWorkflowsFeature} />\n <RegisterFeature feature={PageGetWorkflowsFeature} />\n <WebsiteBuilderWorkflowsMenu />\n <PageEditorConfig />\n <PagesList />\n <ListOpenInNewWindow />\n </Wcp.CanUseWorkflows>\n );\n};\n"],"names":["WebsiteBuilderWorkflows","Wcp","RegisterFeature","PageListWorkflowsFeature","PageGetWorkflowsFeature","WebsiteBuilderWorkflowsMenu","PageEditorConfig","PagesList","ListOpenInNewWindow"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport { RegisterFeature, Wcp } from \"@webiny/app-admin\";\nimport { WebsiteBuilderWorkflowsMenu } from \"~/Routes/index.js\";\nimport { ListOpenInNewWindow, PageEditorConfig, PagesList } from \"~/Components/index.js\";\nimport { PageListWorkflowsFeature } from \"~/presentation/page/PageList/feature.js\";\nimport { PageGetWorkflowsFeature } from \"~/presentation/page/PageGet/feature.js\";\nimport { RevisionListWorkflowsFeature } from \"~/presentation/page/RevisionList/feature.js\";\n\nexport const WebsiteBuilderWorkflows = () => {\n return (\n <Wcp.CanUseWorkflows>\n <RegisterFeature feature={PageListWorkflowsFeature} />\n <RegisterFeature feature={PageGetWorkflowsFeature} />\n <RegisterFeature feature={RevisionListWorkflowsFeature} />\n <WebsiteBuilderWorkflowsMenu />\n <PageEditorConfig />\n <PagesList />\n <ListOpenInNewWindow />\n </Wcp.CanUseWorkflows>\n );\n};\n"],"names":["WebsiteBuilderWorkflows","Wcp","RegisterFeature","PageListWorkflowsFeature","PageGetWorkflowsFeature","RevisionListWorkflowsFeature","WebsiteBuilderWorkflowsMenu","PageEditorConfig","PagesList","ListOpenInNewWindow"],"mappings":";;;;;;;AAQO,MAAMA,0BAA0B,IAC5B,WAAP,GACI,oBAACC,IAAI,eAAe,sBAChB,oBAACC,iBAAeA;QAAC,SAASC;sBAC1B,oBAACD,iBAAeA;QAAC,SAASE;sBAC1B,oBAACF,iBAAeA;QAAC,SAASG;sBAC1B,oBAACC,6BAA2BA,OAAAA,WAAAA,GAC5B,oBAACC,kBAAgBA,OAAAA,WAAAA,GACjB,oBAACC,WAASA,OAAAA,WAAAA,GACV,oBAACC,qBAAmBA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-website-builder-workflows",
|
|
3
|
-
"version": "6.4.12-beta.
|
|
3
|
+
"version": "6.4.12-beta.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@apollo/react-hooks": "3.1.5",
|
|
17
|
-
"@webiny/admin-ui": "6.4.12-beta.
|
|
18
|
-
"@webiny/app": "6.4.12-beta.
|
|
19
|
-
"@webiny/app-admin": "6.4.12-beta.
|
|
20
|
-
"@webiny/app-website-builder": "6.4.12-beta.
|
|
21
|
-
"@webiny/app-workflows": "6.4.12-beta.
|
|
22
|
-
"@webiny/feature": "6.4.12-beta.
|
|
23
|
-
"@webiny/icons": "6.4.12-beta.
|
|
17
|
+
"@webiny/admin-ui": "6.4.12-beta.4",
|
|
18
|
+
"@webiny/app": "6.4.12-beta.4",
|
|
19
|
+
"@webiny/app-admin": "6.4.12-beta.4",
|
|
20
|
+
"@webiny/app-website-builder": "6.4.12-beta.4",
|
|
21
|
+
"@webiny/app-workflows": "6.4.12-beta.4",
|
|
22
|
+
"@webiny/feature": "6.4.12-beta.4",
|
|
23
|
+
"@webiny/icons": "6.4.12-beta.4",
|
|
24
24
|
"mobx": "7.0.3",
|
|
25
25
|
"mobx-react-lite": "5.0.3",
|
|
26
26
|
"react": "18.3.1",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/react": "18.3.31",
|
|
32
|
-
"@webiny/build-tools": "6.4.12-beta.
|
|
32
|
+
"@webiny/build-tools": "6.4.12-beta.4",
|
|
33
33
|
"rimraf": "6.1.3",
|
|
34
34
|
"typescript": "6.0.3"
|
|
35
35
|
},
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IRevisionListPresenterInit, type IRevisionListVm, RevisionListPresenter } from "@webiny/app-website-builder/presentation/pages/RevisionList/abstractions.js";
|
|
2
|
+
/**
|
|
3
|
+
* Publishing a page revision straight from the revisions drawer bypasses the workflow: the top bar
|
|
4
|
+
* hides its own Publish button while a review is in progress, but the drawer knew nothing about
|
|
5
|
+
* workflows and kept offering the action.
|
|
6
|
+
*
|
|
7
|
+
* This decorator is registered only from within `Wcp.CanUseWorkflows`, so its presence already
|
|
8
|
+
* means workflows are enabled for the project. That is a blunt rule - it also hides the action on
|
|
9
|
+
* a page no workflow applies to - but it is the safe direction while the drawer has no access to
|
|
10
|
+
* the per-page workflow state. Publishing remains available from the top bar, which does know it.
|
|
11
|
+
*/
|
|
12
|
+
declare class RevisionListPresenterWithWorkflows implements RevisionListPresenter.Interface {
|
|
13
|
+
private readonly decoratee;
|
|
14
|
+
constructor(decoratee: RevisionListPresenter.Interface);
|
|
15
|
+
get vm(): IRevisionListVm;
|
|
16
|
+
init(params: IRevisionListPresenterInit): void;
|
|
17
|
+
}
|
|
18
|
+
export declare const RevisionListPresenterDecorator: typeof RevisionListPresenterWithWorkflows & {
|
|
19
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/app-website-builder/presentation/pages/RevisionList/abstractions.js").IRevisionListPresenter>;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { makeAutoObservable } from "mobx";
|
|
2
|
+
import { RevisionListPresenter } from "@webiny/app-website-builder/presentation/pages/RevisionList/abstractions.js";
|
|
3
|
+
class RevisionListPresenterWithWorkflows {
|
|
4
|
+
constructor(decoratee){
|
|
5
|
+
this.decoratee = decoratee;
|
|
6
|
+
makeAutoObservable(this);
|
|
7
|
+
}
|
|
8
|
+
get vm() {
|
|
9
|
+
const vm = this.decoratee.vm;
|
|
10
|
+
return {
|
|
11
|
+
...vm,
|
|
12
|
+
revisions: vm.revisions.map((item)=>({
|
|
13
|
+
...item,
|
|
14
|
+
canPublish: false
|
|
15
|
+
}))
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
init(params) {
|
|
19
|
+
this.decoratee.init(params);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const RevisionListPresenterDecorator = RevisionListPresenter.createDecorator({
|
|
23
|
+
decorator: RevisionListPresenterWithWorkflows,
|
|
24
|
+
dependencies: []
|
|
25
|
+
});
|
|
26
|
+
export { RevisionListPresenterDecorator };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=RevisionListPresenterDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/page/RevisionList/RevisionListPresenterDecorator.js","sources":["../../../../src/presentation/page/RevisionList/RevisionListPresenterDecorator.ts"],"sourcesContent":["import { makeAutoObservable } from \"mobx\";\nimport {\n type IRevisionListPresenterInit,\n type IRevisionListVm,\n RevisionListPresenter\n} from \"@webiny/app-website-builder/presentation/pages/RevisionList/abstractions.js\";\n\n/**\n * Publishing a page revision straight from the revisions drawer bypasses the workflow: the top bar\n * hides its own Publish button while a review is in progress, but the drawer knew nothing about\n * workflows and kept offering the action.\n *\n * This decorator is registered only from within `Wcp.CanUseWorkflows`, so its presence already\n * means workflows are enabled for the project. That is a blunt rule - it also hides the action on\n * a page no workflow applies to - but it is the safe direction while the drawer has no access to\n * the per-page workflow state. Publishing remains available from the top bar, which does know it.\n */\nclass RevisionListPresenterWithWorkflows implements RevisionListPresenter.Interface {\n private readonly decoratee;\n\n public constructor(decoratee: RevisionListPresenter.Interface) {\n this.decoratee = decoratee;\n makeAutoObservable(this);\n }\n\n public get vm(): IRevisionListVm {\n const vm = this.decoratee.vm;\n\n return {\n ...vm,\n revisions: vm.revisions.map(item => {\n return {\n ...item,\n canPublish: false\n };\n })\n };\n }\n\n public init(params: IRevisionListPresenterInit): void {\n this.decoratee.init(params);\n }\n}\n\nexport const RevisionListPresenterDecorator = RevisionListPresenter.createDecorator({\n decorator: RevisionListPresenterWithWorkflows,\n dependencies: []\n});\n"],"names":["RevisionListPresenterWithWorkflows","decoratee","makeAutoObservable","vm","item","params","RevisionListPresenterDecorator","RevisionListPresenter"],"mappings":";;AAiBA,MAAMA;IAGF,YAAmBC,SAA0C,CAAE;QAC3D,IAAI,CAAC,SAAS,GAAGA;QACjBC,mBAAmB,IAAI;IAC3B;IAEA,IAAW,KAAsB;QAC7B,MAAMC,KAAK,IAAI,CAAC,SAAS,CAAC,EAAE;QAE5B,OAAO;YACH,GAAGA,EAAE;YACL,WAAWA,GAAG,SAAS,CAAC,GAAG,CAACC,CAAAA,OACjB;oBACH,GAAGA,IAAI;oBACP,YAAY;gBAChB;QAER;IACJ;IAEO,KAAKC,MAAkC,EAAQ;QAClD,IAAI,CAAC,SAAS,CAAC,IAAI,CAACA;IACxB;AACJ;AAEO,MAAMC,iCAAiCC,sBAAsB,eAAe,CAAC;IAChF,WAAWP;IACX,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RevisionListWorkflowsFeature: import("@webiny/feature/admin").FeatureDefinition<any, []>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/admin";
|
|
2
|
+
import { RevisionListPresenterDecorator } from "./RevisionListPresenterDecorator.js";
|
|
3
|
+
const RevisionListWorkflowsFeature = createFeature({
|
|
4
|
+
name: "RevisionListWorkflows",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.registerDecorator(RevisionListPresenterDecorator);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { RevisionListWorkflowsFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/page/RevisionList/feature.js","sources":["../../../../src/presentation/page/RevisionList/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { RevisionListPresenterDecorator } from \"./RevisionListPresenterDecorator.js\";\n\nexport const RevisionListWorkflowsFeature = createFeature({\n name: \"RevisionListWorkflows\",\n register(container) {\n container.registerDecorator(RevisionListPresenterDecorator);\n }\n});\n"],"names":["RevisionListWorkflowsFeature","createFeature","container","RevisionListPresenterDecorator"],"mappings":";;AAGO,MAAMA,+BAA+BC,cAAc;IACtD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,iBAAiB,CAACC;IAChC;AACJ"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import react, { useEffect } from "react";
|
|
2
|
-
import { useSelectFromDocument } from "@webiny/app-website-builder/BaseEditor/hooks/useSelectFromDocument.js";
|
|
3
|
-
import { useApolloClient } from "@apollo/react-hooks";
|
|
4
|
-
import { useAuthentication } from "@webiny/app-admin";
|
|
5
|
-
import { Components, useWorkflowState } from "@webiny/app-workflows";
|
|
6
|
-
import { WB_PAGE_APP } from "../../constants.js";
|
|
7
|
-
import { PageEditorConfig } from "@webiny/app-website-builder";
|
|
8
|
-
import { observer } from "mobx-react-lite";
|
|
9
|
-
import { useDocumentEditor } from "@webiny/app-website-builder/DocumentEditor/index.js";
|
|
10
|
-
const { Ui: Ui } = PageEditorConfig;
|
|
11
|
-
const { ContentReview: { WorkflowStateProvider: WorkflowStateProvider } } = Components;
|
|
12
|
-
const ToggleReadonly = observer(()=>{
|
|
13
|
-
const { presenter } = useWorkflowState();
|
|
14
|
-
const editor = useDocumentEditor();
|
|
15
|
-
const hasState = !!presenter.vm.state?.state;
|
|
16
|
-
useEffect(()=>{
|
|
17
|
-
const options = editor.getEditorOptions();
|
|
18
|
-
editor.updateEditor((state)=>{
|
|
19
|
-
state.isReadOnly = options.isReadOnly || hasState;
|
|
20
|
-
});
|
|
21
|
-
}, [
|
|
22
|
-
hasState
|
|
23
|
-
]);
|
|
24
|
-
return null;
|
|
25
|
-
});
|
|
26
|
-
const PageEditorLayout = Ui.Layout.createDecorator((Original)=>function() {
|
|
27
|
-
const page = useSelectFromDocument((doc)=>({
|
|
28
|
-
id: doc.id,
|
|
29
|
-
title: doc.properties.title || "unknown page"
|
|
30
|
-
}));
|
|
31
|
-
const client = useApolloClient();
|
|
32
|
-
const { identity } = useAuthentication();
|
|
33
|
-
return /*#__PURE__*/ react.createElement(WorkflowStateProvider, {
|
|
34
|
-
app: WB_PAGE_APP,
|
|
35
|
-
id: page.id,
|
|
36
|
-
identity: identity,
|
|
37
|
-
client: client,
|
|
38
|
-
title: `Website Builder: ${page.title}`
|
|
39
|
-
}, /*#__PURE__*/ react.createElement(Original, null), /*#__PURE__*/ react.createElement(ToggleReadonly, null));
|
|
40
|
-
});
|
|
41
|
-
export { PageEditorLayout };
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=PageEditorLayout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageEditorLayout.js","sources":["../../../src/Components/PageEditor/PageEditorLayout.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { useSelectFromDocument } from \"@webiny/app-website-builder/BaseEditor/hooks/useSelectFromDocument.js\";\nimport { useApolloClient } from \"@apollo/react-hooks\";\nimport { useAuthentication } from \"@webiny/app-admin\";\nimport { Components, useWorkflowState } from \"@webiny/app-workflows\";\nimport { WB_PAGE_APP } from \"~/constants.js\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder\";\nimport { observer } from \"mobx-react-lite\";\nimport { useDocumentEditor } from \"@webiny/app-website-builder/DocumentEditor/index.js\";\n\nconst { Ui } = PageEditorConfig;\n\nconst {\n ContentReview: { WorkflowStateProvider }\n} = Components;\n\nconst ToggleReadonly = observer(() => {\n const { presenter } = useWorkflowState();\n const editor = useDocumentEditor();\n\n const hasState = !!presenter.vm.state?.state;\n\n useEffect(() => {\n const options = editor.getEditorOptions();\n editor.updateEditor(state => {\n state.isReadOnly = options.isReadOnly || hasState;\n });\n }, [hasState]);\n\n return null;\n});\n\nexport const PageEditorLayout = Ui.Layout.createDecorator(Original => {\n return function PageEditorTopBarWorkflowsState() {\n const page = useSelectFromDocument(doc => {\n return {\n id: doc.id,\n title: doc.properties.title || \"unknown page\"\n };\n });\n\n const client = useApolloClient();\n const { identity } = useAuthentication();\n\n return (\n <WorkflowStateProvider\n app={WB_PAGE_APP}\n id={page.id}\n identity={identity}\n client={client}\n title={`Website Builder: ${page.title}`}\n >\n <Original />\n <ToggleReadonly />\n </WorkflowStateProvider>\n );\n };\n});\n"],"names":["Ui","PageEditorConfig","WorkflowStateProvider","Components","ToggleReadonly","observer","presenter","useWorkflowState","editor","useDocumentEditor","hasState","useEffect","options","state","PageEditorLayout","Original","page","useSelectFromDocument","doc","client","useApolloClient","identity","useAuthentication","WB_PAGE_APP"],"mappings":";;;;;;;;;AAUA,MAAM,EAAEA,IAAAA,EAAE,EAAE,GAAGC;AAEf,MAAM,EACF,eAAe,EAAEC,uBAAAA,qBAAqB,EAAE,EAC3C,GAAGC;AAEJ,MAAMC,iBAAiBC,SAAS;IAC5B,MAAM,EAAEC,SAAS,EAAE,GAAGC;IACtB,MAAMC,SAASC;IAEf,MAAMC,WAAW,CAAC,CAACJ,UAAU,EAAE,CAAC,KAAK,EAAE;IAEvCK,UAAU;QACN,MAAMC,UAAUJ,OAAO,gBAAgB;QACvCA,OAAO,YAAY,CAACK,CAAAA;YAChBA,MAAM,UAAU,GAAGD,QAAQ,UAAU,IAAIF;QAC7C;IACJ,GAAG;QAACA;KAAS;IAEb,OAAO;AACX;AAEO,MAAMI,mBAAmBd,GAAG,MAAM,CAAC,eAAe,CAACe,CAAAA,WAC/C;QACH,MAAMC,OAAOC,sBAAsBC,CAAAA,MACxB;gBACH,IAAIA,IAAI,EAAE;gBACV,OAAOA,IAAI,UAAU,CAAC,KAAK,IAAI;YACnC;QAGJ,MAAMC,SAASC;QACf,MAAM,EAAEC,QAAQ,EAAE,GAAGC;QAErB,OAAO,WAAP,GACI,oBAACpB,uBAAqBA;YAClB,KAAKqB;YACL,IAAIP,KAAK,EAAE;YACX,UAAUK;YACV,QAAQF;YACR,OAAO,CAAC,iBAAiB,EAAEH,KAAK,KAAK,EAAE;yBAEvC,oBAACD,UAAAA,OAAAA,WAAAA,GACD,oBAACX,gBAAcA;IAG3B"}
|