Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add readOnly to translation modal #2932

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@coorpacademy-components/locales/en/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"skills_change_focus": "Change skill focus",
"skills_choose_focus": "Choose your focus",
"cancel": "Cancel",
"close": "Close",
"confirm": "Confirm",
"Delete": "Delete",
"Draft": "Draft",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const TranslationModal = (props, context) => {
onConfirm,
onClose,
source: {inputText: sourceInputText, textArea: sourceTextArea, inputLanguage},
target: {inputText: targetInputText, textArea: targetTextArea, language: outputLanguage}
target: {inputText: targetInputText, textArea: targetTextArea, language: outputLanguage},
readOnly = false
} = props;
const {translate} = context;

Expand Down Expand Up @@ -54,22 +55,29 @@ const TranslationModal = (props, context) => {
}, [inputValue, textAreaValue]);

const footer = useMemo(() => {
return {
cancelButton: {
onCancel: handleCancel,
label: translate('cancel')
},
confirmButton: {
onConfirm: () => {
onConfirm();
},
label: translate('confirm'),
iconName: 'plus',
disabled: isConfirmDisabled,
color: COLORS.cm_primary_blue
}
};
}, [handleCancel, onConfirm, translate, isConfirmDisabled]);
return readOnly
? {
cancelButton: {
onCancel: handleCancel,
label: translate('close')
}
}
: {
cancelButton: {
onCancel: handleCancel,
label: translate('cancel')
},
confirmButton: {
onConfirm: () => {
onConfirm();
},
label: translate('confirm'),
iconName: 'plus',
disabled: isConfirmDisabled,
color: COLORS.cm_primary_blue
}
};
}, [handleCancel, onConfirm, translate, isConfirmDisabled, readOnly]);

if (!isOpen) return null;

Expand Down Expand Up @@ -109,7 +117,7 @@ const TranslationModal = (props, context) => {
value: textAreaValue,
onChange: handleTextAreaChange
},
disabled: false
disabled: readOnly
})}
</div>
</div>
Expand Down Expand Up @@ -147,7 +155,8 @@ TranslationModal.propTypes = {
theme: PropTypes.string
}),
language: PropTypes.string
})
}),
readOnly: PropTypes.bool
};

export default TranslationModal;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default {
theme: 'coorpmanager',
description: 'This is the tooltip text',
value: 'Agility',
disabled: false,
valid: false,
error: '',
required: true,
Expand All @@ -28,7 +27,6 @@ export default {
description: 'This is the tooltip text',
value:
'Agility is the ability to quickly adapt to change, think on your feet, and respond efficiently in dynamic situations, enhancing performance in both individual and team environments.',
disabled: false,
valid: false,
error: '',
required: true,
Expand All @@ -45,7 +43,6 @@ export default {
theme: 'coorpmanager',
description: 'This is the tooltip text',
value: 'Agilité',
disabled: false,
valid: false,
error: '',
required: true,
Expand All @@ -60,7 +57,6 @@ export default {
theme: 'coorpmanager',
description: 'This is the tooltip text',
value: `L'agilité est la capacité de s'adapter rapidement aux changements, de penser sur le vif et de répondre efficacement dans des situations dynamiques, améliorant ainsi la performance tant dans des environnements individuels qu'en équipe.`,
disabled: false,
valid: false,
error: '',
required: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
export default {
props: {
isOpen: true,
onCancel: () => {},
onConfirm: () => {},
onClose: () => {},
source: {
inputText: {
type: 'text',
title: 'Title',
hint: '7/80 characters',
placeholder: 'This is an input',
theme: 'coorpmanager',
description: 'This is the tooltip text',
value: 'Agility',
valid: false,
error: '',
required: true,
onChange: value => console.log(value)
},
textArea: {
type: 'textarea',
title: 'Description',
hint: '181/400 characters',
placeholder: 'This is an input',
theme: 'coorpmanager',
description: 'This is the tooltip text',
value:
'Agility is the ability to quickly adapt to change, think on your feet, and respond efficiently in dynamic situations, enhancing performance in both individual and team environments.',
valid: false,
error: '',
required: true,
onChange: value => console.log(value)
},
inputLanguage: '🇬🇧 English (default language)'
},
target: {
inputText: {
type: 'text',
title: 'Title',
hint: '8/80 characters',
placeholder: 'This is an input',
theme: 'coorpmanager',
description: 'This is the tooltip text',
value: 'Agilité',
valid: false,
error: '',
required: true,
onChange: value => console.log(value)
},
textArea: {
type: 'textarea',
name: 'Description target',
title: 'Description',
hint: '215/400 characters',
placeholder: 'This is an input',
theme: 'coorpmanager',
description: 'This is the tooltip text',
value: `L'agilité est la capacité de s'adapter rapidement aux changements, de penser sur le vif et de répondre efficacement dans des situations dynamiques, améliorant ainsi la performance tant dans des environnements individuels qu'en équipe.`,
valid: false,
error: '',
required: true,
onChange: value => console.log(value)
},
language: '🇫🇷 French'
},
readOnly: true
}
};