@raketa-cloud/admin 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/HonoAdapter.js +93 -95
- package/src/cloud/PageRevisions.js +15 -1
- package/src/cloud/Pages.js +68 -0
- package/src/handlers/PageCloneHandler.js +1 -1
- package/src/handlers/PageCloneHandler.test/create.test.js +4 -4
- package/src/handlers/PageDeleteHandler.js +2 -2
- package/src/handlers/PageDeleteHandler.test/create.test.js +2 -4
- package/src/handlers/PageTranslationsHandler.js +2 -2
- package/src/handlers/PageURLsHandler.js +1 -1
- package/src/handlers/PageURLsHandler.test/create.test.js +3 -5
- package/src/handlers/RevertPageRevisionHandler.js +1 -1
- package/src/handlers/RevertPageRevisionHandler.test/create.test.js +5 -5
- package/src/index.js +4 -6
- package/src/routeNestedCollection.js +7 -7
- package/src/routePages.js +100 -0
- package/src/routeSettings.js +12 -0
- package/src/routeStandard.js +14 -0
- package/src/setupCloud.js +24 -0
- package/src/tests/routeNestedCollection.test.js +14 -14
- package/src/views/{page_lock → page_revisions/locks}/create_form.ejs +2 -2
- package/src/views/{page_publish → page_revisions/publishes}/_form.ejs +1 -1
- package/src/views/page_revisions/publishes/create_form.ejs +10 -0
- package/src/views/{page_deletes → pages/deletes}/create_form.ejs +2 -2
- package/src/views/pages/index.ejs +2 -2
- package/src/views/pages/show.ejs +7 -7
- package/src/views/{page_translations → pages/translations}/_form.ejs +2 -2
- package/src/views/{page_urls → pages/urls}/create_form.ejs +2 -2
- package/src/cloud/ChangePageURL.js +0 -24
- package/src/cloud/ClonesPage.js +0 -14
- package/src/cloud/DeletePage.js +0 -35
- package/src/cloud/PageTranslations.js +0 -22
- package/src/cloud/RevertPageRevision.js +0 -18
- package/src/setGlobalConfig.js +0 -5
- package/src/views/page_publish/create_form.ejs +0 -11
- /package/src/views/{page_translations → pages/translations}/create_form.ejs +0 -0
package/package.json
CHANGED
package/src/HonoAdapter.js
CHANGED
|
@@ -28,11 +28,11 @@ function bodyToParams(req, parsedBody, adapter) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export default class HonoAdapter extends Adapter {
|
|
31
|
-
constructor(router) {
|
|
31
|
+
constructor(router, config) {
|
|
32
32
|
super(router);
|
|
33
33
|
this.globalCtx = (ctx) => ctx;
|
|
34
34
|
this.router = router;
|
|
35
|
-
this.globalConfig =
|
|
35
|
+
this.globalConfig = config;
|
|
36
36
|
|
|
37
37
|
// TODO: Pass in a path to redirect to after login?
|
|
38
38
|
setupAuthentication(router, {
|
|
@@ -48,10 +48,6 @@ export default class HonoAdapter extends Adapter {
|
|
|
48
48
|
this.globalCtx = globalCtx;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
setGlobalConfig(globalConfigCallback) {
|
|
52
|
-
globalConfigCallback(this.globalConfig);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
51
|
async createContext(router, next, verb, resource, action) {
|
|
56
52
|
const body = await parseBody(router.req);
|
|
57
53
|
|
|
@@ -88,111 +84,113 @@ export default class HonoAdapter extends Adapter {
|
|
|
88
84
|
]) {
|
|
89
85
|
const method = this.getMethod(verb);
|
|
90
86
|
|
|
91
|
-
[...Object.keys(this.globalConfig.locales), ""].forEach(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
87
|
+
[...Object.keys(this.globalConfig.i18n.locales), ""].forEach(
|
|
88
|
+
(currentLocale) => {
|
|
89
|
+
const completedPath = `/${currentLocale}${path}`;
|
|
90
|
+
|
|
91
|
+
method(completedPath, async (routerCtx, next) => {
|
|
92
|
+
const ctx = await this.createContext(
|
|
93
|
+
routerCtx,
|
|
94
|
+
next,
|
|
95
|
+
verb,
|
|
96
|
+
resource,
|
|
97
|
+
action
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
ctx.locales = this.globalConfig.i18n.locales;
|
|
101
|
+
ctx.defaultLocale = this.globalConfig.i18n.defaultLocale;
|
|
102
|
+
ctx.locale = currentLocale;
|
|
103
|
+
|
|
104
|
+
const _context = {
|
|
105
|
+
locales: ctx.locales,
|
|
106
|
+
locale: ctx.locale,
|
|
107
|
+
defaultLocale: ctx.defaultLocale,
|
|
108
|
+
path: ctx.req.path,
|
|
109
|
+
query: ctx.query || {},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
console.info(
|
|
113
|
+
`\x1b[35m[${ctx.method}] ${ctx.rawPath}\x1b[0m -> ${resource}/${action} | ${JSON.stringify(ctx.params)}`
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const assigns = {
|
|
117
|
+
beforeFilterAssigns: {},
|
|
118
|
+
actionAssigns: {},
|
|
119
|
+
afterFilterAssigns: {},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Initialize global context
|
|
123
|
+
ctx.initGlobalContext();
|
|
124
|
+
|
|
125
|
+
// Process before filters
|
|
126
|
+
if (before_filter) {
|
|
127
|
+
const {
|
|
128
|
+
redirect,
|
|
129
|
+
json,
|
|
130
|
+
assigns: beforeFilterAssigns = {},
|
|
131
|
+
} = before_filter(ctx) || {};
|
|
132
|
+
|
|
133
|
+
if (redirect) return routerCtx.redirect(redirect);
|
|
134
|
+
|
|
135
|
+
if (json) {
|
|
136
|
+
return routerCtx.json(json);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
assigns.beforeFilterAssigns = beforeFilterAssigns;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Process action
|
|
130
143
|
const {
|
|
144
|
+
headers,
|
|
131
145
|
redirect,
|
|
132
146
|
json,
|
|
133
|
-
assigns:
|
|
134
|
-
} =
|
|
135
|
-
|
|
136
|
-
if (redirect) return routerCtx.redirect(redirect);
|
|
147
|
+
assigns: actionAssigns = {},
|
|
148
|
+
} = (await handler(ctx)) || {};
|
|
149
|
+
assigns.actionAssigns = actionAssigns;
|
|
137
150
|
|
|
138
|
-
|
|
139
|
-
return routerCtx.json(json);
|
|
140
|
-
}
|
|
151
|
+
this.applyHeaders(headers, routerCtx);
|
|
141
152
|
|
|
142
|
-
|
|
143
|
-
}
|
|
153
|
+
if (redirect) return routerCtx.redirect(redirect);
|
|
144
154
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
assigns.actionAssigns = actionAssigns;
|
|
155
|
+
// Process after filters
|
|
156
|
+
if (after_filter) {
|
|
157
|
+
const {
|
|
158
|
+
redirect,
|
|
159
|
+
json,
|
|
160
|
+
assigns: afterFilterAssigns = {},
|
|
161
|
+
} = after_filter(ctx) || {};
|
|
153
162
|
|
|
154
|
-
|
|
163
|
+
if (redirect) return routerCtx.redirect(redirect);
|
|
155
164
|
|
|
156
|
-
|
|
165
|
+
if (json) {
|
|
166
|
+
return routerCtx.json(json);
|
|
167
|
+
}
|
|
157
168
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const {
|
|
161
|
-
redirect,
|
|
162
|
-
json,
|
|
163
|
-
assigns: afterFilterAssigns = {},
|
|
164
|
-
} = after_filter(ctx) || {};
|
|
169
|
+
assigns.afterFilterAssigns = afterFilterAssigns;
|
|
170
|
+
}
|
|
165
171
|
|
|
166
|
-
|
|
172
|
+
const fullAssigns = {
|
|
173
|
+
...ctx.assigns,
|
|
174
|
+
...assigns.beforeFilterAssigns,
|
|
175
|
+
...assigns.actionAssigns,
|
|
176
|
+
...assigns.afterFilterAssigns,
|
|
177
|
+
_context: _context,
|
|
178
|
+
};
|
|
167
179
|
|
|
168
180
|
if (json) {
|
|
169
181
|
return routerCtx.json(json);
|
|
170
182
|
}
|
|
171
183
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
...assigns.beforeFilterAssigns,
|
|
178
|
-
...assigns.actionAssigns,
|
|
179
|
-
...assigns.afterFilterAssigns,
|
|
180
|
-
_context: _context,
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
if (json) {
|
|
184
|
-
return routerCtx.json(json);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const rendered = this.renderAction({
|
|
188
|
-
views,
|
|
189
|
-
action,
|
|
190
|
-
assigns: fullAssigns,
|
|
191
|
-
});
|
|
184
|
+
const rendered = this.renderAction({
|
|
185
|
+
views,
|
|
186
|
+
action,
|
|
187
|
+
assigns: fullAssigns,
|
|
188
|
+
});
|
|
192
189
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
190
|
+
return routerCtx.html(rendered);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
);
|
|
196
194
|
}
|
|
197
195
|
|
|
198
196
|
routeCollection(mapping) {
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
DeletePageDocument,
|
|
4
4
|
LockPageRevisionDocument,
|
|
5
5
|
MergePageRevisionDocument,
|
|
6
|
-
PageByIdDocument,
|
|
7
6
|
PageRevisionDocument,
|
|
8
7
|
PageRevisionsDocument,
|
|
9
8
|
StartPageRevisionDocument,
|
|
10
9
|
UnlockPageRevisionDocument,
|
|
11
10
|
UpdatePageDocument,
|
|
12
11
|
UpdatePageWidgetsDocument,
|
|
12
|
+
ReopenPageChangeDocument,
|
|
13
13
|
} from "./documents/pagesDocuments";
|
|
14
14
|
|
|
15
15
|
export default class PageRevisions extends RaketaClient {
|
|
@@ -132,4 +132,18 @@ export default class PageRevisions extends RaketaClient {
|
|
|
132
132
|
|
|
133
133
|
return { revision, errors };
|
|
134
134
|
}
|
|
135
|
+
|
|
136
|
+
async revert(pageId, version, locale) {
|
|
137
|
+
const {
|
|
138
|
+
reopenPageChange: { revision, errors, pageErrors },
|
|
139
|
+
} = await this.query(ReopenPageChangeDocument, {
|
|
140
|
+
input: {
|
|
141
|
+
pageId,
|
|
142
|
+
locale,
|
|
143
|
+
version,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
return { revision, errors, pageErrors };
|
|
148
|
+
}
|
|
135
149
|
}
|
package/src/cloud/Pages.js
CHANGED
|
@@ -3,6 +3,10 @@ import {
|
|
|
3
3
|
CreatePageDocument,
|
|
4
4
|
PageByIdDocument,
|
|
5
5
|
PagesDocument,
|
|
6
|
+
ClonePageDocument,
|
|
7
|
+
DeletePageDocument,
|
|
8
|
+
TranslatePageDocument,
|
|
9
|
+
ChangePageSlugDocument,
|
|
6
10
|
} from "./documents/pagesDocuments";
|
|
7
11
|
|
|
8
12
|
export default class Pages extends RaketaClient {
|
|
@@ -60,4 +64,68 @@ export default class Pages extends RaketaClient {
|
|
|
60
64
|
|
|
61
65
|
return { page, errors };
|
|
62
66
|
}
|
|
67
|
+
|
|
68
|
+
async clone(id, locale) {
|
|
69
|
+
const {
|
|
70
|
+
clonePage: { errors, page },
|
|
71
|
+
} = await this.query(ClonePageDocument, {
|
|
72
|
+
input: { id: id, locale: locale },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return { page, errors };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async delete(id, locale, redirect) {
|
|
79
|
+
const input = {
|
|
80
|
+
id,
|
|
81
|
+
locale,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
if (redirect) {
|
|
85
|
+
input.redirect = redirect;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const {
|
|
89
|
+
deletePage: { errors, page },
|
|
90
|
+
} = await this.query(DeletePageDocument, { input });
|
|
91
|
+
|
|
92
|
+
return { page, errors };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async translate(id, locale, params) {
|
|
96
|
+
params.widgets = JSON.stringify(params.widgets);
|
|
97
|
+
params.settings = JSON.stringify(params.settings);
|
|
98
|
+
|
|
99
|
+
const {
|
|
100
|
+
translatePage: { errors, page },
|
|
101
|
+
} = await this.query(TranslatePageDocument, {
|
|
102
|
+
input: {
|
|
103
|
+
locale,
|
|
104
|
+
sourcePageId: id,
|
|
105
|
+
page: params,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return { page, errors };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async updateSlug(id, slug, locale, redirect) {
|
|
113
|
+
const input = {
|
|
114
|
+
id,
|
|
115
|
+
slug,
|
|
116
|
+
locale,
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
if (redirect) {
|
|
120
|
+
input.redirect = redirect;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const {
|
|
124
|
+
changePageSlug: { errors, page },
|
|
125
|
+
} = await this.query(ChangePageSlugDocument, {
|
|
126
|
+
input,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return { page, errors };
|
|
130
|
+
}
|
|
63
131
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const create = async (ctx) => {
|
|
2
2
|
const { parent_id } = ctx.params;
|
|
3
3
|
|
|
4
|
-
const { errors } = await ctx.client.
|
|
4
|
+
const { errors } = await ctx.client.pages.clone(parent_id, ctx.locale);
|
|
5
5
|
|
|
6
6
|
if (errors) {
|
|
7
7
|
throw new Error(`Error cloning page: ${JSON.stringify(errors)}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Pages from "../../cloud/Pages";
|
|
2
2
|
import PageCloneHandler from "../PageCloneHandler";
|
|
3
3
|
|
|
4
4
|
import Factory from "../../../../../apps/admin/test/factory";
|
|
@@ -7,7 +7,7 @@ import { testConfig } from "../../../../../apps/admin/test/handlersHelper";
|
|
|
7
7
|
function buildCtx(page) {
|
|
8
8
|
return {
|
|
9
9
|
client: {
|
|
10
|
-
|
|
10
|
+
pages: new Pages(testConfig, "token"),
|
|
11
11
|
},
|
|
12
12
|
params: { parent_id: page.id },
|
|
13
13
|
locale: "en",
|
|
@@ -20,7 +20,7 @@ describe("Clone page", () => {
|
|
|
20
20
|
const ctx = buildCtx(page);
|
|
21
21
|
|
|
22
22
|
const mockClone = jest
|
|
23
|
-
.spyOn(ctx.client.
|
|
23
|
+
.spyOn(ctx.client.pages, "clone")
|
|
24
24
|
.mockImplementation(() => page);
|
|
25
25
|
|
|
26
26
|
const result = await PageCloneHandler.create(ctx);
|
|
@@ -38,7 +38,7 @@ describe("Clone page", () => {
|
|
|
38
38
|
const ctx = buildCtx(page);
|
|
39
39
|
|
|
40
40
|
const mockClone = jest
|
|
41
|
-
.spyOn(ctx.client.
|
|
41
|
+
.spyOn(ctx.client.pages, "clone")
|
|
42
42
|
.mockImplementation(() => ({
|
|
43
43
|
page: null,
|
|
44
44
|
errors: [{ key: "generalError", message: "some error" }],
|
|
@@ -39,7 +39,7 @@ const create = async (ctx) => {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const { errors } = await ctx.client.
|
|
42
|
+
const { errors } = await ctx.client.pages.delete(
|
|
43
43
|
page.id,
|
|
44
44
|
ctx.locale,
|
|
45
45
|
redirect
|
|
@@ -50,7 +50,7 @@ const create = async (ctx) => {
|
|
|
50
50
|
assigns: {
|
|
51
51
|
deleteAction: { ...params, id: page.id },
|
|
52
52
|
errors: {
|
|
53
|
-
deleteAction: ctx.client.
|
|
53
|
+
deleteAction: ctx.client.pages.formatErrors(errors, "redirect"),
|
|
54
54
|
},
|
|
55
55
|
_translations: [],
|
|
56
56
|
},
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import PageDeleteHandler from "../PageDeleteHandler";
|
|
2
2
|
import Pages from "../../cloud/Pages";
|
|
3
|
-
import DeletePage from "../../cloud/DeletePage";
|
|
4
3
|
import Factory from "../../../../../apps/admin/test/factory";
|
|
5
4
|
import { testConfig } from "../../../../../apps/admin/test/handlersHelper";
|
|
6
5
|
|
|
@@ -8,7 +7,6 @@ function buildCtx(page, updateSettings) {
|
|
|
8
7
|
return {
|
|
9
8
|
client: {
|
|
10
9
|
pages: new Pages(testConfig, "token"),
|
|
11
|
-
deletePage: new DeletePage(testConfig, "token"),
|
|
12
10
|
},
|
|
13
11
|
params: { parent_id: page.id },
|
|
14
12
|
resourceParams: {
|
|
@@ -32,7 +30,7 @@ describe("Page delete", () => {
|
|
|
32
30
|
.mockImplementation(() => page);
|
|
33
31
|
|
|
34
32
|
const mockDelete = jest
|
|
35
|
-
.spyOn(ctx.client.
|
|
33
|
+
.spyOn(ctx.client.pages, "delete")
|
|
36
34
|
.mockImplementation(() => ({ page, errors: null }));
|
|
37
35
|
|
|
38
36
|
const result = await PageDeleteHandler.create(ctx);
|
|
@@ -63,7 +61,7 @@ describe("Page delete", () => {
|
|
|
63
61
|
.mockImplementation(() => page);
|
|
64
62
|
|
|
65
63
|
const mockDelete = jest
|
|
66
|
-
.spyOn(ctx.client.
|
|
64
|
+
.spyOn(ctx.client.pages, "delete")
|
|
67
65
|
.mockImplementation(() => ({
|
|
68
66
|
page: null,
|
|
69
67
|
errors: [
|
|
@@ -41,9 +41,9 @@ const create = async (ctx) => {
|
|
|
41
41
|
const { target_locale, translation } = ctx.resourceParams;
|
|
42
42
|
translation.meta_image = JSON.parse(translation.meta_image);
|
|
43
43
|
|
|
44
|
-
const { errors } = await ctx.client.
|
|
45
|
-
target_locale,
|
|
44
|
+
const { errors } = await ctx.client.pages.translate(
|
|
46
45
|
parent_id,
|
|
46
|
+
target_locale,
|
|
47
47
|
{
|
|
48
48
|
title: translation.title,
|
|
49
49
|
slug: translation.slug,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import PageURLsHandler from "../PageURLsHandler";
|
|
2
2
|
import Pages from "../../cloud/Pages";
|
|
3
|
-
import ChangePageURL from "../../cloud/ChangePageURL";
|
|
4
3
|
import Factory from "../../../../../apps/admin/test/factory";
|
|
5
4
|
import { testConfig } from "../../../../../apps/admin/test/handlersHelper";
|
|
6
5
|
|
|
@@ -8,7 +7,6 @@ function buildCtx(page, updateSettings) {
|
|
|
8
7
|
return {
|
|
9
8
|
client: {
|
|
10
9
|
pages: new Pages(testConfig, "token"),
|
|
11
|
-
changePageURL: new ChangePageURL(testConfig, "token"),
|
|
12
10
|
},
|
|
13
11
|
params: { parent_id: page.id },
|
|
14
12
|
resourceParams: {
|
|
@@ -32,7 +30,7 @@ describe("Page change url", () => {
|
|
|
32
30
|
.mockImplementation(() => page);
|
|
33
31
|
|
|
34
32
|
const mockChange = jest
|
|
35
|
-
.spyOn(ctx.client.
|
|
33
|
+
.spyOn(ctx.client.pages, "updateSlug")
|
|
36
34
|
.mockImplementation(() => ({ page, errors: null }));
|
|
37
35
|
|
|
38
36
|
const result = await PageURLsHandler.create(ctx);
|
|
@@ -67,7 +65,7 @@ describe("Page change url", () => {
|
|
|
67
65
|
.mockImplementation(() => page);
|
|
68
66
|
|
|
69
67
|
const mockChange = jest
|
|
70
|
-
.spyOn(ctx.client.
|
|
68
|
+
.spyOn(ctx.client.pages, "updateSlug")
|
|
71
69
|
.mockImplementation(() => ({
|
|
72
70
|
page: null,
|
|
73
71
|
errors: [{ codes: [], key: "slug", message: "has already been taken" }],
|
|
@@ -105,7 +103,7 @@ describe("Page change url", () => {
|
|
|
105
103
|
.mockImplementation(() => page);
|
|
106
104
|
|
|
107
105
|
const mockChange = jest
|
|
108
|
-
.spyOn(ctx.client.
|
|
106
|
+
.spyOn(ctx.client.pages, "updateSlug")
|
|
109
107
|
.mockImplementation(() => ({
|
|
110
108
|
page: null,
|
|
111
109
|
errors: [
|
|
@@ -2,7 +2,7 @@ const create = async (ctx) => {
|
|
|
2
2
|
const { parent_id } = ctx.params;
|
|
3
3
|
const { version } = ctx.resourceParams;
|
|
4
4
|
|
|
5
|
-
const { errors, pageErrors } = await ctx.client.
|
|
5
|
+
const { errors, pageErrors } = await ctx.client.pageRevisions.revert(
|
|
6
6
|
parent_id,
|
|
7
7
|
Number.parseInt(version, 10),
|
|
8
8
|
ctx.locale
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import RevertPageRevisionHandler from "../RevertPageRevisionHandler";
|
|
2
|
-
import
|
|
2
|
+
import PageRevisions from "../../cloud/PageRevisions";
|
|
3
3
|
import { testConfig } from "../../../../../apps/admin/test/handlersHelper";
|
|
4
4
|
|
|
5
5
|
function buildCtx(pageID, version) {
|
|
6
6
|
return {
|
|
7
7
|
client: {
|
|
8
|
-
|
|
8
|
+
pageRevisions: new PageRevisions(testConfig, "token"),
|
|
9
9
|
},
|
|
10
10
|
params: { parent_id: pageID },
|
|
11
11
|
resourceParams: { version },
|
|
@@ -20,7 +20,7 @@ describe("Page revision revert", () => {
|
|
|
20
20
|
const ctx = buildCtx(pageId, version);
|
|
21
21
|
|
|
22
22
|
const mockRevert = jest
|
|
23
|
-
.spyOn(ctx.client.
|
|
23
|
+
.spyOn(ctx.client.pageRevisions, "revert")
|
|
24
24
|
.mockImplementation(() => ({
|
|
25
25
|
revision: {},
|
|
26
26
|
errors: null,
|
|
@@ -43,7 +43,7 @@ describe("Page revision revert", () => {
|
|
|
43
43
|
const errors = [{ key: "generalError", message: "Some error" }];
|
|
44
44
|
|
|
45
45
|
const mockRevert = jest
|
|
46
|
-
.spyOn(ctx.client.
|
|
46
|
+
.spyOn(ctx.client.pageRevisions, "revert")
|
|
47
47
|
.mockImplementation(() => ({
|
|
48
48
|
revision: null,
|
|
49
49
|
errors: errors,
|
|
@@ -64,7 +64,7 @@ describe("Page revision revert", () => {
|
|
|
64
64
|
const errors = [{ key: "generalError", message: "Some error" }];
|
|
65
65
|
|
|
66
66
|
const mockRevert = jest
|
|
67
|
-
.spyOn(ctx.client.
|
|
67
|
+
.spyOn(ctx.client.pageRevisions, "revert")
|
|
68
68
|
.mockImplementation(() => ({
|
|
69
69
|
revision: null,
|
|
70
70
|
errors: null,
|
package/src/index.js
CHANGED
|
@@ -4,7 +4,10 @@ export { default as routeNestedCollection } from "./routeNestedCollection";
|
|
|
4
4
|
export { default as routeMember } from "./routeMember";
|
|
5
5
|
export { default as routeNestedMember } from "./routeNestedMember";
|
|
6
6
|
export { default as setGlobalContext } from "./setGlobalContext";
|
|
7
|
-
export { default as
|
|
7
|
+
export { default as routePages } from "./routePages";
|
|
8
|
+
export { default as routeSettings } from "./routeSettings";
|
|
9
|
+
export { default as setupCloud } from "./setupCloud";
|
|
10
|
+
export { default as routeStandard } from "./routeStandard";
|
|
8
11
|
|
|
9
12
|
export { default as Redirects } from "./cloud/Redirects";
|
|
10
13
|
export { default as RedirectsHandler } from "./handlers/RedirectsHandler";
|
|
@@ -14,14 +17,9 @@ export { default as Settings } from "./cloud/Settings";
|
|
|
14
17
|
export { default as SettingsGeneralHandler } from "./handlers/SettingsGeneralHandler";
|
|
15
18
|
export { default as SettingsLayoutHandler } from "./handlers/SettingsLayoutHandler";
|
|
16
19
|
export { default as SettingsMetaHandler } from "./handlers/SettingsMetaHandler";
|
|
17
|
-
export { default as ChangePageURL } from "./cloud/ChangePageURL";
|
|
18
|
-
export { default as ClonePage } from "./cloud/ClonesPage";
|
|
19
|
-
export { default as DeletePage } from "./cloud/DeletePage";
|
|
20
20
|
export { default as PageChanges } from "./cloud/PageChanges";
|
|
21
21
|
export { default as PageRevisions } from "./cloud/PageRevisions";
|
|
22
|
-
export { default as PageTranslations } from "./cloud/PageTranslations";
|
|
23
22
|
export { default as Pages } from "./cloud/Pages";
|
|
24
|
-
export { default as RevertPageRevision } from "./cloud/RevertPageRevision";
|
|
25
23
|
export { default as PageCloneHandler } from "./handlers/PageCloneHandler";
|
|
26
24
|
export { default as PageDeleteHandler } from "./handlers/PageDeleteHandler";
|
|
27
25
|
export { default as PageRevisionsCodesHandler } from "./handlers/PageRevisionsCodesHandler";
|
|
@@ -16,7 +16,7 @@ const routeNestedCollection = (adapter, parent, resource, handler) => {
|
|
|
16
16
|
"GET",
|
|
17
17
|
`/${parent}/:parent_id/${resource}`,
|
|
18
18
|
resource,
|
|
19
|
-
resource
|
|
19
|
+
`${parent}/${resource}`,
|
|
20
20
|
"index",
|
|
21
21
|
index,
|
|
22
22
|
before_filter,
|
|
@@ -26,7 +26,7 @@ const routeNestedCollection = (adapter, parent, resource, handler) => {
|
|
|
26
26
|
"GET",
|
|
27
27
|
`/${parent}/:parent_id/${resource}/new`,
|
|
28
28
|
resource,
|
|
29
|
-
resource
|
|
29
|
+
`${parent}/${resource}`,
|
|
30
30
|
"create_form",
|
|
31
31
|
create_form,
|
|
32
32
|
before_filter,
|
|
@@ -36,7 +36,7 @@ const routeNestedCollection = (adapter, parent, resource, handler) => {
|
|
|
36
36
|
"GET",
|
|
37
37
|
`/${resource}/:id`,
|
|
38
38
|
resource,
|
|
39
|
-
resource
|
|
39
|
+
`${parent}/${resource}`,
|
|
40
40
|
"show",
|
|
41
41
|
show,
|
|
42
42
|
before_filter,
|
|
@@ -46,7 +46,7 @@ const routeNestedCollection = (adapter, parent, resource, handler) => {
|
|
|
46
46
|
"GET",
|
|
47
47
|
`/${resource}/:id/edit`,
|
|
48
48
|
resource,
|
|
49
|
-
resource
|
|
49
|
+
`${parent}/${resource}`,
|
|
50
50
|
"edit_form",
|
|
51
51
|
edit_form,
|
|
52
52
|
before_filter,
|
|
@@ -56,7 +56,7 @@ const routeNestedCollection = (adapter, parent, resource, handler) => {
|
|
|
56
56
|
"POST",
|
|
57
57
|
`/${parent}/:parent_id/${resource}`,
|
|
58
58
|
resource,
|
|
59
|
-
resource
|
|
59
|
+
`${parent}/${resource}`,
|
|
60
60
|
"create_form",
|
|
61
61
|
create,
|
|
62
62
|
before_filter,
|
|
@@ -66,7 +66,7 @@ const routeNestedCollection = (adapter, parent, resource, handler) => {
|
|
|
66
66
|
"PUT",
|
|
67
67
|
`/${resource}/:id`,
|
|
68
68
|
resource,
|
|
69
|
-
resource
|
|
69
|
+
`${parent}/${resource}`,
|
|
70
70
|
"update",
|
|
71
71
|
update,
|
|
72
72
|
before_filter,
|
|
@@ -76,7 +76,7 @@ const routeNestedCollection = (adapter, parent, resource, handler) => {
|
|
|
76
76
|
"DELETE",
|
|
77
77
|
`/${resource}/:id`,
|
|
78
78
|
resource,
|
|
79
|
-
resource
|
|
79
|
+
`${parent}/${resource}`,
|
|
80
80
|
"destroy",
|
|
81
81
|
destroy,
|
|
82
82
|
before_filter,
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import routeCollection from "./routeCollection";
|
|
2
|
+
import routeNestedCollection from "./routeNestedCollection";
|
|
3
|
+
import routeNestedMember from "./routeNestedMember";
|
|
4
|
+
import PageTranslationsHandler from "./handlers/PageTranslationsHandler";
|
|
5
|
+
import PageRevisionsHandler from "./handlers/PageRevisionsHandler";
|
|
6
|
+
import PageRevisionsGeneralHandler from "./handlers/PageRevisionsGeneralHandler";
|
|
7
|
+
import PageRevisionsVisualsHandler from "./handlers/PageRevisionsVisualsHandler";
|
|
8
|
+
import PageRevisionsCodesHandler from "./handlers/PageRevisionsCodesHandler";
|
|
9
|
+
import PageRevisionsMetaHandler from "./handlers/PageRevisionsMetaHandler";
|
|
10
|
+
import PageRevisionsTagsHandler from "./handlers/PageRevisionsTagsHandler";
|
|
11
|
+
import PageRevisionsLockHandler from "./handlers/PageRevisionsLockHandler";
|
|
12
|
+
import PageRevisionsUnlockHandler from "./handlers/PageRevisionsUnlockHandler";
|
|
13
|
+
import PageCloneHandler from "./handlers/PageCloneHandler";
|
|
14
|
+
import PageURLsHandler from "./handlers/PageURLsHandler";
|
|
15
|
+
import PageDeleteHandler from "./handlers/PageDeleteHandler";
|
|
16
|
+
import RevertPageRevisionHandler from "./handlers/RevertPageRevisionHandler";
|
|
17
|
+
import PublishPageRevisionHandler from "./handlers/PublishPageRevisionHandler";
|
|
18
|
+
import PageRevisionsWidgetsHandler from "./handlers/PageRevisionsWidgetsHandler";
|
|
19
|
+
import PagesHandler from "./handlers/PagesHandler";
|
|
20
|
+
|
|
21
|
+
function routePages(adapter) {
|
|
22
|
+
routeCollection(adapter, "pages", PagesHandler);
|
|
23
|
+
routeNestedCollection(
|
|
24
|
+
adapter,
|
|
25
|
+
"pages",
|
|
26
|
+
"translations",
|
|
27
|
+
PageTranslationsHandler
|
|
28
|
+
);
|
|
29
|
+
routeNestedCollection(
|
|
30
|
+
adapter,
|
|
31
|
+
"pages",
|
|
32
|
+
"page_revisions",
|
|
33
|
+
PageRevisionsHandler
|
|
34
|
+
);
|
|
35
|
+
routeNestedMember(
|
|
36
|
+
adapter,
|
|
37
|
+
"page_revisions",
|
|
38
|
+
"general",
|
|
39
|
+
PageRevisionsGeneralHandler
|
|
40
|
+
);
|
|
41
|
+
routeNestedMember(
|
|
42
|
+
adapter,
|
|
43
|
+
"page_revisions",
|
|
44
|
+
"visuals",
|
|
45
|
+
PageRevisionsVisualsHandler
|
|
46
|
+
);
|
|
47
|
+
routeNestedMember(
|
|
48
|
+
adapter,
|
|
49
|
+
"page_revisions",
|
|
50
|
+
"codes",
|
|
51
|
+
PageRevisionsCodesHandler
|
|
52
|
+
);
|
|
53
|
+
routeNestedMember(
|
|
54
|
+
adapter,
|
|
55
|
+
"page_revisions",
|
|
56
|
+
"meta",
|
|
57
|
+
PageRevisionsMetaHandler
|
|
58
|
+
);
|
|
59
|
+
routeNestedMember(
|
|
60
|
+
adapter,
|
|
61
|
+
"page_revisions",
|
|
62
|
+
"tags",
|
|
63
|
+
PageRevisionsTagsHandler
|
|
64
|
+
);
|
|
65
|
+
routeNestedCollection(
|
|
66
|
+
adapter,
|
|
67
|
+
"page_revisions",
|
|
68
|
+
"locks",
|
|
69
|
+
PageRevisionsLockHandler
|
|
70
|
+
);
|
|
71
|
+
routeNestedCollection(
|
|
72
|
+
adapter,
|
|
73
|
+
"page_revisions",
|
|
74
|
+
"unlocks",
|
|
75
|
+
PageRevisionsUnlockHandler
|
|
76
|
+
);
|
|
77
|
+
routeNestedCollection(adapter, "pages", "clones", PageCloneHandler);
|
|
78
|
+
routeNestedCollection(adapter, "pages", "urls", PageURLsHandler);
|
|
79
|
+
routeNestedCollection(adapter, "pages", "deletes", PageDeleteHandler);
|
|
80
|
+
routeNestedCollection(
|
|
81
|
+
adapter,
|
|
82
|
+
"pages",
|
|
83
|
+
"page_changes/reverts",
|
|
84
|
+
RevertPageRevisionHandler
|
|
85
|
+
);
|
|
86
|
+
routeNestedCollection(
|
|
87
|
+
adapter,
|
|
88
|
+
"page_revisions",
|
|
89
|
+
"publishes",
|
|
90
|
+
PublishPageRevisionHandler
|
|
91
|
+
);
|
|
92
|
+
routeNestedMember(
|
|
93
|
+
adapter,
|
|
94
|
+
"api/page_revisions",
|
|
95
|
+
"widgets",
|
|
96
|
+
PageRevisionsWidgetsHandler
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default routePages;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import routeMember from "./routeMember";
|
|
2
|
+
import SettingsLayoutHandler from "./handlers/SettingsLayoutHandler";
|
|
3
|
+
import SettingsMetaHandler from "./handlers/SettingsMetaHandler";
|
|
4
|
+
import SettingsGeneralHandler from "./handlers/SettingsGeneralHandler";
|
|
5
|
+
|
|
6
|
+
function routeSettings(adapter) {
|
|
7
|
+
routeMember(adapter, "settings/general", SettingsGeneralHandler);
|
|
8
|
+
routeMember(adapter, "settings/meta", SettingsMetaHandler);
|
|
9
|
+
routeMember(adapter, "settings/layout", SettingsLayoutHandler);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default routeSettings;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import routeCollection from "./routeCollection";
|
|
2
|
+
import routeSettings from "./routeSettings";
|
|
3
|
+
import routePages from "./routePages";
|
|
4
|
+
import RedirectsHandler from "./handlers/RedirectsHandler";
|
|
5
|
+
import TagsHandler from "./handlers/TagsHandler";
|
|
6
|
+
|
|
7
|
+
function routeStandard(adapter) {
|
|
8
|
+
routeCollection(adapter, "redirects", RedirectsHandler);
|
|
9
|
+
routeCollection(adapter, "tags", TagsHandler);
|
|
10
|
+
routeSettings(adapter);
|
|
11
|
+
routePages(adapter);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default routeStandard;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Redirects from "./cloud/Redirects";
|
|
2
|
+
import Settings from "./cloud/Settings";
|
|
3
|
+
import Tags from "./cloud/Tags";
|
|
4
|
+
import Pages from "./cloud/Pages";
|
|
5
|
+
import PageRevisions from "./cloud/PageRevisions";
|
|
6
|
+
import PageChanges from "./cloud/PageChanges";
|
|
7
|
+
|
|
8
|
+
function setupCloud(ctx, getConfig) {
|
|
9
|
+
if (!ctx?.authentication?.token) return;
|
|
10
|
+
|
|
11
|
+
ctx.client = {};
|
|
12
|
+
|
|
13
|
+
ctx.client.redirects = new Redirects(getConfig, ctx.authentication.token);
|
|
14
|
+
ctx.client.settings = new Settings(getConfig, ctx.authentication.token);
|
|
15
|
+
ctx.client.tags = new Tags(getConfig, ctx.authentication.token);
|
|
16
|
+
ctx.client.pages = new Pages(getConfig, ctx.authentication.token);
|
|
17
|
+
ctx.client.pageRevisions = new PageRevisions(
|
|
18
|
+
getConfig,
|
|
19
|
+
ctx.authentication.token
|
|
20
|
+
);
|
|
21
|
+
ctx.client.pageChanges = new PageChanges(getConfig, ctx.authentication.token);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default setupCloud;
|
|
@@ -37,7 +37,7 @@ describe("routeNestedCollection", () => {
|
|
|
37
37
|
"GET",
|
|
38
38
|
"/orders/:parent_id/line_items",
|
|
39
39
|
"line_items",
|
|
40
|
-
"line_items",
|
|
40
|
+
"orders/line_items",
|
|
41
41
|
"index",
|
|
42
42
|
OrdersHandler.index,
|
|
43
43
|
],
|
|
@@ -45,7 +45,7 @@ describe("routeNestedCollection", () => {
|
|
|
45
45
|
"GET",
|
|
46
46
|
"/orders/:parent_id/line_items/new",
|
|
47
47
|
"line_items",
|
|
48
|
-
"line_items",
|
|
48
|
+
"orders/line_items",
|
|
49
49
|
"create_form",
|
|
50
50
|
OrdersHandler.create_form,
|
|
51
51
|
],
|
|
@@ -53,7 +53,7 @@ describe("routeNestedCollection", () => {
|
|
|
53
53
|
"GET",
|
|
54
54
|
"/line_items/:id",
|
|
55
55
|
"line_items",
|
|
56
|
-
"line_items",
|
|
56
|
+
"orders/line_items",
|
|
57
57
|
"show",
|
|
58
58
|
OrdersHandler.show,
|
|
59
59
|
],
|
|
@@ -61,7 +61,7 @@ describe("routeNestedCollection", () => {
|
|
|
61
61
|
"GET",
|
|
62
62
|
"/line_items/:id/edit",
|
|
63
63
|
"line_items",
|
|
64
|
-
"line_items",
|
|
64
|
+
"orders/line_items",
|
|
65
65
|
"edit_form",
|
|
66
66
|
OrdersHandler.edit_form,
|
|
67
67
|
],
|
|
@@ -69,7 +69,7 @@ describe("routeNestedCollection", () => {
|
|
|
69
69
|
"POST",
|
|
70
70
|
"/orders/:parent_id/line_items",
|
|
71
71
|
"line_items",
|
|
72
|
-
"line_items",
|
|
72
|
+
"orders/line_items",
|
|
73
73
|
"create_form",
|
|
74
74
|
OrdersHandler.create,
|
|
75
75
|
],
|
|
@@ -77,7 +77,7 @@ describe("routeNestedCollection", () => {
|
|
|
77
77
|
"PUT",
|
|
78
78
|
"/line_items/:id",
|
|
79
79
|
"line_items",
|
|
80
|
-
"line_items",
|
|
80
|
+
"orders/line_items",
|
|
81
81
|
"update",
|
|
82
82
|
OrdersHandler.update,
|
|
83
83
|
],
|
|
@@ -85,7 +85,7 @@ describe("routeNestedCollection", () => {
|
|
|
85
85
|
"DELETE",
|
|
86
86
|
"/line_items/:id",
|
|
87
87
|
"line_items",
|
|
88
|
-
"line_items",
|
|
88
|
+
"orders/line_items",
|
|
89
89
|
"destroy",
|
|
90
90
|
OrdersHandler.destroy,
|
|
91
91
|
],
|
|
@@ -105,7 +105,7 @@ describe("routeNestedCollection", () => {
|
|
|
105
105
|
"GET",
|
|
106
106
|
"/orders/:parent_id/line_items",
|
|
107
107
|
"line_items",
|
|
108
|
-
"line_items",
|
|
108
|
+
"orders/line_items",
|
|
109
109
|
"index",
|
|
110
110
|
OrdersHandlerWithFilters.index,
|
|
111
111
|
OrdersHandlerWithFilters.before_filter,
|
|
@@ -115,7 +115,7 @@ describe("routeNestedCollection", () => {
|
|
|
115
115
|
"GET",
|
|
116
116
|
"/orders/:parent_id/line_items/new",
|
|
117
117
|
"line_items",
|
|
118
|
-
"line_items",
|
|
118
|
+
"orders/line_items",
|
|
119
119
|
"create_form",
|
|
120
120
|
OrdersHandlerWithFilters.create_form,
|
|
121
121
|
OrdersHandlerWithFilters.before_filter,
|
|
@@ -125,7 +125,7 @@ describe("routeNestedCollection", () => {
|
|
|
125
125
|
"GET",
|
|
126
126
|
"/line_items/:id",
|
|
127
127
|
"line_items",
|
|
128
|
-
"line_items",
|
|
128
|
+
"orders/line_items",
|
|
129
129
|
"show",
|
|
130
130
|
OrdersHandlerWithFilters.show,
|
|
131
131
|
OrdersHandlerWithFilters.before_filter,
|
|
@@ -135,7 +135,7 @@ describe("routeNestedCollection", () => {
|
|
|
135
135
|
"GET",
|
|
136
136
|
"/line_items/:id/edit",
|
|
137
137
|
"line_items",
|
|
138
|
-
"line_items",
|
|
138
|
+
"orders/line_items",
|
|
139
139
|
"edit_form",
|
|
140
140
|
OrdersHandlerWithFilters.edit_form,
|
|
141
141
|
OrdersHandlerWithFilters.before_filter,
|
|
@@ -145,7 +145,7 @@ describe("routeNestedCollection", () => {
|
|
|
145
145
|
"POST",
|
|
146
146
|
"/orders/:parent_id/line_items",
|
|
147
147
|
"line_items",
|
|
148
|
-
"line_items",
|
|
148
|
+
"orders/line_items",
|
|
149
149
|
"create_form",
|
|
150
150
|
OrdersHandlerWithFilters.create,
|
|
151
151
|
OrdersHandlerWithFilters.before_filter,
|
|
@@ -155,7 +155,7 @@ describe("routeNestedCollection", () => {
|
|
|
155
155
|
"PUT",
|
|
156
156
|
"/line_items/:id",
|
|
157
157
|
"line_items",
|
|
158
|
-
"line_items",
|
|
158
|
+
"orders/line_items",
|
|
159
159
|
"update",
|
|
160
160
|
OrdersHandlerWithFilters.update,
|
|
161
161
|
OrdersHandlerWithFilters.before_filter,
|
|
@@ -165,7 +165,7 @@ describe("routeNestedCollection", () => {
|
|
|
165
165
|
"DELETE",
|
|
166
166
|
"/line_items/:id",
|
|
167
167
|
"line_items",
|
|
168
|
-
"line_items",
|
|
168
|
+
"orders/line_items",
|
|
169
169
|
"destroy",
|
|
170
170
|
OrdersHandlerWithFilters.destroy,
|
|
171
171
|
OrdersHandlerWithFilters.before_filter,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<div class="grid gap-4 md:grid-cols-3">
|
|
7
7
|
<div>
|
|
8
8
|
<% form_for({ lock_settings }, errors, (f) => { %>
|
|
9
|
-
<form action="<%= `/${_context.locale}/page_revisions/${lock_settings.revision.id}/
|
|
9
|
+
<form action="<%= `/${_context.locale}/page_revisions/${lock_settings.revision.id}/locks` %>" method="POST" class="form">
|
|
10
10
|
<%- f.field('lock_settings.message', { as: 'textarea', label: 'Lock Message', required: true }) %>
|
|
11
11
|
<div class="form-actions">
|
|
12
12
|
<div class="btn-toolbar">
|
|
@@ -32,4 +32,4 @@
|
|
|
32
32
|
</div>
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|
|
35
|
-
</div>
|
|
35
|
+
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<% form_for({ publishing }, errors, (f) => { %>
|
|
2
|
-
<form action="<%= `/${_context.locale}/page_revisions/${publishing.id}/
|
|
2
|
+
<form action="<%= `/${_context.locale}/page_revisions/${publishing.id}/publishes` %>" method="post" class="form">
|
|
3
3
|
<%- f.field('publishing.title'), { required: true } %>
|
|
4
4
|
<%- f.field('publishing.description', { as: "textarea" }) %>
|
|
5
5
|
<%- f.field('publishing.visibility', { as: 'select', required: true, options: visibilityOptions }) %>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<div class="grid gap-4 md:grid-cols-3">
|
|
7
7
|
<div>
|
|
8
8
|
<% form_for({ deleteAction }, errors, (f) => { %>
|
|
9
|
-
<form action="<%= `/${_context.locale}/pages/${deleteAction.id}/
|
|
9
|
+
<form action="<%= `/${_context.locale}/pages/${deleteAction.id}/deletes` %>" method="POST" class="form">
|
|
10
10
|
<%- f.field('deleteAction.redirect', { as: 'select', required: true,options: [['301', 'Redirect to another page'], ['404', 'Return 404'],['410', 'Return 410']] }) %>
|
|
11
11
|
<%- f.field('deleteAction.destination', {label: 'Destination URL', required: true}) %>
|
|
12
12
|
|
|
@@ -52,4 +52,4 @@
|
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
document.getElementById("f_redirect").addEventListener("change", onDestinationChange)
|
|
55
|
-
</script>
|
|
55
|
+
</script>
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
<img title="<%= name %>" src="<%= flag %>" alt="<%= name %>" class="size-6 rounded-full border dark:border-neutral-700" />
|
|
103
103
|
</a>
|
|
104
104
|
<% } else { %>
|
|
105
|
-
<a href="<%= `/${_context.locale}/pages/${item.id}/
|
|
105
|
+
<a href="<%= `/${_context.locale}/pages/${item.id}/translations/new?target_locale=${key}` %>">
|
|
106
106
|
<img title="<%= name %>" src="<%= flag %>" alt="<%= name %>" class="<%= [" transition-all ease-in-out duration-300 size-6 rounded-full border hover:opacity-100 dark:border-neutral-700", key === _context.locale ? "opacity-100" : "opacity-10"].join(" ") %>" />
|
|
107
107
|
</a>
|
|
108
108
|
<% } %>
|
|
@@ -158,4 +158,4 @@
|
|
|
158
158
|
searchToggle.addEventListener('click', () => {
|
|
159
159
|
sidebar.classList.toggle('hidden');
|
|
160
160
|
});
|
|
161
|
-
</script>
|
|
161
|
+
</script>
|
package/src/views/pages/show.ejs
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<img title="<%= name %>" src="<%= flag %>" alt="<%= name %>" class="size-6 rounded-full border dark:border-neutral-700" />
|
|
13
13
|
</a>
|
|
14
14
|
<% } else { %>
|
|
15
|
-
<a href="<%= `/${_context.locale}/pages/${page.id}/
|
|
15
|
+
<a href="<%= `/${_context.locale}/pages/${page.id}/translations/new?target_locale=${key}` %>">
|
|
16
16
|
<img title="<%= name %>" src="<%= flag %>" alt="<%= name %>" class="<%= [" transition-all ease-in-out duration-300 size-6 rounded-full border hover:opacity-100 dark:border-neutral-700", key === _context.locale ? "opacity-100" : "opacity-10"].join(" ") %>" />
|
|
17
17
|
</a>
|
|
18
18
|
<% } %>
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
</button>
|
|
28
28
|
</form>
|
|
29
29
|
|
|
30
|
-
<a href="<%= `/${_context.locale}/pages/${page.id}/
|
|
30
|
+
<a href="<%= `/${_context.locale}/pages/${page.id}/urls/new` %>" class="btn-text has-icon">
|
|
31
31
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
32
32
|
<path stroke-linecap="round" stroke-linejoin="round" d="M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244" />
|
|
33
33
|
</svg>
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
</button>
|
|
46
46
|
</form>
|
|
47
47
|
|
|
48
|
-
<a href="<%= `/${_context.locale}/pages/${page.id}/
|
|
48
|
+
<a href="<%= `/${_context.locale}/pages/${page.id}/deletes/new` %>" class="btn-danger has-icon">
|
|
49
49
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
50
50
|
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
|
|
51
51
|
</svg>
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
Edit content
|
|
126
126
|
</a>
|
|
127
127
|
|
|
128
|
-
<a href="<%= `/${_context.locale}/page_revisions/${revision.id}/
|
|
128
|
+
<a href="<%= `/${_context.locale}/page_revisions/${revision.id}/publishes/new` %>" class="btn-text has-icon <%= revision.meta && revision.meta.locked ? 'cursor-not-allowed text-gray-400 pointer-events-none' : '' %>">
|
|
129
129
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
130
130
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15.59 14.37a6 6 0 0 1-5.84 7.38v-4.8m5.84-2.58a14.98 14.98 0 0 0 6.16-12.12A14.98 14.98 0 0 0 9.631 8.41m5.96 5.96a14.926 14.926 0 0 1-5.841 2.58m-.119-8.54a6 6 0 0 0-7.381 5.84h4.8m2.581-5.84a14.927 14.927 0 0 0-2.58 5.84m2.699 2.7c-.103.021-.207.041-.311.06a15.09 15.09 0 0 1-2.448-2.448 14.9 14.9 0 0 1 .06-.312m-2.24 2.39a4.493 4.493 0 0 0-1.757 4.306 4.493 4.493 0 0 0 4.306-1.758M16.5 9a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Z" />
|
|
131
131
|
</svg>
|
|
@@ -160,14 +160,14 @@
|
|
|
160
160
|
</a>
|
|
161
161
|
|
|
162
162
|
<% if (revision.meta && revision.meta.locked) { %>
|
|
163
|
-
<form action="<%= `/${_context.locale}/page_revisions/${revision.id}/
|
|
163
|
+
<form action="<%= `/${_context.locale}/page_revisions/${revision.id}/unlocks` %>" method="post" class="inline-flex gap-2 items-center">
|
|
164
164
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
165
165
|
<path stroke-linecap="round" stroke-linejoin="round" d="M13.5 10.5V6.75a4.5 4.5 0 1 1 9 0v3.75M3.75 21.75h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H3.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z" />
|
|
166
166
|
</svg>
|
|
167
167
|
<%- f.submit('Unlock', { class: 'btn-text' }) %>
|
|
168
168
|
</form>
|
|
169
169
|
<% } else { %>
|
|
170
|
-
<a href="<%= `/${_context.locale}/page_revisions/${revision.id}/
|
|
170
|
+
<a href="<%= `/${_context.locale}/page_revisions/${revision.id}/locks/new` %>" class="btn-text has-icon">
|
|
171
171
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
172
172
|
<path stroke-linecap="round" stroke-linejoin="round" d="M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z" />
|
|
173
173
|
</svg>
|
|
@@ -278,4 +278,4 @@
|
|
|
278
278
|
</tbody>
|
|
279
279
|
</table>
|
|
280
280
|
</div>
|
|
281
|
-
</div>
|
|
281
|
+
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<% form_for({ translation }, errors, (f) => { %>
|
|
2
|
-
<form action="<%= `/${_context.locale}/pages/${page.id}/
|
|
2
|
+
<form action="<%= `/${_context.locale}/pages/${page.id}/translations` %>" method="post" class="form">
|
|
3
3
|
<input type="hidden" name="target_locale" value="<%= targetLocale %>" />
|
|
4
4
|
|
|
5
5
|
<%- f.field('translation.title', { required: true }) %>
|
|
@@ -73,4 +73,4 @@
|
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
document.getElementById("f_visibility").addEventListener("change", onVisibilityChange)
|
|
76
|
-
</script>
|
|
76
|
+
</script>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
<div class="grid gap-4 md:grid-cols-3">
|
|
7
7
|
<% form_for({ change }, errors, (f) => { %>
|
|
8
|
-
<form action="<%= `/${_context.locale}/pages/${change.id}/
|
|
8
|
+
<form action="<%= `/${_context.locale}/pages/${change.id}/urls` %>" method="post" class="form">
|
|
9
9
|
<%- f.field('change.slug', { label: "URL", required: true }) %>
|
|
10
10
|
<%- f.field('change.redirect', { as: "checkbox", value: "1", label: "Create 301 redirect for the old URL" }) %>
|
|
11
11
|
|
|
@@ -28,4 +28,4 @@
|
|
|
28
28
|
</div>
|
|
29
29
|
</div>
|
|
30
30
|
</div>
|
|
31
|
-
</div>
|
|
31
|
+
</div>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import RaketaClient from "./RaketaClient";
|
|
2
|
-
import { ChangePageSlugDocument } from "./documents/pagesDocuments";
|
|
3
|
-
|
|
4
|
-
export default class ChangePageURL extends RaketaClient {
|
|
5
|
-
async update(id, slug, locale, redirect) {
|
|
6
|
-
const input = {
|
|
7
|
-
id,
|
|
8
|
-
slug,
|
|
9
|
-
locale,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
if (redirect) {
|
|
13
|
-
input.redirect = redirect;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const {
|
|
17
|
-
changePageSlug: { errors, page },
|
|
18
|
-
} = await this.query(ChangePageSlugDocument, {
|
|
19
|
-
input,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
return { page, errors };
|
|
23
|
-
}
|
|
24
|
-
}
|
package/src/cloud/ClonesPage.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import RaketaClient from "./RaketaClient";
|
|
2
|
-
import { ClonePageDocument } from "./documents/pagesDocuments";
|
|
3
|
-
|
|
4
|
-
export default class ClonePage extends RaketaClient {
|
|
5
|
-
async clone(id, locale) {
|
|
6
|
-
const {
|
|
7
|
-
clonePage: { errors, page },
|
|
8
|
-
} = await this.query(ClonePageDocument, {
|
|
9
|
-
input: { id: id, locale: locale },
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
return { page, errors };
|
|
13
|
-
}
|
|
14
|
-
}
|
package/src/cloud/DeletePage.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import RaketaClient from "./RaketaClient";
|
|
2
|
-
import {
|
|
3
|
-
DeletePageDocument,
|
|
4
|
-
PageByIdDocument,
|
|
5
|
-
} from "./documents/pagesDocuments";
|
|
6
|
-
|
|
7
|
-
export default class DeletePage extends RaketaClient {
|
|
8
|
-
async find(id, locale) {
|
|
9
|
-
const { page: item } = await this.query(PageByIdDocument, {
|
|
10
|
-
input: {
|
|
11
|
-
id,
|
|
12
|
-
locale,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
return item;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async delete(id, locale, redirect) {
|
|
20
|
-
const input = {
|
|
21
|
-
id,
|
|
22
|
-
locale,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
if (redirect) {
|
|
26
|
-
input.redirect = redirect;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const {
|
|
30
|
-
deletePage: { errors, page },
|
|
31
|
-
} = await this.query(DeletePageDocument, { input });
|
|
32
|
-
|
|
33
|
-
return { page, errors };
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import RaketaClient from "./RaketaClient";
|
|
2
|
-
import { TranslatePageDocument } from "./documents/pagesDocuments";
|
|
3
|
-
|
|
4
|
-
export default class PageTranslations extends RaketaClient {
|
|
5
|
-
async create(locale, sourcePageId, params) {
|
|
6
|
-
console.log(params);
|
|
7
|
-
params.widgets = JSON.stringify(params.widgets);
|
|
8
|
-
params.settings = JSON.stringify(params.settings);
|
|
9
|
-
console.log(params);
|
|
10
|
-
const {
|
|
11
|
-
translatePage: { errors, page },
|
|
12
|
-
} = await this.query(TranslatePageDocument, {
|
|
13
|
-
input: {
|
|
14
|
-
locale,
|
|
15
|
-
sourcePageId,
|
|
16
|
-
page: params,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
return { page, errors };
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import RaketaClient from "./RaketaClient";
|
|
2
|
-
import { ReopenPageChangeDocument } from "./documents/pagesDocuments";
|
|
3
|
-
|
|
4
|
-
export default class RevertPageRevision extends RaketaClient {
|
|
5
|
-
async create(pageId, version, locale) {
|
|
6
|
-
const {
|
|
7
|
-
reopenPageChange: { revision, errors, pageErrors },
|
|
8
|
-
} = await this.query(ReopenPageChangeDocument, {
|
|
9
|
-
input: {
|
|
10
|
-
pageId,
|
|
11
|
-
locale,
|
|
12
|
-
version,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
return { revision, errors, pageErrors };
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/setGlobalConfig.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<div class="flex w-full">
|
|
2
|
-
<div class="flex items-center justify-between mt-6 mb-4">
|
|
3
|
-
<div class="flex items-center gap-2">
|
|
4
|
-
<h1 class="heading-1">Publish revision</h1>
|
|
5
|
-
</div>
|
|
6
|
-
</div>
|
|
7
|
-
</div>
|
|
8
|
-
|
|
9
|
-
<div class="grid gap-4 md:grid-cols-3">
|
|
10
|
-
<%- include('_form.ejs') %>
|
|
11
|
-
</div>
|
|
File without changes
|