@raketa-cloud/admin 1.8.9 → 1.8.10
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/dist/application.css +4 -24
- package/package.json +2 -2
- package/src/HonoAdapter.js +24 -33
- package/src/index.js +1 -1
- package/src/{routeResource.js → routeResourceModule.js} +25 -20
- package/src/routeStandard.js +4 -4
- package/src/tests/HonoAdapter.coverage.test.js +3 -3
- package/src/tests/{routeResource.test.js → routeResourceModule.test.js} +18 -14
- package/src/tests/routeStandard.test.js +6 -6
package/dist/application.css
CHANGED
|
@@ -1566,14 +1566,6 @@ select {
|
|
|
1566
1566
|
pointer-events: none;
|
|
1567
1567
|
}
|
|
1568
1568
|
|
|
1569
|
-
.visible {
|
|
1570
|
-
visibility: visible;
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
.collapse {
|
|
1574
|
-
visibility: collapse;
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
1569
|
.static {
|
|
1578
1570
|
position: static;
|
|
1579
1571
|
}
|
|
@@ -1737,10 +1729,6 @@ select {
|
|
|
1737
1729
|
display: inline-flex;
|
|
1738
1730
|
}
|
|
1739
1731
|
|
|
1740
|
-
.\!table {
|
|
1741
|
-
display: table !important;
|
|
1742
|
-
}
|
|
1743
|
-
|
|
1744
1732
|
.table {
|
|
1745
1733
|
display: table;
|
|
1746
1734
|
}
|
|
@@ -1749,6 +1737,10 @@ select {
|
|
|
1749
1737
|
display: grid;
|
|
1750
1738
|
}
|
|
1751
1739
|
|
|
1740
|
+
.contents {
|
|
1741
|
+
display: contents;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1752
1744
|
.hidden {
|
|
1753
1745
|
display: none;
|
|
1754
1746
|
}
|
|
@@ -1880,10 +1872,6 @@ select {
|
|
|
1880
1872
|
cursor: pointer;
|
|
1881
1873
|
}
|
|
1882
1874
|
|
|
1883
|
-
.resize {
|
|
1884
|
-
resize: both;
|
|
1885
|
-
}
|
|
1886
|
-
|
|
1887
1875
|
.flex-col {
|
|
1888
1876
|
flex-direction: column;
|
|
1889
1877
|
}
|
|
@@ -2243,14 +2231,6 @@ select {
|
|
|
2243
2231
|
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
2244
2232
|
}
|
|
2245
2233
|
|
|
2246
|
-
.underline {
|
|
2247
|
-
text-decoration-line: underline;
|
|
2248
|
-
}
|
|
2249
|
-
|
|
2250
|
-
.overline {
|
|
2251
|
-
text-decoration-line: overline;
|
|
2252
|
-
}
|
|
2253
|
-
|
|
2254
2234
|
.opacity-10 {
|
|
2255
2235
|
opacity: 0.1;
|
|
2256
2236
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raketa-cloud/admin",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.10",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"src/",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"prepare": "npx tailwindcss -i ./src/styles/application.css -o ./dist/application.css"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@babel/core": "7.29.
|
|
15
|
+
"@babel/core": "7.29.7",
|
|
16
16
|
"@babel/preset-env": "7.29.0",
|
|
17
17
|
"@babel/preset-typescript": "7.28.5",
|
|
18
18
|
"@repo/typescript-config": "*",
|
package/src/HonoAdapter.js
CHANGED
|
@@ -65,19 +65,12 @@ function putIn(result, key, value) {
|
|
|
65
65
|
const sanitizePath = (filePath) =>
|
|
66
66
|
path.normalize(path.join("/", ...filePath.split("/")));
|
|
67
67
|
|
|
68
|
-
function packageFallbackPaths(views, suffix) {
|
|
69
|
-
const rest = views.split("/").slice(1);
|
|
70
|
-
return ["resources", "resource_revisions"].map((base) =>
|
|
71
|
-
sanitizePath(`${currentPath}/views/${[base, ...rest].join("/")}/${suffix}`),
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
68
|
// Find template path, preferring an app override over the package template
|
|
76
|
-
function getPartialPath(partialPath, views) {
|
|
69
|
+
function getPartialPath(partialPath, views, viewsFallback) {
|
|
77
70
|
const paths = [
|
|
78
71
|
sanitizePath(`${process.cwd()}/src/views/${views}/${partialPath}`),
|
|
79
72
|
sanitizePath(`${currentPath}/views/${views}/${partialPath}`),
|
|
80
|
-
|
|
73
|
+
viewsFallback && sanitizePath(`${currentPath}/views/${viewsFallback}/${partialPath}`),
|
|
81
74
|
].filter(Boolean);
|
|
82
75
|
|
|
83
76
|
// Return first existing path
|
|
@@ -86,7 +79,7 @@ function getPartialPath(partialPath, views) {
|
|
|
86
79
|
if (existingPath) return existingPath;
|
|
87
80
|
|
|
88
81
|
throw new Error(
|
|
89
|
-
`Template not found: "${partialPath}"\nSearched in:\n${paths.join("\n")}
|
|
82
|
+
`Template not found: "${partialPath}"\nSearched in:\n${paths.join("\n")}`
|
|
90
83
|
);
|
|
91
84
|
}
|
|
92
85
|
|
|
@@ -143,17 +136,14 @@ export default class HonoAdapter {
|
|
|
143
136
|
this.globalAfterFilters.push({ pattern, filter });
|
|
144
137
|
}
|
|
145
138
|
|
|
146
|
-
getActionPath(views, action) {
|
|
147
|
-
const
|
|
148
|
-
|
|
139
|
+
getActionPath(views, viewsFallback, action) {
|
|
140
|
+
const packagePath = viewsFallback
|
|
141
|
+
? `${currentPath}/views/${viewsFallback}/${action}.ejs`
|
|
142
|
+
: `${currentPath}/views/${views}/${action}.ejs`;
|
|
149
143
|
|
|
150
|
-
const
|
|
151
|
-
if (existsSync(packagePath)) return packagePath;
|
|
144
|
+
const appPath = `${process.cwd()}/src/views/${views}/${action}.ejs`;
|
|
152
145
|
|
|
153
|
-
|
|
154
|
-
existsSync,
|
|
155
|
-
);
|
|
156
|
-
return fallback ?? packagePath;
|
|
146
|
+
return existsSync(appPath) ? appPath : packagePath;
|
|
157
147
|
}
|
|
158
148
|
|
|
159
149
|
getHelpers(viewHelpersConfig) {
|
|
@@ -181,9 +171,9 @@ export default class HonoAdapter {
|
|
|
181
171
|
});
|
|
182
172
|
}
|
|
183
173
|
|
|
184
|
-
renderPartial(assigns, views) {
|
|
174
|
+
renderPartial(assigns, views, viewsFallback) {
|
|
185
175
|
return function render(relativePath, localAssigns) {
|
|
186
|
-
const partialPath = getPartialPath(relativePath, views);
|
|
176
|
+
const partialPath = getPartialPath(relativePath, views, viewsFallback);
|
|
187
177
|
|
|
188
178
|
try {
|
|
189
179
|
// Synchronously read the partial file as ejs does not support async/await
|
|
@@ -194,7 +184,7 @@ export default class HonoAdapter {
|
|
|
194
184
|
...assigns,
|
|
195
185
|
...localAssigns,
|
|
196
186
|
},
|
|
197
|
-
{ filename: partialPath }
|
|
187
|
+
{ filename: partialPath }
|
|
198
188
|
);
|
|
199
189
|
|
|
200
190
|
return rendered;
|
|
@@ -207,11 +197,11 @@ export default class HonoAdapter {
|
|
|
207
197
|
};
|
|
208
198
|
}
|
|
209
199
|
|
|
210
|
-
async renderAction({ views, action, assigns }, viewHelpersConfig = {}) {
|
|
200
|
+
async renderAction({ views, viewsFallback, action, assigns }, viewHelpersConfig = {}) {
|
|
211
201
|
// Pick the parent here in the views so we can reuse stuff...
|
|
212
|
-
const fullTemplatePath = this.getActionPath(views, action);
|
|
202
|
+
const fullTemplatePath = this.getActionPath(views, viewsFallback, action);
|
|
213
203
|
const renderAssigns = { ...this.getHelpers(viewHelpersConfig), ...assigns };
|
|
214
|
-
const renderPartialHelper = this.renderPartial(renderAssigns, views);
|
|
204
|
+
const renderPartialHelper = this.renderPartial(renderAssigns, views, viewsFallback);
|
|
215
205
|
|
|
216
206
|
try {
|
|
217
207
|
// Synchronously read the full template file
|
|
@@ -224,7 +214,7 @@ export default class HonoAdapter {
|
|
|
224
214
|
...renderAssigns,
|
|
225
215
|
render_partial: renderPartialHelper,
|
|
226
216
|
},
|
|
227
|
-
{ filename: fullTemplatePath }
|
|
217
|
+
{ filename: fullTemplatePath }
|
|
228
218
|
);
|
|
229
219
|
|
|
230
220
|
const fullPage = this.renderLayout(renderAssigns, rendered);
|
|
@@ -290,7 +280,7 @@ export default class HonoAdapter {
|
|
|
290
280
|
|
|
291
281
|
async createAction(
|
|
292
282
|
[verb, path, resource, views, action, handler],
|
|
293
|
-
resourceConfig
|
|
283
|
+
resourceConfig
|
|
294
284
|
) {
|
|
295
285
|
const { i18n } = this.globalConfig;
|
|
296
286
|
|
|
@@ -304,7 +294,7 @@ export default class HonoAdapter {
|
|
|
304
294
|
next,
|
|
305
295
|
verb,
|
|
306
296
|
resource,
|
|
307
|
-
action
|
|
297
|
+
action
|
|
308
298
|
);
|
|
309
299
|
|
|
310
300
|
// Set context properties
|
|
@@ -338,7 +328,7 @@ export default class HonoAdapter {
|
|
|
338
328
|
};
|
|
339
329
|
|
|
340
330
|
ctx.logger.info(
|
|
341
|
-
`${ctx.method} "${ctx.rawPath}" -> ${resource}/${action} | ${JSON.stringify(ctx.params)}
|
|
331
|
+
`${ctx.method} "${ctx.rawPath}" -> ${resource}/${action} | ${JSON.stringify(ctx.params)}`
|
|
342
332
|
);
|
|
343
333
|
|
|
344
334
|
const assigns = {
|
|
@@ -383,7 +373,7 @@ export default class HonoAdapter {
|
|
|
383
373
|
|
|
384
374
|
Object.assign(
|
|
385
375
|
assigns.afterFilterAssigns,
|
|
386
|
-
afterResult.assigns || {}
|
|
376
|
+
afterResult.assigns || {}
|
|
387
377
|
);
|
|
388
378
|
}
|
|
389
379
|
}
|
|
@@ -401,10 +391,11 @@ export default class HonoAdapter {
|
|
|
401
391
|
const rendered = this.renderAction(
|
|
402
392
|
{
|
|
403
393
|
views,
|
|
394
|
+
viewsFallback: resourceConfig.viewsFallback,
|
|
404
395
|
action,
|
|
405
396
|
assigns: fullAssigns,
|
|
406
397
|
},
|
|
407
|
-
this.globalConfig?.helpers || {}
|
|
398
|
+
this.globalConfig?.helpers || {}
|
|
408
399
|
);
|
|
409
400
|
|
|
410
401
|
return routerCtx.html(rendered);
|
|
@@ -415,7 +406,7 @@ export default class HonoAdapter {
|
|
|
415
406
|
// Single method to handle all route types
|
|
416
407
|
routeCollection(mapping, resourceConfig) {
|
|
417
408
|
mapping.forEach((handlerMap) =>
|
|
418
|
-
this.createAction(handlerMap, resourceConfig)
|
|
409
|
+
this.createAction(handlerMap, resourceConfig)
|
|
419
410
|
);
|
|
420
411
|
}
|
|
421
412
|
|
|
@@ -437,7 +428,7 @@ export default class HonoAdapter {
|
|
|
437
428
|
applyHeaders(headers, router) {
|
|
438
429
|
if (!headers) return;
|
|
439
430
|
Object.entries(headers).forEach(([key, value]) =>
|
|
440
|
-
router.header(key, value)
|
|
431
|
+
router.header(key, value)
|
|
441
432
|
);
|
|
442
433
|
}
|
|
443
434
|
|
package/src/index.js
CHANGED
|
@@ -4,7 +4,7 @@ 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 routeResourceModule } from "./routeResourceModule";
|
|
8
8
|
export { default as routeSettings } from "./routeSettings";
|
|
9
9
|
export { default as setupCloud } from "./setupCloud";
|
|
10
10
|
export { default as routeStandard } from "./routeStandard";
|
|
@@ -23,15 +23,20 @@ import routeCollection from "./routeCollection";
|
|
|
23
23
|
import routeNestedCollection from "./routeNestedCollection";
|
|
24
24
|
import routeNestedMember from "./routeNestedMember";
|
|
25
25
|
|
|
26
|
-
function
|
|
26
|
+
function routeResourceModule(
|
|
27
27
|
adapter,
|
|
28
28
|
resourceType,
|
|
29
29
|
resourceTypePlural,
|
|
30
30
|
{ dateFields = [] } = {},
|
|
31
31
|
) {
|
|
32
|
+
const viewsType = "resource";
|
|
33
|
+
const viewsTypePlural = "resources";
|
|
34
|
+
|
|
32
35
|
const baseResource = resourceTypePlural;
|
|
33
36
|
const revisionsBaseResource = `${resourceType}_revisions`;
|
|
34
37
|
const changesBaseResource = `${resourceType}_changes`;
|
|
38
|
+
const viewsRevisions = `${viewsType}_revisions`;
|
|
39
|
+
const viewsChanges = `${viewsType}_changes`;
|
|
35
40
|
|
|
36
41
|
const resourceConfig = {
|
|
37
42
|
resourceType,
|
|
@@ -44,7 +49,7 @@ function routeResource(
|
|
|
44
49
|
"GET",
|
|
45
50
|
`/${baseResource}/exports`,
|
|
46
51
|
"exports",
|
|
47
|
-
|
|
52
|
+
`${viewsTypePlural}/exports`,
|
|
48
53
|
"index",
|
|
49
54
|
ExportsHandler.index,
|
|
50
55
|
],
|
|
@@ -53,7 +58,7 @@ function routeResource(
|
|
|
53
58
|
|
|
54
59
|
routeCollection(adapter, baseResource, ResourcesHandler, {
|
|
55
60
|
...resourceConfig,
|
|
56
|
-
|
|
61
|
+
viewsFallback: "resources",
|
|
57
62
|
});
|
|
58
63
|
|
|
59
64
|
routeNestedCollection(
|
|
@@ -61,12 +66,12 @@ function routeResource(
|
|
|
61
66
|
baseResource,
|
|
62
67
|
"translations",
|
|
63
68
|
TranslationsHandler,
|
|
64
|
-
{ ...resourceConfig,
|
|
69
|
+
{ ...resourceConfig, viewsFallback: "resources/translations" },
|
|
65
70
|
);
|
|
66
71
|
|
|
67
72
|
routeNestedCollection(adapter, baseResource, "history", HistoryHandler, {
|
|
68
73
|
...resourceConfig,
|
|
69
|
-
|
|
74
|
+
viewsFallback: "resources/history",
|
|
70
75
|
});
|
|
71
76
|
|
|
72
77
|
routeNestedCollection(
|
|
@@ -76,38 +81,38 @@ function routeResource(
|
|
|
76
81
|
ResourceRevisionsHandler,
|
|
77
82
|
{
|
|
78
83
|
...resourceConfig,
|
|
79
|
-
views:
|
|
84
|
+
views: `${viewsTypePlural}/${viewsRevisions}`,
|
|
80
85
|
},
|
|
81
86
|
);
|
|
82
87
|
|
|
83
88
|
routeNestedMember(adapter, revisionsBaseResource, "general", GeneralHandler, {
|
|
84
89
|
...resourceConfig,
|
|
85
|
-
|
|
90
|
+
viewsFallback: "resource_revisions/general",
|
|
86
91
|
});
|
|
87
92
|
|
|
88
93
|
routeNestedMember(adapter, revisionsBaseResource, "visuals", VisualHandler, {
|
|
89
94
|
...resourceConfig,
|
|
90
|
-
|
|
95
|
+
viewsFallback: "resource_revisions/visuals",
|
|
91
96
|
});
|
|
92
97
|
|
|
93
98
|
routeNestedMember(adapter, revisionsBaseResource, "codes", CodeHandler, {
|
|
94
99
|
...resourceConfig,
|
|
95
|
-
|
|
100
|
+
viewsFallback: "resource_revisions/codes",
|
|
96
101
|
});
|
|
97
102
|
|
|
98
103
|
routeNestedMember(adapter, revisionsBaseResource, "meta", MetaHandler, {
|
|
99
104
|
...resourceConfig,
|
|
100
|
-
|
|
105
|
+
viewsFallback: "resource_revisions/meta",
|
|
101
106
|
});
|
|
102
107
|
|
|
103
108
|
routeNestedMember(adapter, revisionsBaseResource, "tags", TagHandler, {
|
|
104
109
|
...resourceConfig,
|
|
105
|
-
|
|
110
|
+
viewsFallback: "resource_revisions/tags",
|
|
106
111
|
});
|
|
107
112
|
|
|
108
113
|
routeNestedCollection(adapter, revisionsBaseResource, "locks", LocksHandler, {
|
|
109
114
|
...resourceConfig,
|
|
110
|
-
|
|
115
|
+
viewsFallback: "resource_revisions/locks",
|
|
111
116
|
});
|
|
112
117
|
|
|
113
118
|
routeNestedCollection(
|
|
@@ -117,23 +122,23 @@ function routeResource(
|
|
|
117
122
|
UnlocksHandler,
|
|
118
123
|
{
|
|
119
124
|
...resourceConfig,
|
|
120
|
-
views:
|
|
125
|
+
views: `${viewsRevisions}/unlocks`,
|
|
121
126
|
},
|
|
122
127
|
);
|
|
123
128
|
|
|
124
129
|
routeNestedCollection(adapter, baseResource, "clones", ClonesHandler, {
|
|
125
130
|
...resourceConfig,
|
|
126
|
-
views:
|
|
131
|
+
views: `${viewsTypePlural}/clones`,
|
|
127
132
|
});
|
|
128
133
|
|
|
129
134
|
routeNestedCollection(adapter, baseResource, "urls", URLsHandler, {
|
|
130
135
|
...resourceConfig,
|
|
131
|
-
|
|
136
|
+
viewsFallback: "resources/urls",
|
|
132
137
|
});
|
|
133
138
|
|
|
134
139
|
routeNestedCollection(adapter, baseResource, "deletes", DeletesHandler, {
|
|
135
140
|
...resourceConfig,
|
|
136
|
-
|
|
141
|
+
viewsFallback: "resources/deletes",
|
|
137
142
|
});
|
|
138
143
|
|
|
139
144
|
routeNestedCollection(
|
|
@@ -143,7 +148,7 @@ function routeResource(
|
|
|
143
148
|
RevertsHandler,
|
|
144
149
|
{
|
|
145
150
|
...resourceConfig,
|
|
146
|
-
views:
|
|
151
|
+
views: `${viewsChanges}/reverts`,
|
|
147
152
|
},
|
|
148
153
|
);
|
|
149
154
|
|
|
@@ -154,7 +159,7 @@ function routeResource(
|
|
|
154
159
|
PublishesHandler,
|
|
155
160
|
{
|
|
156
161
|
...resourceConfig,
|
|
157
|
-
|
|
162
|
+
viewsFallback: "resource_revisions/publishes",
|
|
158
163
|
},
|
|
159
164
|
);
|
|
160
165
|
|
|
@@ -165,7 +170,7 @@ function routeResource(
|
|
|
165
170
|
CancelSchedulesHandler,
|
|
166
171
|
{
|
|
167
172
|
...resourceConfig,
|
|
168
|
-
views:
|
|
173
|
+
views: `${viewsRevisions}/cancel_schedules`,
|
|
169
174
|
},
|
|
170
175
|
);
|
|
171
176
|
|
|
@@ -192,4 +197,4 @@ function routeResource(
|
|
|
192
197
|
);
|
|
193
198
|
}
|
|
194
199
|
|
|
195
|
-
export default
|
|
200
|
+
export default routeResourceModule;
|
package/src/routeStandard.js
CHANGED
|
@@ -3,7 +3,7 @@ import RedirectsHandler from "./handlers/RedirectsHandler";
|
|
|
3
3
|
import TagsAPIHandler from "./handlers/TagsAPIHandler";
|
|
4
4
|
import TagsHandler from "./handlers/TagsHandler";
|
|
5
5
|
import routeCollection from "./routeCollection";
|
|
6
|
-
import
|
|
6
|
+
import routeResourceModule from "./routeResourceModule";
|
|
7
7
|
import routeSettings from "./routeSettings";
|
|
8
8
|
|
|
9
9
|
function routeStandard(adapter) {
|
|
@@ -27,9 +27,9 @@ function routeStandard(adapter) {
|
|
|
27
27
|
routeCollection(adapter, "tags", TagsHandler);
|
|
28
28
|
routeCollection(adapter, "api/tags", TagsAPIHandler);
|
|
29
29
|
routeSettings(adapter);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
routeResourceModule(adapter, "page", "pages", { dateFields: [] });
|
|
31
|
+
routeResourceModule(adapter, "article", "articles", { dateFields: ["publish_at"] });
|
|
32
|
+
routeResourceModule(adapter, "event", "events", {
|
|
33
33
|
dateFields: ["publish_at", "starts_at", "ends_at"],
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -86,15 +86,15 @@ describe("HonoAdapter.getActionPath", () => {
|
|
|
86
86
|
test("returns app path when it exists", () => {
|
|
87
87
|
existsSync.mockReturnValue(true);
|
|
88
88
|
|
|
89
|
-
const result = adapter.getActionPath("resources", "index");
|
|
89
|
+
const result = adapter.getActionPath("authors", "resources", "index");
|
|
90
90
|
|
|
91
|
-
expect(result).toBe(`${process.cwd()}/src/views/
|
|
91
|
+
expect(result).toBe(`${process.cwd()}/src/views/authors/index.ejs`);
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
test("returns package path when app missing", () => {
|
|
95
95
|
existsSync.mockReturnValue(false);
|
|
96
96
|
|
|
97
|
-
const result = adapter.getActionPath("resources", "index");
|
|
97
|
+
const result = adapter.getActionPath("widget-sets", "resources", "index");
|
|
98
98
|
|
|
99
99
|
expect(result).toContain("/views/resources/index.ejs");
|
|
100
100
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import routeResourceModule from "../routeResourceModule";
|
|
2
2
|
|
|
3
3
|
function makeAdapter() {
|
|
4
4
|
return {
|
|
@@ -8,11 +8,11 @@ function makeAdapter() {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
describe("
|
|
11
|
+
describe("routeResourceModule", () => {
|
|
12
12
|
test("registers exports collection with explicit mapping", () => {
|
|
13
13
|
const adapter = makeAdapter();
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
routeResourceModule(adapter, "article", "articles", {
|
|
16
16
|
dateFields: ["publish_at"],
|
|
17
17
|
});
|
|
18
18
|
|
|
@@ -38,7 +38,7 @@ describe("routeResource", () => {
|
|
|
38
38
|
test("propagates resourceConfig with dateFields to all helpers", () => {
|
|
39
39
|
const adapter = makeAdapter();
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
routeResourceModule(adapter, "event", "events", {
|
|
42
42
|
dateFields: ["publish_at", "starts_at", "ends_at"],
|
|
43
43
|
});
|
|
44
44
|
|
|
@@ -60,7 +60,7 @@ describe("routeResource", () => {
|
|
|
60
60
|
test("registers ResourcesHandler collection at base resource", () => {
|
|
61
61
|
const adapter = makeAdapter();
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
routeResourceModule(adapter, "page", "pages");
|
|
64
64
|
|
|
65
65
|
const baseCollection = adapter.routeCollection.mock.calls.find(
|
|
66
66
|
([mapping]) => mapping.some(([, path]) => path === "/pages")
|
|
@@ -68,14 +68,18 @@ describe("routeResource", () => {
|
|
|
68
68
|
|
|
69
69
|
expect(baseCollection).toBeDefined();
|
|
70
70
|
expect(baseCollection[1]).toMatchObject({
|
|
71
|
-
|
|
71
|
+
dateFields: [],
|
|
72
|
+
resourceType: "page",
|
|
73
|
+
resourceTypePlural: "pages",
|
|
74
|
+
viewsFallback: "resources",
|
|
75
|
+
|
|
72
76
|
});
|
|
73
77
|
});
|
|
74
78
|
|
|
75
79
|
test("registers api collection for resources", () => {
|
|
76
80
|
const adapter = makeAdapter();
|
|
77
81
|
|
|
78
|
-
|
|
82
|
+
routeResourceModule(adapter, "page", "pages");
|
|
79
83
|
|
|
80
84
|
const apiCollection = adapter.routeCollection.mock.calls.find(
|
|
81
85
|
([mapping]) => mapping.some(([, path]) => path === "/api/pages")
|
|
@@ -87,7 +91,7 @@ describe("routeResource", () => {
|
|
|
87
91
|
test("registers nested collections for revisions, translations, history, locks, unlocks, clones, urls, deletes, publishes, cancel_schedules, reverts", () => {
|
|
88
92
|
const adapter = makeAdapter();
|
|
89
93
|
|
|
90
|
-
|
|
94
|
+
routeResourceModule(adapter, "article", "articles");
|
|
91
95
|
|
|
92
96
|
const nestedPaths = adapter.routeNestedCollection.mock.calls.flatMap(
|
|
93
97
|
([mapping]) => mapping.map(([, path]) => path)
|
|
@@ -113,7 +117,7 @@ describe("routeResource", () => {
|
|
|
113
117
|
test("registers nested members for general, visuals, codes, meta, tags", () => {
|
|
114
118
|
const adapter = makeAdapter();
|
|
115
119
|
|
|
116
|
-
|
|
120
|
+
routeResourceModule(adapter, "article", "articles");
|
|
117
121
|
|
|
118
122
|
const nestedMemberPaths = adapter.routeNestedMember.mock.calls.flatMap(
|
|
119
123
|
([mapping]) => mapping.map(([, path]) => path)
|
|
@@ -133,7 +137,7 @@ describe("routeResource", () => {
|
|
|
133
137
|
test("registers api widgets and change endpoints", () => {
|
|
134
138
|
const adapter = makeAdapter();
|
|
135
139
|
|
|
136
|
-
|
|
140
|
+
routeResourceModule(adapter, "page", "pages");
|
|
137
141
|
|
|
138
142
|
const nestedMemberPaths = adapter.routeNestedMember.mock.calls.flatMap(
|
|
139
143
|
([mapping]) => mapping.map(([, path]) => path)
|
|
@@ -150,7 +154,7 @@ describe("routeResource", () => {
|
|
|
150
154
|
test("uses default empty dateFields when not provided", () => {
|
|
151
155
|
const adapter = makeAdapter();
|
|
152
156
|
|
|
153
|
-
|
|
157
|
+
routeResourceModule(adapter, "page", "pages");
|
|
154
158
|
|
|
155
159
|
const firstCall = adapter.routeCollection.mock.calls[0];
|
|
156
160
|
expect(firstCall[1].dateFields).toEqual([]);
|
|
@@ -159,19 +163,19 @@ describe("routeResource", () => {
|
|
|
159
163
|
test("propagates shared resources views for migrated collection helpers", () => {
|
|
160
164
|
const adapter = makeAdapter();
|
|
161
165
|
|
|
162
|
-
|
|
166
|
+
routeResourceModule(adapter, "event", "events");
|
|
163
167
|
|
|
164
168
|
const baseCollection = adapter.routeCollection.mock.calls.find(
|
|
165
169
|
([mapping]) => mapping.some(([, path]) => path === "/events")
|
|
166
170
|
);
|
|
167
171
|
|
|
168
|
-
expect(baseCollection[1].
|
|
172
|
+
expect(baseCollection[1].viewsFallback).toBe("resources");
|
|
169
173
|
|
|
170
174
|
const translationsCall = adapter.routeNestedCollection.mock.calls.find(
|
|
171
175
|
([mapping]) =>
|
|
172
176
|
mapping.some(([, path]) => path === "/events/:parent_id/translations")
|
|
173
177
|
);
|
|
174
178
|
|
|
175
|
-
expect(translationsCall[1].
|
|
179
|
+
expect(translationsCall[1].viewsFallback).toBe("resources/translations");
|
|
176
180
|
});
|
|
177
181
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import routeStandard from "../routeStandard";
|
|
2
2
|
import routeCollection from "../routeCollection";
|
|
3
3
|
import routeSettings from "../routeSettings";
|
|
4
|
-
import
|
|
4
|
+
import routeResourceModule from "../routeResourceModule";
|
|
5
5
|
|
|
6
6
|
import DashboardsHandler from "../handlers/DashboardsHandler";
|
|
7
7
|
import RedirectsHandler from "../handlers/RedirectsHandler";
|
|
@@ -10,13 +10,13 @@ import TagsAPIHandler from "../handlers/TagsAPIHandler";
|
|
|
10
10
|
|
|
11
11
|
jest.mock("../routeCollection", () => jest.fn());
|
|
12
12
|
jest.mock("../routeSettings", () => jest.fn());
|
|
13
|
-
jest.mock("../
|
|
13
|
+
jest.mock("../routeResourceModule", () => jest.fn());
|
|
14
14
|
|
|
15
15
|
describe("routeStandard", () => {
|
|
16
16
|
beforeEach(() => {
|
|
17
17
|
routeCollection.mockClear();
|
|
18
18
|
routeSettings.mockClear();
|
|
19
|
-
|
|
19
|
+
routeResourceModule.mockClear();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
test("registers dashboard mapping via adapter.routeCollection", () => {
|
|
@@ -57,13 +57,13 @@ describe("routeStandard", () => {
|
|
|
57
57
|
routeStandard(adapter);
|
|
58
58
|
|
|
59
59
|
expect(routeSettings).toHaveBeenCalledWith(adapter);
|
|
60
|
-
expect(
|
|
60
|
+
expect(routeResourceModule).toHaveBeenCalledWith(adapter, "page", "pages", {
|
|
61
61
|
dateFields: [],
|
|
62
62
|
});
|
|
63
|
-
expect(
|
|
63
|
+
expect(routeResourceModule).toHaveBeenCalledWith(adapter, "article", "articles", {
|
|
64
64
|
dateFields: ["publish_at"],
|
|
65
65
|
});
|
|
66
|
-
expect(
|
|
66
|
+
expect(routeResourceModule).toHaveBeenCalledWith(adapter, "event", "events", {
|
|
67
67
|
dateFields: ["publish_at", "starts_at", "ends_at"],
|
|
68
68
|
});
|
|
69
69
|
});
|