@webiny/app-headless-cms 6.6.0-alpha.11 → 6.6.0-alpha.12
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/HeadlessCMS.js +3 -0
- package/HeadlessCMS.js.map +1 -1
- package/features/contentEntry/entryEvents/ApplyEntryChangeToCache.d.ts +21 -0
- package/features/contentEntry/entryEvents/ApplyEntryChangeToCache.js +39 -0
- package/features/contentEntry/entryEvents/ApplyEntryChangeToCache.js.map +1 -0
- package/features/contentEntry/entryEvents/EntryEvents.test.d.ts +1 -0
- package/features/contentEntry/entryEvents/EntryEvents.test.js +124 -0
- package/features/contentEntry/entryEvents/EntryEvents.test.js.map +1 -0
- package/features/contentEntry/entryEvents/feature.d.ts +6 -0
- package/features/contentEntry/entryEvents/feature.js +11 -0
- package/features/contentEntry/entryEvents/feature.js.map +1 -0
- package/features/contentEntry/entryEvents/index.d.ts +1 -0
- package/features/contentEntry/entryEvents/index.js +1 -0
- package/package.json +20 -20
- package/presentation/contentEntries/list/ContentEntriesPresenter.d.ts +8 -1
- package/presentation/contentEntries/list/ContentEntriesPresenter.js +35 -2
- package/presentation/contentEntries/list/ContentEntriesPresenter.js.map +1 -1
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +69 -0
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
- package/presentation/contentEntries/trashBin/CmsTrashBin.js +12 -2
- package/presentation/contentEntries/trashBin/CmsTrashBin.js.map +1 -1
- package/presentation/contentEntries/views/SingleEntryLayout.js +1 -1
- package/presentation/contentEntries/views/SingleEntryLayout.js.map +1 -1
- package/presentation/contentModels/ContentModelsDataSource.d.ts +5 -6
- package/presentation/contentModels/ContentModelsDataSource.js +12 -14
- package/presentation/contentModels/ContentModelsDataSource.js.map +1 -1
- package/presentation/contentModels/ContentModelsDataSource.test.d.ts +1 -0
- package/presentation/contentModels/ContentModelsDataSource.test.js +70 -0
- package/presentation/contentModels/ContentModelsDataSource.test.js.map +1 -0
- package/presentation/contentModels/ContentModelsPresenter.d.ts +1 -2
- package/presentation/contentModels/ContentModelsPresenter.js +13 -24
- package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
- package/presentation/contentModels/abstractions.d.ts +2 -6
- package/presentation/contentModels/abstractions.js.map +1 -1
- package/presentation/contentModels/components/ContentModels.js +1 -0
- package/presentation/contentModels/components/ContentModels.js.map +1 -1
- package/presentation/contentModels/components/ContentModelsDataList.js +12 -37
- package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
- package/presentation/contentModels/isListedModel.d.ts +2 -0
- package/presentation/contentModels/isListedModel.js +4 -0
- package/presentation/contentModels/isListedModel.js.map +1 -0
- package/presentation/modelGroup/ModelGroupDataSource.d.ts +5 -6
- package/presentation/modelGroup/ModelGroupDataSource.js +10 -13
- package/presentation/modelGroup/ModelGroupDataSource.js.map +1 -1
- package/presentation/modelGroup/ModelGroupDataSource.test.d.ts +1 -0
- package/presentation/modelGroup/ModelGroupDataSource.test.js +63 -0
- package/presentation/modelGroup/ModelGroupDataSource.test.js.map +1 -0
- package/presentation/modelGroup/ModelGroupPresenter.d.ts +4 -0
- package/presentation/modelGroup/ModelGroupPresenter.js +32 -2
- package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
- package/presentation/modelGroup/ModelGroupPresenter.test.d.ts +1 -0
- package/presentation/modelGroup/ModelGroupPresenter.test.js +88 -0
- package/presentation/modelGroup/ModelGroupPresenter.test.js.map +1 -0
- package/presentation/modelGroup/abstractions.d.ts +2 -0
- package/presentation/modelGroup/abstractions.js.map +1 -1
- package/presentation/modelGroup/components/ContentModelGroups.js +1 -0
- package/presentation/modelGroup/components/ContentModelGroups.js.map +1 -1
- package/presentation/modelGroup/components/ContentModelGroupsDataList.js +12 -37
- package/presentation/modelGroup/components/ContentModelGroupsDataList.js.map +1 -1
|
@@ -5,6 +5,9 @@ import { ListPresenterFeature } from "@webiny/app-admin/presentation/listPresent
|
|
|
5
5
|
import { FolderTreePresenter } from "@webiny/app-aco/presentation/folderTree/abstractions.js";
|
|
6
6
|
import { GetDescendantFoldersUseCase } from "@webiny/app-aco/features/folders/getDescendantFolders/abstractions.js";
|
|
7
7
|
import { Confirmation } from "@webiny/app-admin/features/confirmation/abstractions.js";
|
|
8
|
+
import { AssistantPageContext } from "@webiny/app-admin/features/assistantPageContext/abstractions.js";
|
|
9
|
+
import { AssistantPageContext as AssistantPageContext_js_AssistantPageContext } from "@webiny/app-admin/features/assistantPageContext/AssistantPageContext.js";
|
|
10
|
+
import { FoldersContext } from "@webiny/app-aco/features/folders/abstractions.js";
|
|
8
11
|
import { ContentEntriesCacheProvider } from "../../../features/contentEntry/ContentEntriesCacheProvider.js";
|
|
9
12
|
import { CmsModelContext } from "../../../features/contentEntry/abstractions.js";
|
|
10
13
|
import { CmsModelContext as CmsModelContext_js_CmsModelContext } from "../../../features/contentEntry/CmsModelContext.js";
|
|
@@ -161,6 +164,10 @@ function setup() {
|
|
|
161
164
|
container.registerInstance(UpdateRevisionDescriptionGateway, {
|
|
162
165
|
execute: vi.fn()
|
|
163
166
|
});
|
|
167
|
+
container.registerInstance(FoldersContext, {
|
|
168
|
+
type: "cms:testModel"
|
|
169
|
+
});
|
|
170
|
+
container.register(AssistantPageContext_js_AssistantPageContext).inSingletonScope();
|
|
164
171
|
container.register(external_ContentEntriesPresenter_js_ContentEntriesPresenter).inSingletonScope();
|
|
165
172
|
const presenter = container.resolve(ContentEntriesPresenter);
|
|
166
173
|
return {
|
|
@@ -228,6 +235,68 @@ describe("ContentEntriesPresenter", ()=>{
|
|
|
228
235
|
expect(t.presenter.vm.model).toStrictEqual(MODEL);
|
|
229
236
|
});
|
|
230
237
|
});
|
|
238
|
+
describe("assistant page context", ()=>{
|
|
239
|
+
const current = ()=>t.container.resolve(AssistantPageContext).get();
|
|
240
|
+
it("tells the assistant the model and folder type once initialised", async ()=>{
|
|
241
|
+
expect(current()).toBeNull();
|
|
242
|
+
await initPresenter(t, {
|
|
243
|
+
data: []
|
|
244
|
+
});
|
|
245
|
+
expect(current()).toEqual({
|
|
246
|
+
view: 'Entries of the "Test Model" content model in Headless CMS',
|
|
247
|
+
details: {
|
|
248
|
+
items: "entries",
|
|
249
|
+
totalCount: 0,
|
|
250
|
+
visibleRows: [],
|
|
251
|
+
modelId: "testModel",
|
|
252
|
+
modelName: "Test Model",
|
|
253
|
+
folderType: "cms:testModel",
|
|
254
|
+
currentFolder: null,
|
|
255
|
+
visibleFolders: []
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
it("follows the open folder and the open entry", async ()=>{
|
|
260
|
+
await initPresenter(t, {
|
|
261
|
+
data: []
|
|
262
|
+
});
|
|
263
|
+
t.foldersPresenter.selectFolder("folder-1");
|
|
264
|
+
t.presenter.selectEntry("entry-1#0002");
|
|
265
|
+
expect(current()?.details).toMatchObject({
|
|
266
|
+
currentFolder: {
|
|
267
|
+
id: "folder-1",
|
|
268
|
+
title: "Home"
|
|
269
|
+
},
|
|
270
|
+
openEntryId: "entry-1"
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
it("stays under a context set over it while the list changes", async ()=>{
|
|
274
|
+
await initPresenter(t, {
|
|
275
|
+
data: []
|
|
276
|
+
});
|
|
277
|
+
const drawer = {
|
|
278
|
+
view: "Entry revisions",
|
|
279
|
+
details: {}
|
|
280
|
+
};
|
|
281
|
+
t.container.resolve(AssistantPageContext).set(drawer);
|
|
282
|
+
t.foldersPresenter.selectFolder("folder-1");
|
|
283
|
+
expect(current()).toEqual(drawer);
|
|
284
|
+
});
|
|
285
|
+
it("takes its context back on dispose, leaving one set before it", async ()=>{
|
|
286
|
+
const pageContext = t.container.resolve(AssistantPageContext);
|
|
287
|
+
const page = {
|
|
288
|
+
view: "Dashboard",
|
|
289
|
+
details: {}
|
|
290
|
+
};
|
|
291
|
+
pageContext.set(page);
|
|
292
|
+
await initPresenter(t, {
|
|
293
|
+
data: []
|
|
294
|
+
});
|
|
295
|
+
expect(current()?.view).toContain("Test Model");
|
|
296
|
+
t.presenter.dispose();
|
|
297
|
+
expect(current()).toEqual(page);
|
|
298
|
+
});
|
|
299
|
+
});
|
|
231
300
|
describe("folder navigation", ()=>{
|
|
232
301
|
it("should filter to folder entries when navigating to a subfolder", async ()=>{
|
|
233
302
|
const rootEntries = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentEntries/list/ContentEntriesPresenter.test.js","sources":["../../../../src/presentation/contentEntries/list/ContentEntriesPresenter.test.ts"],"sourcesContent":["/**\n * @vitest-environment jsdom\n */\nimport { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport type { Mock } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { makeAutoObservable } from \"mobx\";\nimport { ListPresenterFeature } from \"@webiny/app-admin/presentation/listPresenter/index.js\";\nimport { FolderTreePresenter } from \"@webiny/app-aco/presentation/folderTree/abstractions.js\";\nimport { GetDescendantFoldersUseCase } from \"@webiny/app-aco/features/folders/getDescendantFolders/abstractions.js\";\nimport { Confirmation } from \"@webiny/app-admin/features/confirmation/abstractions.js\";\nimport type { CmsContentEntry, CmsModel } from \"~/types.js\";\nimport { ContentEntriesCacheProvider } from \"~/features/contentEntry/ContentEntriesCacheProvider.js\";\nimport { CmsModelContext } from \"~/features/contentEntry/abstractions.js\";\nimport { CmsModelContext as CmsModelContextImpl } from \"~/features/contentEntry/CmsModelContext.js\";\nimport { ListEntriesFeature } from \"~/features/contentEntry/listEntries/feature.js\";\nimport { DeleteEntryFeature } from \"~/features/contentEntry/deleteEntry/feature.js\";\nimport { PublishEntryFeature } from \"~/features/contentEntry/publishEntry/feature.js\";\nimport { UnpublishEntryFeature } from \"~/features/contentEntry/unpublishEntry/feature.js\";\nimport { MoveEntryFeature } from \"~/features/contentEntry/moveEntry/feature.js\";\nimport { DuplicateEntryFeature } from \"~/features/contentEntry/duplicateEntry/feature.js\";\nimport { UpdateRevisionDescriptionFeature } from \"~/features/contentEntry/updateRevisionDescription/feature.js\";\nimport { ListEntriesGateway } from \"~/features/contentEntry/listEntries/abstractions.js\";\nimport { DeleteEntryGateway } from \"~/features/contentEntry/deleteEntry/abstractions.js\";\nimport {\n PublishEntryGateway,\n PublishEntryUseCase\n} from \"~/features/contentEntry/publishEntry/abstractions.js\";\nimport { UnpublishEntryGateway } from \"~/features/contentEntry/unpublishEntry/abstractions.js\";\nimport { MoveEntryGateway } from \"~/features/contentEntry/moveEntry/abstractions.js\";\nimport { DuplicateEntryGateway } from \"~/features/contentEntry/duplicateEntry/abstractions.js\";\nimport { UpdateRevisionDescriptionGateway } from \"~/features/contentEntry/updateRevisionDescription/abstractions.js\";\nimport { EventPublisher } from \"@webiny/app/features/eventPublisher/index.js\";\nimport { ContentEntriesPresenter as Abstraction } from \"./abstractions.js\";\nimport { ContentEntriesPresenter } from \"./ContentEntriesPresenter.js\";\nimport type { IContentEntriesPresenter } from \"./abstractions.js\";\nimport type {\n IFolderTreeViewModel,\n IFolderOperationState\n} from \"@webiny/app-aco/presentation/folderTree/abstractions.js\";\n\nconst MODEL: CmsModel = {\n modelId: \"testModel\",\n name: \"Test Model\",\n singularApiName: \"TestModel\",\n pluralApiName: \"TestModels\",\n fields: [],\n layout: [],\n group: \"group-1\",\n titleFieldId: \"title\",\n descriptionFieldId: null,\n imageFieldId: null,\n tags: [],\n savedOn: \"\"\n} as unknown as CmsModel;\n\nfunction createEntry(\n entryId: string,\n folderId: string,\n overrides: Partial<CmsContentEntry> = {}\n): CmsContentEntry {\n return {\n id: `${entryId}#0001`,\n entryId,\n meta: {\n title: entryId,\n status: \"draft\",\n version: 1,\n locked: false\n },\n wbyAco_location: { folderId },\n values: {},\n createdBy: { id: \"user-1\", displayName: \"Test\", type: \"admin\" },\n createdOn: \"2024-01-01T00:00:00Z\",\n savedOn: \"2024-01-01T00:00:00Z\",\n ...overrides\n } as unknown as CmsContentEntry;\n}\n\nclass MockFolderTreePresenter implements FolderTreePresenter.Interface {\n private _currentFolderId: string | null = null;\n\n constructor() {\n makeAutoObservable(this);\n }\n\n get vm(): IFolderTreeViewModel {\n return {\n folders: [],\n tree: [],\n currentFolderId: this._currentFolderId,\n currentFolder: null,\n isRootFolder: this._currentFolderId === null,\n currentFolderTitle: \"Home\",\n childFolders: [],\n loading: false,\n loadingNodeIds: [],\n operation: { active: false, mode: null } as IFolderOperationState\n };\n }\n\n selectFolder(folderId: string | null): void {\n this._currentFolderId = folderId;\n }\n\n createFolder(): void {}\n editFolder(): void {}\n async deleteFolder(): Promise<void> {}\n async moveFolder(): Promise<void> {}\n async loadChildFolders(): Promise<void> {}\n canManageStructure(): boolean {\n return true;\n }\n getAncestorIds(): string[] {\n return [];\n }\n async submitOperation(): Promise<boolean> {\n return true;\n }\n cancelOperation(): void {}\n onFolderChange(): () => void {\n return () => {};\n }\n}\n\ninterface TestSetup {\n presenter: IContentEntriesPresenter;\n listEntriesGateway: { execute: Mock };\n moveEntryGateway: { execute: Mock };\n deleteEntryGateway: { execute: Mock };\n duplicateEntryGateway: { execute: Mock };\n getDescendantFolders: Mock;\n foldersPresenter: MockFolderTreePresenter;\n publishEntryGateway: { execute: Mock };\n container: Container;\n}\n\nfunction setup(): TestSetup {\n const container = new Container();\n\n ListPresenterFeature.register(container);\n\n const foldersPresenter = new MockFolderTreePresenter();\n container.registerInstance(FolderTreePresenter, foldersPresenter);\n\n container.registerInstance(Confirmation, {\n confirm: vi.fn(async (_name, _params, execute) => {\n if (execute) {\n return await execute(undefined);\n }\n return true;\n })\n } as unknown as Confirmation.Interface);\n\n const getDescendantFolders = vi.fn().mockReturnValue([]);\n container.registerInstance(GetDescendantFoldersUseCase, {\n execute: getDescendantFolders\n });\n\n container.registerInstance(EventPublisher, { publish: vi.fn() });\n container.register(ContentEntriesCacheProvider).inSingletonScope();\n container.register(CmsModelContextImpl).inSingletonScope();\n container.resolve(CmsModelContext).setModel(MODEL);\n\n ListEntriesFeature.register(container);\n DeleteEntryFeature.register(container);\n PublishEntryFeature.register(container);\n UnpublishEntryFeature.register(container);\n MoveEntryFeature.register(container);\n DuplicateEntryFeature.register(container);\n UpdateRevisionDescriptionFeature.register(container);\n\n const listEntriesGateway = { execute: vi.fn() };\n const moveEntryGateway = { execute: vi.fn() };\n const deleteEntryGateway = { execute: vi.fn() };\n\n container.registerInstance(ListEntriesGateway, listEntriesGateway);\n container.registerInstance(MoveEntryGateway, moveEntryGateway);\n container.registerInstance(DeleteEntryGateway, deleteEntryGateway);\n const duplicateEntryGateway = { execute: vi.fn() };\n container.registerInstance(DuplicateEntryGateway, duplicateEntryGateway);\n const publishEntryGateway = { execute: vi.fn() };\n container.registerInstance(PublishEntryGateway, publishEntryGateway);\n container.registerInstance(UnpublishEntryGateway, { execute: vi.fn() });\n container.registerInstance(UpdateRevisionDescriptionGateway, { execute: vi.fn() });\n\n container.register(ContentEntriesPresenter).inSingletonScope();\n const presenter = container.resolve(Abstraction);\n\n return {\n presenter,\n listEntriesGateway,\n moveEntryGateway,\n deleteEntryGateway,\n duplicateEntryGateway,\n getDescendantFolders,\n foldersPresenter,\n publishEntryGateway,\n container\n };\n}\n\nasync function initPresenter(\n t: TestSetup,\n gatewayResponse: { data: CmsContentEntry[]; meta?: object }\n) {\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: gatewayResponse.data,\n meta: gatewayResponse.meta ?? {\n cursor: null,\n hasMoreItems: false,\n totalCount: gatewayResponse.data.length\n }\n });\n\n t.presenter.init();\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.pagination.loading).toBe(false);\n });\n}\n\ndescribe(\"ContentEntriesPresenter\", () => {\n let t: TestSetup;\n\n beforeEach(() => {\n t = setup();\n });\n\n describe(\"initial load\", () => {\n it(\"should show root entries after setModel\", async () => {\n const entries = [createEntry(\"entry-1\", \"root\"), createEntry(\"entry-2\", \"root\")];\n\n await initPresenter(t, { data: entries });\n\n expect(t.presenter.list.vm.rows).toHaveLength(2);\n expect(t.presenter.list.vm.rows.map(r => r.entryId)).toEqual([\"entry-1\", \"entry-2\"]);\n });\n\n it(\"should send folderId=root in the gateway query\", async () => {\n await initPresenter(t, { data: [] });\n\n expect(t.listEntriesGateway.execute).toHaveBeenCalledWith(\n expect.objectContaining({\n where: expect.objectContaining({\n wbyAco_location: { folderId: \"root\" }\n })\n })\n );\n });\n\n it(\"should set model after init\", async () => {\n await initPresenter(t, { data: [] });\n\n expect(t.presenter.vm.model).toStrictEqual(MODEL);\n });\n });\n\n describe(\"folder navigation\", () => {\n it(\"should filter to folder entries when navigating to a subfolder\", async () => {\n const rootEntries = [createEntry(\"root-1\", \"root\")];\n await initPresenter(t, { data: rootEntries });\n\n const folderEntries = [\n createEntry(\"folder-1\", \"folder-a\"),\n createEntry(\"folder-2\", \"folder-a\")\n ];\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: folderEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 2 }\n });\n\n t.foldersPresenter.selectFolder(\"folder-a\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(2);\n });\n\n expect(t.presenter.list.vm.rows.map(r => r.entryId)).toEqual([\"folder-1\", \"folder-2\"]);\n });\n\n it(\"should show only root entries when navigating back to root\", async () => {\n const rootEntries = [createEntry(\"root-1\", \"root\")];\n await initPresenter(t, { data: rootEntries });\n\n const folderEntries = [createEntry(\"folder-1\", \"folder-a\")];\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: folderEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.foldersPresenter.selectFolder(\"folder-a\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"folder-1\");\n });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: rootEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.foldersPresenter.selectFolder(null);\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"root-1\");\n });\n });\n\n it(\"should not leak subfolder entries into root view\", async () => {\n const rootEntries = [createEntry(\"root-1\", \"root\")];\n await initPresenter(t, { data: rootEntries });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [createEntry(\"folder-1\", \"folder-a\")],\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.foldersPresenter.selectFolder(\"folder-a\");\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: rootEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.foldersPresenter.selectFolder(null);\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"root-1\");\n });\n });\n });\n\n describe(\"search\", () => {\n it(\"should show only search results from API\", async () => {\n const rootEntries = [createEntry(\"entry-1\", \"root\"), createEntry(\"entry-2\", \"root\")];\n await initPresenter(t, { data: rootEntries });\n\n const searchResults = [createEntry(\"entry-1\", \"root\")];\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: searchResults,\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.presenter.list.actions.search.set(\"entry-1\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n });\n\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"entry-1\");\n });\n\n it(\"should include entries from subfolders when searching from root\", async () => {\n await initPresenter(t, { data: [] });\n\n const searchResults = [\n createEntry(\"root-1\", \"root\"),\n createEntry(\"folder-1\", \"folder-a\")\n ];\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: searchResults,\n meta: { cursor: null, hasMoreItems: false, totalCount: 2 }\n });\n\n t.presenter.list.actions.search.set(\"test\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(2);\n });\n });\n\n it(\"should search with folderId_in containing all descendant folders when in a subfolder\", async () => {\n const folderEntries = [createEntry(\"folder-1\", \"folder-a\")];\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: folderEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.presenter.init({ initialFolderId: \"folder-a\" });\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.pagination.loading).toBe(false);\n });\n\n t.getDescendantFolders.mockReturnValue([\n { id: \"folder-a\" },\n { id: \"folder-a-1\" },\n { id: \"folder-a-2\" }\n ]);\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [\n createEntry(\"folder-1\", \"folder-a\"),\n createEntry(\"sub-1\", \"folder-a-1\"),\n createEntry(\"sub-2\", \"folder-a-2\")\n ],\n meta: { cursor: null, hasMoreItems: false, totalCount: 3 }\n });\n\n t.presenter.list.actions.search.set(\"test\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(3);\n });\n\n expect(t.getDescendantFolders).toHaveBeenCalledWith(\"folder-a\");\n\n const searchCall = t.listEntriesGateway.execute.mock.calls.at(-1) ?? [];\n expect(searchCall[0].where).toEqual(\n expect.objectContaining({\n wbyAco_location: {\n folderId_in: [\"folder-a\", \"folder-a-1\", \"folder-a-2\"]\n }\n })\n );\n });\n\n it(\"should restore folder view when clearing search\", async () => {\n const rootEntries = [createEntry(\"entry-1\", \"root\"), createEntry(\"entry-2\", \"root\")];\n await initPresenter(t, { data: rootEntries });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [createEntry(\"entry-1\", \"root\")],\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.presenter.list.actions.search.set(\"entry-1\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: rootEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 2 }\n });\n\n t.presenter.list.actions.search.clear();\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(2);\n });\n });\n });\n\n describe(\"status filter\", () => {\n it(\"should filter by status locally\", async () => {\n const entries = [\n createEntry(\"draft-1\", \"root\", {\n meta: {\n title: \"draft-1\",\n status: \"draft\",\n version: 1,\n locked: false\n }\n }),\n createEntry(\"published-1\", \"root\", {\n meta: {\n title: \"published-1\",\n status: \"published\",\n version: 1,\n locked: false\n }\n })\n ];\n await initPresenter(t, { data: entries });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: entries.filter(e => (e.meta as { status: string }).status === \"published\"),\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.presenter.list.actions.filter.set(\"status\", \"published\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"published-1\");\n });\n });\n });\n\n describe(\"move entry\", () => {\n it(\"should remove entry from current view after move\", async () => {\n const entries = [createEntry(\"entry-1\", \"root\"), createEntry(\"entry-2\", \"root\")];\n await initPresenter(t, { data: entries });\n\n t.moveEntryGateway.execute.mockResolvedValueOnce(true);\n\n await t.presenter.moveEntry(\"entry-1#0001\", \"folder-b\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"entry-2\");\n });\n });\n });\n\n describe(\"duplicate entry\", () => {\n it(\"should add the duplicated entry to the current view\", async () => {\n const entries = [\n createEntry(\"entry-2\", \"root\", { savedOn: \"2024-01-02T00:00:00.000Z\" }),\n createEntry(\"entry-1\", \"root\", { savedOn: \"2024-01-01T00:00:00.000Z\" })\n ];\n await initPresenter(t, { data: entries });\n\n const duplicate = createEntry(\"entry-3\", \"root\", {\n savedOn: \"2024-01-03T00:00:00.000Z\"\n });\n t.duplicateEntryGateway.execute.mockResolvedValueOnce(duplicate);\n\n const result = await t.presenter.duplicateEntry(entries[1]);\n\n expect(result).toEqual({ entry: duplicate });\n expect(t.duplicateEntryGateway.execute).toHaveBeenCalledWith({\n model: MODEL,\n revisionId: \"entry-1#0001\"\n });\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows.map(r => r.entryId)).toEqual([\n \"entry-3\",\n \"entry-2\",\n \"entry-1\"\n ]);\n });\n });\n\n it(\"should return the error when duplication fails\", async () => {\n const entries = [createEntry(\"entry-1\", \"root\")];\n await initPresenter(t, { data: entries });\n\n const error = new Error(\"Not allowed.\");\n t.duplicateEntryGateway.execute.mockRejectedValueOnce(error);\n\n const result = await t.presenter.duplicateEntry(entries[0]);\n\n expect(result).toEqual({ error });\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n });\n });\n\n describe(\"delete entry\", () => {\n it(\"should remove entry from current view after delete\", async () => {\n const entries = [createEntry(\"entry-1\", \"root\"), createEntry(\"entry-2\", \"root\")];\n await initPresenter(t, { data: entries });\n\n t.deleteEntryGateway.execute.mockResolvedValueOnce(true);\n\n await t.presenter.deleteEntry(\"entry-1#0001\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"entry-2\");\n });\n });\n });\n\n describe(\"vm\", () => {\n it(\"should set model on init\", () => {\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 }\n });\n t.presenter.init();\n expect(t.presenter.vm.model).toStrictEqual(MODEL);\n });\n\n it(\"should track selected entry\", async () => {\n await initPresenter(t, { data: [] });\n\n expect(t.presenter.vm.showingEntry).toBe(false);\n\n t.presenter.selectEntry(\"some-id\");\n expect(t.presenter.vm.selectedEntryId).toBe(\"some-id\");\n expect(t.presenter.vm.showingEntry).toBe(true);\n\n t.presenter.deselectEntry();\n expect(t.presenter.vm.selectedEntryId).toBeNull();\n expect(t.presenter.vm.showingEntry).toBe(false);\n });\n\n it(\"should set selectedEntryId to 'new' on createEntry\", async () => {\n await initPresenter(t, { data: [] });\n\n t.presenter.createEntry();\n expect(t.presenter.vm.selectedEntryId).toBe(\"new\");\n });\n\n it(\"should show folders when no search or non-folder filters active\", async () => {\n await initPresenter(t, { data: [] });\n\n expect(t.presenter.vm.showFolders).toBe(true);\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 }\n });\n\n t.presenter.list.actions.search.set(\"test\");\n\n await vi.waitFor(() => {\n expect(t.presenter.vm.showFolders).toBe(false);\n });\n });\n });\n\n describe(\"publish entry\", () => {\n /**\n * Publishing is not a content modification: the API returns the entry with its\n * `savedOn` unchanged, so the entry must keep its position in a list sorted by `savedOn`.\n */\n const entries = [\n createEntry(\"entry-3\", \"root\", { savedOn: \"2024-01-03T00:00:00.000Z\" }),\n createEntry(\"entry-2\", \"root\", { savedOn: \"2024-01-02T00:00:00.000Z\" }),\n createEntry(\"entry-1\", \"root\", { savedOn: \"2024-01-01T00:00:00.000Z\" })\n ];\n\n const publish = async (entry: CmsContentEntry) => {\n t.publishEntryGateway.execute.mockResolvedValueOnce({\n ...entry,\n meta: { ...entry.meta, status: \"published\", locked: true }\n });\n await t.container\n .resolve(PublishEntryUseCase)\n .execute({ model: MODEL, revisionId: entry.id });\n };\n\n it(\"should keep a published entry in its position\", async () => {\n await initPresenter(t, { data: entries });\n\n await publish(entries[1]);\n\n const rows = t.presenter.list.vm.rows;\n expect(rows.map(r => r.entryId)).toEqual([\"entry-3\", \"entry-2\", \"entry-1\"]);\n expect((rows[1].meta as { status: string }).status).toBe(\"published\");\n });\n\n it(\"should keep a published entry in its position when sorted ascending\", async () => {\n await initPresenter(t, { data: entries });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [...entries].reverse(),\n meta: { cursor: null, hasMoreItems: false, totalCount: entries.length }\n });\n t.presenter.list.actions.sort.set(\"savedOn\", \"ASC\");\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.appliedQuery?.sort?.direction).toBe(\"ASC\");\n });\n\n await publish(entries[1]);\n\n expect(t.presenter.list.vm.rows.map(r => r.entryId)).toEqual([\n \"entry-1\",\n \"entry-2\",\n \"entry-3\"\n ]);\n });\n });\n});\n"],"names":["MODEL","createEntry","entryId","folderId","overrides","MockFolderTreePresenter","makeAutoObservable","setup","container","Container","ListPresenterFeature","foldersPresenter","FolderTreePresenter","Confirmation","vi","_name","_params","execute","undefined","getDescendantFolders","GetDescendantFoldersUseCase","EventPublisher","ContentEntriesCacheProvider","CmsModelContextImpl","CmsModelContext","ListEntriesFeature","DeleteEntryFeature","PublishEntryFeature","UnpublishEntryFeature","MoveEntryFeature","DuplicateEntryFeature","UpdateRevisionDescriptionFeature","listEntriesGateway","moveEntryGateway","deleteEntryGateway","ListEntriesGateway","MoveEntryGateway","DeleteEntryGateway","duplicateEntryGateway","DuplicateEntryGateway","publishEntryGateway","PublishEntryGateway","UnpublishEntryGateway","UpdateRevisionDescriptionGateway","ContentEntriesPresenter","presenter","Abstraction","initPresenter","t","gatewayResponse","expect","describe","beforeEach","it","entries","r","rootEntries","folderEntries","searchResults","searchCall","e","duplicate","result","error","Error","publish","entry","PublishEntryUseCase","rows"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAMA,QAAkB;IACpB,SAAS;IACT,MAAM;IACN,iBAAiB;IACjB,eAAe;IACf,QAAQ,EAAE;IACV,QAAQ,EAAE;IACV,OAAO;IACP,cAAc;IACd,oBAAoB;IACpB,cAAc;IACd,MAAM,EAAE;IACR,SAAS;AACb;AAEA,SAASC,YACLC,OAAe,EACfC,QAAgB,EAChBC,YAAsC,CAAC,CAAC;IAExC,OAAO;QACH,IAAI,GAAGF,QAAQ,KAAK,CAAC;QACrBA;QACA,MAAM;YACF,OAAOA;YACP,QAAQ;YACR,SAAS;YACT,QAAQ;QACZ;QACA,iBAAiB;YAAEC;QAAS;QAC5B,QAAQ,CAAC;QACT,WAAW;YAAE,IAAI;YAAU,aAAa;YAAQ,M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AG;gBAAE,MAAMM;YAAQ;YAEvCN,EAAE,kBAAkB,CAAC,OAAO,CAAC,qBAAqB,CAAC;gBAC/C,MAAM;uBAAIM;iBAAQ,CAAC,OAAO;gBAC1B,MAAM;oBAAE,QAAQ;oBAAM,cAAc;oBAAO,YAAYA,QAAQ,MAAM;gBAAC;YAC1E;YACAN,EAAE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW;YAC7C,MAAMlC,GAAG,OAAO,CAAC;gBACboC,OAAOF,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,WAAW,IAAI,CAAC;YACnE;YAEA,MAAMiB,QAAQX,OAAO,CAAC,EAAE;YAExBJ,OAAOF,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAACO,CAAAA,IAAKA,EAAE,OAAO,GAAG,OAAO,CAAC;gBACzD;gBACA;gBACA;aACH;QACL;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"presentation/contentEntries/list/ContentEntriesPresenter.test.js","sources":["../../../../src/presentation/contentEntries/list/ContentEntriesPresenter.test.ts"],"sourcesContent":["/**\n * @vitest-environment jsdom\n */\nimport { describe, it, expect, vi, beforeEach } from \"vitest\";\nimport type { Mock } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { makeAutoObservable } from \"mobx\";\nimport { ListPresenterFeature } from \"@webiny/app-admin/presentation/listPresenter/index.js\";\nimport { FolderTreePresenter } from \"@webiny/app-aco/presentation/folderTree/abstractions.js\";\nimport { GetDescendantFoldersUseCase } from \"@webiny/app-aco/features/folders/getDescendantFolders/abstractions.js\";\nimport { Confirmation } from \"@webiny/app-admin/features/confirmation/abstractions.js\";\nimport { AssistantPageContext } from \"@webiny/app-admin/features/assistantPageContext/abstractions.js\";\nimport { AssistantPageContext as AssistantPageContextImpl } from \"@webiny/app-admin/features/assistantPageContext/AssistantPageContext.js\";\nimport { FoldersContext } from \"@webiny/app-aco/features/folders/abstractions.js\";\nimport type { CmsContentEntry, CmsModel } from \"~/types.js\";\nimport { ContentEntriesCacheProvider } from \"~/features/contentEntry/ContentEntriesCacheProvider.js\";\nimport { CmsModelContext } from \"~/features/contentEntry/abstractions.js\";\nimport { CmsModelContext as CmsModelContextImpl } from \"~/features/contentEntry/CmsModelContext.js\";\nimport { ListEntriesFeature } from \"~/features/contentEntry/listEntries/feature.js\";\nimport { DeleteEntryFeature } from \"~/features/contentEntry/deleteEntry/feature.js\";\nimport { PublishEntryFeature } from \"~/features/contentEntry/publishEntry/feature.js\";\nimport { UnpublishEntryFeature } from \"~/features/contentEntry/unpublishEntry/feature.js\";\nimport { MoveEntryFeature } from \"~/features/contentEntry/moveEntry/feature.js\";\nimport { DuplicateEntryFeature } from \"~/features/contentEntry/duplicateEntry/feature.js\";\nimport { UpdateRevisionDescriptionFeature } from \"~/features/contentEntry/updateRevisionDescription/feature.js\";\nimport { ListEntriesGateway } from \"~/features/contentEntry/listEntries/abstractions.js\";\nimport { DeleteEntryGateway } from \"~/features/contentEntry/deleteEntry/abstractions.js\";\nimport {\n PublishEntryGateway,\n PublishEntryUseCase\n} from \"~/features/contentEntry/publishEntry/abstractions.js\";\nimport { UnpublishEntryGateway } from \"~/features/contentEntry/unpublishEntry/abstractions.js\";\nimport { MoveEntryGateway } from \"~/features/contentEntry/moveEntry/abstractions.js\";\nimport { DuplicateEntryGateway } from \"~/features/contentEntry/duplicateEntry/abstractions.js\";\nimport { UpdateRevisionDescriptionGateway } from \"~/features/contentEntry/updateRevisionDescription/abstractions.js\";\nimport { EventPublisher } from \"@webiny/app/features/eventPublisher/index.js\";\nimport { ContentEntriesPresenter as Abstraction } from \"./abstractions.js\";\nimport { ContentEntriesPresenter } from \"./ContentEntriesPresenter.js\";\nimport type { IContentEntriesPresenter } from \"./abstractions.js\";\nimport type {\n IFolderTreeViewModel,\n IFolderOperationState\n} from \"@webiny/app-aco/presentation/folderTree/abstractions.js\";\n\nconst MODEL: CmsModel = {\n modelId: \"testModel\",\n name: \"Test Model\",\n singularApiName: \"TestModel\",\n pluralApiName: \"TestModels\",\n fields: [],\n layout: [],\n group: \"group-1\",\n titleFieldId: \"title\",\n descriptionFieldId: null,\n imageFieldId: null,\n tags: [],\n savedOn: \"\"\n} as unknown as CmsModel;\n\nfunction createEntry(\n entryId: string,\n folderId: string,\n overrides: Partial<CmsContentEntry> = {}\n): CmsContentEntry {\n return {\n id: `${entryId}#0001`,\n entryId,\n meta: {\n title: entryId,\n status: \"draft\",\n version: 1,\n locked: false\n },\n wbyAco_location: { folderId },\n values: {},\n createdBy: { id: \"user-1\", displayName: \"Test\", type: \"admin\" },\n createdOn: \"2024-01-01T00:00:00Z\",\n savedOn: \"2024-01-01T00:00:00Z\",\n ...overrides\n } as unknown as CmsContentEntry;\n}\n\nclass MockFolderTreePresenter implements FolderTreePresenter.Interface {\n private _currentFolderId: string | null = null;\n\n constructor() {\n makeAutoObservable(this);\n }\n\n get vm(): IFolderTreeViewModel {\n return {\n folders: [],\n tree: [],\n currentFolderId: this._currentFolderId,\n currentFolder: null,\n isRootFolder: this._currentFolderId === null,\n currentFolderTitle: \"Home\",\n childFolders: [],\n loading: false,\n loadingNodeIds: [],\n operation: { active: false, mode: null } as IFolderOperationState\n };\n }\n\n selectFolder(folderId: string | null): void {\n this._currentFolderId = folderId;\n }\n\n createFolder(): void {}\n editFolder(): void {}\n async deleteFolder(): Promise<void> {}\n async moveFolder(): Promise<void> {}\n async loadChildFolders(): Promise<void> {}\n canManageStructure(): boolean {\n return true;\n }\n getAncestorIds(): string[] {\n return [];\n }\n async submitOperation(): Promise<boolean> {\n return true;\n }\n cancelOperation(): void {}\n onFolderChange(): () => void {\n return () => {};\n }\n}\n\ninterface TestSetup {\n presenter: IContentEntriesPresenter;\n listEntriesGateway: { execute: Mock };\n moveEntryGateway: { execute: Mock };\n deleteEntryGateway: { execute: Mock };\n duplicateEntryGateway: { execute: Mock };\n getDescendantFolders: Mock;\n foldersPresenter: MockFolderTreePresenter;\n publishEntryGateway: { execute: Mock };\n container: Container;\n}\n\nfunction setup(): TestSetup {\n const container = new Container();\n\n ListPresenterFeature.register(container);\n\n const foldersPresenter = new MockFolderTreePresenter();\n container.registerInstance(FolderTreePresenter, foldersPresenter);\n\n container.registerInstance(Confirmation, {\n confirm: vi.fn(async (_name, _params, execute) => {\n if (execute) {\n return await execute(undefined);\n }\n return true;\n })\n } as unknown as Confirmation.Interface);\n\n const getDescendantFolders = vi.fn().mockReturnValue([]);\n container.registerInstance(GetDescendantFoldersUseCase, {\n execute: getDescendantFolders\n });\n\n container.registerInstance(EventPublisher, { publish: vi.fn() });\n container.register(ContentEntriesCacheProvider).inSingletonScope();\n container.register(CmsModelContextImpl).inSingletonScope();\n container.resolve(CmsModelContext).setModel(MODEL);\n\n ListEntriesFeature.register(container);\n DeleteEntryFeature.register(container);\n PublishEntryFeature.register(container);\n UnpublishEntryFeature.register(container);\n MoveEntryFeature.register(container);\n DuplicateEntryFeature.register(container);\n UpdateRevisionDescriptionFeature.register(container);\n\n const listEntriesGateway = { execute: vi.fn() };\n const moveEntryGateway = { execute: vi.fn() };\n const deleteEntryGateway = { execute: vi.fn() };\n\n container.registerInstance(ListEntriesGateway, listEntriesGateway);\n container.registerInstance(MoveEntryGateway, moveEntryGateway);\n container.registerInstance(DeleteEntryGateway, deleteEntryGateway);\n const duplicateEntryGateway = { execute: vi.fn() };\n container.registerInstance(DuplicateEntryGateway, duplicateEntryGateway);\n const publishEntryGateway = { execute: vi.fn() };\n container.registerInstance(PublishEntryGateway, publishEntryGateway);\n container.registerInstance(UnpublishEntryGateway, { execute: vi.fn() });\n container.registerInstance(UpdateRevisionDescriptionGateway, { execute: vi.fn() });\n\n container.registerInstance(FoldersContext, { type: \"cms:testModel\" });\n container.register(AssistantPageContextImpl).inSingletonScope();\n\n container.register(ContentEntriesPresenter).inSingletonScope();\n const presenter = container.resolve(Abstraction);\n\n return {\n presenter,\n listEntriesGateway,\n moveEntryGateway,\n deleteEntryGateway,\n duplicateEntryGateway,\n getDescendantFolders,\n foldersPresenter,\n publishEntryGateway,\n container\n };\n}\n\nasync function initPresenter(\n t: TestSetup,\n gatewayResponse: { data: CmsContentEntry[]; meta?: object }\n) {\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: gatewayResponse.data,\n meta: gatewayResponse.meta ?? {\n cursor: null,\n hasMoreItems: false,\n totalCount: gatewayResponse.data.length\n }\n });\n\n t.presenter.init();\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.pagination.loading).toBe(false);\n });\n}\n\ndescribe(\"ContentEntriesPresenter\", () => {\n let t: TestSetup;\n\n beforeEach(() => {\n t = setup();\n });\n\n describe(\"initial load\", () => {\n it(\"should show root entries after setModel\", async () => {\n const entries = [createEntry(\"entry-1\", \"root\"), createEntry(\"entry-2\", \"root\")];\n\n await initPresenter(t, { data: entries });\n\n expect(t.presenter.list.vm.rows).toHaveLength(2);\n expect(t.presenter.list.vm.rows.map(r => r.entryId)).toEqual([\"entry-1\", \"entry-2\"]);\n });\n\n it(\"should send folderId=root in the gateway query\", async () => {\n await initPresenter(t, { data: [] });\n\n expect(t.listEntriesGateway.execute).toHaveBeenCalledWith(\n expect.objectContaining({\n where: expect.objectContaining({\n wbyAco_location: { folderId: \"root\" }\n })\n })\n );\n });\n\n it(\"should set model after init\", async () => {\n await initPresenter(t, { data: [] });\n\n expect(t.presenter.vm.model).toStrictEqual(MODEL);\n });\n });\n\n describe(\"assistant page context\", () => {\n const current = () => t.container.resolve(AssistantPageContext).get();\n\n it(\"tells the assistant the model and folder type once initialised\", async () => {\n expect(current()).toBeNull();\n\n await initPresenter(t, { data: [] });\n\n expect(current()).toEqual({\n view: 'Entries of the \"Test Model\" content model in Headless CMS',\n details: {\n items: \"entries\",\n totalCount: 0,\n visibleRows: [],\n modelId: \"testModel\",\n modelName: \"Test Model\",\n folderType: \"cms:testModel\",\n currentFolder: null,\n visibleFolders: []\n }\n });\n });\n\n it(\"follows the open folder and the open entry\", async () => {\n await initPresenter(t, { data: [] });\n\n t.foldersPresenter.selectFolder(\"folder-1\");\n t.presenter.selectEntry(\"entry-1#0002\");\n\n expect(current()?.details).toMatchObject({\n currentFolder: { id: \"folder-1\", title: \"Home\" },\n openEntryId: \"entry-1\"\n });\n });\n\n it(\"stays under a context set over it while the list changes\", async () => {\n await initPresenter(t, { data: [] });\n const drawer = { view: \"Entry revisions\", details: {} };\n t.container.resolve(AssistantPageContext).set(drawer);\n\n t.foldersPresenter.selectFolder(\"folder-1\");\n\n expect(current()).toEqual(drawer);\n });\n\n it(\"takes its context back on dispose, leaving one set before it\", async () => {\n const pageContext = t.container.resolve(AssistantPageContext);\n const page = { view: \"Dashboard\", details: {} };\n pageContext.set(page);\n\n await initPresenter(t, { data: [] });\n expect(current()?.view).toContain(\"Test Model\");\n\n t.presenter.dispose();\n expect(current()).toEqual(page);\n });\n });\n\n describe(\"folder navigation\", () => {\n it(\"should filter to folder entries when navigating to a subfolder\", async () => {\n const rootEntries = [createEntry(\"root-1\", \"root\")];\n await initPresenter(t, { data: rootEntries });\n\n const folderEntries = [\n createEntry(\"folder-1\", \"folder-a\"),\n createEntry(\"folder-2\", \"folder-a\")\n ];\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: folderEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 2 }\n });\n\n t.foldersPresenter.selectFolder(\"folder-a\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(2);\n });\n\n expect(t.presenter.list.vm.rows.map(r => r.entryId)).toEqual([\"folder-1\", \"folder-2\"]);\n });\n\n it(\"should show only root entries when navigating back to root\", async () => {\n const rootEntries = [createEntry(\"root-1\", \"root\")];\n await initPresenter(t, { data: rootEntries });\n\n const folderEntries = [createEntry(\"folder-1\", \"folder-a\")];\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: folderEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.foldersPresenter.selectFolder(\"folder-a\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"folder-1\");\n });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: rootEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.foldersPresenter.selectFolder(null);\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"root-1\");\n });\n });\n\n it(\"should not leak subfolder entries into root view\", async () => {\n const rootEntries = [createEntry(\"root-1\", \"root\")];\n await initPresenter(t, { data: rootEntries });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [createEntry(\"folder-1\", \"folder-a\")],\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.foldersPresenter.selectFolder(\"folder-a\");\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: rootEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.foldersPresenter.selectFolder(null);\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"root-1\");\n });\n });\n });\n\n describe(\"search\", () => {\n it(\"should show only search results from API\", async () => {\n const rootEntries = [createEntry(\"entry-1\", \"root\"), createEntry(\"entry-2\", \"root\")];\n await initPresenter(t, { data: rootEntries });\n\n const searchResults = [createEntry(\"entry-1\", \"root\")];\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: searchResults,\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.presenter.list.actions.search.set(\"entry-1\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n });\n\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"entry-1\");\n });\n\n it(\"should include entries from subfolders when searching from root\", async () => {\n await initPresenter(t, { data: [] });\n\n const searchResults = [\n createEntry(\"root-1\", \"root\"),\n createEntry(\"folder-1\", \"folder-a\")\n ];\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: searchResults,\n meta: { cursor: null, hasMoreItems: false, totalCount: 2 }\n });\n\n t.presenter.list.actions.search.set(\"test\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(2);\n });\n });\n\n it(\"should search with folderId_in containing all descendant folders when in a subfolder\", async () => {\n const folderEntries = [createEntry(\"folder-1\", \"folder-a\")];\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: folderEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.presenter.init({ initialFolderId: \"folder-a\" });\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.pagination.loading).toBe(false);\n });\n\n t.getDescendantFolders.mockReturnValue([\n { id: \"folder-a\" },\n { id: \"folder-a-1\" },\n { id: \"folder-a-2\" }\n ]);\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [\n createEntry(\"folder-1\", \"folder-a\"),\n createEntry(\"sub-1\", \"folder-a-1\"),\n createEntry(\"sub-2\", \"folder-a-2\")\n ],\n meta: { cursor: null, hasMoreItems: false, totalCount: 3 }\n });\n\n t.presenter.list.actions.search.set(\"test\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(3);\n });\n\n expect(t.getDescendantFolders).toHaveBeenCalledWith(\"folder-a\");\n\n const searchCall = t.listEntriesGateway.execute.mock.calls.at(-1) ?? [];\n expect(searchCall[0].where).toEqual(\n expect.objectContaining({\n wbyAco_location: {\n folderId_in: [\"folder-a\", \"folder-a-1\", \"folder-a-2\"]\n }\n })\n );\n });\n\n it(\"should restore folder view when clearing search\", async () => {\n const rootEntries = [createEntry(\"entry-1\", \"root\"), createEntry(\"entry-2\", \"root\")];\n await initPresenter(t, { data: rootEntries });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [createEntry(\"entry-1\", \"root\")],\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.presenter.list.actions.search.set(\"entry-1\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: rootEntries,\n meta: { cursor: null, hasMoreItems: false, totalCount: 2 }\n });\n\n t.presenter.list.actions.search.clear();\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(2);\n });\n });\n });\n\n describe(\"status filter\", () => {\n it(\"should filter by status locally\", async () => {\n const entries = [\n createEntry(\"draft-1\", \"root\", {\n meta: {\n title: \"draft-1\",\n status: \"draft\",\n version: 1,\n locked: false\n }\n }),\n createEntry(\"published-1\", \"root\", {\n meta: {\n title: \"published-1\",\n status: \"published\",\n version: 1,\n locked: false\n }\n })\n ];\n await initPresenter(t, { data: entries });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: entries.filter(e => (e.meta as { status: string }).status === \"published\"),\n meta: { cursor: null, hasMoreItems: false, totalCount: 1 }\n });\n\n t.presenter.list.actions.filter.set(\"status\", \"published\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"published-1\");\n });\n });\n });\n\n describe(\"move entry\", () => {\n it(\"should remove entry from current view after move\", async () => {\n const entries = [createEntry(\"entry-1\", \"root\"), createEntry(\"entry-2\", \"root\")];\n await initPresenter(t, { data: entries });\n\n t.moveEntryGateway.execute.mockResolvedValueOnce(true);\n\n await t.presenter.moveEntry(\"entry-1#0001\", \"folder-b\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"entry-2\");\n });\n });\n });\n\n describe(\"duplicate entry\", () => {\n it(\"should add the duplicated entry to the current view\", async () => {\n const entries = [\n createEntry(\"entry-2\", \"root\", { savedOn: \"2024-01-02T00:00:00.000Z\" }),\n createEntry(\"entry-1\", \"root\", { savedOn: \"2024-01-01T00:00:00.000Z\" })\n ];\n await initPresenter(t, { data: entries });\n\n const duplicate = createEntry(\"entry-3\", \"root\", {\n savedOn: \"2024-01-03T00:00:00.000Z\"\n });\n t.duplicateEntryGateway.execute.mockResolvedValueOnce(duplicate);\n\n const result = await t.presenter.duplicateEntry(entries[1]);\n\n expect(result).toEqual({ entry: duplicate });\n expect(t.duplicateEntryGateway.execute).toHaveBeenCalledWith({\n model: MODEL,\n revisionId: \"entry-1#0001\"\n });\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows.map(r => r.entryId)).toEqual([\n \"entry-3\",\n \"entry-2\",\n \"entry-1\"\n ]);\n });\n });\n\n it(\"should return the error when duplication fails\", async () => {\n const entries = [createEntry(\"entry-1\", \"root\")];\n await initPresenter(t, { data: entries });\n\n const error = new Error(\"Not allowed.\");\n t.duplicateEntryGateway.execute.mockRejectedValueOnce(error);\n\n const result = await t.presenter.duplicateEntry(entries[0]);\n\n expect(result).toEqual({ error });\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n });\n });\n\n describe(\"delete entry\", () => {\n it(\"should remove entry from current view after delete\", async () => {\n const entries = [createEntry(\"entry-1\", \"root\"), createEntry(\"entry-2\", \"root\")];\n await initPresenter(t, { data: entries });\n\n t.deleteEntryGateway.execute.mockResolvedValueOnce(true);\n\n await t.presenter.deleteEntry(\"entry-1#0001\");\n\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.rows).toHaveLength(1);\n expect(t.presenter.list.vm.rows[0].entryId).toBe(\"entry-2\");\n });\n });\n });\n\n describe(\"vm\", () => {\n it(\"should set model on init\", () => {\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 }\n });\n t.presenter.init();\n expect(t.presenter.vm.model).toStrictEqual(MODEL);\n });\n\n it(\"should track selected entry\", async () => {\n await initPresenter(t, { data: [] });\n\n expect(t.presenter.vm.showingEntry).toBe(false);\n\n t.presenter.selectEntry(\"some-id\");\n expect(t.presenter.vm.selectedEntryId).toBe(\"some-id\");\n expect(t.presenter.vm.showingEntry).toBe(true);\n\n t.presenter.deselectEntry();\n expect(t.presenter.vm.selectedEntryId).toBeNull();\n expect(t.presenter.vm.showingEntry).toBe(false);\n });\n\n it(\"should set selectedEntryId to 'new' on createEntry\", async () => {\n await initPresenter(t, { data: [] });\n\n t.presenter.createEntry();\n expect(t.presenter.vm.selectedEntryId).toBe(\"new\");\n });\n\n it(\"should show folders when no search or non-folder filters active\", async () => {\n await initPresenter(t, { data: [] });\n\n expect(t.presenter.vm.showFolders).toBe(true);\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [],\n meta: { cursor: null, hasMoreItems: false, totalCount: 0 }\n });\n\n t.presenter.list.actions.search.set(\"test\");\n\n await vi.waitFor(() => {\n expect(t.presenter.vm.showFolders).toBe(false);\n });\n });\n });\n\n describe(\"publish entry\", () => {\n /**\n * Publishing is not a content modification: the API returns the entry with its\n * `savedOn` unchanged, so the entry must keep its position in a list sorted by `savedOn`.\n */\n const entries = [\n createEntry(\"entry-3\", \"root\", { savedOn: \"2024-01-03T00:00:00.000Z\" }),\n createEntry(\"entry-2\", \"root\", { savedOn: \"2024-01-02T00:00:00.000Z\" }),\n createEntry(\"entry-1\", \"root\", { savedOn: \"2024-01-01T00:00:00.000Z\" })\n ];\n\n const publish = async (entry: CmsContentEntry) => {\n t.publishEntryGateway.execute.mockResolvedValueOnce({\n ...entry,\n meta: { ...entry.meta, status: \"published\", locked: true }\n });\n await t.container\n .resolve(PublishEntryUseCase)\n .execute({ model: MODEL, revisionId: entry.id });\n };\n\n it(\"should keep a published entry in its position\", async () => {\n await initPresenter(t, { data: entries });\n\n await publish(entries[1]);\n\n const rows = t.presenter.list.vm.rows;\n expect(rows.map(r => r.entryId)).toEqual([\"entry-3\", \"entry-2\", \"entry-1\"]);\n expect((rows[1].meta as { status: string }).status).toBe(\"published\");\n });\n\n it(\"should keep a published entry in its position when sorted ascending\", async () => {\n await initPresenter(t, { data: entries });\n\n t.listEntriesGateway.execute.mockResolvedValueOnce({\n data: [...entries].reverse(),\n meta: { cursor: null, hasMoreItems: false, totalCount: entries.length }\n });\n t.presenter.list.actions.sort.set(\"savedOn\", \"ASC\");\n await vi.waitFor(() => {\n expect(t.presenter.list.vm.appliedQuery?.sort?.direction).toBe(\"ASC\");\n });\n\n await publish(entries[1]);\n\n expect(t.presenter.list.vm.rows.map(r => r.entryId)).toEqual([\n \"entry-1\",\n \"entry-2\",\n \"entry-3\"\n ]);\n });\n });\n});\n"],"names":["MODEL","createEntry","entryId","folderId","overrides","MockFolderTreePresenter","makeAutoObservable","setup","container","Container","ListPresenterFeature","foldersPresenter","FolderTreePresenter","Confirmation","vi","_name","_params","execute","undefined","getDescendantFolders","GetDescendantFoldersUseCase","EventPublisher","ContentEntriesCacheProvider","CmsModelContextImpl","CmsModelContext","ListEntriesFeature","DeleteEntryFeature","PublishEntryFeature","UnpublishEntryFeature","MoveEntryFeature","DuplicateEntryFeature","UpdateRevisionDescriptionFeature","listEntriesGateway","moveEntryGateway","deleteEntryGateway","ListEntriesGateway","MoveEntryGateway","DeleteEntryGateway","duplicateEntryGateway","DuplicateEntryGateway","publishEntryGateway","PublishEntryGateway","UnpublishEntryGateway","UpdateRevisionDescriptionGateway","FoldersContext","AssistantPageContextImpl","ContentEntriesPresenter","presenter","Abstraction","initPresenter","t","gatewayResponse","expect","describe","beforeEach","it","entries","r","current","AssistantPageContext","drawer","pageContext","page","rootEntries","folderEntries","searchResults","searchCall","e","duplicate","result","error","Error","publish","entry","PublishEntryUseCase","rows"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAMA,QAAkB;IACpB,SAAS;IACT,MAAM;IACN,iBAAiB;IACjB,eAAe;IACf,QAAQ,EAAE;IACV,QAAQ,EAAE;IAC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Effect, useState } from "react";
|
|
2
2
|
import { observer } from "mobx-react-lite";
|
|
3
3
|
import { useFeature } from "@webiny/app";
|
|
4
4
|
import { TrashBinFeature } from "@webiny/app-admin/presentation/trashBin/feature.js";
|
|
@@ -12,13 +12,23 @@ const CmsTrashBin = observer(()=>{
|
|
|
12
12
|
const { presenter } = useFeature(TrashBinFeature);
|
|
13
13
|
const handleOpen = useCallback(()=>{
|
|
14
14
|
presenter.init({
|
|
15
|
-
nameColumnId: model.titleFieldId || "id"
|
|
15
|
+
nameColumnId: model.titleFieldId || "id",
|
|
16
|
+
assistant: {
|
|
17
|
+
view: `Deleted entries of the "${model.name}" content model in Headless CMS`,
|
|
18
|
+
details: {
|
|
19
|
+
modelId: model.modelId,
|
|
20
|
+
modelName: model.name
|
|
21
|
+
}
|
|
22
|
+
}
|
|
16
23
|
});
|
|
17
24
|
setOpen(true);
|
|
18
25
|
}, [
|
|
19
26
|
model,
|
|
20
27
|
presenter
|
|
21
28
|
]);
|
|
29
|
+
useEffect(()=>()=>presenter.dispose(), [
|
|
30
|
+
presenter
|
|
31
|
+
]);
|
|
22
32
|
const handleClose = useCallback(async ()=>{
|
|
23
33
|
setOpen(false);
|
|
24
34
|
presenter.dispose();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentEntries/trashBin/CmsTrashBin.js","sources":["../../../../src/presentation/contentEntries/trashBin/CmsTrashBin.tsx"],"sourcesContent":["import React
|
|
1
|
+
{"version":3,"file":"presentation/contentEntries/trashBin/CmsTrashBin.js","sources":["../../../../src/presentation/contentEntries/trashBin/CmsTrashBin.tsx"],"sourcesContent":["import React from \"react\";\nimport { useCallback } from \"react\";\nimport { useEffect } from \"react\";\nimport { useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useFeature } from \"@webiny/app\";\nimport { TrashBinFeature } from \"@webiny/app-admin/presentation/trashBin/feature.js\";\nimport { TrashBinOverlay } from \"@webiny/app-admin/presentation/trashBin/components/TrashBinOverlay.js\";\nimport { Sidebar } from \"@webiny/admin-ui\";\nimport { ReactComponent as Delete } from \"@webiny/icons/delete.svg\";\nimport { useModel } from \"~/admin/components/ModelProvider/index.js\";\n\nexport const CmsTrashBin = observer(() => {\n const [open, setOpen] = useState(false);\n const { model } = useModel();\n\n const { presenter } = useFeature(TrashBinFeature);\n\n const handleOpen = useCallback(() => {\n presenter.init({\n nameColumnId: model.titleFieldId || \"id\",\n assistant: {\n view: `Deleted entries of the \"${model.name}\" content model in Headless CMS`,\n details: { modelId: model.modelId, modelName: model.name }\n }\n });\n\n setOpen(true);\n }, [model, presenter]);\n\n // Leaving the list with the trash open would leave its description to the assistant.\n useEffect(() => () => presenter.dispose(), [presenter]);\n\n const handleClose = useCallback(async () => {\n setOpen(false);\n presenter.dispose();\n }, [presenter]);\n\n return (\n <>\n <div className={\"list-none\"}>\n <Sidebar.Item\n onClick={handleOpen}\n text={\"Trash\"}\n icon={<Sidebar.Item.Icon element={<Delete />} label={\"Delete\"} />}\n />\n </div>\n {open ? (\n <TrashBinOverlay\n presenter={presenter}\n title={`Trash - ${model.name}`}\n onExited={handleClose}\n />\n ) : null}\n </>\n );\n});\n"],"names":["CmsTrashBin","observer","open","setOpen","useState","model","useModel","presenter","useFeature","TrashBinFeature","handleOpen","useCallback","useEffect","handleClose","Sidebar","Delete","TrashBinOverlay"],"mappings":";;;;;;;;AAYO,MAAMA,cAAcC,SAAS;IAChC,MAAM,CAACC,MAAMC,QAAQ,GAAGC,SAAS;IACjC,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAElB,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IAEjC,MAAMC,aAAaC,YAAY;QAC3BJ,UAAU,IAAI,CAAC;YACX,cAAcF,MAAM,YAAY,IAAI;YACpC,WAAW;gBACP,MAAM,CAAC,wBAAwB,EAAEA,MAAM,IAAI,CAAC,+BAA+B,CAAC;gBAC5E,SAAS;oBAAE,SAASA,MAAM,OAAO;oBAAE,WAAWA,MAAM,IAAI;gBAAC;YAC7D;QACJ;QAEAF,QAAQ;IACZ,GAAG;QAACE;QAAOE;KAAU;IAGrBK,UAAU,IAAM,IAAML,UAAU,OAAO,IAAI;QAACA;KAAU;IAEtD,MAAMM,cAAcF,YAAY;QAC5BR,QAAQ;QACRI,UAAU,OAAO;IACrB,GAAG;QAACA;KAAU;IAEd,OAAO,WAAP,GACI,wDACI,oBAAC;QAAI,WAAW;qBACZ,oBAACO,QAAQ,IAAI;QACT,SAASJ;QACT,MAAM;QACN,oBAAM,oBAACI,QAAQ,IAAI,CAAC,IAAI;YAAC,uBAAS,oBAACC,gBAAMA;YAAK,OAAO;;SAG5Db,OAAO,WAAPA,GACG,oBAACc,iBAAeA;QACZ,WAAWT;QACX,OAAO,CAAC,QAAQ,EAAEF,MAAM,IAAI,EAAE;QAC9B,UAAUQ;SAEd;AAGhB"}
|
|
@@ -37,7 +37,7 @@ const SingleEntryLayout = observer(({ presenter, modelName })=>{
|
|
|
37
37
|
onClick: handleSave,
|
|
38
38
|
disabled: null !== vm.loading
|
|
39
39
|
}) : null)), /*#__PURE__*/ react.createElement(SimpleFormContent, {
|
|
40
|
-
className: "border-sm border-t-none border-neutral-dimmed-darker rounded-b-
|
|
40
|
+
className: "border-sm border-t-none border-neutral-dimmed-darker rounded-b-lg-plus"
|
|
41
41
|
}, vm.loading ? /*#__PURE__*/ react.createElement(OverlayLoader, {
|
|
42
42
|
text: vm.loading
|
|
43
43
|
}) : null, /*#__PURE__*/ react.createElement(FormView, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentEntries/views/SingleEntryLayout.js","sources":["../../../../src/presentation/contentEntries/views/SingleEntryLayout.tsx"],"sourcesContent":["import React from \"react\";\nimport { useCallback } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { FormView } from \"@webiny/app-admin/features/formModel/FormView.js\";\nimport {\n SimpleForm,\n SimpleFormHeader,\n SimpleFormContent\n} from \"@webiny/app-admin/components/SimpleForm/SimpleForm.js\";\nimport { Button, OverlayLoader, useToast } from \"@webiny/admin-ui\";\nimport { FormErrors } from \"@webiny/app-admin\";\nimport type { ISingleEntryPresenter } from \"../singleEntry/abstractions.js\";\nimport { SingleEntryFormContent } from \"./SingleEntryFormContent.js\";\n\ninterface SingleEntryLayoutProps {\n presenter: ISingleEntryPresenter;\n modelName: string;\n}\n\nexport const SingleEntryLayout = observer(({ presenter, modelName }: SingleEntryLayoutProps) => {\n const toast = useToast();\n const { vm } = presenter;\n\n const handleSave = useCallback(async () => {\n const success = await presenter.save();\n if (success) {\n toast.showSuccessToast({\n title: `${modelName} saved successfully!`\n });\n }\n }, [presenter, modelName]);\n\n if (!vm.form) {\n if (vm.loading) {\n return <OverlayLoader text={vm.loading} />;\n }\n return null;\n }\n\n return (\n <SingleEntryFormContent>\n <SimpleForm size={\"lg\"}>\n <FormErrors form={vm.form} className={\"mb-md\"} />\n <SimpleFormHeader title={modelName}>\n <div className={\"flex justify-end\"}>\n {vm.canSave ? (\n <Button\n text=\"Save\"\n onClick={handleSave}\n disabled={vm.loading !== null}\n />\n ) : null}\n </div>\n </SimpleFormHeader>\n <SimpleFormContent\n className={\"border-sm border-t-none border-neutral-dimmed-darker rounded-b-
|
|
1
|
+
{"version":3,"file":"presentation/contentEntries/views/SingleEntryLayout.js","sources":["../../../../src/presentation/contentEntries/views/SingleEntryLayout.tsx"],"sourcesContent":["import React from \"react\";\nimport { useCallback } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { FormView } from \"@webiny/app-admin/features/formModel/FormView.js\";\nimport {\n SimpleForm,\n SimpleFormHeader,\n SimpleFormContent\n} from \"@webiny/app-admin/components/SimpleForm/SimpleForm.js\";\nimport { Button, OverlayLoader, useToast } from \"@webiny/admin-ui\";\nimport { FormErrors } from \"@webiny/app-admin\";\nimport type { ISingleEntryPresenter } from \"../singleEntry/abstractions.js\";\nimport { SingleEntryFormContent } from \"./SingleEntryFormContent.js\";\n\ninterface SingleEntryLayoutProps {\n presenter: ISingleEntryPresenter;\n modelName: string;\n}\n\nexport const SingleEntryLayout = observer(({ presenter, modelName }: SingleEntryLayoutProps) => {\n const toast = useToast();\n const { vm } = presenter;\n\n const handleSave = useCallback(async () => {\n const success = await presenter.save();\n if (success) {\n toast.showSuccessToast({\n title: `${modelName} saved successfully!`\n });\n }\n }, [presenter, modelName]);\n\n if (!vm.form) {\n if (vm.loading) {\n return <OverlayLoader text={vm.loading} />;\n }\n return null;\n }\n\n return (\n <SingleEntryFormContent>\n <SimpleForm size={\"lg\"}>\n <FormErrors form={vm.form} className={\"mb-md\"} />\n <SimpleFormHeader title={modelName}>\n <div className={\"flex justify-end\"}>\n {vm.canSave ? (\n <Button\n text=\"Save\"\n onClick={handleSave}\n disabled={vm.loading !== null}\n />\n ) : null}\n </div>\n </SimpleFormHeader>\n <SimpleFormContent\n className={\n \"border-sm border-t-none border-neutral-dimmed-darker rounded-b-lg-plus\"\n }\n >\n {vm.loading ? <OverlayLoader text={vm.loading} /> : null}\n <FormView name=\"SingleEntryForm\" form={vm.form} />\n </SimpleFormContent>\n </SimpleForm>\n </SingleEntryFormContent>\n );\n});\n"],"names":["SingleEntryLayout","observer","presenter","modelName","toast","useToast","vm","handleSave","useCallback","success","OverlayLoader","SingleEntryFormContent","SimpleForm","FormErrors","SimpleFormHeader","Button","SimpleFormContent","FormView"],"mappings":";;;;;;;AAmBO,MAAMA,oBAAoBC,SAAS,CAAC,EAAEC,SAAS,EAAEC,SAAS,EAA0B;IACvF,MAAMC,QAAQC;IACd,MAAM,EAAEC,EAAE,EAAE,GAAGJ;IAEf,MAAMK,aAAaC,YAAY;QAC3B,MAAMC,UAAU,MAAMP,UAAU,IAAI;QACpC,IAAIO,SACAL,MAAM,gBAAgB,CAAC;YACnB,OAAO,GAAGD,UAAU,oBAAoB,CAAC;QAC7C;IAER,GAAG;QAACD;QAAWC;KAAU;IAEzB,IAAI,CAACG,GAAG,IAAI,EAAE;QACV,IAAIA,GAAG,OAAO,EACV,OAAO,WAAP,GAAO,oBAACI,eAAaA;YAAC,MAAMJ,GAAG,OAAO;;QAE1C,OAAO;IACX;IAEA,OAAO,WAAP,GACI,oBAACK,wBAAsBA,MAAAA,WAAAA,GACnB,oBAACC,YAAUA;QAAC,MAAM;qBACd,oBAACC,YAAUA;QAAC,MAAMP,GAAG,IAAI;QAAE,WAAW;sBACtC,oBAACQ,kBAAgBA;QAAC,OAAOX;qBACrB,oBAAC;QAAI,WAAW;OACXG,GAAG,OAAO,GAAG,WAAH,GACP,oBAACS,QAAMA;QACH,MAAK;QACL,SAASR;QACT,UAAUD,AAAe,SAAfA,GAAG,OAAO;SAExB,sBAGZ,oBAACU,mBAAiBA;QACd,WACI;OAGHV,GAAG,OAAO,GAAG,WAAH,GAAG,oBAACI,eAAaA;QAAC,MAAMJ,GAAG,OAAO;SAAO,oBACpD,oBAACW,UAAQA;QAAC,MAAK;QAAkB,MAAMX,GAAG,IAAI;;AAKlE"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { IDataSourceQuery } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
|
|
3
|
-
import type { FetchResult } from "@webiny/app-admin/presentation/listPresenter/FolderAwareDataSource.js";
|
|
1
|
+
import { LocalDataSource } from "@webiny/app-admin/presentation/listPresenter/LocalDataSource.js";
|
|
4
2
|
import type { CmsModel } from "../../types.js";
|
|
5
3
|
import type { IListModelsUseCase } from "../../features/model/listModels/abstractions.js";
|
|
6
4
|
import type { IListCache } from "@webiny/app-admin/features/listCache/index.js";
|
|
7
|
-
export declare class ContentModelsDataSource extends
|
|
5
|
+
export declare class ContentModelsDataSource extends LocalDataSource<CmsModel> {
|
|
8
6
|
private listModelsUseCase;
|
|
9
7
|
private cache;
|
|
10
8
|
constructor(listModelsUseCase: IListModelsUseCase, cache: IListCache<CmsModel>);
|
|
11
|
-
get
|
|
12
|
-
|
|
9
|
+
protected get items(): CmsModel[];
|
|
10
|
+
protected load(): Promise<void>;
|
|
11
|
+
protected searchIn(model: CmsModel): Array<string | null | undefined>;
|
|
13
12
|
}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { LocalDataSource } from "@webiny/app-admin/presentation/listPresenter/LocalDataSource.js";
|
|
2
|
+
import { isListedModel } from "./isListedModel.js";
|
|
3
|
+
class ContentModelsDataSource extends LocalDataSource {
|
|
3
4
|
constructor(listModelsUseCase, cache){
|
|
4
5
|
super(), this.listModelsUseCase = listModelsUseCase, this.cache = cache;
|
|
5
6
|
}
|
|
6
|
-
get
|
|
7
|
-
return this.cache.getItems();
|
|
7
|
+
get items() {
|
|
8
|
+
return this.cache.getItems().filter(isListedModel);
|
|
8
9
|
}
|
|
9
|
-
async
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
totalCount: result.length
|
|
17
|
-
}
|
|
18
|
-
};
|
|
10
|
+
async load() {
|
|
11
|
+
await this.listModelsUseCase.execute();
|
|
12
|
+
}
|
|
13
|
+
searchIn(model) {
|
|
14
|
+
return [
|
|
15
|
+
model.name
|
|
16
|
+
];
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
export { ContentModelsDataSource };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentModels/ContentModelsDataSource.js","sources":["../../../src/presentation/contentModels/ContentModelsDataSource.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/ContentModelsDataSource.js","sources":["../../../src/presentation/contentModels/ContentModelsDataSource.ts"],"sourcesContent":["import { LocalDataSource } from \"@webiny/app-admin/presentation/listPresenter/LocalDataSource.js\";\nimport type { CmsModel } from \"~/types.js\";\nimport type { IListModelsUseCase } from \"~/features/model/listModels/abstractions.js\";\nimport type { IListCache } from \"@webiny/app-admin/features/listCache/index.js\";\nimport { isListedModel } from \"./isListedModel.js\";\n\nexport class ContentModelsDataSource extends LocalDataSource<CmsModel> {\n constructor(\n private listModelsUseCase: IListModelsUseCase,\n private cache: IListCache<CmsModel>\n ) {\n super();\n }\n\n protected get items(): CmsModel[] {\n return this.cache.getItems().filter(isListedModel);\n }\n\n protected async load(): Promise<void> {\n await this.listModelsUseCase.execute();\n }\n\n protected searchIn(model: CmsModel): Array<string | null | undefined> {\n return [model.name];\n }\n}\n"],"names":["ContentModelsDataSource","LocalDataSource","listModelsUseCase","cache","isListedModel","model"],"mappings":";;AAMO,MAAMA,gCAAgCC;IACzC,YACYC,iBAAqC,EACrCC,KAA2B,CACrC;QACE,KAAK,SAHGD,iBAAiB,GAAjBA,mBAAAA,IAAAA,CACAC,KAAK,GAALA;IAGZ;IAEA,IAAc,QAAoB;QAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAACC;IACxC;IAEA,MAAgB,OAAsB;QAClC,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO;IACxC;IAEU,SAASC,KAAe,EAAoC;QAClE,OAAO;YAACA,MAAM,IAAI;SAAC;IACvB;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { ListCache } from "@webiny/app-admin/features/listCache/index.js";
|
|
3
|
+
import { ContentModelsDataSource } from "./ContentModelsDataSource.js";
|
|
4
|
+
const model = (modelId, tags = [])=>({
|
|
5
|
+
id: modelId,
|
|
6
|
+
modelId,
|
|
7
|
+
name: modelId,
|
|
8
|
+
tags
|
|
9
|
+
});
|
|
10
|
+
describe("ContentModelsDataSource", ()=>{
|
|
11
|
+
it("lists and counts only the models the screen shows, never hidden ones", async ()=>{
|
|
12
|
+
const models = [
|
|
13
|
+
model("product"),
|
|
14
|
+
model("fmFile", [
|
|
15
|
+
"$hidden:true"
|
|
16
|
+
]),
|
|
17
|
+
model("article")
|
|
18
|
+
];
|
|
19
|
+
const cache = new ListCache();
|
|
20
|
+
const dataSource = new ContentModelsDataSource({
|
|
21
|
+
execute: async ()=>{
|
|
22
|
+
cache.setItems(models);
|
|
23
|
+
return models;
|
|
24
|
+
}
|
|
25
|
+
}, cache);
|
|
26
|
+
await dataSource.query({});
|
|
27
|
+
expect(dataSource.rows.map((row)=>row.modelId)).toEqual([
|
|
28
|
+
"product",
|
|
29
|
+
"article"
|
|
30
|
+
]);
|
|
31
|
+
expect(dataSource.meta.totalCount).toBe(2);
|
|
32
|
+
});
|
|
33
|
+
it("searches and sorts the listed models without loading again, still leaving hidden ones out", async ()=>{
|
|
34
|
+
const models = [
|
|
35
|
+
model("product"),
|
|
36
|
+
model("fmFile", [
|
|
37
|
+
"$hidden:true"
|
|
38
|
+
]),
|
|
39
|
+
model("article")
|
|
40
|
+
];
|
|
41
|
+
const cache = new ListCache();
|
|
42
|
+
const execute = vi.fn(async ()=>{
|
|
43
|
+
cache.setItems(models);
|
|
44
|
+
return models;
|
|
45
|
+
});
|
|
46
|
+
const dataSource = new ContentModelsDataSource({
|
|
47
|
+
execute
|
|
48
|
+
}, cache);
|
|
49
|
+
await dataSource.query({});
|
|
50
|
+
await dataSource.query({
|
|
51
|
+
search: "file"
|
|
52
|
+
});
|
|
53
|
+
expect(dataSource.rows).toEqual([]);
|
|
54
|
+
await dataSource.query({
|
|
55
|
+
search: "R",
|
|
56
|
+
sort: {
|
|
57
|
+
field: "name",
|
|
58
|
+
direction: "ASC"
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
expect(dataSource.rows.map((row)=>row.modelId)).toEqual([
|
|
62
|
+
"article",
|
|
63
|
+
"product"
|
|
64
|
+
]);
|
|
65
|
+
expect(dataSource.meta.totalCount).toBe(2);
|
|
66
|
+
expect(execute).toHaveBeenCalledTimes(1);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=ContentModelsDataSource.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/ContentModelsDataSource.test.js","sources":["../../../src/presentation/contentModels/ContentModelsDataSource.test.ts"],"sourcesContent":["import { describe } from \"vitest\";\nimport { it } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { ListCache } from \"@webiny/app-admin/features/listCache/index.js\";\nimport type { CmsModel } from \"~/types.js\";\nimport { ContentModelsDataSource } from \"./ContentModelsDataSource.js\";\n\nconst model = (modelId: string, tags: string[] = []): CmsModel =>\n ({ id: modelId, modelId, name: modelId, tags }) as unknown as CmsModel;\n\ndescribe(\"ContentModelsDataSource\", () => {\n it(\"lists and counts only the models the screen shows, never hidden ones\", async () => {\n const models = [model(\"product\"), model(\"fmFile\", [\"$hidden:true\"]), model(\"article\")];\n const cache = new ListCache<CmsModel>();\n const dataSource = new ContentModelsDataSource(\n {\n execute: async () => {\n cache.setItems(models);\n return models;\n }\n },\n cache\n );\n\n await dataSource.query({});\n\n expect(dataSource.rows.map(row => row.modelId)).toEqual([\"product\", \"article\"]);\n expect(dataSource.meta.totalCount).toBe(2);\n });\n\n it(\"searches and sorts the listed models without loading again, still leaving hidden ones out\", async () => {\n const models = [model(\"product\"), model(\"fmFile\", [\"$hidden:true\"]), model(\"article\")];\n const cache = new ListCache<CmsModel>();\n const execute = vi.fn(async () => {\n cache.setItems(models);\n return models;\n });\n const dataSource = new ContentModelsDataSource({ execute }, cache);\n\n await dataSource.query({});\n await dataSource.query({ search: \"file\" });\n expect(dataSource.rows).toEqual([]);\n\n await dataSource.query({ search: \"R\", sort: { field: \"name\", direction: \"ASC\" } });\n expect(dataSource.rows.map(row => row.modelId)).toEqual([\"article\", \"product\"]);\n expect(dataSource.meta.totalCount).toBe(2);\n\n expect(execute).toHaveBeenCalledTimes(1);\n });\n});\n"],"names":["model","modelId","tags","describe","it","models","cache","ListCache","dataSource","ContentModelsDataSource","expect","row","execute","vi"],"mappings":";;;AAQA,MAAMA,QAAQ,CAACC,SAAiBC,OAAiB,EAAE,GAC9C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|
|
@@ -13,11 +13,10 @@ declare class ContentModelsPresenterImpl implements Abstraction.Interface {
|
|
|
13
13
|
private cancelDeleteModelUseCase;
|
|
14
14
|
private exportModelsUseCase;
|
|
15
15
|
private cache;
|
|
16
|
-
private loading;
|
|
17
16
|
constructor(listPresenter: ListPresenter.Interface<CmsModel>, listModelsUseCase: ListModelsUseCase.Interface, deleteModelUseCase: DeleteModelUseCase.Interface, cancelDeleteModelUseCase: CancelDeleteModelUseCase.Interface, exportModelsUseCase: ExportModelsUseCase.Interface, cache: ModelsCache.Interface);
|
|
18
|
-
get vm(): Abstraction.ViewModel;
|
|
19
17
|
get list(): ListPresenter.Interface<CmsModel>;
|
|
20
18
|
init(): void;
|
|
19
|
+
dispose(): void;
|
|
21
20
|
deleteModel(modelId: string, confirmation: string): Promise<import("~/features/model/deleteModel/abstractions.js").DeleteModelResult>;
|
|
22
21
|
cancelDelete(modelId: string): Promise<void>;
|
|
23
22
|
exportModels(modelIds?: string[]): Promise<Abstraction.ExportModelResponse | null>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { computed, makeAutoObservable, runInAction } from "mobx";
|
|
2
1
|
import { ListPresenter } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
|
|
3
2
|
import { ListModelsUseCase } from "../../features/model/listModels/abstractions.js";
|
|
4
3
|
import { DeleteModelUseCase } from "../../features/model/deleteModel/abstractions.js";
|
|
@@ -15,25 +14,6 @@ class ContentModelsPresenterImpl {
|
|
|
15
14
|
this.cancelDeleteModelUseCase = cancelDeleteModelUseCase;
|
|
16
15
|
this.exportModelsUseCase = exportModelsUseCase;
|
|
17
16
|
this.cache = cache;
|
|
18
|
-
this.loading = true;
|
|
19
|
-
makeAutoObservable(this, {
|
|
20
|
-
listModelsUseCase: false,
|
|
21
|
-
deleteModelUseCase: false,
|
|
22
|
-
cancelDeleteModelUseCase: false,
|
|
23
|
-
exportModelsUseCase: false,
|
|
24
|
-
cache: false,
|
|
25
|
-
vm: computed
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
get vm() {
|
|
29
|
-
const models = this.cache.getItems().filter((model)=>{
|
|
30
|
-
if (!model.tags || 0 === model.tags.length) return true;
|
|
31
|
-
return !model.tags.includes("$hidden:true");
|
|
32
|
-
});
|
|
33
|
-
return {
|
|
34
|
-
loading: this.loading,
|
|
35
|
-
models
|
|
36
|
-
};
|
|
37
17
|
}
|
|
38
18
|
get list() {
|
|
39
19
|
return this.listPresenter;
|
|
@@ -46,12 +26,21 @@ class ContentModelsPresenterImpl {
|
|
|
46
26
|
field: "savedOn",
|
|
47
27
|
direction: "DESC"
|
|
48
28
|
},
|
|
49
|
-
limit: 1000
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
29
|
+
limit: 1000,
|
|
30
|
+
itemLabel: {
|
|
31
|
+
singular: "model",
|
|
32
|
+
plural: "models"
|
|
33
|
+
},
|
|
34
|
+
assistant: {
|
|
35
|
+
view: ()=>"Content models in Headless CMS",
|
|
36
|
+
rowTitle: (model)=>model.name,
|
|
37
|
+
rowId: (model)=>model.modelId
|
|
38
|
+
}
|
|
53
39
|
});
|
|
54
40
|
}
|
|
41
|
+
dispose() {
|
|
42
|
+
this.listPresenter.dispose();
|
|
43
|
+
}
|
|
55
44
|
async deleteModel(modelId, confirmation) {
|
|
56
45
|
return this.deleteModelUseCase.execute(modelId, confirmation);
|
|
57
46
|
}
|