@looker/api-explorer 0.9.36 → 0.9.38
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/CHANGELOG.md +49 -1
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.map +1 -1
- package/e2e/MethodScene.spec.ts +80 -0
- package/e2e/diffScene.spec.ts +28 -20
- package/e2e/e2e.spec.ts +45 -7
- package/lib/ApiExplorer.js +17 -6
- package/lib/ApiExplorer.js.map +1 -1
- package/lib/components/DocMarkdown/DocMarkdown.js +3 -1
- package/lib/components/DocMarkdown/DocMarkdown.js.map +1 -1
- package/lib/components/DocSDKs/DocDeclarations.js +10 -15
- package/lib/components/DocSDKs/DocDeclarations.js.map +1 -1
- package/lib/components/SelectorContainer/ApiSpecSelector.js +3 -1
- package/lib/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
- package/lib/components/SelectorContainer/SdkLanguageSelector.js +20 -21
- package/lib/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
- package/lib/components/SelectorContainer/SelectorContainer.js +4 -1
- package/lib/components/SelectorContainer/SelectorContainer.js.map +1 -1
- package/lib/components/SelectorContainer/utils.d.ts +2 -0
- package/lib/components/SelectorContainer/utils.js +32 -0
- package/lib/components/SelectorContainer/utils.js.map +1 -0
- package/lib/components/SideNav/SideNav.js +20 -9
- package/lib/components/SideNav/SideNav.js.map +1 -1
- package/lib/components/SideNav/SideNavMethods.js +7 -6
- package/lib/components/SideNav/SideNavMethods.js.map +1 -1
- package/lib/components/SideNav/SideNavTypes.js +5 -4
- package/lib/components/SideNav/SideNavTypes.js.map +1 -1
- package/lib/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -8
- package/lib/components/index.js.map +1 -1
- package/lib/esm/ApiExplorer.js +19 -8
- package/lib/esm/ApiExplorer.js.map +1 -1
- package/lib/esm/components/DocMarkdown/DocMarkdown.js +3 -1
- package/lib/esm/components/DocMarkdown/DocMarkdown.js.map +1 -1
- package/lib/esm/components/DocSDKs/DocDeclarations.js +9 -14
- package/lib/esm/components/DocSDKs/DocDeclarations.js.map +1 -1
- package/lib/esm/components/SelectorContainer/ApiSpecSelector.js +3 -1
- package/lib/esm/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
- package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js +16 -18
- package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
- package/lib/esm/components/SelectorContainer/SelectorContainer.js +5 -2
- package/lib/esm/components/SelectorContainer/SelectorContainer.js.map +1 -1
- package/lib/esm/components/SelectorContainer/utils.js +22 -0
- package/lib/esm/components/SelectorContainer/utils.js.map +1 -0
- package/lib/esm/components/SideNav/SideNav.js +20 -10
- package/lib/esm/components/SideNav/SideNav.js.map +1 -1
- package/lib/esm/components/SideNav/SideNavMethods.js +8 -7
- package/lib/esm/components/SideNav/SideNavMethods.js.map +1 -1
- package/lib/esm/components/SideNav/SideNavTypes.js +6 -5
- package/lib/esm/components/SideNav/SideNavTypes.js.map +1 -1
- package/lib/esm/components/index.js +0 -1
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/routes/AppRouter.js +6 -4
- package/lib/esm/routes/AppRouter.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DiffScene.js +9 -7
- package/lib/esm/scenes/DiffScene/DiffScene.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js +3 -1
- package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js +4 -4
- package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
- package/lib/esm/scenes/ErrorDetailScene/ErrorDetailScene.js +31 -0
- package/lib/esm/scenes/ErrorDetailScene/ErrorDetailScene.js.map +1 -0
- package/lib/esm/scenes/ErrorDetailScene/index.js +2 -0
- package/lib/esm/scenes/ErrorDetailScene/index.js.map +1 -0
- package/lib/esm/scenes/MethodScene/MethodScene.js +28 -9
- package/lib/esm/scenes/MethodScene/MethodScene.js.map +1 -1
- package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.js +1 -1
- package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponseTypes.js.map +1 -0
- package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponses.js +73 -0
- package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponses.js.map +1 -0
- package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/index.js +0 -0
- package/lib/esm/scenes/MethodScene/components/DocResponses/index.js.map +1 -0
- package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/utils.js +0 -0
- package/lib/esm/scenes/MethodScene/components/DocResponses/utils.js.map +1 -0
- package/lib/esm/scenes/MethodScene/components/index.js +1 -0
- package/lib/esm/scenes/MethodScene/components/index.js.map +1 -1
- package/lib/esm/scenes/MethodTagScene/MethodTagScene.js +38 -11
- package/lib/esm/scenes/MethodTagScene/MethodTagScene.js.map +1 -1
- package/lib/esm/scenes/TypeScene/TypeScene.js +3 -1
- package/lib/esm/scenes/TypeScene/TypeScene.js.map +1 -1
- package/lib/esm/scenes/TypeTagScene/TypeTagScene.js +37 -10
- package/lib/esm/scenes/TypeTagScene/TypeTagScene.js.map +1 -1
- package/lib/esm/scenes/index.js +1 -0
- package/lib/esm/scenes/index.js.map +1 -1
- package/lib/esm/scenes/utils/hooks/index.js +2 -0
- package/lib/esm/scenes/utils/hooks/index.js.map +1 -0
- package/lib/esm/scenes/utils/hooks/tagStoreSync.js +37 -0
- package/lib/esm/scenes/utils/hooks/tagStoreSync.js.map +1 -0
- package/lib/esm/scenes/utils/index.js +2 -0
- package/lib/esm/scenes/utils/index.js.map +1 -0
- package/lib/esm/state/settings/selectors.js +1 -0
- package/lib/esm/state/settings/selectors.js.map +1 -1
- package/lib/esm/state/settings/slice.js +6 -1
- package/lib/esm/state/settings/slice.js.map +1 -1
- package/lib/esm/utils/hooks/globalStoreSync.js +53 -0
- package/lib/esm/utils/hooks/globalStoreSync.js.map +1 -0
- package/lib/esm/utils/hooks/index.js +4 -0
- package/lib/esm/utils/hooks/index.js.map +1 -0
- package/lib/esm/utils/hooks/navigation.js +72 -0
- package/lib/esm/utils/hooks/navigation.js.map +1 -0
- package/lib/esm/utils/hooks/useQuery.js +9 -0
- package/lib/esm/utils/hooks/useQuery.js.map +1 -0
- package/lib/esm/utils/index.js +2 -1
- package/lib/esm/utils/index.js.map +1 -1
- package/lib/esm/utils/path.js +21 -0
- package/lib/esm/utils/path.js.map +1 -1
- package/lib/esm/utils/sdkLanguage.js +42 -0
- package/lib/esm/utils/sdkLanguage.js.map +1 -0
- package/lib/routes/AppRouter.d.ts +1 -2
- package/lib/routes/AppRouter.js +5 -3
- package/lib/routes/AppRouter.js.map +1 -1
- package/lib/scenes/DiffScene/DiffScene.d.ts +0 -2
- package/lib/scenes/DiffScene/DiffScene.js +8 -6
- package/lib/scenes/DiffScene/DiffScene.js.map +1 -1
- package/lib/scenes/DiffScene/DocDiff/DiffItem.js +3 -1
- package/lib/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
- package/lib/scenes/DiffScene/DocDiff/DocDiff.js +4 -4
- package/lib/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
- package/lib/scenes/ErrorDetailScene/ErrorDetailScene.d.ts +7 -0
- package/lib/scenes/ErrorDetailScene/ErrorDetailScene.js +47 -0
- package/lib/scenes/ErrorDetailScene/ErrorDetailScene.js.map +1 -0
- package/lib/scenes/ErrorDetailScene/index.d.ts +1 -0
- package/lib/scenes/ErrorDetailScene/index.js +14 -0
- package/lib/{components/DocResponses → scenes/ErrorDetailScene}/index.js.map +1 -1
- package/lib/scenes/MethodScene/MethodScene.js +23 -4
- package/lib/scenes/MethodScene/MethodScene.js.map +1 -1
- package/lib/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.d.ts +2 -2
- package/lib/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.js +2 -2
- package/lib/scenes/MethodScene/components/DocResponses/DocResponseTypes.js.map +1 -0
- package/lib/scenes/MethodScene/components/DocResponses/DocResponses.d.ts +9 -0
- package/lib/scenes/MethodScene/components/DocResponses/DocResponses.js +93 -0
- package/lib/scenes/MethodScene/components/DocResponses/DocResponses.js.map +1 -0
- package/lib/{components → scenes/MethodScene/components}/DocResponses/index.d.ts +0 -0
- package/lib/{components → scenes/MethodScene/components}/DocResponses/index.js +0 -0
- package/lib/scenes/MethodScene/components/DocResponses/index.js.map +1 -0
- package/lib/{components → scenes/MethodScene/components}/DocResponses/utils.d.ts +0 -0
- package/lib/{components → scenes/MethodScene/components}/DocResponses/utils.js +0 -0
- package/lib/scenes/MethodScene/components/DocResponses/utils.js.map +1 -0
- package/lib/scenes/MethodScene/components/index.d.ts +1 -0
- package/lib/scenes/MethodScene/components/index.js +8 -0
- package/lib/scenes/MethodScene/components/index.js.map +1 -1
- package/lib/scenes/MethodTagScene/MethodTagScene.js +42 -12
- package/lib/scenes/MethodTagScene/MethodTagScene.js.map +1 -1
- package/lib/scenes/TypeScene/TypeScene.js +3 -1
- package/lib/scenes/TypeScene/TypeScene.js.map +1 -1
- package/lib/scenes/TypeTagScene/TypeTagScene.js +41 -11
- package/lib/scenes/TypeTagScene/TypeTagScene.js.map +1 -1
- package/lib/scenes/index.d.ts +1 -0
- package/lib/scenes/index.js +8 -0
- package/lib/scenes/index.js.map +1 -1
- package/lib/scenes/utils/hooks/index.d.ts +1 -0
- package/lib/scenes/utils/hooks/index.js +14 -0
- package/lib/scenes/utils/hooks/index.js.map +1 -0
- package/lib/scenes/utils/hooks/tagStoreSync.d.ts +1 -0
- package/lib/scenes/utils/hooks/tagStoreSync.js +51 -0
- package/lib/scenes/utils/hooks/tagStoreSync.js.map +1 -0
- package/lib/scenes/utils/index.d.ts +1 -0
- package/lib/scenes/utils/index.js +14 -0
- package/lib/scenes/utils/index.js.map +1 -0
- package/lib/state/settings/selectors.d.ts +2 -1
- package/lib/state/settings/selectors.js +5 -1
- package/lib/state/settings/selectors.js.map +1 -1
- package/lib/state/settings/slice.d.ts +7 -1
- package/lib/state/settings/slice.js +6 -1
- package/lib/state/settings/slice.js.map +1 -1
- package/lib/test-data/index.d.ts +1 -0
- package/lib/test-data/index.js +14 -0
- package/lib/test-data/index.js.map +1 -1
- package/lib/test-data/sdkLanguages.d.ts +10 -0
- package/lib/test-data/sdkLanguages.js +19 -0
- package/lib/test-data/sdkLanguages.js.map +1 -0
- package/lib/utils/hooks/globalStoreSync.d.ts +1 -0
- package/lib/utils/hooks/globalStoreSync.js +67 -0
- package/lib/utils/hooks/globalStoreSync.js.map +1 -0
- package/lib/utils/hooks/index.d.ts +3 -0
- package/lib/utils/hooks/index.js +30 -0
- package/lib/utils/hooks/index.js.map +1 -0
- package/lib/utils/hooks/navigation.d.ts +11 -0
- package/lib/utils/hooks/navigation.js +83 -0
- package/lib/utils/hooks/navigation.js.map +1 -0
- package/lib/utils/hooks/useQuery.d.ts +1 -0
- package/lib/utils/hooks/useQuery.js +20 -0
- package/lib/utils/hooks/useQuery.js.map +1 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +29 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/path.d.ts +4 -0
- package/lib/utils/path.js +32 -1
- package/lib/utils/path.js.map +1 -1
- package/lib/utils/sdkLanguage.d.ts +6 -0
- package/lib/utils/sdkLanguage.js +59 -0
- package/lib/utils/sdkLanguage.js.map +1 -0
- package/package.json +14 -14
- package/src/ApiExplorer.tsx +13 -8
- package/src/components/DocMarkdown/DocMarkdown.tsx +1 -1
- package/src/components/DocSDKs/DocDeclarations.tsx +11 -22
- package/src/components/DocSDKs/DocSDKs.spec.tsx +4 -1
- package/src/components/Header/Header.spec.tsx +1 -1
- package/src/components/SelectorContainer/ApiSpecSelector.tsx +1 -1
- package/src/components/SelectorContainer/SdkLanguageSelector.spec.tsx +60 -33
- package/src/components/SelectorContainer/SdkLanguageSelector.tsx +15 -22
- package/src/components/SelectorContainer/SelectorContainer.spec.tsx +1 -1
- package/src/components/SelectorContainer/SelectorContainer.tsx +18 -15
- package/src/{utils/hooks.ts → components/SelectorContainer/utils.ts} +13 -21
- package/src/components/SideNav/SideNav.tsx +26 -14
- package/src/components/SideNav/SideNavMethods.spec.tsx +6 -8
- package/src/components/SideNav/SideNavMethods.tsx +8 -12
- package/src/components/SideNav/SideNavTypes.tsx +5 -10
- package/src/components/index.ts +0 -1
- package/src/routes/AppRouter.tsx +7 -5
- package/src/scenes/DiffScene/DiffScene.tsx +8 -8
- package/src/scenes/DiffScene/DocDiff/DiffItem.tsx +1 -1
- package/src/scenes/DiffScene/DocDiff/DocDiff.spec.tsx +73 -2
- package/src/scenes/DiffScene/DocDiff/DocDiff.tsx +4 -4
- package/src/scenes/ErrorDetailScene/ErrorDetailScene.tsx +72 -0
- package/src/scenes/ErrorDetailScene/index.ts +26 -0
- package/src/scenes/MethodScene/MethodScene.tsx +21 -7
- package/src/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.tsx +3 -6
- package/src/scenes/MethodScene/components/DocResponses/DocResponses.spec.tsx +153 -0
- package/src/scenes/MethodScene/components/DocResponses/DocResponses.tsx +103 -0
- package/src/{components → scenes/MethodScene/components}/DocResponses/index.ts +0 -0
- package/src/{components → scenes/MethodScene/components}/DocResponses/utils.spec.ts +1 -1
- package/src/{components → scenes/MethodScene/components}/DocResponses/utils.ts +0 -0
- package/src/scenes/MethodScene/components/index.ts +1 -0
- package/src/scenes/MethodTagScene/MethodTagScene.spec.tsx +25 -14
- package/src/scenes/MethodTagScene/MethodTagScene.tsx +42 -11
- package/src/scenes/TypeScene/TypeScene.tsx +1 -1
- package/src/scenes/TypeTagScene/TypeTagScene.spec.tsx +21 -11
- package/src/scenes/TypeTagScene/TypeTagScene.tsx +44 -11
- package/src/scenes/index.ts +1 -0
- package/src/scenes/utils/hooks/index.ts +27 -0
- package/src/scenes/utils/hooks/tagStoreSync.spec.ts +102 -0
- package/src/scenes/utils/hooks/tagStoreSync.ts +68 -0
- package/src/scenes/utils/index.ts +27 -0
- package/src/state/settings/selectors.spec.ts +5 -1
- package/src/state/settings/selectors.ts +3 -0
- package/src/state/settings/slice.ts +6 -0
- package/src/test-data/index.ts +1 -0
- package/src/test-data/sdkLanguages.ts +36 -0
- package/src/utils/hooks/globalStoreSync.spec.tsx +146 -0
- package/src/utils/hooks/globalStoreSync.ts +77 -0
- package/src/utils/hooks/index.ts +28 -0
- package/src/utils/hooks/navigation.spec.ts +118 -0
- package/src/utils/hooks/navigation.ts +121 -0
- package/src/utils/hooks/useQuery.ts +36 -0
- package/src/utils/index.ts +2 -1
- package/src/utils/path.spec.ts +67 -1
- package/src/utils/path.ts +35 -0
- package/src/utils/sdkLanguage.spec.ts +69 -0
- package/src/utils/sdkLanguage.ts +63 -0
- package/lib/components/DocResponses/DocResponseTypes.js.map +0 -1
- package/lib/components/DocResponses/DocResponses.d.ts +0 -8
- package/lib/components/DocResponses/DocResponses.js +0 -46
- package/lib/components/DocResponses/DocResponses.js.map +0 -1
- package/lib/components/DocResponses/utils.js.map +0 -1
- package/lib/esm/components/DocResponses/DocResponseTypes.js.map +0 -1
- package/lib/esm/components/DocResponses/DocResponses.js +0 -30
- package/lib/esm/components/DocResponses/DocResponses.js.map +0 -1
- package/lib/esm/components/DocResponses/index.js.map +0 -1
- package/lib/esm/components/DocResponses/utils.js.map +0 -1
- package/lib/esm/utils/hooks.js +0 -26
- package/lib/esm/utils/hooks.js.map +0 -1
- package/lib/utils/hooks.d.ts +0 -3
- package/lib/utils/hooks.js +0 -36
- package/lib/utils/hooks.js.map +0 -1
- package/src/components/DocResponses/DocResponses.spec.tsx +0 -60
- package/src/components/DocResponses/DocResponses.tsx +0 -69
- package/src/utils/hooks.spec.ts +0 -78
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2021 Looker Data Sciences, Inc.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
24
|
+
|
|
25
|
+
*/
|
|
26
|
+
import React from 'react'
|
|
27
|
+
import { screen, waitFor } from '@testing-library/react'
|
|
28
|
+
import userEvent from '@testing-library/user-event'
|
|
29
|
+
import {
|
|
30
|
+
registerTestEnvAdaptor,
|
|
31
|
+
unregisterEnvAdaptor,
|
|
32
|
+
} from '@looker/extension-utils'
|
|
33
|
+
|
|
34
|
+
import { api } from '../../../../test-data'
|
|
35
|
+
import { renderWithRouter } from '../../../../test-utils'
|
|
36
|
+
import { DocResponses } from './DocResponses'
|
|
37
|
+
import { buildResponseTree } from './utils'
|
|
38
|
+
|
|
39
|
+
describe('DocResponses', () => {
|
|
40
|
+
beforeAll(() => {
|
|
41
|
+
registerTestEnvAdaptor()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
afterAll(() => {
|
|
45
|
+
unregisterEnvAdaptor()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('it renders all response statuses and their types', async () => {
|
|
49
|
+
const responses = api.methods.run_look.responses
|
|
50
|
+
renderWithRouter(<DocResponses api={api} method={api.methods.run_look} />)
|
|
51
|
+
|
|
52
|
+
expect(screen.getByText('Response Models')).toBeInTheDocument()
|
|
53
|
+
|
|
54
|
+
const responseTree = buildResponseTree(responses)
|
|
55
|
+
const expectedRespStatuses = Object.keys(responseTree)
|
|
56
|
+
expect(
|
|
57
|
+
screen.getAllByRole('tab', {
|
|
58
|
+
name: new RegExp(`${expectedRespStatuses.join('|')}`),
|
|
59
|
+
})
|
|
60
|
+
).toHaveLength(expectedRespStatuses.length)
|
|
61
|
+
|
|
62
|
+
userEvent.click(screen.getByRole('tab', { name: '200: Look' }))
|
|
63
|
+
const successRespTypes = Object.keys(responseTree['200: Look'])
|
|
64
|
+
await waitFor(() => {
|
|
65
|
+
expect(
|
|
66
|
+
screen.getAllByRole('button', {
|
|
67
|
+
name: new RegExp(`${successRespTypes.join('|')}`),
|
|
68
|
+
})
|
|
69
|
+
).toHaveLength(successRespTypes.length)
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('selects tab corresponding to error code query param if present', async () => {
|
|
74
|
+
const sampleIndex = {
|
|
75
|
+
'404': {
|
|
76
|
+
url: '404.md',
|
|
77
|
+
},
|
|
78
|
+
'404/post/login': {
|
|
79
|
+
url: 'login_404.md',
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const badLoginMd = `## API Response 404 for \`login\`
|
|
84
|
+
|
|
85
|
+
## Description
|
|
86
|
+
|
|
87
|
+
A 404 Error response from the /login endpoint most often means that an attempt to login at a valid Looker URL was made but the combination of client_id and client_secret provided do not match an existing valid credential on that instance.
|
|
88
|
+
|
|
89
|
+
See [HTTP 404 - Not Found](https://docs.looker.com/r/reference/looker-http-codes/404) for general information about this HTTP response from Looker.`
|
|
90
|
+
|
|
91
|
+
const mockResponse = async (val: string): Promise<Response> => {
|
|
92
|
+
const resp: Response = {
|
|
93
|
+
bodyUsed: false,
|
|
94
|
+
ok: true,
|
|
95
|
+
redirected: false,
|
|
96
|
+
statusText: '',
|
|
97
|
+
url: '',
|
|
98
|
+
text(): Promise<string> {
|
|
99
|
+
return Promise.resolve(val)
|
|
100
|
+
},
|
|
101
|
+
status: 200,
|
|
102
|
+
headers: {} as Headers,
|
|
103
|
+
type: 'basic',
|
|
104
|
+
clone: function (): Response {
|
|
105
|
+
throw new Error('Function not implemented.')
|
|
106
|
+
},
|
|
107
|
+
body: null,
|
|
108
|
+
arrayBuffer: function (): Promise<ArrayBuffer> {
|
|
109
|
+
throw new Error('Function not implemented.')
|
|
110
|
+
},
|
|
111
|
+
blob: function (): Promise<Blob> {
|
|
112
|
+
throw new Error('Function not implemented.')
|
|
113
|
+
},
|
|
114
|
+
formData: function (): Promise<FormData> {
|
|
115
|
+
throw new Error('Function not implemented.')
|
|
116
|
+
},
|
|
117
|
+
json: function (): Promise<any> {
|
|
118
|
+
throw new Error('Function not implemented.')
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
return Promise.resolve(resp)
|
|
122
|
+
}
|
|
123
|
+
const fetcher = global.fetch
|
|
124
|
+
global.fetch = jest.fn((input: RequestInfo, _init?: RequestInit) => {
|
|
125
|
+
const url = input.toString()
|
|
126
|
+
let result = 'I dunno'
|
|
127
|
+
if (url.endsWith('index.json')) {
|
|
128
|
+
result = JSON.stringify(sampleIndex)
|
|
129
|
+
}
|
|
130
|
+
if (url.endsWith('login_404.md')) {
|
|
131
|
+
result = badLoginMd
|
|
132
|
+
}
|
|
133
|
+
return mockResponse(result)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
renderWithRouter(
|
|
137
|
+
<DocResponses api={api} method={api.methods.login} errorCode="404" />
|
|
138
|
+
)
|
|
139
|
+
expect(screen.getByText('Response Models')).toBeInTheDocument()
|
|
140
|
+
|
|
141
|
+
await waitFor(() => {
|
|
142
|
+
expect(screen.getByRole('tab', { name: /^404: \w+/ })).toHaveAttribute(
|
|
143
|
+
'aria-selected',
|
|
144
|
+
'true'
|
|
145
|
+
)
|
|
146
|
+
expect(
|
|
147
|
+
screen.getByRole('heading', { name: 'Description' })
|
|
148
|
+
).toBeInTheDocument()
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
global.fetch = fetcher
|
|
152
|
+
})
|
|
153
|
+
})
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2021 Looker Data Sciences, Inc.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
24
|
+
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import React, { useEffect, useState } from 'react'
|
|
28
|
+
import { Tabs2, Tab2 } from '@looker/components'
|
|
29
|
+
import type { ApiModel, IMethod } from '@looker/sdk-codegen'
|
|
30
|
+
import { CollapserCard } from '@looker/run-it'
|
|
31
|
+
import { ErrorDoc } from '@looker/sdk-rtl'
|
|
32
|
+
import {
|
|
33
|
+
apiErrorDisplayFetch,
|
|
34
|
+
ExtMarkdown,
|
|
35
|
+
getEnvAdaptor,
|
|
36
|
+
} from '@looker/extension-utils'
|
|
37
|
+
|
|
38
|
+
import { DocResponseTypes } from './DocResponseTypes'
|
|
39
|
+
import { buildResponseTree } from './utils'
|
|
40
|
+
|
|
41
|
+
interface DocResponsesProps {
|
|
42
|
+
api: ApiModel
|
|
43
|
+
method: IMethod
|
|
44
|
+
/** error code to display */
|
|
45
|
+
errorCode?: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Renders a tab list and tab panels for different method response types
|
|
50
|
+
*/
|
|
51
|
+
export const DocResponses = ({ api, method, errorCode }: DocResponsesProps) => {
|
|
52
|
+
const [errorContent, setErrorContent] = useState('')
|
|
53
|
+
const responses = method.responses
|
|
54
|
+
|
|
55
|
+
const responseTree = buildResponseTree(responses)
|
|
56
|
+
const tabNames = Object.keys(responseTree)
|
|
57
|
+
|
|
58
|
+
let defaultTabId = tabNames[0]
|
|
59
|
+
|
|
60
|
+
if (errorCode) {
|
|
61
|
+
const pattern = new RegExp(`${errorCode}: \\w+`)
|
|
62
|
+
tabNames.forEach((el) => {
|
|
63
|
+
if (pattern.test(el)) {
|
|
64
|
+
defaultTabId = el
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (!errorCode) return
|
|
71
|
+
|
|
72
|
+
const getErrorContent = async () => {
|
|
73
|
+
const docUrl = `/err/4.0/${errorCode}/${method.httpMethod.toLocaleLowerCase()}${
|
|
74
|
+
method.endpoint
|
|
75
|
+
}`
|
|
76
|
+
const adaptor = getEnvAdaptor()
|
|
77
|
+
const errDoc = new ErrorDoc(adaptor.sdk, apiErrorDisplayFetch)
|
|
78
|
+
const content = await errDoc.content(docUrl)
|
|
79
|
+
setErrorContent(content)
|
|
80
|
+
}
|
|
81
|
+
getErrorContent()
|
|
82
|
+
}, [errorCode])
|
|
83
|
+
|
|
84
|
+
if (responses.length === 0) return <></>
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<CollapserCard heading="Response Models" id="response models">
|
|
88
|
+
<Tabs2 defaultTabId={defaultTabId}>
|
|
89
|
+
{Object.entries(responseTree).map(([statusCode, response]) => {
|
|
90
|
+
const errorTab = errorCode && statusCode === defaultTabId
|
|
91
|
+
return (
|
|
92
|
+
<Tab2 key={statusCode} id={statusCode} label={statusCode}>
|
|
93
|
+
<DocResponseTypes api={api} responses={response} />
|
|
94
|
+
{errorContent && errorTab && (
|
|
95
|
+
<ExtMarkdown source={errorContent} />
|
|
96
|
+
)}
|
|
97
|
+
</Tab2>
|
|
98
|
+
)
|
|
99
|
+
})}
|
|
100
|
+
</Tabs2>
|
|
101
|
+
</CollapserCard>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -29,16 +29,28 @@ import { screen, waitFor } from '@testing-library/react'
|
|
|
29
29
|
import userEvent from '@testing-library/user-event'
|
|
30
30
|
|
|
31
31
|
import { api } from '../../test-data'
|
|
32
|
-
import {
|
|
32
|
+
import { renderWithRouterAndReduxProvider } from '../../test-utils'
|
|
33
33
|
import { MethodTagScene } from './MethodTagScene'
|
|
34
34
|
|
|
35
35
|
const opBtnNames = /ALL|GET|POST|PUT|PATCH|DELETE/
|
|
36
36
|
|
|
37
|
+
const mockHistoryPush = jest.fn()
|
|
38
|
+
jest.mock('react-router-dom', () => {
|
|
39
|
+
const ReactRouterDOM = jest.requireActual('react-router-dom')
|
|
40
|
+
return {
|
|
41
|
+
...ReactRouterDOM,
|
|
42
|
+
useHistory: () => ({
|
|
43
|
+
push: mockHistoryPush,
|
|
44
|
+
location,
|
|
45
|
+
}),
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
37
49
|
describe('MethodTagScene', () => {
|
|
38
50
|
Element.prototype.scrollTo = jest.fn()
|
|
39
51
|
|
|
40
52
|
test('it renders operation buttons and all methods for a given method tag', () => {
|
|
41
|
-
|
|
53
|
+
renderWithRouterAndReduxProvider(
|
|
42
54
|
<Route path="/:specKey/methods/:methodTag">
|
|
43
55
|
<MethodTagScene api={api} />
|
|
44
56
|
</Route>,
|
|
@@ -62,7 +74,7 @@ describe('MethodTagScene', () => {
|
|
|
62
74
|
|
|
63
75
|
test('it only renders operation buttons for operations that exist under that tag', () => {
|
|
64
76
|
/** ApiAuth contains two POST methods and a DELETE method */
|
|
65
|
-
|
|
77
|
+
renderWithRouterAndReduxProvider(
|
|
66
78
|
<Route path="/:specKey/methods/:methodTag">
|
|
67
79
|
<MethodTagScene api={api} />
|
|
68
80
|
</Route>,
|
|
@@ -75,30 +87,29 @@ describe('MethodTagScene', () => {
|
|
|
75
87
|
).toHaveLength(3)
|
|
76
88
|
})
|
|
77
89
|
|
|
78
|
-
test('it
|
|
79
|
-
|
|
90
|
+
test('it pushes filter to URL on toggle', async () => {
|
|
91
|
+
renderWithRouterAndReduxProvider(
|
|
80
92
|
<Route path="/:specKey/methods/:methodTag">
|
|
81
93
|
<MethodTagScene api={api} />
|
|
82
94
|
</Route>,
|
|
83
95
|
['/3.1/methods/Look']
|
|
84
96
|
)
|
|
85
|
-
const allLookMethods = /^\/look.*/
|
|
86
|
-
expect(screen.getAllByText(allLookMethods)).toHaveLength(7)
|
|
87
97
|
/** Filter by GET operation */
|
|
88
98
|
userEvent.click(screen.getByRole('button', { name: 'GET' }))
|
|
89
99
|
await waitFor(() => {
|
|
90
|
-
expect(
|
|
100
|
+
expect(mockHistoryPush).toHaveBeenCalledWith({
|
|
101
|
+
pathname: location.pathname,
|
|
102
|
+
search: 't=get',
|
|
103
|
+
})
|
|
91
104
|
})
|
|
92
105
|
/** Filter by DELETE operation */
|
|
93
106
|
userEvent.click(screen.getByRole('button', { name: 'DELETE' }))
|
|
94
107
|
await waitFor(() => {
|
|
95
108
|
// eslint-disable-next-line jest-dom/prefer-in-document
|
|
96
|
-
expect(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
await waitFor(() => {
|
|
101
|
-
expect(screen.getAllByText(allLookMethods)).toHaveLength(7)
|
|
109
|
+
expect(mockHistoryPush).toHaveBeenCalledWith({
|
|
110
|
+
pathname: location.pathname,
|
|
111
|
+
search: 't=delete',
|
|
112
|
+
})
|
|
102
113
|
})
|
|
103
114
|
})
|
|
104
115
|
})
|
|
@@ -28,8 +28,11 @@ import React, { useEffect, useState } from 'react'
|
|
|
28
28
|
import { useHistory, useParams } from 'react-router-dom'
|
|
29
29
|
import { Grid, ButtonToggle, ButtonItem } from '@looker/components'
|
|
30
30
|
import type { ApiModel } from '@looker/sdk-codegen'
|
|
31
|
+
import { useSelector } from 'react-redux'
|
|
31
32
|
import { ApixSection, DocTitle, DocMethodSummary, Link } from '../../components'
|
|
32
|
-
import { buildMethodPath, useNavigation } from '../../utils'
|
|
33
|
+
import { buildMethodPath, isValidFilter, useNavigation } from '../../utils'
|
|
34
|
+
import { selectTagFilter, useSettingActions } from '../../state'
|
|
35
|
+
import { useTagStoreSync } from '../utils'
|
|
33
36
|
import { getOperations } from './utils'
|
|
34
37
|
|
|
35
38
|
interface MethodTagSceneProps {
|
|
@@ -44,18 +47,38 @@ interface MethodTagSceneParams {
|
|
|
44
47
|
export const MethodTagScene: FC<MethodTagSceneProps> = ({ api }) => {
|
|
45
48
|
const { specKey, methodTag } = useParams<MethodTagSceneParams>()
|
|
46
49
|
const history = useHistory()
|
|
47
|
-
const
|
|
48
|
-
const
|
|
50
|
+
const methods = api.tags[methodTag]
|
|
51
|
+
const { navigate, buildPathWithGlobalParams, navigateWithGlobalParams } =
|
|
52
|
+
useNavigation()
|
|
53
|
+
const selectedTagFilter = useSelector(selectTagFilter)
|
|
54
|
+
const { setTagFilterAction } = useSettingActions()
|
|
55
|
+
const [tagFilter, setTagFilter] = useState(selectedTagFilter)
|
|
56
|
+
useTagStoreSync()
|
|
57
|
+
|
|
58
|
+
const handleChange = (filter: string) => {
|
|
59
|
+
navigate(location.pathname, {
|
|
60
|
+
t: filter === 'ALL' ? null : filter.toLowerCase(),
|
|
61
|
+
})
|
|
62
|
+
}
|
|
49
63
|
|
|
50
64
|
useEffect(() => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
65
|
+
const searchParams = new URLSearchParams(location.search)
|
|
66
|
+
let verbParam = searchParams.get('t') || 'ALL'
|
|
67
|
+
verbParam = isValidFilter(location.pathname, verbParam)
|
|
68
|
+
? verbParam.toUpperCase()
|
|
69
|
+
: 'ALL'
|
|
70
|
+
setTagFilterAction({
|
|
71
|
+
tagFilter: verbParam,
|
|
72
|
+
})
|
|
73
|
+
}, [location.search])
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
setTagFilter(selectedTagFilter)
|
|
77
|
+
}, [selectedTagFilter])
|
|
54
78
|
|
|
55
|
-
const methods = api.tags[methodTag]
|
|
56
79
|
useEffect(() => {
|
|
57
80
|
if (!methods) {
|
|
58
|
-
|
|
81
|
+
navigateWithGlobalParams(`/${specKey}/methods`)
|
|
59
82
|
}
|
|
60
83
|
}, [history, methods])
|
|
61
84
|
if (!methods) {
|
|
@@ -69,7 +92,12 @@ export const MethodTagScene: FC<MethodTagSceneProps> = ({ api }) => {
|
|
|
69
92
|
return (
|
|
70
93
|
<ApixSection>
|
|
71
94
|
<DocTitle>{`${tag.name}: ${tag.description}`}</DocTitle>
|
|
72
|
-
<ButtonToggle
|
|
95
|
+
<ButtonToggle
|
|
96
|
+
mb="small"
|
|
97
|
+
mt="xlarge"
|
|
98
|
+
value={tagFilter}
|
|
99
|
+
onChange={handleChange}
|
|
100
|
+
>
|
|
73
101
|
<ButtonItem key="ALL" px="large" py="xsmall">
|
|
74
102
|
ALL
|
|
75
103
|
</ButtonItem>
|
|
@@ -81,10 +109,13 @@ export const MethodTagScene: FC<MethodTagSceneProps> = ({ api }) => {
|
|
|
81
109
|
</ButtonToggle>
|
|
82
110
|
{Object.values(methods).map(
|
|
83
111
|
(method, index) =>
|
|
84
|
-
(
|
|
112
|
+
(selectedTagFilter === 'ALL' ||
|
|
113
|
+
selectedTagFilter === method.httpMethod) && (
|
|
85
114
|
<Link
|
|
86
115
|
key={index}
|
|
87
|
-
to={
|
|
116
|
+
to={buildPathWithGlobalParams(
|
|
117
|
+
buildMethodPath(specKey, tag.name, method.name)
|
|
118
|
+
)}
|
|
88
119
|
>
|
|
89
120
|
<Grid columns={1} py="xsmall">
|
|
90
121
|
<DocMethodSummary key={index} method={method} />
|
|
@@ -56,7 +56,7 @@ export const TypeScene: FC<DocTypeProps> = ({ api }) => {
|
|
|
56
56
|
const { specKey, typeTag, typeName } = useParams<DocTypeParams>()
|
|
57
57
|
const type = api.types[typeName]
|
|
58
58
|
const history = useHistory()
|
|
59
|
-
const navigate = useNavigation()
|
|
59
|
+
const { navigate } = useNavigation()
|
|
60
60
|
const typesUsed = typeRefs(api, type?.customTypes)
|
|
61
61
|
const methodsUsedBy = methodRefs(api, type?.methodRefs)
|
|
62
62
|
const typesUsedBy = typeRefs(api, type?.parentTypes)
|
|
@@ -36,6 +36,18 @@ const opBtnNames = /ALL|SPECIFICATION|WRITE|REQUEST|ENUMERATED/
|
|
|
36
36
|
|
|
37
37
|
const path = '/:specKey/types/:typeTag'
|
|
38
38
|
|
|
39
|
+
const mockHistoryPush = jest.fn()
|
|
40
|
+
jest.mock('react-router-dom', () => {
|
|
41
|
+
const ReactRouterDOM = jest.requireActual('react-router-dom')
|
|
42
|
+
return {
|
|
43
|
+
...ReactRouterDOM,
|
|
44
|
+
useHistory: () => ({
|
|
45
|
+
push: mockHistoryPush,
|
|
46
|
+
location,
|
|
47
|
+
}),
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
39
51
|
describe('TypeTagScene', () => {
|
|
40
52
|
Element.prototype.scrollTo = jest.fn()
|
|
41
53
|
|
|
@@ -74,30 +86,28 @@ describe('TypeTagScene', () => {
|
|
|
74
86
|
).toHaveLength(2)
|
|
75
87
|
})
|
|
76
88
|
|
|
77
|
-
test('it
|
|
89
|
+
test('it pushes filter to URL on toggle', async () => {
|
|
78
90
|
renderWithRouterAndReduxProvider(
|
|
79
91
|
<Route path={path}>
|
|
80
92
|
<TypeTagScene api={api} />
|
|
81
93
|
</Route>,
|
|
82
94
|
['/3.1/types/Look']
|
|
83
95
|
)
|
|
84
|
-
expect(screen.getAllByRole('heading', { level: 3 })).toHaveLength(
|
|
85
|
-
Object.keys(api.typeTags.Look).length
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
expect(screen.getAllByRole('heading', { level: 3 })).toHaveLength(
|
|
89
|
-
Object.keys(api.typeTags.Look).length
|
|
90
|
-
)
|
|
91
|
-
|
|
92
96
|
/** Filter by SPECIFICATION */
|
|
93
97
|
userEvent.click(screen.getByRole('button', { name: 'SPECIFICATION' }))
|
|
94
98
|
await waitFor(() => {
|
|
95
|
-
expect(
|
|
99
|
+
expect(mockHistoryPush).toHaveBeenCalledWith({
|
|
100
|
+
pathname: location.pathname,
|
|
101
|
+
search: 't=specification',
|
|
102
|
+
})
|
|
96
103
|
})
|
|
97
104
|
/** Filter by REQUEST */
|
|
98
105
|
userEvent.click(screen.getByRole('button', { name: 'REQUEST' }))
|
|
99
106
|
await waitFor(() => {
|
|
100
|
-
expect(
|
|
107
|
+
expect(mockHistoryPush).toHaveBeenCalledWith({
|
|
108
|
+
pathname: location.pathname,
|
|
109
|
+
search: 't=request',
|
|
110
|
+
})
|
|
101
111
|
})
|
|
102
112
|
})
|
|
103
113
|
})
|
|
@@ -28,8 +28,11 @@ import React, { useEffect, useState } from 'react'
|
|
|
28
28
|
import { Grid, ButtonToggle, ButtonItem } from '@looker/components'
|
|
29
29
|
import type { ApiModel } from '@looker/sdk-codegen'
|
|
30
30
|
import { useParams } from 'react-router-dom'
|
|
31
|
+
import { useSelector } from 'react-redux'
|
|
31
32
|
import { ApixSection, DocTitle, DocTypeSummary, Link } from '../../components'
|
|
32
|
-
import { buildTypePath, useNavigation } from '../../utils'
|
|
33
|
+
import { buildTypePath, isValidFilter, useNavigation } from '../../utils'
|
|
34
|
+
import { selectTagFilter, useSettingActions } from '../../state'
|
|
35
|
+
import { useTagStoreSync } from '../utils'
|
|
33
36
|
import { getMetaTypes } from './utils'
|
|
34
37
|
|
|
35
38
|
interface TypeTagSceneProps {
|
|
@@ -43,21 +46,41 @@ interface TypeTagSceneParams {
|
|
|
43
46
|
|
|
44
47
|
export const TypeTagScene: FC<TypeTagSceneProps> = ({ api }) => {
|
|
45
48
|
const { specKey, typeTag } = useParams<TypeTagSceneParams>()
|
|
46
|
-
const navigate =
|
|
47
|
-
|
|
49
|
+
const { navigate, buildPathWithGlobalParams, navigateWithGlobalParams } =
|
|
50
|
+
useNavigation()
|
|
51
|
+
const selectedTagFilter = useSelector(selectTagFilter)
|
|
52
|
+
const { setTagFilterAction } = useSettingActions()
|
|
53
|
+
const [tagFilter, setTagFilter] = useState(selectedTagFilter)
|
|
54
|
+
useTagStoreSync()
|
|
55
|
+
|
|
56
|
+
const handleChange = (filter: string) => {
|
|
57
|
+
navigate(location.pathname, {
|
|
58
|
+
t: filter === 'ALL' ? null : filter.toLowerCase(),
|
|
59
|
+
})
|
|
60
|
+
}
|
|
48
61
|
|
|
49
62
|
useEffect(() => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
const searchParams = new URLSearchParams(location.search)
|
|
64
|
+
let verbParam = searchParams.get('t') || 'ALL'
|
|
65
|
+
verbParam = isValidFilter(location.pathname, verbParam)
|
|
66
|
+
? verbParam.toUpperCase()
|
|
67
|
+
: 'ALL'
|
|
68
|
+
setTagFilterAction({
|
|
69
|
+
tagFilter: verbParam,
|
|
70
|
+
})
|
|
71
|
+
}, [location.search])
|
|
53
72
|
|
|
54
73
|
const types = api.typeTags[typeTag]
|
|
55
74
|
useEffect(() => {
|
|
56
75
|
if (!types) {
|
|
57
|
-
|
|
76
|
+
navigateWithGlobalParams(`/${specKey}/types`)
|
|
58
77
|
}
|
|
59
78
|
}, [types])
|
|
60
79
|
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
setTagFilter(selectedTagFilter)
|
|
82
|
+
}, [selectedTagFilter])
|
|
83
|
+
|
|
61
84
|
if (!types) {
|
|
62
85
|
return <></>
|
|
63
86
|
}
|
|
@@ -67,7 +90,12 @@ export const TypeTagScene: FC<TypeTagSceneProps> = ({ api }) => {
|
|
|
67
90
|
return (
|
|
68
91
|
<ApixSection>
|
|
69
92
|
<DocTitle>{`${tag.name}: ${tag.description}`}</DocTitle>
|
|
70
|
-
<ButtonToggle
|
|
93
|
+
<ButtonToggle
|
|
94
|
+
mb="small"
|
|
95
|
+
mt="xlarge"
|
|
96
|
+
value={tagFilter}
|
|
97
|
+
onChange={handleChange}
|
|
98
|
+
>
|
|
71
99
|
<ButtonItem key="ALL" px="large" py="xsmall">
|
|
72
100
|
ALL
|
|
73
101
|
</ButtonItem>
|
|
@@ -79,9 +107,14 @@ export const TypeTagScene: FC<TypeTagSceneProps> = ({ api }) => {
|
|
|
79
107
|
</ButtonToggle>
|
|
80
108
|
{Object.values(types).map(
|
|
81
109
|
(type, index) =>
|
|
82
|
-
(
|
|
83
|
-
|
|
84
|
-
<Link
|
|
110
|
+
(selectedTagFilter === 'ALL' ||
|
|
111
|
+
selectedTagFilter === type.metaType.toString().toUpperCase()) && (
|
|
112
|
+
<Link
|
|
113
|
+
key={index}
|
|
114
|
+
to={buildPathWithGlobalParams(
|
|
115
|
+
buildTypePath(specKey, tag.name, type.name)
|
|
116
|
+
)}
|
|
117
|
+
>
|
|
85
118
|
<Grid columns={1} py="xsmall">
|
|
86
119
|
<DocTypeSummary key={index} type={type} />
|
|
87
120
|
</Grid>
|
package/src/scenes/index.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2021 Looker Data Sciences, Inc.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
24
|
+
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export { useTagStoreSync } from './tagStoreSync'
|