Skip to content

Commit

Permalink
References preview fixes
Browse files Browse the repository at this point in the history
Some style updates.
  • Loading branch information
fgatti675 committed Dec 7, 2024
1 parent dc54521 commit 8f6af8f
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 25 deletions.
18 changes: 14 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@ If you would like to make changes to the source, feel free to submit a PR!

## Getting Started

You can find the source code for the library under `lib`.
The demo project used for development is under `example`.
This project is a monorepo managed with [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/).

After pulling the code you just need to run
You can find all the FireCMS packages in the `packages` folder.
The code that simulates a final project implemented by a user can be found in the `examples` folder.

All dependencies are linked automatically and just running the following commands should be enough to get you started.

After pulling the code you just need to run:

```bash
yarn
yarn dev
```

to start the demo project.

You can also run:
```bash
yarn
yarn pro
```
to use the example project with the Pro version of FireCMS.

## Support and discussion

Please join our [Discord channel](https://discord.gg/fxy7xsQm3m) to discuss any details regarding adaptations. We are
Expand Down
20 changes: 12 additions & 8 deletions examples/example_pro/src/FirestoreApp/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import CustomColorTextField from "./custom_field/CustomColorTextField";
import { booksCollection } from "./collections/books_collection";
import { FirebaseApp } from "@firebase/app";
import { TestEditorView } from "./views/TestEditorView";
import { useCollectionEditorPlugin } from "@firecms/collection_editor";
import { mergeCollections, useCollectionEditorPlugin } from "@firecms/collection_editor";
import { useFirestoreCollectionsConfigController } from "@firecms/collection_editor_firebase";
import { ReCaptchaEnterpriseProvider } from "@firebase/app-check";
import { useExportPlugin } from "@firecms/data_export";
Expand Down Expand Up @@ -231,11 +231,11 @@ export function App() {
if (process.env.NODE_ENV !== "production") {
sourceCollections.push(testCollection);
}
return sourceCollections;
// return mergeCollections(
// sourceCollections,
// collectionConfigController.collections ?? []
// )
// return sourceCollections;
return mergeCollections(
sourceCollections,
collectionConfigController.collections ?? []
);
}, [collectionConfigController.collections, secondaryFirestoreDelegate]);

const views: CMSView[] = useMemo(() => ([
Expand Down Expand Up @@ -348,8 +348,12 @@ export function App() {
dataSourceDelegate={firestoreDelegate}
storageSource={storageSource}

plugins={[userManagementPlugin, dataEnhancementPlugin, exportPlugin, demoPlugin
// collectionEditorPlugin
plugins={[
userManagementPlugin,
dataEnhancementPlugin,
exportPlugin,
demoPlugin,
collectionEditorPlugin
]}
onAnalyticsEvent={onAnalyticsEvent}
propertyConfigs={propertyConfigs}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export function SampleCollectionActions({ selectionController }: CollectionActio

return (
<Button onClick={onClick}
color="primary"
color="text"
variant={"text"}>
Extra action
Demo action
</Button>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const productsCollection = buildCollection<Product>({
create: true,
delete: true
}),
Actions: [SampleCollectionActions, CustomFiltersActions],
Actions: [SampleCollectionActions],
subcollections: [localeCollection],
// defaultSelectedView: "sample_custom_view",
entityViews: [
Expand Down
14 changes: 9 additions & 5 deletions packages/firecms_core/src/components/EntityPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ export function EntityPreview({
const titleProperty = getEntityTitlePropertyKey(resolvedCollection, customizationController.propertyConfigs);
const imagePropertyKey = getEntityImagePreviewPropertyKey(resolvedCollection);
const imageProperty = imagePropertyKey ? resolvedCollection.properties[imagePropertyKey] : undefined;
const usedImageProperty = "of" in imageProperty ? imageProperty.of : imageProperty;
const usedImageProperty = imageProperty && "of" in imageProperty ? imageProperty.of : imageProperty;
const restProperties = listProperties.filter(p => p !== titleProperty && p !== imagePropertyKey);

const imageValue = getValueInPath(entity.values, imagePropertyKey as string);
const usedImageValue = "of" in imageProperty ? ((imageValue ?? []).length > 0 ? imageValue[0] : undefined) : imageValue;
const imageValue = imagePropertyKey ? getValueInPath(entity.values, imagePropertyKey) : undefined;
const usedImageValue = imageProperty !== undefined ? ("of" in imageProperty
? ((imageValue ?? []).length > 0
? imageValue[0] : undefined)
: imageValue)
: undefined;

return <EntityPreviewContainer onClick={disabled ? undefined : onClick}
hover={disabled ? undefined : hover}
Expand Down Expand Up @@ -108,7 +112,7 @@ export function EntityPreview({
: <Skeleton/>)}

{titleProperty && (
<div className={"my-0.5 text-sm font-medium"}>
<div className={"truncate my-0.5 text-sm font-medium"}>
{
entity
? <PropertyPreview
Expand All @@ -129,7 +133,7 @@ export function EntityPreview({

return (
<div key={"ref_prev_" + key}
className={restProperties.length > 1 ? "my-0.5" : "my-0"}>
className={cls("truncate", restProperties.length > 1 ? "my-0.5" : "my-0")}>
{
entity
? <PropertyPreview
Expand Down
5 changes: 2 additions & 3 deletions packages/firecms_core/src/core/EntityEditView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
})?.toString()}
</>;
return (
<div>
<div key={`additional_${key}`}>
<LabelWithIconAndTooltip
propertyKey={key}
icon={<NotesIcon size={"small"}/>}
Expand All @@ -808,8 +808,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
})
.filter(Boolean)}

</>
);
</>);

const disabled = formex.isSubmitting || (!modified && status === "existing");
const formRef = React.useRef<HTMLDivElement>(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function KeyValuePreview({ value }: { value: any }) {
</div>
<div
className="flex-grow max-w-[75%]">
{childValue && ("toString" in childValue) && <Typography>
{childValue && <Typography>
<ErrorBoundary>
{childValue.toString()}
</ErrorBoundary>
Expand Down
2 changes: 1 addition & 1 deletion website/src/neat_colors.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"enabled": true
}
],
"speed": 3,
"speed": 2,
"horizontalPressure": 2,
"verticalPressure": 2,
"waveFrequencyX": 2,
Expand Down

0 comments on commit 8f6af8f

Please sign in to comment.