From fe2b9b26d71506767a8edbe9a7c21219567cc3cd Mon Sep 17 00:00:00 2001 From: Naumov Alexey Date: Tue, 17 Nov 2020 13:03:39 +0300 Subject: [PATCH 1/5] feat(plugin-data-viewer): CB-455 add error icon to error Dialog --- .../src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx | 6 +++++- .../core-dialogs/src/CommonDialog/CommonDialog/styles.ts | 5 +++++ .../plugin-data-viewer/src/TableViewer/ErrorDialog.tsx | 5 ++++- .../plugin-data-viewer/src/TableViewer/TableViewerModel.ts | 1 + webapp/packages/plugin-data-viewer/src/locales/en.ts | 1 + webapp/packages/plugin-data-viewer/src/locales/ru.ts | 1 + 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx index dfbf0a15a3..373a165ae8 100644 --- a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx +++ b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx @@ -8,13 +8,15 @@ import styled, { use } from 'reshadow'; -import { Icon, IconOrImage } from '@cloudbeaver/core-blocks'; +import { Icon, IconOrImage, NotificationMark } from '@cloudbeaver/core-blocks'; +import { ENotificationType } from '@cloudbeaver/core-events'; import { useStyles } from '@cloudbeaver/core-theming'; import { commonDialogStyle } from './styles'; export interface CommonDialogWrapperProps { title?: string; + type?: ENotificationType; icon?: string; viewBox?: string; onReject?: () => void; @@ -27,6 +29,7 @@ export interface CommonDialogWrapperProps { export const CommonDialogWrapper: React.FC = function CommonDialogWrapper({ title, + type, icon, viewBox, header, @@ -40,6 +43,7 @@ export const CommonDialogWrapper: React.FC = function
+ {type && !icon && } {icon && }

{title}

{onReject && ( diff --git a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts index b8b4458175..96dd3b0238 100644 --- a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts +++ b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts @@ -50,6 +50,11 @@ export const commonDialogStyle = composes( padding-right: 0; margin-right: -8px; } + NotificationMark { + padding: 18px 24px; + padding-right: 0; + margin-right: -8px; + } dialog-body { box-sizing: border-box; display: flex; diff --git a/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx b/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx index 5470354e98..7a9edb5fcc 100644 --- a/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx +++ b/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx @@ -11,6 +11,7 @@ import styled, { css } from 'reshadow'; import { Button, SanitizedHTML } from '@cloudbeaver/core-blocks'; import { CommonDialogWrapper, DialogComponent } from '@cloudbeaver/core-dialogs'; +import { ENotificationType } from '@cloudbeaver/core-events'; import { useTranslate } from '@cloudbeaver/core-localization'; import { useStyles } from '@cloudbeaver/core-theming'; @@ -40,6 +41,7 @@ const styles = css` export interface ErrorDialogPayload { message: string; + title: string; onShowDetails?: () => void; } @@ -51,7 +53,8 @@ export const ErrorDialog: DialogComponent = observer(functio return styled(useStyles(styles))( {payload.onShowDetails && ( diff --git a/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewerModel.ts b/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewerModel.ts index d33d33087b..0f34f2a041 100644 --- a/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewerModel.ts +++ b/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewerModel.ts @@ -279,6 +279,7 @@ export class TableViewerModel { ErrorDialog, { message, + title: 'data_viewer_save_error', onShowDetails: hasDetails ? () => this.commonDialogService.open(ErrorDetailsDialog, exception) : undefined, diff --git a/webapp/packages/plugin-data-viewer/src/locales/en.ts b/webapp/packages/plugin-data-viewer/src/locales/en.ts index a07b5d7ec2..3f3eda0ae9 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/en.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/en.ts @@ -1,4 +1,5 @@ export default [ ['table_header_sql_expression', 'Enter a SQL expression to filter results'], ['data_viewer_nodata_message', 'No data to show'], + ['data_viewer_save_error', 'Error saving table'], ]; diff --git a/webapp/packages/plugin-data-viewer/src/locales/ru.ts b/webapp/packages/plugin-data-viewer/src/locales/ru.ts index 345ecf9fc1..f2ff7f2c0b 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/ru.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/ru.ts @@ -1,4 +1,5 @@ export default [ ['table_header_sql_expression', 'Введите SQL выражение чтобы отфильтровать результаты'], ['data_viewer_nodata_message', 'Нет данных для отображения'], + ['data_viewer_save_error', 'Не удалось сохранить таблицу'], ]; From 381f3e304f80a926502590c65f054f7874d32471 Mon Sep 17 00:00:00 2001 From: Naumov Alexey Date: Wed, 18 Nov 2020 16:39:00 +0300 Subject: [PATCH 2/5] feat(plugin-data-viewer): CB-455 remove notificationType --- .../CommonDialog/CommonDialog/CommonDialogWrapper.tsx | 10 ++++------ .../src/CommonDialog/CommonDialog/styles.ts | 9 ++++----- .../plugin-data-viewer/src/TableViewer/ErrorDialog.tsx | 4 ++-- webapp/packages/plugin-data-viewer/src/locales/en.ts | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx index 373a165ae8..2c726ea7d1 100644 --- a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx +++ b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx @@ -8,17 +8,16 @@ import styled, { use } from 'reshadow'; -import { Icon, IconOrImage, NotificationMark } from '@cloudbeaver/core-blocks'; -import { ENotificationType } from '@cloudbeaver/core-events'; +import { Icon, IconOrImage } from '@cloudbeaver/core-blocks'; import { useStyles } from '@cloudbeaver/core-theming'; import { commonDialogStyle } from './styles'; export interface CommonDialogWrapperProps { title?: string; - type?: ENotificationType; icon?: string; viewBox?: string; + stretchIcon?: boolean; onReject?: () => void; className?: string; noBodyPadding?: boolean; @@ -29,9 +28,9 @@ export interface CommonDialogWrapperProps { export const CommonDialogWrapper: React.FC = function CommonDialogWrapper({ title, - type, icon, viewBox, + stretchIcon, header, footer, noBodyPadding, @@ -43,8 +42,7 @@ export const CommonDialogWrapper: React.FC = function
- {type && !icon && } - {icon && } + {icon && }

{title}

{onReject && ( diff --git a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts index 96dd3b0238..5a873f9f47 100644 --- a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts +++ b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts @@ -49,11 +49,10 @@ export const commonDialogStyle = composes( padding: 18px 24px; padding-right: 0; margin-right: -8px; - } - NotificationMark { - padding: 18px 24px; - padding-right: 0; - margin-right: -8px; + &[|stretchIcon] { + width: unset; + height: unset; + } } dialog-body { box-sizing: border-box; diff --git a/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx b/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx index 7a9edb5fcc..8a44e54c8a 100644 --- a/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx +++ b/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx @@ -11,7 +11,6 @@ import styled, { css } from 'reshadow'; import { Button, SanitizedHTML } from '@cloudbeaver/core-blocks'; import { CommonDialogWrapper, DialogComponent } from '@cloudbeaver/core-dialogs'; -import { ENotificationType } from '@cloudbeaver/core-events'; import { useTranslate } from '@cloudbeaver/core-localization'; import { useStyles } from '@cloudbeaver/core-theming'; @@ -53,7 +52,7 @@ export const ErrorDialog: DialogComponent = observer(functio return styled(useStyles(styles))( @@ -67,6 +66,7 @@ export const ErrorDialog: DialogComponent = observer(functio )} + stretchIcon onReject={rejectDialog} > diff --git a/webapp/packages/plugin-data-viewer/src/locales/en.ts b/webapp/packages/plugin-data-viewer/src/locales/en.ts index 3f3eda0ae9..cc280d7007 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/en.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/en.ts @@ -1,5 +1,5 @@ export default [ ['table_header_sql_expression', 'Enter a SQL expression to filter results'], ['data_viewer_nodata_message', 'No data to show'], - ['data_viewer_save_error', 'Error saving table'], + ['data_viewer_save_error', 'Save error'], ]; From 55c93eda0596e228320341dafe4055ed2da3365e Mon Sep 17 00:00:00 2001 From: Naumov Alexey Date: Wed, 18 Nov 2020 17:24:38 +0300 Subject: [PATCH 3/5] feat(plugin-data-viewer): CB-455 stretchIcon prop -> isError --- .../CommonDialog/CommonDialog/CommonDialogWrapper.tsx | 9 ++++++--- .../core-dialogs/src/CommonDialog/CommonDialog/styles.ts | 6 +++--- .../plugin-data-viewer/src/TableViewer/ErrorDialog.tsx | 3 +-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx index 2c726ea7d1..a7affae06f 100644 --- a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx +++ b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx @@ -17,7 +17,7 @@ export interface CommonDialogWrapperProps { title?: string; icon?: string; viewBox?: string; - stretchIcon?: boolean; + isError?: boolean; onReject?: () => void; className?: string; noBodyPadding?: boolean; @@ -30,7 +30,7 @@ export const CommonDialogWrapper: React.FC = function title, icon, viewBox, - stretchIcon, + isError, header, footer, noBodyPadding, @@ -38,11 +38,14 @@ export const CommonDialogWrapper: React.FC = function onReject, children, }) { + if (!icon && isError) { + icon = '/icons/error_icon.svg'; + } return styled(useStyles(commonDialogStyle))(
- {icon && } + {icon && }

{title}

{onReject && ( diff --git a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts index 5a873f9f47..77825eee71 100644 --- a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts +++ b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts @@ -49,9 +49,9 @@ export const commonDialogStyle = composes( padding: 18px 24px; padding-right: 0; margin-right: -8px; - &[|stretchIcon] { - width: unset; - height: unset; + &[|isError] { + width: 40px; + height: 40px; } } dialog-body { diff --git a/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx b/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx index 8a44e54c8a..1713fcf90a 100644 --- a/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx +++ b/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx @@ -52,7 +52,6 @@ export const ErrorDialog: DialogComponent = observer(functio return styled(useStyles(styles))( @@ -66,7 +65,7 @@ export const ErrorDialog: DialogComponent = observer(functio )} - stretchIcon + isError onReject={rejectDialog} > From b94805e0d0a55ad0f4508263dfcd9a68fc479717 Mon Sep 17 00:00:00 2001 From: Naumov Alexey Date: Wed, 18 Nov 2020 17:35:37 +0300 Subject: [PATCH 4/5] feat(plugin-data-viewer): isError -> error --- .../src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx | 8 ++++---- .../core-dialogs/src/CommonDialog/CommonDialog/styles.ts | 2 +- .../ErrorDetailsDialog/ErrorDetailsDialog.tsx | 1 + .../plugin-data-viewer/src/TableViewer/ErrorDialog.tsx | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx index a7affae06f..8722e09b45 100644 --- a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx +++ b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/CommonDialogWrapper.tsx @@ -17,7 +17,7 @@ export interface CommonDialogWrapperProps { title?: string; icon?: string; viewBox?: string; - isError?: boolean; + error?: boolean; onReject?: () => void; className?: string; noBodyPadding?: boolean; @@ -30,7 +30,7 @@ export const CommonDialogWrapper: React.FC = function title, icon, viewBox, - isError, + error, header, footer, noBodyPadding, @@ -38,14 +38,14 @@ export const CommonDialogWrapper: React.FC = function onReject, children, }) { - if (!icon && isError) { + if (!icon && error) { icon = '/icons/error_icon.svg'; } return styled(useStyles(commonDialogStyle))(
- {icon && } + {icon && }

{title}

{onReject && ( diff --git a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts index 77825eee71..a0c2f525a0 100644 --- a/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts +++ b/webapp/packages/core-dialogs/src/CommonDialog/CommonDialog/styles.ts @@ -49,7 +49,7 @@ export const commonDialogStyle = composes( padding: 18px 24px; padding-right: 0; margin-right: -8px; - &[|isError] { + &[|error] { width: 40px; height: 40px; } diff --git a/webapp/packages/core-notifications/src/NotificationsItem/ErrorDetailsDialog/ErrorDetailsDialog.tsx b/webapp/packages/core-notifications/src/NotificationsItem/ErrorDetailsDialog/ErrorDetailsDialog.tsx index fcaec8def7..8b172adee2 100644 --- a/webapp/packages/core-notifications/src/NotificationsItem/ErrorDetailsDialog/ErrorDetailsDialog.tsx +++ b/webapp/packages/core-notifications/src/NotificationsItem/ErrorDetailsDialog/ErrorDetailsDialog.tsx @@ -63,6 +63,7 @@ export const ErrorDetailsDialog: DialogComponent = observe )} )} + error onReject={props.rejectDialog} > {error.reason && {error.reason}} diff --git a/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx b/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx index 1713fcf90a..7bb38c97c4 100644 --- a/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx +++ b/webapp/packages/plugin-data-viewer/src/TableViewer/ErrorDialog.tsx @@ -65,7 +65,7 @@ export const ErrorDialog: DialogComponent = observer(functio )} - isError + error onReject={rejectDialog} > From b1fd9a9e993680c2130443834b148f3fb37ec653 Mon Sep 17 00:00:00 2001 From: Naumov Alexey Date: Wed, 18 Nov 2020 18:03:48 +0300 Subject: [PATCH 5/5] feat(plugin-data-viewer): return old locales --- .../plugin-data-viewer/src/TableViewer/TableViewerModel.ts | 2 +- webapp/packages/plugin-data-viewer/src/locales/en.ts | 1 - webapp/packages/plugin-data-viewer/src/locales/ru.ts | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewerModel.ts b/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewerModel.ts index 0f34f2a041..8867e190d4 100644 --- a/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewerModel.ts +++ b/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewerModel.ts @@ -279,7 +279,7 @@ export class TableViewerModel { ErrorDialog, { message, - title: 'data_viewer_save_error', + title: 'ui_data_saving_error', onShowDetails: hasDetails ? () => this.commonDialogService.open(ErrorDetailsDialog, exception) : undefined, diff --git a/webapp/packages/plugin-data-viewer/src/locales/en.ts b/webapp/packages/plugin-data-viewer/src/locales/en.ts index cc280d7007..a07b5d7ec2 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/en.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/en.ts @@ -1,5 +1,4 @@ export default [ ['table_header_sql_expression', 'Enter a SQL expression to filter results'], ['data_viewer_nodata_message', 'No data to show'], - ['data_viewer_save_error', 'Save error'], ]; diff --git a/webapp/packages/plugin-data-viewer/src/locales/ru.ts b/webapp/packages/plugin-data-viewer/src/locales/ru.ts index f2ff7f2c0b..345ecf9fc1 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/ru.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/ru.ts @@ -1,5 +1,4 @@ export default [ ['table_header_sql_expression', 'Введите SQL выражение чтобы отфильтровать результаты'], ['data_viewer_nodata_message', 'Нет данных для отображения'], - ['data_viewer_save_error', 'Не удалось сохранить таблицу'], ];