From d73fbad635a036ade87c2da6706ae28d9cdcdc50 Mon Sep 17 00:00:00 2001 From: Mansi Shinde Date: Mon, 11 Dec 2023 15:24:27 -0500 Subject: [PATCH] sort by managed policy feature Signed-off-by: Mansi Shinde --- .../BackingIndices/BackingIndices.tsx | 2 +- .../__snapshots__/Indices.test.tsx.snap | 20 ++++++++---- public/pages/Indices/utils/constants.tsx | 2 +- server/services/IndexService.ts | 32 +++++++++++++++---- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/public/pages/CreateDataStream/containers/BackingIndices/BackingIndices.tsx b/public/pages/CreateDataStream/containers/BackingIndices/BackingIndices.tsx index b7f327a83..9f941c933 100644 --- a/public/pages/CreateDataStream/containers/BackingIndices/BackingIndices.tsx +++ b/public/pages/CreateDataStream/containers/BackingIndices/BackingIndices.tsx @@ -103,7 +103,7 @@ export default function BackingIndices(props: SubDetailProps) { { field: "managed", name: "Managed by policy", - sortable: false, + sortable: true, truncateText: true, textOnly: true, render: renderNumber, diff --git a/public/pages/Indices/containers/Indices/__snapshots__/Indices.test.tsx.snap b/public/pages/Indices/containers/Indices/__snapshots__/Indices.test.tsx.snap index 6eba9f596..191b4b655 100644 --- a/public/pages/Indices/containers/Indices/__snapshots__/Indices.test.tsx.snap +++ b/public/pages/Indices/containers/Indices/__snapshots__/Indices.test.tsx.snap @@ -349,21 +349,29 @@ exports[` spec renders the component 1`] = ` - - Managed by policy + + Managed by policy + - + ({ - ...catIndex, - managed: managedStatus[catIndex.index] ? "Yes" : "No", - managedPolicy: managedStatus[catIndex.index], - })), + indices: paginatedIndices + .map((catIndex: CatIndex) => ({ + ...catIndex, + managed: managedStatus[catIndex.index] ? "Yes" : "No", + managedPolicy: managedStatus[catIndex.index], + })) + .sort((a, b) => { + let flag; + const aManaged = a.managed as string; + const bManaged = b.managed as string; + + if (sortDirection === "asc") { + flag = aManaged < bManaged; + } else { + flag = aManaged > bManaged; + } + + return flag ? -1 : 1; + }), totalIndices: filteredIndices.length, }, },