@firecms/collection_editor 3.0.0-canary.38 → 3.0.0-canary.39
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/index.es.js +759 -748
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/ui/EditorCollectionActionStart.d.ts +2 -0
- package/package.json +6 -6
- package/src/ui/EditorCollectionAction.tsx +0 -51
- package/src/ui/EditorCollectionActionStart.tsx +87 -0
- package/src/useCollectionEditorPlugin.tsx +2 -0
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/collection_editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.39",
|
|
5
5
|
"main": "./dist/index.umd.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"source": "src/index.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@firecms/data_import_export": "^3.0.0-canary.
|
|
11
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
12
|
-
"@firecms/schema_inference": "^3.0.0-canary.
|
|
13
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
10
|
+
"@firecms/data_import_export": "^3.0.0-canary.39",
|
|
11
|
+
"@firecms/formex": "^3.0.0-canary.39",
|
|
12
|
+
"@firecms/schema_inference": "^3.0.0-canary.39",
|
|
13
|
+
"@firecms/ui": "^3.0.0-canary.39",
|
|
14
14
|
"json5": "^2.2.3",
|
|
15
15
|
"prism-react-renderer": "^2.3.1"
|
|
16
16
|
},
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "8ed816e32d8f66d2bf0dffcbfceb569b48a3cc0d"
|
|
85
85
|
}
|
|
@@ -23,8 +23,6 @@ export function EditorCollectionAction({
|
|
|
23
23
|
const authController = useAuthController();
|
|
24
24
|
const navigationController = useNavigationController();
|
|
25
25
|
const collectionEditorController = useCollectionEditorController();
|
|
26
|
-
const configController = useCollectionsConfigController();
|
|
27
|
-
const snackbarController = useSnackbarController();
|
|
28
26
|
|
|
29
27
|
const parentCollection = navigationController.getCollectionFromIds(parentCollectionIds);
|
|
30
28
|
|
|
@@ -35,54 +33,6 @@ export function EditorCollectionAction({
|
|
|
35
33
|
}).editCollections
|
|
36
34
|
: true;
|
|
37
35
|
|
|
38
|
-
let saveDefaultFilterButton = null;
|
|
39
|
-
if (!equal(getObjectOrNull(tableController.filterValues), getObjectOrNull(collection.initialFilter)) ||
|
|
40
|
-
!equal(getObjectOrNull(tableController.sortBy), getObjectOrNull(collection.initialSort))) {
|
|
41
|
-
saveDefaultFilterButton = <>
|
|
42
|
-
{(collection.initialFilter || collection.initialSort) && <Tooltip
|
|
43
|
-
title={"Reset to default filter and sort"}>
|
|
44
|
-
<Button
|
|
45
|
-
color={"primary"}
|
|
46
|
-
size={"small"}
|
|
47
|
-
variant={"text"}
|
|
48
|
-
onClick={() => {
|
|
49
|
-
tableController.clearFilter?.();
|
|
50
|
-
if (collection?.initialFilter)
|
|
51
|
-
tableController.setFilterValues?.(collection?.initialFilter);
|
|
52
|
-
if (collection?.initialSort)
|
|
53
|
-
tableController.setSortBy?.(collection?.initialSort);
|
|
54
|
-
}}>
|
|
55
|
-
<UndoIcon/>
|
|
56
|
-
</Button>
|
|
57
|
-
</Tooltip>}
|
|
58
|
-
|
|
59
|
-
<Tooltip
|
|
60
|
-
title={tableController.sortBy || tableController.filterValues ? "Save default filter and sort" : "Clear default filter and sort"}>
|
|
61
|
-
<Button
|
|
62
|
-
color={"primary"}
|
|
63
|
-
size={"small"}
|
|
64
|
-
variant={"outlined"}
|
|
65
|
-
onClick={() => configController
|
|
66
|
-
?.saveCollection({
|
|
67
|
-
id: collection.id,
|
|
68
|
-
parentCollectionIds,
|
|
69
|
-
collectionData: mergeDeep(collection as PersistedCollection,
|
|
70
|
-
{
|
|
71
|
-
initialFilter: tableController.filterValues ?? null,
|
|
72
|
-
initialSort: tableController.sortBy ?? null
|
|
73
|
-
})
|
|
74
|
-
}).then(() => {
|
|
75
|
-
snackbarController.open({
|
|
76
|
-
type: "success",
|
|
77
|
-
message: "Default config saved"
|
|
78
|
-
});
|
|
79
|
-
})}>
|
|
80
|
-
<SaveIcon/>
|
|
81
|
-
</Button>
|
|
82
|
-
</Tooltip>
|
|
83
|
-
</>;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
36
|
const editorButton = <Tooltip
|
|
87
37
|
title={canEditCollection ? "Edit collection" : "You don't have permissions to edit this collection"}>
|
|
88
38
|
<IconButton
|
|
@@ -96,7 +46,6 @@ export function EditorCollectionAction({
|
|
|
96
46
|
</Tooltip>;
|
|
97
47
|
|
|
98
48
|
return <>
|
|
99
|
-
{canEditCollection && saveDefaultFilterButton}
|
|
100
49
|
{editorButton}
|
|
101
50
|
</>
|
|
102
51
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import equal from "react-fast-compare"
|
|
2
|
+
|
|
3
|
+
import { CollectionActionsProps, mergeDeep, useAuthController, useSnackbarController } from "@firecms/core";
|
|
4
|
+
import { Button, SaveIcon, Tooltip, UndoIcon, } from "@firecms/ui";
|
|
5
|
+
|
|
6
|
+
import { useCollectionEditorController } from "../useCollectionEditorController";
|
|
7
|
+
import { useCollectionsConfigController } from "../useCollectionsConfigController";
|
|
8
|
+
import { PersistedCollection } from "../types/persisted_collection";
|
|
9
|
+
|
|
10
|
+
export function EditorCollectionActionStart({
|
|
11
|
+
path: fullPath,
|
|
12
|
+
parentCollectionIds,
|
|
13
|
+
collection,
|
|
14
|
+
tableController
|
|
15
|
+
}: CollectionActionsProps) {
|
|
16
|
+
|
|
17
|
+
const authController = useAuthController();
|
|
18
|
+
const collectionEditorController = useCollectionEditorController();
|
|
19
|
+
const configController = useCollectionsConfigController();
|
|
20
|
+
const snackbarController = useSnackbarController();
|
|
21
|
+
|
|
22
|
+
const canEditCollection = collectionEditorController.configPermissions
|
|
23
|
+
? collectionEditorController.configPermissions({
|
|
24
|
+
user: authController.user,
|
|
25
|
+
collection
|
|
26
|
+
}).editCollections
|
|
27
|
+
: true;
|
|
28
|
+
|
|
29
|
+
let saveDefaultFilterButton = null;
|
|
30
|
+
if (!equal(getObjectOrNull(tableController.filterValues), getObjectOrNull(collection.initialFilter)) ||
|
|
31
|
+
!equal(getObjectOrNull(tableController.sortBy), getObjectOrNull(collection.initialSort))) {
|
|
32
|
+
saveDefaultFilterButton = <>
|
|
33
|
+
<Tooltip
|
|
34
|
+
title={tableController.sortBy || tableController.filterValues ? "Save default filter and sort" : "Clear default filter and sort"}>
|
|
35
|
+
<Button
|
|
36
|
+
color={"primary"}
|
|
37
|
+
size={"small"}
|
|
38
|
+
variant={"outlined"}
|
|
39
|
+
onClick={() => configController
|
|
40
|
+
?.saveCollection({
|
|
41
|
+
id: collection.id,
|
|
42
|
+
parentCollectionIds,
|
|
43
|
+
collectionData: mergeDeep(collection as PersistedCollection,
|
|
44
|
+
{
|
|
45
|
+
initialFilter: tableController.filterValues ?? null,
|
|
46
|
+
initialSort: tableController.sortBy ?? null
|
|
47
|
+
})
|
|
48
|
+
}).then(() => {
|
|
49
|
+
snackbarController.open({
|
|
50
|
+
type: "success",
|
|
51
|
+
message: "Default config saved"
|
|
52
|
+
});
|
|
53
|
+
})}>
|
|
54
|
+
<SaveIcon/>
|
|
55
|
+
</Button>
|
|
56
|
+
</Tooltip>
|
|
57
|
+
|
|
58
|
+
{(collection.initialFilter || collection.initialSort) && <Tooltip
|
|
59
|
+
title={"Reset to default filter and sort"}>
|
|
60
|
+
<Button
|
|
61
|
+
color={"primary"}
|
|
62
|
+
size={"small"}
|
|
63
|
+
variant={"text"}
|
|
64
|
+
onClick={() => {
|
|
65
|
+
tableController.clearFilter?.();
|
|
66
|
+
if (collection?.initialFilter)
|
|
67
|
+
tableController.setFilterValues?.(collection?.initialFilter);
|
|
68
|
+
if (collection?.initialSort)
|
|
69
|
+
tableController.setSortBy?.(collection?.initialSort);
|
|
70
|
+
}}>
|
|
71
|
+
<UndoIcon/>
|
|
72
|
+
</Button>
|
|
73
|
+
</Tooltip>}
|
|
74
|
+
</>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return <>
|
|
78
|
+
{canEditCollection && saveDefaultFilterButton}
|
|
79
|
+
</>
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getObjectOrNull(o?: object): object | null {
|
|
84
|
+
if (o && Object.keys(o).length === 0)
|
|
85
|
+
return o
|
|
86
|
+
return o ?? null;
|
|
87
|
+
}
|
|
@@ -14,6 +14,7 @@ import { PropertyAddColumnComponent } from "./ui/PropertyAddColumnComponent";
|
|
|
14
14
|
import { NewCollectionButton } from "./ui/NewCollectionButton";
|
|
15
15
|
import { AddIcon, Button, Typography } from "@firecms/ui";
|
|
16
16
|
import { useCollectionEditorController } from "./useCollectionEditorController";
|
|
17
|
+
import { EditorCollectionActionStart } from "./ui/EditorCollectionActionStart";
|
|
17
18
|
|
|
18
19
|
export interface CollectionConfigControllerProps<EC extends PersistedCollection = PersistedCollection, UserType extends User = User> {
|
|
19
20
|
|
|
@@ -105,6 +106,7 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
|
|
|
105
106
|
AdditionalCards: introMode ? undefined : NewCollectionCard,
|
|
106
107
|
},
|
|
107
108
|
collectionView: {
|
|
109
|
+
CollectionActionsStart: EditorCollectionActionStart,
|
|
108
110
|
CollectionActions: EditorCollectionAction,
|
|
109
111
|
HeaderAction: CollectionViewHeaderAction,
|
|
110
112
|
AddColumnComponent: PropertyAddColumnComponent
|