@looker/api-explorer 0.9.21 → 0.9.26
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 +101 -0
- package/lib/ApiExplorer.d.ts +4 -39
- package/lib/ApiExplorer.js +23 -30
- package/lib/ApiExplorer.js.map +1 -1
- package/lib/App.d.ts +1 -0
- package/lib/App.js +29 -0
- package/lib/App.js.map +1 -0
- package/lib/StandaloneApiExplorer.js +8 -13
- package/lib/StandaloneApiExplorer.js.map +1 -1
- package/lib/components/DocCode/DocCode.js +6 -10
- package/lib/components/DocCode/DocCode.js.map +1 -1
- package/lib/components/DocMarkdown/DocMarkdown.js +11 -15
- package/lib/components/DocMarkdown/DocMarkdown.js.map +1 -1
- package/lib/components/DocReferences/DocReferences.js +7 -11
- package/lib/components/DocReferences/DocReferences.js.map +1 -1
- package/lib/components/DocSdkUsage/DocSdkUsage.js +3 -6
- package/lib/components/DocSdkUsage/DocSdkUsage.js.map +1 -1
- package/lib/components/DocSource/DocSource.js +5 -7
- package/lib/components/DocSource/DocSource.js.map +1 -1
- package/lib/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.d.ts +1 -1
- package/lib/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.js +152 -8
- package/lib/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.js.map +1 -1
- package/lib/components/SelectorContainer/SdkLanguageSelector.js +1 -1
- package/lib/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
- package/lib/components/SideNav/SideNav.js +39 -26
- package/lib/components/SideNav/SideNav.js.map +1 -1
- package/lib/components/SideNav/SideNavMethods.js +7 -9
- package/lib/components/SideNav/SideNavMethods.js.map +1 -1
- package/lib/components/SideNav/SideNavTypes.js +6 -8
- package/lib/components/SideNav/SideNavTypes.js.map +1 -1
- package/lib/components/SideNav/searchUtils.d.ts +1 -1
- package/lib/components/SideNav/searchUtils.js +1 -1
- package/lib/components/SideNav/searchUtils.js.map +1 -1
- package/lib/components/common/Loader.d.ts +1 -1
- package/lib/components/common/Loader.js.map +1 -1
- package/lib/esm/ApiExplorer.js +26 -33
- package/lib/esm/ApiExplorer.js.map +1 -1
- package/lib/esm/App.js +19 -0
- package/lib/esm/App.js.map +1 -0
- package/lib/esm/StandaloneApiExplorer.js +7 -10
- package/lib/esm/StandaloneApiExplorer.js.map +1 -1
- package/lib/esm/components/DocCode/DocCode.js +5 -8
- package/lib/esm/components/DocCode/DocCode.js.map +1 -1
- package/lib/esm/components/DocMarkdown/DocMarkdown.js +8 -11
- package/lib/esm/components/DocMarkdown/DocMarkdown.js.map +1 -1
- package/lib/esm/components/DocReferences/DocReferences.js +5 -8
- package/lib/esm/components/DocReferences/DocReferences.js.map +1 -1
- package/lib/esm/components/DocSdkUsage/DocSdkUsage.js +5 -7
- package/lib/esm/components/DocSdkUsage/DocSdkUsage.js.map +1 -1
- package/lib/esm/components/DocSource/DocSource.js +4 -5
- package/lib/esm/components/DocSource/DocSource.js.map +1 -1
- package/lib/esm/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.js +153 -6
- package/lib/esm/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.js.map +1 -1
- package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js +2 -2
- package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
- package/lib/esm/components/SideNav/SideNav.js +40 -27
- package/lib/esm/components/SideNav/SideNav.js.map +1 -1
- package/lib/esm/components/SideNav/SideNavMethods.js +7 -10
- package/lib/esm/components/SideNav/SideNavMethods.js.map +1 -1
- package/lib/esm/components/SideNav/SideNavTypes.js +6 -9
- package/lib/esm/components/SideNav/SideNavTypes.js.map +1 -1
- package/lib/esm/components/SideNav/searchUtils.js +1 -1
- package/lib/esm/components/SideNav/searchUtils.js.map +1 -1
- package/lib/esm/components/common/Loader.js.map +1 -1
- package/lib/esm/index.js +4 -18
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/reducers/index.js +0 -1
- package/lib/esm/reducers/index.js.map +1 -1
- package/lib/esm/routes/AppRouter.js +2 -2
- package/lib/esm/routes/AppRouter.js.map +1 -1
- package/lib/esm/scenes/MethodScene/MethodScene.js +9 -11
- package/lib/esm/scenes/MethodScene/MethodScene.js.map +1 -1
- package/lib/esm/state/index.js +1 -0
- package/lib/esm/state/index.js.map +1 -1
- package/lib/esm/state/lodes/index.js +3 -0
- package/lib/{test-utils/envAdaptor.js.map → esm/state/lodes/index.js.map} +1 -1
- package/lib/esm/state/lodes/sagas.js +25 -0
- package/lib/esm/state/lodes/sagas.js.map +1 -0
- package/lib/esm/state/lodes/selectors.js +5 -0
- package/lib/esm/state/lodes/selectors.js.map +1 -0
- package/lib/esm/state/lodes/slice.js +30 -0
- package/lib/esm/state/lodes/slice.js.map +1 -0
- package/lib/esm/state/settings/sagas.js +28 -16
- package/lib/esm/state/settings/sagas.js.map +1 -1
- package/lib/esm/state/settings/selectors.js +5 -3
- package/lib/esm/state/settings/selectors.js.map +1 -1
- package/lib/esm/state/settings/slice.js +16 -9
- package/lib/esm/state/settings/slice.js.map +1 -1
- package/lib/esm/state/store.js +6 -3
- package/lib/esm/state/store.js.map +1 -1
- package/lib/esm/test-utils/index.js +2 -4
- package/lib/esm/test-utils/index.js.map +1 -1
- package/lib/esm/test-utils/lodes.js +12 -0
- package/lib/esm/test-utils/lodes.js.map +1 -0
- package/lib/esm/test-utils/redux.js +12 -9
- package/lib/esm/test-utils/redux.js.map +1 -1
- package/lib/esm/utils/index.js +0 -1
- package/lib/esm/utils/index.js.map +1 -1
- package/lib/esm/utils/lodeUtils.js +3 -7
- package/lib/esm/utils/lodeUtils.js.map +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +52 -23
- package/lib/index.js.map +1 -1
- package/lib/reducers/index.d.ts +0 -1
- package/lib/reducers/index.js +0 -13
- package/lib/reducers/index.js.map +1 -1
- package/lib/routes/AppRouter.d.ts +2 -2
- package/lib/routes/AppRouter.js +2 -2
- package/lib/routes/AppRouter.js.map +1 -1
- package/lib/scenes/MethodScene/MethodScene.d.ts +2 -2
- package/lib/scenes/MethodScene/MethodScene.js +7 -9
- package/lib/scenes/MethodScene/MethodScene.js.map +1 -1
- package/lib/state/index.d.ts +1 -0
- package/lib/state/index.js +13 -0
- package/lib/state/index.js.map +1 -1
- package/lib/state/lodes/index.d.ts +2 -0
- package/lib/{reducers/search → state/lodes}/index.js +8 -8
- package/lib/state/lodes/index.js.map +1 -0
- package/lib/state/lodes/sagas.d.ts +1 -0
- package/lib/state/lodes/sagas.js +34 -0
- package/lib/state/lodes/sagas.js.map +1 -0
- package/lib/state/lodes/selectors.d.ts +3 -0
- package/lib/state/lodes/selectors.js +17 -0
- package/lib/state/lodes/selectors.js.map +1 -0
- package/lib/state/lodes/slice.d.ts +29 -0
- package/lib/state/lodes/slice.js +45 -0
- package/lib/state/lodes/slice.js.map +1 -0
- package/lib/state/settings/sagas.js +28 -15
- package/lib/state/settings/sagas.js.map +1 -1
- package/lib/state/settings/selectors.d.ts +2 -0
- package/lib/state/settings/selectors.js +12 -4
- package/lib/state/settings/selectors.js.map +1 -1
- package/lib/state/settings/slice.d.ts +24 -16
- package/lib/state/settings/slice.js +22 -14
- package/lib/state/settings/slice.js.map +1 -1
- package/lib/state/store.d.ts +3 -0
- package/lib/state/store.js +6 -2
- package/lib/state/store.js.map +1 -1
- package/lib/test-data/declarations.js +24 -0
- package/lib/test-data/declarations.js.map +1 -0
- package/lib/test-data/index.js +23 -0
- package/lib/test-data/index.js.map +1 -1
- package/lib/test-utils/index.d.ts +2 -4
- package/lib/test-utils/index.js +22 -56
- package/lib/test-utils/index.js.map +1 -1
- package/lib/test-utils/lodes.d.ts +4 -0
- package/lib/test-utils/lodes.js +23 -0
- package/lib/test-utils/lodes.js.map +1 -0
- package/lib/test-utils/redux.d.ts +9 -3
- package/lib/test-utils/redux.js +14 -10
- package/lib/test-utils/redux.js.map +1 -1
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -24
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/lodeUtils.d.ts +2 -2
- package/lib/utils/lodeUtils.js +3 -7
- package/lib/utils/lodeUtils.js.map +1 -1
- package/package.json +11 -10
- package/public/Looker.3.1.json +1343 -412
- package/public/Looker.4.0.json +3305 -661
- package/src/ApiExplorer.tsx +100 -119
- package/src/{index.tsx → App.tsx} +0 -0
- package/src/StandaloneApiExplorer.tsx +8 -16
- package/src/components/DocCode/DocCode.tsx +6 -6
- package/src/components/DocMarkdown/DocMarkdown.spec.tsx +16 -11
- package/src/components/DocMarkdown/DocMarkdown.tsx +8 -10
- package/src/components/DocReferences/DocReferences.spec.tsx +11 -4
- package/src/components/DocReferences/DocReferences.tsx +8 -9
- package/src/components/DocSdkUsage/DocSdkUsage.spec.tsx +2 -2
- package/src/components/DocSdkUsage/DocSdkUsage.tsx +5 -5
- package/src/components/DocSource/DocSource.tsx +4 -3
- package/src/components/ErrorBoundary/components/SomethingWentWrong/SomethingWentWrong.spec.tsx +1 -1
- package/src/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/SomethingWentWrongGraphic.tsx +170 -6
- package/src/components/ExploreType/ExploreProperty.spec.tsx +7 -12
- package/src/components/ExploreType/ExploreType.spec.tsx +9 -27
- package/src/components/Header/Header.spec.tsx +30 -38
- package/src/components/SelectorContainer/ApiSpecSelector.spec.tsx +2 -2
- package/src/components/SelectorContainer/SdkLanguageSelector.spec.tsx +3 -5
- package/src/components/SelectorContainer/SdkLanguageSelector.tsx +2 -2
- package/src/components/SelectorContainer/SelectorContainer.spec.tsx +20 -26
- package/src/components/SideNav/SideNav.spec.tsx +24 -29
- package/src/components/SideNav/SideNav.tsx +45 -24
- package/src/components/SideNav/SideNavMethodTags.spec.tsx +8 -6
- package/src/components/SideNav/SideNavMethods.spec.tsx +9 -5
- package/src/components/SideNav/SideNavMethods.tsx +8 -8
- package/src/components/SideNav/SideNavTypeTags.spec.tsx +8 -6
- package/src/components/SideNav/SideNavTypes.spec.tsx +9 -4
- package/src/components/SideNav/SideNavTypes.tsx +7 -7
- package/src/components/SideNav/{searchUtils.tsx → searchUtils.ts} +2 -2
- package/src/components/common/Loader.tsx +1 -1
- package/src/{context/lode/index.ts → index.ts} +4 -1
- package/src/reducers/index.ts +0 -1
- package/src/routes/AppRouter.tsx +5 -4
- package/src/scenes/MethodScene/MethodScene.tsx +11 -11
- package/src/scenes/TypeTagScene/TypeTagScene.spec.tsx +4 -4
- package/src/state/index.ts +1 -0
- package/src/{reducers/search → state/lodes}/index.ts +2 -2
- package/src/state/lodes/sagas.spec.ts +92 -0
- package/src/state/lodes/sagas.ts +51 -0
- package/src/{context/search/SearchContext.ts → state/lodes/selectors.spec.ts} +13 -15
- package/src/{test-utils/envAdaptor.ts → state/lodes/selectors.ts} +8 -5
- package/src/{test-utils/render_with_lode.tsx → state/lodes/slice.ts} +37 -37
- package/src/state/settings/sagas.spec.ts +29 -24
- package/src/state/settings/sagas.ts +16 -16
- package/src/state/settings/selectors.spec.ts +1 -5
- package/src/state/settings/selectors.ts +9 -3
- package/src/state/settings/slice.ts +27 -10
- package/src/state/store.ts +7 -2
- package/src/{reducers/search/actions.ts → test-data/declarations.ts} +16 -15
- package/src/test-data/index.ts +1 -0
- package/src/test-utils/index.ts +2 -10
- package/src/{context/lode/LodeContext.ts → test-utils/lodes.tsx} +14 -13
- package/src/test-utils/redux.tsx +29 -10
- package/src/utils/index.ts +0 -1
- package/src/utils/lodeUtils.ts +4 -6
- package/webpack.dev.config.js +3 -0
- package/webpack.prod.config.js +4 -0
- package/lib/components/SideNav/SearchCriteriaSelector.d.ts +0 -2
- package/lib/components/SideNav/SearchCriteriaSelector.js +0 -57
- package/lib/components/SideNav/SearchCriteriaSelector.js.map +0 -1
- package/lib/context/index.d.ts +0 -2
- package/lib/context/index.js +0 -34
- package/lib/context/index.js.map +0 -1
- package/lib/context/lode/LodeContext.d.ts +0 -9
- package/lib/context/lode/LodeContext.js +0 -21
- package/lib/context/lode/LodeContext.js.map +0 -1
- package/lib/context/lode/index.d.ts +0 -1
- package/lib/context/lode/index.js +0 -20
- package/lib/context/lode/index.js.map +0 -1
- package/lib/context/search/SearchContext.d.ts +0 -9
- package/lib/context/search/SearchContext.js +0 -19
- package/lib/context/search/SearchContext.js.map +0 -1
- package/lib/context/search/index.d.ts +0 -1
- package/lib/context/search/index.js +0 -20
- package/lib/context/search/index.js.map +0 -1
- package/lib/esm/components/SideNav/SearchCriteriaSelector.js +0 -38
- package/lib/esm/components/SideNav/SearchCriteriaSelector.js.map +0 -1
- package/lib/esm/context/index.js +0 -3
- package/lib/esm/context/index.js.map +0 -1
- package/lib/esm/context/lode/LodeContext.js +0 -11
- package/lib/esm/context/lode/LodeContext.js.map +0 -1
- package/lib/esm/context/lode/index.js +0 -2
- package/lib/esm/context/lode/index.js.map +0 -1
- package/lib/esm/context/search/SearchContext.js +0 -8
- package/lib/esm/context/search/SearchContext.js.map +0 -1
- package/lib/esm/context/search/index.js +0 -2
- package/lib/esm/context/search/index.js.map +0 -1
- package/lib/esm/reducers/search/actions.js +0 -13
- package/lib/esm/reducers/search/actions.js.map +0 -1
- package/lib/esm/reducers/search/index.js +0 -3
- package/lib/esm/reducers/search/index.js.map +0 -1
- package/lib/esm/reducers/search/reducer.js +0 -31
- package/lib/esm/reducers/search/reducer.js.map +0 -1
- package/lib/esm/test-utils/envAdaptor.js +0 -5
- package/lib/esm/test-utils/envAdaptor.js.map +0 -1
- package/lib/esm/test-utils/render_with_lode.js +0 -19
- package/lib/esm/test-utils/render_with_lode.js.map +0 -1
- package/lib/esm/test-utils/render_with_search.js +0 -34
- package/lib/esm/test-utils/render_with_search.js.map +0 -1
- package/lib/esm/utils/envAdaptor.js +0 -84
- package/lib/esm/utils/envAdaptor.js.map +0 -1
- package/lib/reducers/search/actions.d.ts +0 -4
- package/lib/reducers/search/actions.js +0 -25
- package/lib/reducers/search/actions.js.map +0 -1
- package/lib/reducers/search/index.d.ts +0 -2
- package/lib/reducers/search/index.js.map +0 -1
- package/lib/reducers/search/reducer.d.ts +0 -11
- package/lib/reducers/search/reducer.js +0 -43
- package/lib/reducers/search/reducer.js.map +0 -1
- package/lib/test-utils/envAdaptor.d.ts +0 -2
- package/lib/test-utils/envAdaptor.js +0 -15
- package/lib/test-utils/render_with_lode.d.ts +0 -7
- package/lib/test-utils/render_with_lode.js +0 -36
- package/lib/test-utils/render_with_lode.js.map +0 -1
- package/lib/test-utils/render_with_search.d.ts +0 -4
- package/lib/test-utils/render_with_search.js +0 -52
- package/lib/test-utils/render_with_search.js.map +0 -1
- package/lib/utils/envAdaptor.d.ts +0 -31
- package/lib/utils/envAdaptor.js +0 -106
- package/lib/utils/envAdaptor.js.map +0 -1
- package/src/components/ErrorBoundary/components/SomethingWentWrong/components/SomethingWentWrongGraphic/somethingWentWrong.svg +0 -45
- package/src/components/SideNav/SearchCriteriaSelector.tsx +0 -76
- package/src/context/index.ts +0 -27
- package/src/context/search/index.ts +0 -26
- package/src/reducers/search/actions.spec.ts +0 -50
- package/src/reducers/search/reducer.spec.ts +0 -69
- package/src/reducers/search/reducer.ts +0 -63
- package/src/test-utils/render_with_search.tsx +0 -71
- package/src/utils/envAdaptor.spec.ts +0 -50
- package/src/utils/envAdaptor.ts +0 -147
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
26
|
import React from 'react'
|
|
27
|
-
import {
|
|
27
|
+
import { criteriaToSet } from '@looker/sdk-codegen'
|
|
28
28
|
import userEvent from '@testing-library/user-event'
|
|
29
|
-
import {
|
|
29
|
+
import { screen, waitFor } from '@testing-library/react'
|
|
30
30
|
|
|
31
31
|
import { getLoadedSpecs, specState } from '../../test-data'
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
32
|
+
import { renderWithRouterAndReduxProvider } from '../../test-utils'
|
|
33
|
+
import { defaultSettingsState } from '../../state'
|
|
34
34
|
import { SideNav } from './SideNav'
|
|
35
35
|
import { countMethods, countTypes } from './searchUtils'
|
|
36
36
|
|
|
@@ -55,7 +55,7 @@ describe('SideNav', () => {
|
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
test('it renders search, methods tab and types tab', () => {
|
|
58
|
-
|
|
58
|
+
renderWithRouterAndReduxProvider(
|
|
59
59
|
<SideNav
|
|
60
60
|
specs={specs}
|
|
61
61
|
spec={specState.spec}
|
|
@@ -78,7 +78,7 @@ describe('SideNav', () => {
|
|
|
78
78
|
})
|
|
79
79
|
|
|
80
80
|
test('Methods tab is the default active tab', () => {
|
|
81
|
-
|
|
81
|
+
renderWithRouterAndReduxProvider(
|
|
82
82
|
<SideNav
|
|
83
83
|
specs={specs}
|
|
84
84
|
spec={specState.spec}
|
|
@@ -97,7 +97,7 @@ describe('SideNav', () => {
|
|
|
97
97
|
})
|
|
98
98
|
|
|
99
99
|
test('url determines active tab', () => {
|
|
100
|
-
|
|
100
|
+
renderWithRouterAndReduxProvider(
|
|
101
101
|
<SideNav
|
|
102
102
|
specs={specs}
|
|
103
103
|
spec={specState.spec}
|
|
@@ -115,7 +115,7 @@ describe('Search', () => {
|
|
|
115
115
|
const specDispatch = jest.fn()
|
|
116
116
|
|
|
117
117
|
test('it filters methods and types on input', async () => {
|
|
118
|
-
|
|
118
|
+
renderWithRouterAndReduxProvider(
|
|
119
119
|
<SideNav
|
|
120
120
|
specs={specs}
|
|
121
121
|
spec={specState.spec}
|
|
@@ -125,28 +125,23 @@ describe('Search', () => {
|
|
|
125
125
|
const searchPattern = 'embedsso'
|
|
126
126
|
const input = screen.getByLabelText('Search')
|
|
127
127
|
jest.spyOn(specState.spec.api!, 'search')
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
/** Pasting to avoid triggering search multiple times */
|
|
129
|
+
await userEvent.paste(input, searchPattern)
|
|
130
|
+
await waitFor(() => {
|
|
131
|
+
expect(specState.spec.api!.search).toHaveBeenCalledWith(
|
|
132
|
+
searchPattern,
|
|
133
|
+
criteriaToSet(defaultSettingsState.searchCriteria)
|
|
134
|
+
)
|
|
135
|
+
const methods = screen.getByRole('tab', { name: 'Methods (1)' })
|
|
136
|
+
userEvent.click(methods)
|
|
137
|
+
expect(
|
|
138
|
+
screen.getByText(
|
|
139
|
+
specState.spec.api!.tags.Auth.create_sso_embed_url.summary
|
|
135
140
|
)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
screen.getByText(
|
|
141
|
-
specState.spec.api!.tags.Auth.create_sso_embed_url.summary
|
|
142
|
-
)
|
|
143
|
-
).toBeInTheDocument()
|
|
144
|
-
|
|
145
|
-
userEvent.click(types)
|
|
146
|
-
expect(
|
|
147
|
-
screen.getByText(specState.spec.api!.types.EmbedSsoParams.name)
|
|
148
|
-
).toBeInTheDocument()
|
|
149
|
-
})
|
|
141
|
+
).toBeInTheDocument()
|
|
142
|
+
const types = screen.getByRole('tab', { name: 'Types (1)' })
|
|
143
|
+
userEvent.click(types)
|
|
144
|
+
expect(screen.getByText('EmbedSso')).toBeInTheDocument()
|
|
150
145
|
})
|
|
151
146
|
})
|
|
152
147
|
})
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import type { FC, Dispatch } from 'react'
|
|
28
|
-
import React, {
|
|
28
|
+
import React, { useEffect, useState } from 'react'
|
|
29
29
|
import { useHistory, useLocation } from 'react-router-dom'
|
|
30
30
|
import {
|
|
31
31
|
TabList,
|
|
@@ -40,19 +40,29 @@ import type {
|
|
|
40
40
|
SpecList,
|
|
41
41
|
ISearchResult,
|
|
42
42
|
ApiModel,
|
|
43
|
+
TagList,
|
|
44
|
+
TypeTagList,
|
|
43
45
|
} from '@looker/sdk-codegen'
|
|
44
|
-
import {
|
|
46
|
+
import { criteriaToSet, tagTypes } from '@looker/sdk-codegen'
|
|
47
|
+
import { useSelector } from 'react-redux'
|
|
45
48
|
|
|
46
|
-
import { SearchContext } from '../../context'
|
|
47
49
|
import type { SpecAction } from '../../reducers'
|
|
48
|
-
import { setPattern } from '../../reducers'
|
|
49
50
|
import { useWindowSize } from '../../utils'
|
|
50
51
|
import { HEADER_REM } from '../Header'
|
|
52
|
+
import { selectSearchCriteria, useSettingActions } from '../../state'
|
|
51
53
|
import { SideNavMethodTags } from './SideNavMethodTags'
|
|
52
54
|
import { SideNavTypeTags } from './SideNavTypeTags'
|
|
53
55
|
import { useDebounce, countMethods, countTypes } from './searchUtils'
|
|
54
56
|
import { SearchMessage } from './SearchMessage'
|
|
55
57
|
|
|
58
|
+
interface SideNavState {
|
|
59
|
+
tags: TagList
|
|
60
|
+
typeTags: TypeTagList
|
|
61
|
+
methodCount: number
|
|
62
|
+
typeCount: number
|
|
63
|
+
searchResults?: ISearchResult
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
interface SideNavProps {
|
|
57
67
|
headless?: boolean
|
|
58
68
|
/** Specs to choose from */
|
|
@@ -66,7 +76,6 @@ interface SideNavProps {
|
|
|
66
76
|
export const SideNav: FC<SideNavProps> = ({ headless = false, spec }) => {
|
|
67
77
|
const history = useHistory()
|
|
68
78
|
const location = useLocation()
|
|
69
|
-
const api = spec.api || ({} as ApiModel)
|
|
70
79
|
const specKey = spec.key
|
|
71
80
|
const tabNames = ['methods', 'types']
|
|
72
81
|
const pathParts = location.pathname.split('/')
|
|
@@ -90,16 +99,19 @@ export const SideNav: FC<SideNavProps> = ({ headless = false, spec }) => {
|
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
101
|
const tabs = useTabs({ defaultIndex, onChange: onTabChange })
|
|
93
|
-
const
|
|
94
|
-
const
|
|
102
|
+
const searchCriteria = useSelector(selectSearchCriteria)
|
|
103
|
+
const { setSearchPatternAction } = useSettingActions()
|
|
104
|
+
|
|
105
|
+
const [pattern, setSearchPattern] = useState('')
|
|
95
106
|
const debouncedPattern = useDebounce(pattern, 250)
|
|
96
|
-
const [
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
const [sideNavState, setSideNavState] = useState<SideNavState>(() => ({
|
|
108
|
+
tags: spec?.api?.tags || {},
|
|
109
|
+
typeTags: spec?.api?.typeTags || {},
|
|
110
|
+
methodCount: countMethods(spec?.api?.tags || {}),
|
|
111
|
+
typeCount: countTypes(spec?.api?.types || {}),
|
|
112
|
+
searchResults: undefined,
|
|
113
|
+
}))
|
|
114
|
+
const { tags, typeTags, methodCount, typeCount, searchResults } = sideNavState
|
|
103
115
|
|
|
104
116
|
const handleInputChange = (value: string) => {
|
|
105
117
|
setSearchPattern(value)
|
|
@@ -110,8 +122,10 @@ export const SideNav: FC<SideNavProps> = ({ headless = false, spec }) => {
|
|
|
110
122
|
let newTags
|
|
111
123
|
let newTypes
|
|
112
124
|
let newTypeTags
|
|
125
|
+
const api = spec.api || ({} as ApiModel)
|
|
126
|
+
|
|
113
127
|
if (debouncedPattern && api.search) {
|
|
114
|
-
results = api.search(pattern, searchCriteria)
|
|
128
|
+
results = api.search(pattern, criteriaToSet(searchCriteria))
|
|
115
129
|
newTags = results.tags
|
|
116
130
|
newTypes = results.types
|
|
117
131
|
newTypeTags = tagTypes(api, results.types)
|
|
@@ -121,14 +135,22 @@ export const SideNav: FC<SideNavProps> = ({ headless = false, spec }) => {
|
|
|
121
135
|
newTypeTags = api.typeTags || {}
|
|
122
136
|
}
|
|
123
137
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
138
|
+
setSideNavState({
|
|
139
|
+
tags: newTags,
|
|
140
|
+
typeTags: newTypeTags,
|
|
141
|
+
typeCount: countTypes(newTypes),
|
|
142
|
+
methodCount: countMethods(newTags),
|
|
143
|
+
searchResults: results,
|
|
144
|
+
})
|
|
145
|
+
setSearchPatternAction({ searchPattern: debouncedPattern })
|
|
146
|
+
}, [
|
|
147
|
+
debouncedPattern,
|
|
148
|
+
specKey,
|
|
149
|
+
spec,
|
|
150
|
+
setSearchPatternAction,
|
|
151
|
+
pattern,
|
|
152
|
+
searchCriteria,
|
|
153
|
+
])
|
|
132
154
|
|
|
133
155
|
useEffect(() => {
|
|
134
156
|
const { selectedIndex, onSelectTab } = tabs
|
|
@@ -153,7 +175,6 @@ export const SideNav: FC<SideNavProps> = ({ headless = false, spec }) => {
|
|
|
153
175
|
placeholder="Search"
|
|
154
176
|
value={pattern}
|
|
155
177
|
isClearable
|
|
156
|
-
changeOnSelect
|
|
157
178
|
/>
|
|
158
179
|
<SearchMessage search={searchResults} />
|
|
159
180
|
<TabList {...tabs} distribute>
|
|
@@ -29,13 +29,15 @@ import { screen } 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 { SideNavMethodTags } from './SideNavMethodTags'
|
|
34
34
|
|
|
35
35
|
describe('SideNavTags', () => {
|
|
36
36
|
const tags = pick(api.tags, ['ApiAuth', 'Dashboard'])
|
|
37
37
|
test('it renders a provided tag and its methods', () => {
|
|
38
|
-
|
|
38
|
+
renderWithRouterAndReduxProvider(
|
|
39
|
+
<SideNavMethodTags tags={tags} specKey={'3.1'} />
|
|
40
|
+
)
|
|
39
41
|
const tag = screen.getByText('Dashboard')
|
|
40
42
|
const tagContent = 'Create Dashboard'
|
|
41
43
|
expect(screen.queryByText(tagContent)).not.toBeInTheDocument()
|
|
@@ -46,7 +48,9 @@ describe('SideNavTags', () => {
|
|
|
46
48
|
})
|
|
47
49
|
|
|
48
50
|
test('tags are rendered initially collapsed and expand when clicked', () => {
|
|
49
|
-
|
|
51
|
+
renderWithRouterAndReduxProvider(
|
|
52
|
+
<SideNavMethodTags tags={tags} specKey={'3.1'} />
|
|
53
|
+
)
|
|
50
54
|
|
|
51
55
|
const allTags = screen.getAllByText(/ApiAuth|Dashboard/)
|
|
52
56
|
expect(allTags).toHaveLength(2)
|
|
@@ -58,10 +62,8 @@ describe('SideNavTags', () => {
|
|
|
58
62
|
})
|
|
59
63
|
|
|
60
64
|
test('tag is expanded if specified in route', () => {
|
|
61
|
-
|
|
65
|
+
renderWithRouterAndReduxProvider(
|
|
62
66
|
<SideNavMethodTags tags={tags} specKey={'3.1'} />,
|
|
63
|
-
undefined,
|
|
64
|
-
undefined,
|
|
65
67
|
['/3.1/methods/Dashboard']
|
|
66
68
|
)
|
|
67
69
|
|
|
@@ -29,7 +29,10 @@ import userEvent from '@testing-library/user-event'
|
|
|
29
29
|
import { screen } from '@testing-library/react'
|
|
30
30
|
|
|
31
31
|
import { api } from '../../test-data'
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
createTestStore,
|
|
34
|
+
renderWithRouterAndReduxProvider,
|
|
35
|
+
} from '../../test-utils'
|
|
33
36
|
import { SideNavMethods } from './SideNavMethods'
|
|
34
37
|
|
|
35
38
|
describe('SideNavMethods', () => {
|
|
@@ -37,7 +40,7 @@ describe('SideNavMethods', () => {
|
|
|
37
40
|
const methods = api.tags[tag]
|
|
38
41
|
|
|
39
42
|
test('it renders provided methods', () => {
|
|
40
|
-
|
|
43
|
+
renderWithRouterAndReduxProvider(
|
|
41
44
|
<SideNavMethods methods={methods} tag={tag} specKey={'3.1'} />
|
|
42
45
|
)
|
|
43
46
|
userEvent.click(screen.getByText(tag))
|
|
@@ -50,14 +53,15 @@ describe('SideNavMethods', () => {
|
|
|
50
53
|
})
|
|
51
54
|
|
|
52
55
|
test('it highlights text matching search pattern in both tag and methods', () => {
|
|
53
|
-
const
|
|
54
|
-
|
|
56
|
+
const store = createTestStore({ settings: { searchPattern: 'dash' } })
|
|
57
|
+
renderWithRouterAndReduxProvider(
|
|
55
58
|
<SideNavMethods
|
|
56
59
|
methods={pick(methods, 'create_dashboard')}
|
|
57
60
|
tag={tag}
|
|
58
61
|
specKey={'3.1'}
|
|
59
62
|
/>,
|
|
60
|
-
|
|
63
|
+
undefined,
|
|
64
|
+
store
|
|
61
65
|
)
|
|
62
66
|
userEvent.click(screen.getByText('Dash'))
|
|
63
67
|
const matches = screen.getAllByText(/dash/i)
|
|
@@ -24,14 +24,16 @@
|
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import React, {
|
|
27
|
+
import React, { useEffect, useState } from 'react'
|
|
28
28
|
import styled from 'styled-components'
|
|
29
29
|
import { Accordion2, Heading } from '@looker/components'
|
|
30
30
|
import type { MethodList } from '@looker/sdk-codegen'
|
|
31
|
+
import { useSelector } from 'react-redux'
|
|
31
32
|
import { useHistory, useRouteMatch } from 'react-router-dom'
|
|
33
|
+
|
|
32
34
|
import { Link } from '../Link'
|
|
33
35
|
import { buildMethodPath, highlightHTML } from '../../utils'
|
|
34
|
-
import {
|
|
36
|
+
import { selectSearchPattern } from '../../state'
|
|
35
37
|
|
|
36
38
|
interface MethodsProps {
|
|
37
39
|
methods: MethodList
|
|
@@ -43,9 +45,7 @@ interface MethodsProps {
|
|
|
43
45
|
|
|
44
46
|
export const SideNavMethods = styled(
|
|
45
47
|
({ className, methods, tag, specKey, defaultOpen = false }: MethodsProps) => {
|
|
46
|
-
const
|
|
47
|
-
searchSettings: { pattern },
|
|
48
|
-
} = useContext(SearchContext)
|
|
48
|
+
const searchPattern = useSelector(selectSearchPattern)
|
|
49
49
|
const match = useRouteMatch<{ methodTag: string }>(
|
|
50
50
|
`/:specKey/methods/:methodTag/:methodName?`
|
|
51
51
|
)
|
|
@@ -63,7 +63,7 @@ export const SideNavMethods = styled(
|
|
|
63
63
|
? defaultOpen || match.params.methodTag === tag
|
|
64
64
|
: defaultOpen
|
|
65
65
|
setIsOpen(status)
|
|
66
|
-
}, [defaultOpen, match])
|
|
66
|
+
}, [defaultOpen, match, tag])
|
|
67
67
|
|
|
68
68
|
/* TODO: Fix highlighting. It is applied but it is somehow being overridden */
|
|
69
69
|
return (
|
|
@@ -73,7 +73,7 @@ export const SideNavMethods = styled(
|
|
|
73
73
|
className={className}
|
|
74
74
|
label={
|
|
75
75
|
<Heading as="h4" fontSize="small" py="xsmall">
|
|
76
|
-
{highlightHTML(
|
|
76
|
+
{highlightHTML(searchPattern, tag)}
|
|
77
77
|
</Heading>
|
|
78
78
|
}
|
|
79
79
|
>
|
|
@@ -81,7 +81,7 @@ export const SideNavMethods = styled(
|
|
|
81
81
|
{Object.values(methods).map((method) => (
|
|
82
82
|
<li key={method.name}>
|
|
83
83
|
<Link to={`${buildMethodPath(specKey, tag, method.name)}`}>
|
|
84
|
-
{highlightHTML(
|
|
84
|
+
{highlightHTML(searchPattern, method.summary)}
|
|
85
85
|
</Link>
|
|
86
86
|
</li>
|
|
87
87
|
))}
|
|
@@ -30,13 +30,15 @@ import { screen } from '@testing-library/react'
|
|
|
30
30
|
import userEvent from '@testing-library/user-event'
|
|
31
31
|
|
|
32
32
|
import { api } from '../../test-data'
|
|
33
|
-
import {
|
|
33
|
+
import { renderWithRouterAndReduxProvider } from '../../test-utils'
|
|
34
34
|
import { SideNavTypeTags } from './SideNavTypeTags'
|
|
35
35
|
|
|
36
36
|
describe('SideNavTypeTags', () => {
|
|
37
37
|
const tags = pick(api.typeTags, ['ApiAuth', 'Dashboard'])
|
|
38
38
|
test('it renders a provided tag and its methods', () => {
|
|
39
|
-
|
|
39
|
+
renderWithRouterAndReduxProvider(
|
|
40
|
+
<SideNavTypeTags tags={tags} specKey={'3.1'} />
|
|
41
|
+
)
|
|
40
42
|
const tag = screen.getByText('Dashboard')
|
|
41
43
|
const tagContent = 'CreateDashboardFilter'
|
|
42
44
|
expect(screen.queryByText(tagContent)).not.toBeInTheDocument()
|
|
@@ -47,7 +49,9 @@ describe('SideNavTypeTags', () => {
|
|
|
47
49
|
})
|
|
48
50
|
|
|
49
51
|
test('tags are rendered initially collapsed and expand when clicked', () => {
|
|
50
|
-
|
|
52
|
+
renderWithRouterAndReduxProvider(
|
|
53
|
+
<SideNavTypeTags tags={tags} specKey={'3.1'} />
|
|
54
|
+
)
|
|
51
55
|
|
|
52
56
|
const allTags = screen.getAllByText(/ApiAuth|Dashboard/)
|
|
53
57
|
expect(allTags).toHaveLength(2)
|
|
@@ -60,10 +64,8 @@ describe('SideNavTypeTags', () => {
|
|
|
60
64
|
|
|
61
65
|
test('tag is expanded if specified in route', () => {
|
|
62
66
|
const tags = pick(api.typeTags, ['ApiAuth', 'DataAction'])
|
|
63
|
-
|
|
67
|
+
renderWithRouterAndReduxProvider(
|
|
64
68
|
<SideNavTypeTags tags={tags} specKey={'3.1'} />,
|
|
65
|
-
undefined,
|
|
66
|
-
undefined,
|
|
67
69
|
['/3.1/types/DataAction']
|
|
68
70
|
)
|
|
69
71
|
|
|
@@ -27,12 +27,15 @@ import React from 'react'
|
|
|
27
27
|
import { screen } from '@testing-library/react'
|
|
28
28
|
|
|
29
29
|
import { api } from '../../test-data'
|
|
30
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
createTestStore,
|
|
32
|
+
renderWithRouterAndReduxProvider,
|
|
33
|
+
} from '../../test-utils'
|
|
31
34
|
import { SideNavTypes } from './SideNavTypes'
|
|
32
35
|
|
|
33
36
|
describe('SideNavTypes', () => {
|
|
34
37
|
test('it renders provided types', () => {
|
|
35
|
-
|
|
38
|
+
renderWithRouterAndReduxProvider(
|
|
36
39
|
<SideNavTypes
|
|
37
40
|
specKey={'3.1'}
|
|
38
41
|
types={{
|
|
@@ -46,7 +49,8 @@ describe('SideNavTypes', () => {
|
|
|
46
49
|
})
|
|
47
50
|
|
|
48
51
|
test('it highlights text matching search pattern', () => {
|
|
49
|
-
|
|
52
|
+
const store = createTestStore({ settings: { searchPattern: 'dash' } })
|
|
53
|
+
renderWithRouterAndReduxProvider(
|
|
50
54
|
<SideNavTypes
|
|
51
55
|
specKey={'3.1'}
|
|
52
56
|
types={{
|
|
@@ -54,7 +58,8 @@ describe('SideNavTypes', () => {
|
|
|
54
58
|
}}
|
|
55
59
|
tag="Dashboard"
|
|
56
60
|
/>,
|
|
57
|
-
|
|
61
|
+
undefined,
|
|
62
|
+
store
|
|
58
63
|
)
|
|
59
64
|
const match = screen.getByText(/dash/i)
|
|
60
65
|
expect(match).toContainHTML('<span class="hi">Dash</span>')
|
|
@@ -24,14 +24,16 @@
|
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import React, {
|
|
27
|
+
import React, { useEffect, useState } from 'react'
|
|
28
28
|
import styled from 'styled-components'
|
|
29
29
|
import { Accordion2, Heading } from '@looker/components'
|
|
30
30
|
import type { TypeList } from '@looker/sdk-codegen'
|
|
31
31
|
import { useHistory, useRouteMatch } from 'react-router-dom'
|
|
32
|
+
import { useSelector } from 'react-redux'
|
|
33
|
+
|
|
32
34
|
import { Link } from '../Link'
|
|
33
35
|
import { buildTypePath, highlightHTML } from '../../utils'
|
|
34
|
-
import {
|
|
36
|
+
import { selectSearchPattern } from '../../state'
|
|
35
37
|
|
|
36
38
|
interface TypesProps {
|
|
37
39
|
types: TypeList
|
|
@@ -43,9 +45,7 @@ interface TypesProps {
|
|
|
43
45
|
|
|
44
46
|
export const SideNavTypes = styled(
|
|
45
47
|
({ className, types, tag, specKey, defaultOpen = false }: TypesProps) => {
|
|
46
|
-
const
|
|
47
|
-
searchSettings: { pattern },
|
|
48
|
-
} = useContext(SearchContext)
|
|
48
|
+
const searchPattern = useSelector(selectSearchPattern)
|
|
49
49
|
const match = useRouteMatch<{ typeTag: string }>(
|
|
50
50
|
`/:specKey/types/:typeTag/:typeName?`
|
|
51
51
|
)
|
|
@@ -73,7 +73,7 @@ export const SideNavTypes = styled(
|
|
|
73
73
|
className={className}
|
|
74
74
|
label={
|
|
75
75
|
<Heading as="h4" fontSize="small" py="xsmall">
|
|
76
|
-
{highlightHTML(
|
|
76
|
+
{highlightHTML(searchPattern, tag)}
|
|
77
77
|
</Heading>
|
|
78
78
|
}
|
|
79
79
|
>
|
|
@@ -81,7 +81,7 @@ export const SideNavTypes = styled(
|
|
|
81
81
|
{Object.values(types).map((type) => (
|
|
82
82
|
<li key={type.name}>
|
|
83
83
|
<Link to={`${buildTypePath(specKey, tag, type.name)}`}>
|
|
84
|
-
{highlightHTML(
|
|
84
|
+
{highlightHTML(searchPattern, type.name)}
|
|
85
85
|
</Link>
|
|
86
86
|
</li>
|
|
87
87
|
))}
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
import { useState, useEffect } from 'react'
|
|
28
28
|
import type { TagList, TypeList } from '@looker/sdk-codegen'
|
|
29
29
|
|
|
30
|
-
export const useDebounce = (value:
|
|
31
|
-
const [debouncedValue, setDebouncedValue] = useState()
|
|
30
|
+
export const useDebounce = <T>(value: T, delay: number): T => {
|
|
31
|
+
const [debouncedValue, setDebouncedValue] = useState(value)
|
|
32
32
|
useEffect(() => {
|
|
33
33
|
// Update debounced value only once delay has been elapsed
|
|
34
34
|
const handler = setTimeout(() => {
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
Heading,
|
|
33
33
|
ProgressCircular,
|
|
34
34
|
} from '@looker/components'
|
|
35
|
-
import type { ThemeOverrides } from '
|
|
35
|
+
import type { ThemeOverrides } from '@looker/extension-utils'
|
|
36
36
|
|
|
37
37
|
export interface LoaderProps {
|
|
38
38
|
themeOverrides: ThemeOverrides
|
package/src/reducers/index.ts
CHANGED
package/src/routes/AppRouter.tsx
CHANGED
|
@@ -23,11 +23,13 @@
|
|
|
23
23
|
SOFTWARE.
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
|
+
|
|
26
27
|
import type { FC } from 'react'
|
|
27
28
|
import React from 'react'
|
|
28
29
|
import { Redirect, Route, Switch } from 'react-router-dom'
|
|
29
30
|
import type { ApiModel, SpecList } from '@looker/sdk-codegen'
|
|
30
31
|
import type { RunItSetter } from '@looker/run-it'
|
|
32
|
+
import type { IEnvironmentAdaptor } from '@looker/extension-utils'
|
|
31
33
|
|
|
32
34
|
import {
|
|
33
35
|
HomeScene,
|
|
@@ -37,7 +39,6 @@ import {
|
|
|
37
39
|
TypeTagScene,
|
|
38
40
|
} from '../scenes'
|
|
39
41
|
import { DiffScene } from '../scenes/DiffScene'
|
|
40
|
-
import type { IApixEnvAdaptor } from '../utils'
|
|
41
42
|
import { diffPath } from '../utils'
|
|
42
43
|
|
|
43
44
|
interface AppRouterProps {
|
|
@@ -45,7 +46,7 @@ interface AppRouterProps {
|
|
|
45
46
|
specKey: string
|
|
46
47
|
specs: SpecList
|
|
47
48
|
toggleNavigation: (target?: boolean) => void
|
|
48
|
-
|
|
49
|
+
adaptor: IEnvironmentAdaptor
|
|
49
50
|
setVersionsUrl: RunItSetter
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -54,7 +55,7 @@ export const AppRouter: FC<AppRouterProps> = ({
|
|
|
54
55
|
api,
|
|
55
56
|
specs,
|
|
56
57
|
toggleNavigation,
|
|
57
|
-
|
|
58
|
+
adaptor,
|
|
58
59
|
setVersionsUrl,
|
|
59
60
|
}) => {
|
|
60
61
|
return (
|
|
@@ -72,7 +73,7 @@ export const AppRouter: FC<AppRouterProps> = ({
|
|
|
72
73
|
<Route path="/:specKey/methods/:methodTag/:methodName">
|
|
73
74
|
<MethodScene
|
|
74
75
|
api={api}
|
|
75
|
-
|
|
76
|
+
adaptor={adaptor}
|
|
76
77
|
setVersionsUrl={setVersionsUrl}
|
|
77
78
|
/>
|
|
78
79
|
</Route>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import type { FC } from 'react'
|
|
28
|
-
import React, {
|
|
28
|
+
import React, { useState, useEffect } from 'react'
|
|
29
29
|
import {
|
|
30
30
|
Aside,
|
|
31
31
|
Button,
|
|
@@ -37,11 +37,12 @@ import {
|
|
|
37
37
|
import { Beaker } from '@looker/icons'
|
|
38
38
|
import { useHistory, useParams } from 'react-router-dom'
|
|
39
39
|
import type { RunItSetter } from '@looker/run-it'
|
|
40
|
-
import { RunIt,
|
|
40
|
+
import { RunIt, RunItFormKey } from '@looker/run-it'
|
|
41
41
|
import type { ApiModel } from '@looker/sdk-codegen'
|
|
42
42
|
import { typeRefs } from '@looker/sdk-codegen'
|
|
43
43
|
import { useSelector } from 'react-redux'
|
|
44
44
|
|
|
45
|
+
import type { IEnvironmentAdaptor } from '@looker/extension-utils'
|
|
45
46
|
import {
|
|
46
47
|
ApixSection,
|
|
47
48
|
DocActivityType,
|
|
@@ -57,12 +58,11 @@ import {
|
|
|
57
58
|
DocSchema,
|
|
58
59
|
} from '../../components'
|
|
59
60
|
import { selectSdkLanguage } from '../../state'
|
|
60
|
-
import type { IApixEnvAdaptor } from '../../utils'
|
|
61
61
|
import { DocOperation, DocRequestBody } from './components'
|
|
62
62
|
|
|
63
63
|
interface MethodSceneProps {
|
|
64
64
|
api: ApiModel
|
|
65
|
-
|
|
65
|
+
adaptor: IEnvironmentAdaptor
|
|
66
66
|
setVersionsUrl: RunItSetter
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -72,18 +72,17 @@ interface MethodSceneParams {
|
|
|
72
72
|
specKey: string
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const showRunIt = async (
|
|
76
|
-
const data = await
|
|
75
|
+
const showRunIt = async (adaptor: IEnvironmentAdaptor) => {
|
|
76
|
+
const data = await adaptor.localStorageGetItem(RunItFormKey)
|
|
77
77
|
return !!data
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export const MethodScene: FC<MethodSceneProps> = ({
|
|
81
81
|
api,
|
|
82
|
-
|
|
82
|
+
adaptor,
|
|
83
83
|
setVersionsUrl,
|
|
84
84
|
}) => {
|
|
85
85
|
const history = useHistory()
|
|
86
|
-
const { sdk } = useContext(RunItContext)
|
|
87
86
|
const sdkLanguage = useSelector(selectSdkLanguage)
|
|
88
87
|
const { specKey, methodTag, methodName } = useParams<MethodSceneParams>()
|
|
89
88
|
const { value, toggle, setOn } = useToggle()
|
|
@@ -110,7 +109,7 @@ export const MethodScene: FC<MethodSceneProps> = ({
|
|
|
110
109
|
useEffect(() => {
|
|
111
110
|
const checkRunIt = async () => {
|
|
112
111
|
try {
|
|
113
|
-
const show = await showRunIt(
|
|
112
|
+
const show = await showRunIt(adaptor)
|
|
114
113
|
if (show) {
|
|
115
114
|
setOn()
|
|
116
115
|
}
|
|
@@ -119,7 +118,7 @@ export const MethodScene: FC<MethodSceneProps> = ({
|
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
checkRunIt()
|
|
122
|
-
}, [
|
|
121
|
+
}, [adaptor, setOn])
|
|
123
122
|
|
|
124
123
|
const runItToggle = (
|
|
125
124
|
<RunItButton
|
|
@@ -157,7 +156,7 @@ export const MethodScene: FC<MethodSceneProps> = ({
|
|
|
157
156
|
<DocSchema object={method.schema} />
|
|
158
157
|
</ApixSection>
|
|
159
158
|
)}
|
|
160
|
-
{
|
|
159
|
+
{value && (
|
|
161
160
|
<Aside width="50rem">
|
|
162
161
|
<ExtendComponentsThemeProvider
|
|
163
162
|
themeCustomizations={{
|
|
@@ -171,6 +170,7 @@ export const MethodScene: FC<MethodSceneProps> = ({
|
|
|
171
170
|
}}
|
|
172
171
|
>
|
|
173
172
|
<RunIt
|
|
173
|
+
adaptor={adaptor}
|
|
174
174
|
key={method.operationId}
|
|
175
175
|
sdkLanguage={sdkLanguage}
|
|
176
176
|
api={api}
|