From dd42dbe0cd6c571ad0de2479d13fe7511e9f1296 Mon Sep 17 00:00:00 2001 From: Si Tang Date: Mon, 21 Feb 2022 22:12:27 +0900 Subject: [PATCH] #867: add a view for comparing schema versions (#1044) * #867: add a view for comparing schema versions * fixing test for diff component * adding color to lines which are different in versions * adding function to determine schema type and display correct format when comparing versions * removing unneccessary style * changing fetch approach and fixing test issue * fixinf schema versions comparision path change approach * remove unnecessary code * removing enzyme,removing direct use of Colors and adding dispatch to array of deps * added requested changes * makeing requested changes Co-authored-by: NelyDavtyan Co-authored-by: Roman Zabaluev Co-authored-by: NelyDavtyan <96067981+NelyDavtyan@users.noreply.github.com> --- .../components/Schemas/Details/Details.tsx | 18 +- .../components/Schemas/Diff/Diff.styled.ts | 58 ++++++ .../src/components/Schemas/Diff/Diff.tsx | 179 ++++++++++++++++++ .../components/Schemas/Diff/DiffContainer.ts | 32 ++++ .../Schemas/Diff/__test__/Diff.spec.tsx | 127 +++++++++++++ .../Schemas/Diff/__test__/fixtures.ts | 31 +++ .../src/components/Schemas/Schemas.tsx | 7 + .../src/components/common/Button/Button.tsx | 2 +- .../common/DiffViewer/DiffViewer.tsx | 51 +++++ .../DiffViewer/__tests__/DiffViewer.spec.tsx | 56 ++++++ kafka-ui-react-app/src/lib/paths.ts | 4 + 11 files changed, 562 insertions(+), 3 deletions(-) create mode 100644 kafka-ui-react-app/src/components/Schemas/Diff/Diff.styled.ts create mode 100644 kafka-ui-react-app/src/components/Schemas/Diff/Diff.tsx create mode 100644 kafka-ui-react-app/src/components/Schemas/Diff/DiffContainer.ts create mode 100644 kafka-ui-react-app/src/components/Schemas/Diff/__test__/Diff.spec.tsx create mode 100644 kafka-ui-react-app/src/components/Schemas/Diff/__test__/fixtures.ts create mode 100644 kafka-ui-react-app/src/components/common/DiffViewer/DiffViewer.tsx create mode 100644 kafka-ui-react-app/src/components/common/DiffViewer/__tests__/DiffViewer.spec.tsx diff --git a/kafka-ui-react-app/src/components/Schemas/Details/Details.tsx b/kafka-ui-react-app/src/components/Schemas/Details/Details.tsx index 2fc85812ef..9a79cbbf79 100644 --- a/kafka-ui-react-app/src/components/Schemas/Details/Details.tsx +++ b/kafka-ui-react-app/src/components/Schemas/Details/Details.tsx @@ -1,6 +1,10 @@ import React from 'react'; import { useHistory, useParams } from 'react-router'; -import { clusterSchemasPath, clusterSchemaEditPath } from 'lib/paths'; +import { + clusterSchemasPath, + clusterSchemaSchemaDiffPath, + clusterSchemaEditPath, +} from 'lib/paths'; import ClusterContext from 'components/contexts/ClusterContext'; import ConfirmationModal from 'components/common/ConfirmationModal/ConfirmationModal'; import PageLoader from 'components/common/PageLoader/PageLoader'; @@ -77,12 +81,22 @@ const Details: React.FC = () => { if (!isFetched || !schema) { return ; } - return ( <> {!isReadOnly && ( <> +