Skip to content

Commit

Permalink
Refactor and fixes for propertyValue prop in property builders
Browse files Browse the repository at this point in the history
  • Loading branch information
fgatti675 committed May 8, 2024
1 parent 58bd832 commit cea8107
Show file tree
Hide file tree
Showing 29 changed files with 373 additions and 245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ export function SampleCustomEntityCollection() {

const getPropertyFor = ({
propertyKey,
propertyValue,
entity
}: {
propertyKey: string,
propertyValue: any,
entity: Entity<any>
}) => {
let propertyOrBuilder: PropertyOrBuilder | undefined = getPropertyInPath(collection.properties, propertyKey);
Expand All @@ -58,7 +56,6 @@ export function SampleCustomEntityCollection() {
propertyKey,
propertyOrBuilder,
path,
propertyValue,
values: entity.values,
entityId: entity.id
});
Expand All @@ -80,7 +77,6 @@ export function SampleCustomEntityCollection() {
const propertyKey = column.key;

let disabled = column.custom?.disabled;
const propertyValue = entity.values ? getValueInPath(entity.values, propertyKey) : undefined;

if (columnIndex === 0) {
return <EntityCollectionRowActions entity={entity}
Expand All @@ -90,7 +86,6 @@ export function SampleCustomEntityCollection() {

const property = getPropertyFor({
propertyKey,
propertyValue,
entity
});
if (!property?.disabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,17 @@ export const testCollection = buildCollection({
fromTo: "Saturation available range",
}
},
value: ({ propertyValue, index }) => {
value: (props) => {
const { propertyValue } = props;
// console.log("props", props);
if (propertyValue?.type === "oneNum") {
return ({
name: "Saturation",
dataType: "number",
validation: { min: 0, max: 100 }
validation: {
min: 0,
max: 100
}
})
} else if (propertyValue?.type === "fromTo") {
return ({
Expand Down Expand Up @@ -148,6 +153,38 @@ export const testCollection = buildCollection({
}
},
},
map: {
name: "Map",
dataType: "map",
properties: {
nested_1: {
name: "Nested 1",
dataType: "map",
properties: {
nested_2: {
name: "Nested 2",
dataType: "map",
properties: {
nested_3: {
name: "Nested 3",
dataType: "map",
properties: {
name: {
name: "Name",
dataType: "string"
},
num: {
name: "Num",
dataType: "number"
}
}
}
}
}
}
}
}
},
array_enum: {
name: "Array enum",
dataType: "array",
Expand Down
1 change: 0 additions & 1 deletion packages/data_import_export/src/utils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export function processValueMapping(value: any, property?: PropertyOrBuilder): a
if (property === undefined) return value;
const usedProperty: ResolvedProperty | null = resolveProperty({
propertyOrBuilder: property,
propertyValue: value
})
if (usedProperty === null) return value;
const from = inferTypeFromValue(value);
Expand Down
10 changes: 0 additions & 10 deletions packages/firecms_core/jest.config.js

This file was deleted.

262 changes: 140 additions & 122 deletions packages/firecms_core/package.json
Original file line number Diff line number Diff line change
@@ -1,125 +1,143 @@
{
"name": "@firecms/core",
"type": "module",
"version": "3.0.0-canary.45",
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
"funding": {
"url": "https://github.com/sponsors/firecmsco"
},
"author": "FireCMS",
"license": "MIT",
"repository": "git@github.com:FireCMSco/firecms.git",
"main": "./dist/index.umd.js",
"module": "./dist/index.es.js",
"types": "./dist/index.d.ts",
"source": "src/index.ts",
"engines": {
"node": ">=14"
},
"keywords": [
"firebase",
"cms",
"admin",
"admin panel",
"firebase panel",
"firestore",
"headless",
"headless cms",
"content manager"
],
"scripts": {
"watch": "vite build --watch",
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
"prepublishOnly": "run-s build",
"createTag": "PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$PACKAGE_VERSION && git push --tags",
"test:lint": "eslint \"src/**\" --quiet",
"test": "jest",
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
"generateIcons": "ts-node --esm src/icons/generateIcons.ts"
},
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js",
"types": "./dist/index.d.ts"
"name": "@firecms/core",
"type": "module",
"version": "3.0.0-canary.45",
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
"funding": {
"url": "https://github.com/sponsors/firecmsco"
},
"./package.json": "./package.json"
},
"dependencies": {
"@firecms/formex": "^3.0.0-canary.45",
"@firecms/ui": "^3.0.0-canary.45",
"@fontsource/jetbrains-mono": "^5.0.19",
"@hello-pangea/dnd": "^16.6.0",
"@radix-ui/react-portal": "^1.0.4",
"clsx": "^2.1.0",
"date-fns": "^3.6.0",
"history": "^5.3.0",
"js-search": "^2.0.1",
"markdown-it": "^14.1.0",
"notistack": "^3.0.1",
"object-hash": "^3.0.0",
"react-dropzone": "^14.2.3",
"react-fast-compare": "^3.2.2",
"react-image-file-resizer": "^0.4.8",
"react-markdown-editor-lite": "^1.3.4",
"react-transition-group": "^4.4.5",
"react-use-measure": "^2.1.1",
"react-window": "^1.8.10",
"typeface-rubik": "^1.1.13",
"yup": "^0.32.11"
},
"peerDependencies": {
"firebase": "^10.5.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.22.0",
"react-router-dom": "^6.22.0"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.3.1",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.7",
"@types/object-hash": "^3.0.6",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@types/react-measure": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@vitejs/plugin-react": "^4.2.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"firebase": "^10.11.0",
"jest": "^29.7.0",
"npm-run-all": "^4.1.5",
"react-router": "^6.22.3",
"react-router-dom": "^6.22.3",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tsd": "^0.31.0",
"typescript": "^5.4.5",
"vite": "^5.2.9"
},
"files": [
"dist",
"src"
],
"gitHead": "7f22bfa3bb20479ad23becd9c10f78cac1a3bc32",
"publishConfig": {
"access": "public"
}
"author": "FireCMS",
"license": "MIT",
"repository": "git@github.com:FireCMSco/firecms.git",
"main": "./dist/index.umd.js",
"module": "./dist/index.es.js",
"types": "./dist/index.d.ts",
"source": "src/index.ts",
"engines": {
"node": ">=14"
},
"keywords": [
"firebase",
"cms",
"admin",
"admin panel",
"firebase panel",
"firestore",
"headless",
"headless cms",
"content manager"
],
"scripts": {
"watch": "vite build --watch",
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
"prepublishOnly": "run-s build",
"createTag": "PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$PACKAGE_VERSION && git push --tags",
"test:lint": "eslint \"src/**\" --quiet",
"test": "jest",
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
"generateIcons": "ts-node --esm src/icons/generateIcons.ts"
},
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"dependencies": {
"@firecms/formex": "^3.0.0-canary.45",
"@firecms/ui": "^3.0.0-canary.45",
"@fontsource/jetbrains-mono": "^5.0.19",
"@hello-pangea/dnd": "^16.6.0",
"@radix-ui/react-portal": "^1.0.4",
"clsx": "^2.1.0",
"date-fns": "^3.6.0",
"history": "^5.3.0",
"js-search": "^2.0.1",
"markdown-it": "^14.1.0",
"notistack": "^3.0.1",
"object-hash": "^3.0.0",
"react-dropzone": "^14.2.3",
"react-fast-compare": "^3.2.2",
"react-image-file-resizer": "^0.4.8",
"react-markdown-editor-lite": "^1.3.4",
"react-transition-group": "^4.4.5",
"react-use-measure": "^2.1.1",
"react-window": "^1.8.10",
"typeface-rubik": "^1.1.13",
"yup": "^0.32.11"
},
"peerDependencies": {
"firebase": "^10.5.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.22.0",
"react-router-dom": "^6.22.0"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@types/jest": "^29.5.12",
"@testing-library/react": "^14.3.1",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^20.12.7",
"@types/object-hash": "^3.0.6",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@types/react-measure": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@vitejs/plugin-react": "^4.2.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"firebase": "^10.11.0",
"jest": "^29.7.0",
"npm-run-all": "^4.1.5",
"react-router": "^6.22.3",
"react-router-dom": "^6.22.3",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tsd": "^0.31.0",
"typescript": "^5.4.5",
"vite": "^5.2.9"
},
"files": [
"dist",
"src"
],
"gitHead": "7f22bfa3bb20479ad23becd9c10f78cac1a3bc32",
"publishConfig": {
"access": "public"
},

"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"testEnvironment": "node",
"moduleNameMapper": {
"\\.(css|less)$": "<rootDir>/test/__mocks__/styleMock.js"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
const propertyKey = column.key;

let disabled = column.custom?.disabled;
const propertyValue = entity.values ? getValueInPath(entity.values, propertyKey) : undefined;
const property = getPropertyFor?.({
propertyKey,
propertyValue,
entity
}) ?? column.custom.resolvedProperty;
if (!property?.disabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ export type EntityCollectionTableProps<M extends Record<string, any>,

export type GetPropertyForProps<M extends Record<string, any>> = {
propertyKey: string,
propertyValue: any,
entity: Entity<M>
};

Expand Down
Loading

0 comments on commit cea8107

Please sign in to comment.