Skip to content

Commit 236c296

Browse files
committed
draft
1 parent 3fe112f commit 236c296

3 files changed

Lines changed: 59 additions & 6 deletions

File tree

client/src/features/searchV2/api/searchV2-empty.api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/dist/query/react";
2020

2121
// initialize an empty api service that we'll inject endpoints into later as needed
2222
export const searchV2EmptyApi = createApi({
23-
baseQuery: fetchBaseQuery({ baseUrl: "/ui-server/api/search" }),
23+
baseQuery: fetchBaseQuery({ baseUrl: "/api/data" }),
2424
endpoints: () => ({}),
2525
reducerPath: "searchV2Api",
2626
});

client/src/features/searchV2/components/SearchV2Results.tsx

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import cx from "classnames";
2020
import { ReactNode, useEffect, useRef } from "react";
2121
import {
22+
Database,
2223
Folder2Open,
2324
Globe2,
2425
Icon,
@@ -39,16 +40,18 @@ import {
3940
} from "reactstrap";
4041

4142
import ClampedParagraph from "../../../components/clamped/ClampedParagraph";
43+
import { RtkOrNotebooksError } from "../../../components/errors/RtkErrorAlert";
4244
import { Loader } from "../../../components/Loader";
4345
import Pagination from "../../../components/Pagination";
4446
import { TimeCaption } from "../../../components/TimeCaption";
4547
import { ABSOLUTE_ROUTES } from "../../../routing/routes.constants";
4648
import useAppSelector from "../../../utils/customHooks/useAppSelector.hook";
4749
import {
48-
Group,
49-
Project,
50-
SearchEntity,
51-
User,
50+
type DataConnector,
51+
type Group,
52+
type Project,
53+
type SearchEntity,
54+
type User,
5255
searchV2Api,
5356
} from "../api/searchV2Api.api";
5457
import useClampSearchPage from "../hooks/useClampSearchPage.hook";
@@ -107,8 +110,14 @@ function SearchV2ResultsContent() {
107110
return <Loader />;
108111
}
109112

113+
if (searchResults.error) {
114+
return (
115+
<RtkOrNotebooksError error={searchResults.error} dismissible={false} />
116+
);
117+
}
118+
110119
if (!searchResults.data?.items?.length) {
111-
return query == null ? (
120+
return query == null || query === "" ? (
112121
<p>No results</p>
113122
) : (
114123
<>
@@ -136,6 +145,14 @@ function SearchV2ResultsContent() {
136145
return (
137146
<SearchV2ResultUser key={`user-result-${entity.id}`} user={entity} />
138147
);
148+
} else if (entity.type === "DataConnector") {
149+
entity;
150+
return (
151+
<SearchV2ResultDataConnector
152+
key={`user-result-${entity.id}`}
153+
dataConnector={entity}
154+
/>
155+
);
139156
}
140157
// Unknown entity type, in case backend introduces new types before the UI catches up
141158
return <SearchV2ResultsUnknown key={`unknown-result-${index}`} />;
@@ -216,6 +233,8 @@ export function EntityPill({
216233
? People
217234
: entityType === "User"
218235
? Person
236+
: entityType === "DataConnector"
237+
? Database
219238
: Question;
220239
const sizeClass =
221240
size == "sm"
@@ -379,6 +398,39 @@ function SearchV2ResultUser({ user }: SearchV2ResultUserProps) {
379398
);
380399
}
381400

401+
interface SearchV2ResultDataConnectorProps {
402+
dataConnector: DataConnector;
403+
}
404+
function SearchV2ResultDataConnector({
405+
dataConnector,
406+
}: SearchV2ResultDataConnectorProps) {
407+
const { id, name, namespace } = dataConnector;
408+
409+
const namespaceUrl =
410+
namespace?.type === "User"
411+
? generatePath(ABSOLUTE_ROUTES.v2.users.show, {
412+
username: namespace?.namespace ?? "",
413+
})
414+
: generatePath(ABSOLUTE_ROUTES.v2.groups.show.root, {
415+
slug: namespace?.namespace ?? "",
416+
});
417+
const hash = `data-connector-${id}`;
418+
const dcUrl = `${namespaceUrl}#${hash}`;
419+
420+
return (
421+
<SearchV2ResultsContainer>
422+
<SearchV2CardTitle
423+
entityType="DataConnector"
424+
entityUrl={dcUrl}
425+
name={name}
426+
namespace={namespace?.namespace ?? ""}
427+
namespaceUrl={namespaceUrl}
428+
/>
429+
<CardBody />
430+
</SearchV2ResultsContainer>
431+
);
432+
}
433+
382434
function SearchV2ResultsUnknown() {
383435
return (
384436
<SearchV2ResultsContainer>

client/src/features/searchV2/searchV2.constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const TYPE_FILTER_ALLOWED_VALUES: SearchEntityType[] = [
7777
"group",
7878
"project",
7979
"user",
80+
"dataconnector", //eslint-disable-line spellcheck/spell-checker
8081
];
8182

8283
// Visibility filter constants

0 commit comments

Comments
 (0)