From d6b2179555785b35081e52196c12be4e0b9a802c Mon Sep 17 00:00:00 2001 From: Anton Standrik Date: Wed, 30 Oct 2024 12:16:53 +0300 Subject: [PATCH] fix: review fixes --- .../CriticalActionDialog.tsx | 2 +- src/containers/Operations/Operations.scss | 5 --- src/containers/Operations/columns.tsx | 26 ++++++++++---- src/containers/Operations/i18n/en.json | 4 ++- src/containers/Tenant/Query/Issues/Issues.tsx | 34 +++++++++++++++---- 5 files changed, 51 insertions(+), 20 deletions(-) diff --git a/src/components/CriticalActionDialog/CriticalActionDialog.tsx b/src/components/CriticalActionDialog/CriticalActionDialog.tsx index aea72bbe3..4e80453de 100644 --- a/src/components/CriticalActionDialog/CriticalActionDialog.tsx +++ b/src/components/CriticalActionDialog/CriticalActionDialog.tsx @@ -15,7 +15,7 @@ const b = cn('ydb-critical-dialog'); const parseError = (error: IResponseError) => { if (error.data && 'issues' in error.data && error.data.issues) { - return ; + return ; } if (error.status === 403) { return criticalActionDialogKeyset('no-rights-error'); diff --git a/src/containers/Operations/Operations.scss b/src/containers/Operations/Operations.scss index 1964e59b1..b8efa27a1 100644 --- a/src/containers/Operations/Operations.scss +++ b/src/containers/Operations/Operations.scss @@ -2,9 +2,4 @@ &__search { width: 220px; } - - &__buttons-container { - display: flex; - gap: var(--g-spacing-2); - } } diff --git a/src/containers/Operations/columns.tsx b/src/containers/Operations/columns.tsx index 2e6ff5a55..159a5f94f 100644 --- a/src/containers/Operations/columns.tsx +++ b/src/containers/Operations/columns.tsx @@ -1,7 +1,7 @@ import {duration} from '@gravity-ui/date-utils'; import {Ban, CircleStop} from '@gravity-ui/icons'; import type {Column as DataTableColumn} from '@gravity-ui/react-data-table'; -import {Icon, Text} from '@gravity-ui/uikit'; +import {Flex, Icon, Text} from '@gravity-ui/uikit'; import {ButtonWithConfirmDialog} from '../../components/ButtonWithConfirmDialog/ButtonWithConfirmDialog'; import {CellWithPopover} from '../../components/CellWithPopover/CellWithPopover'; @@ -9,12 +9,12 @@ import {operationsApi} from '../../store/reducers/operations'; import type {TOperation} from '../../types/api/operations'; import {EStatusCode} from '../../types/api/operations'; import {EMPTY_DATA_PLACEHOLDER, HOUR_IN_SECONDS, SECOND_IN_MS} from '../../utils/constants'; +import createToast from '../../utils/createToast'; import {formatDateTime} from '../../utils/dataFormatters/dataFormatters'; import {parseProtobufTimestampToMs} from '../../utils/timeParsers'; import {COLUMNS_NAMES, COLUMNS_TITLES} from './constants'; import i18n from './i18n'; -import {b} from './shared'; import './Operations.scss'; @@ -162,7 +162,7 @@ function OperationsActions({operation, database, refreshTable}: OperationsAction } return ( -
+ forgetOperation({id, database}) .unwrap() - .then(() => refreshTable()) + .then(() => { + createToast({ + name: 'Forgotten', + title: i18n('text_forgotten', {id}), + type: 'success', + }); + refreshTable(); + }) } buttonDisabled={isLoadingCancel} withPopover @@ -187,7 +194,14 @@ function OperationsActions({operation, database, refreshTable}: OperationsAction onConfirmAction={() => cancelOperation({id, database}) .unwrap() - .then(() => refreshTable()) + .then(() => { + createToast({ + name: 'Cancelled', + title: i18n('text_cancelled', {id}), + type: 'success', + }); + refreshTable(); + }) } buttonDisabled={isForgetLoading} withPopover @@ -197,6 +211,6 @@ function OperationsActions({operation, database, refreshTable}: OperationsAction > -
+ ); } diff --git a/src/containers/Operations/i18n/en.json b/src/containers/Operations/i18n/en.json index cf3c0e146..712b4093a 100644 --- a/src/containers/Operations/i18n/en.json +++ b/src/containers/Operations/i18n/en.json @@ -18,5 +18,7 @@ "header_cancel": "Cancel operation", "header_forget": "Forget operation", "text_cancel": "The operation will be cancelled. Do you want to proceed?", - "text_forget": "The operation will be forgotten. Do you want to proceed?" + "text_forget": "The operation will be forgotten. Do you want to proceed?", + "text_forgotten": "The operation {{id}} has been forgotten", + "text_cancelled": "The operation {{id}} has been cancelled" } diff --git a/src/containers/Tenant/Query/Issues/Issues.tsx b/src/containers/Tenant/Query/Issues/Issues.tsx index a3962a671..e0c4913d6 100644 --- a/src/containers/Tenant/Query/Issues/Issues.tsx +++ b/src/containers/Tenant/Query/Issues/Issues.tsx @@ -25,9 +25,10 @@ const blockIssue = cn('kv-issue'); interface ResultIssuesProps { data: ErrorResponse | string; + hideSeverity?: boolean; } -export function ResultIssues({data}: ResultIssuesProps) { +export function ResultIssues({data, hideSeverity}: ResultIssuesProps) { const [showIssues, setShowIssues] = React.useState(false); const issues = typeof data === 'string' ? undefined : data?.issues; @@ -41,7 +42,11 @@ export function ResultIssues({data}: ResultIssuesProps) { const severity = getSeverity(data?.error?.severity); content = ( - {' '} + {hideSeverity ? null : ( + + {' '} + + )} {data?.error?.message} @@ -62,15 +67,16 @@ export function ResultIssues({data}: ResultIssuesProps) { )} - {hasIssues && showIssues && } + {hasIssues && showIssues && } ); } interface IssuesProps { issues: IssueMessage[] | null | undefined; + hideSeverity?: boolean; } -export function Issues({issues}: IssuesProps) { +export function Issues({issues, hideSeverity}: IssuesProps) { const mostSevereIssue = issues?.reduce((result, issue) => { const severity = issue.severity ?? 10; return Math.min(result, severity); @@ -78,13 +84,27 @@ export function Issues({issues}: IssuesProps) { return (
{issues?.map((issue, index) => ( - + ))}
); } -function Issue({issue, level = 0}: {issue: IssueMessage; expanded?: boolean; level?: number}) { +function Issue({ + issue, + hideSeverity, + level = 0, +}: { + issue: IssueMessage; + expanded?: boolean; + hideSeverity?: boolean; + level?: number; +}) { const [isExpand, setIsExpand] = React.useState(true); const severity = getSeverity(issue.severity); const position = getIssuePosition(issue); @@ -111,7 +131,7 @@ function Issue({issue, level = 0}: {issue: IssueMessage; expanded?: boolean; lev )} - + {hideSeverity ? null : } {position && (