Skip to content
Closed
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
1 change: 1 addition & 0 deletions demo/src/Components/ErrorPage/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import '@diplodoc/components';
19 changes: 18 additions & 1 deletion demo/src/Components/ErrorPage/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import React from 'react';
import {ERROR_CODES, ErrorPage} from '@diplodoc/components';

// import './index.scss';

type Args = {
Title: string;
Mobile: string;
ErrorCode: string;
ReceiveAccessText?: string;
ReceiveAccessUrl?: string;
};

const ErrorPageDemo = (args: Args) => {
const title = args['Title'];
const isMobile = args['Mobile'];
const errorCode = args['ErrorCode'];
const receiveAccessText = args['ReceiveAccessText'] || '';
const receiveAccessUrl = args['ReceiveAccessUrl'];

const processedUrl = receiveAccessUrl?.trim();
const renderMultiline = (text: string) => text.replace(/\r\n/g, '\n').replace(/\\n/g, '\n');

return (
<div className={isMobile === 'true' ? 'mobile' : 'desktop'}>
<ErrorPage
code={Number(errorCode)}
receiveAccessUrl={'Request access url'}
receiveAccessText={renderMultiline(receiveAccessText)}
receiveAccessUrl={processedUrl}
errorTitle={title}
/>
</div>
Expand All @@ -37,6 +47,12 @@ export default {
control: 'select',
options: ERROR_CODES,
},
ReceiveAccessText: {
control: 'text',
},
ReceiveAccessUrl: {
control: 'text',
},
},
};

Expand All @@ -45,5 +61,6 @@ export const Error = {
Title: '',
Mobile: false,
ErrorCode: ERROR_CODES,
ReceiveAccessText: 'Request access',
},
};
1 change: 1 addition & 0 deletions src/components/ErrorPage/ErrorPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

max-width: 800px;
margin-bottom: 20px;
white-space: pre-line;
}

&__description {
Expand Down
4 changes: 3 additions & 1 deletion src/components/ErrorPage/ErrorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface ErrorPageProps {
code?: number;
pageGroup?: string;
homeUrl?: string;
receiveAccessText?: string;
receiveAccessUrl?: string;
links?: LinkType[];
errorTitle?: string;
Expand All @@ -26,6 +27,7 @@ export interface ErrorPageProps {
const ErrorPage: React.FC<ErrorPageProps> = ({
code = 500,
homeUrl,
receiveAccessText,
receiveAccessUrl,
pageGroup,
links,
Expand All @@ -50,7 +52,7 @@ const ErrorPage: React.FC<ErrorPageProps> = ({
{receiveAccessUrl && (
<Link href={receiveAccessUrl} target="_blank" rel="noopener noreferrer">
<Button view="action" className={b('description-link')}>
{t('label_link-access')}
{receiveAccessText || t('label_link-access')}
</Button>
</Link>
)}
Expand Down
3 changes: 3 additions & 0 deletions src/components/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ export const DOC_PAGE_FEEDBACK_SHOWN_URL =
BASE_URL + '/iframe.html?args=HideFeedback:false&id=pages-document--document&viewMode=story';
export const SEARCH_SUGGEST_URL =
BASE_URL + '/iframe.html?id=components-searchsuggest--search-suggest&viewMode=story';
export const ERROR_PAGE_URL =
BASE_URL +
'/iframe.html?args=ErrorCode:403;Title:Page%20403;ReceiveAccessText:Custom%20link;ReceiveAccessUrl:access&id=pages-error--error&viewMode=story';