Skip to content

Commit

Permalink
Allow browsing integrations in Flyout from Data Sources page (opensea…
Browse files Browse the repository at this point in the history
…rch-project#1560)

* Move add integration button to custom component

Signed-off-by: Simeon Widdis <[email protected]>

* Add flyout toggle in installed integrations table

Signed-off-by: Simeon Widdis <[email protected]>

* Fix category filters naming

Signed-off-by: Simeon Widdis <[email protected]>

* Break out integration category filter

Signed-off-by: Simeon Widdis <[email protected]>

* Repair category filtering for new install flyout

Signed-off-by: Simeon Widdis <[email protected]>

* Update testing constants for new filter handling

Signed-off-by: Simeon Widdis <[email protected]>

* Add tests for new flyout

Signed-off-by: Simeon Widdis <[email protected]>

* Move basePathLink to shared utils

Signed-off-by: Simeon Widdis <[email protected]>

---------

Signed-off-by: Simeon Widdis <[email protected]>
  • Loading branch information
Swiddis authored Mar 18, 2024
1 parent 26e8610 commit 7d29261
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 7d29261

Please sign in to comment.