-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CB-5795 replaces error status message with custom redirect notification
- Loading branch information
1 parent
ac93769
commit 47f8bfc
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
webapp/packages/core-blocks/src/Snackbars/RedirectSnackbar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { observer } from 'mobx-react-lite'; | ||
import type React from 'react'; | ||
|
||
import { Container, Link, SnackbarBody, SnackbarContent, SnackbarStatus, SnackbarWrapper, Text, useTranslate } from '@cloudbeaver/core-blocks'; | ||
import type { INotificationExtraProps, NotificationComponent } from '@cloudbeaver/core-events'; | ||
|
||
export interface RedirectSnackbarProps extends INotificationExtraProps { | ||
link: React.ComponentProps<typeof Link>; | ||
} | ||
|
||
export const RedirectSnackbar: NotificationComponent<RedirectSnackbarProps> = observer(function RedirectSnackbar({ notification, link }) { | ||
const translate = useTranslate(); | ||
|
||
return ( | ||
<SnackbarWrapper persistent={notification.persistent} onClose={() => notification.close(false)}> | ||
<SnackbarStatus status={notification.type} /> | ||
<SnackbarContent> | ||
<SnackbarBody title={translate(notification.title)}> | ||
<Container keepSize dense gap> | ||
{notification.message && <Text>{translate(notification.message)}</Text>} | ||
<Link {...link}>{link.href}</Link> | ||
</Container> | ||
</SnackbarBody> | ||
</SnackbarContent> | ||
</SnackbarWrapper> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters