@firecms/collection_editor 3.0.0-canary.178 → 3.0.0-canary.179

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.
@@ -1,5 +1,6 @@
1
+ import React from "react";
1
2
  import { EntityCollection } from "@firecms/core";
2
- export declare function CollectionDetailsForm({ isNewCollection, reservedGroups, existingPaths, existingIds, groups, parentCollection }: {
3
+ export declare function CollectionDetailsForm({ isNewCollection, reservedGroups, existingPaths, existingIds, groups, parentCollection, children }: {
3
4
  isNewCollection: boolean;
4
5
  reservedGroups?: string[];
5
6
  existingPaths?: string[];
@@ -7,4 +8,5 @@ export declare function CollectionDetailsForm({ isNewCollection, reservedGroups,
7
8
  groups: string[] | null;
8
9
  parentCollection?: EntityCollection;
9
10
  parentCollectionIds?: string[];
11
+ children?: React.ReactNode;
10
12
  }): import("react/jsx-runtime").JSX.Element;
@@ -3,4 +3,4 @@ import { PersistedCollection } from "../types/persisted_collection";
3
3
  /**
4
4
  * Function in charge of merging collections defined in code with those stored in the backend.
5
5
  */
6
- export declare const mergeCollections: (baseCollections: EntityCollection[], backendCollections: PersistedCollection[], modifyCollection?: (props: ModifyCollectionProps) => EntityCollection | void) => EntityCollection<any, any>[];
6
+ export declare const mergeCollections: (baseCollections: EntityCollection[], backendCollections?: PersistedCollection[], modifyCollection?: (props: ModifyCollectionProps) => EntityCollection | void) => EntityCollection<any, any>[];
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@firecms/collection_editor",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.178",
4
+ "version": "3.0.0-canary.179",
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_export": "^3.0.0-canary.178",
11
- "@firecms/data_import": "^3.0.0-canary.178",
12
- "@firecms/data_import_export": "^3.0.0-canary.178",
13
- "@firecms/formex": "^3.0.0-canary.178",
14
- "@firecms/schema_inference": "^3.0.0-canary.178",
15
- "@firecms/ui": "^3.0.0-canary.178",
10
+ "@firecms/data_export": "^3.0.0-canary.179",
11
+ "@firecms/data_import": "^3.0.0-canary.179",
12
+ "@firecms/data_import_export": "^3.0.0-canary.179",
13
+ "@firecms/formex": "^3.0.0-canary.179",
14
+ "@firecms/schema_inference": "^3.0.0-canary.179",
15
+ "@firecms/ui": "^3.0.0-canary.179",
16
16
  "@hello-pangea/dnd": "^17.0.0",
17
17
  "json5": "^2.2.3",
18
18
  "prism-react-renderer": "^2.4.1"
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "87cb7b5b305fbcca1223aa8e3a62d6eee0f3570d"
73
+ "gitHead": "39125fe4c1a15167d203baee64f2bbd5376eb766"
74
74
  }
@@ -31,7 +31,8 @@ export function CollectionDetailsForm({
31
31
  existingPaths,
32
32
  existingIds,
33
33
  groups,
34
- parentCollection
34
+ parentCollection,
35
+ children
35
36
  }: {
36
37
  isNewCollection: boolean,
37
38
  reservedGroups?: string[];
@@ -40,6 +41,7 @@ export function CollectionDetailsForm({
40
41
  groups: string[] | null;
41
42
  parentCollection?: EntityCollection;
42
43
  parentCollectionIds?: string[];
44
+ children?: React.ReactNode;
43
45
  }) {
44
46
 
45
47
  const groupRef = React.useRef<HTMLInputElement>(null);
@@ -390,9 +392,13 @@ export function CollectionDetailsForm({
390
392
  for large collections, as it may incur in performance and cost issues.
391
393
  </FieldCaption>
392
394
  </div>
395
+
396
+
393
397
  </div>
394
398
  </ExpandablePanel>
395
399
 
400
+ {children}
401
+
396
402
  </div>
397
403
 
398
404
  </div>
@@ -2,6 +2,7 @@ import * as React from "react";
2
2
  import { useEffect, useRef, useState } from "react";
3
3
  import {
4
4
  CircularProgressCenter,
5
+ ConfirmationDialog,
5
6
  Entity,
6
7
  EntityCollection,
7
8
  ErrorView,
@@ -37,7 +38,8 @@ import {
37
38
  IconButton,
38
39
  LoadingButton,
39
40
  Tab,
40
- Tabs
41
+ Tabs,
42
+ Typography
41
43
  } from "@firecms/ui";
42
44
  import { YupSchema } from "./CollectionYupValidation";
43
45
  import { CollectionDetailsForm } from "./CollectionDetailsForm";
@@ -533,8 +535,24 @@ function CollectionEditorInternal<M extends Record<string, any>>({
533
535
  };
534
536
 
535
537
  const editable = collection?.editable === undefined || collection?.editable === true;
538
+ // @ts-ignore
539
+ const isMergedCollection = collection?.merged ?? false;
536
540
  const collectionEditable = editable || isNewCollection;
537
541
 
542
+ const [deleteRequested, setDeleteRequested] = useState(false);
543
+
544
+ const deleteCollection = () => {
545
+ if (!collection) return;
546
+ configController?.deleteCollection({ id: collection.id }).then(() => {
547
+ setDeleteRequested(false);
548
+ handleCancel();
549
+ snackbarController.open({
550
+ message: "Collection deleted",
551
+ type: "success"
552
+ });
553
+ });
554
+ };
555
+
538
556
  return <DialogContent fullHeight={true}>
539
557
  <Formex value={formController}>
540
558
 
@@ -614,7 +632,18 @@ function CollectionEditorInternal<M extends Record<string, any>>({
614
632
  groups={groups}
615
633
  parentCollectionIds={parentCollectionIds}
616
634
  parentCollection={parentCollection}
617
- isNewCollection={isNewCollection}/>}
635
+ isNewCollection={isNewCollection}>
636
+ {!isNewCollection && isMergedCollection && <div className={"flex flex-col gap-4 mt-8"}>
637
+ <Typography variant={"body2"} color={"secondary"}>This collection is defined in code.
638
+ The changes done in this editor will override the properties defined in code.
639
+ You can delete the overridden values to revert to the state defined in code.
640
+ </Typography>
641
+ <Button variant={"neutral"}
642
+ onClick={() => {
643
+ setDeleteRequested(true);
644
+ }}>Reset to code</Button>
645
+ </div>}
646
+ </CollectionDetailsForm>}
618
647
 
619
648
  {currentView === "subcollections" && collection &&
620
649
  <SubcollectionsEditTab
@@ -748,6 +777,15 @@ function CollectionEditorInternal<M extends Record<string, any>>({
748
777
 
749
778
  </Formex>
750
779
 
780
+ <ConfirmationDialog
781
+ open={deleteRequested}
782
+ onAccept={deleteCollection}
783
+ onCancel={() => setDeleteRequested(false)}
784
+ title={<>Delete the stored config?</>}
785
+ body={<> This will <b>not
786
+ delete any data</b>, only
787
+ the stored config, and reset to the code state.</>}/>
788
+
751
789
  </DialogContent>
752
790
 
753
791
  }
@@ -49,5 +49,6 @@ export function LayoutModeSwitch({
49
49
  </Tooltip>
50
50
 
51
51
  </div>
52
+ <Typography variant={"caption"} color={"secondary"} className={"ml-3.5"}>Should documents be opened full screen or in an inline side dialog</Typography>
52
53
  </div>
53
54
  }
@@ -11,7 +11,7 @@ import { PersistedCollection } from "../types/persisted_collection";
11
11
  * Function in charge of merging collections defined in code with those stored in the backend.
12
12
  */
13
13
  export const mergeCollections = (baseCollections: EntityCollection[],
14
- backendCollections: PersistedCollection[],
14
+ backendCollections: PersistedCollection[] = [],
15
15
  modifyCollection?: (props: ModifyCollectionProps) => EntityCollection | void
16
16
  ) => {
17
17
 
@@ -19,16 +19,18 @@ export const mergeCollections = (baseCollections: EntityCollection[],
19
19
  makePropertiesEditable(c.properties as Properties);
20
20
  c.subcollections?.forEach(markAsEditable);
21
21
  };
22
- const storedCollections = backendCollections ?? [];
23
- storedCollections.forEach(markAsEditable);
24
22
 
25
- console.debug("Collections specified in code:", baseCollections);
26
- console.debug("Collections stored in the backend", storedCollections);
27
- const result = joinCollectionLists(baseCollections, storedCollections, [], modifyCollection);
23
+ backendCollections.forEach(markAsEditable);
24
+
25
+ const result = joinCollectionLists(baseCollections, backendCollections, [], modifyCollection);
28
26
 
29
27
  // sort the collections so they are in the same order as the base collections
30
28
  result.sort((a, b) => baseCollections.findIndex(c => c.id === a.id) - baseCollections.findIndex(c => c.id === b.id));
29
+ console.debug("Collections result", {
30
+ baseCollections,
31
+ backendCollections,
32
+ result
33
+ });
31
34
 
32
- console.debug("Collections after joining:", result);
33
35
  return result;
34
36
  }