@webiny/app-headless-cms 6.5.0-beta.0 → 6.5.0-beta.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/ContentEntriesModule.js +14 -2
- package/ContentEntriesModule.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.d.ts +2 -0
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.js +84 -0
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.js.map +1 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.d.ts +2 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js +34 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js.map +1 -0
- package/admin/components/ContentEntries/Table/Actions/index.d.ts +1 -0
- package/admin/components/ContentEntries/Table/Actions/index.js +1 -0
- package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.d.ts +2 -0
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js +22 -0
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js.map +1 -0
- package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
- package/admin/components/FieldEditor/Field.js +4 -4
- package/admin/components/FieldEditor/Field.js.map +1 -1
- package/features/contentEntry/CmsEntryError.d.ts +10 -0
- package/features/contentEntry/CmsEntryError.js +11 -0
- package/features/contentEntry/CmsEntryError.js.map +1 -0
- package/features/contentEntry/createEntry/CreateEntryGateway.d.ts +0 -1
- package/features/contentEntry/createEntry/CreateEntryGateway.js +3 -10
- package/features/contentEntry/createEntry/CreateEntryGateway.js.map +1 -1
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.d.ts +3 -1
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js +8 -3
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js.map +1 -1
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.d.ts +14 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js +43 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js.map +1 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.d.ts +15 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js +34 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js.map +1 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.d.ts +11 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js +18 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js.map +1 -0
- package/features/contentEntry/duplicateEntry/abstractions.d.ts +26 -0
- package/features/contentEntry/duplicateEntry/abstractions.js +7 -0
- package/features/contentEntry/duplicateEntry/abstractions.js.map +1 -0
- package/features/contentEntry/duplicateEntry/feature.d.ts +3 -0
- package/features/contentEntry/duplicateEntry/feature.js +21 -0
- package/features/contentEntry/duplicateEntry/feature.js.map +1 -0
- package/features/contentEntry/entryValueGateways.test.d.ts +1 -0
- package/features/contentEntry/entryValueGateways.test.js +106 -0
- package/features/contentEntry/entryValueGateways.test.js.map +1 -0
- package/features/contentEntry/feature.js +2 -0
- package/features/contentEntry/feature.js.map +1 -1
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.d.ts +0 -1
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js +3 -10
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js.map +1 -1
- package/features/contentEntry/updateEntry/UpdateEntryGateway.d.ts +0 -1
- package/features/contentEntry/updateEntry/UpdateEntryGateway.js +3 -10
- package/features/contentEntry/updateEntry/UpdateEntryGateway.js.map +1 -1
- package/features/contentEntry/valueTransformers/EntryDataPreparer.d.ts +9 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.js +8 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.js.map +1 -1
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.d.ts +1 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js +113 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js.map +1 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.d.ts +146 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.js +171 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.js.map +1 -0
- package/features/formModel/CmsFormModelBuilder.d.ts +9 -1
- package/features/formModel/CmsFormModelBuilder.js +26 -15
- package/features/formModel/CmsFormModelBuilder.js.map +1 -1
- package/features/formModel/CmsFormModelBuilder.test.d.ts +1 -0
- package/features/formModel/CmsFormModelBuilder.test.js +252 -0
- package/features/formModel/CmsFormModelBuilder.test.js.map +1 -0
- package/features/formModel/CmsLayoutMapper.d.ts +8 -1
- package/features/formModel/CmsLayoutMapper.js +23 -1
- package/features/formModel/CmsLayoutMapper.js.map +1 -1
- package/features/formModel/mappers/DynamicZoneFieldMapper.js +4 -0
- package/features/formModel/mappers/DynamicZoneFieldMapper.js.map +1 -1
- package/features/formModel/mappers/ObjectFieldMapper.js +11 -6
- package/features/formModel/mappers/ObjectFieldMapper.js.map +1 -1
- package/features/model/exportModels/ExportModelsGateway.d.ts +1 -1
- package/features/model/exportModels/ExportModelsGateway.js.map +1 -1
- package/features/model/exportModels/ExportModelsUseCase.js +7 -1
- package/features/model/exportModels/ExportModelsUseCase.js.map +1 -1
- package/features/model/exportModels/abstractions.d.ts +8 -2
- package/features/model/exportModels/abstractions.js.map +1 -1
- package/package.json +26 -26
- package/presentation/cloneContentModel/CloneContentModelPresenter.d.ts +1 -0
- package/presentation/cloneContentModel/CloneContentModelPresenter.js +8 -6
- package/presentation/cloneContentModel/CloneContentModelPresenter.js.map +1 -1
- package/presentation/contentEntries/form/ContentEntryFormPresenter.js +34 -29
- package/presentation/contentEntries/form/ContentEntryFormPresenter.js.map +1 -1
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js +210 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js.map +1 -0
- package/presentation/contentEntries/form/toFormErrors.d.ts +7 -0
- package/presentation/contentEntries/form/toFormErrors.js +49 -0
- package/presentation/contentEntries/form/toFormErrors.js.map +1 -0
- package/presentation/contentEntries/form/toFormErrors.test.d.ts +1 -0
- package/presentation/contentEntries/form/toFormErrors.test.js +175 -0
- package/presentation/contentEntries/form/toFormErrors.test.js.map +1 -0
- package/presentation/contentEntries/list/ContentEntriesDataSource.d.ts +5 -0
- package/presentation/contentEntries/list/ContentEntriesDataSource.js +11 -2
- package/presentation/contentEntries/list/ContentEntriesDataSource.js.map +1 -1
- package/presentation/contentEntries/list/ContentEntriesPresenter.d.ts +6 -2
- package/presentation/contentEntries/list/ContentEntriesPresenter.js +27 -2
- package/presentation/contentEntries/list/ContentEntriesPresenter.js.map +1 -1
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +130 -5
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
- package/presentation/contentEntries/list/abstractions.d.ts +12 -0
- package/presentation/contentEntries/list/abstractions.js.map +1 -1
- package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +12 -1
- package/presentation/contentEntries/preview/LivePreviewPresenter.js +48 -5
- package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -1
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.js +81 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.js.map +1 -0
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js +1 -1
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -1
- package/presentation/contentEntries/preview/PreviewDecorator.js +25 -6
- package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -1
- package/presentation/contentEntries/preview/PreviewDomainStatus.d.ts +10 -0
- package/presentation/contentEntries/preview/PreviewDomainStatus.js +19 -0
- package/presentation/contentEntries/preview/PreviewDomainStatus.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewPane.d.ts +10 -1
- package/presentation/contentEntries/preview/PreviewPane.js +81 -45
- package/presentation/contentEntries/preview/PreviewPane.js.map +1 -1
- package/presentation/contentEntries/preview/abstractions.d.ts +8 -0
- package/presentation/contentEntries/preview/abstractions.js.map +1 -1
- package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +21 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.js +50 -1
- package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -1
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.d.ts +1 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.js +127 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.js.map +1 -0
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js +9 -4
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js.map +1 -1
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js +122 -0
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js.map +1 -0
- package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
- package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
- package/presentation/contentEntries/views/OlderRevisionAlert.d.ts +2 -2
- package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
- package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
- package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
- package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
- package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
- package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
- package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
- package/presentation/contentModels/ContentModelsPresenter.d.ts +5 -5
- package/presentation/contentModels/ContentModelsPresenter.js +1 -1
- package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
- package/presentation/contentModels/abstractions.d.ts +7 -2
- package/presentation/contentModels/abstractions.js.map +1 -1
- package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
- package/presentation/contentModels/components/ContentModels.d.ts +2 -2
- package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
- package/presentation/contentModels/components/ContentModelsDataList.js +6 -5
- package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
- package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
- package/presentation/contentModels/components/fullDelete/dialog/Content.js +2 -2
- package/presentation/contentModels/components/fullDelete/dialog/Content.js.map +1 -1
- package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.d.ts +1 -0
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js +133 -0
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js.map +1 -0
- package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.js +3 -2
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.js.map +1 -1
- package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
- package/presentation/importContentModels/ImportContentModelsPresenter.js +1 -1
- package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
- package/presentation/importContentModels/components/DataList.d.ts +2 -2
- package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
- package/presentation/importContentModels/components/FileUpload.js +1 -1
- package/presentation/importContentModels/components/FileUpload.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModelItem.js +3 -3
- package/presentation/importContentModels/components/Model/DataListModelItem.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModelItemInfo.js +2 -2
- package/presentation/importContentModels/components/Model/DataListModelItemInfo.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
- package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
- package/presentation/modelGroup/ModelGroupPresenter.js +1 -2
- package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
- package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
- package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
- package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
- package/presentation/newContentModel/NewContentModelPresenter.d.ts +1 -0
- package/presentation/newContentModel/NewContentModelPresenter.js +8 -6
- package/presentation/newContentModel/NewContentModelPresenter.js.map +1 -1
- package/utils/normalizeIcon.d.ts +4 -0
- package/utils/normalizeIcon.js +9 -6
- package/utils/normalizeIcon.js.map +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { Container } from "@webiny/di";
|
|
3
|
+
import { SearchContentEntriesUseCase } from "../../../../features/contentEntry/searchContentEntries/abstractions.js";
|
|
4
|
+
import { GetContentEntriesUseCase } from "../../../../features/contentEntry/getContentEntries/abstractions.js";
|
|
5
|
+
import { RefMultiAutocompletePresenter } from "./multi/abstractions.js";
|
|
6
|
+
import { RefMultiAutocompletePresenter as RefMultiAutocompletePresenter_js_RefMultiAutocompletePresenter } from "./multi/RefMultiAutocompletePresenter.js";
|
|
7
|
+
import { RefSingleAutocompletePresenter } from "./single/abstractions.js";
|
|
8
|
+
import { RefSingleAutocompletePresenter as RefSingleAutocompletePresenter_js_RefSingleAutocompletePresenter } from "./single/RefSingleAutocompletePresenter.js";
|
|
9
|
+
const createEntry = (entryId, title)=>({
|
|
10
|
+
id: `${entryId}#0001`,
|
|
11
|
+
entryId,
|
|
12
|
+
status: "draft",
|
|
13
|
+
title,
|
|
14
|
+
description: null,
|
|
15
|
+
image: null,
|
|
16
|
+
createdOn: "2026-01-01T00:00:00.000Z",
|
|
17
|
+
savedOn: "2026-01-01T00:00:00.000Z",
|
|
18
|
+
createdBy: {
|
|
19
|
+
id: "1",
|
|
20
|
+
type: "admin",
|
|
21
|
+
displayName: "Admin"
|
|
22
|
+
},
|
|
23
|
+
modifiedBy: null,
|
|
24
|
+
model: {
|
|
25
|
+
modelId: "location",
|
|
26
|
+
name: "Location"
|
|
27
|
+
},
|
|
28
|
+
published: null,
|
|
29
|
+
wbyAco_location: null
|
|
30
|
+
});
|
|
31
|
+
const defaultEntry = createEntry("first", "First");
|
|
32
|
+
const searchedEntry = createEntry("second", "Second");
|
|
33
|
+
const createContainer = ()=>{
|
|
34
|
+
const container = new Container();
|
|
35
|
+
container.registerInstance(SearchContentEntriesUseCase, {
|
|
36
|
+
execute: async ({ query })=>({
|
|
37
|
+
data: query ? [
|
|
38
|
+
searchedEntry
|
|
39
|
+
] : [
|
|
40
|
+
defaultEntry
|
|
41
|
+
]
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
container.registerInstance(GetContentEntriesUseCase, {
|
|
45
|
+
execute: async ()=>({
|
|
46
|
+
latest: [],
|
|
47
|
+
published: []
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
return container;
|
|
51
|
+
};
|
|
52
|
+
describe("RefMultiAutocompletePresenter", ()=>{
|
|
53
|
+
it("keeps an entry picked from the search results", async ()=>{
|
|
54
|
+
const container = createContainer();
|
|
55
|
+
container.register(RefMultiAutocompletePresenter_js_RefMultiAutocompletePresenter);
|
|
56
|
+
const presenter = container.resolve(RefMultiAutocompletePresenter);
|
|
57
|
+
await presenter.init({
|
|
58
|
+
modelIds: [
|
|
59
|
+
"location"
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
await presenter.search("sec");
|
|
63
|
+
const refs = presenter.select([
|
|
64
|
+
"second"
|
|
65
|
+
]);
|
|
66
|
+
expect(refs).toEqual([
|
|
67
|
+
{
|
|
68
|
+
id: "second#0001",
|
|
69
|
+
modelId: "location"
|
|
70
|
+
}
|
|
71
|
+
]);
|
|
72
|
+
expect(presenter.vm.values).toEqual([
|
|
73
|
+
"second"
|
|
74
|
+
]);
|
|
75
|
+
expect(presenter.vm.options).toContainEqual({
|
|
76
|
+
label: "Second",
|
|
77
|
+
value: "second"
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
it("keeps earlier picks when another entry is picked from the search results", async ()=>{
|
|
81
|
+
const container = createContainer();
|
|
82
|
+
container.register(RefMultiAutocompletePresenter_js_RefMultiAutocompletePresenter);
|
|
83
|
+
const presenter = container.resolve(RefMultiAutocompletePresenter);
|
|
84
|
+
await presenter.init({
|
|
85
|
+
modelIds: [
|
|
86
|
+
"location"
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
presenter.select([
|
|
90
|
+
"first"
|
|
91
|
+
]);
|
|
92
|
+
await presenter.search("sec");
|
|
93
|
+
const refs = presenter.select([
|
|
94
|
+
"first",
|
|
95
|
+
"second"
|
|
96
|
+
]);
|
|
97
|
+
expect(refs).toEqual([
|
|
98
|
+
{
|
|
99
|
+
id: "first#0001",
|
|
100
|
+
modelId: "location"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: "second#0001",
|
|
104
|
+
modelId: "location"
|
|
105
|
+
}
|
|
106
|
+
]);
|
|
107
|
+
expect(presenter.vm.values).toEqual([
|
|
108
|
+
"first",
|
|
109
|
+
"second"
|
|
110
|
+
]);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
describe("RefSingleAutocompletePresenter", ()=>{
|
|
114
|
+
it("keeps an entry picked from the search results", async ()=>{
|
|
115
|
+
const container = createContainer();
|
|
116
|
+
container.register(RefSingleAutocompletePresenter_js_RefSingleAutocompletePresenter);
|
|
117
|
+
const presenter = container.resolve(RefSingleAutocompletePresenter);
|
|
118
|
+
await presenter.init({
|
|
119
|
+
modelIds: [
|
|
120
|
+
"location"
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
await presenter.search("sec");
|
|
124
|
+
const ref = presenter.select("second");
|
|
125
|
+
expect(ref).toEqual({
|
|
126
|
+
id: "second#0001",
|
|
127
|
+
modelId: "location"
|
|
128
|
+
});
|
|
129
|
+
expect(presenter.vm.value).toBe("second");
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=RefAutocompletePresenters.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js","sources":["../../../../../src/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { SearchContentEntriesUseCase } from \"~/features/contentEntry/searchContentEntries/abstractions.js\";\nimport { GetContentEntriesUseCase } from \"~/features/contentEntry/getContentEntries/abstractions.js\";\nimport type { CmsReferenceEntry } from \"~/features/contentEntry/refTypes.js\";\nimport { RefMultiAutocompletePresenter as MultiAbstraction } from \"./multi/abstractions.js\";\nimport { RefMultiAutocompletePresenter } from \"./multi/RefMultiAutocompletePresenter.js\";\nimport { RefSingleAutocompletePresenter as SingleAbstraction } from \"./single/abstractions.js\";\nimport { RefSingleAutocompletePresenter } from \"./single/RefSingleAutocompletePresenter.js\";\n\nconst createEntry = (entryId: string, title: string): CmsReferenceEntry => ({\n id: `${entryId}#0001`,\n entryId,\n status: \"draft\",\n title,\n description: null,\n image: null,\n createdOn: \"2026-01-01T00:00:00.000Z\",\n savedOn: \"2026-01-01T00:00:00.000Z\",\n createdBy: { id: \"1\", type: \"admin\", displayName: \"Admin\" },\n modifiedBy: null,\n model: { modelId: \"location\", name: \"Location\" },\n published: null,\n wbyAco_location: null\n});\n\n// The default list holds only the first entry, so the second one can only be found by searching.\nconst defaultEntry = createEntry(\"first\", \"First\");\nconst searchedEntry = createEntry(\"second\", \"Second\");\n\nconst createContainer = () => {\n const container = new Container();\n container.registerInstance(SearchContentEntriesUseCase, {\n execute: async ({ query }) => ({ data: query ? [searchedEntry] : [defaultEntry] })\n });\n container.registerInstance(GetContentEntriesUseCase, {\n execute: async () => ({ latest: [], published: [] })\n });\n return container;\n};\n\ndescribe(\"RefMultiAutocompletePresenter\", () => {\n it(\"keeps an entry picked from the search results\", async () => {\n const container = createContainer();\n container.register(RefMultiAutocompletePresenter);\n const presenter = container.resolve(MultiAbstraction);\n\n await presenter.init({ modelIds: [\"location\"] });\n await presenter.search(\"sec\");\n\n const refs = presenter.select([\"second\"]);\n\n expect(refs).toEqual([{ id: \"second#0001\", modelId: \"location\" }]);\n expect(presenter.vm.values).toEqual([\"second\"]);\n expect(presenter.vm.options).toContainEqual({ label: \"Second\", value: \"second\" });\n });\n\n it(\"keeps earlier picks when another entry is picked from the search results\", async () => {\n const container = createContainer();\n container.register(RefMultiAutocompletePresenter);\n const presenter = container.resolve(MultiAbstraction);\n\n await presenter.init({ modelIds: [\"location\"] });\n presenter.select([\"first\"]);\n await presenter.search(\"sec\");\n\n const refs = presenter.select([\"first\", \"second\"]);\n\n expect(refs).toEqual([\n { id: \"first#0001\", modelId: \"location\" },\n { id: \"second#0001\", modelId: \"location\" }\n ]);\n expect(presenter.vm.values).toEqual([\"first\", \"second\"]);\n });\n});\n\ndescribe(\"RefSingleAutocompletePresenter\", () => {\n it(\"keeps an entry picked from the search results\", async () => {\n const container = createContainer();\n container.register(RefSingleAutocompletePresenter);\n const presenter = container.resolve(SingleAbstraction);\n\n await presenter.init({ modelIds: [\"location\"] });\n await presenter.search(\"sec\");\n\n const ref = presenter.select(\"second\");\n\n expect(ref).toEqual({ id: \"second#0001\", modelId: \"location\" });\n expect(presenter.vm.value).toBe(\"second\");\n });\n});\n"],"names":["createEntry","entryId","title","defaultEntry","searchedEntry","createContainer","container","Container","SearchContentEntriesUseCase","query","GetContentEntriesUseCase","describe","it","RefMultiAutocompletePresenter","presenter","MultiAbstraction","refs","expect","RefSingleAutocompletePresenter","SingleAbstraction","ref"],"mappings":";;;;;;;;AAUA,MAAMA,cAAc,CAACC,SAAiBC,QAAsC;QACxE,IAAI,GAAGD,QAAQ,KAAK,CAAC;QACrBA;QACA,QAAQ;QACRC;QACA,aAAa;QACb,OAAO;QACP,WAAW;QACX,SAAS;QACT,WAAW;YAAE,IAAI;YAAK,MAAM;YAAS,aAAa;QAAQ;QAC1D,YAAY;QACZ,OAAO;YAAE,SAAS;YAAY,MAAM;QAAW;QAC/C,WAAW;QACX,iBAAiB;IACrB;AAGA,MAAMC,eAAeH,YAAY,SAA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Ac,SAAS;YAAW;YACxC;gBAAE,IAAI;gBAAe,SAAS;YAAW;SAC5C;QACDC,OAAOH,UAAU,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;YAAC;YAAS;SAAS;IAC3D;AACJ;AAEAH,SAAS,kCAAkC;IACvCC,GAAG,iDAAiD;QAChD,MAAMN,YAAYD;QAClBC,UAAU,QAAQ,CAACY;QACnB,MAAMJ,YAAYR,UAAU,OAAO,CAACa;QAEpC,MAAML,UAAU,IAAI,CAAC;YAAE,UAAU;gBAAC;aAAW;QAAC;QAC9C,MAAMA,UAAU,MAAM,CAAC;QAEvB,MAAMM,MAAMN,UAAU,MAAM,CAAC;QAE7BG,OAAOG,KAAK,OAAO,CAAC;YAAE,IAAI;YAAe,SAAS;QAAW;QAC7DH,OAAOH,UAAU,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;IACpC;AACJ"}
|
|
@@ -47,9 +47,9 @@ class RefMultiAutocompletePresenterImpl {
|
|
|
47
47
|
await this.base.search(query);
|
|
48
48
|
}
|
|
49
49
|
select(entryIds) {
|
|
50
|
-
this.base.clearSearch();
|
|
51
50
|
const allOptions = this.getAllKnownOptions();
|
|
52
51
|
const selected = entryIds.map((entryId)=>allOptions.find((o)=>o.entryId === entryId)).filter((o)=>null != o);
|
|
52
|
+
this.base.clearSearch();
|
|
53
53
|
this.resolved = selected;
|
|
54
54
|
return selected.map((opt)=>({
|
|
55
55
|
id: opt.id,
|
package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js","sources":["../../../../../../src/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.ts"],"sourcesContent":["import { computed, makeAutoObservable, runInAction } from \"mobx\";\nimport { SearchContentEntriesUseCase } from \"~/features/contentEntry/searchContentEntries/abstractions.js\";\nimport { GetContentEntriesUseCase } from \"~/features/contentEntry/getContentEntries/abstractions.js\";\nimport type { CmsReferenceValue } from \"~/features/contentEntry/refTypes.js\";\nimport type { IRefEntryOption, IDropdownOption } from \"../abstractions.js\";\nimport { BaseAutocompletePresenter } from \"../BaseAutocompletePresenter.js\";\nimport {\n RefMultiAutocompletePresenter as Abstraction,\n type IRefMultiAutocompleteInitConfig,\n type IRefMultiAutocompleteViewModel\n} from \"./abstractions.js\";\n\nclass RefMultiAutocompletePresenterImpl implements Abstraction.Interface {\n private base: BaseAutocompletePresenter;\n private resolved: IRefEntryOption[] = [];\n\n constructor(\n searchUseCase: SearchContentEntriesUseCase.Interface,\n getEntriesUseCase: GetContentEntriesUseCase.Interface\n ) {\n this.base = new BaseAutocompletePresenter(searchUseCase, getEntriesUseCase);\n makeAutoObservable(this, { vm: computed });\n }\n\n get vm(): IRefMultiAutocompleteViewModel {\n const baseOptions = this.base.activeOptions;\n\n const seen = new Set<string>();\n const merged: IDropdownOption[] = [];\n\n for (const opt of this.resolved) {\n if (!seen.has(opt.entryId)) {\n seen.add(opt.entryId);\n merged.push({ label: opt.name, value: opt.entryId });\n }\n }\n\n for (const opt of baseOptions) {\n if (!seen.has(opt.entryId)) {\n seen.add(opt.entryId);\n merged.push({ label: opt.name, value: opt.entryId });\n }\n }\n\n const values = this.resolved.map(v => v.entryId);\n const ready = this.resolved.length > 0;\n\n return {\n loading: this.base.loading,\n options: merged,\n values: ready ? values : [],\n ready\n };\n }\n\n async init(config: IRefMultiAutocompleteInitConfig): Promise<void> {\n this.base.modelIds = config.modelIds;\n await this.base.loadDefaults();\n\n if (config.values && config.values.length > 0) {\n await this.resolve(config.values);\n }\n }\n\n async search(query: string): Promise<void> {\n await this.base.search(query);\n }\n\n select(entryIds: string[]): CmsReferenceValue[] {\n
|
|
1
|
+
{"version":3,"file":"presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js","sources":["../../../../../../src/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.ts"],"sourcesContent":["import { computed, makeAutoObservable, runInAction } from \"mobx\";\nimport { SearchContentEntriesUseCase } from \"~/features/contentEntry/searchContentEntries/abstractions.js\";\nimport { GetContentEntriesUseCase } from \"~/features/contentEntry/getContentEntries/abstractions.js\";\nimport type { CmsReferenceValue } from \"~/features/contentEntry/refTypes.js\";\nimport type { IRefEntryOption, IDropdownOption } from \"../abstractions.js\";\nimport { BaseAutocompletePresenter } from \"../BaseAutocompletePresenter.js\";\nimport {\n RefMultiAutocompletePresenter as Abstraction,\n type IRefMultiAutocompleteInitConfig,\n type IRefMultiAutocompleteViewModel\n} from \"./abstractions.js\";\n\nclass RefMultiAutocompletePresenterImpl implements Abstraction.Interface {\n private base: BaseAutocompletePresenter;\n private resolved: IRefEntryOption[] = [];\n\n constructor(\n searchUseCase: SearchContentEntriesUseCase.Interface,\n getEntriesUseCase: GetContentEntriesUseCase.Interface\n ) {\n this.base = new BaseAutocompletePresenter(searchUseCase, getEntriesUseCase);\n makeAutoObservable(this, { vm: computed });\n }\n\n get vm(): IRefMultiAutocompleteViewModel {\n const baseOptions = this.base.activeOptions;\n\n const seen = new Set<string>();\n const merged: IDropdownOption[] = [];\n\n for (const opt of this.resolved) {\n if (!seen.has(opt.entryId)) {\n seen.add(opt.entryId);\n merged.push({ label: opt.name, value: opt.entryId });\n }\n }\n\n for (const opt of baseOptions) {\n if (!seen.has(opt.entryId)) {\n seen.add(opt.entryId);\n merged.push({ label: opt.name, value: opt.entryId });\n }\n }\n\n const values = this.resolved.map(v => v.entryId);\n const ready = this.resolved.length > 0;\n\n return {\n loading: this.base.loading,\n options: merged,\n values: ready ? values : [],\n ready\n };\n }\n\n async init(config: IRefMultiAutocompleteInitConfig): Promise<void> {\n this.base.modelIds = config.modelIds;\n await this.base.loadDefaults();\n\n if (config.values && config.values.length > 0) {\n await this.resolve(config.values);\n }\n }\n\n async search(query: string): Promise<void> {\n await this.base.search(query);\n }\n\n select(entryIds: string[]): CmsReferenceValue[] {\n // Look the entries up before clearing the search, or one picked from the search results is lost.\n const allOptions = this.getAllKnownOptions();\n const selected = entryIds\n .map(entryId => allOptions.find(o => o.entryId === entryId))\n .filter((o): o is IRefEntryOption => o != null);\n\n this.base.clearSearch();\n this.resolved = selected;\n return selected.map(opt => ({ id: opt.id, modelId: opt.modelId }));\n }\n\n clear(): void {\n this.base.clearSearch();\n this.resolved = [];\n }\n\n dispose(): void {}\n\n private async resolve(values: CmsReferenceValue[]): Promise<void> {\n const options = await this.base.resolveEntries(values);\n runInAction(() => {\n this.resolved = options;\n });\n }\n\n private getAllKnownOptions(): IRefEntryOption[] {\n const seen = new Set<string>();\n const result: IRefEntryOption[] = [];\n\n for (const source of [this.resolved, this.base.searchOptions, this.base.defaultOptions]) {\n for (const opt of source) {\n if (!seen.has(opt.entryId)) {\n seen.add(opt.entryId);\n result.push(opt);\n }\n }\n }\n\n return result;\n }\n}\n\nexport const RefMultiAutocompletePresenter = Abstraction.createImplementation({\n implementation: RefMultiAutocompletePresenterImpl,\n dependencies: [SearchContentEntriesUseCase, GetContentEntriesUseCase]\n});\n"],"names":["RefMultiAutocompletePresenterImpl","searchUseCase","getEntriesUseCase","BaseAutocompletePresenter","makeAutoObservable","computed","baseOptions","seen","Set","merged","opt","values","v","ready","config","query","entryIds","allOptions","selected","entryId","o","options","runInAction","result","source","RefMultiAutocompletePresenter","Abstraction","SearchContentEntriesUseCase","GetContentEntriesUseCase"],"mappings":";;;;;AAYA,MAAMA;IAIF,YACIC,aAAoD,EACpDC,iBAAqD,CACvD;aALM,QAAQ,GAAsB,EAAE;QAMpC,IAAI,CAAC,IAAI,GAAG,IAAIC,0BAA0BF,eAAeC;QACzDE,mBAAmB,IAAI,EAAE;YAAE,IAAIC;QAAS;IAC5C;IAEA,IAAI,KAAqC;QACrC,MAAMC,cAAc,IAAI,CAAC,IAAI,CAAC,aAAa;QAE3C,MAAMC,OAAO,IAAIC;QACjB,MAAMC,SAA4B,EAAE;QAEpC,KAAK,MAAMC,O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QAALA;QAEzC,IAAI,CAAC,IAAI,CAAC,WAAW;QACrB,IAAI,CAAC,QAAQ,GAAGF;QAChB,OAAOA,SAAS,GAAG,CAACR,CAAAA,MAAQ;gBAAE,IAAIA,IAAI,EAAE;gBAAE,SAASA,IAAI,OAAO;YAAC;IACnE;IAEA,QAAc;QACV,IAAI,CAAC,IAAI,CAAC,WAAW;QACrB,IAAI,CAAC,QAAQ,GAAG,EAAE;IACtB;IAEA,UAAgB,CAAC;IAEjB,MAAc,QAAQC,MAA2B,EAAiB;QAC9D,MAAMU,UAAU,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAACV;QAC/CW,YAAY;YACR,IAAI,CAAC,QAAQ,GAAGD;QACpB;IACJ;IAEQ,qBAAwC;QAC5C,MAAMd,OAAO,IAAIC;QACjB,MAAMe,SAA4B,EAAE;QAEpC,KAAK,MAAMC,UAAU;YAAC,IAAI,CAAC,QAAQ;YAAE,IAAI,CAAC,IAAI,CAAC,aAAa;YAAE,IAAI,CAAC,IAAI,CAAC,cAAc;SAAC,CACnF,KAAK,MAAMd,OAAOc,OACd,IAAI,CAACjB,KAAK,GAAG,CAACG,IAAI,OAAO,GAAG;YACxBH,KAAK,GAAG,CAACG,IAAI,OAAO;YACpBa,OAAO,IAAI,CAACb;QAChB;QAIR,OAAOa;IACX;AACJ;AAEO,MAAME,8DAAgCC,8BAAAA,oBAAgC,CAAC;IAC1E,gBAAgB1B;IAChB,cAAc;QAAC2B;QAA6BC;KAAyB;AACzE"}
|
package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js
CHANGED
|
@@ -45,8 +45,8 @@ class RefSingleAutocompletePresenterImpl {
|
|
|
45
45
|
await this.base.search(query);
|
|
46
46
|
}
|
|
47
47
|
select(entryId) {
|
|
48
|
-
this.base.clearSearch();
|
|
49
48
|
const opt = this.findOption(entryId);
|
|
49
|
+
this.base.clearSearch();
|
|
50
50
|
if (!opt) return null;
|
|
51
51
|
this.resolved = opt;
|
|
52
52
|
return {
|
package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js","sources":["../../../../../../src/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.ts"],"sourcesContent":["import { computed, makeAutoObservable, runInAction } from \"mobx\";\nimport { SearchContentEntriesUseCase } from \"~/features/contentEntry/searchContentEntries/abstractions.js\";\nimport { GetContentEntriesUseCase } from \"~/features/contentEntry/getContentEntries/abstractions.js\";\nimport type { CmsReferenceValue } from \"~/features/contentEntry/refTypes.js\";\nimport type { IRefEntryOption, IDropdownOption } from \"../abstractions.js\";\nimport { BaseAutocompletePresenter } from \"../BaseAutocompletePresenter.js\";\nimport {\n RefSingleAutocompletePresenter as Abstraction,\n type IRefSingleAutocompleteInitConfig,\n type IRefSingleAutocompleteViewModel\n} from \"./abstractions.js\";\n\nclass RefSingleAutocompletePresenterImpl implements Abstraction.Interface {\n private base: BaseAutocompletePresenter;\n private resolved: IRefEntryOption | null = null;\n\n constructor(\n searchUseCase: SearchContentEntriesUseCase.Interface,\n getEntriesUseCase: GetContentEntriesUseCase.Interface\n ) {\n this.base = new BaseAutocompletePresenter(searchUseCase, getEntriesUseCase);\n makeAutoObservable(this, { vm: computed });\n }\n\n get vm(): IRefSingleAutocompleteViewModel {\n const baseOptions = this.base.activeOptions;\n\n const seen = new Set<string>();\n const merged: IDropdownOption[] = [];\n\n if (this.resolved) {\n seen.add(this.resolved.entryId);\n merged.push({ label: this.resolved.name, value: this.resolved.entryId });\n }\n\n for (const opt of baseOptions) {\n if (!seen.has(opt.entryId)) {\n seen.add(opt.entryId);\n merged.push({ label: opt.name, value: opt.entryId });\n }\n }\n\n return {\n loading: this.base.loading,\n options: merged,\n value: this.resolved ? this.resolved.entryId : undefined,\n canReset: this.resolved !== null\n };\n }\n\n async init(config: IRefSingleAutocompleteInitConfig): Promise<void> {\n this.base.modelIds = config.modelIds;\n await this.base.loadDefaults();\n\n if (config.value) {\n await this.resolve(config.value);\n }\n }\n\n async search(query: string): Promise<void> {\n await this.base.search(query);\n }\n\n select(entryId: string): CmsReferenceValue | null {\n
|
|
1
|
+
{"version":3,"file":"presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js","sources":["../../../../../../src/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.ts"],"sourcesContent":["import { computed, makeAutoObservable, runInAction } from \"mobx\";\nimport { SearchContentEntriesUseCase } from \"~/features/contentEntry/searchContentEntries/abstractions.js\";\nimport { GetContentEntriesUseCase } from \"~/features/contentEntry/getContentEntries/abstractions.js\";\nimport type { CmsReferenceValue } from \"~/features/contentEntry/refTypes.js\";\nimport type { IRefEntryOption, IDropdownOption } from \"../abstractions.js\";\nimport { BaseAutocompletePresenter } from \"../BaseAutocompletePresenter.js\";\nimport {\n RefSingleAutocompletePresenter as Abstraction,\n type IRefSingleAutocompleteInitConfig,\n type IRefSingleAutocompleteViewModel\n} from \"./abstractions.js\";\n\nclass RefSingleAutocompletePresenterImpl implements Abstraction.Interface {\n private base: BaseAutocompletePresenter;\n private resolved: IRefEntryOption | null = null;\n\n constructor(\n searchUseCase: SearchContentEntriesUseCase.Interface,\n getEntriesUseCase: GetContentEntriesUseCase.Interface\n ) {\n this.base = new BaseAutocompletePresenter(searchUseCase, getEntriesUseCase);\n makeAutoObservable(this, { vm: computed });\n }\n\n get vm(): IRefSingleAutocompleteViewModel {\n const baseOptions = this.base.activeOptions;\n\n const seen = new Set<string>();\n const merged: IDropdownOption[] = [];\n\n if (this.resolved) {\n seen.add(this.resolved.entryId);\n merged.push({ label: this.resolved.name, value: this.resolved.entryId });\n }\n\n for (const opt of baseOptions) {\n if (!seen.has(opt.entryId)) {\n seen.add(opt.entryId);\n merged.push({ label: opt.name, value: opt.entryId });\n }\n }\n\n return {\n loading: this.base.loading,\n options: merged,\n value: this.resolved ? this.resolved.entryId : undefined,\n canReset: this.resolved !== null\n };\n }\n\n async init(config: IRefSingleAutocompleteInitConfig): Promise<void> {\n this.base.modelIds = config.modelIds;\n await this.base.loadDefaults();\n\n if (config.value) {\n await this.resolve(config.value);\n }\n }\n\n async search(query: string): Promise<void> {\n await this.base.search(query);\n }\n\n select(entryId: string): CmsReferenceValue | null {\n // Look the entry up before clearing the search, or one picked from the search results is lost.\n const opt = this.findOption(entryId);\n this.base.clearSearch();\n if (!opt) {\n return null;\n }\n this.resolved = opt;\n return { id: opt.id, modelId: opt.modelId };\n }\n\n clear(): void {\n this.base.clearSearch();\n this.resolved = null;\n }\n\n dispose(): void {}\n\n private async resolve(value: CmsReferenceValue): Promise<void> {\n const options = await this.base.resolveEntries([value]);\n runInAction(() => {\n this.resolved = options[0] ?? null;\n });\n }\n\n private findOption(entryId: string): IRefEntryOption | undefined {\n const sources = [\n this.resolved ? [this.resolved] : [],\n this.base.searchOptions,\n this.base.defaultOptions\n ];\n for (const source of sources) {\n const found = source.find(o => o.entryId === entryId);\n if (found) {\n return found;\n }\n }\n return undefined;\n }\n}\n\nexport const RefSingleAutocompletePresenter = Abstraction.createImplementation({\n implementation: RefSingleAutocompletePresenterImpl,\n dependencies: [SearchContentEntriesUseCase, GetContentEntriesUseCase]\n});\n"],"names":["RefSingleAutocompletePresenterImpl","searchUseCase","getEntriesUseCase","BaseAutocompletePresenter","makeAutoObservable","computed","baseOptions","seen","Set","merged","opt","undefined","config","query","entryId","value","options","runInAction","sources","source","found","o","RefSingleAutocompletePresenter","Abstraction","SearchContentEntriesUseCase","GetContentEntriesUseCase"],"mappings":";;;;;AAYA,MAAMA;IAIF,YACIC,aAAoD,EACpDC,iBAAqD,CACvD;aALM,QAAQ,GAA2B;QAMvC,IAAI,CAAC,IAAI,GAAG,IAAIC,0BAA0BF,eAAeC;QACzDE,mBAAmB,IAAI,EAAE;YAAE,IAAIC;QAAS;IAC5C;IAEA,IAAI,KAAsC;QACtC,MAA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,EAAE;YAAE,SAASA,IAAI,OAAO;QAAC;IAC9C;IAEA,QAAc;QACV,IAAI,CAAC,IAAI,CAAC,WAAW;QACrB,IAAI,CAAC,QAAQ,GAAG;IACpB;IAEA,UAAgB,CAAC;IAEjB,MAAc,QAAQK,KAAwB,EAAiB;QAC3D,MAAMC,UAAU,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;YAACD;SAAM;QACtDE,YAAY;YACR,IAAI,CAAC,QAAQ,GAAGD,OAAO,CAAC,EAAE,IAAI;QAClC;IACJ;IAEQ,WAAWF,OAAe,EAA+B;QAC7D,MAAMI,UAAU;YACZ,IAAI,CAAC,QAAQ,GAAG;gBAAC,IAAI,CAAC,QAAQ;aAAC,GAAG,EAAE;YACpC,IAAI,CAAC,IAAI,CAAC,aAAa;YACvB,IAAI,CAAC,IAAI,CAAC,cAAc;SAC3B;QACD,KAAK,MAAMC,UAAUD,QAAS;YAC1B,MAAME,QAAQD,OAAO,IAAI,CAACE,CAAAA,IAAKA,EAAE,OAAO,KAAKP;YAC7C,IAAIM,OACA,OAAOA;QAEf;IAEJ;AACJ;AAEO,MAAME,gEAAiCC,+BAAAA,oBAAgC,CAAC;IAC3E,gBAAgBvB;IAChB,cAAc;QAACwB;QAA6BC;KAAyB;AACzE"}
|
|
@@ -5,7 +5,7 @@ interface RefFieldOptionsProps {
|
|
|
5
5
|
onNewRecord: (modelId: string) => void;
|
|
6
6
|
onLinkExistingRecord: (modelId: string) => void;
|
|
7
7
|
}
|
|
8
|
-
export declare const RefFieldOptions: (({ models, onNewRecord, onLinkExistingRecord }: RefFieldOptionsProps) => React.JSX.Element) & {
|
|
9
|
-
|
|
8
|
+
export declare const RefFieldOptions: (({ models, onNewRecord, onLinkExistingRecord }: RefFieldOptionsProps) => React.JSX.Element) & React.NamedExoticComponent<RefFieldOptionsProps> & {
|
|
9
|
+
readonly type: ({ models, onNewRecord, onLinkExistingRecord }: RefFieldOptionsProps) => React.JSX.Element;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
|
@@ -11,9 +11,10 @@ const ModelListItem = ({ model, onClick: originalOnClick })=>{
|
|
|
11
11
|
}, [
|
|
12
12
|
originalOnClick
|
|
13
13
|
]);
|
|
14
|
-
const
|
|
14
|
+
const faIcon = normalizeIcon(model.icon);
|
|
15
|
+
const icon = faIcon ? /*#__PURE__*/ react.createElement(Icon, {
|
|
15
16
|
icon: /*#__PURE__*/ react.createElement(FontAwesomeIcon, {
|
|
16
|
-
icon:
|
|
17
|
+
icon: faIcon
|
|
17
18
|
}),
|
|
18
19
|
label: "Model icon",
|
|
19
20
|
size: "lg",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldRenderers/ref/components/RefFieldOptions.js","sources":["../../../../../src/presentation/fieldRenderers/ref/components/RefFieldOptions.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport type { CmsModel } from \"~/types.js\";\nimport { ReactComponent as AddIcon } from \"@webiny/icons/add.svg\";\nimport { ReactComponent as LinkIcon } from \"@webiny/icons/link.svg\";\nimport { Button, DropdownMenu, Text, Icon } from \"@webiny/admin-ui\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport
|
|
1
|
+
{"version":3,"file":"presentation/fieldRenderers/ref/components/RefFieldOptions.js","sources":["../../../../../src/presentation/fieldRenderers/ref/components/RefFieldOptions.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport type { CmsModel } from \"~/types.js\";\nimport { ReactComponent as AddIcon } from \"@webiny/icons/add.svg\";\nimport { ReactComponent as LinkIcon } from \"@webiny/icons/link.svg\";\nimport { Button, DropdownMenu, Text, Icon } from \"@webiny/admin-ui\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport { normalizeIcon } from \"~/utils/normalizeIcon.js\";\nimport { observer } from \"mobx-react-lite\";\n\ninterface ModelListItemProps {\n model: Pick<CmsModel, \"modelId\" | \"name\" | \"description\" | \"icon\">;\n onClick: (modelId: string) => void;\n}\n\nconst ModelListItem = ({ model, onClick: originalOnClick }: ModelListItemProps) => {\n const onClick = useCallback(() => {\n originalOnClick(model.modelId);\n }, [originalOnClick]);\n\n const faIcon = normalizeIcon(model.icon);\n const icon = faIcon ? (\n <Icon\n icon={<FontAwesomeIcon icon={faIcon} />}\n label={\"Model icon\"}\n size={\"lg\"}\n className={\"text-neutral-strong\"}\n />\n ) : undefined;\n\n return (\n <DropdownMenu.Item\n onClick={onClick}\n icon={icon}\n text={\n <div>\n <Text as={\"div\"}>{model.name}</Text>\n <Text as={\"div\"} size={\"sm\"} className={\"text-neutral-strong\"}>\n {model.description}\n </Text>\n </div>\n }\n />\n );\n};\n\ninterface RefFieldOptionsProps {\n models: CmsModel[];\n onNewRecord: (modelId: string) => void;\n onLinkExistingRecord: (modelId: string) => void;\n}\n\nexport const RefFieldOptions = observer(\n ({ models, onNewRecord, onLinkExistingRecord }: RefFieldOptionsProps) => {\n const hasMultipleModels = models.length > 1;\n\n const onSingleNewRecord = useCallback(() => {\n if (models.length === 0 || hasMultipleModels) {\n return;\n }\n onNewRecord(models[0].modelId);\n }, [models]);\n\n const onSingleExistingRecord = useCallback(() => {\n if (models.length === 0 || hasMultipleModels) {\n return;\n }\n onLinkExistingRecord(models[0].modelId);\n }, [models]);\n\n if (hasMultipleModels) {\n return (\n <div className={\"flex flex-wrap gap-sm\"}>\n <DropdownMenu\n trigger={\n <Button\n variant={\"tertiary\"}\n text=\"Create a new record\"\n icon={<AddIcon />}\n />\n }\n >\n {models.map(model => (\n <ModelListItem\n key={model.modelId}\n onClick={onNewRecord}\n model={model}\n />\n ))}\n </DropdownMenu>\n <DropdownMenu\n trigger={\n <Button\n variant={\"tertiary\"}\n text=\"Select an existing record\"\n icon={<LinkIcon />}\n />\n }\n >\n {models.map(model => (\n <ModelListItem\n key={model.modelId}\n onClick={onLinkExistingRecord}\n model={model}\n />\n ))}\n </DropdownMenu>\n </div>\n );\n }\n\n return (\n <div className={\"flex flex-wrap gap-sm\"}>\n <Button\n variant={\"tertiary\"}\n text=\"Create a new record\"\n icon={<AddIcon />}\n onClick={onSingleNewRecord}\n />\n <Button\n variant={\"tertiary\"}\n text=\"Select an existing record\"\n icon={<LinkIcon />}\n onClick={onSingleExistingRecord}\n />\n </div>\n );\n }\n);\n"],"names":["ModelListItem","model","originalOnClick","onClick","useCallback","faIcon","normalizeIcon","icon","Icon","FontAwesomeIcon","undefined","DropdownMenu","Text","RefFieldOptions","observer","models","onNewRecord","onLinkExistingRecord","hasMultipleModels","onSingleNewRecord","onSingleExistingRecord","Button","AddIcon","LinkIcon"],"mappings":";;;;;;;AAcA,MAAMA,gBAAgB,CAAC,EAAEC,KAAK,EAAE,SAASC,eAAe,EAAsB;IAC1E,MAAMC,UAAUC,YAAY;QACxBF,gBAAgBD,MAAM,OAAO;IACjC,GAAG;QAACC;KAAgB;IAEpB,MAAMG,SAASC,cAAcL,MAAM,IAAI;IACvC,MAAMM,OAAOF,SAAS,WAATA,GACT,oBAACG,MAAIA;QACD,oBAAM,oBAACC,iBAAeA;YAAC,MAAMJ;;QAC7B,OAAO;QACP,MAAM;QACN,WAAW;SAEfK;IAEJ,OAAO,WAAP,GACI,oBAACC,aAAa,IAAI;QACd,SAASR;QACT,MAAMI;QACN,oBACI,oBAAC,2BACG,oBAACK,MAAIA;YAAC,IAAI;WAAQX,MAAM,IAAI,iBAC5B,oBAACW,MAAIA;YAAC,IAAI;YAAO,MAAM;YAAM,WAAW;WACnCX,MAAM,WAAW;;AAM1C;AAQO,MAAMY,kBAAkBC,SAC3B,CAAC,EAAEC,MAAM,EAAEC,WAAW,EAAEC,oBAAoB,EAAwB;IAChE,MAAMC,oBAAoBH,OAAO,MAAM,GAAG;IAE1C,MAAMI,oBAAoBf,YAAY;QAClC,IAAIW,AAAkB,MAAlBA,OAAO,MAAM,IAAUG,mBACvB;QAEJF,YAAYD,MAAM,CAAC,EAAE,CAAC,OAAO;IACjC,GAAG;QAACA;KAAO;IAEX,MAAMK,yBAAyBhB,YAAY;QACvC,IAAIW,AAAkB,MAAlBA,OAAO,MAAM,IAAUG,mBACvB;QAEJD,qBAAqBF,MAAM,CAAC,EAAE,CAAC,OAAO;IAC1C,GAAG;QAACA;KAAO;IAEX,IAAIG,mBACA,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACP,cAAYA;QACT,uBACI,oBAACU,QAAMA;YACH,SAAS;YACT,MAAK;YACL,oBAAM,oBAACC,gBAAOA;;OAIrBP,OAAO,GAAG,CAACd,CAAAA,QAAAA,WAAAA,GACR,oBAACD,eAAaA;YACV,KAAKC,MAAM,OAAO;YAClB,SAASe;YACT,OAAOf;4BAInB,oBAACU,cAAYA;QACT,uBACI,oBAACU,QAAMA;YACH,SAAS;YACT,MAAK;YACL,oBAAM,oBAACE,yBAAQA;;OAItBR,OAAO,GAAG,CAACd,CAAAA,QAAAA,WAAAA,GACR,oBAACD,eAAaA;YACV,KAAKC,MAAM,OAAO;YAClB,SAASgB;YACT,OAAOhB;;IAQ/B,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACoB,QAAMA;QACH,SAAS;QACT,MAAK;QACL,oBAAM,oBAACC,gBAAOA;QACd,SAASH;sBAEb,oBAACE,QAAMA;QACH,SAAS;QACT,MAAK;QACL,oBAAM,oBAACE,yBAAQA;QACf,SAASH;;AAIzB"}
|
|
@@ -2,6 +2,6 @@ import React from "react";
|
|
|
2
2
|
export interface ImportContentModelsDialogProps {
|
|
3
3
|
onClose: () => void;
|
|
4
4
|
}
|
|
5
|
-
export declare const ImportContentModelsDialog: ((props: ImportContentModelsDialogProps) => React.JSX.Element) & {
|
|
6
|
-
|
|
5
|
+
export declare const ImportContentModelsDialog: ((props: ImportContentModelsDialogProps) => React.JSX.Element) & React.NamedExoticComponent<ImportContentModelsDialogProps> & {
|
|
6
|
+
readonly type: (props: ImportContentModelsDialogProps) => React.JSX.Element;
|
|
7
7
|
};
|
|
@@ -9,7 +9,7 @@ const createSelected = (params)=>{
|
|
|
9
9
|
for (const id of item.related){
|
|
10
10
|
const model = models.find((model)=>model.id === id);
|
|
11
11
|
if (!model) continue;
|
|
12
|
-
if (selected.has(model.id) || model.imported) continue;
|
|
12
|
+
else if (selected.has(model.id) || model.imported) continue;
|
|
13
13
|
const related = createSelected({
|
|
14
14
|
previous: selected,
|
|
15
15
|
models,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/importContentModels/ImportContentModelsPresenter.js","sources":["../../../src/presentation/importContentModels/ImportContentModelsPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport type { CmsGroup, CmsModel } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport type { ImportGroupData, ImportModelData } from \"./types.js\";\nimport { ImportAction } from \"./types.js\";\nimport type { ImportStructureVariablesGroup, ImportStructureVariablesModel } from \"./graphql.js\";\nimport { ValidateImportUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport { ImportModelsUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport {\n ImportContentModelsPresenter as Abstraction,\n type IImportContentModelsPresenter,\n type IImportContentModelsPresenterViewModel\n} from \"./abstractions.js\";\n\ninterface Data {\n groups: CmsGroup[];\n models: CmsModel[];\n}\n\ntype Selected = Map<string, string[]>;\n\ninterface CreateSelectedParams {\n previous: Selected;\n models: Pick<ImportModelData, \"id\" | \"related\" | \"imported\">[];\n item: Pick<ImportModelData, \"id\" | \"related\">;\n}\n\nconst createSelected = (params: CreateSelectedParams): Selected => {\n const { previous, models, item } = params;\n let selected = new Map(previous);\n\n selected.set(item.id, item.related);\n for (const id of item.related) {\n const model = models.find(model => model.id === id);\n if (!model) {\n continue;\n } else if (selected.has(model.id) || model.imported) {\n continue;\n }\n const related = createSelected({\n previous: selected,\n models,\n item: model\n });\n selected = new Map([...selected, ...related]);\n }\n\n return selected;\n};\n\ninterface DataToImportResult {\n groups: ImportStructureVariablesGroup[];\n models: ImportStructureVariablesModel[];\n}\n\nclass ImportContentModelsPresenterImpl implements IImportContentModelsPresenter {\n private data: Data | null = null;\n private loading = false;\n private groups: ImportGroupData[] = [];\n private models: ImportModelData[] = [];\n private file: File | null = null;\n private errors: string[] = [];\n private validated = false;\n private selected: Selected = new Map();\n\n constructor(\n private validateUseCase: ValidateImportUseCase.Interface,\n private importUseCase: ImportModelsUseCase.Interface\n ) {\n makeAutoObservable<ImportContentModelsPresenterImpl, \"validateUseCase\" | \"importUseCase\">(\n this,\n {\n validateUseCase: false,\n importUseCase: false\n }\n );\n }\n\n get vm(): IImportContentModelsPresenterViewModel {\n return {\n data: this.data,\n loading: this.loading,\n groups: this.groups,\n models: this.models,\n file: this.file,\n errors: this.errors,\n validated: this.validated\n };\n }\n\n hasSelected(): boolean {\n return this.selected.size > 0;\n }\n\n isModelSelected(item: Pick<ImportModelData, \"id\">): boolean {\n return this.selected.has(item.id);\n }\n\n isModelRelated({ id: target }: Pick<ImportModelData, \"id\">): boolean {\n for (const id of this.selected.keys()) {\n if (id === target) {\n continue;\n }\n const related = this.selected.get(id);\n if (related && related.includes(target)) {\n return true;\n }\n }\n return false;\n }\n\n onFile(file: File): void {\n const reader = new FileReader();\n reader.addEventListener(\"load\", event => {\n try {\n const data = this.parseFileContent(event.target?.result);\n runInAction(() => {\n this.models = [];\n this.groups = [];\n this.selected = new Map();\n this.errors = [];\n this.validated = false;\n this.file = file;\n this.data = data;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.file = file;\n this.selected = new Map();\n this.validated = false;\n this.groups = [];\n this.models = [];\n this.data = null;\n this.errors = [ex.message];\n });\n }\n });\n reader.readAsText(file);\n }\n\n onFileError(error: string): void {\n this.file = null;\n this.errors = [error];\n }\n\n toggleModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n this.removeModel(item);\n } else {\n this.addModel(item);\n }\n }\n\n async handleModelsValidation(): Promise<void> {\n if (!this.data) {\n return;\n }\n\n this.loading = true;\n\n try {\n const data = await this.validateUseCase.execute(this.data as any);\n\n runInAction(() => {\n this.loading = false;\n this.groups = data.groups.map(group => ({\n id: group.group.id,\n name: group.group.name,\n slug: group.group.slug,\n error: group.error,\n action: group.action\n }));\n this.models = data.models.map(model => ({\n id: model.model.modelId,\n name: model.model.name,\n group: model.model.group,\n related: model.related || [],\n error: model.error,\n action: model.action\n }));\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n async handleModelsImport(): Promise<void> {\n if (!this.data || !this.groups.length || !this.models.length || !this.selected.size) {\n return;\n }\n\n this.loading = true;\n\n const dataToImport = this.getDataToImport();\n\n try {\n const data = await this.importUseCase.execute(dataToImport);\n\n runInAction(() => {\n this.loading = false;\n this.selected = new Map();\n this.groups = this.groups.map(group => {\n const result = data.groups.find(item => item.group.id === group.id);\n return {\n id: result?.group.id || group.id,\n name: result?.group.name || group.name,\n slug: result?.group.slug || group.slug,\n error: result?.error || group.error,\n imported: result ? result.imported : group.imported\n };\n });\n this.models = this.models.map(model => {\n const result = data.models.find(item => item.model.modelId === model.id);\n return {\n id: result?.model.modelId || model.id,\n name: result?.model.name || model.name,\n group: result?.model.group || model.group,\n related: result?.related || model.related || [],\n action: result?.action || model.action,\n error: result?.error || model.error,\n imported: result ? result.imported : model.imported\n };\n });\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n reset(): void {\n this.data = null;\n this.loading = false;\n this.groups = [];\n this.models = [];\n this.file = null;\n this.errors = [];\n this.validated = false;\n this.selected = new Map();\n }\n\n private addModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n return;\n }\n this.selected = createSelected({\n previous: this.selected,\n models: this.models,\n item\n });\n }\n\n private removeModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelRelated(item)) {\n return;\n }\n const selected = new Map(this.selected);\n selected.delete(item.id);\n this.selected = selected;\n }\n\n private getDataToImport(): DataToImportResult {\n const selected = Array.from(this.selected.keys());\n const groups: Map<string, ImportStructureVariablesGroup> = new Map();\n const models: Map<string, ImportStructureVariablesModel> = new Map();\n const noAction = [ImportAction.CODE, ImportAction.NONE];\n\n for (const id of selected) {\n const validatedModel = this.models.find(model => model.id === id);\n if (\n !validatedModel?.action ||\n validatedModel.error ||\n noAction.includes(validatedModel.action)\n ) {\n continue;\n }\n const validatedGroup = this.groups.find(group => group.slug === validatedModel.group);\n if (!validatedGroup?.action || validatedGroup.error) {\n continue;\n }\n\n const model = this.data?.models?.find(model => model.modelId === id);\n if (!model) {\n continue;\n }\n models.set(id, {\n ...model,\n layout: model.layout || [],\n titleFieldId: model.titleFieldId || \"id\",\n descriptionFieldId: model.descriptionFieldId || \"\",\n imageFieldId: model.imageFieldId || \"\",\n group: validatedModel.group\n });\n\n if (noAction.includes(validatedGroup.action)) {\n continue;\n }\n\n const group = this.data?.groups?.find(group => group.slug === validatedModel.group);\n if (!group) {\n continue;\n }\n groups.set(group.id, group);\n }\n\n return {\n groups: Array.from(groups.values()),\n models: Array.from(models.values())\n };\n }\n\n private parseFileContent(content?: string | ArrayBuffer | null): Data {\n if (!content) {\n throw new Error(\"Missing data in uploaded file.\");\n }\n const raw =\n content instanceof ArrayBuffer ? Buffer.from(content).toString(\"utf8\") : content;\n\n let data: Record<string, any> = {};\n try {\n data = JSON.parse(raw);\n } catch {\n throw new Error(\"Could not parse the uploaded file. Make sure it's a valid JSON file.\");\n }\n if (!data.groups?.length && !data.models?.length) {\n throw new Error(\"No groups and models in the uploaded file.\");\n } else if (data.groups.length === 0) {\n throw new Error(\"No groups in the uploaded file. There must be at least one group.\");\n }\n return {\n groups: data.groups,\n models: data.models\n };\n }\n}\n\nexport const ImportContentModelsPresenter = Abstraction.createImplementation({\n implementation: ImportContentModelsPresenterImpl,\n dependencies: [ValidateImportUseCase, ImportModelsUseCase]\n});\n"],"names":["createSelected","params","previous","models","item","selected","Map","id","model","related","ImportContentModelsPresenterImpl","validateUseCase","importUseCase","makeAutoObservable","target","file","reader","FileReader","event","data","runInAction","ex","error","group","dataToImport","result","Array","groups","noAction","ImportAction","validatedModel","validatedGroup","content","Error","raw","ArrayBuffer","Buffer","JSON","ImportContentModelsPresenter","Abstraction","ValidateImportUseCase","ImportModelsUseCase"],"mappings":";;;;AA0BA,MAAMA,iBAAiB,CAACC;IACpB,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IACnC,IAAII,WAAW,IAAIC,IAAIJ;IAEvBG,SAAS,GAAG,CAACD,KAAK,EAAE,EAAEA,KAAK,OAAO;IAClC,KAAK,MAAMG,MAAMH,KAAK,OAAO,CAAE;QAC3B,MAAMI,QAAQL,OAAO,IAAI,CAACK,CAAAA,QAASA,MAAM,EAAE,KAAKD;QAChD,IAAI,CAACC,OACD;QACG,IAAIH,SAAS,GAAG,CAACG,MAAM,EAAE,KAAKA,MAAM,QAAQ,EAC/C;QAEJ,MAAMC,UAAUT,eAAe;YAC3B,UAAUK;YACVF;YACA,MAAMK;QACV;QACAH,WAAW,IAAIC,IAAI;eAAID;eAAaI;SAAQ;IAChD;IAEA,OAAOJ;AACX;AAOA,MAAMK;IAUF,YACYC,eAAgD,EAChDC,aAA4C,CACtD;aAFUD,eAAe,GAAfA;aACAC,aAAa,GAAbA;aAXJ,IAAI,GAAgB;aACpB,OAAO,GAAG;aACV,MAAM,GAAsB,EAAE;aAC9B,MAAM,GAAsB,EAAE;aAC9B,IAAI,GAAgB;aACpB,MAAM,GAAa,EAAE;aACrB,SAAS,GAAG;aACZ,QAAQ,GAAa,IAAIN;QAM7BO,mBACI,IAAI,EACJ;YACI,iBAAiB;YACjB,eAAe;QACnB;IAER;IAEA,IAAI,KAA6C;QAC7C,OAAO;YACH,MAAM,IAAI,CAAC,IAAI;YACf,SAAS,IAAI,CAAC,OAAO;YACrB,QAAQ,IAAI,CAAC,MAAM;YACnB,QAAQ,IA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mBAAmBG,cAAcC,OAAO,IAAI,CAACJ,SAAS,QAAQ,CAAC,UAAUA;QAE7E,IAAIb,OAA4B,CAAC;QACjC,IAAI;YACAA,OAAOkB,KAAK,KAAK,CAACH;QACtB,EAAE,OAAM;YACJ,MAAM,IAAID,MAAM;QACpB;QACA,IAAI,AAACd,KAAK,MAAM,EAAE,UAAWA,KAAK,MAAM,EAAE,QAEnC;YAAA,IAAIA,AAAuB,MAAvBA,KAAK,MAAM,CAAC,MAAM,EACzB,MAAM,IAAIc,MAAM;QACpB,OAHI,MAAM,IAAIA,MAAM;QAIpB,OAAO;YACH,QAAQd,KAAK,MAAM;YACnB,QAAQA,KAAK,MAAM;QACvB;IACJ;AACJ;AAEO,MAAMmB,4DAA+BC,6BAAAA,oBAAgC,CAAC;IACzE,gBAAgB7B;IAChB,cAAc;QAAC8B;QAAuBC;KAAoB;AAC9D"}
|
|
1
|
+
{"version":3,"file":"presentation/importContentModels/ImportContentModelsPresenter.js","sources":["../../../src/presentation/importContentModels/ImportContentModelsPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport type { CmsGroup, CmsModel } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport type { ImportGroupData, ImportModelData } from \"./types.js\";\nimport { ImportAction } from \"./types.js\";\nimport type { ImportStructureVariablesGroup, ImportStructureVariablesModel } from \"./graphql.js\";\nimport { ValidateImportUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport { ImportModelsUseCase } from \"~/features/model/importModels/abstractions.js\";\nimport {\n ImportContentModelsPresenter as Abstraction,\n type IImportContentModelsPresenter,\n type IImportContentModelsPresenterViewModel\n} from \"./abstractions.js\";\n\ninterface Data {\n groups: CmsGroup[];\n models: CmsModel[];\n}\n\ntype Selected = Map<string, string[]>;\n\ninterface CreateSelectedParams {\n previous: Selected;\n models: Pick<ImportModelData, \"id\" | \"related\" | \"imported\">[];\n item: Pick<ImportModelData, \"id\" | \"related\">;\n}\n\nconst createSelected = (params: CreateSelectedParams): Selected => {\n const { previous, models, item } = params;\n let selected = new Map(previous);\n\n selected.set(item.id, item.related);\n for (const id of item.related) {\n const model = models.find(model => model.id === id);\n if (!model) {\n continue;\n } else if (selected.has(model.id) || model.imported) {\n continue;\n }\n const related = createSelected({\n previous: selected,\n models,\n item: model\n });\n selected = new Map([...selected, ...related]);\n }\n\n return selected;\n};\n\ninterface DataToImportResult {\n groups: ImportStructureVariablesGroup[];\n models: ImportStructureVariablesModel[];\n}\n\nclass ImportContentModelsPresenterImpl implements IImportContentModelsPresenter {\n private data: Data | null = null;\n private loading = false;\n private groups: ImportGroupData[] = [];\n private models: ImportModelData[] = [];\n private file: File | null = null;\n private errors: string[] = [];\n private validated = false;\n private selected: Selected = new Map();\n\n constructor(\n private validateUseCase: ValidateImportUseCase.Interface,\n private importUseCase: ImportModelsUseCase.Interface\n ) {\n makeAutoObservable<ImportContentModelsPresenterImpl, \"validateUseCase\" | \"importUseCase\">(\n this,\n {\n validateUseCase: false,\n importUseCase: false\n }\n );\n }\n\n get vm(): IImportContentModelsPresenterViewModel {\n return {\n data: this.data,\n loading: this.loading,\n groups: this.groups,\n models: this.models,\n file: this.file,\n errors: this.errors,\n validated: this.validated\n };\n }\n\n hasSelected(): boolean {\n return this.selected.size > 0;\n }\n\n isModelSelected(item: Pick<ImportModelData, \"id\">): boolean {\n return this.selected.has(item.id);\n }\n\n isModelRelated({ id: target }: Pick<ImportModelData, \"id\">): boolean {\n for (const id of this.selected.keys()) {\n if (id === target) {\n continue;\n }\n const related = this.selected.get(id);\n if (related && related.includes(target)) {\n return true;\n }\n }\n return false;\n }\n\n onFile(file: File): void {\n const reader = new FileReader();\n reader.addEventListener(\"load\", event => {\n try {\n const data = this.parseFileContent(event.target?.result);\n runInAction(() => {\n this.models = [];\n this.groups = [];\n this.selected = new Map();\n this.errors = [];\n this.validated = false;\n this.file = file;\n this.data = data;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.file = file;\n this.selected = new Map();\n this.validated = false;\n this.groups = [];\n this.models = [];\n this.data = null;\n this.errors = [ex.message];\n });\n }\n });\n reader.readAsText(file);\n }\n\n onFileError(error: string): void {\n this.file = null;\n this.errors = [error];\n }\n\n toggleModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n this.removeModel(item);\n } else {\n this.addModel(item);\n }\n }\n\n async handleModelsValidation(): Promise<void> {\n if (!this.data) {\n return;\n }\n\n this.loading = true;\n\n try {\n const data = await this.validateUseCase.execute(this.data as any);\n\n runInAction(() => {\n this.loading = false;\n this.groups = data.groups.map(group => ({\n id: group.group.id,\n name: group.group.name,\n slug: group.group.slug,\n error: group.error,\n action: group.action\n }));\n this.models = data.models.map(model => ({\n id: model.model.modelId,\n name: model.model.name,\n group: model.model.group,\n related: model.related || [],\n error: model.error,\n action: model.action\n }));\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n async handleModelsImport(): Promise<void> {\n if (!this.data || !this.groups.length || !this.models.length || !this.selected.size) {\n return;\n }\n\n this.loading = true;\n\n const dataToImport = this.getDataToImport();\n\n try {\n const data = await this.importUseCase.execute(dataToImport);\n\n runInAction(() => {\n this.loading = false;\n this.selected = new Map();\n this.groups = this.groups.map(group => {\n const result = data.groups.find(item => item.group.id === group.id);\n return {\n id: result?.group.id || group.id,\n name: result?.group.name || group.name,\n slug: result?.group.slug || group.slug,\n error: result?.error || group.error,\n imported: result ? result.imported : group.imported\n };\n });\n this.models = this.models.map(model => {\n const result = data.models.find(item => item.model.modelId === model.id);\n return {\n id: result?.model.modelId || model.id,\n name: result?.model.name || model.name,\n group: result?.model.group || model.group,\n related: result?.related || model.related || [],\n action: result?.action || model.action,\n error: result?.error || model.error,\n imported: result ? result.imported : model.imported\n };\n });\n this.validated = true;\n });\n } catch (ex: any) {\n runInAction(() => {\n this.loading = false;\n this.errors = [ex.message];\n });\n }\n }\n\n reset(): void {\n this.data = null;\n this.loading = false;\n this.groups = [];\n this.models = [];\n this.file = null;\n this.errors = [];\n this.validated = false;\n this.selected = new Map();\n }\n\n private addModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelSelected(item)) {\n return;\n }\n this.selected = createSelected({\n previous: this.selected,\n models: this.models,\n item\n });\n }\n\n private removeModel(item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">): void {\n if (this.isModelRelated(item)) {\n return;\n }\n const selected = new Map(this.selected);\n selected.delete(item.id);\n this.selected = selected;\n }\n\n private getDataToImport(): DataToImportResult {\n const selected = Array.from(this.selected.keys());\n const groups: Map<string, ImportStructureVariablesGroup> = new Map();\n const models: Map<string, ImportStructureVariablesModel> = new Map();\n const noAction = [ImportAction.CODE, ImportAction.NONE];\n\n for (const id of selected) {\n const validatedModel = this.models.find(model => model.id === id);\n if (\n !validatedModel?.action ||\n validatedModel.error ||\n noAction.includes(validatedModel.action)\n ) {\n continue;\n }\n const validatedGroup = this.groups.find(group => group.slug === validatedModel.group);\n if (!validatedGroup?.action || validatedGroup.error) {\n continue;\n }\n\n const model = this.data?.models?.find(model => model.modelId === id);\n if (!model) {\n continue;\n }\n models.set(id, {\n ...model,\n layout: model.layout || [],\n titleFieldId: model.titleFieldId || \"id\",\n descriptionFieldId: model.descriptionFieldId || \"\",\n imageFieldId: model.imageFieldId || \"\",\n group: validatedModel.group\n });\n\n if (noAction.includes(validatedGroup.action)) {\n continue;\n }\n\n const group = this.data?.groups?.find(group => group.slug === validatedModel.group);\n if (!group) {\n continue;\n }\n groups.set(group.id, group);\n }\n\n return {\n groups: Array.from(groups.values()),\n models: Array.from(models.values())\n };\n }\n\n private parseFileContent(content?: string | ArrayBuffer | null): Data {\n if (!content) {\n throw new Error(\"Missing data in uploaded file.\");\n }\n const raw =\n content instanceof ArrayBuffer ? Buffer.from(content).toString(\"utf8\") : content;\n\n let data: Record<string, any> = {};\n try {\n data = JSON.parse(raw);\n } catch {\n throw new Error(\"Could not parse the uploaded file. Make sure it's a valid JSON file.\");\n }\n if (!data.groups?.length && !data.models?.length) {\n throw new Error(\"No groups and models in the uploaded file.\");\n } else if (data.groups.length === 0) {\n throw new Error(\"No groups in the uploaded file. There must be at least one group.\");\n }\n return {\n groups: data.groups,\n models: data.models\n };\n }\n}\n\nexport const ImportContentModelsPresenter = Abstraction.createImplementation({\n implementation: ImportContentModelsPresenterImpl,\n dependencies: [ValidateImportUseCase, ImportModelsUseCase]\n});\n"],"names":["createSelected","params","previous","models","item","selected","Map","id","model","related","ImportContentModelsPresenterImpl","validateUseCase","importUseCase","makeAutoObservable","target","file","reader","FileReader","event","data","runInAction","ex","error","group","dataToImport","result","Array","groups","noAction","ImportAction","validatedModel","validatedGroup","content","Error","raw","ArrayBuffer","Buffer","JSON","ImportContentModelsPresenter","Abstraction","ValidateImportUseCase","ImportModelsUseCase"],"mappings":";;;;AA0BA,MAAMA,iBAAiB,CAACC;IACpB,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IACnC,IAAII,WAAW,IAAIC,IAAIJ;IAEvBG,SAAS,GAAG,CAACD,KAAK,EAAE,EAAEA,KAAK,OAAO;IAClC,KAAK,MAAMG,MAAMH,KAAK,OAAO,CAAE;QAC3B,MAAMI,QAAQL,OAAO,IAAI,CAACK,CAAAA,QAASA,MAAM,EAAE,KAAKD;QAChD,IAAI,CAACC,OACD;aACG,IAAIH,SAAS,GAAG,CAACG,MAAM,EAAE,KAAKA,MAAM,QAAQ,EAC/C;QAEJ,MAAMC,UAAUT,eAAe;YAC3B,UAAUK;YACVF;YACA,MAAMK;QACV;QACAH,WAAW,IAAIC,IAAI;eAAID;eAAaI;SAAQ;IAChD;IAEA,OAAOJ;AACX;AAOA,MAAMK;IAUF,YACYC,eAAgD,EAChDC,aAA4C,CACtD;aAFUD,eAAe,GAAfA;aACAC,aAAa,GAAbA;aAXJ,IAAI,GAAgB;aACpB,OAAO,GAAG;aACV,MAAM,GAAsB,EAAE;aAC9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A,QAASA,MAAM,IAAI,KAAKO,eAAe,KAAK;YAClF,IAAKP,OAGLI,OAAO,GAAG,CAACJ,MAAM,EAAE,EAAEA;QACzB;QAEA,OAAO;YACH,QAAQG,MAAM,IAAI,CAACC,OAAO,MAAM;YAChC,QAAQD,MAAM,IAAI,CAACvB,OAAO,MAAM;QACpC;IACJ;IAEQ,iBAAiB6B,OAAqC,EAAQ;QAClE,IAAI,CAACA,SACD,MAAM,IAAIC,MAAM;QAEpB,MAAMC,MACFF,mBAAmBG,cAAcC,OAAO,IAAI,CAACJ,SAAS,QAAQ,CAAC,UAAUA;QAE7E,IAAIb,OAA4B,CAAC;QACjC,IAAI;YACAA,OAAOkB,KAAK,KAAK,CAACH;QACtB,EAAE,OAAM;YACJ,MAAM,IAAID,MAAM;QACpB;QACA,IAAI,AAACd,KAAK,MAAM,EAAE,UAAWA,KAAK,MAAM,EAAE,QAEnC;YAAA,IAAIA,AAAuB,MAAvBA,KAAK,MAAM,CAAC,MAAM,EACzB,MAAM,IAAIc,MAAM;QACpB,OAHI,MAAM,IAAIA,MAAM;QAIpB,OAAO;YACH,QAAQd,KAAK,MAAM;YACnB,QAAQA,KAAK,MAAM;QACvB;IACJ;AACJ;AAEO,MAAMmB,4DAA+BC,6BAAAA,oBAAgC,CAAC;IACzE,gBAAgB7B;IAChB,cAAc;QAAC8B;QAAuBC;KAAoB;AAC9D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const DataList: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const DataList: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/importContentModels/components/FileUpload.js","sources":["../../../../src/presentation/importContentModels/components/FileUpload.tsx"],"sourcesContent":["import React from \"react\";\nimport { BrowserFilePicker } from \"@webiny/app-admin/presentation/browserFilePicker/index.js\";\nimport { Text } from \"@webiny/admin-ui\";\nimport { getError } from \"./Errors.js\";\nimport { observer } from \"mobx-react-lite\";\nimport { useImportContentModelsPresenter } from \"../useImportContentModelsPresenter.js\";\n\nexport const FileUpload = observer(() => {\n const presenter = useImportContentModelsPresenter();\n const onFile = (file: File) => presenter.onFile(file);\n const onFileError = (error: string) => presenter.onFileError(error);\n const fileName = presenter.vm.file?.name;\n\n return (\n <BrowserFilePicker\n accept={[\"application/json\"]}\n maxSize={\"
|
|
1
|
+
{"version":3,"file":"presentation/importContentModels/components/FileUpload.js","sources":["../../../../src/presentation/importContentModels/components/FileUpload.tsx"],"sourcesContent":["import React from \"react\";\nimport { BrowserFilePicker } from \"@webiny/app-admin/presentation/browserFilePicker/index.js\";\nimport { Text } from \"@webiny/admin-ui\";\nimport { getError } from \"./Errors.js\";\nimport { observer } from \"mobx-react-lite\";\nimport { useImportContentModelsPresenter } from \"../useImportContentModelsPresenter.js\";\n\nexport const FileUpload = observer(() => {\n const presenter = useImportContentModelsPresenter();\n const onFile = (file: File) => presenter.onFile(file);\n const onFileError = (error: string) => presenter.onFileError(error);\n const fileName = presenter.vm.file?.name;\n\n return (\n <BrowserFilePicker\n accept={[\"application/json\"]}\n maxSize={\"10mb\"}\n onSuccess={files => {\n const file = files.find(f => f.src.file);\n const uploadedFile = file?.src?.file;\n if (!uploadedFile) {\n onFileError(\n \"File is not valid. Please make sure you are uploading a valid JSON file.\"\n );\n return;\n }\n onFile(uploadedFile);\n }}\n onError={err => {\n const errors = err.map(er => {\n return getError(er);\n });\n if (errors.length === 0) {\n return;\n }\n onFileError(errors[0]);\n }}\n multiple={false}\n >\n {({ browseFiles, getDropZoneProps }) => {\n return (\n <>\n <div\n className={\n \"w-full mx-auto my-0 border-sm border-dashed cursor-pointer border-neutral-muted bg-neutral-base text-center p-md \"\n }\n onClick={() => browseFiles()}\n {...getDropZoneProps()}\n >\n <Text>{fileName || \"Drop a file here, or click to select one.\"}</Text>\n </div>\n </>\n );\n }}\n </BrowserFilePicker>\n );\n});\n"],"names":["FileUpload","observer","presenter","useImportContentModelsPresenter","onFile","file","onFileError","error","fileName","BrowserFilePicker","files","f","uploadedFile","err","errors","er","getError","browseFiles","getDropZoneProps","Text"],"mappings":";;;;;;AAOO,MAAMA,aAAaC,SAAS;IAC/B,MAAMC,YAAYC;IAClB,MAAMC,SAAS,CAACC,OAAeH,UAAU,MAAM,CAACG;IAChD,MAAMC,cAAc,CAACC,QAAkBL,UAAU,WAAW,CAACK;IAC7D,MAAMC,WAAWN,UAAU,EAAE,CAAC,IAAI,EAAE;IAEpC,OAAO,WAAP,GACI,oBAACO,mBAAiBA;QACd,QAAQ;YAAC;SAAmB;QAC5B,SAAS;QACT,WAAWC,CAAAA;YACP,MAAML,OAAOK,MAAM,IAAI,CAACC,CAAAA,IAAKA,EAAE,GAAG,CAAC,IAAI;YACvC,MAAMC,eAAeP,MAAM,KAAK;YAChC,IAAI,CAACO,cAAc,YACfN,YACI;YAIRF,OAAOQ;QACX;QACA,SAASC,CAAAA;YACL,MAAMC,SAASD,IAAI,GAAG,CAACE,CAAAA,KACZC,SAASD;YAEpB,IAAID,AAAkB,MAAlBA,OAAO,MAAM,EACb;YAEJR,YAAYQ,MAAM,CAAC,EAAE;QACzB;QACA,UAAU;OAET,CAAC,EAAEG,WAAW,EAAEC,gBAAgB,EAAE,GACxB,WAAP,GACI,wDACI,oBAAC;YACG,WACI;YAEJ,SAAS,IAAMD;YACd,GAAGC,kBAAkB;yBAEtB,oBAACC,MAAIA,MAAEX,YAAY;AAO/C"}
|
|
@@ -72,9 +72,9 @@ const Checkbox = ({ model, toggle, selected })=>{
|
|
|
72
72
|
};
|
|
73
73
|
const Container = ({ model, children })=>{
|
|
74
74
|
if (model.imported) return /*#__PURE__*/ react.createElement(ContainerImported, null, children);
|
|
75
|
-
if ("create" === model.action) return /*#__PURE__*/ react.createElement(ContainerCreate, null, children);
|
|
76
|
-
if ("update" === model.action) return /*#__PURE__*/ react.createElement(ContainerUpdate, null, children);
|
|
77
|
-
if (model.error) return /*#__PURE__*/ react.createElement(ContainerError, null, children);
|
|
75
|
+
else if ("create" === model.action) return /*#__PURE__*/ react.createElement(ContainerCreate, null, children);
|
|
76
|
+
else if ("update" === model.action) return /*#__PURE__*/ react.createElement(ContainerUpdate, null, children);
|
|
77
|
+
else if (model.error) return /*#__PURE__*/ react.createElement(ContainerError, null, children);
|
|
78
78
|
return /*#__PURE__*/ react.createElement(ContainerBase, null, children);
|
|
79
79
|
};
|
|
80
80
|
const DataListModelItem = ({ model, toggle, selected })=>/*#__PURE__*/ react.createElement(Container, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItem.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItem.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\nimport { DataListModelItemError } from \"./DataListModelItemError.js\";\nimport { DataListModelItemInfo } from \"./DataListModelItemInfo.js\";\n\ntype ToggleModelCb = (item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">) => void;\n\nconst ContainerBase = styled(\"div\")(() => {\n return {\n width: \"100%\",\n padding: \"0px 5px 15px 5px\",\n margin: \"0\",\n boxSizing: \"border-box\" as const,\n \"&:last-child\": {\n paddingBottom: \"2px\"\n }\n };\n});\nconst ContainerCreate = styled(ContainerBase)(() => {\n return {\n // backgroundColor: \"var(--mdc-theme-secondary)\"\n };\n});\nconst ContainerImported = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerUpdate = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerError = styled(ContainerBase)(() => {\n return {};\n});\n\nconst ModelContainer = styled(\"div\")({\n display: \"flex\",\n width: \"100%\",\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"space-between\"\n});\nconst Name = styled(\"h4\")({\n fontSize: \"12px\",\n flex: \"1 0 auto\",\n lineHeight: \"18px\"\n});\nconst CheckboxContainer = styled(\"div\")({\n width: \"120px\",\n textAlign: \"right\",\n verticalAlign: \"middle\"\n});\n\nconst Button = styled(\"button\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n cursor: \"pointer\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-background)\",\n \"&.selected\": {\n border: \"1px solid var(--mdc-theme-secondary)\"\n }\n});\n\nconst ImportedText = styled(\"div\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-secondary)\",\n color: \"#FFF\"\n});\n\nconst Imported = () => {\n return (\n <CheckboxContainer>\n <ImportedText>Imported.</ImportedText>\n </CheckboxContainer>\n );\n};\n\ninterface CheckboxProps {\n model: Pick<ImportModelData, \"id\" | \"name\" | \"error\" | \"related\">;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nconst Checkbox = ({ model, toggle, selected }: CheckboxProps) => {\n const onClick = useCallback(() => {\n toggle(model);\n }, [toggle]);\n if (model.error) {\n return null;\n }\n return (\n <CheckboxContainer>\n <Button onClick={onClick} className={selected ? \"selected\" : \"\"}>\n {selected ? \"Model will be imported\" : \"Model will be skipped\"}\n </Button>\n </CheckboxContainer>\n );\n};\n\ninterface ContainerProps {\n model: Pick<ImportModelData, \"action\" | \"error\" | \"imported\">;\n children: React.ReactNode;\n}\n\nconst Container = ({ model, children }: ContainerProps) => {\n if (model.imported) {\n return <ContainerImported>{children}</ContainerImported>;\n } else if (model.action === \"create\") {\n return <ContainerCreate>{children}</ContainerCreate>;\n } else if (model.action === \"update\") {\n return <ContainerUpdate>{children}</ContainerUpdate>;\n } else if (model.error) {\n return <ContainerError>{children}</ContainerError>;\n }\n return <ContainerBase>{children}</ContainerBase>;\n};\n\ninterface DataListModelItemProps {\n model: ImportModelData;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nexport const DataListModelItem = ({ model, toggle, selected }: DataListModelItemProps) => {\n return (\n <Container model={model}>\n <ModelContainer>\n <div>\n <Name>{model.name || model.id}</Name>\n {model.error ? (\n <DataListModelItemError error={model.error} />\n ) : (\n <DataListModelItemInfo model={model} />\n )}\n </div>\n {model.imported ? (\n <Imported />\n ) : (\n <Checkbox model={model} toggle={toggle} selected={selected} />\n )}\n </ModelContainer>\n </Container>\n );\n};\n"],"names":["ContainerBase","styled","ContainerCreate","ContainerImported","ContainerUpdate","ContainerError","ModelContainer","Name","CheckboxContainer","Button","ImportedText","Imported","Checkbox","model","toggle","selected","onClick","useCallback","Container","children","DataListModelItem","DataListModelItemError","DataListModelItemInfo"],"mappings":";;;;AAQA,MAAMA,gBAAgBC,OAAO,OAAO,IACzB;QACH,OAAO;QACP,SAAS;QACT,QAAQ;QACR,WAAW;QACX,gBAAgB;YACZ,eAAe;QACnB;IACJ;AAEJ,MAAMC,kBAAkBD,OAAOD,eAAe,IACnC,EAEP;AAEJ,MAAMG,oBAAoBF,OAAOD,eAAe,IACrC,EAAC;AAEZ,MAAMI,kBAAkBH,OAAOD,eAAe,IACnC,EAAC;AAEZ,MAAMK,iBAAiBJ,OAAOD,eAAe,IAClC,EAAC;AAGZ,MAAMM,iBAAiBL,OAAO,OAAO;IACjC,SAAS;IACT,OAAO;IACP,eAAe;IACf,YAAY;IACZ,gBAAgB;AACpB;AACA,MAAMM,OAAON,OAAO,MAAM;IACtB,UAAU;IACV,MAAM;IACN,YAAY;AAChB;AACA,MAAMO,oBAAoBP,OAAO,OAAO;IACpC,OAAO;IACP,WAAW;IACX,eAAe;AACnB;AAEA,MAAMQ,SAASR,OAAO,UAAU;IAC5B,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,iBAAiB;IACjB,cAAc;QACV,QAAQ;IACZ;AACJ;AAEA,MAAMS,eAAeT,OAAO,OAAO;IAC/B,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,SAAS;IACT,iBAAiB;IACjB,OAAO;AACX;AAEA,MAAMU,WAAW,IACN,WAAP,GACI,oBAACH,mBAAiBA,MAAAA,WAAAA,GACd,oBAACE,cAAYA,MAAC;AAW1B,MAAME,WAAW,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAiB;IACxD,MAAMC,UAAUC,YAAY;QACxBH,OAAOD;IACX,GAAG;QAACC;KAAO;IACX,IAAID,MAAM,KAAK,EACX,OAAO;IAEX,OAAO,WAAP,GACI,oBAACL,mBAAiBA,MAAAA,WAAAA,GACd,oBAACC,QAAMA;QAAC,SAASO;QAAS,WAAWD,WAAW,aAAa;OACxDA,WAAW,2BAA2B;AAIvD;AAOA,MAAMG,YAAY,CAAC,EAAEL,KAAK,EAAEM,QAAQ,EAAkB;IAClD,IAAIN,MAAM,QAAQ,EACd,OAAO,WAAP,GAAO,oBAACV,mBAAiBA,MAAEgB;
|
|
1
|
+
{"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItem.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItem.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\nimport { DataListModelItemError } from \"./DataListModelItemError.js\";\nimport { DataListModelItemInfo } from \"./DataListModelItemInfo.js\";\n\ntype ToggleModelCb = (item: Pick<ImportModelData, \"id\" | \"name\" | \"related\">) => void;\n\nconst ContainerBase = styled(\"div\")(() => {\n return {\n width: \"100%\",\n padding: \"0px 5px 15px 5px\",\n margin: \"0\",\n boxSizing: \"border-box\" as const,\n \"&:last-child\": {\n paddingBottom: \"2px\"\n }\n };\n});\nconst ContainerCreate = styled(ContainerBase)(() => {\n return {\n // backgroundColor: \"var(--mdc-theme-secondary)\"\n };\n});\nconst ContainerImported = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerUpdate = styled(ContainerBase)(() => {\n return {};\n});\nconst ContainerError = styled(ContainerBase)(() => {\n return {};\n});\n\nconst ModelContainer = styled(\"div\")({\n display: \"flex\",\n width: \"100%\",\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"space-between\"\n});\nconst Name = styled(\"h4\")({\n fontSize: \"12px\",\n flex: \"1 0 auto\",\n lineHeight: \"18px\"\n});\nconst CheckboxContainer = styled(\"div\")({\n width: \"120px\",\n textAlign: \"right\",\n verticalAlign: \"middle\"\n});\n\nconst Button = styled(\"button\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n cursor: \"pointer\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-background)\",\n \"&.selected\": {\n border: \"1px solid var(--mdc-theme-secondary)\"\n }\n});\n\nconst ImportedText = styled(\"div\")({\n padding: \"1px 5px\",\n textAlign: \"right\",\n display: \"inline-block\",\n border: \"1px solid var(--mdc-theme-on-background)\",\n fontSize: \"10px\",\n lineHeight: \"12px\",\n outline: \"0 none\",\n backgroundColor: \"var(--mdc-theme-secondary)\",\n color: \"#FFF\"\n});\n\nconst Imported = () => {\n return (\n <CheckboxContainer>\n <ImportedText>Imported.</ImportedText>\n </CheckboxContainer>\n );\n};\n\ninterface CheckboxProps {\n model: Pick<ImportModelData, \"id\" | \"name\" | \"error\" | \"related\">;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nconst Checkbox = ({ model, toggle, selected }: CheckboxProps) => {\n const onClick = useCallback(() => {\n toggle(model);\n }, [toggle]);\n if (model.error) {\n return null;\n }\n return (\n <CheckboxContainer>\n <Button onClick={onClick} className={selected ? \"selected\" : \"\"}>\n {selected ? \"Model will be imported\" : \"Model will be skipped\"}\n </Button>\n </CheckboxContainer>\n );\n};\n\ninterface ContainerProps {\n model: Pick<ImportModelData, \"action\" | \"error\" | \"imported\">;\n children: React.ReactNode;\n}\n\nconst Container = ({ model, children }: ContainerProps) => {\n if (model.imported) {\n return <ContainerImported>{children}</ContainerImported>;\n } else if (model.action === \"create\") {\n return <ContainerCreate>{children}</ContainerCreate>;\n } else if (model.action === \"update\") {\n return <ContainerUpdate>{children}</ContainerUpdate>;\n } else if (model.error) {\n return <ContainerError>{children}</ContainerError>;\n }\n return <ContainerBase>{children}</ContainerBase>;\n};\n\ninterface DataListModelItemProps {\n model: ImportModelData;\n toggle: ToggleModelCb;\n selected: boolean;\n}\n\nexport const DataListModelItem = ({ model, toggle, selected }: DataListModelItemProps) => {\n return (\n <Container model={model}>\n <ModelContainer>\n <div>\n <Name>{model.name || model.id}</Name>\n {model.error ? (\n <DataListModelItemError error={model.error} />\n ) : (\n <DataListModelItemInfo model={model} />\n )}\n </div>\n {model.imported ? (\n <Imported />\n ) : (\n <Checkbox model={model} toggle={toggle} selected={selected} />\n )}\n </ModelContainer>\n </Container>\n );\n};\n"],"names":["ContainerBase","styled","ContainerCreate","ContainerImported","ContainerUpdate","ContainerError","ModelContainer","Name","CheckboxContainer","Button","ImportedText","Imported","Checkbox","model","toggle","selected","onClick","useCallback","Container","children","DataListModelItem","DataListModelItemError","DataListModelItemInfo"],"mappings":";;;;AAQA,MAAMA,gBAAgBC,OAAO,OAAO,IACzB;QACH,OAAO;QACP,SAAS;QACT,QAAQ;QACR,WAAW;QACX,gBAAgB;YACZ,eAAe;QACnB;IACJ;AAEJ,MAAMC,kBAAkBD,OAAOD,eAAe,IACnC,EAEP;AAEJ,MAAMG,oBAAoBF,OAAOD,eAAe,IACrC,EAAC;AAEZ,MAAMI,kBAAkBH,OAAOD,eAAe,IACnC,EAAC;AAEZ,MAAMK,iBAAiBJ,OAAOD,eAAe,IAClC,EAAC;AAGZ,MAAMM,iBAAiBL,OAAO,OAAO;IACjC,SAA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tB,IAAIN,MAAM,KAAK,EAClB,OAAO,WAAP,GAAO,oBAACR,gBAAcA,MAAEc;IAE5B,OAAO,WAAP,GAAO,oBAACnB,eAAaA,MAAEmB;AAC3B;AAQO,MAAMC,oBAAoB,CAAC,EAAEP,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAA0B,GAC1E,WAAP,GACI,oBAACG,WAASA;QAAC,OAAOL;qBACd,oBAACP,gBAAcA,MAAAA,WAAAA,GACX,oBAAC,2BACG,oBAACC,MAAIA,MAAEM,MAAM,IAAI,IAAIA,MAAM,EAAE,GAC5BA,MAAM,KAAK,GAAG,WAAH,GACR,oBAACQ,wBAAsBA;QAAC,OAAOR,MAAM,KAAK;uBAE1C,oBAACS,uBAAqBA;QAAC,OAAOT;SAGrCA,MAAM,QAAQ,GAAG,WAAH,GACX,oBAACF,UAAQA,QAAAA,WAAAA,GAET,oBAACC,UAAQA;QAAC,OAAOC;QAAO,QAAQC;QAAQ,UAAUC"}
|
|
@@ -9,8 +9,8 @@ const Text = styled("p")({
|
|
|
9
9
|
});
|
|
10
10
|
const getText = (action)=>{
|
|
11
11
|
if ("create" === action) return "Model will be created.";
|
|
12
|
-
if ("update" === action) return "Model will be updated.";
|
|
13
|
-
if ("code" === action) return "Model cannot be updated because it was created via code.";
|
|
12
|
+
else if ("update" === action) return "Model will be updated.";
|
|
13
|
+
else if ("code" === action) return "Model cannot be updated because it was created via code.";
|
|
14
14
|
return `Unknown action: ${action}`;
|
|
15
15
|
};
|
|
16
16
|
const DataListModelItemInfo = ({ model })=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItemInfo.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItemInfo.tsx"],"sourcesContent":["import React from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\n\nconst Text = styled(\"p\")({\n fontSize: \"9px\",\n lineHeight: \"10px\",\n display: \"block\",\n padding: \"0\",\n margin: \"0\"\n});\n\nconst getText = (action?: string | null) => {\n if (action === \"create\") {\n return `Model will be created.`;\n } else if (action === \"update\") {\n return `Model will be updated.`;\n } else if (action === \"code\") {\n return \"Model cannot be updated because it was created via code.\";\n }\n return `Unknown action: ${action}`;\n};\n\ninterface DataListModelItemInfoProps {\n model: ImportModelData;\n}\n\nexport const DataListModelItemInfo = ({ model }: DataListModelItemInfoProps) => {\n const { action } = model;\n\n return <Text>{getText(action)}</Text>;\n};\n"],"names":["Text","styled","getText","action","DataListModelItemInfo","model"],"mappings":";;AAIA,MAAMA,OAAOC,OAAO,KAAK;IACrB,UAAU;IACV,YAAY;IACZ,SAAS;IACT,SAAS;IACT,QAAQ;AACZ;AAEA,MAAMC,UAAU,CAACC;IACb,IAAIA,AAAW,aAAXA,QACA,OAAO;
|
|
1
|
+
{"version":3,"file":"presentation/importContentModels/components/Model/DataListModelItemInfo.js","sources":["../../../../../src/presentation/importContentModels/components/Model/DataListModelItemInfo.tsx"],"sourcesContent":["import React from \"react\";\nimport styled from \"@emotion/styled\";\nimport type { ImportModelData } from \"../../types.js\";\n\nconst Text = styled(\"p\")({\n fontSize: \"9px\",\n lineHeight: \"10px\",\n display: \"block\",\n padding: \"0\",\n margin: \"0\"\n});\n\nconst getText = (action?: string | null) => {\n if (action === \"create\") {\n return `Model will be created.`;\n } else if (action === \"update\") {\n return `Model will be updated.`;\n } else if (action === \"code\") {\n return \"Model cannot be updated because it was created via code.\";\n }\n return `Unknown action: ${action}`;\n};\n\ninterface DataListModelItemInfoProps {\n model: ImportModelData;\n}\n\nexport const DataListModelItemInfo = ({ model }: DataListModelItemInfoProps) => {\n const { action } = model;\n\n return <Text>{getText(action)}</Text>;\n};\n"],"names":["Text","styled","getText","action","DataListModelItemInfo","model"],"mappings":";;AAIA,MAAMA,OAAOC,OAAO,KAAK;IACrB,UAAU;IACV,YAAY;IACZ,SAAS;IACT,SAAS;IACT,QAAQ;AACZ;AAEA,MAAMC,UAAU,CAACC;IACb,IAAIA,AAAW,aAAXA,QACA,OAAO;SACJ,IAAIA,AAAW,aAAXA,QACP,OAAO;SACJ,IAAIA,AAAW,WAAXA,QACP,OAAO;IAEX,OAAO,CAAC,gBAAgB,EAAEA,QAAQ;AACtC;AAMO,MAAMC,wBAAwB,CAAC,EAAEC,KAAK,EAA8B;IACvE,MAAM,EAAEF,MAAM,EAAE,GAAGE;IAEnB,OAAO,WAAP,GAAO,oBAACL,MAAIA,MAAEE,QAAQC;AAC1B"}
|
|
@@ -3,7 +3,7 @@ import type { ImportModelData } from "../../types.js";
|
|
|
3
3
|
interface DataListModelsProps {
|
|
4
4
|
models: ImportModelData[];
|
|
5
5
|
}
|
|
6
|
-
export declare const DataListModels: (({ models }: DataListModelsProps) => React.JSX.Element) & {
|
|
7
|
-
|
|
6
|
+
export declare const DataListModels: (({ models }: DataListModelsProps) => React.JSX.Element) & React.NamedExoticComponent<DataListModelsProps> & {
|
|
7
|
+
readonly type: ({ models }: DataListModelsProps) => React.JSX.Element;
|
|
8
8
|
};
|
|
9
9
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const ContentGroupsMenuItems: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const ContentGroupsMenuItems: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|