@firecms/core 3.0.0-beta.14 → 3.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +2 -1
- package/dist/components/HomePage/DefaultHomePage.d.ts +2 -15
- package/dist/components/HomePage/HomePageDnD.d.ts +76 -0
- package/dist/components/HomePage/NavigationCard.d.ts +3 -1
- package/dist/components/HomePage/NavigationCardBinding.d.ts +3 -2
- package/dist/components/HomePage/NavigationGroup.d.ts +7 -1
- package/dist/components/HomePage/RenameGroupDialog.d.ts +9 -0
- package/dist/core/EntityEditView.d.ts +3 -0
- package/dist/core/EntityEditViewFormActions.d.ts +1 -1
- package/dist/core/field_configs.d.ts +1 -1
- package/dist/form/EntityForm.d.ts +2 -1
- package/dist/form/EntityFormActions.d.ts +6 -2
- package/dist/form/field_bindings/ReferenceAsStringFieldBinding.d.ts +9 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/hooks/useBuildNavigationController.d.ts +51 -2
- package/dist/index.es.js +2184 -1052
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2181 -1049
- package/dist/index.umd.js.map +1 -1
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/collections.d.ts +8 -2
- package/dist/types/customization_controller.d.ts +8 -0
- package/dist/types/entity_actions.d.ts +46 -6
- package/dist/types/firecms.d.ts +8 -0
- package/dist/types/navigation.d.ts +21 -5
- package/dist/types/plugins.d.ts +20 -1
- package/dist/types/properties.d.ts +7 -0
- package/dist/types/property_config.d.ts +1 -1
- package/dist/types/side_entity_controller.d.ts +4 -0
- package/dist/util/icons.d.ts +2 -2
- package/dist/util/navigation_from_path.d.ts +4 -0
- package/dist/util/resolutions.d.ts +2 -1
- package/package.json +5 -5
- package/src/components/ConfirmationDialog.tsx +1 -0
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +6 -0
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +25 -3
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +2 -2
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +7 -4
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +3 -2
- package/src/components/FireCMSLogo.tsx +7 -51
- package/src/components/HomePage/DefaultHomePage.tsx +491 -157
- package/src/components/HomePage/FavouritesView.tsx +3 -3
- package/src/components/HomePage/HomePageDnD.tsx +599 -0
- package/src/components/HomePage/NavigationCard.tsx +47 -38
- package/src/components/HomePage/NavigationCardBinding.tsx +10 -6
- package/src/components/HomePage/NavigationGroup.tsx +63 -29
- package/src/components/HomePage/RenameGroupDialog.tsx +117 -0
- package/src/components/UnsavedChangesDialog.tsx +6 -2
- package/src/components/common/default_entity_actions.tsx +25 -9
- package/src/components/common/useDataSourceTableController.tsx +2 -2
- package/src/core/DefaultDrawer.tsx +8 -8
- package/src/core/DrawerNavigationItem.tsx +1 -1
- package/src/core/EntityEditView.tsx +41 -6
- package/src/core/EntityEditViewFormActions.tsx +154 -29
- package/src/core/EntitySidePanel.tsx +5 -2
- package/src/core/FireCMS.tsx +2 -0
- package/src/core/field_configs.tsx +15 -1
- package/src/form/EntityForm.tsx +36 -4
- package/src/form/EntityFormActions.tsx +51 -9
- package/src/form/components/StorageItemPreview.tsx +1 -1
- package/src/form/components/StorageUploadProgress.tsx +3 -3
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +4 -2
- package/src/form/field_bindings/ReferenceAsStringFieldBinding.tsx +135 -0
- package/src/form/field_bindings/RepeatFieldBinding.tsx +0 -1
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +12 -17
- package/src/form/index.tsx +1 -0
- package/src/hooks/useBuildNavigationController.tsx +273 -84
- package/src/internal/useBuildSideEntityController.tsx +7 -4
- package/src/preview/PropertyPreview.tsx +14 -0
- package/src/routes/FireCMSRoute.tsx +3 -3
- package/src/types/analytics.ts +3 -0
- package/src/types/collections.ts +8 -2
- package/src/types/customization_controller.tsx +9 -0
- package/src/types/entity_actions.tsx +57 -6
- package/src/types/firecms.tsx +9 -0
- package/src/types/navigation.ts +28 -6
- package/src/types/plugins.tsx +24 -1
- package/src/types/properties.ts +8 -0
- package/src/types/property_config.tsx +1 -0
- package/src/types/side_entity_controller.tsx +5 -0
- package/src/util/icons.tsx +22 -7
- package/src/util/join_collections.ts +3 -1
- package/src/util/navigation_from_path.ts +15 -5
- package/src/util/navigation_utils.ts +2 -2
- package/src/util/resolutions.ts +13 -1
|
@@ -4,6 +4,7 @@ import { Entity } from "./entities";
|
|
|
4
4
|
import { EntityCollection, SelectionController } from "./collections";
|
|
5
5
|
import { User } from "./user";
|
|
6
6
|
import { SideEntityController } from "./side_entity_controller";
|
|
7
|
+
import { FormContext } from "./fields";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* An entity action is a custom action that can be performed on an entity.
|
|
@@ -17,7 +18,10 @@ export type EntityAction<M extends object = any, USER extends User = User> = {
|
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Key of the action. You only need to provide this if you want to
|
|
20
|
-
* override the default actions
|
|
21
|
+
* override the default actions, or if you are not passing the action
|
|
22
|
+
* directly to the `entityActions` prop of a collection.
|
|
23
|
+
* You can define your actions at the app level, in which case you
|
|
24
|
+
* must provide a key.
|
|
21
25
|
* The default actions are:
|
|
22
26
|
* - edit
|
|
23
27
|
* - delete
|
|
@@ -36,6 +40,12 @@ export type EntityAction<M extends object = any, USER extends User = User> = {
|
|
|
36
40
|
*/
|
|
37
41
|
onClick: (props: EntityActionClickProps<M, USER>) => Promise<void> | void;
|
|
38
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Optional callback in case you want to disable the action
|
|
45
|
+
* @param props
|
|
46
|
+
*/
|
|
47
|
+
isEnabled?: (props: EntityActionClickProps<M, USER>) => boolean;
|
|
48
|
+
|
|
39
49
|
/**
|
|
40
50
|
* Show this action collapsed in the menu of the collection view.
|
|
41
51
|
* Defaults to true
|
|
@@ -51,18 +61,59 @@ export type EntityAction<M extends object = any, USER extends User = User> = {
|
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
export type EntityActionClickProps<M extends object, USER extends User = User> = {
|
|
54
|
-
entity
|
|
64
|
+
entity?: Entity<M>;
|
|
55
65
|
context: FireCMSContext<USER>;
|
|
66
|
+
|
|
56
67
|
fullPath?: string;
|
|
68
|
+
fullIdPath?: string;
|
|
57
69
|
collection?: EntityCollection<M>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Optional form context, present if the action is being called from a form.
|
|
73
|
+
* This allows you to access the form state and methods, including modifying the form values.
|
|
74
|
+
*/
|
|
75
|
+
formContext?: FormContext;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Present if this actions is being called from a side dialog only
|
|
79
|
+
*/
|
|
80
|
+
sideEntityController?: SideEntityController;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Is the action being called from the collection view or from the entity form view?
|
|
84
|
+
*/
|
|
85
|
+
view: "collection" | "form";
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* If the action is rendered in the form, is it open in a side panel or full screen?
|
|
89
|
+
*/
|
|
90
|
+
openEntityMode: "side_panel" | "full_screen";
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Optional selection controller, present if the action is being called from a collection view
|
|
94
|
+
*/
|
|
58
95
|
selectionController?: SelectionController;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Optional highlight function to highlight the entity in the collection view
|
|
99
|
+
* @param entity
|
|
100
|
+
*/
|
|
59
101
|
highlightEntity?: (entity: Entity<any>) => void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Optional unhighlight function to remove the highlight from the entity in the collection view
|
|
105
|
+
* @param entity
|
|
106
|
+
*/
|
|
60
107
|
unhighlightEntity?: (entity: Entity<any>) => void;
|
|
61
|
-
|
|
108
|
+
|
|
62
109
|
/**
|
|
63
|
-
*
|
|
110
|
+
* Optional function to navigate back (e.g. when deleting an entity or navigating from a form)
|
|
64
111
|
*/
|
|
65
|
-
|
|
112
|
+
navigateBack?: () => void;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Callback to be called when the collection changes, e.g. after an entity is deleted or created.
|
|
116
|
+
*/
|
|
117
|
+
onCollectionChange?: () => void;
|
|
66
118
|
|
|
67
|
-
openEntityMode: "side_panel" | "full_screen";
|
|
68
119
|
};
|
package/src/types/firecms.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import { EntityLinkBuilder } from "./entity_link_builder";
|
|
|
12
12
|
import { UserConfigurationPersistence } from "./local_config_persistence";
|
|
13
13
|
import { FireCMSPlugin } from "./plugins";
|
|
14
14
|
import { CMSAnalyticsEvent } from "./analytics";
|
|
15
|
+
import { EntityAction } from "./entity_actions";
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Use this callback to build entity collections dynamically.
|
|
@@ -94,6 +95,14 @@ export type FireCMSProps<USER extends User> = {
|
|
|
94
95
|
*/
|
|
95
96
|
entityViews?: EntityCustomView[];
|
|
96
97
|
|
|
98
|
+
/**
|
|
99
|
+
* List of actions that can be performed on entities.
|
|
100
|
+
* These actions are displayed in the entity view and in the collection view.
|
|
101
|
+
* You can later reuse these actions in the `entityActions` prop of a collection,
|
|
102
|
+
* by specifying the `key` of the action.
|
|
103
|
+
*/
|
|
104
|
+
entityActions?: EntityAction[];
|
|
105
|
+
|
|
97
106
|
/**
|
|
98
107
|
* Format of the dates in the CMS.
|
|
99
108
|
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
package/src/types/navigation.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
|
|
|
36
36
|
* level of the navigation (e.g. in the home page or the navigation
|
|
37
37
|
* drawer)
|
|
38
38
|
*/
|
|
39
|
-
topLevelNavigation?:
|
|
39
|
+
topLevelNavigation?: NavigationResult;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Is the navigation loading (the configuration persistence has not
|
|
@@ -206,7 +206,7 @@ export interface CMSView {
|
|
|
206
206
|
* e.g. 'account_tree' or 'person'
|
|
207
207
|
* Find all the icons in https://firecms.co/docs/icons
|
|
208
208
|
*/
|
|
209
|
-
icon?: string;
|
|
209
|
+
icon?: string | React.ReactNode;
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
212
|
* Should this view be hidden from the main navigation panel.
|
|
@@ -229,7 +229,22 @@ export interface CMSView {
|
|
|
229
229
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Used to group navigation entries in the main navigation.
|
|
234
|
+
*/
|
|
235
|
+
export interface NavigationGroupMapping {
|
|
236
|
+
/**
|
|
237
|
+
* Name of the group, used to display the group header in the UI
|
|
238
|
+
*/
|
|
239
|
+
name: string;
|
|
240
|
+
/**
|
|
241
|
+
* List of collection ids or view paths that belong to this group.
|
|
242
|
+
*/
|
|
243
|
+
entries: string[];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface NavigationEntry {
|
|
247
|
+
id: string;
|
|
233
248
|
url: string;
|
|
234
249
|
name: string;
|
|
235
250
|
path: string;
|
|
@@ -240,7 +255,14 @@ export interface TopNavigationEntry {
|
|
|
240
255
|
group: string;
|
|
241
256
|
}
|
|
242
257
|
|
|
243
|
-
export type
|
|
244
|
-
|
|
245
|
-
|
|
258
|
+
export type NavigationResult = {
|
|
259
|
+
|
|
260
|
+
allowDragAndDrop: boolean;
|
|
261
|
+
|
|
262
|
+
navigationEntries: NavigationEntry[],
|
|
263
|
+
|
|
264
|
+
groups: string[],
|
|
265
|
+
|
|
266
|
+
onNavigationEntriesUpdate: (entries: NavigationGroupMapping[]) => void;
|
|
246
267
|
};
|
|
268
|
+
|
package/src/types/plugins.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import { FieldProps, FormContext } from "./fields";
|
|
|
7
7
|
import { CMSType, Property } from "./properties";
|
|
8
8
|
import { EntityStatus } from "./entities";
|
|
9
9
|
import { ResolvedProperty } from "./resolved_entities";
|
|
10
|
+
import { NavigationGroupMapping } from "./navigation";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Interface used to define plugins for FireCMS.
|
|
@@ -84,6 +85,20 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
84
85
|
children: React.ReactNode;
|
|
85
86
|
}
|
|
86
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Allow reordering with drag and drop of the collections in the home page.
|
|
90
|
+
*/
|
|
91
|
+
allowDragAndDrop?: boolean;
|
|
92
|
+
|
|
93
|
+
navigationEntries?: NavigationGroupMapping[];
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* This method will be called when the entries are updated in the home page.
|
|
97
|
+
* group => navigationEntriesOrder (path)
|
|
98
|
+
* @param entries
|
|
99
|
+
*/
|
|
100
|
+
onNavigationEntriesUpdate?: (entries: NavigationGroupMapping[]) => void;
|
|
101
|
+
|
|
87
102
|
}
|
|
88
103
|
|
|
89
104
|
collectionView?: {
|
|
@@ -151,8 +166,16 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
151
166
|
props?: FORM_PROPS;
|
|
152
167
|
}
|
|
153
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Add custom actions to the default ones ("Save", "Discard"...)
|
|
171
|
+
*/
|
|
154
172
|
Actions?: React.ComponentType<PluginFormActionProps<any, EC>>;
|
|
155
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Add custom actions to the top of the form
|
|
176
|
+
*/
|
|
177
|
+
ActionsTop?: React.ComponentType<PluginFormActionProps<any, EC>>;
|
|
178
|
+
|
|
156
179
|
fieldBuilder?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T, any, EC>) => React.ComponentType<FieldProps<T>> | null;
|
|
157
180
|
|
|
158
181
|
fieldBuilderEnabled?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T>) => boolean;
|
|
@@ -206,12 +229,12 @@ export interface PluginHomePageActionsProps<EP extends object = object, M extend
|
|
|
206
229
|
export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
|
|
207
230
|
entityId?: string;
|
|
208
231
|
path: string;
|
|
232
|
+
parentCollectionIds: string[];
|
|
209
233
|
status: EntityStatus;
|
|
210
234
|
collection: EC;
|
|
211
235
|
disabled: boolean;
|
|
212
236
|
formContext?: FormContext<any>;
|
|
213
237
|
context: FireCMSContext<USER>;
|
|
214
|
-
currentEntityId?: string;
|
|
215
238
|
openEntityMode: "side_panel" | "full_screen";
|
|
216
239
|
}
|
|
217
240
|
|
package/src/types/properties.ts
CHANGED
|
@@ -413,6 +413,14 @@ export interface StringProperty extends BaseProperty<string> {
|
|
|
413
413
|
* Add an icon to clear the value and set it to `null`. Defaults to `false`
|
|
414
414
|
*/
|
|
415
415
|
clearable?: boolean;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* You can use this property (a string) to behave as a reference to another
|
|
419
|
+
* collection. The stored value is the ID of the entity in the
|
|
420
|
+
* collection, and the `path` prop is used to
|
|
421
|
+
* define the collection this reference points to.
|
|
422
|
+
*/
|
|
423
|
+
reference?: ReferenceProperty;
|
|
416
424
|
}
|
|
417
425
|
|
|
418
426
|
/**
|
|
@@ -15,6 +15,11 @@ export interface EntitySidePanelProps<M extends Record<string, any> = any> {
|
|
|
15
15
|
*/
|
|
16
16
|
path: string;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Full CMS path of the entity, including the collection and sub-collections.
|
|
20
|
+
*/
|
|
21
|
+
fullIdPath?: string;
|
|
22
|
+
|
|
18
23
|
/**
|
|
19
24
|
* ID of the entity, if not set, it means we are creating a new entity
|
|
20
25
|
*/
|
package/src/util/icons.tsx
CHANGED
|
@@ -4,13 +4,28 @@ import { coolIconKeys, Icon, IconColor, iconKeys } from "@firecms/ui";
|
|
|
4
4
|
import { slugify } from "./strings";
|
|
5
5
|
import equal from "react-fast-compare"
|
|
6
6
|
|
|
7
|
-
export function getIcon(iconKey?: string
|
|
7
|
+
export function getIcon(iconKey?: string | React.ReactNode,
|
|
8
|
+
className?: string,
|
|
9
|
+
color?: IconColor,
|
|
10
|
+
size?: "smallest" | "small" | "medium" | "large" | number,): React.ReactElement | undefined {
|
|
11
|
+
|
|
12
|
+
if (React.isValidElement(iconKey)) {
|
|
13
|
+
return iconKey;
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
if (!iconKey) return undefined;
|
|
9
|
-
iconKey
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
if (typeof iconKey === "string") {
|
|
18
|
+
|
|
19
|
+
const usedIconKey = slugify(iconKey);
|
|
20
|
+
if (!(usedIconKey in iconKeysMap)) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return usedIconKey in iconKeysMap ?
|
|
24
|
+
<Icon iconKey={usedIconKey} size={size} className={className} color={color}/> : undefined;
|
|
12
25
|
}
|
|
13
|
-
|
|
26
|
+
|
|
27
|
+
console.warn("Invalid icon key provided:", iconKey);
|
|
28
|
+
return undefined;
|
|
14
29
|
}
|
|
15
30
|
|
|
16
31
|
export type IconViewProps = {
|
|
@@ -18,7 +33,7 @@ export type IconViewProps = {
|
|
|
18
33
|
name: string;
|
|
19
34
|
singularName?: string;
|
|
20
35
|
group?: string;
|
|
21
|
-
icon?: string;
|
|
36
|
+
icon?: string | React.ReactNode;
|
|
22
37
|
}
|
|
23
38
|
|
|
24
39
|
export const IconForView = React.memo(
|
|
@@ -34,7 +49,7 @@ export const IconForView = React.memo(
|
|
|
34
49
|
size?: "smallest" | "small" | "medium" | "large" | number,
|
|
35
50
|
}): React.ReactElement {
|
|
36
51
|
if (!collectionOrView) return <></>;
|
|
37
|
-
const icon = getIcon(collectionOrView.icon, className, color);
|
|
52
|
+
const icon = getIcon(collectionOrView.icon, className, color, size);
|
|
38
53
|
if (collectionOrView?.icon && icon)
|
|
39
54
|
return icon;
|
|
40
55
|
|
|
@@ -100,13 +100,15 @@ export function mergeCollection(target: EntityCollection,
|
|
|
100
100
|
const sourcePropertiesOrder = getCollectionKeys(source);
|
|
101
101
|
const mergedPropertiesOrder = [...new Set([...sourcePropertiesOrder, ...targetPropertiesOrder])];
|
|
102
102
|
const mergedEntityViews = [...new Set([...(target.entityViews ?? []), ...(source.entityViews ?? [])])];
|
|
103
|
+
const mergedEntityActions = [...new Set([...(target.entityActions ?? []), ...(source.entityActions ?? [])])];
|
|
103
104
|
|
|
104
105
|
let resultCollection: EntityCollection = {
|
|
105
106
|
...mergedCollection,
|
|
106
107
|
subcollections: subcollectionsMerged,
|
|
107
108
|
properties: sortProperties(propertiesMerged, mergedPropertiesOrder),
|
|
108
109
|
propertiesOrder: mergedPropertiesOrder,
|
|
109
|
-
entityViews: mergedEntityViews
|
|
110
|
+
entityViews: mergedEntityViews,
|
|
111
|
+
entityActions: mergedEntityActions,
|
|
110
112
|
};
|
|
111
113
|
if (modifyCollection) {
|
|
112
114
|
const modifiedCollection = modifyCollection({
|
|
@@ -11,6 +11,7 @@ export interface NavigationViewEntityInternal<M extends Record<string, any>> {
|
|
|
11
11
|
type: "entity";
|
|
12
12
|
entityId: string;
|
|
13
13
|
path: string;
|
|
14
|
+
fullIdPath: string;
|
|
14
15
|
fullPath: string;
|
|
15
16
|
parentCollection: EntityCollection<M>;
|
|
16
17
|
}
|
|
@@ -19,6 +20,7 @@ export interface NavigationViewCollectionInternal<M extends Record<string, any>>
|
|
|
19
20
|
type: "collection";
|
|
20
21
|
id: string;
|
|
21
22
|
path: string;
|
|
23
|
+
fullIdPath: string;
|
|
22
24
|
fullPath: string;
|
|
23
25
|
collection: EntityCollection<M>;
|
|
24
26
|
}
|
|
@@ -26,6 +28,7 @@ export interface NavigationViewCollectionInternal<M extends Record<string, any>>
|
|
|
26
28
|
export interface NavigationViewEntityCustomInternal<M extends Record<string, any>> {
|
|
27
29
|
type: "custom_view";
|
|
28
30
|
path: string;
|
|
31
|
+
fullIdPath: string;
|
|
29
32
|
fullPath: string;
|
|
30
33
|
entityId: string;
|
|
31
34
|
view: EntityCustomView<M>;
|
|
@@ -35,13 +38,15 @@ export function getNavigationEntriesFromPath(props: {
|
|
|
35
38
|
path: string,
|
|
36
39
|
collections: EntityCollection[] | undefined,
|
|
37
40
|
currentFullPath?: string,
|
|
41
|
+
currentFullIdPath?: string,
|
|
38
42
|
contextEntityViews?: EntityCustomView<any>[]
|
|
39
43
|
}): NavigationViewInternal [] {
|
|
40
44
|
|
|
41
45
|
const {
|
|
42
46
|
path,
|
|
43
47
|
collections = [],
|
|
44
|
-
currentFullPath
|
|
48
|
+
currentFullPath,
|
|
49
|
+
currentFullIdPath
|
|
45
50
|
} = props;
|
|
46
51
|
|
|
47
52
|
const subpaths = removeInitialAndTrailingSlashes(path).split("/");
|
|
@@ -58,16 +63,18 @@ export function getNavigationEntriesFromPath(props: {
|
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
if (collection) {
|
|
61
|
-
const pathOrAlias = collection.id ?? collection.path;
|
|
62
66
|
const collectionPath = currentFullPath && currentFullPath.length > 0
|
|
63
|
-
? (currentFullPath + "/" +
|
|
64
|
-
:
|
|
65
|
-
|
|
67
|
+
? (currentFullPath + "/" + collection.path)
|
|
68
|
+
: collection.path;
|
|
69
|
+
const fullIdPath = currentFullIdPath && currentFullIdPath.length > 0
|
|
70
|
+
? (currentFullIdPath + "/" + collection.id)
|
|
71
|
+
: collection.id;
|
|
66
72
|
result.push({
|
|
67
73
|
type: "collection",
|
|
68
74
|
id: collection.id,
|
|
69
75
|
path: collectionPath,
|
|
70
76
|
fullPath: collectionPath,
|
|
77
|
+
fullIdPath,
|
|
71
78
|
collection
|
|
72
79
|
});
|
|
73
80
|
const restOfThePath = removeInitialAndTrailingSlashes(removeInitialAndTrailingSlashes(path).replace(subpathCombination, ""));
|
|
@@ -79,6 +86,7 @@ export function getNavigationEntriesFromPath(props: {
|
|
|
79
86
|
type: "entity",
|
|
80
87
|
entityId,
|
|
81
88
|
path: collectionPath,
|
|
89
|
+
fullIdPath,
|
|
82
90
|
fullPath: fullPath,
|
|
83
91
|
parentCollection: collection
|
|
84
92
|
});
|
|
@@ -97,6 +105,7 @@ export function getNavigationEntriesFromPath(props: {
|
|
|
97
105
|
type: "custom_view",
|
|
98
106
|
path: collectionPath,
|
|
99
107
|
entityId: entityId,
|
|
108
|
+
fullIdPath,
|
|
100
109
|
fullPath: fullPath + "/" + customView.key,
|
|
101
110
|
view: customView
|
|
102
111
|
});
|
|
@@ -105,6 +114,7 @@ export function getNavigationEntriesFromPath(props: {
|
|
|
105
114
|
path: newPath,
|
|
106
115
|
collections: collection.subcollections,
|
|
107
116
|
currentFullPath: fullPath,
|
|
117
|
+
currentFullIdPath: fullIdPath,
|
|
108
118
|
contextEntityViews: props.contextEntityViews
|
|
109
119
|
}));
|
|
110
120
|
}
|
package/src/util/resolutions.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
AuthController,
|
|
4
4
|
CMSType,
|
|
5
5
|
CustomizationController,
|
|
6
|
+
EntityAction,
|
|
6
7
|
EntityCollection,
|
|
7
8
|
EntityCustomView,
|
|
8
9
|
EntityValues,
|
|
@@ -438,6 +439,17 @@ export function resolveEntityView(entityView: string | EntityCustomView<any>, co
|
|
|
438
439
|
}
|
|
439
440
|
}
|
|
440
441
|
|
|
442
|
+
export function resolveEntityAction<M extends Record<string, any>>(
|
|
443
|
+
entityAction: string | EntityAction<M>,
|
|
444
|
+
contextEntityActions?: EntityAction<M>[]
|
|
445
|
+
): EntityAction<M> | undefined {
|
|
446
|
+
if (typeof entityAction === "string") {
|
|
447
|
+
return contextEntityActions?.find((entry) => entry.key === entityAction);
|
|
448
|
+
} else {
|
|
449
|
+
return entityAction;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
441
453
|
export function resolvedSelectedEntityView<M extends Record<string, any>>(
|
|
442
454
|
customViews: (string | EntityCustomView<M>)[] | undefined,
|
|
443
455
|
customizationController: CustomizationController,
|
|
@@ -447,7 +459,7 @@ export function resolvedSelectedEntityView<M extends Record<string, any>>(
|
|
|
447
459
|
const resolvedEntityViews = customViews ? customViews
|
|
448
460
|
.map(e => resolveEntityView(e, customizationController.entityViews))
|
|
449
461
|
.filter((e): e is EntityCustomView<M> => Boolean(e))
|
|
450
|
-
|
|
462
|
+
// .filter((e) => canEdit || !e.includeActions)
|
|
451
463
|
: [];
|
|
452
464
|
|
|
453
465
|
const selectedEntityView = resolvedEntityViews.find(e => e.key === selectedTab);
|