@redocly/theme 0.21.2 → 0.21.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Catalog/CatalogCard.d.ts +1 -0
- package/lib/components/Catalog/CatalogCard.js +2 -1
- package/lib/components/OpenApiDocs/ScorecardBadges.d.ts +10 -0
- package/lib/components/OpenApiDocs/ScorecardBadges.js +36 -0
- package/lib/components/OpenApiDocs/index.d.ts +1 -0
- package/lib/components/OpenApiDocs/index.js +1 -0
- package/lib/globalStyle.js +3 -0
- package/lib/layouts/OIDCForbidden.d.ts +2 -0
- package/lib/layouts/OIDCForbidden.js +95 -0
- package/lib/layouts/index.d.ts +1 -0
- package/lib/layouts/index.js +1 -0
- package/package.json +1 -1
- package/src/components/Catalog/CatalogCard.tsx +1 -1
- package/src/components/OpenApiDocs/ScorecardBadges.tsx +55 -0
- package/src/components/OpenApiDocs/index.ts +1 -0
- package/src/globalStyle.ts +3 -0
- package/src/layouts/OIDCForbidden.tsx +89 -0
- package/src/layouts/index.ts +1 -0
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.CatalogCard = void 0;
|
|
29
|
+
exports.statusToColor = exports.CatalogCard = void 0;
|
|
30
30
|
const React = __importStar(require("react"));
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
32
|
const Link_1 = require("../../mocks/Link");
|
|
@@ -68,6 +68,7 @@ function statusToColor(status) {
|
|
|
68
68
|
return '';
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
exports.statusToColor = statusToColor;
|
|
71
72
|
const SelectButton = styled_components_1.default.div `
|
|
72
73
|
border: 1px solid var(--catalog-card-button-border-color);
|
|
73
74
|
border-radius: 100%;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface ScorecardBadgesProps {
|
|
3
|
+
metadata?: {
|
|
4
|
+
scorecardLevel?: string;
|
|
5
|
+
scorecardStatus?: string;
|
|
6
|
+
scoreCardSlug?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare function ScorecardBadges(props: ScorecardBadgesProps): JSX.Element | null;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ScorecardBadges = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const Tag_1 = require("../../components/Tag");
|
|
10
|
+
const Link_1 = require("../../mocks/Link");
|
|
11
|
+
const telemetry_1 = require("../../mocks/telemetry");
|
|
12
|
+
const CatalogCard_1 = require("../../components/Catalog/CatalogCard");
|
|
13
|
+
function ScorecardBadges(props) {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
return ((((_a = props.metadata) === null || _a === void 0 ? void 0 : _a.scorecardLevel) && (react_1.default.createElement(ScorecardBadgesWrapper, { "data-component-name": "OpenApiDocs/ScorecardBadges" },
|
|
16
|
+
react_1.default.createElement(ComplianceTag, { level: props.metadata.scorecardLevel, status: (_b = props.metadata) === null || _b === void 0 ? void 0 : _b.scorecardStatus, slug: (_c = props.metadata) === null || _c === void 0 ? void 0 : _c.scoreCardSlug })))) ||
|
|
17
|
+
null);
|
|
18
|
+
}
|
|
19
|
+
exports.ScorecardBadges = ScorecardBadges;
|
|
20
|
+
const ScorecardBadgesWrapper = styled_components_1.default.div `
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: row;
|
|
23
|
+
|
|
24
|
+
margin-top: var(--panel-gap-vertical);
|
|
25
|
+
position: absolute;
|
|
26
|
+
z-index: 1;
|
|
27
|
+
right: var(--panel-gap-horizontal);
|
|
28
|
+
`;
|
|
29
|
+
function ComplianceTag(props) {
|
|
30
|
+
const { level, status, slug } = props;
|
|
31
|
+
return (react_1.default.createElement(Link_1.Link, { to: slug },
|
|
32
|
+
react_1.default.createElement(Tag_1.Tag, { color: (0, CatalogCard_1.statusToColor)(status), size: "large", onClick: () => telemetry_1.telemetry.send('scorecard_link_clicked', { action: 'click' }) },
|
|
33
|
+
level,
|
|
34
|
+
" oops")));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=ScorecardBadges.js.map
|
|
@@ -7,3 +7,4 @@ export * from '../../components/OpenApiDocs/hooks/AfterOpenApiOperation';
|
|
|
7
7
|
export * from '../../components/OpenApiDocs/hooks/AfterOpenApiOperationSummary';
|
|
8
8
|
export * from '../../components/OpenApiDocs/hooks/BeforeOpenApiOperation';
|
|
9
9
|
export * from '../../components/OpenApiDocs/hooks/BeforeOpenApiOperationSummary';
|
|
10
|
+
export * from '../../components/OpenApiDocs/ScorecardBadges';
|
|
@@ -23,4 +23,5 @@ __exportStar(require("../../components/OpenApiDocs/hooks/AfterOpenApiOperation")
|
|
|
23
23
|
__exportStar(require("../../components/OpenApiDocs/hooks/AfterOpenApiOperationSummary"), exports);
|
|
24
24
|
__exportStar(require("../../components/OpenApiDocs/hooks/BeforeOpenApiOperation"), exports);
|
|
25
25
|
__exportStar(require("../../components/OpenApiDocs/hooks/BeforeOpenApiOperationSummary"), exports);
|
|
26
|
+
__exportStar(require("../../components/OpenApiDocs/ScorecardBadges"), exports);
|
|
26
27
|
//# sourceMappingURL=index.js.map
|
package/lib/globalStyle.js
CHANGED
|
@@ -839,6 +839,9 @@ const pages = (0, styled_components_1.css) `
|
|
|
839
839
|
--page-403-description-margin: 0; // @presenter Spacing
|
|
840
840
|
|
|
841
841
|
--page-403-button-margin: 4em; // @presenter Spacing
|
|
842
|
+
|
|
843
|
+
--page-403-oidc-description-font-size: var(--font-size-lg);
|
|
844
|
+
--page-403-oidc-description-margin: var(--spacing-md) var(--spacing-sm);
|
|
842
845
|
|
|
843
846
|
// @tokens End
|
|
844
847
|
`;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.OIDCForbidden = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
33
|
+
const hooks_1 = require("../mocks/hooks");
|
|
34
|
+
function OIDCForbidden() {
|
|
35
|
+
const { translate } = (0, hooks_1.useTranslate)();
|
|
36
|
+
const [searchParams, setSearchParams] = (0, react_router_dom_1.useSearchParams)();
|
|
37
|
+
const [errorDescription, setErrorDescription] = (0, react_1.useState)('');
|
|
38
|
+
const translationKeys = {
|
|
39
|
+
title: 'theme.page.forbidden.title',
|
|
40
|
+
};
|
|
41
|
+
// use whatever you want here
|
|
42
|
+
const URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
|
|
43
|
+
const renderText = (text) => text.split(' ').map((part) => URL_REGEX.test(part) ? (react_1.default.createElement(ErrorDescriptionLink, { key: part, href: part },
|
|
44
|
+
part,
|
|
45
|
+
' ')) : (part + ' '));
|
|
46
|
+
(0, react_1.useEffect)(() => {
|
|
47
|
+
if (Array.from(searchParams).length) {
|
|
48
|
+
setErrorDescription(searchParams.get('error_description') || searchParams.get('error') || '');
|
|
49
|
+
setSearchParams({});
|
|
50
|
+
}
|
|
51
|
+
}, [searchParams, setSearchParams]);
|
|
52
|
+
return (react_1.default.createElement(Wrapper, { "data-component-name": "Pages/OIDCForbidden" },
|
|
53
|
+
react_1.default.createElement(Header, null, "403"),
|
|
54
|
+
react_1.default.createElement(Description, { "data-translation-key": translationKeys.title }, translate(translationKeys.title, 'Access forbidden')),
|
|
55
|
+
errorDescription && react_1.default.createElement(ErrorDescription, null, renderText(errorDescription))));
|
|
56
|
+
}
|
|
57
|
+
exports.OIDCForbidden = OIDCForbidden;
|
|
58
|
+
const Wrapper = styled_components_1.default.div `
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
align-items: center;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
margin: 25px auto;
|
|
64
|
+
font-family: var(--page-403-font-family);
|
|
65
|
+
text-align: center;
|
|
66
|
+
`;
|
|
67
|
+
const Header = styled_components_1.default.div `
|
|
68
|
+
color: var(--page-403-header-text-color);
|
|
69
|
+
margin: var(--page-403-header-margin);
|
|
70
|
+
font-size: var(--page-403-header-font-size);
|
|
71
|
+
line-height: var(--page-403-header-line-height);
|
|
72
|
+
font-weight: var(--page-403-header-font-weight);
|
|
73
|
+
`;
|
|
74
|
+
const Description = styled_components_1.default.div `
|
|
75
|
+
color: var(--page-403-description-text-color);
|
|
76
|
+
margin: var(--page-403-description-margin);
|
|
77
|
+
font-size: var(--page-403-description-font-size);
|
|
78
|
+
line-height: var(--page-403-description-line-height);
|
|
79
|
+
font-weight: var(--page-403-description-font-weight);
|
|
80
|
+
`;
|
|
81
|
+
const ErrorDescription = styled_components_1.default.div `
|
|
82
|
+
margin: var(--page-403-oidc-description-margin);
|
|
83
|
+
font-size: var(--page-403-oidc-description-font-size);
|
|
84
|
+
color: var(--page-403-description-text-color);
|
|
85
|
+
line-height: var(--page-403-description-line-height);
|
|
86
|
+
font-weight: var(--page-403-description-font-weight);
|
|
87
|
+
`;
|
|
88
|
+
const ErrorDescriptionLink = styled_components_1.default.a `
|
|
89
|
+
color: var(--link-text-color);
|
|
90
|
+
|
|
91
|
+
&:hover {
|
|
92
|
+
color: var(--link-hover-text-color);
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
95
|
+
//# sourceMappingURL=OIDCForbidden.js.map
|
package/lib/layouts/index.d.ts
CHANGED
package/lib/layouts/index.js
CHANGED
|
@@ -18,4 +18,5 @@ __exportStar(require("../layouts/RootLayout"), exports);
|
|
|
18
18
|
__exportStar(require("../layouts/PageLayout"), exports);
|
|
19
19
|
__exportStar(require("../layouts/NotFound"), exports);
|
|
20
20
|
__exportStar(require("../layouts/Forbidden"), exports);
|
|
21
|
+
__exportStar(require("../layouts/OIDCForbidden"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import { Tag } from '@theme/components/Tag';
|
|
5
|
+
import { Link } from '@portal/Link';
|
|
6
|
+
import { telemetry } from '@portal/telemetry';
|
|
7
|
+
import { statusToColor } from '@theme/components/Catalog/CatalogCard';
|
|
8
|
+
|
|
9
|
+
interface ScorecardBadgesProps {
|
|
10
|
+
metadata?: {
|
|
11
|
+
scorecardLevel?: string;
|
|
12
|
+
scorecardStatus?: string;
|
|
13
|
+
scoreCardSlug?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function ScorecardBadges(props: ScorecardBadgesProps) {
|
|
18
|
+
return (
|
|
19
|
+
(props.metadata?.scorecardLevel && (
|
|
20
|
+
<ScorecardBadgesWrapper data-component-name="OpenApiDocs/ScorecardBadges">
|
|
21
|
+
<ComplianceTag
|
|
22
|
+
level={props.metadata.scorecardLevel as string}
|
|
23
|
+
status={props.metadata?.scorecardStatus as string}
|
|
24
|
+
slug={props.metadata?.scoreCardSlug as string}
|
|
25
|
+
/>
|
|
26
|
+
</ScorecardBadgesWrapper>
|
|
27
|
+
)) ||
|
|
28
|
+
null
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const ScorecardBadgesWrapper = styled.div`
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: row;
|
|
35
|
+
|
|
36
|
+
margin-top: var(--panel-gap-vertical);
|
|
37
|
+
position: absolute;
|
|
38
|
+
z-index: 1;
|
|
39
|
+
right: var(--panel-gap-horizontal);
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
function ComplianceTag(props: { level: string; status: string; slug: string }) {
|
|
43
|
+
const { level, status, slug } = props;
|
|
44
|
+
return (
|
|
45
|
+
<Link to={slug}>
|
|
46
|
+
<Tag
|
|
47
|
+
color={statusToColor(status)}
|
|
48
|
+
size="large"
|
|
49
|
+
onClick={() => telemetry.send('scorecard_link_clicked', { action: 'click' })}
|
|
50
|
+
>
|
|
51
|
+
{level} oops
|
|
52
|
+
</Tag>
|
|
53
|
+
</Link>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -7,3 +7,4 @@ export * from '@theme/components/OpenApiDocs/hooks/AfterOpenApiOperation';
|
|
|
7
7
|
export * from '@theme/components/OpenApiDocs/hooks/AfterOpenApiOperationSummary';
|
|
8
8
|
export * from '@theme/components/OpenApiDocs/hooks/BeforeOpenApiOperation';
|
|
9
9
|
export * from '@theme/components/OpenApiDocs/hooks/BeforeOpenApiOperationSummary';
|
|
10
|
+
export * from '@theme/components/OpenApiDocs/ScorecardBadges';
|
package/src/globalStyle.ts
CHANGED
|
@@ -850,6 +850,9 @@ const pages = css`
|
|
|
850
850
|
--page-403-description-margin: 0; // @presenter Spacing
|
|
851
851
|
|
|
852
852
|
--page-403-button-margin: 4em; // @presenter Spacing
|
|
853
|
+
|
|
854
|
+
--page-403-oidc-description-font-size: var(--font-size-lg);
|
|
855
|
+
--page-403-oidc-description-margin: var(--spacing-md) var(--spacing-sm);
|
|
853
856
|
|
|
854
857
|
// @tokens End
|
|
855
858
|
`
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { useSearchParams } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import { useTranslate } from '@portal/hooks';
|
|
6
|
+
|
|
7
|
+
export function OIDCForbidden(): JSX.Element {
|
|
8
|
+
const { translate } = useTranslate();
|
|
9
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
10
|
+
const [errorDescription, setErrorDescription] = useState<string>('');
|
|
11
|
+
|
|
12
|
+
const translationKeys = {
|
|
13
|
+
title: 'theme.page.forbidden.title',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// use whatever you want here
|
|
17
|
+
const URL_REGEX =
|
|
18
|
+
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
|
|
19
|
+
|
|
20
|
+
const renderText = (text: string) =>
|
|
21
|
+
text.split(' ').map((part: string) =>
|
|
22
|
+
URL_REGEX.test(part) ? (
|
|
23
|
+
<ErrorDescriptionLink key={part} href={part}>
|
|
24
|
+
{part}{' '}
|
|
25
|
+
</ErrorDescriptionLink>
|
|
26
|
+
) : (
|
|
27
|
+
part + ' '
|
|
28
|
+
),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (Array.from(searchParams).length) {
|
|
33
|
+
setErrorDescription(searchParams.get('error_description') || searchParams.get('error') || '');
|
|
34
|
+
setSearchParams({});
|
|
35
|
+
}
|
|
36
|
+
}, [searchParams, setSearchParams]);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Wrapper data-component-name="Pages/OIDCForbidden">
|
|
40
|
+
<Header>403</Header>
|
|
41
|
+
<Description data-translation-key={translationKeys.title}>
|
|
42
|
+
{translate(translationKeys.title, 'Access forbidden')}
|
|
43
|
+
</Description>
|
|
44
|
+
{errorDescription && <ErrorDescription>{renderText(errorDescription)}</ErrorDescription>}
|
|
45
|
+
</Wrapper>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const Wrapper = styled.div`
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
margin: 25px auto;
|
|
55
|
+
font-family: var(--page-403-font-family);
|
|
56
|
+
text-align: center;
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
const Header = styled.div`
|
|
60
|
+
color: var(--page-403-header-text-color);
|
|
61
|
+
margin: var(--page-403-header-margin);
|
|
62
|
+
font-size: var(--page-403-header-font-size);
|
|
63
|
+
line-height: var(--page-403-header-line-height);
|
|
64
|
+
font-weight: var(--page-403-header-font-weight);
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
const Description = styled.div`
|
|
68
|
+
color: var(--page-403-description-text-color);
|
|
69
|
+
margin: var(--page-403-description-margin);
|
|
70
|
+
font-size: var(--page-403-description-font-size);
|
|
71
|
+
line-height: var(--page-403-description-line-height);
|
|
72
|
+
font-weight: var(--page-403-description-font-weight);
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
const ErrorDescription = styled.div`
|
|
76
|
+
margin: var(--page-403-oidc-description-margin);
|
|
77
|
+
font-size: var(--page-403-oidc-description-font-size);
|
|
78
|
+
color: var(--page-403-description-text-color);
|
|
79
|
+
line-height: var(--page-403-description-line-height);
|
|
80
|
+
font-weight: var(--page-403-description-font-weight);
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
const ErrorDescriptionLink = styled.a`
|
|
84
|
+
color: var(--link-text-color);
|
|
85
|
+
|
|
86
|
+
&:hover {
|
|
87
|
+
color: var(--link-hover-text-color);
|
|
88
|
+
}
|
|
89
|
+
`;
|
package/src/layouts/index.ts
CHANGED