Skip to content

Commit 1ef4859

Browse files
committed
Added prop to disable JSON tab in entities
1 parent a4f9079 commit 1ef4859

File tree

4 files changed

+8
-41
lines changed

4 files changed

+8
-41
lines changed

examples/example_pro/src/FirestoreApp/App.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import {
3535
FirebaseAuthController,
3636
FirebaseSignInProvider,
3737
FirebaseUserWrapper,
38-
useAppCheck,
3938
useFirebaseAuthController,
4039
useFirebaseStorageSource,
4140
useFirestoreDelegate,
@@ -49,7 +48,7 @@ import { firebaseConfig, secondaryFirebaseConfig } from "../firebase_config";
4948
import { ExampleCMSView } from "./views/ExampleCMSView";
5049
import { testCollection } from "./collections/test_collection";
5150
import { usersCollection } from "./collections/users_collection";
52-
import { localeCollectionGroup, pppCollection, productsCollection } from "./collections/products_collection";
51+
import { localeCollectionGroup, productsCollection } from "./collections/products_collection";
5352
import { blogCollection } from "./collections/blog_collection";
5453
import { showcaseCollection } from "./collections/showcase_collection";
5554

@@ -61,7 +60,6 @@ import { FirebaseApp } from "@firebase/app";
6160
import { TestEditorView } from "./views/TestEditorView";
6261
import { mergeCollections, useCollectionEditorPlugin } from "@firecms/collection_editor";
6362
import { useFirestoreCollectionsConfigController } from "@firecms/collection_editor_firebase";
64-
import { ReCaptchaEnterpriseProvider } from "@firebase/app-check";
6563
import { useExportPlugin } from "@firecms/data_export";
6664
import { useImportPlugin } from "@firecms/data_import";
6765
import { DemoImportAction } from "./DemoImportAction";
@@ -233,7 +231,6 @@ export function App() {
233231
showcaseCollection,
234232
cryptoCollection,
235233
localeCollectionGroup,
236-
pppCollection,
237234
// carsCollection(secondaryFirestoreDelegate)
238235
];
239236
if (process.env.NODE_ENV !== "production") {

examples/example_pro/src/FirestoreApp/collections/products_collection.tsx

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export const productsCollection = buildCollection<Product>({
124124
create: true,
125125
delete: true
126126
}),
127+
includeJsonView: false,
127128
Actions: [SampleCollectionActions],
128129
subcollections: [localeCollection],
129130
// defaultSelectedView: "sample_custom_view",
@@ -374,39 +375,3 @@ export const productsSimpleCollection = buildCollection<any>({
374375
}
375376

376377
});
377-
378-
379-
export const pppCollection = buildCollection<Product>({
380-
path: "products",
381-
id: "ppp",
382-
callbacks: productCallbacks,
383-
name: "PPP",
384-
group: "Demo collections",
385-
icon: "shopping_cart",
386-
openEntityMode: "full_screen",
387-
description: "List of the products currently sold in our shop",
388-
textSearchEnabled: true,
389-
permissions: ({ authController }) => ({
390-
edit: true,
391-
create: true,
392-
delete: true
393-
}),
394-
Actions: [SampleCollectionActions],
395-
subcollections: [localeCollection],
396-
// defaultSelectedView: "sample_custom_view",
397-
additionalFields: [productAdditionalField],
398-
// @ts-ignore
399-
properties: {
400-
name: {
401-
dataType: "string",
402-
name: "Name",
403-
description: "Name of this product",
404-
clearable: true,
405-
validation: {
406-
required: true
407-
}
408-
}
409-
}
410-
411-
});
412-

packages/firecms_core/src/core/EntityEditView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
179179
const subcollectionsCount = subcollections?.length ?? 0;
180180
const customViews = collection.entityViews;
181181
const customViewsCount = customViews?.length ?? 0;
182-
const includeJsonView = true;
182+
const includeJsonView = collection.includeJsonView === undefined ? true : collection.includeJsonView;
183183
const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0 || includeJsonView;
184184

185185
const {

packages/firecms_core/src/types/collections.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
332332
* Defaults to false.
333333
*/
334334
alwaysApplyDefaultValues?: boolean;
335+
336+
/**
337+
* If set to true, a tab including the JSON representation of the entity will be included.
338+
*/
339+
includeJsonView?: boolean;
335340
}
336341

337342
/**

0 commit comments

Comments
 (0)