1
1
import clsx from 'clsx' ;
2
- import { Button , styled } from '@mui/material' ;
2
+ import { Button , styled , Tooltip } from '@mui/material' ;
3
3
import React from 'react' ;
4
4
import { GlossaryListStyledRowCell } from 'tg.ee.module/glossary/components/GlossaryListStyledRowCell' ;
5
5
import { components } from 'tg.service/apiSchema.generated' ;
@@ -51,6 +51,7 @@ type Props = {
51
51
translation ?: GlossaryTermTranslationModel ;
52
52
languageTag : string ;
53
53
editEnabled : boolean ;
54
+ editDisabledReason ?: React . ReactNode ;
54
55
isEditing ?: boolean ;
55
56
onEdit ?: ( ) => void ;
56
57
onCancel ?: ( ) => void ;
@@ -64,6 +65,7 @@ export const GlossaryListTranslationCell: React.VFC<Props> = ({
64
65
translation,
65
66
languageTag,
66
67
editEnabled,
68
+ editDisabledReason,
67
69
isEditing,
68
70
onEdit,
69
71
onCancel,
@@ -109,51 +111,53 @@ export const GlossaryListTranslationCell: React.VFC<Props> = ({
109
111
const onHandleEdit = editEnabled && ! isEditing ? handleEdit : undefined ;
110
112
111
113
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 >
158
162
) ;
159
163
} ;
0 commit comments