♻️(frontend) change search using document path to its id

The search endpoint does not accept anymore the usage of the path
parameter but it is using the document id directly. We have to reflect
this changes in the frontend application.
This commit is contained in:
Manuel Raynaud
2026-07-07 11:21:47 +02:00
parent 9ef4a15f5e
commit c647cb62f1
4 changed files with 15 additions and 15 deletions
@@ -263,7 +263,7 @@ export const SearchPage = ({
<DocSearchContent
groupName={t('Link a doc')}
search={search}
parentPath={treeContext?.root?.path}
parentDocId={treeContext?.root?.id}
isSearchNotMandatory
onSelect={(doc) => {
if (!isEditable) {
@@ -15,21 +15,21 @@ export type SearchDocsParams = {
page: number;
q: string;
filter?: DocSearchFilterTypes;
parentPath?: string;
parentDocId?: string;
};
const constructParams = ({
q,
page,
filter,
parentPath,
parentDocId,
}: SearchDocsParams): URLSearchParams => {
const searchParams = new URLSearchParams();
searchParams.set('q', q);
if (filter === 'current' && parentPath) {
searchParams.set('path', parentPath);
if (filter === 'current' && parentDocId) {
searchParams.set('document', parentDocId);
}
if (page) {
searchParams.set('page', page.toString());
@@ -48,9 +48,9 @@ const searchDocs = async ({
q,
page,
filter,
parentPath,
parentDocId,
}: SearchDocsParams): Promise<SearchDocsResponse> => {
const searchParams = constructParams({ q, page, filter, parentPath });
const searchParams = constructParams({ q, page, filter, parentDocId });
const response = await fetchAPI(
`documents/search/?${searchParams.toString()}`,
);
@@ -19,7 +19,7 @@ type DocSearchContentProps = {
onResults?: (results: DocSearch[]) => void;
onSelect: (doc: DocSearch) => void;
onLoadingChange?: (loading: boolean) => void;
parentPath?: string;
parentDocId?: string;
renderSearchElement?: (doc: DocSearch) => React.ReactNode;
};
@@ -31,7 +31,7 @@ export const DocSearchContent = ({
onSelect,
onLoadingChange,
renderSearchElement,
parentPath,
parentDocId,
isSearchNotMandatory,
}: DocSearchContentProps) => {
const { filter } = useDocSearchFilterStore();
@@ -47,10 +47,10 @@ export const DocSearchContent = ({
q: search,
page: 1,
filter,
parentPath,
parentDocId,
},
{
enabled: filter !== 'current' || !!parentPath,
enabled: filter !== 'current' || !!parentDocId,
},
);
@@ -41,13 +41,13 @@ type DocSearchModalGlobalProps = {
isOpen: boolean;
showFilters?: boolean;
defaultFilters: DocSearchFilterTypes;
parentPath?: string; // If defined, the search will be limited to the children of the document with the given path
parentDocId?: string; // If defined, the search will be limited to the children of the document with the given id
};
const DocSearchModalGlobal = ({
showFilters = false,
defaultFilters,
parentPath,
parentDocId,
...modalProps
}: DocSearchModalGlobalProps) => {
const { t } = useTranslation();
@@ -175,7 +175,7 @@ const DocSearchModalGlobal = ({
onSelect={handleSelect}
onResults={setResults}
onLoadingChange={setLoading}
parentPath={filter === 'current' ? parentPath : undefined}
parentDocId={filter === 'current' ? parentDocId : undefined}
/>
)}
</Box>
@@ -203,7 +203,7 @@ const DocSearchModalDetail = ({
{...modalProps}
showFilters={isWithChildren && authenticated}
defaultFilters={isWithChildren ? 'current' : 'all'}
parentPath={treeContext?.root?.path}
parentDocId={treeContext?.root?.id}
/>
);
};