Skip to content

Commit 4e40454

Browse files
committed
♻️(fronend) 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.
1 parent 037c5d9 commit 4e40454

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-inline-content/Interlinking/SearchPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export const SearchPage = ({
263263
<DocSearchContent
264264
groupName={t('Link a doc')}
265265
search={search}
266-
parentPath={treeContext?.root?.path}
266+
parentDocId={treeContext?.root?.id}
267267
isSearchNotMandatory
268268
onSelect={(doc) => {
269269
if (!isEditable) {

src/frontend/apps/impress/src/features/docs/doc-search/api/useSearchDocs.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ export type SearchDocsParams = {
1515
page: number;
1616
q: string;
1717
filter?: DocSearchFilterTypes;
18-
parentPath?: string;
18+
parentDocId?: string;
1919
};
2020

2121
const constructParams = ({
2222
q,
2323
page,
2424
filter,
25-
parentPath,
25+
parentDocId,
2626
}: SearchDocsParams): URLSearchParams => {
2727
const searchParams = new URLSearchParams();
2828

2929
searchParams.set('q', q);
3030

31-
if (filter === 'current' && parentPath) {
32-
searchParams.set('path', parentPath);
31+
if (filter === 'current' && parentDocId) {
32+
searchParams.set('document', parentDocId);
3333
}
3434
if (page) {
3535
searchParams.set('page', page.toString());
@@ -48,9 +48,9 @@ const searchDocs = async ({
4848
q,
4949
page,
5050
filter,
51-
parentPath,
51+
parentDocId,
5252
}: SearchDocsParams): Promise<SearchDocsResponse> => {
53-
const searchParams = constructParams({ q, page, filter, parentPath });
53+
const searchParams = constructParams({ q, page, filter, parentDocId });
5454
const response = await fetchAPI(
5555
`documents/search/?${searchParams.toString()}`,
5656
);

src/frontend/apps/impress/src/features/docs/doc-search/components/DocSearchContent.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type DocSearchContentProps = {
1919
onResults?: (results: DocSearch[]) => void;
2020
onSelect: (doc: DocSearch) => void;
2121
onLoadingChange?: (loading: boolean) => void;
22-
parentPath?: string;
22+
parentDocId?: string;
2323
renderSearchElement?: (doc: DocSearch) => React.ReactNode;
2424
};
2525

@@ -31,7 +31,7 @@ export const DocSearchContent = ({
3131
onSelect,
3232
onLoadingChange,
3333
renderSearchElement,
34-
parentPath,
34+
parentDocId,
3535
isSearchNotMandatory,
3636
}: DocSearchContentProps) => {
3737
const { filter } = useDocSearchFilterStore();
@@ -47,10 +47,10 @@ export const DocSearchContent = ({
4747
q: search,
4848
page: 1,
4949
filter,
50-
parentPath,
50+
parentDocId,
5151
},
5252
{
53-
enabled: filter !== 'current' || !!parentPath,
53+
enabled: filter !== 'current' || !!parentDocId,
5454
},
5555
);
5656

src/frontend/apps/impress/src/features/docs/doc-search/components/DocSearchModal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ type DocSearchModalGlobalProps = {
4141
isOpen: boolean;
4242
showFilters?: boolean;
4343
defaultFilters: DocSearchFilterTypes;
44-
parentPath?: string; // If defined, the search will be limited to the children of the document with the given path
44+
parentDocId?: string; // If defined, the search will be limited to the children of the document with the given id
4545
};
4646

4747
const DocSearchModalGlobal = ({
4848
showFilters = false,
4949
defaultFilters,
50-
parentPath,
50+
parentDocId,
5151
...modalProps
5252
}: DocSearchModalGlobalProps) => {
5353
const { t } = useTranslation();
@@ -175,7 +175,7 @@ const DocSearchModalGlobal = ({
175175
onSelect={handleSelect}
176176
onResults={setResults}
177177
onLoadingChange={setLoading}
178-
parentPath={filter === 'current' ? parentPath : undefined}
178+
parentDocId={filter === 'current' ? parentDocId : undefined}
179179
/>
180180
)}
181181
</Box>
@@ -203,7 +203,7 @@ const DocSearchModalDetail = ({
203203
{...modalProps}
204204
showFilters={isWithChildren && authenticated}
205205
defaultFilters={isWithChildren ? 'current' : 'all'}
206-
parentPath={treeContext?.root?.path}
206+
parentDocId={treeContext?.root?.id}
207207
/>
208208
);
209209
};

0 commit comments

Comments
 (0)