@raketa-cloud/admin 0.0.72 → 0.0.74
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/Adapter.js +13 -1
- package/src/HonoAdapter.js +0 -7
- package/src/handlers/article_revisions/TagHandler.js +1 -2
- package/src/handlers/event_revisions/TagHandler.js +1 -3
- package/src/handlers/page_revisions/TagHandler.js +0 -4
- package/src/helpers/FormBuilder.js +14 -4
- package/src/setupAuthentication.js +5 -5
- package/src/utils.js +0 -12
- package/src/views/articles/_shared/_history_toolbar.ejs +1 -1
- package/src/views/events/_shared/_history_toolbar.ejs +1 -1
- package/src/views/pages/_shared/_history_toolbar.ejs +1 -1
package/package.json
CHANGED
package/src/Adapter.js
CHANGED
|
@@ -68,13 +68,25 @@ const renderError = (message, stack) => {
|
|
|
68
68
|
return `<style>${errorCSS}</style><div class="fail-squid">🦑</div><h1>${message}</h1><pre>${escapeHtml(stack)}</pre>`;
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
+
function toArray(value) {
|
|
72
|
+
if (Array.isArray(value)) {
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return [value].filter(Boolean);
|
|
77
|
+
}
|
|
78
|
+
|
|
71
79
|
function putIn(result, key, value) {
|
|
72
80
|
const segments = key.split(/[\[\]]+/).filter(Boolean);
|
|
73
81
|
let current = result;
|
|
74
82
|
|
|
75
83
|
segments.forEach((segment, idx) => {
|
|
76
84
|
if (idx === segments.length - 1) {
|
|
77
|
-
|
|
85
|
+
if (key.endsWith("[]") || Array.isArray(value)) {
|
|
86
|
+
current[segment] = toArray(value);
|
|
87
|
+
} else {
|
|
88
|
+
current[segment] = value;
|
|
89
|
+
}
|
|
78
90
|
} else {
|
|
79
91
|
if (!current[segment]) {
|
|
80
92
|
current[segment] = {};
|
package/src/HonoAdapter.js
CHANGED
|
@@ -38,13 +38,6 @@ export default class HonoAdapter extends Adapter {
|
|
|
38
38
|
// TODO: Pass in a path to redirect to after login?
|
|
39
39
|
setupAuthentication(
|
|
40
40
|
router,
|
|
41
|
-
{
|
|
42
|
-
remote: {
|
|
43
|
-
domain: "localhost",
|
|
44
|
-
host: "http://localhost:3000",
|
|
45
|
-
cookie_key: "cms-starter-slim",
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
41
|
config
|
|
49
42
|
);
|
|
50
43
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toDateTimeInput
|
|
1
|
+
import { toDateTimeInput } from "../../utils";
|
|
2
2
|
|
|
3
3
|
const edit_form = async (ctx) => {
|
|
4
4
|
const { parent_id } = ctx.params;
|
|
@@ -41,7 +41,6 @@ const update = async (ctx) => {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const params = ctx.resourceParams.resource ? ctx.resourceParams.resource : {};
|
|
44
|
-
params.tags = checkboxesToArray(params.tags);
|
|
45
44
|
|
|
46
45
|
const resource = ctx.client.articleRevisions.deepMerge(
|
|
47
46
|
revision,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toDateTimeInput
|
|
1
|
+
import { toDateTimeInput } from "../../utils";
|
|
2
2
|
|
|
3
3
|
const edit_form = async (ctx) => {
|
|
4
4
|
const { parent_id } = ctx.params;
|
|
@@ -37,8 +37,6 @@ const update = async (ctx) => {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const params = ctx.resourceParams.resource ? ctx.resourceParams.resource : {};
|
|
40
|
-
params.tags = checkboxesToArray(params.tags);
|
|
41
|
-
|
|
42
40
|
const resource = ctx.client.eventRevisions.deepMerge(
|
|
43
41
|
revision,
|
|
44
42
|
ctx.client.eventRevisions.formatDates(params)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { checkboxesToArray } from "../../utils";
|
|
2
|
-
|
|
3
1
|
const fetchDefaultLocaleTags = async (ctx, resource) => {
|
|
4
2
|
if (ctx.locale === ctx.defaultLocale) {
|
|
5
3
|
return { defaultLocaleName: "", defaultLocaleTags: [] };
|
|
@@ -68,8 +66,6 @@ const update = async (ctx) => {
|
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
const params = ctx.resourceParams.resource ? ctx.resourceParams.resource : {};
|
|
71
|
-
params.tags = checkboxesToArray(params.tags);
|
|
72
|
-
|
|
73
69
|
const resource = ctx.client.pageRevisions.deepMerge(revision, params);
|
|
74
70
|
|
|
75
71
|
const { errors } = await ctx.client.pageRevisions.update(
|
|
@@ -207,7 +207,7 @@ export default class FormBuilder extends HTMLBuilder {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
checkbox_group(name, opts = {}) {
|
|
210
|
-
const { value, options = [], hint = "", ...rest } = opts;
|
|
210
|
+
const { value, options = [], hint = "", name: optsName, ...rest } = opts;
|
|
211
211
|
const selected = value || this.__getValue(name);
|
|
212
212
|
|
|
213
213
|
const renderedOpts = [];
|
|
@@ -219,7 +219,7 @@ export default class FormBuilder extends HTMLBuilder {
|
|
|
219
219
|
|
|
220
220
|
const checkbox = this.tag("input", null, {
|
|
221
221
|
type: "checkbox",
|
|
222
|
-
name: `${
|
|
222
|
+
name: `${optsName}[]`,
|
|
223
223
|
value: o[0],
|
|
224
224
|
...additionalOpts,
|
|
225
225
|
});
|
|
@@ -227,6 +227,16 @@ export default class FormBuilder extends HTMLBuilder {
|
|
|
227
227
|
renderedOpts.push(this.tag("label", `${checkbox} ${o[1]}`));
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
if (renderedOpts.length) {
|
|
231
|
+
renderedOpts.push(
|
|
232
|
+
this.tag("input", null, {
|
|
233
|
+
type: "hidden",
|
|
234
|
+
name: `${optsName}[]`,
|
|
235
|
+
value: "",
|
|
236
|
+
})
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
230
240
|
return this.withHint(
|
|
231
241
|
this.tag(
|
|
232
242
|
"div",
|
|
@@ -234,8 +244,8 @@ export default class FormBuilder extends HTMLBuilder {
|
|
|
234
244
|
renderedOpts.length
|
|
235
245
|
? renderedOpts.join("")
|
|
236
246
|
: this.tag("div", "No items available.", {
|
|
237
|
-
|
|
238
|
-
|
|
247
|
+
class: "italic opacity-50",
|
|
248
|
+
}),
|
|
239
249
|
|
|
240
250
|
{
|
|
241
251
|
...rest,
|
|
@@ -9,7 +9,7 @@ function getAuthBearer(c) {
|
|
|
9
9
|
return authHeader.replace("Bearer ", "");
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const setupAuthentication = (app,
|
|
12
|
+
const setupAuthentication = (app, config) => {
|
|
13
13
|
app.use(async (c, next) => {
|
|
14
14
|
const token = getCookie(c, AuthHelper.cookie_key) || getAuthBearer(c);
|
|
15
15
|
|
|
@@ -67,7 +67,7 @@ const setupAuthentication = (app, opts, config) => {
|
|
|
67
67
|
|
|
68
68
|
app.get("/logout", (c) => {
|
|
69
69
|
deleteCookie(c, AuthHelper.cookie_key);
|
|
70
|
-
deleteCookie(c,
|
|
70
|
+
deleteCookie(c, config.remoteConfig.cookie_key);
|
|
71
71
|
return c.redirect("/login");
|
|
72
72
|
});
|
|
73
73
|
|
|
@@ -79,14 +79,14 @@ const setupAuthentication = (app, opts, config) => {
|
|
|
79
79
|
return c.redirect("/login");
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
setCookie(c,
|
|
82
|
+
setCookie(c, config.remoteConfig.cookie_key, token, {
|
|
83
83
|
path: "/",
|
|
84
84
|
httpOnly: true,
|
|
85
85
|
secure: true,
|
|
86
|
-
domain:
|
|
86
|
+
domain: config.remoteConfig.domain,
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
return c.redirect([
|
|
89
|
+
return c.redirect([config.remoteConfig.host, c.req.query().redirect_to].join(""));
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
app.get("/profile", (c) => {
|
package/src/utils.js
CHANGED
|
@@ -28,15 +28,3 @@ export function toDateTimeInput(initialDate = null) {
|
|
|
28
28
|
now.getMinutes().toString().padStart(2, "0"),
|
|
29
29
|
].join("");
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
export function checkboxesToArray(value) {
|
|
33
|
-
if (Array.isArray(value)) {
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!value) {
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return [value];
|
|
42
|
-
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</form>
|
|
13
13
|
<% } %>
|
|
14
14
|
|
|
15
|
-
<a href="
|
|
15
|
+
<a href="/remote-login?redirect_to=/admin/<%= _context.resourceConfig.articleTypePlural %>/<%= resource.id %>/changes/<%= change.version %>" class="btn-text has-icon">
|
|
16
16
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
17
17
|
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" />
|
|
18
18
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</form>
|
|
13
13
|
<% } %>
|
|
14
14
|
|
|
15
|
-
<a href="
|
|
15
|
+
<a href="/remote-login?redirect_to=/admin/<%= _context.resourceConfig.eventTypePlural %>/<%= resource.id %>/changes/<%= change.version %>" class="btn-text has-icon">
|
|
16
16
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
17
17
|
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" />
|
|
18
18
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</form>
|
|
13
13
|
<% } %>
|
|
14
14
|
|
|
15
|
-
<a href="
|
|
15
|
+
<a href="/remote-login?redirect_to=/admin/<%= _context.resourceConfig.pageTypePlural %>/<%= resource.id %>/changes/<%= change.version %>" class="btn-text has-icon">
|
|
16
16
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
17
17
|
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" />
|
|
18
18
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
|