Skip to content

feat(createToast): allow more props from uikit #2370

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

Merged
merged 1 commit into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/containers/Operations/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function OperationsActions({operation, database, refreshTable}: OperationsAction
createToast({
name: 'Forgotten',
title: i18n('text_forgotten', {id}),
type: 'success',
theme: 'success',
});
refreshTable();
})
Expand All @@ -200,7 +200,7 @@ function OperationsActions({operation, database, refreshTable}: OperationsAction
createToast({
name: 'Cancelled',
title: i18n('text_cancelled', {id}),
type: 'success',
theme: 'success',
});
refreshTable();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const QueryEditorControls = ({
name: 'stop-error',
title: '',
content: i18n('toaster.stop-error'),
type: 'error',
theme: 'danger',
autoHiding: STOP_AUTO_HIDE_TIMEOUT,
});
setCancelQueryError(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function useQueryInfoMenuItems({
createToast({
title: i18n('text_error-plan-svg', {error: errorMessage}),
name: 'plan-svg-error',
type: 'error',
theme: 'danger',
});
return null;
});
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Tenant/utils/schemaActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ const bindActions = (
createToast({
name: 'Copied',
title: i18n('actions.copied'),
type: 'success',
theme: 'success',
});
} catch {
createToast({
name: 'Not copied',
title: i18n('actions.notCopied'),
type: 'error',
theme: 'danger',
});
}
},
Expand Down
21 changes: 6 additions & 15 deletions src/utils/createToast.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import type {ToastProps} from '@gravity-ui/uikit';
import {toaster} from '@gravity-ui/uikit/toaster-singleton-react-18';

export {toaster};

interface CreateToastProps {
name?: string;
title?: string;
content?: string;
type: 'error' | 'success';
autoHiding?: number | false;
className?: string;
}

function createToast({name, title, type, content, autoHiding, className}: CreateToastProps) {
function createToast({name, title, theme, isClosable, autoHiding, ...restProps}: ToastProps) {
return toaster.add({
name: name ?? 'Request succeeded',
title: title ?? 'Request succeeded',
theme: type === 'error' ? 'danger' : 'success',
content: content,
isClosable: true,
autoHiding: autoHiding ?? (type === 'success' ? 5000 : false),
className,
theme: theme ?? 'success',
isClosable: isClosable ?? true,
autoHiding: autoHiding ?? (theme === 'success' ? 5000 : false),
...restProps,
});
}

Expand Down
Loading