-
Notifications
You must be signed in to change notification settings - Fork 1
feat(greenhouse): add Exposed Services dashboard #1585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
guoda-puidokaite
wants to merge
23
commits into
main
Choose a base branch
from
guoda-exposed-services
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
fa582d7
exposed services
guoda-puidokaite 317c5c3
exposed services
guoda-puidokaite f68a8c1
exposed services
guoda-puidokaite 7e70666
lisences
guoda-puidokaite 69925ba
types
guoda-puidokaite 081a85d
tests
guoda-puidokaite 5a7d47e
tests
guoda-puidokaite ba15bbc
alignment
guoda-puidokaite 2503607
or feedback
guoda-puidokaite 12fbbe1
code improvements, flattening services and filter by supportGroup def…
guoda-puidokaite 55c125d
code improvements, safe url
guoda-puidokaite eb80597
fix tests
guoda-puidokaite 0dd9d07
improvements
guoda-puidokaite 21fa43c
lisence
guoda-puidokaite fb7b7e9
unused var
guoda-puidokaite 51344f8
improvements
guoda-puidokaite a8ab23a
search params update
guoda-puidokaite 05db6df
remove not needed import
guoda-puidokaite e36f663
use flex for icon alignment
guoda-puidokaite 7370283
design
guoda-puidokaite 3a08720
Merge branch 'main' into guoda-exposed-services
ArtieReus e2616b6
Merge branch 'main' into guoda-exposed-services
guoda-puidokaite e273c1c
Merge branch 'main' into guoda-clusters
guoda-puidokaite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@cloudoperators/juno-app-greenhouse": minor | ||
| --- | ||
|
|
||
| - Add a list of exposed services for all plugins | ||
| - Updated the plugin instance detail page to display a list of exposed services under `Details`, instead of a separate section. |
55 changes: 55 additions & 0 deletions
55
...reenhouse/src/components/admin/ExposedServices/ExposedServicesDataGrid/DataRows/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Juno contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import React from "react" | ||
| import { useSuspenseQuery } from "@tanstack/react-query" | ||
| import { useRouteContext, useSearch } from "@tanstack/react-router" | ||
| import { DataGridRow, DataGridCell } from "@cloudoperators/juno-ui-components" | ||
|
|
||
| import { NO_VALUE_DEFAULT } from "../../../constants" | ||
| import { | ||
| fetchExposedServices, | ||
| FETCH_EXPOSED_SERVICES_CACHE_KEY, | ||
| } from "../../../api/exposed-services/fetchExposedServices" | ||
| import { EmptyDataGridRow } from "../../../common/EmptyDataGridRow" | ||
| import { extractFilterSettingsFromSearchParams } from "../../../utils" | ||
| import { ExternalLink } from "../../../common/ExternalLink" | ||
|
|
||
| interface DataRowsProps { | ||
| colSpan: number | ||
| } | ||
|
|
||
| export const DataRows = ({ colSpan }: DataRowsProps) => { | ||
| const { apiClient, user } = useRouteContext({ from: "/admin/exposed-services" }) | ||
| const search = useSearch({ from: "/admin/exposed-services" }) | ||
| const filterSettings = extractFilterSettingsFromSearchParams(search) | ||
|
|
||
|
guoda-puidokaite marked this conversation as resolved.
|
||
| const { data: flattenedExposedServices } = useSuspenseQuery({ | ||
| queryKey: [FETCH_EXPOSED_SERVICES_CACHE_KEY, user.organization, filterSettings], | ||
| queryFn: () => | ||
| fetchExposedServices({ | ||
| apiClient, | ||
| namespace: user.organization, | ||
| filterSettings, | ||
| }), | ||
| }) | ||
|
guoda-puidokaite marked this conversation as resolved.
|
||
|
|
||
| if (!flattenedExposedServices || flattenedExposedServices.length === 0) { | ||
| return <EmptyDataGridRow colSpan={colSpan}>No exposed services found.</EmptyDataGridRow> | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| {flattenedExposedServices.map((service, index) => ( | ||
| <DataGridRow key={`${service.serviceName}-${index}`}> | ||
|
guoda-puidokaite marked this conversation as resolved.
|
||
| <DataGridCell>{<ExternalLink url={service.serviceUrl} label={service.serviceName} />}</DataGridCell> | ||
| <DataGridCell>{service.clusterName || NO_VALUE_DEFAULT}</DataGridCell> | ||
| <DataGridCell>{service.pluginName || NO_VALUE_DEFAULT}</DataGridCell> | ||
| <DataGridCell>{service.supportGroup || NO_VALUE_DEFAULT}</DataGridCell> | ||
|
guoda-puidokaite marked this conversation as resolved.
|
||
| </DataGridRow> | ||
| ))} | ||
| </> | ||
| ) | ||
| } | ||
99 changes: 99 additions & 0 deletions
99
apps/greenhouse/src/components/admin/ExposedServices/ExposedServicesDataGrid/index.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Juno contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import React, { act } from "react" | ||
| import { | ||
| createMemoryHistory, | ||
| createRootRoute, | ||
| createRoute, | ||
| createRouter, | ||
| Outlet, | ||
| RouterProvider, | ||
| } from "@tanstack/react-router" | ||
| import { render, screen } from "@testing-library/react" | ||
| import { QueryClient, QueryClientProvider } from "@tanstack/react-query" | ||
| import { ExposedServicesDataGrid } from "./index" | ||
| import { mockExposedServices, MockPluginsWithExposedServicesResponse } from "../../__mocks__/exposedServices" | ||
|
|
||
| const renderComponent = async (mockPromise: Promise<MockPluginsWithExposedServicesResponse | unknown>) => { | ||
| const rootRoute = createRootRoute({ | ||
| component: () => <Outlet />, | ||
| }) | ||
| const testRoute = createRoute({ | ||
| getParentRoute: () => rootRoute, | ||
| path: "/admin/exposed-services", | ||
| component: () => ( | ||
| <QueryClientProvider | ||
| client={ | ||
| new QueryClient({ | ||
| defaultOptions: { | ||
| queries: { | ||
| retry: false, | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
| > | ||
| <ExposedServicesDataGrid /> | ||
| </QueryClientProvider> | ||
| ), | ||
| loader: () => ({ | ||
| filterSettings: { | ||
| selectedFilters: [], | ||
| searchTerm: "", | ||
| }, | ||
| }), | ||
| }) | ||
| const routeTree = rootRoute.addChildren([testRoute]) | ||
| const router = createRouter({ | ||
| routeTree: routeTree, | ||
| defaultPendingMinMs: 0, | ||
| context: { | ||
| apiClient: { | ||
| get() { | ||
| return mockPromise | ||
| }, | ||
| }, | ||
| user: { | ||
| organization: "test-org", | ||
| supportGroups: [], | ||
| }, | ||
| }, | ||
| history: createMemoryHistory({ | ||
| initialEntries: ["/admin/exposed-services"], | ||
| }), | ||
| }) | ||
| return await act(async () => render(<RouterProvider router={router} />)) | ||
| } | ||
|
|
||
| describe("ExposedServicesDataGrid", () => { | ||
| it("should render exposed services", async () => { | ||
| await renderComponent( | ||
| new Promise<MockPluginsWithExposedServicesResponse>((resolve) => resolve(mockExposedServices)) | ||
| ) | ||
|
|
||
| // Check for column headers | ||
| expect(screen.getByText("Name")).toBeInTheDocument() | ||
| expect(screen.getByText("Cluster")).toBeInTheDocument() | ||
| expect(screen.getByText("Plugin")).toBeInTheDocument() | ||
| expect(screen.getByText("Support Group")).toBeInTheDocument() | ||
|
|
||
| // Verify service names are in the document | ||
| expect(screen.getByText("service1")).toBeInTheDocument() | ||
| expect(screen.getByText("service2")).toBeInTheDocument() | ||
| expect(screen.getByText("service3")).toBeInTheDocument() | ||
|
|
||
| // Verify service links with correct URLs | ||
| const service1Link = screen.getByRole("link", { name: /service1/i }) | ||
| const service2Link = screen.getByRole("link", { name: /service2/i }) | ||
|
|
||
| expect(service1Link).toHaveAttribute("href", "https://demo-service1.sci.greenhouse-qa.eu-nl-1.cloud.sap/") | ||
| expect(service2Link).toHaveAttribute("href", "https://demo-service2.sci.greenhouse-qa.eu-nl-1.cloud.sap/") | ||
|
|
||
| // Ensure no link rendered without URL | ||
| const service3Link = screen.queryByRole("link", { name: /service3/i }) | ||
| expect(service3Link).toBeNull() | ||
| }) | ||
| }) |
39 changes: 39 additions & 0 deletions
39
apps/greenhouse/src/components/admin/ExposedServices/ExposedServicesDataGrid/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Juno contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import React, { Suspense } from "react" | ||
| import { useLoaderData } from "@tanstack/react-router" | ||
| import { DataGrid, DataGridRow, DataGridHeadCell } from "@cloudoperators/juno-ui-components" | ||
|
|
||
| import { DataRows } from "./DataRows" | ||
| import { ErrorBoundary } from "../../common/ErrorBoundary" | ||
| import { LoadingDataRow } from "../../common/LoadingDataRow" | ||
| import { getErrorDataRowComponent } from "../../common/getErrorDataRow" | ||
|
|
||
| const COLUMN_SPAN = 4 | ||
|
|
||
| export const ExposedServicesDataGrid = () => { | ||
| const { filterSettings } = useLoaderData({ from: "/admin/exposed-services" }) | ||
| return ( | ||
| <DataGrid columns={COLUMN_SPAN}> | ||
| <DataGridRow> | ||
| <DataGridHeadCell>Name</DataGridHeadCell> | ||
| <DataGridHeadCell>Cluster</DataGridHeadCell> | ||
| <DataGridHeadCell>Plugin</DataGridHeadCell> | ||
| <DataGridHeadCell>Support Group</DataGridHeadCell> | ||
| </DataGridRow> | ||
|
|
||
| <ErrorBoundary | ||
| displayErrorMessage | ||
| fallbackRender={getErrorDataRowComponent({ colspan: COLUMN_SPAN })} | ||
| resetKeys={[filterSettings]} // Reset on filter changes | ||
| > | ||
| <Suspense fallback={<LoadingDataRow colSpan={COLUMN_SPAN} />}> | ||
| <DataRows colSpan={COLUMN_SPAN} /> | ||
| </Suspense> | ||
| </ErrorBoundary> | ||
| </DataGrid> | ||
| ) | ||
| } |
127 changes: 127 additions & 0 deletions
127
apps/greenhouse/src/components/admin/ExposedServices/ExposedServicesFilters.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Juno contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import React, { useCallback } from "react" | ||
| import { useLoaderData, useNavigate, useRouteContext } from "@tanstack/react-router" | ||
| import { Stack, InputGroup, Button, SearchInput } from "@cloudoperators/juno-ui-components/index" | ||
|
|
||
| import { getFiltersForUrl } from "../utils" | ||
| import { useQuery } from "@tanstack/react-query" | ||
| import { SELECTED_FILTER_PREFIX } from "../constants" | ||
| import { FilterSelect } from "../common/FilterSelect" | ||
| import { SelectedFilters } from "../common/SelectedFilters" | ||
| import { | ||
| FETCH_EXPOSED_SERVICES_FILTERS_CACHE_KEY, | ||
| fetchExposedServicesFilters, | ||
| } from "../api/exposed-services/fetchExposedServicesFilters" | ||
| import { FilterSettings, SelectedFilter } from "../common/types" | ||
|
|
||
| export const ExposedServicesFilters = () => { | ||
| const navigate = useNavigate() | ||
| const { apiClient, user } = useRouteContext({ from: "/admin/exposed-services" }) | ||
| const { filterSettings } = useLoaderData({ from: "/admin/exposed-services" }) | ||
|
|
||
| const { | ||
| data: filters, | ||
| isLoading, | ||
| error, | ||
| } = useQuery({ | ||
| queryKey: [FETCH_EXPOSED_SERVICES_FILTERS_CACHE_KEY, user.organization], | ||
| queryFn: () => | ||
| fetchExposedServicesFilters({ | ||
| apiClient, | ||
| namespace: user.organization, | ||
| }), | ||
| }) | ||
|
|
||
| const updateFilters = useCallback( | ||
| (updatedFilterSettings: FilterSettings) => { | ||
| navigate({ | ||
| to: "/admin/exposed-services", | ||
| search: (prev) => { | ||
| const newFilterParams = getFiltersForUrl(updatedFilterSettings) | ||
| const cleanedPrev = Object.fromEntries( | ||
| Object.entries(prev).filter(([key]) => !key.startsWith(SELECTED_FILTER_PREFIX)) | ||
| ) | ||
| return { | ||
| ...cleanedPrev, | ||
| ...newFilterParams, | ||
| } | ||
| }, | ||
| }) | ||
| }, | ||
| [navigate] | ||
| ) | ||
|
|
||
| const handleFilterDelete = useCallback( | ||
| (filterToRemove: SelectedFilter) => { | ||
| updateFilters({ | ||
| ...filterSettings, | ||
| selectedFilters: filterSettings.selectedFilters?.filter( | ||
| (filter) => !(filter.id === filterToRemove.id && filter.value === filterToRemove.value) | ||
| ), | ||
| }) | ||
| }, | ||
| [filterSettings, updateFilters] | ||
| ) | ||
|
|
||
| return ( | ||
| <Stack direction="vertical" gap="4" className="bg-theme-background-lvl-1 py-2 px-4 mb-px"> | ||
| <Stack alignment="start" gap="4"> | ||
| <InputGroup> | ||
| <FilterSelect | ||
| filters={filters} | ||
| isLoading={isLoading} | ||
| error={error} | ||
| onChange={(selectedFilter: SelectedFilter) => { | ||
| const filterExists = filterSettings.selectedFilters?.some( | ||
| (filter) => filter.id === selectedFilter.id && filter.value === selectedFilter.value | ||
| ) | ||
| // Only add filter if it does not already exist | ||
| if (!filterExists) { | ||
| updateFilters({ | ||
| ...filterSettings, | ||
| selectedFilters: [...(filterSettings.selectedFilters || []), selectedFilter], | ||
| }) | ||
| } | ||
| }} | ||
| /> | ||
| </InputGroup> | ||
| <Button | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since I commented this in the Clusters PR, here as well to make it consistent: |
||
| label="Clear all" | ||
| className="ml-4" | ||
| onClick={() => | ||
| updateFilters({ | ||
| ...filterSettings, | ||
| selectedFilters: [], | ||
| }) | ||
| } | ||
| variant="subdued" | ||
| /> | ||
| <SearchInput | ||
| placeholder={`search term for exposed service name`} | ||
| className="w-96 ml-auto" | ||
| data-testid="searchbar" | ||
| value={filterSettings.searchTerm} | ||
| onSearch={(searchTerm) => { | ||
| updateFilters({ | ||
| ...filterSettings, | ||
| searchTerm, | ||
|
guoda-puidokaite marked this conversation as resolved.
|
||
| }) | ||
| }} | ||
| onClear={() => | ||
| updateFilters({ | ||
| ...filterSettings, | ||
| searchTerm: "", | ||
| }) | ||
| } | ||
| /> | ||
| </Stack> | ||
| {filterSettings.selectedFilters && filterSettings.selectedFilters.length > 0 && ( | ||
| <SelectedFilters selectedFilters={filterSettings.selectedFilters} onDelete={handleFilterDelete} /> | ||
| )} | ||
| </Stack> | ||
| ) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.