@webiny/app-website-builder 6.4.12-beta.2 → 6.4.12-beta.3
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/Extension.js +2 -0
- package/Extension.js.map +1 -1
- package/domain/Page/Page.d.ts +2 -0
- package/domain/Page/Page.js +1 -0
- package/domain/Page/Page.js.map +1 -1
- package/domain/PageRevision/PageRevision.d.ts +11 -0
- package/domain/PageRevision/PageRevision.js +20 -0
- package/domain/PageRevision/PageRevision.js.map +1 -1
- package/features/pages/createPageRevisionFrom/CreatePageRevisionFrom.test.js +41 -1
- package/features/pages/createPageRevisionFrom/CreatePageRevisionFrom.test.js.map +1 -1
- package/features/pages/createPageRevisionFrom/CreatePageRevisionFromRepository.d.ts +3 -2
- package/features/pages/createPageRevisionFrom/CreatePageRevisionFromRepository.js +8 -2
- package/features/pages/createPageRevisionFrom/CreatePageRevisionFromRepository.js.map +1 -1
- package/features/pages/deletePageRevision/DeletePageRevision.test.d.ts +1 -0
- package/features/pages/deletePageRevision/DeletePageRevision.test.js +67 -0
- package/features/pages/deletePageRevision/DeletePageRevision.test.js.map +1 -0
- package/features/pages/deletePageRevision/DeletePageRevisionGateway.d.ts +1 -1
- package/features/pages/deletePageRevision/DeletePageRevisionGateway.js +2 -3
- package/features/pages/deletePageRevision/DeletePageRevisionGateway.js.map +1 -1
- package/features/pages/deletePageRevision/DeletePageRevisionRepository.d.ts +4 -2
- package/features/pages/deletePageRevision/DeletePageRevisionRepository.js +7 -3
- package/features/pages/deletePageRevision/DeletePageRevisionRepository.js.map +1 -1
- package/features/pages/deletePageRevision/DeletePageRevisionUseCase.js +1 -1
- package/features/pages/deletePageRevision/DeletePageRevisionUseCase.js.map +1 -1
- package/features/pages/deletePageRevision/abstractions.d.ts +2 -3
- package/features/pages/deletePageRevision/abstractions.js.map +1 -1
- package/features/pages/getPage/PageGatewayDto.d.ts +2 -0
- package/features/pages/publishPage/PublishPage.test.js +41 -1
- package/features/pages/publishPage/PublishPage.test.js.map +1 -1
- package/features/pages/publishPage/PublishPageRepository.d.ts +3 -2
- package/features/pages/publishPage/PublishPageRepository.js +15 -4
- package/features/pages/publishPage/PublishPageRepository.js.map +1 -1
- package/features/pages/shared/pageGraphQLFields.js +1 -0
- package/features/pages/shared/pageGraphQLFields.js.map +1 -1
- package/features/pages/unpublishPage/UnpublishPage.test.js +4 -1
- package/features/pages/unpublishPage/UnpublishPage.test.js.map +1 -1
- package/features/pages/unpublishPage/UnpublishPageRepository.d.ts +3 -2
- package/features/pages/unpublishPage/UnpublishPageRepository.js +12 -4
- package/features/pages/unpublishPage/UnpublishPageRepository.js.map +1 -1
- package/modules/pages/PageEditor/Revisions/RevisionListDrawer.js +4 -0
- package/modules/pages/PageEditor/Revisions/RevisionListDrawer.js.map +1 -1
- package/modules/pages/PageEditor/Revisions/RevisionListItem.d.ts +3 -3
- package/modules/pages/PageEditor/Revisions/RevisionListItem.js +9 -20
- package/modules/pages/PageEditor/Revisions/RevisionListItem.js.map +1 -1
- package/modules/pages/PageEditor/Revisions/RevisionsList.js +7 -19
- package/modules/pages/PageEditor/Revisions/RevisionsList.js.map +1 -1
- package/modules/pages/PageEditor/Revisions/useRevision.d.ts +1 -1
- package/modules/pages/PageEditor/Revisions/useRevision.js +84 -14
- package/modules/pages/PageEditor/Revisions/useRevision.js.map +1 -1
- package/modules/pages/PageEditor/Revisions/useRevisionList.d.ts +3 -0
- package/modules/pages/PageEditor/Revisions/useRevisionList.js +31 -0
- package/modules/pages/PageEditor/Revisions/useRevisionList.js.map +1 -0
- package/modules/pages/PageEditor/TopBar/RevisionsMenu.js +9 -21
- package/modules/pages/PageEditor/TopBar/RevisionsMenu.js.map +1 -1
- package/package.json +23 -23
- package/presentation/pages/RevisionList/RevisionListPresenter.d.ts +27 -0
- package/presentation/pages/RevisionList/RevisionListPresenter.js +73 -0
- package/presentation/pages/RevisionList/RevisionListPresenter.js.map +1 -0
- package/presentation/pages/RevisionList/RevisionListPresenter.test.d.ts +1 -0
- package/presentation/pages/RevisionList/RevisionListPresenter.test.js +219 -0
- package/presentation/pages/RevisionList/RevisionListPresenter.test.js.map +1 -0
- package/presentation/pages/RevisionList/abstractions.d.ts +34 -0
- package/presentation/pages/RevisionList/abstractions.js +5 -0
- package/presentation/pages/RevisionList/abstractions.js.map +1 -0
- package/presentation/pages/RevisionList/feature.d.ts +3 -0
- package/presentation/pages/RevisionList/feature.js +17 -0
- package/presentation/pages/RevisionList/feature.js.map +1 -0
- package/presentation/pages/RevisionList/index.d.ts +2 -0
- package/presentation/pages/RevisionList/index.js +1 -0
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import react
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { List, OverlayLoader } from "@webiny/admin-ui";
|
|
3
3
|
import RevisionListItem from "./RevisionListItem.js";
|
|
4
|
-
import {
|
|
5
|
-
import { parseIdentifier } from "@webiny/utils/parseIdentifier.js";
|
|
4
|
+
import { useRevisionList } from "./useRevisionList.js";
|
|
6
5
|
const RevisionsList = (props)=>{
|
|
7
6
|
const { page } = props;
|
|
8
|
-
const
|
|
9
|
-
const { loading, getPageRevisions } = useGetPageRevisions();
|
|
10
|
-
useEffect(()=>{
|
|
11
|
-
const { id: entryId } = parseIdentifier(page.id);
|
|
12
|
-
getPageRevisions({
|
|
13
|
-
entryId
|
|
14
|
-
}).then((revisions)=>{
|
|
15
|
-
setRevisions(revisions.sort((a, b)=>new Date(a.savedOn).getTime() - new Date(b.savedOn).getTime()).reverse());
|
|
16
|
-
});
|
|
17
|
-
}, [
|
|
18
|
-
page.id
|
|
19
|
-
]);
|
|
7
|
+
const { vm } = useRevisionList(page.id);
|
|
20
8
|
return /*#__PURE__*/ react.createElement("div", {
|
|
21
9
|
className: "relative"
|
|
22
|
-
},
|
|
10
|
+
}, (vm.isLoading || vm.isMutating) && /*#__PURE__*/ react.createElement(OverlayLoader, null), vm.revisions.length ? /*#__PURE__*/ react.createElement(List, {
|
|
23
11
|
"data-testid": "cms.content-form.revisions"
|
|
24
|
-
}, revisions.map((
|
|
25
|
-
|
|
26
|
-
key: revision.id
|
|
12
|
+
}, vm.revisions.map((item)=>/*#__PURE__*/ react.createElement(RevisionListItem, {
|
|
13
|
+
item: item,
|
|
14
|
+
key: item.revision.id
|
|
27
15
|
}))) : /*#__PURE__*/ react.createElement("div", {
|
|
28
16
|
className: "p-lg"
|
|
29
17
|
}, "No revisions to show."));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules/pages/PageEditor/Revisions/RevisionsList.js","sources":["../../../../../src/modules/pages/PageEditor/Revisions/RevisionsList.tsx"],"sourcesContent":["import React
|
|
1
|
+
{"version":3,"file":"modules/pages/PageEditor/Revisions/RevisionsList.js","sources":["../../../../../src/modules/pages/PageEditor/Revisions/RevisionsList.tsx"],"sourcesContent":["import React from \"react\";\nimport { List, OverlayLoader } from \"@webiny/admin-ui\";\nimport RevisionListItem from \"./RevisionListItem.js\";\nimport type { Page } from \"~/domain/Page/index.js\";\nimport { useRevisionList } from \"./useRevisionList.js\";\n\ninterface IRevisionsListProps {\n page: Pick<Page, \"id\">;\n}\n\nexport const RevisionsList = (props: IRevisionsListProps) => {\n const { page } = props;\n const { vm } = useRevisionList(page.id);\n\n return (\n <div className={\"relative\"}>\n {(vm.isLoading || vm.isMutating) && <OverlayLoader />}\n {vm.revisions.length ? (\n <List data-testid={\"cms.content-form.revisions\"}>\n {vm.revisions.map(item => (\n <RevisionListItem item={item} key={item.revision.id} />\n ))}\n </List>\n ) : (\n <div className={\"p-lg\"}>No revisions to show.</div>\n )}\n </div>\n );\n};\n"],"names":["RevisionsList","props","page","vm","useRevisionList","OverlayLoader","List","item","RevisionListItem"],"mappings":";;;;AAUO,MAAMA,gBAAgB,CAACC;IAC1B,MAAM,EAAEC,IAAI,EAAE,GAAGD;IACjB,MAAM,EAAEE,EAAE,EAAE,GAAGC,gBAAgBF,KAAK,EAAE;IAEtC,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;OACVC,AAAAA,CAAAA,GAAG,SAAS,IAAIA,GAAG,UAAS,mBAAM,oBAACE,eAAaA,OACjDF,GAAG,SAAS,CAAC,MAAM,GAAG,WAAH,GAChB,oBAACG,MAAIA;QAAC,eAAa;OACdH,GAAG,SAAS,CAAC,GAAG,CAACI,CAAAA,OAAAA,WAAAA,GACd,oBAACC,kBAAgBA;YAAC,MAAMD;YAAM,KAAKA,KAAK,QAAQ,CAAC,EAAE;6BAI3D,oBAAC;QAAI,WAAW;OAAQ;AAIxC"}
|
|
@@ -3,7 +3,7 @@ export interface UseRevisionProps {
|
|
|
3
3
|
revision: PageRevision;
|
|
4
4
|
}
|
|
5
5
|
export declare const useRevision: (props: UseRevisionProps) => {
|
|
6
|
-
createRevision: () => void
|
|
6
|
+
createRevision: () => Promise<void>;
|
|
7
7
|
editRevision: () => void;
|
|
8
8
|
deleteRevision: () => void;
|
|
9
9
|
publishRevision: () => void;
|
|
@@ -1,49 +1,119 @@
|
|
|
1
|
+
import react, { useCallback } from "react";
|
|
1
2
|
import { useCreatePageRevisionFrom, useDeletePageRevision, usePublishPage, useUnpublishPage } from "../../../../features/pages/index.js";
|
|
2
|
-
import {
|
|
3
|
+
import { Text, useToast } from "@webiny/admin-ui";
|
|
4
|
+
import { useDialogs } from "@webiny/app-admin";
|
|
5
|
+
import { ReactComponent } from "@webiny/icons/visibility.svg";
|
|
6
|
+
import { ReactComponent as visibility_off_svg_ReactComponent } from "@webiny/icons/visibility_off.svg";
|
|
7
|
+
import { ReactComponent as delete_svg_ReactComponent } from "@webiny/icons/delete.svg";
|
|
3
8
|
import { Routes } from "../../../../routes.js";
|
|
4
9
|
import { useRouter } from "@webiny/app";
|
|
10
|
+
import { usePageEditorDrawer } from "./usePageEditorDrawer.js";
|
|
5
11
|
const useRevision = (props)=>{
|
|
6
12
|
const { revision } = props;
|
|
7
13
|
const { goToRoute } = useRouter();
|
|
14
|
+
const { openRevisionList } = usePageEditorDrawer();
|
|
15
|
+
const { showDialog } = useDialogs();
|
|
16
|
+
const { showSuccessToast, showWarningToast } = useToast();
|
|
8
17
|
const { createPageRevisionFrom } = useCreatePageRevisionFrom();
|
|
9
18
|
const { deletePageRevision } = useDeletePageRevision();
|
|
10
19
|
const { publishPage } = usePublishPage();
|
|
11
20
|
const { unpublishPage } = useUnpublishPage();
|
|
12
|
-
const createRevision = useCallback(()=>{
|
|
13
|
-
createPageRevisionFrom({
|
|
21
|
+
const createRevision = useCallback(async ()=>{
|
|
22
|
+
await createPageRevisionFrom({
|
|
14
23
|
id: revision.id
|
|
15
24
|
});
|
|
16
25
|
}, [
|
|
17
26
|
revision.id
|
|
18
27
|
]);
|
|
19
28
|
const deleteRevision = useCallback(()=>{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
showDialog({
|
|
30
|
+
title: "Delete revision",
|
|
31
|
+
icon: /*#__PURE__*/ react.createElement(delete_svg_ReactComponent, null),
|
|
32
|
+
content: /*#__PURE__*/ react.createElement(Text, null, `You are about to delete revision #${revision.version}. This cannot be undone. Are you sure you want to continue?`),
|
|
33
|
+
acceptLabel: "Yes, delete this revision!",
|
|
34
|
+
cancelLabel: "Cancel",
|
|
35
|
+
onAccept: async ()=>{
|
|
36
|
+
try {
|
|
37
|
+
await deletePageRevision({
|
|
38
|
+
id: revision.id
|
|
39
|
+
});
|
|
40
|
+
showSuccessToast({
|
|
41
|
+
title: `Revision #${revision.version} was deleted successfully!`
|
|
42
|
+
});
|
|
43
|
+
} catch (ex) {
|
|
44
|
+
showWarningToast({
|
|
45
|
+
title: "Could not delete the revision.",
|
|
46
|
+
description: ex.message
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
23
50
|
});
|
|
24
51
|
}, [
|
|
25
|
-
revision.id
|
|
52
|
+
revision.id,
|
|
53
|
+
revision.version
|
|
26
54
|
]);
|
|
27
55
|
const publishRevision = useCallback(()=>{
|
|
28
|
-
|
|
29
|
-
|
|
56
|
+
showDialog({
|
|
57
|
+
title: "Publish revision",
|
|
58
|
+
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
59
|
+
content: /*#__PURE__*/ react.createElement(Text, null, `You are about to publish revision #${revision.version}. Are you sure you want to continue?`),
|
|
60
|
+
acceptLabel: "Yes, publish this revision!",
|
|
61
|
+
cancelLabel: "Cancel",
|
|
62
|
+
onAccept: async ()=>{
|
|
63
|
+
try {
|
|
64
|
+
await publishPage({
|
|
65
|
+
id: revision.id
|
|
66
|
+
});
|
|
67
|
+
showSuccessToast({
|
|
68
|
+
title: `Revision #${revision.version} was published successfully!`
|
|
69
|
+
});
|
|
70
|
+
} catch (ex) {
|
|
71
|
+
showWarningToast({
|
|
72
|
+
title: "Could not publish the revision.",
|
|
73
|
+
description: ex.message
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
30
77
|
});
|
|
31
78
|
}, [
|
|
32
|
-
revision.id
|
|
79
|
+
revision.id,
|
|
80
|
+
revision.version
|
|
33
81
|
]);
|
|
34
82
|
const unpublishRevision = useCallback(()=>{
|
|
35
|
-
|
|
36
|
-
|
|
83
|
+
showDialog({
|
|
84
|
+
title: "Unpublish revision",
|
|
85
|
+
icon: /*#__PURE__*/ react.createElement(visibility_off_svg_ReactComponent, null),
|
|
86
|
+
content: /*#__PURE__*/ react.createElement(Text, null, `You are about to unpublish revision #${revision.version}, which will take the page off the live website. Are you sure you want to continue?`),
|
|
87
|
+
acceptLabel: "Yes, unpublish this revision!",
|
|
88
|
+
cancelLabel: "Cancel",
|
|
89
|
+
onAccept: async ()=>{
|
|
90
|
+
try {
|
|
91
|
+
await unpublishPage({
|
|
92
|
+
id: revision.id
|
|
93
|
+
});
|
|
94
|
+
showSuccessToast({
|
|
95
|
+
title: `Revision #${revision.version} was unpublished successfully!`
|
|
96
|
+
});
|
|
97
|
+
} catch (ex) {
|
|
98
|
+
showWarningToast({
|
|
99
|
+
title: "Could not unpublish the revision.",
|
|
100
|
+
description: ex.message
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
37
104
|
});
|
|
38
105
|
}, [
|
|
39
|
-
revision.id
|
|
106
|
+
revision.id,
|
|
107
|
+
revision.version
|
|
40
108
|
]);
|
|
41
109
|
const editRevision = useCallback(()=>{
|
|
110
|
+
openRevisionList(false);
|
|
42
111
|
goToRoute(Routes.Pages.Editor, {
|
|
43
112
|
id: revision.id
|
|
44
113
|
});
|
|
45
114
|
}, [
|
|
46
|
-
revision.id
|
|
115
|
+
revision.id,
|
|
116
|
+
openRevisionList
|
|
47
117
|
]);
|
|
48
118
|
return {
|
|
49
119
|
createRevision,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules/pages/PageEditor/Revisions/useRevision.js","sources":["../../../../../src/modules/pages/PageEditor/Revisions/useRevision.tsx"],"sourcesContent":["import type { PageRevision } from \"~/domain/PageRevision/index.js\";\nimport {\n usePublishPage,\n useUnpublishPage,\n useCreatePageRevisionFrom,\n useDeletePageRevision\n} from \"~/features/pages/index.js\";\nimport { useCallback } from \"react\";\nimport { Routes } from \"~/routes.js\";\nimport { useRouter } from \"@webiny/app\";\n\nexport interface UseRevisionProps {\n revision: PageRevision;\n}\n\nexport const useRevision = (props: UseRevisionProps) => {\n const { revision } = props;\n\n const { goToRoute } = useRouter();\n\n const { createPageRevisionFrom } = useCreatePageRevisionFrom();\n const { deletePageRevision } = useDeletePageRevision();\n const { publishPage } = usePublishPage();\n const { unpublishPage } = useUnpublishPage();\n\n const createRevision = useCallback(() => {\n createPageRevisionFrom({\n id: revision.id\n });\n }, [revision.id]);\n\n const deleteRevision = useCallback(() => {\n deletePageRevision({\n
|
|
1
|
+
{"version":3,"file":"modules/pages/PageEditor/Revisions/useRevision.js","sources":["../../../../../src/modules/pages/PageEditor/Revisions/useRevision.tsx"],"sourcesContent":["import React from \"react\";\nimport type { PageRevision } from \"~/domain/PageRevision/index.js\";\nimport {\n usePublishPage,\n useUnpublishPage,\n useCreatePageRevisionFrom,\n useDeletePageRevision\n} from \"~/features/pages/index.js\";\nimport { useCallback } from \"react\";\nimport { Text, useToast } from \"@webiny/admin-ui\";\nimport { useDialogs } from \"@webiny/app-admin\";\nimport { ReactComponent as PublishIcon } from \"@webiny/icons/visibility.svg\";\nimport { ReactComponent as UnpublishIcon } from \"@webiny/icons/visibility_off.svg\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { Routes } from \"~/routes.js\";\nimport { useRouter } from \"@webiny/app\";\nimport { usePageEditorDrawer } from \"./usePageEditorDrawer.js\";\n\nexport interface UseRevisionProps {\n revision: PageRevision;\n}\n\nexport const useRevision = (props: UseRevisionProps) => {\n const { revision } = props;\n\n const { goToRoute } = useRouter();\n const { openRevisionList } = usePageEditorDrawer();\n const { showDialog } = useDialogs();\n const { showSuccessToast, showWarningToast } = useToast();\n\n const { createPageRevisionFrom } = useCreatePageRevisionFrom();\n const { deletePageRevision } = useDeletePageRevision();\n const { publishPage } = usePublishPage();\n const { unpublishPage } = useUnpublishPage();\n\n const createRevision = useCallback(async () => {\n await createPageRevisionFrom({\n id: revision.id\n });\n }, [revision.id]);\n\n const deleteRevision = useCallback(() => {\n showDialog({\n title: \"Delete revision\",\n icon: <DeleteIcon />,\n content: (\n <Text>\n {`You are about to delete revision #${revision.version}. This cannot be undone. Are you sure you want to continue?`}\n </Text>\n ),\n acceptLabel: \"Yes, delete this revision!\",\n cancelLabel: \"Cancel\",\n onAccept: async () => {\n try {\n await deletePageRevision({\n id: revision.id\n });\n\n showSuccessToast({\n title: `Revision #${revision.version} was deleted successfully!`\n });\n } catch (ex) {\n showWarningToast({\n title: \"Could not delete the revision.\",\n description: ex.message\n });\n }\n }\n });\n }, [revision.id, revision.version]);\n\n const publishRevision = useCallback(() => {\n showDialog({\n title: \"Publish revision\",\n icon: <PublishIcon />,\n content: (\n <Text>\n {`You are about to publish revision #${revision.version}. Are you sure you want to continue?`}\n </Text>\n ),\n acceptLabel: \"Yes, publish this revision!\",\n cancelLabel: \"Cancel\",\n onAccept: async () => {\n try {\n await publishPage({\n id: revision.id\n });\n\n showSuccessToast({\n title: `Revision #${revision.version} was published successfully!`\n });\n } catch (ex) {\n showWarningToast({\n title: \"Could not publish the revision.\",\n description: ex.message\n });\n }\n }\n });\n }, [revision.id, revision.version]);\n\n const unpublishRevision = useCallback(() => {\n showDialog({\n title: \"Unpublish revision\",\n icon: <UnpublishIcon />,\n content: (\n <Text>\n {`You are about to unpublish revision #${revision.version}, which will take the page off the live website. Are you sure you want to continue?`}\n </Text>\n ),\n acceptLabel: \"Yes, unpublish this revision!\",\n cancelLabel: \"Cancel\",\n onAccept: async () => {\n try {\n await unpublishPage({\n id: revision.id\n });\n\n showSuccessToast({\n title: `Revision #${revision.version} was unpublished successfully!`\n });\n } catch (ex) {\n showWarningToast({\n title: \"Could not unpublish the revision.\",\n description: ex.message\n });\n }\n }\n });\n }, [revision.id, revision.version]);\n\n const editRevision = useCallback(() => {\n // The drawer lives outside the editor, so it would stay open across the navigation.\n openRevisionList(false);\n\n goToRoute(Routes.Pages.Editor, {\n id: revision.id\n });\n }, [revision.id, openRevisionList]);\n\n return {\n createRevision,\n editRevision,\n deleteRevision,\n publishRevision,\n unpublishRevision\n };\n};\n"],"names":["useRevision","props","revision","goToRoute","useRouter","openRevisionList","usePageEditorDrawer","showDialog","useDialogs","showSuccessToast","showWarningToast","useToast","createPageRevisionFrom","useCreatePageRevisionFrom","deletePageRevision","useDeletePageRevision","publishPage","usePublishPage","unpublishPage","useUnpublishPage","createRevision","useCallback","deleteRevision","DeleteIcon","Text","ex","publishRevision","PublishIcon","unpublishRevision","UnpublishIcon","editRevision","Routes"],"mappings":";;;;;;;;;;AAsBO,MAAMA,cAAc,CAACC;IACxB,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IAErB,MAAM,EAAEE,SAAS,EAAE,GAAGC;IACtB,MAAM,EAAEC,gBAAgB,EAAE,GAAGC;IAC7B,MAAM,EAAEC,UAAU,EAAE,GAAGC;IACvB,MAAM,EAA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4B,CAAC;oBACtE;gBACJ,EAAE,OAAOuB,IAAI;oBACTf,iBAAiB;wBACb,OAAO;wBACP,aAAae,GAAG,OAAO;oBAC3B;gBACJ;YACJ;QACJ;IACJ,GAAG;QAACvB,SAAS,EAAE;QAAEA,SAAS,OAAO;KAAC;IAElC,MAAM0B,oBAAoBP,YAAY;QAClCd,WAAW;YACP,OAAO;YACP,MAAM,WAAN,GAAM,oBAACsB,mCAAaA;YACpB,SAAS,WAAT,GACI,oBAACL,MAAIA,MACA,CAAC,qCAAqC,EAAEtB,SAAS,OAAO,CAAC,mFAAmF,CAAC;YAGtJ,aAAa;YACb,aAAa;YACb,UAAU;gBACN,IAAI;oBACA,MAAMgB,cAAc;wBAChB,IAAIhB,SAAS,EAAE;oBACnB;oBAEAO,iBAAiB;wBACb,OAAO,CAAC,UAAU,EAAEP,SAAS,OAAO,CAAC,8BAA8B,CAAC;oBACxE;gBACJ,EAAE,OAAOuB,IAAI;oBACTf,iBAAiB;wBACb,OAAO;wBACP,aAAae,GAAG,OAAO;oBAC3B;gBACJ;YACJ;QACJ;IACJ,GAAG;QAACvB,SAAS,EAAE;QAAEA,SAAS,OAAO;KAAC;IAElC,MAAM4B,eAAeT,YAAY;QAE7BhB,iBAAiB;QAEjBF,UAAU4B,OAAO,KAAK,CAAC,MAAM,EAAE;YAC3B,IAAI7B,SAAS,EAAE;QACnB;IACJ,GAAG;QAACA,SAAS,EAAE;QAAEG;KAAiB;IAElC,OAAO;QACHe;QACAU;QACAR;QACAI;QACAE;IACJ;AACJ"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { autorun } from "mobx";
|
|
3
|
+
import { useFeature } from "@webiny/app";
|
|
4
|
+
import { parseIdentifier } from "@webiny/utils/parseIdentifier.js";
|
|
5
|
+
import { RevisionListFeature } from "../../../../presentation/pages/RevisionList/feature.js";
|
|
6
|
+
const useRevisionList = (pageId)=>{
|
|
7
|
+
const { presenter } = useFeature(RevisionListFeature);
|
|
8
|
+
const { id: entryId } = useMemo(()=>parseIdentifier(pageId), [
|
|
9
|
+
pageId
|
|
10
|
+
]);
|
|
11
|
+
useEffect(()=>{
|
|
12
|
+
presenter.init({
|
|
13
|
+
entryId
|
|
14
|
+
});
|
|
15
|
+
}, [
|
|
16
|
+
entryId,
|
|
17
|
+
presenter
|
|
18
|
+
]);
|
|
19
|
+
const [vm, setVm] = useState(presenter.vm);
|
|
20
|
+
useEffect(()=>autorun(()=>{
|
|
21
|
+
setVm(presenter.vm);
|
|
22
|
+
}), [
|
|
23
|
+
presenter
|
|
24
|
+
]);
|
|
25
|
+
return {
|
|
26
|
+
vm
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export { useRevisionList };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=useRevisionList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules/pages/PageEditor/Revisions/useRevisionList.js","sources":["../../../../../src/modules/pages/PageEditor/Revisions/useRevisionList.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport { autorun } from \"mobx\";\nimport { useFeature } from \"@webiny/app\";\nimport { parseIdentifier } from \"@webiny/utils/parseIdentifier.js\";\nimport { RevisionListFeature } from \"~/presentation/pages/RevisionList/feature.js\";\n\nexport const useRevisionList = (pageId: string) => {\n const { presenter } = useFeature(RevisionListFeature);\n\n const { id: entryId } = useMemo(() => parseIdentifier(pageId), [pageId]);\n\n useEffect(() => {\n presenter.init({ entryId });\n }, [entryId, presenter]);\n\n const [vm, setVm] = useState(presenter.vm);\n\n useEffect(() => {\n return autorun(() => {\n setVm(presenter.vm);\n });\n }, [presenter]);\n\n return { vm };\n};\n"],"names":["useRevisionList","pageId","presenter","useFeature","RevisionListFeature","entryId","useMemo","parseIdentifier","useEffect","vm","setVm","useState","autorun"],"mappings":";;;;;AAMO,MAAMA,kBAAkB,CAACC;IAC5B,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IAEjC,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,QAAQ,IAAMC,gBAAgBN,SAAS;QAACA;KAAO;IAEvEO,UAAU;QACNN,UAAU,IAAI,CAAC;YAAEG;QAAQ;IAC7B,GAAG;QAACA;QAASH;KAAU;IAEvB,MAAM,CAACO,IAAIC,MAAM,GAAGC,SAAST,UAAU,EAAE;IAEzCM,UAAU,IACCI,QAAQ;YACXF,MAAMR,UAAU,EAAE;QACtB,IACD;QAACA;KAAU;IAEd,OAAO;QAAEO;IAAG;AAChB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import react, { useCallback
|
|
1
|
+
import react, { useCallback } from "react";
|
|
2
2
|
import { Button, DropdownMenu, Text } from "@webiny/admin-ui";
|
|
3
3
|
import { ReactComponent } from "@webiny/icons/keyboard_arrow_down.svg";
|
|
4
4
|
import { ReactComponent as draw_svg_ReactComponent } from "@webiny/icons/draw.svg";
|
|
5
5
|
import { ReactComponent as lock_svg_ReactComponent } from "@webiny/icons/lock.svg";
|
|
6
6
|
import { ReactComponent as remove_red_eye_svg_ReactComponent } from "@webiny/icons/remove_red_eye.svg";
|
|
7
|
-
import { useGetPageRevisions } from "../../../../features/pages/index.js";
|
|
8
7
|
import { useSelectFromDocument } from "../../../../BaseEditor/hooks/useSelectFromDocument.js";
|
|
8
|
+
import { useRevisionList } from "../Revisions/useRevisionList.js";
|
|
9
9
|
import { useRouter } from "@webiny/app-admin";
|
|
10
10
|
import { Routes } from "../../../../routes.js";
|
|
11
11
|
import { usePageEditorDrawer } from "../Revisions/usePageEditorDrawer.js";
|
|
@@ -17,23 +17,11 @@ const statusIcon = {
|
|
|
17
17
|
};
|
|
18
18
|
const RevisionsMenu = ()=>{
|
|
19
19
|
const { getLink } = useRouter();
|
|
20
|
-
const [revisions, setRevisions] = useState([]);
|
|
21
|
-
const { loading, getPageRevisions } = useGetPageRevisions();
|
|
22
20
|
const id = useSelectFromDocument((document)=>document.id);
|
|
23
|
-
const status = useSelectFromDocument((document)=>document.status);
|
|
24
21
|
const { openRevisionList } = usePageEditorDrawer();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
entryId
|
|
29
|
-
}).then((revisions)=>{
|
|
30
|
-
setRevisions(revisions.sort((a, b)=>new Date(a.savedOn).getTime() - new Date(b.savedOn).getTime()).reverse());
|
|
31
|
-
});
|
|
32
|
-
}, [
|
|
33
|
-
id,
|
|
34
|
-
status
|
|
35
|
-
]);
|
|
36
|
-
const currentRevision = revisions.find((r)=>r.id === id);
|
|
22
|
+
const { vm } = useRevisionList(id);
|
|
23
|
+
const { revisions, isLoading } = vm;
|
|
24
|
+
const currentRevision = revisions.find((item)=>item.revision.id === id)?.revision;
|
|
37
25
|
const goToRevision = useCallback((id)=>{
|
|
38
26
|
window.location.pathname = getLink(Routes.Pages.Editor, {
|
|
39
27
|
id
|
|
@@ -44,13 +32,13 @@ const RevisionsMenu = ()=>{
|
|
|
44
32
|
}, []);
|
|
45
33
|
return /*#__PURE__*/ react.createElement(DropdownMenu, {
|
|
46
34
|
trigger: /*#__PURE__*/ react.createElement(Button, {
|
|
47
|
-
disabled:
|
|
35
|
+
disabled: isLoading,
|
|
48
36
|
variant: "ghost",
|
|
49
37
|
text: currentRevision ? currentRevision.getLabel() : "Loading...",
|
|
50
38
|
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
51
39
|
iconPosition: "end"
|
|
52
40
|
})
|
|
53
|
-
}, revisions.slice(0, 5).map((revision)=>/*#__PURE__*/ react.createElement(Item, {
|
|
41
|
+
}, revisions.slice(0, 5).map(({ revision })=>/*#__PURE__*/ react.createElement(Item, {
|
|
54
42
|
key: revision.id,
|
|
55
43
|
className: "cursor-pointer",
|
|
56
44
|
onClick: ()=>goToRevision(revision.id),
|
|
@@ -61,13 +49,13 @@ const RevisionsMenu = ()=>{
|
|
|
61
49
|
text: /*#__PURE__*/ react.createElement(Text, {
|
|
62
50
|
size: "sm"
|
|
63
51
|
}, revision.getLabel())
|
|
64
|
-
})),
|
|
52
|
+
})), /*#__PURE__*/ react.createElement(DropdownMenu.Separator, null), /*#__PURE__*/ react.createElement(DropdownMenu.Item, {
|
|
65
53
|
key: "revisions-all",
|
|
66
54
|
onClick: onOpenRevisionList,
|
|
67
55
|
text: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Text, {
|
|
68
56
|
size: "sm"
|
|
69
57
|
}, "Show All Revisions"))
|
|
70
|
-
}))
|
|
58
|
+
}));
|
|
71
59
|
};
|
|
72
60
|
export { RevisionsMenu };
|
|
73
61
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules/pages/PageEditor/TopBar/RevisionsMenu.js","sources":["../../../../../src/modules/pages/PageEditor/TopBar/RevisionsMenu.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"modules/pages/PageEditor/TopBar/RevisionsMenu.js","sources":["../../../../../src/modules/pages/PageEditor/TopBar/RevisionsMenu.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { Button, DropdownMenu, Text } from \"@webiny/admin-ui\";\nimport { ReactComponent as ArrowDown } from \"@webiny/icons/keyboard_arrow_down.svg\";\nimport { ReactComponent as Draft } from \"@webiny/icons/draw.svg\";\nimport { ReactComponent as Unpublished } from \"@webiny/icons/lock.svg\";\nimport { ReactComponent as Published } from \"@webiny/icons/remove_red_eye.svg\";\nimport { useSelectFromDocument } from \"~/BaseEditor/hooks/useSelectFromDocument.js\";\nimport { useRevisionList } from \"~/modules/pages/PageEditor/Revisions/useRevisionList.js\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport { Routes } from \"~/routes.js\";\nimport { usePageEditorDrawer } from \"~/modules/pages/PageEditor/Revisions/usePageEditorDrawer.js\";\n\nconst { Item } = DropdownMenu;\n\nconst statusIcon: Record<string, React.JSX.Element> = {\n draft: <Draft />,\n published: <Published />,\n unpublished: <Unpublished />\n};\n\nexport const RevisionsMenu = () => {\n const { getLink } = useRouter();\n const id = useSelectFromDocument(document => document.id);\n\n const { openRevisionList } = usePageEditorDrawer();\n\n // Shares the presenter with the revisions drawer, so mutations made there are reflected here.\n const { vm } = useRevisionList(id);\n const { revisions, isLoading } = vm;\n\n const currentRevision = revisions.find(item => item.revision.id === id)?.revision;\n\n const goToRevision = useCallback((id: string) => {\n // TODO: make this work without a full app reload\n window.location.pathname = getLink(Routes.Pages.Editor, { id });\n }, []);\n\n const onOpenRevisionList = useCallback(() => {\n openRevisionList(true);\n }, []);\n\n return (\n <DropdownMenu\n trigger={\n <Button\n disabled={isLoading}\n variant=\"ghost\"\n text={currentRevision ? currentRevision.getLabel() : \"Loading...\"}\n icon={<ArrowDown />}\n iconPosition={\"end\"}\n />\n }\n >\n {revisions.slice(0, 5).map(({ revision }) => (\n <Item\n key={revision.id}\n className={\"cursor-pointer\"}\n onClick={() => goToRevision(revision.id)}\n icon={\n <Item.Icon\n label={revision.getLabel()}\n element={statusIcon[revision.status]}\n />\n }\n text={<Text size={\"sm\"}>{revision.getLabel()}</Text>}\n />\n ))}\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n key={\"revisions-all\"}\n onClick={onOpenRevisionList}\n text={\n <>\n <Text size={\"sm\"}>Show All Revisions</Text>\n </>\n }\n />\n </DropdownMenu>\n );\n};\n"],"names":["Item","DropdownMenu","statusIcon","Draft","Published","Unpublished","RevisionsMenu","getLink","useRouter","id","useSelectFromDocument","document","openRevisionList","usePageEditorDrawer","vm","useRevisionList","revisions","isLoading","currentRevision","item","goToRevision","useCallback","window","Routes","onOpenRevisionList","Button","ArrowDown","revision","Text"],"mappings":";;;;;;;;;;;AAYA,MAAM,EAAEA,MAAAA,IAAI,EAAE,GAAGC;AAEjB,MAAMC,aAAgD;IAClD,OAAO,WAAP,GAAO,oBAACC,yBAAKA;IACb,WAAW,WAAX,GAAW,oBAACC,mCAASA;IACrB,aAAa,WAAb,GAAa,oBAACC,yBAAWA;AAC7B;AAEO,MAAMC,gBAA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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-website-builder",
|
|
3
|
-
"version": "6.4.12-beta.
|
|
3
|
+
"version": "6.4.12-beta.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -21,28 +21,28 @@
|
|
|
21
21
|
"@monaco-editor/react": "4.7.0",
|
|
22
22
|
"@svgr/webpack": "8.1.0",
|
|
23
23
|
"@types/react": "18.3.31",
|
|
24
|
-
"@webiny/admin-ui": "6.4.12-beta.
|
|
25
|
-
"@webiny/app": "6.4.12-beta.
|
|
26
|
-
"@webiny/app-aco": "6.4.12-beta.
|
|
27
|
-
"@webiny/app-admin": "6.4.12-beta.
|
|
28
|
-
"@webiny/app-headless-cms-common": "6.4.12-beta.
|
|
29
|
-
"@webiny/app-trash-bin": "6.4.12-beta.
|
|
30
|
-
"@webiny/app-utils": "6.4.12-beta.
|
|
24
|
+
"@webiny/admin-ui": "6.4.12-beta.3",
|
|
25
|
+
"@webiny/app": "6.4.12-beta.3",
|
|
26
|
+
"@webiny/app-aco": "6.4.12-beta.3",
|
|
27
|
+
"@webiny/app-admin": "6.4.12-beta.3",
|
|
28
|
+
"@webiny/app-headless-cms-common": "6.4.12-beta.3",
|
|
29
|
+
"@webiny/app-trash-bin": "6.4.12-beta.3",
|
|
30
|
+
"@webiny/app-utils": "6.4.12-beta.3",
|
|
31
31
|
"@webiny/di": "1.1.0",
|
|
32
|
-
"@webiny/error": "6.4.12-beta.
|
|
33
|
-
"@webiny/feature": "6.4.12-beta.
|
|
34
|
-
"@webiny/form": "6.4.12-beta.
|
|
35
|
-
"@webiny/icons": "6.4.12-beta.
|
|
36
|
-
"@webiny/languages": "6.4.12-beta.
|
|
37
|
-
"@webiny/lexical-converter": "6.4.12-beta.
|
|
38
|
-
"@webiny/lexical-editor": "6.4.12-beta.
|
|
39
|
-
"@webiny/lexical-nodes": "6.4.12-beta.
|
|
40
|
-
"@webiny/lexical-theme": "6.4.12-beta.
|
|
41
|
-
"@webiny/react-composition": "6.4.12-beta.
|
|
42
|
-
"@webiny/react-properties": "6.4.12-beta.
|
|
43
|
-
"@webiny/utils": "6.4.12-beta.
|
|
44
|
-
"@webiny/validation": "6.4.12-beta.
|
|
45
|
-
"@webiny/website-builder-sdk": "6.4.12-beta.
|
|
32
|
+
"@webiny/error": "6.4.12-beta.3",
|
|
33
|
+
"@webiny/feature": "6.4.12-beta.3",
|
|
34
|
+
"@webiny/form": "6.4.12-beta.3",
|
|
35
|
+
"@webiny/icons": "6.4.12-beta.3",
|
|
36
|
+
"@webiny/languages": "6.4.12-beta.3",
|
|
37
|
+
"@webiny/lexical-converter": "6.4.12-beta.3",
|
|
38
|
+
"@webiny/lexical-editor": "6.4.12-beta.3",
|
|
39
|
+
"@webiny/lexical-nodes": "6.4.12-beta.3",
|
|
40
|
+
"@webiny/lexical-theme": "6.4.12-beta.3",
|
|
41
|
+
"@webiny/react-composition": "6.4.12-beta.3",
|
|
42
|
+
"@webiny/react-properties": "6.4.12-beta.3",
|
|
43
|
+
"@webiny/utils": "6.4.12-beta.3",
|
|
44
|
+
"@webiny/validation": "6.4.12-beta.3",
|
|
45
|
+
"@webiny/website-builder-sdk": "6.4.12-beta.3",
|
|
46
46
|
"apollo-cache": "1.3.5",
|
|
47
47
|
"apollo-client": "2.6.10",
|
|
48
48
|
"apollo-link": "1.2.14",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/deep-equal": "1.0.4",
|
|
71
71
|
"@types/is-hotkey": "0.1.10",
|
|
72
|
-
"@webiny/build-tools": "6.4.12-beta.
|
|
72
|
+
"@webiny/build-tools": "6.4.12-beta.3",
|
|
73
73
|
"execa": "5.1.1",
|
|
74
74
|
"rimraf": "6.1.3",
|
|
75
75
|
"typescript": "6.0.3",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GetPageRevisionsUseCase } from "../../../features/pages/getPageRevisions/abstractions.js";
|
|
2
|
+
import { PageRevisionsCache, WbPageLoadingRepository, WbPageRevisionsLoadingRepository } from "../../../features/pages/shared/abstractions.js";
|
|
3
|
+
import { WbPermissions } from "../../../features/permissions/abstractions.js";
|
|
4
|
+
import { RevisionListPresenter as PresenterAbstraction } from "./abstractions.js";
|
|
5
|
+
declare class RevisionListPresenterImpl implements PresenterAbstraction.Interface {
|
|
6
|
+
private revisionsCache;
|
|
7
|
+
private loadingRepository;
|
|
8
|
+
private pageLoadingRepository;
|
|
9
|
+
private permissions;
|
|
10
|
+
private getPageRevisions;
|
|
11
|
+
private entryId;
|
|
12
|
+
constructor(revisionsCache: PageRevisionsCache.Interface, loadingRepository: WbPageRevisionsLoadingRepository.Interface, pageLoadingRepository: WbPageLoadingRepository.Interface, permissions: WbPermissions.Interface, getPageRevisions: GetPageRevisionsUseCase.Interface);
|
|
13
|
+
init(params: PresenterAbstraction.Init): void;
|
|
14
|
+
get vm(): PresenterAbstraction.ViewModel;
|
|
15
|
+
private getRevisions;
|
|
16
|
+
private getItemVm;
|
|
17
|
+
private getIsLoading;
|
|
18
|
+
/**
|
|
19
|
+
* Watching named actions rather than `hasLoading()`: the `WbPage` namespace is shared with
|
|
20
|
+
* the pages table, so that would also react to listing and fetching.
|
|
21
|
+
*/
|
|
22
|
+
private getIsMutating;
|
|
23
|
+
}
|
|
24
|
+
export declare const RevisionListPresenter: typeof RevisionListPresenterImpl & {
|
|
25
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IRevisionListPresenter>;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { makeAutoObservable } from "mobx";
|
|
2
|
+
import orderBy from "lodash/orderBy.js";
|
|
3
|
+
import { WbPageStatus, loadingActions } from "../../../constants.js";
|
|
4
|
+
import { GetPageRevisionsUseCase } from "../../../features/pages/getPageRevisions/abstractions.js";
|
|
5
|
+
import { PageRevisionsCache, WbPageLoadingRepository, WbPageRevisionsLoadingRepository } from "../../../features/pages/shared/abstractions.js";
|
|
6
|
+
import { WbPermissions } from "../../../features/permissions/abstractions.js";
|
|
7
|
+
import { RevisionListPresenter } from "./abstractions.js";
|
|
8
|
+
const MUTATION_ACTIONS = [
|
|
9
|
+
loadingActions.createRevisionFrom
|
|
10
|
+
];
|
|
11
|
+
class RevisionListPresenterImpl {
|
|
12
|
+
constructor(revisionsCache, loadingRepository, pageLoadingRepository, permissions, getPageRevisions){
|
|
13
|
+
this.revisionsCache = revisionsCache;
|
|
14
|
+
this.loadingRepository = loadingRepository;
|
|
15
|
+
this.pageLoadingRepository = pageLoadingRepository;
|
|
16
|
+
this.permissions = permissions;
|
|
17
|
+
this.getPageRevisions = getPageRevisions;
|
|
18
|
+
this.entryId = void 0;
|
|
19
|
+
this.getRevisions = ()=>{
|
|
20
|
+
if (!this.entryId) return [];
|
|
21
|
+
const revisions = this.revisionsCache.getItems().filter((revision)=>revision.entryId === this.entryId);
|
|
22
|
+
return orderBy(revisions, [
|
|
23
|
+
"savedOn"
|
|
24
|
+
], [
|
|
25
|
+
"desc"
|
|
26
|
+
]).map((revision)=>this.getItemVm(revision));
|
|
27
|
+
};
|
|
28
|
+
this.getItemVm = (revision)=>{
|
|
29
|
+
const canEdit = this.permissions.canEdit("page", revision);
|
|
30
|
+
return {
|
|
31
|
+
revision,
|
|
32
|
+
canCreateFrom: canEdit,
|
|
33
|
+
canEdit: !revision.locked && canEdit,
|
|
34
|
+
canPublish: revision.status !== WbPageStatus.Published && this.permissions.canPublish("page"),
|
|
35
|
+
canUnpublish: revision.status === WbPageStatus.Published && this.permissions.canUnpublish("page"),
|
|
36
|
+
canDelete: this.permissions.canDelete("page", revision)
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
this.getIsLoading = ()=>Boolean(this.loadingRepository.isLoading(loadingActions.get));
|
|
40
|
+
this.getIsMutating = ()=>MUTATION_ACTIONS.some((action)=>this.pageLoadingRepository.isLoading(action));
|
|
41
|
+
makeAutoObservable(this);
|
|
42
|
+
}
|
|
43
|
+
init(params) {
|
|
44
|
+
if (this.entryId === params.entryId) return;
|
|
45
|
+
this.entryId = params.entryId;
|
|
46
|
+
this.getPageRevisions.execute({
|
|
47
|
+
entryId: params.entryId
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
get vm() {
|
|
51
|
+
const revisions = this.getRevisions();
|
|
52
|
+
const isLoading = this.getIsLoading();
|
|
53
|
+
return {
|
|
54
|
+
revisions,
|
|
55
|
+
isLoading,
|
|
56
|
+
isMutating: this.getIsMutating(),
|
|
57
|
+
isEmpty: !isLoading && 0 === revisions.length
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const RevisionListPresenter_RevisionListPresenter = RevisionListPresenter.createImplementation({
|
|
62
|
+
implementation: RevisionListPresenterImpl,
|
|
63
|
+
dependencies: [
|
|
64
|
+
PageRevisionsCache,
|
|
65
|
+
WbPageRevisionsLoadingRepository,
|
|
66
|
+
WbPageLoadingRepository,
|
|
67
|
+
WbPermissions,
|
|
68
|
+
GetPageRevisionsUseCase
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
export { RevisionListPresenter_RevisionListPresenter as RevisionListPresenter };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=RevisionListPresenter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/pages/RevisionList/RevisionListPresenter.js","sources":["../../../../src/presentation/pages/RevisionList/RevisionListPresenter.ts"],"sourcesContent":["import { makeAutoObservable } from \"mobx\";\nimport orderBy from \"lodash/orderBy.js\";\nimport { loadingActions, WbPageStatus } from \"~/constants.js\";\nimport { GetPageRevisionsUseCase } from \"~/features/pages/getPageRevisions/abstractions.js\";\nimport {\n PageRevisionsCache,\n WbPageLoadingRepository,\n WbPageRevisionsLoadingRepository\n} from \"~/features/pages/shared/abstractions.js\";\nimport { WbPermissions } from \"~/features/permissions/abstractions.js\";\nimport type { PageRevision } from \"~/domain/PageRevision/PageRevision.js\";\nimport { RevisionListPresenter as PresenterAbstraction } from \"./abstractions.js\";\n\n/**\n * Only actions that run straight from the menu need the overlay. Delete, publish and unpublish\n * are confirmed through a dialog, which shows its own loader while the action runs.\n */\nconst MUTATION_ACTIONS = [loadingActions.createRevisionFrom];\n\nclass RevisionListPresenterImpl implements PresenterAbstraction.Interface {\n private entryId: string | undefined = undefined;\n\n constructor(\n private revisionsCache: PageRevisionsCache.Interface,\n private loadingRepository: WbPageRevisionsLoadingRepository.Interface,\n private pageLoadingRepository: WbPageLoadingRepository.Interface,\n private permissions: WbPermissions.Interface,\n private getPageRevisions: GetPageRevisionsUseCase.Interface\n ) {\n makeAutoObservable(this);\n }\n\n public init(params: PresenterAbstraction.Init) {\n if (this.entryId === params.entryId) {\n return;\n }\n\n this.entryId = params.entryId;\n void this.getPageRevisions.execute({ entryId: params.entryId });\n }\n\n public get vm(): PresenterAbstraction.ViewModel {\n const revisions = this.getRevisions();\n const isLoading = this.getIsLoading();\n\n return {\n revisions,\n isLoading,\n isMutating: this.getIsMutating(),\n isEmpty: !isLoading && revisions.length === 0\n };\n }\n\n private getRevisions = () => {\n if (!this.entryId) {\n return [];\n }\n\n // The cache is shared across pages, so it can hold revisions of previously opened pages.\n const revisions = this.revisionsCache\n .getItems()\n .filter(revision => revision.entryId === this.entryId);\n\n return orderBy(revisions, [\"savedOn\"], [\"desc\"]).map(revision => this.getItemVm(revision));\n };\n\n private getItemVm = (revision: PageRevision): PresenterAbstraction.ItemViewModel => {\n const canEdit = this.permissions.canEdit(\"page\", revision);\n\n return {\n revision,\n canCreateFrom: canEdit,\n // A locked revision has already been published, so its content can no longer change.\n canEdit: !revision.locked && canEdit,\n canPublish:\n revision.status !== WbPageStatus.Published && this.permissions.canPublish(\"page\"),\n canUnpublish:\n revision.status === WbPageStatus.Published && this.permissions.canUnpublish(\"page\"),\n // Deleting a published or locked revision is allowed, matching the API.\n canDelete: this.permissions.canDelete(\"page\", revision)\n };\n };\n\n private getIsLoading = () => {\n return Boolean(this.loadingRepository.isLoading(loadingActions.get));\n };\n\n /**\n * Watching named actions rather than `hasLoading()`: the `WbPage` namespace is shared with\n * the pages table, so that would also react to listing and fetching.\n */\n private getIsMutating = () => {\n return MUTATION_ACTIONS.some(action => this.pageLoadingRepository.isLoading(action));\n };\n}\n\nexport const RevisionListPresenter = PresenterAbstraction.createImplementation({\n implementation: RevisionListPresenterImpl,\n dependencies: [\n PageRevisionsCache,\n WbPageRevisionsLoadingRepository,\n WbPageLoadingRepository,\n WbPermissions,\n GetPageRevisionsUseCase\n ]\n});\n"],"names":["MUTATION_ACTIONS","loadingActions","RevisionListPresenterImpl","revisionsCache","loadingRepository","pageLoadingRepository","permissions","getPageRevisions","undefined","revisions","revision","orderBy","canEdit","WbPageStatus","Boolean","action","makeAutoObservable","params","isLoading","RevisionListPresenter","PresenterAbstraction","PageRevisionsCache","WbPageRevisionsLoadingRepository","WbPageLoadingRepository","WbPermissions","GetPageRevisionsUseCase"],"mappings":";;;;;;;AAiBA,MAAMA,mBAAmB;IAACC,eAAe,kBAAkB;CAAC;AAE5D,MAAMC;IAGF,YACYC,cAA4C,EAC5CC,iBAA6D,EAC7DC,qBAAwD,EACxDC,WAAoC,EACpCC,gBAAmD,CAC7D;aALUJ,cAAc,GAAdA;aACAC,iBAAiB,GAAjBA;aACAC,qBAAqB,GAArBA;aACAC,WAAW,GAAXA;aACAC,gBAAgB,GAAhBA;aAPJ,OAAO,GAAuBC;aAiC9B,YAAY,GAAG;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EACb,OAAO,EAAE;YAIb,MAAMC,YAAY,IAAI,CAAC,cAAc,CAChC,QAAQ,GACR,MAAM,CAACC,CAAAA,WAAYA,SAAS,OAAO,KAAK,IAAI,CAAC,OAAO;YAEzD,OAAOC,QAAQF,WAAW;gBAAC;aAAU,EAAE;gBAAC;aAAO,EAAE,GAAG,CAACC,CAAAA,WAAY,IAAI,CAAC,SAAS,CAACA;QACpF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