Skip to content

Commit 0dda6ec

Browse files
feat(createToast): allow more props from uikit (#2370)
1 parent eac76af commit 0dda6ec

File tree

5 files changed

+12
-21
lines changed

5 files changed

+12
-21
lines changed

src/containers/Operations/columns.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function OperationsActions({operation, database, refreshTable}: OperationsAction
176176
createToast({
177177
name: 'Forgotten',
178178
title: i18n('text_forgotten', {id}),
179-
type: 'success',
179+
theme: 'success',
180180
});
181181
refreshTable();
182182
})
@@ -200,7 +200,7 @@ function OperationsActions({operation, database, refreshTable}: OperationsAction
200200
createToast({
201201
name: 'Cancelled',
202202
title: i18n('text_cancelled', {id}),
203-
type: 'success',
203+
theme: 'success',
204204
});
205205
refreshTable();
206206
})

src/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const QueryEditorControls = ({
101101
name: 'stop-error',
102102
title: '',
103103
content: i18n('toaster.stop-error'),
104-
type: 'error',
104+
theme: 'danger',
105105
autoHiding: STOP_AUTO_HIDE_TIMEOUT,
106106
});
107107
setCancelQueryError(true);

src/containers/Tenant/Query/QueryResult/components/QueryInfoDropdown/useQueryInfoMenuItems.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function useQueryInfoMenuItems({
8989
createToast({
9090
title: i18n('text_error-plan-svg', {error: errorMessage}),
9191
name: 'plan-svg-error',
92-
type: 'error',
92+
theme: 'danger',
9393
});
9494
return null;
9595
});

src/containers/Tenant/utils/schemaActions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ const bindActions = (
127127
createToast({
128128
name: 'Copied',
129129
title: i18n('actions.copied'),
130-
type: 'success',
130+
theme: 'success',
131131
});
132132
} catch {
133133
createToast({
134134
name: 'Not copied',
135135
title: i18n('actions.notCopied'),
136-
type: 'error',
136+
theme: 'danger',
137137
});
138138
}
139139
},

src/utils/createToast.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
1+
import type {ToastProps} from '@gravity-ui/uikit';
12
import {toaster} from '@gravity-ui/uikit/toaster-singleton-react-18';
23

34
export {toaster};
45

5-
interface CreateToastProps {
6-
name?: string;
7-
title?: string;
8-
content?: string;
9-
type: 'error' | 'success';
10-
autoHiding?: number | false;
11-
className?: string;
12-
}
13-
14-
function createToast({name, title, type, content, autoHiding, className}: CreateToastProps) {
6+
function createToast({name, title, theme, isClosable, autoHiding, ...restProps}: ToastProps) {
157
return toaster.add({
168
name: name ?? 'Request succeeded',
179
title: title ?? 'Request succeeded',
18-
theme: type === 'error' ? 'danger' : 'success',
19-
content: content,
20-
isClosable: true,
21-
autoHiding: autoHiding ?? (type === 'success' ? 5000 : false),
22-
className,
10+
theme: theme ?? 'success',
11+
isClosable: isClosable ?? true,
12+
autoHiding: autoHiding ?? (theme === 'success' ? 5000 : false),
13+
...restProps,
2314
});
2415
}
2516

0 commit comments

Comments
 (0)