diff --git a/ontrack-web-core/components/search/SearchResult.js b/ontrack-web-core/components/search/SearchResult.js index 596e23b41b..38bc24d6d3 100644 --- a/ontrack-web-core/components/search/SearchResult.js +++ b/ontrack-web-core/components/search/SearchResult.js @@ -1,9 +1,14 @@ import {Dynamic} from "@components/common/Dynamic"; +import {Space} from "antd"; +import SearchResultType from "@components/search/SearchResultType"; -export default function SearchResult({type, result}) { +export default function SearchResult({result}) { return ( <> - + + + + ) } \ No newline at end of file diff --git a/ontrack-web-core/components/search/SearchResultList.js b/ontrack-web-core/components/search/SearchResultList.js index ea0cdac10f..834ecb2d1f 100644 --- a/ontrack-web-core/components/search/SearchResultList.js +++ b/ontrack-web-core/components/search/SearchResultList.js @@ -1,14 +1,13 @@ import {Space} from "antd"; import SearchResult from "@components/search/SearchResult"; -export default function SearchResultList({type, results}) { +export default function SearchResultList({results}) { return ( <> { results.map((result, index) => ) } diff --git a/ontrack-web-core/components/search/SearchResultType.js b/ontrack-web-core/components/search/SearchResultType.js index 4220f0dfb4..2cd6c2d23c 100644 --- a/ontrack-web-core/components/search/SearchResultType.js +++ b/ontrack-web-core/components/search/SearchResultType.js @@ -1,14 +1,17 @@ -import {Space, Typography} from "antd"; +import {Popover, Typography} from "antd"; import SearchResultTypeIcon from "@components/search/SearchResultTypeIcon"; export default function SearchResultType({type}) { return ( <> - - - {type.name} - {type.description} - + {type.description}} + > +
+ +
+
) } \ No newline at end of file diff --git a/ontrack-web-core/components/search/SearchView.js b/ontrack-web-core/components/search/SearchView.js index 0e1014fff9..1125dcbf61 100644 --- a/ontrack-web-core/components/search/SearchView.js +++ b/ontrack-web-core/components/search/SearchView.js @@ -6,11 +6,55 @@ import {homeUri} from "@components/common/Links"; import {CloseCommand} from "@components/common/Commands"; import {homeBreadcrumbs} from "@components/common/Breadcrumbs"; import MainPage from "@components/layouts/MainPage"; -import {Space} from "antd"; -import SearchTypeSection from "@components/search/SearchTypeSection"; +import {Skeleton} from "antd"; +import {useEffect, useState} from "react"; +import {gql} from "graphql-request"; +import SearchResultList from "@components/search/SearchResultList"; export default function SearchView({q}) { - const {searchResultTypes} = useRefData() + + const client = useGraphQLClient() + const [searching, setSearching] = useState(true) + const [results, setResults] = useState([]) + + useEffect(() => { + if (client && q) { + setSearching(true) + client.request( + gql` + query SearchWithType($q: String!) { + search(offset: 0, size: 10, token: $q) { + pageInfo { + totalSize + nextPage { + offset + size + } + } + pageItems { + type { + id + name + description + } + title + description + data + accuracy + } + } + } + `, + { + q: q, + } + ).then(data => { + setResults(data.search.pageItems) + }).finally(() => { + setSearching(false) + }) + } + }, [client, q]) return ( <> @@ -24,15 +68,9 @@ export default function SearchView({q}) { , ]} > - - { - searchResultTypes.map(type => ( - <> - - - )) - } - + + + )