@firecms/core 3.0.0-canary.42 → 3.0.0-canary.43
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/EntityCollectionTableProps.d.ts +1 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/common/types.d.ts +1 -1
- package/dist/hooks/useValidateAuthenticator.d.ts +2 -6
- package/dist/index.es.js +2092 -2100
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +1 -16
- package/dist/types/datasource.d.ts +2 -5
- package/dist/types/entities.d.ts +5 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/properties.d.ts +2 -2
- package/dist/util/entities.d.ts +1 -1
- package/package.json +17 -17
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +10 -6
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +1 -1
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +16 -19
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +11 -6
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +4 -1
- package/src/components/SelectableTable/SelectableTable.tsx +1 -1
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
- package/src/components/common/types.tsx +1 -1
- package/src/hooks/data/save.ts +1 -0
- package/src/hooks/useValidateAuthenticator.tsx +2 -22
- package/src/internal/useBuildDataSource.ts +42 -47
- package/src/preview/PropertyPreview.tsx +2 -12
- package/src/types/datasource.ts +7 -4
- package/src/types/entities.ts +9 -1
- package/src/types/index.ts +0 -1
- package/src/types/properties.ts +5 -4
- package/src/util/entities.ts +1 -1
- package/dist/types/appcheck.d.ts +0 -26
- package/src/types/appcheck.ts +0 -29
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataSource, DataSourceDelegate,
|
|
1
|
+
import { DataSource, DataSourceDelegate, NavigationController, PropertyConfig } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Use this hook to build a {@link DataSource} based on Firestore
|
|
4
4
|
* @param firebaseApp
|
|
@@ -9,18 +9,3 @@ export declare function useBuildDataSource({ delegate, propertyConfigs, navigati
|
|
|
9
9
|
propertyConfigs?: Record<string, PropertyConfig>;
|
|
10
10
|
navigationController: NavigationController;
|
|
11
11
|
}): DataSource;
|
|
12
|
-
/**
|
|
13
|
-
* Recursive function that converts Firestore data types into CMS or plain
|
|
14
|
-
* JS types.
|
|
15
|
-
* FireCMS uses Javascript dates internally instead of Firestore timestamps.
|
|
16
|
-
* This makes it easier to interact with the rest of the libraries and
|
|
17
|
-
* bindings.
|
|
18
|
-
* Also, Firestore references are replaced with {@link EntityReference}
|
|
19
|
-
* @param data
|
|
20
|
-
* @param buildReference
|
|
21
|
-
* @param buildGeoPoint
|
|
22
|
-
* @param buildDate
|
|
23
|
-
* @param buildDelete
|
|
24
|
-
* @group Firestore
|
|
25
|
-
*/
|
|
26
|
-
export declare function cmsToDelegateModel(data: any, buildReference: (reference: EntityReference) => any, buildGeoPoint: (geoPoint: GeoPoint) => any, buildDate: (date: Date) => any, buildDelete: () => any): any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity,
|
|
1
|
+
import { Entity, EntityStatus, EntityValues } from "./entities";
|
|
2
2
|
import { EntityCollection, FilterValues } from "./collections";
|
|
3
3
|
import { ResolvedEntityCollection } from "./resolved_entities";
|
|
4
4
|
/**
|
|
@@ -245,18 +245,15 @@ export interface DataSourceDelegate {
|
|
|
245
245
|
* Convert a FireCMS reference to a reference that can be used by the datasource
|
|
246
246
|
* @param reference
|
|
247
247
|
*/
|
|
248
|
-
buildReference: (reference: EntityReference) => any;
|
|
249
248
|
/**
|
|
250
249
|
* Convert a FireCMS GeoPoint to a GeoPoint that can be used by the datasource
|
|
251
250
|
* @param geoPoint
|
|
252
251
|
*/
|
|
253
|
-
buildGeoPoint: (geoPoint: GeoPoint) => any;
|
|
254
252
|
/**
|
|
255
253
|
* Get the object to generate the current time in the datasource
|
|
256
254
|
*/
|
|
257
255
|
currentTime(): any;
|
|
258
|
-
buildDate: (date: Date) => any;
|
|
259
|
-
buildDeleteFieldValue: () => any;
|
|
260
256
|
delegateToCMSModel: (data: any) => any;
|
|
257
|
+
cmsToDelegateModel: (data: any) => any;
|
|
261
258
|
setDateToMidnight: (input?: any) => any;
|
|
262
259
|
}
|
package/dist/types/entities.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type EntityValues<M extends object> = M;
|
|
|
31
31
|
/**
|
|
32
32
|
* Class used to create a reference to an entity in a different path
|
|
33
33
|
*/
|
|
34
|
-
export declare class EntityReference
|
|
34
|
+
export declare class EntityReference {
|
|
35
35
|
/**
|
|
36
36
|
* ID of the entity
|
|
37
37
|
*/
|
|
@@ -56,3 +56,7 @@ export declare class GeoPoint {
|
|
|
56
56
|
readonly longitude: number;
|
|
57
57
|
constructor(latitude: number, longitude: number);
|
|
58
58
|
}
|
|
59
|
+
export declare class Vector {
|
|
60
|
+
readonly value: number[];
|
|
61
|
+
constructor(value: number[]);
|
|
62
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export * from "./plugins";
|
|
|
23
23
|
export * from "./analytics";
|
|
24
24
|
export * from "./firecms";
|
|
25
25
|
export * from "./roles";
|
|
26
|
-
export * from "./appcheck";
|
|
27
26
|
export * from "./export_import";
|
|
28
27
|
export * from "./modify_collections";
|
|
29
28
|
export * from "./analytics_controller";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FieldProps } from "./fields";
|
|
3
3
|
import { PropertyPreviewProps } from "../preview";
|
|
4
|
-
import { EntityReference, EntityValues, GeoPoint } from "./entities";
|
|
4
|
+
import { EntityReference, EntityValues, GeoPoint, Vector } from "./entities";
|
|
5
5
|
import { ResolvedArrayProperty, ResolvedStringProperty } from "./resolved_entities";
|
|
6
6
|
import { FilterValues } from "./collections";
|
|
7
7
|
import { ChipColorKey, ChipColorScheme } from "@firecms/ui";
|
|
8
8
|
/**
|
|
9
9
|
* @group Entity properties
|
|
10
10
|
*/
|
|
11
|
-
export type DataType<T extends CMSType = CMSType> = T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : T extends Date ? "date" : T extends GeoPoint ? "geopoint" : T extends EntityReference ? "reference" : T extends Array<CMSType> ? "array" : T extends Record<string, any> ? "map" : never;
|
|
11
|
+
export type DataType<T extends CMSType = CMSType> = T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : T extends Date ? "date" : T extends GeoPoint ? "geopoint" : T extends Vector ? "vector" : T extends EntityReference ? "reference" : T extends Array<CMSType> ? "array" : T extends Record<string, any> ? "map" : never;
|
|
12
12
|
/**
|
|
13
13
|
* @group Entity properties
|
|
14
14
|
*/
|
package/dist/util/entities.d.ts
CHANGED
|
@@ -23,6 +23,6 @@ export declare function updateDateAutoValues<M extends Record<string, any>>({ in
|
|
|
23
23
|
* @group Datasource
|
|
24
24
|
*/
|
|
25
25
|
export declare function sanitizeData<M extends Record<string, any>>(values: EntityValues<M>, properties: ResolvedProperties<M>): any;
|
|
26
|
-
export declare function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference
|
|
26
|
+
export declare function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference;
|
|
27
27
|
export declare function traverseValuesProperties<M extends Record<string, any>>(inputValues: Partial<EntityValues<M>>, properties: ResolvedProperties<M>, operation: (value: any, property: Property) => any): EntityValues<M> | undefined;
|
|
28
28
|
export declare function traverseValueProperty(inputValue: any, property: Property, operation: (value: any, property: Property) => any): any;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.43",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"./package.json": "./package.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
50
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
49
|
+
"@firecms/formex": "^3.0.0-canary.43",
|
|
50
|
+
"@firecms/ui": "^3.0.0-canary.43",
|
|
51
51
|
"@fontsource/jetbrains-mono": "^5.0.19",
|
|
52
|
-
"@hello-pangea/dnd": "^16.
|
|
52
|
+
"@hello-pangea/dnd": "^16.6.0",
|
|
53
53
|
"@radix-ui/react-portal": "^1.0.4",
|
|
54
54
|
"clsx": "^2.1.0",
|
|
55
55
|
"date-fns": "^3.6.0",
|
|
@@ -84,16 +84,16 @@
|
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@jest/globals": "^29.7.0",
|
|
86
86
|
"@testing-library/jest-dom": "^6.4.2",
|
|
87
|
-
"@testing-library/react": "^14.
|
|
87
|
+
"@testing-library/react": "^14.3.1",
|
|
88
88
|
"@testing-library/user-event": "^14.5.2",
|
|
89
89
|
"@types/jest": "^29.5.12",
|
|
90
|
-
"@types/node": "^20.
|
|
90
|
+
"@types/node": "^20.12.7",
|
|
91
91
|
"@types/object-hash": "^3.0.6",
|
|
92
|
-
"@types/react": "^18.2.
|
|
93
|
-
"@types/react-dom": "^18.2.
|
|
92
|
+
"@types/react": "^18.2.79",
|
|
93
|
+
"@types/react-dom": "^18.2.25",
|
|
94
94
|
"@types/react-measure": "^2.0.12",
|
|
95
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
96
|
-
"@typescript-eslint/parser": "^7.
|
|
95
|
+
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
|
96
|
+
"@typescript-eslint/parser": "^7.7.0",
|
|
97
97
|
"@vitejs/plugin-react": "^4.2.1",
|
|
98
98
|
"cross-env": "^7.0.3",
|
|
99
99
|
"eslint": "^8.57.0",
|
|
@@ -103,22 +103,22 @@
|
|
|
103
103
|
"eslint-plugin-promise": "^6.1.1",
|
|
104
104
|
"eslint-plugin-react": "^7.34.1",
|
|
105
105
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
106
|
-
"firebase": "^10.
|
|
106
|
+
"firebase": "^10.11.0",
|
|
107
107
|
"jest": "^29.7.0",
|
|
108
108
|
"npm-run-all": "^4.1.5",
|
|
109
|
-
"react-router": "^6.22.
|
|
110
|
-
"react-router-dom": "^6.22.
|
|
109
|
+
"react-router": "^6.22.3",
|
|
110
|
+
"react-router-dom": "^6.22.3",
|
|
111
111
|
"ts-jest": "^29.1.2",
|
|
112
112
|
"ts-node": "^10.9.2",
|
|
113
|
-
"tsd": "^0.
|
|
114
|
-
"typescript": "^5.4.
|
|
115
|
-
"vite": "^5.2.
|
|
113
|
+
"tsd": "^0.31.0",
|
|
114
|
+
"typescript": "^5.4.5",
|
|
115
|
+
"vite": "^5.2.9"
|
|
116
116
|
},
|
|
117
117
|
"files": [
|
|
118
118
|
"dist",
|
|
119
119
|
"src"
|
|
120
120
|
],
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "fedcb0d43c504245dd76b702e4ab4479fa8592df",
|
|
122
122
|
"publishConfig": {
|
|
123
123
|
"access": "public"
|
|
124
124
|
}
|
|
@@ -16,7 +16,6 @@ import { propertiesToColumns } from "./column_utils";
|
|
|
16
16
|
import { ErrorView } from "../ErrorView";
|
|
17
17
|
import { SelectableTable } from "../SelectableTable/SelectableTable";
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
/**
|
|
21
20
|
* This component is in charge of rendering a collection table with a high
|
|
22
21
|
* degree of customization.
|
|
@@ -177,7 +176,10 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
|
|
|
177
176
|
|
|
178
177
|
const child = Builder
|
|
179
178
|
? <Builder entity={entity} context={context}/>
|
|
180
|
-
: <>{additionalField.value?.({
|
|
179
|
+
: <>{additionalField.value?.({
|
|
180
|
+
entity,
|
|
181
|
+
context
|
|
182
|
+
})}</>;
|
|
181
183
|
|
|
182
184
|
return (
|
|
183
185
|
<EntityTableCell
|
|
@@ -235,10 +237,12 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
|
|
|
235
237
|
|
|
236
238
|
const columns: VirtualTableColumn[] = [
|
|
237
239
|
idColumn,
|
|
238
|
-
...displayedColumnIds
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
...(displayedColumnIds
|
|
241
|
+
? displayedColumnIds
|
|
242
|
+
.map((p) => {
|
|
243
|
+
return collectionColumns.find(c => c.key === p.key);
|
|
244
|
+
}).filter(Boolean)
|
|
245
|
+
: collectionColumns) as VirtualTableColumn[]
|
|
242
246
|
];
|
|
243
247
|
|
|
244
248
|
const cellRenderer = (props: CellRendererParams<any>) => {
|
|
@@ -92,7 +92,7 @@ export type EntityCollectionTableProps<M extends Record<string, any>,
|
|
|
92
92
|
*/
|
|
93
93
|
tableController: EntityTableController<M>;
|
|
94
94
|
|
|
95
|
-
displayedColumnIds
|
|
95
|
+
displayedColumnIds?: PropertyColumnConfig[];
|
|
96
96
|
|
|
97
97
|
forceFilter?: FilterValues<Extract<keyof M, string>>;
|
|
98
98
|
|
|
@@ -95,6 +95,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
95
95
|
const internalValueRef = useRef(value);
|
|
96
96
|
|
|
97
97
|
const [error, setError] = useState<Error | undefined>();
|
|
98
|
+
const [validationError, setValidationError] = useState<Error | undefined>();
|
|
98
99
|
const [saved, setSaved] = useState<boolean>(false);
|
|
99
100
|
|
|
100
101
|
const onValueUpdated = useCallback(() => {
|
|
@@ -120,7 +121,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
120
121
|
useEffect(
|
|
121
122
|
() => {
|
|
122
123
|
if (!equal(value, internalValueRef.current)) {
|
|
123
|
-
|
|
124
|
+
setValidationError(undefined);
|
|
124
125
|
setInternalValue(value);
|
|
125
126
|
internalValueRef.current = value;
|
|
126
127
|
onValueUpdated();
|
|
@@ -136,7 +137,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
136
137
|
validation
|
|
137
138
|
.validate(value)
|
|
138
139
|
.then(() => {
|
|
139
|
-
|
|
140
|
+
setValidationError(undefined);
|
|
140
141
|
internalValueRef.current = value;
|
|
141
142
|
if (onValueChange) {
|
|
142
143
|
onValueChange({
|
|
@@ -151,17 +152,15 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
151
152
|
}
|
|
152
153
|
})
|
|
153
154
|
.catch((e) => {
|
|
154
|
-
|
|
155
|
+
setValidationError(e);
|
|
155
156
|
});
|
|
156
157
|
};
|
|
157
158
|
|
|
158
159
|
useEffect(() => {
|
|
159
160
|
validation
|
|
160
161
|
.validate(internalValue)
|
|
161
|
-
.then(() =>
|
|
162
|
-
.catch(
|
|
163
|
-
setError(e);
|
|
164
|
-
});
|
|
162
|
+
.then(() => setValidationError(undefined))
|
|
163
|
+
.catch(setValidationError);
|
|
165
164
|
}, [internalValue, validation, propertyKey, property, entity]);
|
|
166
165
|
|
|
167
166
|
const updateValue = (newValue: any | null) => {
|
|
@@ -237,7 +236,6 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
237
236
|
height={getRowHeight(size)}
|
|
238
237
|
propertyKey={propertyKey}
|
|
239
238
|
property={property}
|
|
240
|
-
// entity={entity}
|
|
241
239
|
value={internalValue}
|
|
242
240
|
size={getPreviewSizeFrom(size)}
|
|
243
241
|
/>
|
|
@@ -247,7 +245,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
247
245
|
if (!customField && (!customPreview || selected)) {
|
|
248
246
|
const isAStorageProperty = isStorageProperty(property);
|
|
249
247
|
if (isAStorageProperty) {
|
|
250
|
-
innerComponent = <TableStorageUpload error={error}
|
|
248
|
+
innerComponent = <TableStorageUpload error={validationError ?? error}
|
|
251
249
|
disabled={disabled}
|
|
252
250
|
focused={selected}
|
|
253
251
|
selected={selected}
|
|
@@ -274,7 +272,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
274
272
|
valueType={"number"}
|
|
275
273
|
small={getPreviewSizeFrom(size) !== "medium"}
|
|
276
274
|
enumValues={numberProperty.enumValues}
|
|
277
|
-
error={error}
|
|
275
|
+
error={validationError ?? error}
|
|
278
276
|
internalValue={internalValue as string | number}
|
|
279
277
|
updateValue={updateValue}
|
|
280
278
|
/>;
|
|
@@ -282,7 +280,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
282
280
|
} else {
|
|
283
281
|
innerComponent = <VirtualTableNumberInput
|
|
284
282
|
align={align}
|
|
285
|
-
error={error}
|
|
283
|
+
error={validationError ?? error}
|
|
286
284
|
focused={selected}
|
|
287
285
|
disabled={disabled}
|
|
288
286
|
value={internalValue as number}
|
|
@@ -300,14 +298,14 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
300
298
|
valueType={"string"}
|
|
301
299
|
small={getPreviewSizeFrom(size) !== "medium"}
|
|
302
300
|
enumValues={stringProperty.enumValues}
|
|
303
|
-
error={error}
|
|
301
|
+
error={validationError ?? error}
|
|
304
302
|
internalValue={internalValue as string | number}
|
|
305
303
|
updateValue={updateValue}
|
|
306
304
|
/>;
|
|
307
305
|
fullHeight = true;
|
|
308
306
|
} else if (!stringProperty.storage) {
|
|
309
307
|
const multiline = Boolean(stringProperty.multiline) || Boolean(stringProperty.markdown);
|
|
310
|
-
innerComponent = <VirtualTableInput error={error}
|
|
308
|
+
innerComponent = <VirtualTableInput error={validationError ?? error}
|
|
311
309
|
disabled={disabled}
|
|
312
310
|
multiline={multiline}
|
|
313
311
|
focused={selected}
|
|
@@ -317,7 +315,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
317
315
|
allowScroll = true;
|
|
318
316
|
}
|
|
319
317
|
} else if (property.dataType === "boolean") {
|
|
320
|
-
innerComponent = <VirtualTableSwitch error={error}
|
|
318
|
+
innerComponent = <VirtualTableSwitch error={validationError ?? error}
|
|
321
319
|
disabled={disabled}
|
|
322
320
|
focused={selected}
|
|
323
321
|
internalValue={internalValue as boolean}
|
|
@@ -325,7 +323,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
325
323
|
/>;
|
|
326
324
|
} else if (property.dataType === "date") {
|
|
327
325
|
innerComponent = <VirtualTableDateField name={propertyKey as string}
|
|
328
|
-
error={error}
|
|
326
|
+
error={validationError ?? error}
|
|
329
327
|
disabled={disabled}
|
|
330
328
|
mode={property.mode}
|
|
331
329
|
focused={selected}
|
|
@@ -368,7 +366,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
368
366
|
small={getPreviewSizeFrom(size) !== "medium"}
|
|
369
367
|
valueType={arrayProperty.of.dataType}
|
|
370
368
|
enumValues={arrayProperty.of.enumValues}
|
|
371
|
-
error={error}
|
|
369
|
+
error={validationError ?? error}
|
|
372
370
|
internalValue={internalValue as string | number}
|
|
373
371
|
updateValue={updateValue}
|
|
374
372
|
/>;
|
|
@@ -403,9 +401,8 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
403
401
|
allowScroll = false;
|
|
404
402
|
showExpandIcon = selected && !innerComponent && !disabled && !readOnlyProperty;
|
|
405
403
|
innerComponent = (
|
|
406
|
-
<PropertyPreview
|
|
404
|
+
<PropertyPreview width={width}
|
|
407
405
|
height={height}
|
|
408
|
-
// entity={entity}
|
|
409
406
|
propertyKey={propertyKey as string}
|
|
410
407
|
value={internalValue}
|
|
411
408
|
property={property}
|
|
@@ -426,7 +423,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
426
423
|
removePadding={removePadding}
|
|
427
424
|
fullHeight={fullHeight}
|
|
428
425
|
saved={saved}
|
|
429
|
-
error={error}
|
|
426
|
+
error={validationError ?? error}
|
|
430
427
|
align={align}
|
|
431
428
|
allowScroll={allowScroll}
|
|
432
429
|
showExpandIcon={showExpandIcon}
|
|
@@ -96,7 +96,7 @@ export const EntityTableCell = React.memo<EntityTableCellProps>(
|
|
|
96
96
|
const [onHover, setOnHover] = useState(false);
|
|
97
97
|
const [internalSaved, setInternalSaved] = useState(saved);
|
|
98
98
|
|
|
99
|
-
const showError = !disabled && error;
|
|
99
|
+
const showError = !disabled && Boolean(error);
|
|
100
100
|
|
|
101
101
|
useEffect(() => {
|
|
102
102
|
if (saved) {
|
|
@@ -176,21 +176,26 @@ export const EntityTableCell = React.memo<EntityTableCellProps>(
|
|
|
176
176
|
const setOnHoverTrue = useCallback(() => setOnHover(true), []);
|
|
177
177
|
const setOnHoverFalse = useCallback(() => setOnHover(false), []);
|
|
178
178
|
|
|
179
|
+
const borderClass = showError
|
|
180
|
+
? "border-red-500"
|
|
181
|
+
: internalSaved
|
|
182
|
+
? "border-green-500"
|
|
183
|
+
: isSelected
|
|
184
|
+
? "border-primary"
|
|
185
|
+
: "border-transparent";
|
|
186
|
+
|
|
179
187
|
return (
|
|
180
188
|
<div
|
|
181
|
-
ref={ref}
|
|
182
189
|
className={cn(
|
|
183
190
|
"transition-colors duration-100 ease-in-out",
|
|
184
191
|
`flex relative h-full rounded-md p-${p} border border-4 border-opacity-75`,
|
|
185
192
|
onHover && !disabled ? "bg-gray-50 dark:bg-gray-900" : "",
|
|
186
193
|
saved ? "bg-gray-100 bg-opacity-75 dark:bg-gray-800 dark:bg-opacity-75" : "",
|
|
187
|
-
!isSelected && !internalSaved && !showError ? "border-transparent" : "",
|
|
188
194
|
hideOverflow ? "overflow-hidden" : "",
|
|
189
195
|
isSelected ? "bg-gray-50 dark:bg-gray-900" : "",
|
|
190
|
-
|
|
191
|
-
internalSaved ? "border-green-500 " : "",
|
|
192
|
-
showError ? "border-red-500" : ""
|
|
196
|
+
borderClass
|
|
193
197
|
)}
|
|
198
|
+
ref={ref}
|
|
194
199
|
style={{
|
|
195
200
|
justifyContent,
|
|
196
201
|
alignItems: disabled || !isOverflowing ? "center" : undefined,
|
|
@@ -337,7 +337,10 @@ export const EntityCollectionView = React.memo(
|
|
|
337
337
|
callbacks: collection.callbacks,
|
|
338
338
|
dataSource,
|
|
339
339
|
context,
|
|
340
|
-
onSaveSuccess: () =>
|
|
340
|
+
onSaveSuccess: () => {
|
|
341
|
+
setError(undefined);
|
|
342
|
+
onValueUpdated();
|
|
343
|
+
},
|
|
341
344
|
onSaveFailure: (e: Error) => {
|
|
342
345
|
console.error("Save failure");
|
|
343
346
|
console.error(e);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "../../types";
|
|
11
11
|
import { CellRendererParams, VirtualTable, VirtualTableColumn } from "../VirtualTable";
|
|
12
12
|
import { enumToObjectEntries } from "../../util";
|
|
13
|
-
import { OnCellValueChange, OnColumnResizeParams } from "../common
|
|
13
|
+
import { OnCellValueChange, OnColumnResizeParams } from "../common";
|
|
14
14
|
import { FilterFormFieldProps } from "../VirtualTable/VirtualTableHeader";
|
|
15
15
|
import { ReferenceFilterField } from "./filters/ReferenceFilterField";
|
|
16
16
|
import { StringNumberFilterField } from "./filters/StringNumberFilterField";
|
|
@@ -32,7 +32,7 @@ export function BooleanFilterField({
|
|
|
32
32
|
const valueSet = !!value;
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
|
-
<div className="w-[
|
|
35
|
+
<div className="w-[300px]">
|
|
36
36
|
<BooleanSwitchWithLabel
|
|
37
37
|
value={valueSetToTrue}
|
|
38
38
|
allowIndeterminate={true}
|
|
@@ -44,6 +44,5 @@ export function BooleanFilterField({
|
|
|
44
44
|
: `${title} is false`}
|
|
45
45
|
/>
|
|
46
46
|
</div>
|
|
47
|
-
)
|
|
48
|
-
;
|
|
47
|
+
);
|
|
49
48
|
}
|
|
@@ -36,7 +36,7 @@ export interface OnCellValueChangeParams<T = any, M extends Record<string, any>
|
|
|
36
36
|
propertyKey: string,
|
|
37
37
|
entity: Entity<M>,
|
|
38
38
|
onValueUpdated: () => void
|
|
39
|
-
setError: (e: Error) => void
|
|
39
|
+
setError: (e: Error | undefined) => void
|
|
40
40
|
fullPath: string
|
|
41
41
|
context: FireCMSContext
|
|
42
42
|
}
|
package/src/hooks/data/save.ts
CHANGED
|
@@ -145,6 +145,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
145
145
|
onSaveSuccess(entity);
|
|
146
146
|
})
|
|
147
147
|
.catch((e) => {
|
|
148
|
+
console.error("!!!", e);
|
|
148
149
|
if (callbacks?.onSaveFailure) {
|
|
149
150
|
|
|
150
151
|
const resolvedCollection = resolveCollection<M>({
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import equal from "react-fast-compare";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { AuthController, Authenticator, DataSourceDelegate, StorageSource, User } from "../index";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* This hook is used internally for validating an authenticator.
|
|
8
8
|
*
|
|
9
9
|
* @param authController
|
|
10
10
|
* @param authentication
|
|
11
|
-
* @param getAppCheckToken
|
|
12
|
-
* @param appCheckForceRefresh
|
|
13
11
|
* @param storageSource
|
|
14
12
|
* @param dataSourceDelegate
|
|
15
13
|
*/
|
|
@@ -17,8 +15,6 @@ export function useValidateAuthenticator<UserType extends User = User, Controlle
|
|
|
17
15
|
disabled,
|
|
18
16
|
authController,
|
|
19
17
|
authenticator,
|
|
20
|
-
getAppCheckToken,
|
|
21
|
-
appCheckForceRefresh = false,
|
|
22
18
|
storageSource,
|
|
23
19
|
dataSourceDelegate
|
|
24
20
|
}:
|
|
@@ -26,8 +22,6 @@ export function useValidateAuthenticator<UserType extends User = User, Controlle
|
|
|
26
22
|
disabled?: boolean,
|
|
27
23
|
authController: Controller,
|
|
28
24
|
authenticator?: boolean | Authenticator<UserType, Controller>,
|
|
29
|
-
getAppCheckToken?: (forceRefresh: boolean) => Promise<AppCheckTokenResult> | undefined,
|
|
30
|
-
appCheckForceRefresh?: boolean,
|
|
31
25
|
dataSourceDelegate: DataSourceDelegate;
|
|
32
26
|
storageSource: StorageSource;
|
|
33
27
|
}): {
|
|
@@ -78,20 +72,6 @@ export function useValidateAuthenticator<UserType extends User = User, Controlle
|
|
|
78
72
|
const delegateUser = authController.user;
|
|
79
73
|
console.debug("Checking authentication for user", delegateUser);
|
|
80
74
|
|
|
81
|
-
if (getAppCheckToken) {
|
|
82
|
-
try {
|
|
83
|
-
if (!await getAppCheckToken(appCheckForceRefresh)) {
|
|
84
|
-
setNotAllowedError("App Check failed.");
|
|
85
|
-
authController.signOut();
|
|
86
|
-
} else {
|
|
87
|
-
console.debug("App Check success.");
|
|
88
|
-
}
|
|
89
|
-
} catch (e: any) {
|
|
90
|
-
setNotAllowedError(e.message);
|
|
91
|
-
authController.signOut();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
75
|
if (authenticator instanceof Function && delegateUser && !equal(checkedUserRef.current?.uid, delegateUser.uid)) {
|
|
96
76
|
setAuthLoading(true);
|
|
97
77
|
try {
|
|
@@ -120,7 +100,7 @@ export function useValidateAuthenticator<UserType extends User = User, Controlle
|
|
|
120
100
|
setAuthVerified(true);
|
|
121
101
|
}
|
|
122
102
|
|
|
123
|
-
}, [disabled, authController, authenticator,
|
|
103
|
+
}, [disabled, authController, authenticator, dataSourceDelegate, storageSource]);
|
|
124
104
|
|
|
125
105
|
useEffect(() => {
|
|
126
106
|
checkAuthentication();
|