Skip to content

Commit

Permalink
CB-5795 replaces error status message with custom redirect notification
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyteleshev committed Oct 16, 2024
1 parent ac93769 commit 47f8bfc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions webapp/packages/core-blocks/src/Snackbars/RedirectSnackbar.tsx
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>
);
});
1 change: 1 addition & 0 deletions webapp/packages/core-blocks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export * from './Snackbars/SnackbarMarkups/SnackbarBody.js';
export * from './Snackbars/SnackbarMarkups/SnackbarFooter.js';
export * from './Snackbars/Snackbar.js';
export * from './Snackbars/ActionSnackbar.js';
export * from './Snackbars/RedirectSnackbar.js';
export * from './Snackbars/ProcessSnackbar.js';
export * from './useUserData.js';
export * from './useListKeyboardNavigation.js';
Expand Down

0 comments on commit 47f8bfc

Please sign in to comment.