From eea5de67a22b0429506040285cde1d1e2d35739d Mon Sep 17 00:00:00 2001
From: hodanoori <107242553+hodanoori@users.noreply.github.com>
Date: Fri, 8 Nov 2024 15:45:52 +0100
Subject: [PATCH] feat(heureka): adds pagination for component instances on a
service details panel (#577)
* feat(heureka): adds pagination for component instances list on service details page
* chore(heureka): removes the commented out code
* chore(heureka): optimises graphql queries
* chore(heureka): adjusts tests
* chore(heureka): adds changeset
* feat(heureka): renames name to ccrn for Services, Components and Support Group in all queries
* feat(heureka): renames name to ccrn for Services, Components and Support Group in all queries
* feat(heureka): adds a test for ComponentInstancesList
* feat(heureka): add tests for pagination component
---
.changeset/grumpy-squids-hear.md | 6 ++
.../components/ComponentsListItem.jsx | 2 +-
.../issueMatches/IssueMatchesDetails.jsx | 6 +-
.../issueMatches/IssueMatchesListItem.jsx | 4 +-
.../services/ComponentInstancesList.jsx | 86 +++++++++++++++++++
.../components/services/ServicesDetails.jsx | 37 ++------
.../components/services/ServicesListItem.jsx | 10 +--
.../src/components/shared/HintNotFound.jsx | 6 +-
.../src/components/shared/ListController.jsx | 61 +++----------
.../components/shared/PaginationComponent.jsx | 56 ++++++++++++
.../shared/PaginationComponent.test.jsx | 79 +++++++++++++++++
apps/heureka/src/hooks/useQueryClientFn.js | 15 +++-
.../src/lib/queries/addRemoveServiceOwners.js | 2 +-
apps/heureka/src/lib/queries/components.js | 2 +-
apps/heureka/src/lib/queries/issueMatches.js | 10 +--
.../lib/queries/issueMatchesFilterValues.js | 4 +-
.../src/lib/queries/serviceFilterValues.js | 4 +-
apps/heureka/src/lib/queries/services.js | 79 ++++++++++-------
.../src/lib/slices/createGlobalsSlice.js | 5 ++
.../src/lib/slices/createGlobalsSlice.test.js | 1 +
20 files changed, 335 insertions(+), 140 deletions(-)
create mode 100644 .changeset/grumpy-squids-hear.md
create mode 100644 apps/heureka/src/components/services/ComponentInstancesList.jsx
create mode 100644 apps/heureka/src/components/shared/PaginationComponent.jsx
create mode 100644 apps/heureka/src/components/shared/PaginationComponent.test.jsx
diff --git a/.changeset/grumpy-squids-hear.md b/.changeset/grumpy-squids-hear.md
new file mode 100644
index 000000000..cfb28f741
--- /dev/null
+++ b/.changeset/grumpy-squids-hear.md
@@ -0,0 +1,6 @@
+---
+"@cloudoperators/juno-app-heureka": minor
+"@cloudoperators/juno-app-greenhouse": patch
+---
+
+The pagination is added to the list of component instances for a selected service on the service details page.
diff --git a/apps/heureka/src/components/components/ComponentsListItem.jsx b/apps/heureka/src/components/components/ComponentsListItem.jsx
index fd055cdd7..f98d8c5d8 100644
--- a/apps/heureka/src/components/components/ComponentsListItem.jsx
+++ b/apps/heureka/src/components/components/ComponentsListItem.jsx
@@ -14,7 +14,7 @@ const sumTotalInstances = (versions) => {
const ComponentsListItem = ({ item }) => {
return (
- {item?.node?.name}
+ {item?.node?.ccrn}
{item?.node?.type}
{item?.node?.componentVersions?.totalCount}
{sumTotalInstances(item?.node?.componentVersions?.edges)}
diff --git a/apps/heureka/src/components/issueMatches/IssueMatchesDetails.jsx b/apps/heureka/src/components/issueMatches/IssueMatchesDetails.jsx
index 3e3c4d24c..8e7722c51 100644
--- a/apps/heureka/src/components/issueMatches/IssueMatchesDetails.jsx
+++ b/apps/heureka/src/components/issueMatches/IssueMatchesDetails.jsx
@@ -77,7 +77,7 @@ const IssueMatchesDetails = () => {
Service Name
-
+
@@ -85,7 +85,7 @@ const IssueMatchesDetails = () => {
Support Group Name
-
+
@@ -93,7 +93,7 @@ const IssueMatchesDetails = () => {
Component Name
-
+
diff --git a/apps/heureka/src/components/issueMatches/IssueMatchesListItem.jsx b/apps/heureka/src/components/issueMatches/IssueMatchesListItem.jsx
index 3e2a3e647..54ea9e2fa 100644
--- a/apps/heureka/src/components/issueMatches/IssueMatchesListItem.jsx
+++ b/apps/heureka/src/components/issueMatches/IssueMatchesListItem.jsx
@@ -47,10 +47,10 @@ const IssueMatchesListItem = ({ item }) => {
{severity}
{item?.node?.issue?.primaryName}
- {item?.node?.componentInstance?.service?.name}
+ {item?.node?.componentInstance?.service?.ccrn}
{extractedCcrn}
- {listOfCommaSeparatedObjs(item?.node?.componentInstance?.service?.supportGroups, "name")}
+ {listOfCommaSeparatedObjs(item?.node?.componentInstance?.service?.supportGroups, "ccrn")}
{item?.node?.status}
{formatDate(item?.node?.targetRemediationDate)}
diff --git a/apps/heureka/src/components/services/ComponentInstancesList.jsx b/apps/heureka/src/components/services/ComponentInstancesList.jsx
new file mode 100644
index 000000000..cd5f6e5bb
--- /dev/null
+++ b/apps/heureka/src/components/services/ComponentInstancesList.jsx
@@ -0,0 +1,86 @@
+/*
+ * SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import React from "react"
+import { useQuery } from "@tanstack/react-query"
+import {
+ ContentHeading,
+ Container,
+ DataGrid,
+ DataGridRow,
+ DataGridCell,
+ DataGridHeadCell,
+} from "@cloudoperators/juno-ui-components"
+import { useGlobalsQueryClientFnReady, useGlobalsQueryOptions, useGlobalsActions } from "../StoreProvider"
+import LoadElement from "../shared/LoadElement"
+import { severityString, highestSeverity } from "../shared/Helper"
+import PaginationComponent from "../shared/PaginationComponent"
+import HintNotFound from "../shared/HintNotFound"
+
+const ComponentInstancesList = ({ serviceCcrn }) => {
+ const queryOptions = useGlobalsQueryOptions("ComponentInstancesOfService")
+ const { setQueryOptions } = useGlobalsActions()
+ const queryClientFnReady = useGlobalsQueryClientFnReady()
+
+ const { data, isLoading } = useQuery({
+ queryKey: [
+ "ComponentInstancesOfService",
+ {
+ ...queryOptions,
+ filter: { serviceCcrn: [serviceCcrn] },
+ },
+ ],
+ enabled: !!queryClientFnReady && !!serviceCcrn,
+ })
+
+ const items = data?.ComponentInstances?.edges || []
+
+ return (
+ <>
+
+
+
+ Component
+ Version
+ Total Number of Issues
+ Highest Severity
+
+ {isLoading ? (
+
+
+
+
+
+
+
+ ) : items.length === 0 ? (
+
+ ) : (
+ items.map((componentInstance, i) => (
+
+ {componentInstance?.node?.ccrn}
+
+ {componentInstance?.node?.componentVersion?.version}
+
+ {componentInstance?.node?.issueMatches?.totalCount}
+
+ {severityString(highestSeverity(componentInstance?.node?.issueMatches?.edges))}
+
+
+ ))
+ )}
+
+
+ >
+ )
+}
+
+export default ComponentInstancesList
diff --git a/apps/heureka/src/components/services/ServicesDetails.jsx b/apps/heureka/src/components/services/ServicesDetails.jsx
index 42f6baf87..cc4534f4d 100644
--- a/apps/heureka/src/components/services/ServicesDetails.jsx
+++ b/apps/heureka/src/components/services/ServicesDetails.jsx
@@ -24,7 +24,8 @@ import { useQuery, useMutation } from "@tanstack/react-query"
import LoadElement from "../shared/LoadElement"
import { useActions as messageActions } from "@cloudoperators/juno-messages-provider"
import { parseError } from "../../helpers"
-import { listOfCommaSeparatedObjs, severityString, highestSeverity } from "../shared/Helper"
+import { listOfCommaSeparatedObjs } from "../shared/Helper"
+import ComponentInstancesList from "./ComponentInstancesList"
const ServicesDetail = () => {
const showServiceDetail = useGlobalsShowServiceDetail()
@@ -32,7 +33,7 @@ const ServicesDetail = () => {
const { addMessage, resetMessages } = messageActions()
const serviceElem = useQuery({
- queryKey: ["ServicesDetails", { filter: { serviceName: [showServiceDetail] } }],
+ queryKey: ["ServicesDetails", { filter: { serviceCcrn: [showServiceDetail] } }],
enabled: !!queryClientFnReady && !!showServiceDetail,
})
@@ -216,41 +217,13 @@ const ServicesDetail = () => {
Support Group
- {listOfCommaSeparatedObjs(service?.supportGroups, "name")}} />
+ {listOfCommaSeparatedObjs(service?.supportGroups, "ccrn")}} />
-
-
-
- Component
- Version
- Total Number of Issues
- Highest Severity
-
- {!service?.componentInstances?.edges && (
-
-
-
-
-
- )}
-
- {service?.componentInstances?.edges?.map((componentInstance, i) => (
-
- {componentInstance?.node?.ccrn}
-
- {componentInstance?.node?.componentVersion?.version}
-
- {componentInstance?.node?.issueMatches?.totalCount}
-
- {severityString(highestSeverity(componentInstance?.node?.issueMatches?.edges))}
-
-
- ))}
-
+
>
)
diff --git a/apps/heureka/src/components/services/ServicesListItem.jsx b/apps/heureka/src/components/services/ServicesListItem.jsx
index 3b50f6c22..6199bc7aa 100644
--- a/apps/heureka/src/components/services/ServicesListItem.jsx
+++ b/apps/heureka/src/components/services/ServicesListItem.jsx
@@ -19,13 +19,13 @@ const ServicesListItem = ({ item }) => {
}, [item])
const handleClick = () => {
- if (showServiceDetail === service?.name && showPanel === constants.PANEL_SERVICE) {
+ if (showServiceDetail === service?.ccrn && showPanel === constants.PANEL_SERVICE) {
{
setShowServiceDetail(null)
setShowPanel(constants.PANEL_NONE)
}
} else {
- setShowServiceDetail(service?.name)
+ setShowServiceDetail(service?.ccrn)
setShowPanel(constants.PANEL_SERVICE)
}
}
@@ -33,13 +33,13 @@ const ServicesListItem = ({ item }) => {
return (
handleClick()}
>
- {service?.name}
+ {service?.ccrn}
{listOfCommaSeparatedObjs(service?.owners, "name")}
- {listOfCommaSeparatedObjs(service?.supportGroups, "name")}
+ {listOfCommaSeparatedObjs(service?.supportGroups, "ccrn")}
{service?.metadata?.componentInstanceCount}
{service?.metadata?.issueMatchCount}
diff --git a/apps/heureka/src/components/shared/HintNotFound.jsx b/apps/heureka/src/components/shared/HintNotFound.jsx
index 9a73ad493..d97a7288b 100644
--- a/apps/heureka/src/components/shared/HintNotFound.jsx
+++ b/apps/heureka/src/components/shared/HintNotFound.jsx
@@ -4,13 +4,13 @@
*/
import React from "react"
-import { Stack } from "@cloudoperators/juno-ui-components"
+import { Container } from "@cloudoperators/juno-ui-components"
const HintNotFound = ({ text }) => {
return (
-
+
{text}
-
+
)
}
diff --git a/apps/heureka/src/components/shared/ListController.jsx b/apps/heureka/src/components/shared/ListController.jsx
index 67ccea719..26f88300a 100644
--- a/apps/heureka/src/components/shared/ListController.jsx
+++ b/apps/heureka/src/components/shared/ListController.jsx
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import React, { useEffect, useMemo, useState } from "react"
+import React, { useEffect } from "react"
import { useQuery } from "@tanstack/react-query"
import {
useGlobalsQueryClientFnReady,
@@ -11,9 +11,9 @@ import {
useGlobalsActions,
useGlobalsActiveView,
} from "../StoreProvider"
-import { Pagination, Container, Stack } from "@cloudoperators/juno-ui-components"
import { useActions as messageActions } from "@cloudoperators/juno-messages-provider"
import { parseError } from "../../helpers"
+import PaginationComponent from "./PaginationComponent"
const ListController = ({ queryKey, entityName, ListComponent, activeFilters, searchTerm, enableSearchAndFilter }) => {
const queryClientFnReady = useGlobalsQueryClientFnReady()
@@ -60,12 +60,7 @@ const ListController = ({ queryKey, entityName, ListComponent, activeFilters, se
enabled: !!queryClientFnReady && queryKey === activeView,
})
- const [currentPage, setCurrentPage] = useState(1)
-
- const items = useMemo(() => {
- if (!mainData) return null
- return mainData?.[entityName]?.edges || []
- }, [mainData, entityName])
+ const items = mainData?.[entityName]?.edges || []
useEffect(() => {
if (!mainError && !countError) return resetMessages()
@@ -75,52 +70,16 @@ const ListController = ({ queryKey, entityName, ListComponent, activeFilters, se
})
}, [mainError, countError, addMessage, resetMessages])
- const pageInfo = useMemo(() => {
- if (!countData) return null
- return countData?.[entityName]?.pageInfo
- }, [countData, entityName])
-
- const totalPages = useMemo(() => {
- if (!pageInfo?.pages) return 0
- return pageInfo.pages.length
- }, [pageInfo])
-
- const onPaginationChanged = (newPage) => {
- setCurrentPage(newPage)
- if (!pageInfo?.pages) return
- const pages = pageInfo.pages
- const currentPageIndex = pages?.findIndex((page) => page?.pageNumber === parseInt(newPage))
- if (currentPageIndex > -1) {
- const after = pages[currentPageIndex]?.after
- setQueryOptions(queryKey, {
- ...queryOptions,
- after: `${after}`,
- })
- }
- }
-
return (
<>
-
-
- onPaginationChanged(currentPage + 1)}
- onPressPrevious={() => onPaginationChanged(currentPage - 1)}
- onKeyPress={(oKey) => {
- if (oKey.code === "Enter") {
- onPaginationChanged(parseInt(oKey.currentTarget.value))
- }
- }}
- onSelectChange={onPaginationChanged}
- pages={totalPages}
- variant="input"
- />
-
-
+
>
)
}
diff --git a/apps/heureka/src/components/shared/PaginationComponent.jsx b/apps/heureka/src/components/shared/PaginationComponent.jsx
new file mode 100644
index 000000000..376af67c7
--- /dev/null
+++ b/apps/heureka/src/components/shared/PaginationComponent.jsx
@@ -0,0 +1,56 @@
+/*
+ * SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import React, { useState } from "react"
+import { Pagination, Stack, Container } from "@cloudoperators/juno-ui-components"
+
+const PaginationComponent = ({ queryKey, queryOptions, entityName, setQueryOptions, countData }) => {
+ const [currentPage, setCurrentPage] = useState(1)
+
+ const pageInfo = countData?.[entityName]?.pageInfo || null
+ const totalPages = pageInfo?.pages?.length || 0
+
+ const onPaginationChanged = (newPage) => {
+ setCurrentPage(newPage)
+ if (!pageInfo?.pages) return
+ const pages = pageInfo.pages
+ const currentPageIndex = pages?.findIndex((page) => page?.pageNumber === parseInt(newPage))
+ if (currentPageIndex > -1) {
+ const after = pages[currentPageIndex]?.after
+ setQueryOptions(queryKey, {
+ ...queryOptions,
+ after: `${after}`,
+ })
+ }
+ }
+
+ const onKeyPress = (event) => {
+ if (event.code === "Enter") {
+ onPaginationChanged(event.currentTarget.value)
+ }
+ }
+
+ return (
+ <>
+
+
+ onPaginationChanged(currentPage + 1)}
+ onPressPrevious={() => onPaginationChanged(currentPage - 1)}
+ onKeyPress={onKeyPress}
+ onSelectChange={onPaginationChanged}
+ pages={totalPages}
+ variant="input"
+ />
+
+
+ >
+ )
+}
+
+export default PaginationComponent
diff --git a/apps/heureka/src/components/shared/PaginationComponent.test.jsx b/apps/heureka/src/components/shared/PaginationComponent.test.jsx
new file mode 100644
index 000000000..22af4742e
--- /dev/null
+++ b/apps/heureka/src/components/shared/PaginationComponent.test.jsx
@@ -0,0 +1,79 @@
+/*
+ * SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import React from "react"
+import { render, screen, fireEvent, waitFor } from "@testing-library/react"
+import { vi } from "vitest"
+import PaginationComponent from "./PaginationComponent"
+
+// Mocking queryOptions and countData props
+const mockSetQueryOptions = vi.fn()
+const mockQueryKey = "testQuery"
+const mockQueryOptions = {}
+const mockCountData = {
+ testEntity: {
+ pageInfo: {
+ pages: [
+ { pageNumber: 1, after: "1" },
+ { pageNumber: 2, after: "2" },
+ ],
+ },
+ },
+}
+
+test('should update currentPage when "Next Page" button is clicked', async () => {
+ render(
+
+ )
+
+ // Initial value should be "1"
+ expect(screen.getByRole("textbox").value).toBe("1")
+
+ // Simulate click on "Next Page"
+ fireEvent.click(screen.getByText(/Next Page/i))
+
+ // Wait for the currentPage to update to "2"
+ await waitFor(() => expect(screen.getByRole("textbox").value).toBe("2"))
+
+ // Verify that the `setQueryOptions` function was called with the correct after value for the next page
+ expect(mockSetQueryOptions).toHaveBeenCalledWith(mockQueryKey, {
+ ...mockQueryOptions,
+ after: "2",
+ })
+})
+
+test('should update currentPage when "Previous Page" button is clicked', async () => {
+ render(
+
+ )
+
+ // Simulate click on "Next Page" to go to page 2
+ fireEvent.click(screen.getByText(/Next Page/i))
+ expect(screen.getByRole("textbox").value).toBe("2")
+
+ // Simulate click on "Previous Page"
+ fireEvent.click(screen.getByText(/Previous Page/i))
+
+ // Wait for the currentPage to update to "1"
+ await waitFor(() => expect(screen.getByRole("textbox").value).toBe("1"))
+
+ // Verify that the `setQueryOptions` function was called with the correct after value for the previous page
+ expect(mockSetQueryOptions).toHaveBeenCalledWith(mockQueryKey, {
+ ...mockQueryOptions,
+ after: "1",
+ })
+})
diff --git a/apps/heureka/src/hooks/useQueryClientFn.js b/apps/heureka/src/hooks/useQueryClientFn.js
index 2d9c83b4c..9b1d4411d 100644
--- a/apps/heureka/src/hooks/useQueryClientFn.js
+++ b/apps/heureka/src/hooks/useQueryClientFn.js
@@ -7,7 +7,12 @@ import { useEffect } from "react"
import { useQueryClient } from "@tanstack/react-query"
import { useGlobalsApiEndpoint, useGlobalsActions } from "../components/StoreProvider"
import { request } from "graphql-request"
-import { servicesMainQuery, servicesDetailsQuery, servicesCountQuery } from "../lib/queries/services"
+import {
+ servicesMainQuery,
+ servicesDetailsQuery,
+ servicesCountQuery,
+ componentInstancesOfServiceQuery,
+} from "../lib/queries/services"
import { componentsMainQuery, componentsCountQuery } from "../lib/queries/components"
import { issueMatchesMainQuery, issueMatchesDetailsQuery, issueMatchesCountQuery } from "../lib/queries/issueMatches"
import serviceFilterValuesQuery from "../lib/queries/serviceFilterValues"
@@ -41,6 +46,14 @@ const useQueryClientFn = () => {
},
})
+ // ComponentInstances of a service query both for main and count info - for the service details page
+ queryClient.setQueryDefaults(["ComponentInstancesOfService"], {
+ queryFn: async ({ queryKey }) => {
+ const [_key, options] = queryKey
+ return await request(endpoint, componentInstancesOfServiceQuery(), options)
+ },
+ })
+
// Services count query (for totalCount and pageInfo)
queryClient.setQueryDefaults(["ServicesCount"], {
queryFn: async ({ queryKey }) => {
diff --git a/apps/heureka/src/lib/queries/addRemoveServiceOwners.js b/apps/heureka/src/lib/queries/addRemoveServiceOwners.js
index 0c4ae1289..732ac079e 100644
--- a/apps/heureka/src/lib/queries/addRemoveServiceOwners.js
+++ b/apps/heureka/src/lib/queries/addRemoveServiceOwners.js
@@ -14,7 +14,7 @@ export default (serviceId, userId, action) => {
const mutation = `mutation ($serviceId: ID!, $userId: ID!) {
${mutationName}(serviceId: $serviceId, userId: $userId) {
id
- name
+ ccrn
owners {
edges {
node {
diff --git a/apps/heureka/src/lib/queries/components.js b/apps/heureka/src/lib/queries/components.js
index fa51ffd21..27c4339af 100644
--- a/apps/heureka/src/lib/queries/components.js
+++ b/apps/heureka/src/lib/queries/components.js
@@ -16,7 +16,7 @@ export const componentsMainQuery = () => gql`
edges {
node {
id
- name
+ ccrn
type
componentVersions {
totalCount
diff --git a/apps/heureka/src/lib/queries/issueMatches.js b/apps/heureka/src/lib/queries/issueMatches.js
index e406f08b6..c5840ad73 100644
--- a/apps/heureka/src/lib/queries/issueMatches.js
+++ b/apps/heureka/src/lib/queries/issueMatches.js
@@ -34,7 +34,7 @@ export const issueMatchesMainQuery = () => gql`
ccrn
count
service {
- name
+ ccrn
owners {
edges {
node {
@@ -48,7 +48,7 @@ export const issueMatchesMainQuery = () => gql`
supportGroups {
edges {
node {
- name
+ ccrn
}
}
}
@@ -98,11 +98,11 @@ export const issueMatchesDetailsQuery = () => gql`
componentVersion {
version
component {
- name
+ ccrn
}
}
service {
- name
+ ccrn
owners {
edges {
node {
@@ -116,7 +116,7 @@ export const issueMatchesDetailsQuery = () => gql`
supportGroups {
edges {
node {
- name
+ ccrn
}
}
}
diff --git a/apps/heureka/src/lib/queries/issueMatchesFilterValues.js b/apps/heureka/src/lib/queries/issueMatchesFilterValues.js
index 7c8422967..167ab66fb 100644
--- a/apps/heureka/src/lib/queries/issueMatchesFilterValues.js
+++ b/apps/heureka/src/lib/queries/issueMatchesFilterValues.js
@@ -32,12 +32,12 @@ export default () => gql`
filterName
values
}
- componentName {
+ componentCcrn {
displayName
filterName
values
}
- supportGroupName {
+ supportGroupCcrn {
displayName
filterName
values
diff --git a/apps/heureka/src/lib/queries/serviceFilterValues.js b/apps/heureka/src/lib/queries/serviceFilterValues.js
index b73b5a87e..1d943cd4d 100644
--- a/apps/heureka/src/lib/queries/serviceFilterValues.js
+++ b/apps/heureka/src/lib/queries/serviceFilterValues.js
@@ -12,12 +12,12 @@ import { gql } from "graphql-request"
export default () => gql`
query {
ServiceFilterValues {
- serviceName {
+ serviceCcrn {
displayName
filterName
values
}
- supportGroupName {
+ supportGroupCcrn {
displayName
filterName
values
diff --git a/apps/heureka/src/lib/queries/services.js b/apps/heureka/src/lib/queries/services.js
index 1996384fd..36692c91a 100644
--- a/apps/heureka/src/lib/queries/services.js
+++ b/apps/heureka/src/lib/queries/services.js
@@ -16,7 +16,7 @@ export const servicesMainQuery = () => gql`
edges {
node {
id
- name
+ ccrn
metadata {
componentInstanceCount
issueMatchCount
@@ -35,7 +35,7 @@ export const servicesMainQuery = () => gql`
edges {
node {
id
- name
+ ccrn
}
cursor
}
@@ -53,7 +53,7 @@ export const servicesDetailsQuery = () => gql`
edges {
node {
id
- name
+ ccrn
metadata {
componentInstanceCount
issueMatchCount
@@ -69,39 +69,12 @@ export const servicesDetailsQuery = () => gql`
}
}
supportGroups {
- edges {
- node {
- id
- name
- }
- cursor
- }
- }
- componentInstances {
edges {
node {
id
ccrn
- count
- componentVersion {
- version
- component {
- name
- }
- }
- issueMatches(first: 10000) {
- totalCount
- edges {
- node {
- id
- severity {
- value
- score
- }
- }
- }
- }
}
+ cursor
}
}
}
@@ -132,3 +105,47 @@ export const servicesCountQuery = () => gql`
}
}
`
+// Query to fetch only Component Instances for a specific Service
+export const componentInstancesOfServiceQuery = () => gql`
+ query ($filter: ComponentInstanceFilter, $first: Int, $after: String) {
+ ComponentInstances(filter: $filter, first: $first, after: $after) {
+ edges {
+ node {
+ id
+ ccrn
+ count
+ componentVersion {
+ version
+ component {
+ ccrn
+ }
+ }
+ issueMatches {
+ totalCount
+ edges {
+ node {
+ severity {
+ value
+ score
+ }
+ }
+ }
+ }
+ }
+ }
+ pageInfo {
+ hasNextPage
+ hasPreviousPage
+ isValidPage
+ pageNumber
+ nextPageAfter
+ pages {
+ after
+ isCurrent
+ pageNumber
+ pageCount
+ }
+ }
+ }
+ }
+`
diff --git a/apps/heureka/src/lib/slices/createGlobalsSlice.js b/apps/heureka/src/lib/slices/createGlobalsSlice.js
index 7dac0dca5..e5869e45a 100644
--- a/apps/heureka/src/lib/slices/createGlobalsSlice.js
+++ b/apps/heureka/src/lib/slices/createGlobalsSlice.js
@@ -33,6 +33,11 @@ const createGlobalsSlice = (set, get, options) => ({
first: 20,
},
},
+ ComponentInstancesOfService: {
+ queryOptions: {
+ first: 8,
+ },
+ },
},
actions: {
diff --git a/apps/heureka/src/lib/slices/createGlobalsSlice.test.js b/apps/heureka/src/lib/slices/createGlobalsSlice.test.js
index cf38f0fd8..56713d772 100644
--- a/apps/heureka/src/lib/slices/createGlobalsSlice.test.js
+++ b/apps/heureka/src/lib/slices/createGlobalsSlice.test.js
@@ -33,6 +33,7 @@ describe("createGlobalsSlice", () => {
Services: { queryOptions: { first: 20 } },
IssueMatches: { queryOptions: { first: 20 } },
Components: { queryOptions: { first: 20 } },
+ ComponentInstancesOfService: { queryOptions: { first: 8 } },
},
actions: expect.any(Object),
})