Skip to content

Commit 8c79d99

Browse files
AntoLCPanchoutNathan
authored andcommitted
✏️(frontend) child document with different wording
We want to have a different wording when the child document has no title, so we can distinguish between the two cases.
1 parent 4bb992a commit 8c79d99

File tree

8 files changed

+18
-28
lines changed

8 files changed

+18
-28
lines changed

src/frontend/apps/impress/src/features/docs/doc-editor/components/DocEditor.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ export const DocEditor = ({ doc, versionId }: DocEditorProps) => {
5454
$padding={{ horizontal: isDesktop ? '54px' : 'base' }}
5555
className="--docs--doc-editor-header"
5656
>
57-
{isVersion ? (
58-
<DocVersionHeader title={doc.title} />
59-
) : (
60-
<DocHeader doc={doc} />
61-
)}
57+
{isVersion ? <DocVersionHeader /> : <DocHeader doc={doc} />}
6258
</Box>
6359

6460
<Box

src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
4646
const [format, setFormat] = useState<DocDownloadFormat>(
4747
DocDownloadFormat.PDF,
4848
);
49-
const { untitledDocument } = useTrans();
50-
49+
const { untitledDocument } = useTrans(doc);
5150
const templateOptions = useMemo(() => {
5251
const templateOptions = (templates?.pages || [])
5352
.map((page) =>

src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
KEY_DOC,
1414
KEY_LIST_DOC,
1515
KEY_SUB_PAGE,
16+
useDocStore,
1617
useTrans,
1718
useUpdateDoc,
1819
} from '@/docs/doc-management';
@@ -24,19 +25,16 @@ interface DocTitleProps {
2425

2526
export const DocTitle = ({ doc }: DocTitleProps) => {
2627
if (!doc.abilities.partial_update) {
27-
return <DocTitleText title={doc.title} />;
28+
return <DocTitleText />;
2829
}
2930

3031
return <DocTitleInput doc={doc} />;
3132
};
3233

33-
interface DocTitleTextProps {
34-
title?: string;
35-
}
36-
37-
export const DocTitleText = ({ title }: DocTitleTextProps) => {
34+
export const DocTitleText = () => {
3835
const { isMobile } = useResponsiveStore();
39-
const { untitledDocument } = useTrans();
36+
const { currentDoc } = useDocStore();
37+
const { untitledDocument } = useTrans(currentDoc);
4038

4139
return (
4240
<Text
@@ -45,7 +43,7 @@ export const DocTitleText = ({ title }: DocTitleTextProps) => {
4543
$size={isMobile ? 'h4' : 'h2'}
4644
$variation="1000"
4745
>
48-
{title || untitledDocument}
46+
{currentDoc?.title || untitledDocument}
4947
</Text>
5048
);
5149
};
@@ -57,7 +55,7 @@ const DocTitleInput = ({ doc }: DocTitleProps) => {
5755
const { colorsTokens } = useCunninghamTheme();
5856
const [titleDisplay, setTitleDisplay] = useState(doc.title);
5957

60-
const { untitledDocument } = useTrans();
58+
const { untitledDocument } = useTrans(doc);
6159

6260
const { broadcast } = useBroadcastStore();
6361

src/frontend/apps/impress/src/features/docs/doc-header/components/DocVersionHeader.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ import { useCunninghamTheme } from '@/cunningham';
55

66
import { DocTitleText } from './DocTitle';
77

8-
interface DocVersionHeaderProps {
9-
title?: string;
10-
}
11-
12-
export const DocVersionHeader = ({ title }: DocVersionHeaderProps) => {
8+
export const DocVersionHeader = () => {
139
const { spacingsTokens } = useCunninghamTheme();
1410

1511
const { t } = useTranslation();
@@ -23,7 +19,7 @@ export const DocVersionHeader = ({ title }: DocVersionHeaderProps) => {
2319
aria-label={t('It is the document title')}
2420
className="--docs--doc-version-header"
2521
>
26-
<DocTitleText title={title} />
22+
<DocTitleText />
2723
<HorizontalSeparator />
2824
</Box>
2925
</>

src/frontend/apps/impress/src/features/docs/doc-management/components/ModalRemoveDoc.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const ModalRemoveDoc = ({
2929
const { toast } = useToastProvider();
3030
const { push } = useRouter();
3131
const pathname = usePathname();
32-
const { untitledDocument } = useTrans();
32+
const { untitledDocument } = useTrans(doc);
3333

3434
const {
3535
mutate: removeDoc,

src/frontend/apps/impress/src/features/docs/doc-management/hooks/useTrans.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { useTranslation } from 'react-i18next';
22

3-
import { Role } from '../types';
3+
import { Doc, Role } from '../types';
44

5-
export const useTrans = () => {
5+
export const useTrans = (doc?: Doc) => {
66
const { t } = useTranslation();
7+
const isChild = doc && doc.nb_accesses_ancestors > 1;
78

89
const translatedRoles = {
910
[Role.READER]: t('Reader'),
@@ -16,7 +17,7 @@ export const useTrans = () => {
1617
transRole: (role: Role) => {
1718
return translatedRoles[role];
1819
},
19-
untitledDocument: t('Untitled document'),
20+
untitledDocument: isChild ? t('Untitled page') : t('Untitled document'),
2021
translatedRoles,
2122
};
2223
};

src/frontend/apps/impress/src/features/docs/doc-tree/components/DocSubPageItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type Props = TreeViewNodeProps<Doc>;
3434
export const DocSubPageItem = (props: Props) => {
3535
const doc = props.node.data.value as Doc;
3636
const treeContext = useTreeContext<Doc>();
37-
const { untitledDocument } = useTrans();
37+
const { untitledDocument } = useTrans(doc);
3838
const { node } = props;
3939
const { spacingsTokens } = useCunninghamTheme();
4040
const [isHover, setIsHover] = useState(false);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const SimpleDocItem = ({
3434
const { t } = useTranslation();
3535
const { spacingsTokens, colorsTokens } = useCunninghamTheme();
3636
const { isDesktop } = useResponsiveStore();
37-
const { untitledDocument } = useTrans();
37+
const { untitledDocument } = useTrans(doc);
3838

3939
return (
4040
<Box

0 commit comments

Comments
 (0)