Skip to content

Commit

Permalink
feat(Navigation): add pages for 500 and 901 errors [YTFRONT-4049]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanstantsin Autushka committed Dec 16, 2024
1 parent d61ff09 commit c45447b
Show file tree
Hide file tree
Showing 16 changed files with 362 additions and 82 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const NetworkCode = {
NETWORK_ERROR: 0,
MOUNT_ERROR: 1706,
NODE_COUNT_LIMIT: 902,
};
} as const;

export const ErrorMessage = {
[NetworkCode.EXIST]: 'Object with the same path already exists. Please, try another one',
Expand Down
76 changes: 15 additions & 61 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 @@ -58,7 +55,6 @@ 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 @@ -249,66 +245,26 @@ class Navigation extends Component {

renderError() {
const {
error: {message, details},
error: {details, message},
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) {
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';
const errorType = isPermissionDenied ? 'ACCESS_DENIED' : 'INCORRECT_PATH';

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}
type={errorType}
details={permissionDeniedError ?? details}
message={message}
/>
);
}

Expand All @@ -317,7 +273,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 +284,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
Loading

0 comments on commit c45447b

Please sign in to comment.