Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Navigation): add pages for 500 and 901 errors [YTFRONT-4049] #919

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/ui/src/ui/assets/img/svg/500.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions packages/ui/src/ui/assets/img/svg/901.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 3 additions & 7 deletions packages/ui/src/ui/components/ErrorDetails/ErrorDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,7 @@ export default class ErrorDetails extends Component {

return (
<div className={b('tabs')}>
<Tabs
onTabChange={this.changeCurrentTab}
active={currentTab}
items={items}
underline
/>
<Tabs onTabChange={this.changeCurrentTab} active={currentTab} items={items} />
</div>
);
}
Expand Down Expand Up @@ -219,7 +214,8 @@ export default class ErrorDetails extends Component {
return (
<Icon
className={b('error-toggler')}
awesome={showDetails ? 'angle-up' : 'angle-down'}
awesome={showDetails ? 'angle-up' : 'angle-right'}
size="l"
/>
);
}
Expand Down
22 changes: 16 additions & 6 deletions packages/ui/src/ui/components/ErrorDetails/ErrorDetails.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
.elements-error-details {
&__details {
display: flex;
flex-direction: column;
gap: 10px;

padding: 8px;
margin-bottom: 10px;

.unipika-wrapper {
background-color: var(--main-background);
border-radius: var(--g-border-radius-l);

padding: 10px 15px;
}
background-color: var(--light-background);
}

&__message {
Expand All @@ -17,7 +20,7 @@
margin-bottom: 5px;

&-toggler {
margin-right: 5px;
margin-right: 4px;
}
}

Expand All @@ -27,7 +30,14 @@
}

&__tabs {
margin: 10px 0 20px;
span {
color: var(--g-color-text-complementary);
font-weight: 700;
}

::before {
display: none;
}
}

&__inner-errors {
Expand Down
74 changes: 7 additions & 67 deletions packages/ui/src/ui/pages/navigation/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import cn from 'bem-cn-lite';

import map_ from 'lodash/map';

import ypath from '../../../common/thor/ypath';
import {getCluster} from '../../../store/selectors/global';
import {updateTitle} from '../../../store/actions/global';

Expand All @@ -18,13 +17,11 @@ import {
MoveObjectModal,
RestoreObjectModal,
} from './PathEditorModal';
import RequestPermissions from '../../../pages/navigation/tabs/ACL/RequestPermissions/RequestPermissions';
import ErrorBoundary from '../../../components/ErrorBoundary/ErrorBoundary';
import ContentViewer from './ContentViewer/ContentViewer';
import {checkContentIsSupported} from './ContentViewer/helpers';
import Error from '../../../components/Error/Error';
import {Info} from '../../../components/Info/Info';
import Tabs from '../../../components/Tabs/Tabs';
import {NavigationError} from './NavigationError';

import {Tab} from '../../../constants/navigation';
import {LOADING_STATUS} from '../../../constants/index';
Expand Down Expand Up @@ -57,8 +54,6 @@ import CreateACOModal from '../modals/CreateACOModal';
import Button from '../../../components/Button/Button';
import Icon from '../../../components/Icon/Icon';
import {showNavigationAttributesEditor} from '../../../store/actions/navigation/modals/attributes-editor';
import {getPermissionDeniedError} from '../../../utils/errors';
import {getParentPath} from '../../../utils/navigation';
import UIFactory from '../../../UIFactory';

import './Navigation.scss';
Expand Down Expand Up @@ -250,65 +245,12 @@ class Navigation extends Component {
renderError() {
const {
error: {message, details},
isIdmSupported,
cluster,
path,
} = this.props;

// Looking for permission denied error
const permissionDeniedError = getPermissionDeniedError(details);
const isPermissionDenied = permissionDeniedError && isIdmSupported;

return (
<div>
<div className={block('error-block')}>
<Error
className={block('error-block')}
message={message}
error={permissionDeniedError ?? details}
/>
{isPermissionDenied && this.renderRequestPermission(permissionDeniedError)}
</div>
</div>
);
}

renderRequestPermission(error) {
KostyaAvtushko marked this conversation as resolved.
Show resolved Hide resolved
const objectType = ypath.getValue(error?.attributes, '/object_type');
const errorPath = ypath.getValue(error?.attributes, '/path');
const {path: currentPath, cluster} = this.props;
const isRequestPermissionsForPathAllowed = objectType === 'map_node';

const path = errorPath ?? currentPath;

const pathForRequest = isRequestPermissionsForPathAllowed ? path : getParentPath(path);
const textForRequest = isRequestPermissionsForPathAllowed
? 'Request permission'
: 'Request permission for parent node';

return (
<div>
{!isRequestPermissionsForPathAllowed &&
this.renderRequestPermissionIsNotAllowed(objectType)}

<RequestPermissions
className={block('error-action-button')}
buttonClassName={block('request-permissions-button')}
parentPath={pathForRequest}
path={pathForRequest}
cluster={cluster}
buttonText={textForRequest}
buttonProps={{size: 'l', width: 'max'}}
/>
</div>
);
}

renderRequestPermissionIsNotAllowed(objectType) {
return (
<Info className={block('error-block')}>
It is not possible to request access to the{' '}
{hammer.format['Readable'](objectType, {caps: 'none'})}. Please request access to
the parent directory.
</Info>
<NavigationError cluster={cluster} path={path} details={details} message={message} />
);
}

Expand All @@ -317,7 +259,7 @@ class Navigation extends Component {

return (
<ErrorBoundary>
<div className="navigation elements-main-section">
<div className={block({error: hasError}, 'elements-main-section')}>
<StickyContainer>
<div className={block('header')}>
<NavigationPermissionsNotice />
Expand All @@ -328,11 +270,9 @@ class Navigation extends Component {
</div>
</div>

<div className={block('main')}>
{loaded && this.renderView()}
{hasError && this.renderError()}
</div>
<div className={block('main')}>{loaded && this.renderView()}</div>
</StickyContainer>
{hasError && this.renderError()}

{UIFactory.yqlWidgetSetup?.renderWidget()}

Expand Down
11 changes: 4 additions & 7 deletions packages/ui/src/ui/pages/navigation/Navigation/Navigation.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
.navigation {
min-width: 1200px;

&__error-action-button {
margin-top: 20px;
&_error {
display: flex;
flex-direction: column;
flex-grow: 1;
}

&__viewer {
Expand Down Expand Up @@ -31,11 +33,6 @@
margin-top: 20px;
}

&__error-action-button {
width: 100%;
height: 38px;
}

&__instruments {
display: flex;
margin-bottom: 15px;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.navigation-error {
flex-grow: 1;

&__info {
max-width: 650px;

color: var(--g-color-text-complementary);
font-size: 13px;
font-weight: 400;
}

&__title {
font-size: 17px;
line-height: 24px;
font-weight: 500;
color: var(--g-color-text-primary);
}

&__unexpected-error {
margin-top: 20px;
}
}
Loading
Loading