mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-26 06:18:04 +00:00
* Introduced tsconfig.app.json and tsconfig.base.json * yarn.lock * Introduced tsconfig.app.json, tsconfig.base.jsonfig. * Refactored eslint.config.js to latest structure * Returned previous recommended rules. * More rules * Force import rules * Check * Check * Cleanup ESLint configuration and plugins * Cleanup heap: "writable",DD_RUM: "writable" from ESLint configuration * "scripts" moved to the top of package.json
71 lines
1.7 KiB
TypeScript
71 lines
1.7 KiB
TypeScript
import { Diff2HtmlUI } from "diff2html/lib/ui/js/diff2html-ui-base";
|
|
import hljs from "highlight.js/lib/core";
|
|
import yaml from "highlight.js/lib/languages/yaml";
|
|
import { useEffect, useRef } from "react";
|
|
|
|
import { diffConfiguration } from "../../../utils";
|
|
import Spinner from "../../Spinner";
|
|
|
|
hljs.registerLanguage("yaml", yaml);
|
|
|
|
interface ManifestDiffProps {
|
|
diff?: string;
|
|
isLoading: boolean;
|
|
error: string;
|
|
}
|
|
|
|
const ManifestDiff = ({ diff, isLoading, error }: ManifestDiffProps) => {
|
|
const diffContainerRef = useRef<HTMLDivElement | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (isLoading) {
|
|
// we're listening to isLoading to draw new diffs which are not
|
|
// always rerender, probably because of the use of ref
|
|
return;
|
|
}
|
|
|
|
if (diff && diffContainerRef.current) {
|
|
const diff2htmlUi = new Diff2HtmlUI(
|
|
diffContainerRef.current,
|
|
diff,
|
|
diffConfiguration,
|
|
hljs
|
|
);
|
|
diff2htmlUi.draw();
|
|
diff2htmlUi.highlightCode();
|
|
}
|
|
}, [diff, isLoading]);
|
|
|
|
if (isLoading && !error) {
|
|
return (
|
|
<div className="flex items-end text-lg">
|
|
<Spinner />
|
|
Calculating diff...
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<h4 className="text-xl">Manifest changes:</h4>
|
|
|
|
{error ? (
|
|
<p className="text-lg text-red-600">
|
|
Failed to get upgrade info: {error.toString()}
|
|
</p>
|
|
) : diff ? (
|
|
<div
|
|
ref={diffContainerRef}
|
|
className="relative overflow-y-auto leading-5"
|
|
></div>
|
|
) : (
|
|
<pre className="font-roboto text-base">
|
|
No changes will happen to the cluster
|
|
</pre>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default ManifestDiff;
|