Skip to content

Commit

Permalink
[Backport 2.x] Allow browsing integrations in Flyout from Data Source…
Browse files Browse the repository at this point in the history
…s page (#1562)

* Move add integration button to custom component



* Add flyout toggle in installed integrations table



* Fix category filters naming



* Break out integration category filter



* Repair category filtering for new install flyout



* Update testing constants for new filter handling



* Add tests for new flyout



* Move basePathLink to shared utils



---------


(cherry picked from commit 7d29261)

Signed-off-by: Simeon Widdis <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent d960b56 commit 36bd75e
Show file tree
Hide file tree
Showing 14 changed files with 3,933 additions and 170 deletions.
26 changes: 26 additions & 0 deletions common/utils/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = { [k: string]: Nested<T> | T }` then you can't accumulate because `T` is not `Nested<T>`
* 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<T = unknown>(obj: Record<string, any>, 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;
}

Expand Down Expand Up @@ -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;
}
};
Loading

0 comments on commit 36bd75e

Please sign in to comment.