From c11c82ca12c4d87742a47eeafcacbfe5a79a13dd Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Mon, 18 Sep 2023 10:14:40 +0300 Subject: [PATCH] fix: re-order change and analysis modal titles and add overflow Overflow on last item now shows ellipses Closes #1379 --- .../ConfigAnalysis/ConfigInsightsList.tsx | 2 +- .../ConfigInsightsDetailsModal.tsx | 32 +++++++++-------- src/components/ConfigChangeHistory/index.tsx | 6 ++-- .../ConfigDetailsChanges.tsx | 36 ++++++++++--------- src/components/ConfigLink/ConfigLink.tsx | 10 +++--- src/components/Modal/ModalTitleListItems.tsx | 24 +++++++++++++ 6 files changed, 69 insertions(+), 41 deletions(-) create mode 100644 src/components/Modal/ModalTitleListItems.tsx diff --git a/src/components/ConfigAnalysis/ConfigInsightsList.tsx b/src/components/ConfigAnalysis/ConfigInsightsList.tsx index fb0ccc57d4..37a1a162ac 100644 --- a/src/components/ConfigAnalysis/ConfigInsightsList.tsx +++ b/src/components/ConfigAnalysis/ConfigInsightsList.tsx @@ -1,6 +1,6 @@ import { SortingState } from "@tanstack/react-table"; import { useMemo, useState } from "react"; -import { useParams, useSearchParams } from "react-router-dom"; +import { useSearchParams } from "react-router-dom"; import { useConfigInsightsQuery } from "../../api/query-hooks/useConfigAnalysisQuery"; import ConfigInsightsDetailsModal from "../ConfigAnalysisLink/ConfigInsightsDetailsModal"; import { ConfigTypeInsights } from "../ConfigInsights"; diff --git a/src/components/ConfigAnalysisLink/ConfigInsightsDetailsModal.tsx b/src/components/ConfigAnalysisLink/ConfigInsightsDetailsModal.tsx index eaf075c7bf..df7105c2a7 100644 --- a/src/components/ConfigAnalysisLink/ConfigInsightsDetailsModal.tsx +++ b/src/components/ConfigAnalysisLink/ConfigInsightsDetailsModal.tsx @@ -10,6 +10,7 @@ import ConfigLink from "../ConfigLink/ConfigLink"; import { DescriptionCard } from "../DescriptionCard"; import { Modal } from "../Modal"; import TextSkeletonLoader from "../SkeletonLoader/TextSkeletonLoader"; +import ModalTitleListItems from "../Modal/ModalTitleListItems"; type Props = { id?: string; @@ -35,10 +36,10 @@ export default function ConfigInsightsDetailsModal({ { label: "Type", value: ( - <> +
{configInsight?.analysis_type} - +
) }, { @@ -75,18 +76,21 @@ export default function ConfigInsightsDetailsModal({ return ( - - {" / "} - - {configInsight.analyzer} - + + + {configInsight.analyzer} + , + + ]} + /> } open={isOpen} onClose={() => { diff --git a/src/components/ConfigChangeHistory/index.tsx b/src/components/ConfigChangeHistory/index.tsx index 4dbd5f0fd5..7ab2d0c3bf 100644 --- a/src/components/ConfigChangeHistory/index.tsx +++ b/src/components/ConfigChangeHistory/index.tsx @@ -1,14 +1,12 @@ import { ColumnDef } from "@tanstack/table-core"; import { useState } from "react"; -import { useGetConfigByIdQuery } from "../../api/query-hooks"; import { ConfigTypeChanges } from "../ConfigChanges"; import ConfigLink from "../ConfigLink/ConfigLink"; - +import { useGetConfigChangesByConfigChangeIdQuery } from "../../api/query-hooks/useGetConfigChangesByConfigChangeIdQuery"; +import { ConfigDetailChangeModal } from "../ConfigDetailsChanges/ConfigDetailsChanges"; import { DateCell } from "../ConfigViewer/columns"; import { PaginationOptions } from "../DataTable"; import { DataTable, Icon } from "../index"; -import { ConfigDetailChangeModal } from "../ConfigDetailsChanges/ConfigDetailsChanges"; -import { useGetConfigChangesByConfigChangeIdQuery } from "../../api/query-hooks/useGetConfigChangesByConfigChangeIdQuery"; const columns: ColumnDef[] = [ { diff --git a/src/components/ConfigDetailsChanges/ConfigDetailsChanges.tsx b/src/components/ConfigDetailsChanges/ConfigDetailsChanges.tsx index e7a8aa35b5..be21f87fee 100644 --- a/src/components/ConfigDetailsChanges/ConfigDetailsChanges.tsx +++ b/src/components/ConfigDetailsChanges/ConfigDetailsChanges.tsx @@ -17,6 +17,7 @@ import { JSONViewer } from "../JSONViewer"; import { Modal } from "../Modal"; import TextSkeletonLoader from "../SkeletonLoader/TextSkeletonLoader"; import ConfigChangeDetailSection from "./ConfigChangeDetailsSection"; +import ModalTitleListItems from "../Modal/ModalTitleListItems"; type ConfigDetailsChangesProps = { id: string; @@ -200,22 +201,25 @@ export function ConfigDetailChangeModal({ - - / - - {changeDetails?.change_type} - + + + {changeDetails?.change_type} + , + + ]} + /> ) } open={open} diff --git a/src/components/ConfigLink/ConfigLink.tsx b/src/components/ConfigLink/ConfigLink.tsx index 5412054fe1..7bdea97696 100644 --- a/src/components/ConfigLink/ConfigLink.tsx +++ b/src/components/ConfigLink/ConfigLink.tsx @@ -13,14 +13,14 @@ type ConfigLinkProps = { variant?: "label" | "link"; target?: HTMLAttributeAnchorTarget; }; + export default function ConfigLink({ configId, configName, configType, configTypeSecondary, variant = "link", - className = "text-zinc-600 text-sm", - ...props + className = "text-zinc-600 text-sm" }: ConfigLinkProps) { if (variant === "link") { return ( @@ -35,7 +35,7 @@ export default function ConfigLink({ type: configType }} /> -
{configName}
+
{configName}
); } @@ -46,9 +46,7 @@ export default function ConfigLink({ secondary={configTypeSecondary} className="w-5 mr-1 h-5" /> -
- {configName} -
+
{configName}
); } diff --git a/src/components/Modal/ModalTitleListItems.tsx b/src/components/Modal/ModalTitleListItems.tsx new file mode 100644 index 0000000000..41defbb49e --- /dev/null +++ b/src/components/Modal/ModalTitleListItems.tsx @@ -0,0 +1,24 @@ +import { ReactNode } from "react"; + +type ModalTitleListItemsProps = { + items: ReactNode[]; +}; + +export default function ModalTitleListItems({ + items +}: ModalTitleListItemsProps) { + return ( +
+ {items.map((item, idx) => { + return ( + <> + {item} + {idx !== items.length - 1 && ( + / + )} + + ); + })} +
+ ); +}