Skip to content

Commit

Permalink
moves translate to source string
Browse files Browse the repository at this point in the history
Signed-off-by: Ashwin Pc <ashwinpc@amazon.com>
  • Loading branch information
ashwin-pc committed Sep 9, 2022
1 parent cc000f5 commit aa946df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,7 @@ export const getTopNavConfig = (
}),
testId: 'wizardSaveButton',
disableButton: !!saveDisabledReason,
tooltip() {
if (saveDisabledReason) {
return i18n.translate('wizard.topNavMenu.saveVisualizationDisabledButtonTooltip', {
defaultMessage: saveDisabledReason,
});
}
},
tooltip: saveDisabledReason,
run: (_anchorElement) => {
const onSave = async ({
newTitle,
Expand Down
15 changes: 12 additions & 3 deletions src/plugins/wizard/public/application/utils/use/use_can_save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import { useTypedSelector } from '../state_management';

export const useCanSave = () => {
Expand All @@ -20,12 +21,20 @@ export const useCanSave = () => {

// TODO: Need to finalize the error messages
const getErrorMsg = (isEmpty, hasNoChange, hasDraftAgg) => {
const i18nTranslate = (key: string, defaultMessage: string) =>
i18n.translate(`wizard.saveVisualizationTooltip.${key}`, {
defaultMessage,
});

if (isEmpty) {
return 'The canvas is empty. Add some aggregations before saving.';
return i18nTranslate('empty', 'The canvas is empty. Add some aggregations before saving.');
} else if (hasNoChange) {
return 'Add some changes before saving.';
return i18nTranslate('noChange', 'Add some changes before saving.');
} else if (hasDraftAgg) {
return 'Has unapplied aggregations changes, update them before saving.';
return i18nTranslate(
'hasDraftAgg',
'Has unapplied aggregations changes, update them before saving.'
);
} else {
return undefined;
}
Expand Down

0 comments on commit aa946df

Please sign in to comment.