Skip to content

Commit

Permalink
Add showing error when entry duplication failed. (datalens-tech#721)
Browse files Browse the repository at this point in the history
* fix error preview when duplicate failed

* Translated using Weblate (Russian)

Currently translated at 100.0% (42 of 42 strings)

Translation: DataLens/new-workbooks__721
Translate-URL: https://weblate.gravity-ui.com/projects/datalens/fix-invalid-name-entry-error-721/new-workbooks-721/ru/

* Translated using Weblate (English)

Currently translated at 97.6% (41 of 42 strings)

Translation: DataLens/new-workbooks__721
Translate-URL: https://weblate.gravity-ui.com/projects/datalens/fix-invalid-name-entry-error-721/new-workbooks-721/en/

* Translated using Weblate (English)

Currently translated at 100.0% (42 of 42 strings)

Translation: DataLens/new-workbooks__721
Translate-URL: https://weblate.gravity-ui.com/projects/datalens/fix-invalid-name-entry-error-721/new-workbooks-721/en/

---------

Co-authored-by: Darya Tikhonova <[email protected]>
Co-authored-by: Matthew Casserly <[email protected]>
Co-authored-by: Maksim Sitnikov <[email protected]>
  • Loading branch information
4 people authored Mar 12, 2024
1 parent 3dc2766 commit 4a98896
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/i18n-keysets/new-workbooks/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
"title_charts": "Charts",
"title_connections": "Connections",
"title_dashboards": "Dashboards",
"title_datasets": "Datasets"
"title_datasets": "Datasets",
"toast_duplicate-failed": "An error occurred while duplicating"
}
3 changes: 2 additions & 1 deletion src/i18n-keysets/new-workbooks/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
"title_charts": "Чарты",
"title_connections": "Подключения",
"title_dashboards": "Дашборды",
"title_datasets": "Датасеты"
"title_datasets": "Датасеты",
"toast_duplicate-failed": "При дублировании произошла ошибка"
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React from 'react';

import {I18n} from 'i18n';
import {useDispatch} from 'react-redux';
import {CopyWorkbookEntryResponse} from 'shared/schema';
import {DataLensApiError} from 'ui/typings';
import {isEntryAlreadyExists} from 'utils/errors/errorByCode';

import {getSdk} from '../../../../../ui/libs/schematic-sdk';
import DialogManager from '../../../../components/DialogManager/DialogManager';
import {DialogCreateWorkbookEntry} from '../../../../components/EntryDialogues/DialogCreateWorkbookEntry/DialogCreateWorkbookEntry';
import {showToast} from '../../../../store/actions/toaster';

export type Props = {
open: boolean;
Expand All @@ -27,6 +29,8 @@ export type OpenDialogDuplicateEntryInWorkbookArgs = {
const i18n = I18n.keyset('new-workbooks');

const DuplicateEntryDialog: React.FC<Props> = ({open, onClose, onApply, initName, entryId}) => {
const dispatch = useDispatch();

const handleApply = React.useCallback(
async ({name}: {name: string}) => {
const duplicatedEntry = await getSdk().us.copyWorkbookEntry({
Expand All @@ -46,6 +50,15 @@ const DuplicateEntryDialog: React.FC<Props> = ({open, onClose, onApply, initName
};
}

dispatch(
showToast({
title: i18n('toast_duplicate-failed'),
name: 'DialogDuplicateEntry',
error,
withReport: true,
}),
);

return null;
};

Expand Down

0 comments on commit 4a98896

Please sign in to comment.