Migrating from version 1.0 to 2.0
important
FireCMS 2.0 is in alpha and the changes proposed here may break or not be relevant in future iterations
This is a guide on how to migrate FireCMS apps from version 1.0 to 2.0.
Main config​
The main navigation has been revamped:
- The
navigation
prop has been removed and replaced withcollections
andviews
. - If you need to have dynamic collections or views based on the user or other config,
you can use a
EntityCollectionsBuilder
orCMSViewsBuilder
in an analogous way to v1.
Collections​
Collections and entity schemas have been merged into one single concept. All the fields related to entity schemas have been moved to the collection level. We felt it was redundant, and the distribution of logic between those 2 concepts felt arbitrary.
Most of the new props in EntityCollection
have the same signature as the
previous existing ones in EntitySchema
, so you will be able to copy and paste
most of the config:
Code in version 1.0​
const usersSchema = buildSchema(
{
name: "User",
properties: {
display_name: buildProperty({
dataType: "string",
title: "Display name"
}),
email: {
dataType: "string",
title: "Email",
validation: {
email: true
}
}
}
});
const usersCollection = buildCollection({
path: "users",
schema: usersSchema,
name: "Users",
callbacks: {
onPreSave: ({ values }: EntityOnSaveProps<any, any>) =>{
return values;
}
},
properties: ["display_name", "email", "country_code", "birth_year", "photo_url", "current_level", "level_points", "current_habit_refs", "challenge_id"],
textSearchEnabled: true
});
Code in version 2.0​
const usersCollection = buildCollection({
path: "users",
name: "User",
properties: {
display_name: buildProperty({
dataType: "string",
name: "Display name"
}),
email: {
dataType: "string",
name: "Email",
validation: {
email: true
}
}
}
callbacks: {
onPreSave: ({ values }: EntityOnSaveProps<any, any>) =>{
return values;
}
},
textSearchEnabled: true
});
Properties​
- The
title
prop of properties has been renamed toname
. Note that this is a critical update, and you might get a cryptic typescript error if not done - All the configuration options that were located under the
config
prop ofproperties
have been moved to the property level
buildProperty<string>({
dataType: "string",
title: "Currency",
config: {
enumValues: {
EUR: "Euros",
DOL: "Dollars"
}
},
validation: {
required: true
}
});
now becomes:
buildProperty<string>({
dataType: "string",
name: "Currency",
enumValues: {
EUR: "Euros",
DOL: "Dollars"
},
validation: {
required: true
}
});
TimestampProperty
is now renamed toDateProperty
in order to reflect better the alignment with JS types instead of Firebase ones. The discriminator when declaring date properties now isdate
instead oftimestamp
.PreviewComponent
has been renamed toPropertyPreview
PreviewComponentProps
has been renamed toPropertyPreviewProps
Validation: The
email
andurl
validation prop in string properties are now placed at the property level (not undervalidation
).url
now only takes a boolean value instead of the preview type.storageMeta
prop in string properties is now calledstorage
name
inFieldProps
which refers to a property key, is now calledpropertyKey
name
inPreviewComponent
which refers to a property key, is now calledpropertyKey
name
inCMSFormFieldProps
which refers to a property key, is now calledpropertyKey
Removed
mediaType
in the storage configuration of string properties. It is now inferred automatically.toolbarActionsBuilder
inCollectionTable
has been replaced by a prop where you pass a React Component directly:Actions
toolbarActionsBuilder
inCollectionTable
has been replaced by a prop where you pass a React Component directly:Actions
Enum values: if you are using enum values with custom configurations, you need to include the id in the new object as well
skipLoginButtonEnabled
renamed toallowSkipLogin
inFirebaseLoginViewProps
buildProperty(({ values }) => ({
title: "Status",
dataType: "string",
enumValues: {
published: {
id: "published", // new compulsory field
label: "Published",
disabled: !values.header_image,
},
draft: "Draft"
}
}))