Skip to content

Commit 7eb3a67

Browse files
committed
feat: tooltip for non-translatable terms
1 parent 83f64f2 commit 7eb3a67

File tree

2 files changed

+57
-47
lines changed

2 files changed

+57
-47
lines changed

webapp/src/ee/glossary/components/GlossaryListTranslationCell.tsx

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import clsx from 'clsx';
2-
import { Button, styled } from '@mui/material';
2+
import { Button, styled, Tooltip } from '@mui/material';
33
import React from 'react';
44
import { GlossaryListStyledRowCell } from 'tg.ee.module/glossary/components/GlossaryListStyledRowCell';
55
import { components } from 'tg.service/apiSchema.generated';
@@ -51,6 +51,7 @@ type Props = {
5151
translation?: GlossaryTermTranslationModel;
5252
languageTag: string;
5353
editEnabled: boolean;
54+
editDisabledReason?: React.ReactNode;
5455
isEditing?: boolean;
5556
onEdit?: () => void;
5657
onCancel?: () => void;
@@ -64,6 +65,7 @@ export const GlossaryListTranslationCell: React.VFC<Props> = ({
6465
translation,
6566
languageTag,
6667
editEnabled,
68+
editDisabledReason,
6769
isEditing,
6870
onEdit,
6971
onCancel,
@@ -109,51 +111,53 @@ export const GlossaryListTranslationCell: React.VFC<Props> = ({
109111
const onHandleEdit = editEnabled && !isEditing ? handleEdit : undefined;
110112

111113
return (
112-
<StyledRowTranslationCell
113-
className={clsx({
114-
clickable: editEnabled,
115-
editing: isEditing,
116-
})}
117-
onClick={onHandleEdit}
118-
>
119-
{!isEditing ? (
120-
<Box overflow="hidden" gridArea="text">
121-
<LimitedHeightText maxLines={3}>
122-
{translation?.text}
123-
</LimitedHeightText>
124-
</Box>
125-
) : (
126-
<StyledEditBox>
127-
<TextField
128-
onChange={(e) => {
129-
setValue(e.target.value);
130-
}}
131-
value={value}
132-
multiline
133-
minRows={3}
134-
autoFocus
135-
/>
136-
<StyledControls>
137-
<Button
138-
onClick={onCancel}
139-
color="primary"
140-
variant="outlined"
141-
size="small"
142-
>
143-
<T keyName="translate_glossary_term_cell_cancel" />
144-
</Button>
145-
<LoadingButton
146-
onClick={save}
147-
color="primary"
148-
size="small"
149-
variant="contained"
150-
loading={isSaveLoading}
151-
>
152-
<T keyName="translate_glossary_term_cell_save" />
153-
</LoadingButton>
154-
</StyledControls>
155-
</StyledEditBox>
156-
)}
157-
</StyledRowTranslationCell>
114+
<Tooltip title={!editEnabled && editDisabledReason} placement="bottom">
115+
<StyledRowTranslationCell
116+
className={clsx({
117+
clickable: editEnabled,
118+
editing: isEditing,
119+
})}
120+
onClick={onHandleEdit}
121+
>
122+
{!isEditing ? (
123+
<Box overflow="hidden" gridArea="text">
124+
<LimitedHeightText maxLines={3}>
125+
{translation?.text}
126+
</LimitedHeightText>
127+
</Box>
128+
) : (
129+
<StyledEditBox>
130+
<TextField
131+
onChange={(e) => {
132+
setValue(e.target.value);
133+
}}
134+
value={value}
135+
multiline
136+
minRows={3}
137+
autoFocus
138+
/>
139+
<StyledControls>
140+
<Button
141+
onClick={onCancel}
142+
color="primary"
143+
variant="outlined"
144+
size="small"
145+
>
146+
<T keyName="translate_glossary_term_cell_cancel" />
147+
</Button>
148+
<LoadingButton
149+
onClick={save}
150+
color="primary"
151+
size="small"
152+
variant="contained"
153+
loading={isSaveLoading}
154+
>
155+
<T keyName="translate_glossary_term_cell_save" />
156+
</LoadingButton>
157+
</StyledControls>
158+
</StyledEditBox>
159+
)}
160+
</StyledRowTranslationCell>
161+
</Tooltip>
158162
);
159163
};

webapp/src/ee/glossary/components/GlossaryViewListRow.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { components } from 'tg.service/apiSchema.generated';
44
import { GlossaryListTranslationCell } from 'tg.ee.module/glossary/components/GlossaryListTranslationCell';
55
import { GlossaryListTermCell } from 'tg.ee.module/glossary/components/GlossaryListTermCell';
66
import { SelectionService } from 'tg.service/useSelectionService';
7+
import { T } from '@tolgee/react';
78

89
type GlossaryTermWithTranslationsModel =
910
components['schemas']['GlossaryTermWithTranslationsModel'];
@@ -68,6 +69,11 @@ export const GlossaryViewListRow: React.VFC<Props> = ({
6869
translation={translation}
6970
languageTag={tag}
7071
editEnabled={editEnabled && !item.flagNonTranslatable}
72+
editDisabledReason={
73+
item.flagNonTranslatable && (
74+
<T keyName="glossary_term_edit_disabled_non_translatable_tooltip" />
75+
)
76+
}
7177
isEditing={editingTermId === item.id && editingLanguageTag === tag}
7278
onEdit={() => onEditTranslation(item.id, tag)}
7379
onCancel={() => onEditTranslation(item.id, undefined)}

0 commit comments

Comments
 (0)