Skip to content

Commit 4680316

Browse files
committed
🚚(frontend) move import code in the doc-import feature folder
We are going to add new modal to import docs, and to avoid having too much code in the docs-grid feature, we are moving all the import code in a new doc-import feature folder. This is a pure move, no logic has been changed, only the location of the files and the imports.
1 parent 010ed46 commit 4680316

File tree

4 files changed

+54
-38
lines changed

4 files changed

+54
-38
lines changed

src/frontend/apps/impress/src/features/docs/docs-grid/components/DocsGrid.tsx

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
import {
2-
Button,
3-
Tooltip as TooltipBase,
4-
} from '@gouvfr-lasuite/cunningham-react';
1+
import { Button } from '@gouvfr-lasuite/cunningham-react';
52
import { useMemo, useState } from 'react';
63
import { useTranslation } from 'react-i18next';
74
import { InView } from 'react-intersection-observer';
8-
import styled, { css } from 'styled-components';
5+
import { css } from 'styled-components';
96

107
import AllDocs from '@/assets/icons/doc-all.svg';
118
import { Box, Card, Icon, Text } from '@/components';
129
import { DocDefaultFilter, useInfiniteDocs } from '@/docs/doc-management';
1310
import { useResponsiveStore } from '@/stores';
1411

12+
import { ButtonImport } from '../../docs-import/components/ButtonImport';
13+
import { useImport } from '../../docs-import/hooks/useImport';
1514
import { useInfiniteDocsTrashbin } from '../api';
16-
import { useImport } from '../hooks/useImport';
1715
import { useResponsiveDocGrid } from '../hooks/useResponsiveDocGrid';
1816

1917
import {
@@ -22,17 +20,6 @@ import {
2220
} from './DocGridContentList';
2321
import { DocsGridLoader } from './DocsGridLoader';
2422

25-
const Tooltip = styled(TooltipBase)`
26-
& {
27-
max-width: 200px;
28-
29-
.c__tooltip__content {
30-
max-width: 200px;
31-
width: max-content;
32-
}
33-
}
34-
`;
35-
3623
type DocsGridProps = {
3724
target?: DocDefaultFilter;
3825
};
@@ -241,27 +228,7 @@ const DocGridTitleBar = ({
241228
{title}
242229
</Text>
243230
</Box>
244-
{withUpload && (
245-
<Tooltip
246-
content={
247-
<Text $textAlign="center" $theme="neutral" $variation="tertiary">
248-
{t('Import Docx or Markdown files')}
249-
</Text>
250-
}
251-
>
252-
<Button
253-
color="brand"
254-
variant="tertiary"
255-
onClick={(e) => {
256-
e.stopPropagation();
257-
onUploadClick();
258-
}}
259-
aria-label={t('Open the upload dialog')}
260-
>
261-
<Icon iconName="upload_file" $withThemeInherited />
262-
</Button>
263-
</Tooltip>
264-
)}
231+
{withUpload && <ButtonImport onUploadClick={onUploadClick} />}
265232
</Box>
266233
);
267234
};

src/frontend/apps/impress/src/features/docs/docs-grid/api/useImportDoc.tsx renamed to src/frontend/apps/impress/src/features/docs/docs-import/api/useImportDoc.tsx

File renamed without changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import {
2+
Button,
3+
Tooltip as TooltipBase,
4+
} from '@gouvfr-lasuite/cunningham-react';
5+
import { useTranslation } from 'react-i18next';
6+
import styled from 'styled-components';
7+
8+
import { Icon, Text } from '@/components';
9+
10+
const Tooltip = styled(TooltipBase)`
11+
& {
12+
max-width: 200px;
13+
14+
.c__tooltip__content {
15+
max-width: 200px;
16+
width: max-content;
17+
}
18+
}
19+
`;
20+
21+
export const ButtonImport = ({
22+
onUploadClick,
23+
}: {
24+
onUploadClick: () => void;
25+
}) => {
26+
const { t } = useTranslation();
27+
28+
return (
29+
<Tooltip
30+
content={
31+
<Text $textAlign="center" $theme="neutral" $variation="tertiary">
32+
{t('Import Docx or Markdown files')}
33+
</Text>
34+
}
35+
>
36+
<Button
37+
color="brand"
38+
variant="tertiary"
39+
onClick={(e) => {
40+
e.stopPropagation();
41+
onUploadClick();
42+
}}
43+
aria-label={t('Open the upload dialog')}
44+
>
45+
<Icon iconName="upload_file" $withThemeInherited />
46+
</Button>
47+
</Tooltip>
48+
);
49+
};

src/frontend/apps/impress/src/features/docs/docs-grid/hooks/useImport.tsx renamed to src/frontend/apps/impress/src/features/docs/docs-import/hooks/useImport.tsx

File renamed without changes.

0 commit comments

Comments
 (0)