refactor(core-blocks): CB-479 remove message from SnackbarBody, revert closeable prop

This commit is contained in:
Naumov Alexey
2020-11-12 13:18:51 +03:00
parent 6b5c80180f
commit 2cb90a73b5
6 changed files with 34 additions and 24 deletions
@@ -42,13 +42,20 @@ export const ExportNotification: React.FC<Props> = observer(function ExportNotif
}) {
const controller = useController(ExportNotificationController, notification);
const translate = useTranslate();
const exportNotificationType = controller.isSuccess ? ENotificationType.Info : ENotificationType.Error;
const getExportNotificationType = () => {
if (controller.isPending) {
return ENotificationType.Loading;
} else {
return controller.isSuccess ? ENotificationType.Info : ENotificationType.Error;
}
};
return styled(useStyles(styles))(
<SnackbarWrapper closing={false} closeable={!controller.isPending} onClose={() => notification.close(false)}>
<SnackbarStatus status={controller.isPending ? ENotificationType.Loading : exportNotificationType} />
<SnackbarWrapper unclosable={controller.isPending} onClose={controller.delete}>
<SnackbarStatus status={getExportNotificationType()} />
<SnackbarContent>
<SnackbarBody title={translate(controller.status)} message={controller.sourceName}>
<SnackbarBody title={translate(controller.status)}>
{controller.sourceName}
{controller.task?.context.sourceName && (
<pre title={controller.task?.context.sourceName}>
{controller.task?.context.sourceName}
@@ -56,7 +63,7 @@ export const ExportNotification: React.FC<Props> = observer(function ExportNotif
)}
</SnackbarBody>
<SnackbarFooter timestamp={notification.timestamp}>
{controller.isSuccess && (
{getExportNotificationType() === ENotificationType.Info && (
<>
<Button
type="button"
@@ -76,7 +83,7 @@ export const ExportNotification: React.FC<Props> = observer(function ExportNotif
</Button>
</>
)}
{controller.hasDetails && (
{getExportNotificationType() === ENotificationType.Error && (
<Button
type="button"
mod={['outlined']}
@@ -86,7 +93,7 @@ export const ExportNotification: React.FC<Props> = observer(function ExportNotif
{translate('ui_errors_details')}
</Button>
)}
{controller.isPending && (
{getExportNotificationType() === ENotificationType.Loading && (
<Button
type="button"
mod={['outlined']}