@stoplight/elements-dev-portal 3.0.12-beta-0.2 → 3.0.12-beta-0.4

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.
Files changed (108) hide show
  1. package/{dist/index.esm.js → index.esm.js} +1 -1
  2. package/{dist/index.js → index.js} +1 -1
  3. package/{dist/index.mjs → index.mjs} +1 -1
  4. package/package.json +17 -71
  5. package/version.d.ts +1 -0
  6. package/web-components.min.js +2 -0
  7. package/.storybook/main.js +0 -6
  8. package/.storybook/manager.js +0 -1
  9. package/.storybook/preview.jsx +0 -46
  10. package/dist/LICENSE +0 -190
  11. package/dist/README.md +0 -22
  12. package/dist/package.json +0 -51
  13. package/dist/version.d.ts +0 -1
  14. package/dist/web-components.min.js +0 -2
  15. package/jest.config.js +0 -10
  16. package/src/__fixtures__/branches.json +0 -28
  17. package/src/__fixtures__/node-content.json +0 -257
  18. package/src/__fixtures__/table-of-contents.json +0 -144
  19. package/src/components/BranchSelector/BranchSelector.spec.tsx +0 -61
  20. package/src/components/BranchSelector/BranchSelector.stories.tsx +0 -41
  21. package/src/components/BranchSelector/BranchSelector.tsx +0 -50
  22. package/src/components/BranchSelector/index.tsx +0 -1
  23. package/src/components/DevPortalProvider/index.tsx +0 -25
  24. package/src/components/Forbidden.tsx +0 -11
  25. package/src/components/Loading.tsx +0 -9
  26. package/src/components/NodeContent/NodeContent.spec.tsx +0 -128
  27. package/src/components/NodeContent/NodeContent.stories.tsx +0 -60
  28. package/src/components/NodeContent/NodeContent.tsx +0 -235
  29. package/src/components/NodeContent/index.tsx +0 -1
  30. package/src/components/NotFound.tsx +0 -11
  31. package/src/components/Search/Search.stories.tsx +0 -151
  32. package/src/components/Search/Search.tsx +0 -161
  33. package/src/components/Search/SearchOverlay.tsx +0 -88
  34. package/src/components/Search/index.tsx +0 -1
  35. package/src/components/TableOfContents/TableOfContents.stories.tsx +0 -68
  36. package/src/components/TableOfContents/TableOfContents.tsx +0 -54
  37. package/src/components/TableOfContents/index.tsx +0 -1
  38. package/src/components/UpgradeToStarter.tsx +0 -22
  39. package/src/consts.ts +0 -32
  40. package/src/containers/StoplightProject.spec.tsx +0 -78
  41. package/src/containers/StoplightProject.stories.tsx +0 -28
  42. package/src/containers/StoplightProject.tsx +0 -269
  43. package/src/handlers/__tests__/getBranches.test.ts +0 -30
  44. package/src/handlers/__tests__/getNodeContent.test.ts +0 -35
  45. package/src/handlers/__tests__/getNodes.test.ts +0 -38
  46. package/src/handlers/__tests__/getTableOfContents.test.ts +0 -34
  47. package/src/handlers/__tests__/getWorkspace.test.ts +0 -30
  48. package/src/handlers/getBranches.ts +0 -27
  49. package/src/handlers/getNodeContent.ts +0 -53
  50. package/src/handlers/getNodes.ts +0 -69
  51. package/src/handlers/getTableOfContents.ts +0 -30
  52. package/src/handlers/getWorkspace.ts +0 -27
  53. package/src/hooks/__tests__/dataFetching.spec.tsx +0 -42
  54. package/src/hooks/useGetBranches.ts +0 -17
  55. package/src/hooks/useGetNodeContent.ts +0 -24
  56. package/src/hooks/useGetNodes.ts +0 -34
  57. package/src/hooks/useGetTableOfContents.ts +0 -17
  58. package/src/hooks/useGetWorkspace.tsx +0 -13
  59. package/src/index.ts +0 -25
  60. package/src/styles.css +0 -1
  61. package/src/types.ts +0 -85
  62. package/src/version.ts +0 -2
  63. package/src/web-components/__stories__/StoplightProject.stories.tsx +0 -33
  64. package/src/web-components/components.ts +0 -19
  65. package/src/web-components/index.ts +0 -3
  66. package/tsconfig.build.json +0 -18
  67. package/tsconfig.json +0 -7
  68. package/web-components.config.js +0 -1
  69. /package/{dist/components → components}/BranchSelector/BranchSelector.d.ts +0 -0
  70. /package/{dist/components → components}/BranchSelector/BranchSelector.spec.d.ts +0 -0
  71. /package/{dist/components → components}/BranchSelector/BranchSelector.stories.d.ts +0 -0
  72. /package/{dist/components → components}/BranchSelector/index.d.ts +0 -0
  73. /package/{dist/components → components}/DevPortalProvider/index.d.ts +0 -0
  74. /package/{dist/components → components}/Forbidden.d.ts +0 -0
  75. /package/{dist/components → components}/Loading.d.ts +0 -0
  76. /package/{dist/components → components}/NodeContent/NodeContent.d.ts +0 -0
  77. /package/{dist/components → components}/NodeContent/NodeContent.spec.d.ts +0 -0
  78. /package/{dist/components → components}/NodeContent/NodeContent.stories.d.ts +0 -0
  79. /package/{dist/components → components}/NodeContent/index.d.ts +0 -0
  80. /package/{dist/components → components}/NotFound.d.ts +0 -0
  81. /package/{dist/components → components}/Search/Search.d.ts +0 -0
  82. /package/{dist/components → components}/Search/Search.stories.d.ts +0 -0
  83. /package/{dist/components → components}/Search/SearchOverlay.d.ts +0 -0
  84. /package/{dist/components → components}/Search/index.d.ts +0 -0
  85. /package/{dist/components → components}/TableOfContents/TableOfContents.d.ts +0 -0
  86. /package/{dist/components → components}/TableOfContents/TableOfContents.stories.d.ts +0 -0
  87. /package/{dist/components → components}/TableOfContents/index.d.ts +0 -0
  88. /package/{dist/components → components}/UpgradeToStarter.d.ts +0 -0
  89. /package/{dist/consts.d.ts → consts.d.ts} +0 -0
  90. /package/{dist/containers → containers}/StoplightProject.d.ts +0 -0
  91. /package/{dist/containers → containers}/StoplightProject.spec.d.ts +0 -0
  92. /package/{dist/containers → containers}/StoplightProject.stories.d.ts +0 -0
  93. /package/{dist/handlers → handlers}/getBranches.d.ts +0 -0
  94. /package/{dist/handlers → handlers}/getNodeContent.d.ts +0 -0
  95. /package/{dist/handlers → handlers}/getNodes.d.ts +0 -0
  96. /package/{dist/handlers → handlers}/getTableOfContents.d.ts +0 -0
  97. /package/{dist/handlers → handlers}/getWorkspace.d.ts +0 -0
  98. /package/{dist/hooks → hooks}/useGetBranches.d.ts +0 -0
  99. /package/{dist/hooks → hooks}/useGetNodeContent.d.ts +0 -0
  100. /package/{dist/hooks → hooks}/useGetNodes.d.ts +0 -0
  101. /package/{dist/hooks → hooks}/useGetTableOfContents.d.ts +0 -0
  102. /package/{dist/hooks → hooks}/useGetWorkspace.d.ts +0 -0
  103. /package/{dist/index.d.ts → index.d.ts} +0 -0
  104. /package/{dist/styles.min.css → styles.min.css} +0 -0
  105. /package/{dist/types.d.ts → types.d.ts} +0 -0
  106. /package/{dist/web-components → web-components}/components.d.ts +0 -0
  107. /package/{dist/web-components → web-components}/index.d.ts +0 -0
  108. /package/{dist/web-components.min.js.LICENSE.txt → web-components.min.js.LICENSE.txt} +0 -0
package/jest.config.js DELETED
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- ...require('../../jest.config'),
3
- reporters: [
4
- 'default',
5
- [
6
- 'jest-junit',
7
- { suiteName: 'elements-dev-portal', outputFile: '<rootDir>/../../test-results/elements-dev-portal/results.xml' },
8
- ],
9
- ],
10
- };
@@ -1,28 +0,0 @@
1
- {
2
- "items": [
3
- {
4
- "id": "YnI6NDc4MDUy",
5
- "name": null,
6
- "slug": "master",
7
- "is_default": true,
8
- "is_published": true,
9
- "project_id": "cHJqOjM1ODEw"
10
- },
11
- {
12
- "id": "YnI6OTYwNDM4",
13
- "name": null,
14
- "slug": "v2",
15
- "is_default": false,
16
- "is_published": true,
17
- "project_id": "cHJqOjM1ODEw"
18
- },
19
- {
20
- "id": "YnI6OTYwNDM5",
21
- "name": null,
22
- "slug": "feat/toc-file",
23
- "is_default": false,
24
- "is_published": true,
25
- "project_id": "cHJqOjM1ODEw"
26
- }
27
- ]
28
- }
@@ -1,257 +0,0 @@
1
- {
2
- "id": "b3A6Mzg5NDM2",
3
- "branch_node_id": 21,
4
- "type": "http_operation",
5
- "uri": "/reference/todos/todo.v1.yaml/paths/~1todos/post",
6
- "slug": "b3A6Mzg5NDM2-create-todo",
7
- "title": "Create Todo",
8
- "branch": "master",
9
- "summary": "This creates a Todo object\n\n*Markdown is supported in descriptions. Add information here for users to get accustomed to endpoints*",
10
- "project_id": "cHJqOjExOTY",
11
- "branch_id": "YnI6MTAyODA",
12
- "data": {
13
- "id": "?http-operation-id?",
14
- "iid": "post-todos",
15
- "description": "This creates a Todo object\n\n*Markdown is supported in descriptions. Add information here for users to get accustomed to endpoints*",
16
- "method": "post",
17
- "path": "/todos",
18
- "summary": "Create Todo",
19
- "responses": [
20
- {
21
- "code": "201",
22
- "description": "New Todo Created",
23
- "headers": [],
24
- "contents": [
25
- {
26
- "mediaType": "multipart/form-data",
27
- "schema": {
28
- "description": "I'm a model's description.",
29
- "type": "object",
30
- "x-examples": {},
31
- "title": "Todo",
32
- "properties": {
33
- "id": {
34
- "type": "number",
35
- "minimum": 0,
36
- "maximum": 9999,
37
- "description": "ID of the task",
38
- "readOnly": true
39
- },
40
- "name": { "type": "string", "minLength": 1, "maxLength": 100, "description": "Name of the task" },
41
- "completed": {
42
- "type": "boolean",
43
- "default": false,
44
- "description": "Boolean indicating if the task has been completed or not"
45
- },
46
- "completed_at": {
47
- "type": "string",
48
- "format": "date-time",
49
- "description": "Time when the task was completed",
50
- "readOnly": true
51
- },
52
- "created_at": {
53
- "type": "string",
54
- "format": "date-time",
55
- "description": "Time when the task was created",
56
- "readOnly": true
57
- },
58
- "updated_at": {
59
- "type": "string",
60
- "format": "date-time",
61
- "description": "Time when the task was updated",
62
- "readOnly": true
63
- }
64
- },
65
- "required": ["id", "name", "completed_at", "created_at", "updated_at"],
66
- "$schema": "http://json-schema.org/draft-07/schema#"
67
- },
68
- "examples": [
69
- {
70
- "key": "Example Todo",
71
- "value": {
72
- "id": 0,
73
- "name": "string",
74
- "completed": true,
75
- "completed_at": "2019-08-24T14:15:22Z",
76
- "created_at": "2019-08-24T14:15:22Z",
77
- "updated_at": "2019-08-24T14:15:22Z"
78
- }
79
- }
80
- ],
81
- "encodings": []
82
- }
83
- ]
84
- },
85
- {
86
- "code": "403",
87
- "description": "Action not allowed",
88
- "headers": [],
89
- "contents": [
90
- {
91
- "mediaType": "application/json",
92
- "schema": {
93
- "type": "object",
94
- "properties": { "message": { "type": "string" } },
95
- "required": ["message"],
96
- "$schema": "http://json-schema.org/draft-07/schema#"
97
- },
98
- "examples": [],
99
- "encodings": []
100
- }
101
- ]
102
- },
103
- {
104
- "code": "404",
105
- "description": "Resource not found",
106
- "headers": [],
107
- "contents": [
108
- {
109
- "mediaType": "application/json",
110
- "schema": {
111
- "title": "Error",
112
- "type": "object",
113
- "description": "A standard error object.",
114
- "x-tags": ["Common"],
115
- "properties": { "status": { "type": "string", "description": "A code." }, "error": { "type": "string" } },
116
- "required": ["status", "error"],
117
- "$schema": "http://json-schema.org/draft-07/schema#"
118
- },
119
- "examples": [],
120
- "encodings": []
121
- }
122
- ]
123
- }
124
- ],
125
- "servers": [
126
- { "description": "Production", "url": "https://todos.stoplight.io" },
127
- { "description": "Sandbox", "url": "https://todos-sandbox.stoplight.io" }
128
- ],
129
- "request": {
130
- "body": {
131
- "description": "Name of the Todo",
132
- "contents": [
133
- {
134
- "mediaType": "application/json",
135
- "schema": {
136
- "description": "I'm a model's description.",
137
- "type": "object",
138
- "x-examples": {},
139
- "title": "Todo",
140
- "properties": {
141
- "id": {
142
- "type": "number",
143
- "minimum": 0,
144
- "maximum": 9999,
145
- "description": "ID of the task",
146
- "readOnly": true
147
- },
148
- "name": { "type": "string", "minLength": 1, "maxLength": 100, "description": "Name of the task" },
149
- "completed": {
150
- "type": "boolean",
151
- "default": false,
152
- "description": "Boolean indicating if the task has been completed or not"
153
- },
154
- "completed_at": {
155
- "type": "string",
156
- "format": "date-time",
157
- "description": "Time when the task was completed",
158
- "readOnly": true
159
- },
160
- "created_at": {
161
- "type": "string",
162
- "format": "date-time",
163
- "description": "Time when the task was created",
164
- "readOnly": true
165
- },
166
- "updated_at": {
167
- "type": "string",
168
- "format": "date-time",
169
- "description": "Time when the task was updated",
170
- "readOnly": true
171
- }
172
- },
173
- "required": ["id", "name", "completed_at", "created_at", "updated_at"],
174
- "$schema": "http://json-schema.org/draft-07/schema#"
175
- },
176
- "examples": [],
177
- "encodings": []
178
- }
179
- ]
180
- },
181
- "headers": [
182
- {
183
- "name": "Content-Type",
184
- "required": true,
185
- "description": "application/json",
186
- "schema": {
187
- "type": "string",
188
- "default": "application/json",
189
- "$schema": "http://json-schema.org/draft-07/schema#"
190
- },
191
- "examples": []
192
- }
193
- ],
194
- "query": [],
195
- "cookie": [],
196
- "path": []
197
- },
198
- "tags": [],
199
- "security": [
200
- [
201
- {
202
- "key": "API Key",
203
- "description": "Just use `123`. It's super secure ;)",
204
- "type": "apiKey",
205
- "name": "apikey",
206
- "in": "query"
207
- }
208
- ]
209
- ]
210
- },
211
- "links": { "mock_url": "https://stoplight.io/mocks/demo/studio-demo/389434/todos" },
212
- "outbound_edges": [
213
- {
214
- "id": "c2NoOjkxNDY1MDA",
215
- "type": "model",
216
- "slug": "c2NoOjkxNDY1MDA-todo",
217
- "title": "Todo",
218
- "uri": "/reference/todos/todo.v1.yaml/components/schemas/Todos"
219
- },
220
- {
221
- "id": "YXBpOjM4OTQzNA",
222
- "type": "http_service",
223
- "slug": "YXBpOjM4OTQzNA-to-dos",
224
- "title": "To-dos",
225
- "uri": "/reference/todos/todo.v1.yaml"
226
- },
227
- {
228
- "id": "YXBpOjM4OTQzNA",
229
- "type": "http_service",
230
- "slug": "YXBpOjM4OTQzNA-to-dos",
231
- "title": "To-dos",
232
- "uri": "/reference/todos/todo.v1.yaml"
233
- },
234
- {
235
- "id": "YXBpOjM4OTQzNA",
236
- "type": "http_service",
237
- "slug": "YXBpOjM4OTQzNA-to-dos",
238
- "title": "To-dos",
239
- "uri": "/reference/todos/todo.v1.yaml"
240
- },
241
- {
242
- "id": "c2NoOjkxNDY1MDA",
243
- "type": "model",
244
- "slug": "c2NoOjkxNDY1MDA-todo",
245
- "title": "Todo",
246
- "uri": "/reference/todos/todo.v1.yaml/components/schemas/Todos"
247
- },
248
- {
249
- "id": "YXBpOjM4OTQzNA",
250
- "type": "http_service",
251
- "slug": "YXBpOjM4OTQzNA-to-dos",
252
- "title": "To-dos",
253
- "uri": "/reference/todos/todo.v1.yaml"
254
- }
255
- ],
256
- "inbound_edges": []
257
- }
@@ -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
- );