From 7d29261eb0bdd206a59d2b1c48a31267e392765d Mon Sep 17 00:00:00 2001 From: Simeon Widdis Date: Mon, 18 Mar 2024 15:20:09 -0700 Subject: [PATCH] Allow browsing integrations in Flyout from Data Sources page (#1560) * Move add integration button to custom component Signed-off-by: Simeon Widdis * Add flyout toggle in installed integrations table Signed-off-by: Simeon Widdis * Fix category filters naming Signed-off-by: Simeon Widdis * Break out integration category filter Signed-off-by: Simeon Widdis * Repair category filtering for new install flyout Signed-off-by: Simeon Widdis * Update testing constants for new filter handling Signed-off-by: Simeon Widdis * Add tests for new flyout Signed-off-by: Simeon Widdis * Move basePathLink to shared utils Signed-off-by: Simeon Widdis --------- Signed-off-by: Simeon Widdis --- common/utils/shared.ts | 26 + ...installed_integrations_table.test.tsx.snap | 3726 ++++++++++++++++- .../installed_integrations_table.test.tsx | 30 +- .../components/manage/data_connection.tsx | 7 +- .../installed_integrations_table.tsx | 104 +- ...ilable_integration_card_view.test.tsx.snap | 1 - ...lable_integration_table_view.test.tsx.snap | 5 +- .../setup_integration.test.tsx.snap | 10 + .../components/__tests__/testing_constants.ts | 4 - .../available_integration_card_view.tsx | 8 +- .../available_integration_overview_page.tsx | 142 +- .../available_integration_table.tsx | 28 +- .../components/integration_header.tsx | 2 +- test/constants.ts | 10 + 14 files changed, 3933 insertions(+), 170 deletions(-) diff --git a/common/utils/shared.ts b/common/utils/shared.ts index 7615723d38..0729946c8d 100644 --- a/common/utils/shared.ts +++ b/common/utils/shared.ts @@ -3,7 +3,17 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { coreRefs } from '../../public/framework/core_refs'; + +/** + * TODO making this method type-safe is nontrivial: if you just define + * `Nested = { [k: string]: Nested | T }` then you can't accumulate because `T` is not `Nested` + * There might be a way to define a recursive type that accumulates cleanly but it's probably not + * worth the effort. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function get(obj: Record, path: string, defaultValue?: T): T { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return path.split('.').reduce((acc: any, part: string) => acc && acc[part], obj) || defaultValue; } @@ -33,3 +43,19 @@ export function combineSchemaAndDatarows( return combinedData; } + +/** + * Safely prepend the `basePath` from `coreRefs` to the given link. + * If `coreRefs.http.basePath` exists (always true in normal operation), prepend it to the link. + * If it doesn't exist (usually during unit testing), return the link as-is. + * + * @param link The link to prepend with `coreRefs.http.basePath`. + * @returns The link with the prepended `basePath` if it exists, otherwise the unmodified link. + */ +export const basePathLink = (link: string): string => { + if (coreRefs.http?.basePath) { + return coreRefs.http.basePath.prepend(link); + } else { + return link; + } +}; diff --git a/public/components/datasources/components/__tests__/__snapshots__/installed_integrations_table.test.tsx.snap b/public/components/datasources/components/__tests__/__snapshots__/installed_integrations_table.test.tsx.snap index ada6cb9328..97ee1a1bf1 100644 --- a/public/components/datasources/components/__tests__/__snapshots__/installed_integrations_table.test.tsx.snap +++ b/public/components/datasources/components/__tests__/__snapshots__/installed_integrations_table.test.tsx.snap @@ -2,6 +2,7 @@ exports[`Installed Integrations Table test Renders the empty installed integrations table 1`] = ` @@ -13,7 +14,9 @@ exports[`Installed Integrations Table test Renders the empty installed integrati @@ -159,6 +167,7 @@ exports[`Installed Integrations Table test Renders the empty installed integrati exports[`Installed Integrations Table test Renders the installed integrations table 1`] = ` - - - - - - Add Integration + + Add Integrations + - - - - - + + + + + @@ -844,3 +859,3588 @@ exports[`Installed Integrations Table test Renders the installed integrations ta `; + +exports[`Installed Integrations Table test Renders the installed integrations table flyout 1`] = ` + + + + + +