Skip to content

Commit

Permalink
feat(Navigation/NavigationError): add copy button and impove error de…
Browse files Browse the repository at this point in the history
…tails [YTFRONT-4049]
  • Loading branch information
KostyaAvtushko committed Feb 5, 2025
1 parent 36a2d12 commit 8368094
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
24 changes: 13 additions & 11 deletions packages/ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"@gravity-ui/react-data-table": "^2.1.1",
"@gravity-ui/stylelint-config": "^4.0.1",
"@gravity-ui/tsconfig": "^1.0.0",
"@gravity-ui/uikit": "^6.19.0",
"@gravity-ui/uikit": "^6.37.0",
"@gravity-ui/unipika": "^5.1.0",
"@gravity-ui/websql-autocomplete": "^12.3.0",
"@gravity-ui/yagr": "^4.3.1",
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/src/ui/components/ErrorDetails/ErrorDetails.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {ClipboardButton} from '@gravity-ui/uikit';
import Link from '../../components/Link/Link';
import block from 'bem-cn-lite';
import ypath from '../../common/thor/ypath';
Expand Down Expand Up @@ -107,13 +108,16 @@ export default class ErrorDetails extends Component {
}

renderTabs() {
const {error} = this.props;
const {currentTab} = this.state;

const items = this.prepareTabs();
const text = unipika.formatFromYSON(error.attributes, {asHTML: false});

return (
<div className={b('tabs')}>
<Tabs onTabChange={this.changeCurrentTab} active={currentTab} items={items} />
<ClipboardButton title="Copy error" view="flat-secondary" size="s" text={text} />
</div>
);
}
Expand Down
5 changes: 5 additions & 0 deletions packages/ui/src/ui/components/ErrorDetails/ErrorDetails.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
}

&__tabs {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;

span {
color: var(--g-color-text-complementary);
font-weight: 700;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import cn from 'bem-cn-lite';
import {Flex, Text} from '@gravity-ui/uikit';
import {ClipboardButton, Flex, Text} from '@gravity-ui/uikit';

import Error from '../../../../components/Error/Error';
import {NavigationErrorImage} from './NavigationErrorImage';
import ErrorDetails from '../../../../components/ErrorDetails/ErrorDetails';
import {RequestPermission} from './RequestPermission';
import {getPermissionDeniedError} from '../../../../utils/errors';
import {YTError} from '../../../../../@types/types';
import {getErrorTitle, getLeadingErrorCode} from './helpers';
import {formatForCopy, getErrorTitle, getLeadingErrorCode} from './helpers';

import './NavigationError.scss';

Expand All @@ -26,8 +26,8 @@ function PrettyError(props: Props) {

const code = getLeadingErrorCode(details);
const error = code == 901 ? getPermissionDeniedError(details)! : details;

const title = getErrorTitle(error, path);
const errorInfo = JSON.stringify(details, null, 4);

return (
<Flex className={block()} justifyContent="center" alignItems="center" gap={7}>
Expand All @@ -37,7 +37,14 @@ function PrettyError(props: Props) {
<Flex direction="column" className={block('info')} gap={4}>
<Text className={block('title')}>{title}</Text>
<ErrorDetails error={details} />
{code === 901 && <RequestPermission cluster={cluster} path={path} error={error} />}
<Flex direction="row" gap={3}>
{code === 901 && (
<RequestPermission cluster={cluster} path={path} error={error} />
)}
<ClipboardButton className={block('copy')} view="outlined" text={errorInfo}>
Copy error details
</ClipboardButton>
</Flex>
</Flex>
</Flex>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import unipika from '../../../../../common/thor/unipika';

import {getYtErrorCode} from '../../../../../utils/errors';
import {YTError} from '../../../../../../@types/types';
import {UnipikaValue} from '../../../../../components/Yson/StructuredYson/StructuredYsonTypes';
Expand Down

0 comments on commit 8368094

Please sign in to comment.