Skip to content

Commit

Permalink
Merge pull request #3377 from opral/lixfm-1-checkpoint-timeline
Browse files Browse the repository at this point in the history
Add LIXFM–1 checkpoint timeline
  • Loading branch information
NiklasBuchfink authored Jan 29, 2025
2 parents 103d3bc + 175f7f9 commit 54f4b86
Show file tree
Hide file tree
Showing 26 changed files with 2,504 additions and 1,336 deletions.
23 changes: 23 additions & 0 deletions .changeset/shy-lizards-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
"lix-file-manager": patch
"@lix-js/plugin-csv": patch
"@lix-js/sdk": patch
---

@lix-js/sdk:
- define UiDiffComponent type
- diff components can now consume multiple diffs

@lix-js/plugin-csv:
- update to use new diff component type
- display multiple diffs in a single component
- add rowId to snapshot content
- group diffs by rowId

lix-file-manager:
- add checkpoint timeline instead of change list
- refactor API diff component rendering
- refactor queries to use new UiDiffComponent type

PR URL:
https://github.com/opral/monorepo/pull/3377
4 changes: 2 additions & 2 deletions packages/lix-file-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
"native-file-system-adapter": "^3.0.1",
"papaparse": "^5.4.1",
"posthog-js": "^1.91.1",
"react": "^18.3.1",
"react": "^19.0.0",
"react-datasheet-grid": "^4.11.4",
"react-dom": "^18.3.1",
"react-dom": "^19.0.0",
"react-dropzone": "^14.2.10",
"react-error-boundary": "^4.1.2",
"react-hook-form": "^7.53.2",
Expand Down
192 changes: 0 additions & 192 deletions packages/lix-file-manager/src/components/ChangeComponent.tsx

This file was deleted.

51 changes: 51 additions & 0 deletions packages/lix-file-manager/src/components/ChangeDiffComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { useEffect, useState } from "react";
import { UiDiffComponentProps } from "@lix-js/sdk";
import { lixAtom } from "@/state.ts";
import { useAtom } from "jotai/react";
import clsx from "clsx";

export const ChangeDiffComponent = (props: {
diffs: UiDiffComponentProps["diffs"];
className?: string;
}) => {
const [lix] = useAtom(lixAtom);
const [isComponentLoaded, setIsComponentLoaded] = useState(false);

const pluginKey = props.diffs[0]?.plugin_key;
const CustomElementName = `diff-${pluginKey.replace(/_/g, "-")}`;

useEffect(() => {
const loadDiffComponent = async () => {
const component = (await lix.plugin.getAll()).find(
(p) => p.key === pluginKey
)?.diffUiComponent;

if (!customElements.get(CustomElementName)) {
if (component) {
customElements.define(CustomElementName, component);
setIsComponentLoaded(true);
} else {
console.warn(`No diff UI component found for plugin key '${pluginKey}'`);
// Fallback logic
}
} else {
setIsComponentLoaded(true);
}
};

loadDiffComponent();
}, [lix, pluginKey]);

if (!isComponentLoaded) {
return null;
}

return (
<div className={clsx("w-full overflow-x-auto pb-4", props.className)}>
<CustomElementName
// @ts-expect-error - Custom element props
diffs={props.diffs}
/>
</div>
);
};
5 changes: 3 additions & 2 deletions packages/lix-file-manager/src/components/ChangeDot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { cn } from "@/lib/utils.ts";
interface ChangeDotProps {
top?: boolean;
bottom?: boolean;
highlighted?: boolean;
}

const ChangeDot = ({ top, bottom }: ChangeDotProps) => {
const ChangeDot = ({ top, bottom, highlighted }: ChangeDotProps) => {
return (
<div className="flex flex-col justify-center items-center w-10 h-auto relative gap-0.5">
<div className={(cn("h-[17px] w-0.5", top && "bg-slate-200"))} />
<div className="flex-grow-0 flex-shrink-0 w-[7px] h-[7px] rounded bg-slate-700" />
<div className={(cn("flex-grow-0 flex-shrink-0 w-[7px] h-[7px] rounded", highlighted ? "bg-primary" : "bg-slate-700"))} />
<div className={(cn("flex-grow w-0.5", bottom && "bg-slate-200"))} />
</div>
)
Expand Down
Loading

0 comments on commit 54f4b86

Please sign in to comment.