@stoplight/elements-dev-portal 3.0.12-beta-0.1 → 3.0.13
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/{dist/index.esm.js → index.esm.js} +2 -2
- package/{dist/index.js → index.js} +2 -2
- package/{dist/index.mjs → index.mjs} +2 -2
- package/package.json +17 -71
- package/{dist/types.d.ts → types.d.ts} +0 -1
- package/version.d.ts +1 -0
- package/{dist/web-components.min.js → web-components.min.js} +1 -1
- package/.storybook/main.js +0 -6
- package/.storybook/manager.js +0 -1
- package/.storybook/preview.jsx +0 -46
- package/dist/LICENSE +0 -190
- package/dist/README.md +0 -22
- package/dist/package.json +0 -51
- package/dist/version.d.ts +0 -1
- package/jest.config.js +0 -10
- package/src/__fixtures__/branches.json +0 -28
- package/src/__fixtures__/node-content.json +0 -257
- package/src/__fixtures__/table-of-contents.json +0 -144
- package/src/components/BranchSelector/BranchSelector.spec.tsx +0 -61
- package/src/components/BranchSelector/BranchSelector.stories.tsx +0 -41
- package/src/components/BranchSelector/BranchSelector.tsx +0 -50
- package/src/components/BranchSelector/index.tsx +0 -1
- package/src/components/DevPortalProvider/index.tsx +0 -25
- package/src/components/Forbidden.tsx +0 -11
- package/src/components/Loading.tsx +0 -9
- package/src/components/NodeContent/NodeContent.spec.tsx +0 -128
- package/src/components/NodeContent/NodeContent.stories.tsx +0 -60
- package/src/components/NodeContent/NodeContent.tsx +0 -235
- package/src/components/NodeContent/index.tsx +0 -1
- package/src/components/NotFound.tsx +0 -11
- package/src/components/Search/Search.stories.tsx +0 -151
- package/src/components/Search/Search.tsx +0 -161
- package/src/components/Search/SearchOverlay.tsx +0 -88
- package/src/components/Search/index.tsx +0 -1
- package/src/components/TableOfContents/TableOfContents.stories.tsx +0 -68
- package/src/components/TableOfContents/TableOfContents.tsx +0 -54
- package/src/components/TableOfContents/index.tsx +0 -1
- package/src/components/UpgradeToStarter.tsx +0 -22
- package/src/consts.ts +0 -32
- package/src/containers/StoplightProject.spec.tsx +0 -78
- package/src/containers/StoplightProject.stories.tsx +0 -28
- package/src/containers/StoplightProject.tsx +0 -269
- package/src/handlers/__tests__/getBranches.test.ts +0 -30
- package/src/handlers/__tests__/getNodeContent.test.ts +0 -35
- package/src/handlers/__tests__/getNodes.test.ts +0 -38
- package/src/handlers/__tests__/getTableOfContents.test.ts +0 -34
- package/src/handlers/__tests__/getWorkspace.test.ts +0 -30
- package/src/handlers/getBranches.ts +0 -27
- package/src/handlers/getNodeContent.ts +0 -53
- package/src/handlers/getNodes.ts +0 -69
- package/src/handlers/getTableOfContents.ts +0 -30
- package/src/handlers/getWorkspace.ts +0 -27
- package/src/hooks/__tests__/dataFetching.spec.tsx +0 -42
- package/src/hooks/useGetBranches.ts +0 -17
- package/src/hooks/useGetNodeContent.ts +0 -24
- package/src/hooks/useGetNodes.ts +0 -34
- package/src/hooks/useGetTableOfContents.ts +0 -17
- package/src/hooks/useGetWorkspace.tsx +0 -13
- package/src/index.ts +0 -25
- package/src/styles.css +0 -1
- package/src/types.ts +0 -85
- package/src/version.ts +0 -2
- package/src/web-components/__stories__/StoplightProject.stories.tsx +0 -33
- package/src/web-components/components.ts +0 -19
- package/src/web-components/index.ts +0 -3
- package/tsconfig.build.json +0 -18
- package/tsconfig.json +0 -7
- package/web-components.config.js +0 -1
- /package/{dist/components → components}/BranchSelector/BranchSelector.d.ts +0 -0
- /package/{dist/components → components}/BranchSelector/BranchSelector.spec.d.ts +0 -0
- /package/{dist/components → components}/BranchSelector/BranchSelector.stories.d.ts +0 -0
- /package/{dist/components → components}/BranchSelector/index.d.ts +0 -0
- /package/{dist/components → components}/DevPortalProvider/index.d.ts +0 -0
- /package/{dist/components → components}/Forbidden.d.ts +0 -0
- /package/{dist/components → components}/Loading.d.ts +0 -0
- /package/{dist/components → components}/NodeContent/NodeContent.d.ts +0 -0
- /package/{dist/components → components}/NodeContent/NodeContent.spec.d.ts +0 -0
- /package/{dist/components → components}/NodeContent/NodeContent.stories.d.ts +0 -0
- /package/{dist/components → components}/NodeContent/index.d.ts +0 -0
- /package/{dist/components → components}/NotFound.d.ts +0 -0
- /package/{dist/components → components}/Search/Search.d.ts +0 -0
- /package/{dist/components → components}/Search/Search.stories.d.ts +0 -0
- /package/{dist/components → components}/Search/SearchOverlay.d.ts +0 -0
- /package/{dist/components → components}/Search/index.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/TableOfContents.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/TableOfContents.stories.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/index.d.ts +0 -0
- /package/{dist/components → components}/UpgradeToStarter.d.ts +0 -0
- /package/{dist/consts.d.ts → consts.d.ts} +0 -0
- /package/{dist/containers → containers}/StoplightProject.d.ts +0 -0
- /package/{dist/containers → containers}/StoplightProject.spec.d.ts +0 -0
- /package/{dist/containers → containers}/StoplightProject.stories.d.ts +0 -0
- /package/{dist/handlers → handlers}/getBranches.d.ts +0 -0
- /package/{dist/handlers → handlers}/getNodeContent.d.ts +0 -0
- /package/{dist/handlers → handlers}/getNodes.d.ts +0 -0
- /package/{dist/handlers → handlers}/getTableOfContents.d.ts +0 -0
- /package/{dist/handlers → handlers}/getWorkspace.d.ts +0 -0
- /package/{dist/hooks → hooks}/useGetBranches.d.ts +0 -0
- /package/{dist/hooks → hooks}/useGetNodeContent.d.ts +0 -0
- /package/{dist/hooks → hooks}/useGetNodes.d.ts +0 -0
- /package/{dist/hooks → hooks}/useGetTableOfContents.d.ts +0 -0
- /package/{dist/hooks → hooks}/useGetWorkspace.d.ts +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/styles.min.css → styles.min.css} +0 -0
- /package/{dist/web-components → web-components}/components.d.ts +0 -0
- /package/{dist/web-components → web-components}/index.d.ts +0 -0
- /package/{dist/web-components.min.js.LICENSE.txt → web-components.min.js.LICENSE.txt} +0 -0
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"showPoweredBy": true,
|
|
3
|
-
"items": [
|
|
4
|
-
{ "id": "ZG9jOjE", "title": "Introduction", "type": "article", "slug": "ZG9jOjE-introduction", "meta": "" },
|
|
5
|
-
{ "id": "ZG9jOjI", "title": "UI Overview", "type": "article", "slug": "ZG9jOjI-ui-overview", "meta": "" },
|
|
6
|
-
{ "title": "markdown" },
|
|
7
|
-
{ "id": "ZG9jOjM", "title": "Markdown Basics", "type": "article", "slug": "ZG9jOjM-markdown-basics", "meta": "" },
|
|
8
|
-
{
|
|
9
|
-
"id": "ZG9jOjQ",
|
|
10
|
-
"title": "Stoplight Flavored Markdown (SMD)",
|
|
11
|
-
"type": "article",
|
|
12
|
-
"slug": "ZG9jOjQ-stoplight-flavored-markdown-smd",
|
|
13
|
-
"meta": ""
|
|
14
|
-
},
|
|
15
|
-
{ "title": "APIS" },
|
|
16
|
-
{
|
|
17
|
-
"id": "YXBpOjEy",
|
|
18
|
-
"title": "Swagger Petstore",
|
|
19
|
-
"type": "http_service",
|
|
20
|
-
"slug": "YXBpOjEy-swagger-petstore",
|
|
21
|
-
"meta": "",
|
|
22
|
-
"items": [
|
|
23
|
-
{
|
|
24
|
-
"title": "pets",
|
|
25
|
-
"items": [
|
|
26
|
-
{
|
|
27
|
-
"id": "b3A6MTU",
|
|
28
|
-
"title": "Create a pet",
|
|
29
|
-
"type": "http_operation",
|
|
30
|
-
"slug": "b3A6MTU-create-a-pet",
|
|
31
|
-
"meta": "post"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"id": "b3A6MTY",
|
|
35
|
-
"title": "Info for a specific pet",
|
|
36
|
-
"type": "http_operation",
|
|
37
|
-
"slug": "b3A6MTY-info-for-a-specific-pet",
|
|
38
|
-
"meta": "get"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"id": "b3A6MTQ",
|
|
42
|
-
"title": "List all pets",
|
|
43
|
-
"type": "http_operation",
|
|
44
|
-
"slug": "b3A6MTQ-list-all-pets",
|
|
45
|
-
"meta": "get"
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"title": "Schemas",
|
|
51
|
-
"items": [{ "id": "c2NoOjg", "title": "Pets", "type": "model", "slug": "c2NoOjg-pets", "meta": "" }]
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"id": "YXBpOjM4OTQzNA",
|
|
57
|
-
"title": "To-dos",
|
|
58
|
-
"type": "http_service",
|
|
59
|
-
"slug": "YXBpOjM4OTQzNA-to-dos",
|
|
60
|
-
"meta": "",
|
|
61
|
-
"items": [
|
|
62
|
-
{
|
|
63
|
-
"id": "b3A6Mzg5NDM1",
|
|
64
|
-
"title": "List Todos",
|
|
65
|
-
"type": "http_operation",
|
|
66
|
-
"slug": "b3A6Mzg5NDM1-list-todos",
|
|
67
|
-
"meta": "get"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
"id": "b3A6Mzg5NDM2",
|
|
71
|
-
"title": "Create Todo",
|
|
72
|
-
"type": "http_operation",
|
|
73
|
-
"slug": "b3A6Mzg5NDM2-create-todo",
|
|
74
|
-
"meta": "post"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"id": "b3A6Mzg5NDM4",
|
|
78
|
-
"title": "Get Todo",
|
|
79
|
-
"type": "http_operation",
|
|
80
|
-
"slug": "b3A6Mzg5NDM4-get-todo",
|
|
81
|
-
"meta": "get"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"id": "b3A6OTE0NjUxMA",
|
|
85
|
-
"title": "Replace Todo",
|
|
86
|
-
"type": "http_operation",
|
|
87
|
-
"slug": "b3A6OTE0NjUxMA-replace-todo",
|
|
88
|
-
"meta": "put"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
"id": "b3A6Mzg5NDM5",
|
|
92
|
-
"title": "Delete Todo",
|
|
93
|
-
"type": "http_operation",
|
|
94
|
-
"slug": "b3A6Mzg5NDM5-delete-todo",
|
|
95
|
-
"meta": "delete"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"id": "b3A6Mzg5NDQw",
|
|
99
|
-
"title": "Update Todo",
|
|
100
|
-
"type": "http_operation",
|
|
101
|
-
"slug": "b3A6Mzg5NDQw-update-todo",
|
|
102
|
-
"meta": "patch"
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"title": "Users",
|
|
106
|
-
"items": [
|
|
107
|
-
{
|
|
108
|
-
"id": "b3A6OTE0NjUxMw",
|
|
109
|
-
"title": "Get User",
|
|
110
|
-
"type": "http_operation",
|
|
111
|
-
"slug": "b3A6OTE0NjUxMw-get-user",
|
|
112
|
-
"meta": "get"
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
"id": "b3A6OTE0NjUxNA",
|
|
116
|
-
"title": "Delete User",
|
|
117
|
-
"type": "http_operation",
|
|
118
|
-
"slug": "b3A6OTE0NjUxNA-delete-user",
|
|
119
|
-
"meta": "delete"
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
"id": "b3A6OTE0NjUxNQ",
|
|
123
|
-
"title": "Create User",
|
|
124
|
-
"type": "http_operation",
|
|
125
|
-
"slug": "b3A6OTE0NjUxNQ-create-user",
|
|
126
|
-
"meta": "post"
|
|
127
|
-
}
|
|
128
|
-
]
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
"title": "Schemas",
|
|
132
|
-
"items": [
|
|
133
|
-
{ "id": "c2NoOjkxNDY1MDA", "title": "Todo", "type": "model", "slug": "c2NoOjkxNDY1MDA-todo", "meta": "" },
|
|
134
|
-
{ "id": "c2NoOjkxNDY1MDE", "title": "User", "type": "model", "slug": "c2NoOjkxNDY1MDE-user", "meta": "" }
|
|
135
|
-
]
|
|
136
|
-
}
|
|
137
|
-
]
|
|
138
|
-
},
|
|
139
|
-
{ "title": "Schemas" },
|
|
140
|
-
{ "id": "c2NoOjU", "title": "Error", "type": "model", "slug": "c2NoOjU-error", "meta": "" },
|
|
141
|
-
{ "id": "c2NoOjY", "title": "Category", "type": "model", "slug": "c2NoOjY-category", "meta": "" },
|
|
142
|
-
{ "id": "c2NoOjc", "title": "Pet", "type": "model", "slug": "c2NoOjc-pet", "meta": "" }
|
|
143
|
-
]
|
|
144
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Provider as MosaicProvider } from '@stoplight/mosaic';
|
|
2
|
-
import { screen } from '@testing-library/dom';
|
|
3
|
-
import { render } from '@testing-library/react';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
|
|
7
|
-
import { Branch } from '../../types';
|
|
8
|
-
import { BranchSelector } from './BranchSelector';
|
|
9
|
-
|
|
10
|
-
export const branches: Branch[] = [
|
|
11
|
-
{
|
|
12
|
-
id: 0,
|
|
13
|
-
slug: 'main',
|
|
14
|
-
is_default: true,
|
|
15
|
-
is_published: false,
|
|
16
|
-
name: 'main-name',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
id: 1,
|
|
20
|
-
slug: 'beta',
|
|
21
|
-
is_default: false,
|
|
22
|
-
is_published: false,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
id: 2,
|
|
26
|
-
slug: 'feature-branch',
|
|
27
|
-
is_default: false,
|
|
28
|
-
is_published: false,
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
const BranchSelectorWrapper: React.FC = () => {
|
|
33
|
-
const [branchSlug, setBranchSlug] = React.useState('main');
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<MosaicProvider>
|
|
37
|
-
<BranchSelector branchSlug={branchSlug} branches={branches} onChange={branch => setBranchSlug(branch.slug)} />
|
|
38
|
-
</MosaicProvider>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function getBranchSelector() {
|
|
43
|
-
return screen.getByRole('button');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
describe('Branch selector', () => {
|
|
47
|
-
it('shows the default branch by default', () => {
|
|
48
|
-
render(<BranchSelectorWrapper />);
|
|
49
|
-
|
|
50
|
-
expect(getBranchSelector()).toHaveTextContent('main-name');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('selects a branch', () => {
|
|
54
|
-
render(<BranchSelectorWrapper />);
|
|
55
|
-
|
|
56
|
-
userEvent.click(getBranchSelector());
|
|
57
|
-
userEvent.click(screen.getByRole('menuitemradio', { name: 'beta' }));
|
|
58
|
-
|
|
59
|
-
expect(getBranchSelector()).toHaveTextContent('beta');
|
|
60
|
-
});
|
|
61
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Box } from '@stoplight/mosaic';
|
|
2
|
-
import { Story } from '@storybook/react';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
|
|
5
|
-
import { useGetBranches } from '../../hooks/useGetBranches';
|
|
6
|
-
import { BranchSelector } from './';
|
|
7
|
-
|
|
8
|
-
// Wrapper to show how to use the node content hook
|
|
9
|
-
const BranchSelectorWrapper = ({ projectId }: { projectId: string }) => {
|
|
10
|
-
const [branchSlug, setBranchSlug] = React.useState('master');
|
|
11
|
-
const { data } = useGetBranches({ projectId });
|
|
12
|
-
|
|
13
|
-
if (data) {
|
|
14
|
-
return (
|
|
15
|
-
<Box mt={10} w={40}>
|
|
16
|
-
<BranchSelector branchSlug={branchSlug} branches={data.items} onChange={branch => setBranchSlug(branch.slug)} />
|
|
17
|
-
</Box>
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return <Box>Loading</Box>;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default {
|
|
25
|
-
title: 'Public/BranchSelector',
|
|
26
|
-
component: BranchSelectorWrapper,
|
|
27
|
-
argTypes: {
|
|
28
|
-
projectId: { table: { category: 'Input' } },
|
|
29
|
-
platformUrl: { table: { category: 'Input' } },
|
|
30
|
-
},
|
|
31
|
-
args: {
|
|
32
|
-
projectId: 'cHJqOjYwNjYx',
|
|
33
|
-
platformUrl: 'https://stoplight.io',
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const Playground: Story<{ nodeSlug: string; projectId: string; branchSlug?: string }> = args => (
|
|
38
|
-
<BranchSelectorWrapper {...args} />
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
Playground.storyName = 'Studio Demo';
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { FieldButton, Menu } from '@stoplight/mosaic';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
import { Branch } from '../../types';
|
|
5
|
-
|
|
6
|
-
export type BranchSelectorProps = {
|
|
7
|
-
branchSlug: string;
|
|
8
|
-
branches: Branch[];
|
|
9
|
-
onChange: (branch: Branch) => void;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const BranchSelector = ({ branchSlug, branches, onChange }: BranchSelectorProps) => {
|
|
13
|
-
const currentBranch = branches.find(branch => (!branchSlug ? branch.is_default : branch.slug === branchSlug));
|
|
14
|
-
const handleChange = React.useCallback(
|
|
15
|
-
(selectedSlug: React.ReactText) => {
|
|
16
|
-
const selectedBranch = branches.find(branch => branch.slug === selectedSlug);
|
|
17
|
-
if (selectedBranch) {
|
|
18
|
-
onChange(selectedBranch);
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
[onChange, branches],
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<Menu
|
|
26
|
-
aria-label="Versions"
|
|
27
|
-
placement="bottom left"
|
|
28
|
-
closeOnPress
|
|
29
|
-
matchTriggerWidth
|
|
30
|
-
renderTrigger={({ isOpen }) => (
|
|
31
|
-
<FieldButton w="full" icon="layer-group" px={4} h="md" active={isOpen} borderR={0} roundedR="none">
|
|
32
|
-
{currentBranch?.name || currentBranch?.slug || 'Choose a version'}
|
|
33
|
-
</FieldButton>
|
|
34
|
-
)}
|
|
35
|
-
items={[
|
|
36
|
-
{
|
|
37
|
-
type: 'option_group',
|
|
38
|
-
title: 'Versions',
|
|
39
|
-
onChange: handleChange,
|
|
40
|
-
value: currentBranch?.slug || '',
|
|
41
|
-
children: branches.map(branch => ({
|
|
42
|
-
title: branch.name || branch.slug,
|
|
43
|
-
value: branch.slug,
|
|
44
|
-
meta: branch.is_default ? 'Default' : undefined,
|
|
45
|
-
})),
|
|
46
|
-
},
|
|
47
|
-
]}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './BranchSelector';
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { withMosaicProvider, withPersistenceBoundary, withQueryClientProvider } from '@stoplight/elements-core';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
export type DevPortalProviderProps = {
|
|
5
|
-
platformUrl?: string;
|
|
6
|
-
platformAuthToken?: string;
|
|
7
|
-
isLoggedIn?: boolean;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const PlatformContext = React.createContext<DevPortalProviderProps>({ platformUrl: 'https://stoplight.io' });
|
|
11
|
-
|
|
12
|
-
const PlatformProvider: React.FC<DevPortalProviderProps> = ({
|
|
13
|
-
platformUrl = 'https://stoplight.io',
|
|
14
|
-
platformAuthToken,
|
|
15
|
-
isLoggedIn,
|
|
16
|
-
children,
|
|
17
|
-
}) => {
|
|
18
|
-
return (
|
|
19
|
-
<PlatformContext.Provider value={{ platformUrl, platformAuthToken, isLoggedIn }}>
|
|
20
|
-
{children}
|
|
21
|
-
</PlatformContext.Provider>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const DevPortalProvider = withPersistenceBoundary(withQueryClientProvider(withMosaicProvider(PlatformProvider)));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Box, Flex, Heading, VStack } from '@stoplight/mosaic';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
export const Forbidden = () => (
|
|
5
|
-
<Flex align="center" justify="center" flexGrow>
|
|
6
|
-
<VStack spacing={4} align="center">
|
|
7
|
-
<Heading size={1}>Forbidden</Heading>
|
|
8
|
-
<Box as="p">You don't have permission to access this resource</Box>
|
|
9
|
-
</VStack>
|
|
10
|
-
</Flex>
|
|
11
|
-
);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { faCircleNotch } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
-
import { Flex, Icon } from '@stoplight/mosaic';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
export const Loading = () => (
|
|
6
|
-
<Flex justify="center" alignItems="center" w="full" minH="screen" color="muted">
|
|
7
|
-
<Icon icon={faCircleNotch} size="3x" spin />
|
|
8
|
-
</Flex>
|
|
9
|
-
);
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { CustomLinkComponent } from '@stoplight/elements-core';
|
|
2
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
5
|
-
|
|
6
|
-
import nodeContent from '../../__fixtures__/node-content.json';
|
|
7
|
-
import { NodeContent } from './NodeContent';
|
|
8
|
-
|
|
9
|
-
const DummyLink: CustomLinkComponent = ({ children, ...propsRest }) => {
|
|
10
|
-
return <a {...propsRest}>{children}</a>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const data = {
|
|
14
|
-
id: '35hsi28m3b2m0',
|
|
15
|
-
branch_node_id: -1,
|
|
16
|
-
type: 'article',
|
|
17
|
-
uri: '/docs/test.md',
|
|
18
|
-
slug: '35hsi28m3b2m0-header',
|
|
19
|
-
title: 'Header',
|
|
20
|
-
summary:
|
|
21
|
-
'This is the main header section.\nThe beginning of an awesome article...\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetu...',
|
|
22
|
-
project_id: 'cHJqOjQz',
|
|
23
|
-
branch_id: 'YnI6MjQw',
|
|
24
|
-
branch: 'main',
|
|
25
|
-
links: {},
|
|
26
|
-
outbound_edges: [
|
|
27
|
-
{
|
|
28
|
-
id: '35hsi28m3b2m0',
|
|
29
|
-
type: 'article',
|
|
30
|
-
slug: '35hsi28m3b2m0-header',
|
|
31
|
-
title: 'Header',
|
|
32
|
-
uri: '/docs/test.md',
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
inbound_edges: [],
|
|
36
|
-
data: '---\nstoplight-id: 35hsi28m3b2m0\n---\n\n# Header\nThis is the main header section.\nThe beginning of an awesome article...\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Naggggm quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,\n\n## Subheader\nThis is the subheader section. More ContentHere is some more dummy content to fill the page.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum vestibulum. Cras venenatis euismod malesuada.\nThe beginning of an awesome article...\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Naggggm quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,\n### External\nLinkFor more information, visit Google.\nThe beginning of an awesome article...\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Naggggm quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,\n\n[Go to header](#header)\n\n[Go to subheader](#subheader)\n\n<a href="https://www.google.com">Go to Google</a>',
|
|
37
|
-
};
|
|
38
|
-
describe(NodeContent.name, () => {
|
|
39
|
-
it('renders correctly', async () => {
|
|
40
|
-
const { unmount } = render(
|
|
41
|
-
<MemoryRouter>
|
|
42
|
-
<NodeContent node={nodeContent} Link={DummyLink} />
|
|
43
|
-
</MemoryRouter>,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
expect(screen.getByRole('heading', { name: /create todo/i })).toBeInTheDocument();
|
|
47
|
-
expect(
|
|
48
|
-
await screen.findByText(
|
|
49
|
-
'Markdown is supported in descriptions. Add information here for users to get accustomed to endpoints',
|
|
50
|
-
),
|
|
51
|
-
).toBeInTheDocument();
|
|
52
|
-
|
|
53
|
-
unmount();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('shows TryIt by default', () => {
|
|
57
|
-
const { unmount } = render(
|
|
58
|
-
<MemoryRouter>
|
|
59
|
-
<NodeContent node={nodeContent} Link={DummyLink} />
|
|
60
|
-
</MemoryRouter>,
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
expect(screen.getByText(/send api request/i)).toBeInTheDocument();
|
|
64
|
-
|
|
65
|
-
unmount();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('can hide TryIt', () => {
|
|
69
|
-
const { unmount } = render(
|
|
70
|
-
<MemoryRouter>
|
|
71
|
-
<NodeContent node={nodeContent} Link={DummyLink} hideTryIt />
|
|
72
|
-
</MemoryRouter>,
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
expect(screen.queryByText(/send api request/i)).not.toBeInTheDocument();
|
|
76
|
-
|
|
77
|
-
unmount();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('can hide SecurityInfo', () => {
|
|
81
|
-
const { unmount } = render(
|
|
82
|
-
<MemoryRouter>
|
|
83
|
-
<NodeContent node={nodeContent} Link={DummyLink} hideSecurityInfo />
|
|
84
|
-
</MemoryRouter>,
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
expect(screen.getByRole('heading', { name: /create todo/i })).toBeInTheDocument();
|
|
88
|
-
expect(screen.queryByText(/API Key/i)).not.toBeInTheDocument();
|
|
89
|
-
|
|
90
|
-
unmount();
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
describe('NodeContent Component Navigation Links', () => {
|
|
95
|
-
const originalLocation = window.location;
|
|
96
|
-
beforeAll(() => {
|
|
97
|
-
delete (window as any).location;
|
|
98
|
-
(window as any).location = {
|
|
99
|
-
...originalLocation,
|
|
100
|
-
pathname: data.slug,
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('renders links with correct href attributes and navigates to target sections on click', () => {
|
|
105
|
-
const { unmount } = render(
|
|
106
|
-
<MemoryRouter>
|
|
107
|
-
<NodeContent node={data} Link={DummyLink} hideSecurityInfo />
|
|
108
|
-
</MemoryRouter>,
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
const headerElement = screen.getByRole('link', { name: /Go to header/i });
|
|
112
|
-
const subheaderElement = screen.getByRole('link', { name: /Go to subheader/i });
|
|
113
|
-
|
|
114
|
-
expect(headerElement).toHaveAttribute('href', '#header');
|
|
115
|
-
expect(subheaderElement).toHaveAttribute('href', '#subheader');
|
|
116
|
-
fireEvent.click(headerElement);
|
|
117
|
-
|
|
118
|
-
expect(document.getElementById('header')).toBeInTheDocument();
|
|
119
|
-
fireEvent.click(subheaderElement);
|
|
120
|
-
expect(document.getElementById('subheader')).toBeInTheDocument();
|
|
121
|
-
|
|
122
|
-
unmount();
|
|
123
|
-
|
|
124
|
-
afterAll(() => {
|
|
125
|
-
window.location = originalLocation;
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
});
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Story } from '@storybook/react';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
import { useGetNodeContent } from '../../hooks/useGetNodeContent';
|
|
5
|
-
import { NodeContent } from './';
|
|
6
|
-
|
|
7
|
-
// Wrapper to show how to use the node content hook
|
|
8
|
-
const NodeContentWrapper = ({
|
|
9
|
-
nodeSlug,
|
|
10
|
-
projectId,
|
|
11
|
-
branchSlug,
|
|
12
|
-
}: {
|
|
13
|
-
nodeSlug: string;
|
|
14
|
-
projectId: string;
|
|
15
|
-
branchSlug?: string;
|
|
16
|
-
}) => {
|
|
17
|
-
const { data } = useGetNodeContent({ nodeSlug, projectId, branchSlug });
|
|
18
|
-
|
|
19
|
-
return data ? (
|
|
20
|
-
<NodeContent
|
|
21
|
-
node={data}
|
|
22
|
-
Link={({ children, ...props }) => {
|
|
23
|
-
return (
|
|
24
|
-
<a
|
|
25
|
-
onClick={() => {
|
|
26
|
-
console.log('Link clicked!', props);
|
|
27
|
-
}}
|
|
28
|
-
>
|
|
29
|
-
{children}
|
|
30
|
-
</a>
|
|
31
|
-
);
|
|
32
|
-
}}
|
|
33
|
-
/>
|
|
34
|
-
) : (
|
|
35
|
-
<>Loading</>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default {
|
|
40
|
-
title: 'Public/NodeContent',
|
|
41
|
-
component: NodeContentWrapper,
|
|
42
|
-
argTypes: {
|
|
43
|
-
nodeSlug: { table: { category: 'Input' } },
|
|
44
|
-
projectId: { table: { category: 'Input' } },
|
|
45
|
-
branchSlug: { table: { category: 'Input' } },
|
|
46
|
-
platformUrl: { table: { category: 'Input' } },
|
|
47
|
-
},
|
|
48
|
-
args: {
|
|
49
|
-
nodeSlug: 'b3A6Mzg5NDM2-create-todo',
|
|
50
|
-
projectId: 'cHJqOjYwNjYx',
|
|
51
|
-
branchSlug: '',
|
|
52
|
-
platformUrl: 'https://stoplight.io',
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const Playground: Story<{ nodeSlug: string; projectId: string; branchSlug?: string }> = args => (
|
|
57
|
-
<NodeContentWrapper {...args} />
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
Playground.storyName = 'Create Todo';
|