@looker/api-explorer 0.9.22 → 0.9.24
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 +50 -0
- package/lib/ApiExplorer.d.ts +4 -39
- package/lib/ApiExplorer.js +23 -24
- 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/DocMarkdown/DocMarkdown.js +5 -5
- package/lib/components/DocMarkdown/DocMarkdown.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 +1 -1
- package/lib/components/SideNav/SideNav.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 +25 -26
- 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/DocMarkdown/DocMarkdown.js +3 -3
- package/lib/esm/components/DocMarkdown/DocMarkdown.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 +2 -2
- package/lib/esm/components/SideNav/SideNav.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/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 -5
- package/lib/esm/state/settings/selectors.js.map +1 -1
- package/lib/esm/state/settings/slice.js +8 -8
- 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 +1 -2
- 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 +11 -8
- 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/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/state/lodes/index.js +32 -0
- 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.js +5 -5
- package/lib/state/settings/selectors.js.map +1 -1
- package/lib/state/settings/slice.d.ts +13 -13
- package/lib/state/settings/slice.js +13 -13
- 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 +1 -2
- package/lib/test-utils/index.js +12 -28
- 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 +3 -1
- package/lib/test-utils/redux.js +12 -8
- 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 +99 -102
- package/src/{index.tsx → App.tsx} +0 -0
- package/src/StandaloneApiExplorer.tsx +8 -16
- package/src/components/DocMarkdown/DocMarkdown.tsx +3 -3
- 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/SelectorContainer/SdkLanguageSelector.spec.tsx +3 -5
- package/src/components/SelectorContainer/SdkLanguageSelector.tsx +2 -2
- package/src/components/SideNav/SideNav.tsx +2 -2
- package/src/components/common/Loader.tsx +1 -1
- package/src/{context/lode/index.ts → index.ts} +4 -1
- package/src/routes/AppRouter.tsx +5 -4
- package/src/scenes/MethodScene/MethodScene.tsx +11 -11
- package/src/state/index.ts +1 -0
- package/src/{context → state/lodes}/index.ts +2 -1
- package/src/state/lodes/sagas.spec.ts +92 -0
- package/src/state/lodes/sagas.ts +51 -0
- package/src/state/lodes/selectors.spec.ts +42 -0
- 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 +25 -21
- package/src/state/settings/sagas.ts +16 -16
- package/src/state/settings/selectors.spec.ts +1 -5
- package/src/state/settings/selectors.ts +5 -5
- package/src/state/settings/slice.ts +12 -7
- package/src/state/store.ts +7 -2
- package/src/{context/lode/LodeContext.ts → test-data/declarations.ts} +17 -14
- package/src/test-data/index.ts +1 -0
- package/src/test-utils/index.ts +1 -5
- package/src/test-utils/lodes.tsx +41 -0
- package/src/test-utils/redux.tsx +19 -7
- 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/context/index.d.ts +0 -1
- package/lib/context/index.js +0 -20
- 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/esm/context/index.js +0 -2
- 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/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/utils/envAdaptor.js +0 -84
- package/lib/esm/utils/envAdaptor.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/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/utils/envAdaptor.spec.ts +0 -50
- package/src/utils/envAdaptor.ts +0 -147
|
@@ -23,9 +23,12 @@
|
|
|
23
23
|
SOFTWARE.
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
|
-
import type {
|
|
27
|
-
import { registerEnvAdaptor, StandaloneEnvAdaptor } from '../utils'
|
|
26
|
+
import type { RootState } from '../store'
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const selectLodeState = (state: RootState) => state.lodes
|
|
29
|
+
|
|
30
|
+
export const selectExamplesLode = (state: RootState) =>
|
|
31
|
+
selectLodeState(state).examples
|
|
32
|
+
|
|
33
|
+
export const selectDeclarationsLode = (state: RootState) =>
|
|
34
|
+
selectLodeState(state).declarations
|
|
@@ -23,47 +23,47 @@
|
|
|
23
23
|
SOFTWARE.
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
import type { ReactElement } from 'react'
|
|
28
|
-
import React from 'react'
|
|
29
|
-
import type { RenderOptions } from '@testing-library/react'
|
|
30
|
-
import type { Store } from 'redux'
|
|
31
|
-
|
|
32
|
-
import { renderWithTheme } from '@looker/components-test-utils'
|
|
26
|
+
import { createSliceHooks } from '@looker/redux'
|
|
33
27
|
import type { IDeclarationMine, IExampleMine } from '@looker/sdk-codegen'
|
|
34
|
-
import {
|
|
35
|
-
import
|
|
36
|
-
import { withReduxProvider } from './redux'
|
|
28
|
+
import type { PayloadAction } from '@reduxjs/toolkit'
|
|
29
|
+
import { createSlice } from '@reduxjs/toolkit'
|
|
37
30
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
import { saga } from './sagas'
|
|
32
|
+
|
|
33
|
+
export interface LodesState {
|
|
34
|
+
examples?: IExampleMine
|
|
41
35
|
declarations?: IDeclarationMine
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<LodeContext.Provider value={{ examples, declarations }}>
|
|
45
|
-
{consumer}
|
|
46
|
-
</LodeContext.Provider>
|
|
47
|
-
)
|
|
36
|
+
error?: Error
|
|
48
37
|
}
|
|
49
38
|
|
|
50
|
-
export const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
declarations?: IDeclarationMine,
|
|
54
|
-
options?: Omit<RenderOptions, 'queries'>
|
|
55
|
-
) => {
|
|
56
|
-
return renderWithTheme(withLode(component, examples, declarations), options)
|
|
39
|
+
export const defaultLodesState: LodesState = {
|
|
40
|
+
examples: undefined,
|
|
41
|
+
declarations: undefined,
|
|
57
42
|
}
|
|
58
43
|
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
44
|
+
export interface InitPayload {
|
|
45
|
+
examplesLodeUrl?: string
|
|
46
|
+
declarationsLodeUrl?: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type InitSuccessAction = LodesState
|
|
50
|
+
|
|
51
|
+
export const lodesSlice = createSlice({
|
|
52
|
+
name: 'lodes',
|
|
53
|
+
initialState: defaultLodesState,
|
|
54
|
+
reducers: {
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
56
|
+
initLodesAction(_state, _action: PayloadAction<InitPayload>) {},
|
|
57
|
+
initLodesSuccessAction(state, action: PayloadAction<InitSuccessAction>) {
|
|
58
|
+
state.examples = action.payload.examples
|
|
59
|
+
state.declarations = action.payload.declarations
|
|
60
|
+
},
|
|
61
|
+
initLodesFailureAction(state, action: PayloadAction<Error>) {
|
|
62
|
+
state.error = action.payload
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
export const lodeActions = lodesSlice.actions
|
|
68
|
+
export const { useActions: useLodeActions, useStoreState: useLodesStoreState } =
|
|
69
|
+
createSliceHooks(lodesSlice, saga)
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
26
|
import ReduxSagaTester from 'redux-saga-tester'
|
|
27
|
-
import { registerTestEnvAdaptor } from '../../test-utils'
|
|
28
27
|
|
|
29
|
-
import {
|
|
28
|
+
import { getEnvAdaptor, registerTestEnvAdaptor } from '@looker/extension-utils'
|
|
29
|
+
import { StoreConstants } from '@looker/run-it'
|
|
30
30
|
import * as sagas from './sagas'
|
|
31
|
-
import {
|
|
31
|
+
import { settingActions, defaultSettings, settingsSlice } from './slice'
|
|
32
32
|
|
|
33
33
|
describe('Settings Sagas', () => {
|
|
34
34
|
let sagaTester: ReduxSagaTester<any>
|
|
@@ -39,7 +39,7 @@ describe('Settings Sagas', () => {
|
|
|
39
39
|
sagaTester = new ReduxSagaTester({
|
|
40
40
|
initialState: { settings: { sdkLanguage: 'Go' } },
|
|
41
41
|
reducers: {
|
|
42
|
-
settings:
|
|
42
|
+
settings: settingsSlice.reducer,
|
|
43
43
|
},
|
|
44
44
|
})
|
|
45
45
|
localStorage.clear()
|
|
@@ -47,7 +47,7 @@ describe('Settings Sagas', () => {
|
|
|
47
47
|
})
|
|
48
48
|
|
|
49
49
|
describe('setSdkLanguageSaga', () => {
|
|
50
|
-
const setSdkLanguageAction =
|
|
50
|
+
const setSdkLanguageAction = settingActions.setSdkLanguageAction
|
|
51
51
|
|
|
52
52
|
test('persists value sdkLanguage in localstorage', async () => {
|
|
53
53
|
sagaTester.dispatch(setSdkLanguageAction({ sdkLanguage: 'Kotlin' }))
|
|
@@ -60,58 +60,62 @@ describe('Settings Sagas', () => {
|
|
|
60
60
|
})
|
|
61
61
|
)
|
|
62
62
|
expect(localStorage.setItem).toHaveBeenLastCalledWith(
|
|
63
|
-
|
|
63
|
+
StoreConstants.LOCALSTORAGE_SETTINGS_KEY,
|
|
64
64
|
JSON.stringify({ sdkLanguage: 'Kotlin' })
|
|
65
65
|
)
|
|
66
66
|
})
|
|
67
67
|
})
|
|
68
68
|
|
|
69
69
|
describe('initSaga', () => {
|
|
70
|
-
const {
|
|
70
|
+
const {
|
|
71
|
+
initSettingsAction,
|
|
72
|
+
initSettingsSuccessAction,
|
|
73
|
+
initSettingsFailureAction,
|
|
74
|
+
} = settingActions
|
|
71
75
|
|
|
72
76
|
test('sends initSuccess action with defaults on success if no persisted settings are found', async () => {
|
|
73
|
-
sagaTester.dispatch(
|
|
74
|
-
await sagaTester.waitFor('settings/
|
|
77
|
+
sagaTester.dispatch(initSettingsAction())
|
|
78
|
+
await sagaTester.waitFor('settings/initSettingsSuccessAction')
|
|
75
79
|
const calledActions = sagaTester.getCalledActions()
|
|
76
80
|
expect(calledActions).toHaveLength(2)
|
|
77
|
-
expect(calledActions[0]).toEqual(
|
|
81
|
+
expect(calledActions[0]).toEqual(initSettingsAction())
|
|
78
82
|
expect(calledActions[1]).toEqual(
|
|
79
|
-
|
|
83
|
+
initSettingsSuccessAction({
|
|
80
84
|
...defaultSettings,
|
|
81
85
|
})
|
|
82
86
|
)
|
|
83
87
|
})
|
|
84
88
|
|
|
85
|
-
test('sends
|
|
89
|
+
test('sends initSettingsSuccessAction with persisted language on success', async () => {
|
|
86
90
|
jest
|
|
87
91
|
.spyOn(getEnvAdaptor(), 'localStorageGetItem')
|
|
88
92
|
.mockResolvedValueOnce(JSON.stringify({ sdkLanguage: 'Go' }))
|
|
89
93
|
|
|
90
|
-
sagaTester.dispatch(
|
|
91
|
-
await sagaTester.waitFor('settings/
|
|
94
|
+
sagaTester.dispatch(initSettingsAction())
|
|
95
|
+
await sagaTester.waitFor('settings/initSettingsSuccessAction')
|
|
92
96
|
const calledActions = sagaTester.getCalledActions()
|
|
93
97
|
expect(calledActions).toHaveLength(2)
|
|
94
|
-
expect(calledActions[0]).toEqual(
|
|
98
|
+
expect(calledActions[0]).toEqual(initSettingsAction())
|
|
95
99
|
expect(calledActions[1]).toEqual(
|
|
96
|
-
|
|
100
|
+
initSettingsSuccessAction({
|
|
97
101
|
...defaultSettings,
|
|
98
102
|
sdkLanguage: 'Go',
|
|
99
103
|
})
|
|
100
104
|
)
|
|
101
105
|
})
|
|
102
106
|
|
|
103
|
-
test('sends
|
|
107
|
+
test('sends initSettingsFailureAction on error', async () => {
|
|
104
108
|
const error = new Error('boom')
|
|
105
109
|
jest
|
|
106
110
|
.spyOn(getEnvAdaptor(), 'localStorageGetItem')
|
|
107
111
|
.mockRejectedValueOnce(error)
|
|
108
112
|
|
|
109
|
-
sagaTester.dispatch(
|
|
110
|
-
await sagaTester.waitFor('settings/
|
|
113
|
+
sagaTester.dispatch(initSettingsAction())
|
|
114
|
+
await sagaTester.waitFor('settings/initSettingsFailureAction')
|
|
111
115
|
const calledActions = sagaTester.getCalledActions()
|
|
112
116
|
expect(calledActions).toHaveLength(2)
|
|
113
|
-
expect(calledActions[0]).toEqual(
|
|
114
|
-
expect(calledActions[1]).toEqual(
|
|
117
|
+
expect(calledActions[0]).toEqual(initSettingsAction())
|
|
118
|
+
expect(calledActions[1]).toEqual(initSettingsFailureAction(error))
|
|
115
119
|
})
|
|
116
120
|
})
|
|
117
121
|
})
|
|
@@ -25,21 +25,21 @@
|
|
|
25
25
|
*/
|
|
26
26
|
import { takeEvery, call, put, select } from 'typed-redux-saga'
|
|
27
27
|
|
|
28
|
-
import {
|
|
28
|
+
import { getEnvAdaptor } from '@looker/extension-utils'
|
|
29
|
+
import { StoreConstants } from '@looker/run-it'
|
|
29
30
|
import type { RootState } from '../store'
|
|
30
|
-
import {
|
|
31
|
+
import { settingActions, defaultSettings } from './slice'
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* Serializes state to local storage
|
|
34
35
|
*/
|
|
35
36
|
function* serializeToLocalStorageSaga() {
|
|
36
|
-
const
|
|
37
|
+
const adaptor = getEnvAdaptor()
|
|
37
38
|
const settings = yield* select((state: RootState) => ({
|
|
38
39
|
sdkLanguage: state.settings.sdkLanguage,
|
|
39
40
|
}))
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
EnvAdaptorConstants.LOCALSTORAGE_SETTINGS_KEY,
|
|
41
|
+
adaptor.localStorageSetItem(
|
|
42
|
+
StoreConstants.LOCALSTORAGE_SETTINGS_KEY,
|
|
43
43
|
JSON.stringify(settings)
|
|
44
44
|
)
|
|
45
45
|
}
|
|
@@ -47,11 +47,10 @@ function* serializeToLocalStorageSaga() {
|
|
|
47
47
|
/**
|
|
48
48
|
* Returns default settings overridden with any persisted state in local storage
|
|
49
49
|
*/
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
const settings =
|
|
53
|
-
|
|
54
|
-
EnvAdaptorConstants.LOCALSTORAGE_SETTINGS_KEY
|
|
50
|
+
async function deserializeLocalStorage() {
|
|
51
|
+
const adaptor = getEnvAdaptor()
|
|
52
|
+
const settings = await adaptor.localStorageGetItem(
|
|
53
|
+
StoreConstants.LOCALSTORAGE_SETTINGS_KEY
|
|
55
54
|
)
|
|
56
55
|
return settings
|
|
57
56
|
? { ...defaultSettings, ...JSON.parse(settings) }
|
|
@@ -62,18 +61,19 @@ function* deserializeLocalStorage() {
|
|
|
62
61
|
* Initializes the store with default settings and existing persisted settings
|
|
63
62
|
*/
|
|
64
63
|
function* initSaga() {
|
|
65
|
-
const {
|
|
64
|
+
const { initSettingsSuccessAction, initSettingsFailureAction } =
|
|
65
|
+
settingActions
|
|
66
66
|
try {
|
|
67
67
|
const settings = yield* call(deserializeLocalStorage)
|
|
68
|
-
yield* put(
|
|
68
|
+
yield* put(initSettingsSuccessAction(settings))
|
|
69
69
|
} catch (error: any) {
|
|
70
|
-
yield* put(
|
|
70
|
+
yield* put(initSettingsFailureAction(error))
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export function* saga() {
|
|
75
|
-
const {
|
|
75
|
+
const { initSettingsAction, setSdkLanguageAction } = settingActions
|
|
76
76
|
|
|
77
|
-
yield* takeEvery(
|
|
77
|
+
yield* takeEvery(initSettingsAction, initSaga)
|
|
78
78
|
yield* takeEvery(setSdkLanguageAction, serializeToLocalStorageSaga)
|
|
79
79
|
}
|
|
@@ -23,13 +23,9 @@
|
|
|
23
23
|
SOFTWARE.
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
|
-
import { createTestStore } from '../../test-utils'
|
|
26
|
+
import { createTestStore, preloadedState } from '../../test-utils'
|
|
27
27
|
import { selectSdkLanguage, isInitialized } from './selectors'
|
|
28
28
|
|
|
29
|
-
const preloadedState = {
|
|
30
|
-
settings: { initialized: false, sdkLanguage: 'Python' },
|
|
31
|
-
}
|
|
32
|
-
|
|
33
29
|
const testStore = createTestStore()
|
|
34
30
|
|
|
35
31
|
describe('Settings selectors', () => {
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
*/
|
|
26
26
|
import type { RootState } from '../store'
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const selectSettingsState = (state: RootState) => state.settings
|
|
29
29
|
|
|
30
30
|
export const selectSdkLanguage = (state: RootState) =>
|
|
31
|
-
|
|
31
|
+
selectSettingsState(state).sdkLanguage
|
|
32
32
|
|
|
33
33
|
export const selectSearchPattern = (state: RootState) =>
|
|
34
|
-
|
|
34
|
+
selectSettingsState(state).searchPattern
|
|
35
35
|
|
|
36
36
|
export const selectSearchCriteria = (state: RootState) =>
|
|
37
|
-
|
|
37
|
+
selectSettingsState(state).searchCriteria
|
|
38
38
|
|
|
39
39
|
export const isInitialized = (state: RootState) =>
|
|
40
|
-
|
|
40
|
+
selectSettingsState(state).initialized
|
|
@@ -58,17 +58,20 @@ type SetSdkLanguageAction = Pick<SettingState, 'sdkLanguage'>
|
|
|
58
58
|
|
|
59
59
|
export type InitSuccessPayload = UserDefinedSettings
|
|
60
60
|
|
|
61
|
-
export const
|
|
61
|
+
export const settingsSlice = createSlice({
|
|
62
62
|
name: 'settings',
|
|
63
63
|
initialState: defaultSettingsState,
|
|
64
64
|
reducers: {
|
|
65
65
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
initSettingsAction() {},
|
|
67
|
+
initSettingsSuccessAction(
|
|
68
|
+
state,
|
|
69
|
+
action: PayloadAction<InitSuccessPayload>
|
|
70
|
+
) {
|
|
68
71
|
state.sdkLanguage = action.payload.sdkLanguage
|
|
69
72
|
state.initialized = true
|
|
70
73
|
},
|
|
71
|
-
|
|
74
|
+
initSettingsFailureAction(state, action: PayloadAction<Error>) {
|
|
72
75
|
state.error = action.payload
|
|
73
76
|
state.initialized = false
|
|
74
77
|
},
|
|
@@ -84,6 +87,8 @@ export const slice = createSlice({
|
|
|
84
87
|
},
|
|
85
88
|
})
|
|
86
89
|
|
|
87
|
-
export const
|
|
88
|
-
export const {
|
|
89
|
-
|
|
90
|
+
export const settingActions = settingsSlice.actions
|
|
91
|
+
export const {
|
|
92
|
+
useActions: useSettingActions,
|
|
93
|
+
useStoreState: useSettingStoreState,
|
|
94
|
+
} = createSliceHooks(settingsSlice, saga)
|
package/src/state/store.ts
CHANGED
|
@@ -26,17 +26,22 @@
|
|
|
26
26
|
import { createStore } from '@looker/redux'
|
|
27
27
|
|
|
28
28
|
import type { SettingState } from './settings'
|
|
29
|
-
import { defaultSettingsState,
|
|
29
|
+
import { defaultSettingsState, settingsSlice } from './settings'
|
|
30
|
+
import type { LodesState } from './lodes'
|
|
31
|
+
import { lodesSlice, defaultLodesState } from './lodes'
|
|
30
32
|
|
|
31
33
|
export const store = createStore({
|
|
32
34
|
preloadedState: {
|
|
33
35
|
settings: defaultSettingsState,
|
|
36
|
+
lodes: defaultLodesState,
|
|
34
37
|
},
|
|
35
38
|
reducer: {
|
|
36
|
-
settings:
|
|
39
|
+
settings: settingsSlice.reducer,
|
|
40
|
+
lodes: lodesSlice.reducer,
|
|
37
41
|
},
|
|
38
42
|
})
|
|
39
43
|
|
|
40
44
|
export interface RootState {
|
|
41
45
|
settings: SettingState
|
|
46
|
+
lodes: LodesState
|
|
42
47
|
}
|
|
@@ -23,18 +23,21 @@
|
|
|
23
23
|
SOFTWARE.
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
import type { IDeclarationMine } from '@looker/sdk-codegen'
|
|
27
|
+
|
|
28
|
+
export const declarations: IDeclarationMine = {
|
|
29
|
+
commitHash: '1e9348b797c2f3760d03c1f94c60f18e534e8298',
|
|
30
|
+
remoteOrigin: 'https://github.com/looker-open-source/sdk-codegen',
|
|
31
|
+
types: {
|
|
32
|
+
FullLode: {
|
|
33
|
+
line: 40,
|
|
34
|
+
sourceFile: 'packages/api-explorer/src/utils/lodeUtils.ts',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
methods: {
|
|
38
|
+
getLoded: {
|
|
39
|
+
line: 45,
|
|
40
|
+
sourceFile: 'packages/api-explorer/src/utils/lodeUtils.ts',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
36
43
|
}
|
|
37
|
-
|
|
38
|
-
export const LodeContext = createContext<LodeContextProps>(
|
|
39
|
-
defaultLodeContextValue
|
|
40
|
-
)
|
package/src/test-data/index.ts
CHANGED
package/src/test-utils/index.ts
CHANGED
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
SOFTWARE.
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
27
|
-
renderWithLode,
|
|
28
|
-
renderWithReduxProviderAndLode,
|
|
29
|
-
} from './render_with_lode'
|
|
26
|
+
export * from './lodes'
|
|
30
27
|
export * from './router'
|
|
31
28
|
export * from './redux'
|
|
32
|
-
export { registerTestEnvAdaptor } from './envAdaptor'
|
|
@@ -0,0 +1,41 @@
|
|
|
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 type { IDeclarationMine, IExampleMine } from '@looker/sdk-codegen'
|
|
27
|
+
import type { ReactElement } from 'react'
|
|
28
|
+
import type { RenderOptions } from '@testing-library/react'
|
|
29
|
+
import { renderWithTheme } from '@looker/components-test-utils'
|
|
30
|
+
|
|
31
|
+
import { createTestStore, withReduxProvider } from './redux'
|
|
32
|
+
|
|
33
|
+
export const renderWithLode = (
|
|
34
|
+
consumers: ReactElement<any>,
|
|
35
|
+
examples: IExampleMine,
|
|
36
|
+
declarations?: IDeclarationMine,
|
|
37
|
+
options?: Omit<RenderOptions, 'queries'>
|
|
38
|
+
) => {
|
|
39
|
+
const store = createTestStore({ lodes: { examples, declarations } })
|
|
40
|
+
return renderWithTheme(withReduxProvider(consumers, store), options)
|
|
41
|
+
}
|
package/src/test-utils/redux.tsx
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
SOFTWARE.
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
|
+
|
|
26
27
|
import type { ReactElement } from 'react'
|
|
27
28
|
import React from 'react'
|
|
28
29
|
import { Provider } from 'react-redux'
|
|
@@ -30,18 +31,24 @@ import type { Store } from 'redux'
|
|
|
30
31
|
import { renderWithTheme } from '@looker/components-test-utils'
|
|
31
32
|
import type { RenderOptions } from '@testing-library/react'
|
|
32
33
|
import { createStore } from '@looker/redux'
|
|
34
|
+
import { BrowserAdaptor, registerEnvAdaptor } from '@looker/extension-utils'
|
|
35
|
+
import { initRunItSdk } from '@looker/run-it'
|
|
33
36
|
|
|
34
|
-
import type { RootState, SettingState } from '../state'
|
|
35
|
-
import {
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
import type { LodesState, RootState, SettingState } from '../state'
|
|
38
|
+
import {
|
|
39
|
+
settingsSlice,
|
|
40
|
+
defaultLodesState,
|
|
41
|
+
defaultSettingsState,
|
|
42
|
+
store as defaultStore,
|
|
43
|
+
lodesSlice,
|
|
44
|
+
} from '../state'
|
|
38
45
|
import { renderWithRouter } from './router'
|
|
39
46
|
|
|
40
47
|
export const withReduxProvider = (
|
|
41
48
|
consumers: ReactElement<any>,
|
|
42
49
|
store: Store<RootState> = defaultStore
|
|
43
50
|
) => {
|
|
44
|
-
registerEnvAdaptor(new
|
|
51
|
+
registerEnvAdaptor(new BrowserAdaptor(initRunItSdk()))
|
|
45
52
|
return <Provider store={store}>{consumers}</Provider>
|
|
46
53
|
}
|
|
47
54
|
|
|
@@ -59,8 +66,9 @@ export const renderWithRouterAndReduxProvider = (
|
|
|
59
66
|
) =>
|
|
60
67
|
renderWithRouter(withReduxProvider(consumers, store), initialEntries, options)
|
|
61
68
|
|
|
62
|
-
const preloadedState: RootState = {
|
|
69
|
+
export const preloadedState: RootState = {
|
|
63
70
|
settings: defaultSettingsState,
|
|
71
|
+
lodes: defaultLodesState,
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
type DeepPartial<T> = {
|
|
@@ -74,6 +82,10 @@ export const createTestStore = (overrides?: DeepPartial<RootState>) =>
|
|
|
74
82
|
...preloadedState.settings,
|
|
75
83
|
...overrides?.settings,
|
|
76
84
|
} as SettingState,
|
|
85
|
+
lodes: {
|
|
86
|
+
...defaultLodesState,
|
|
87
|
+
...overrides?.lodes,
|
|
88
|
+
} as LodesState,
|
|
77
89
|
},
|
|
78
|
-
reducer: { settings: settingsSlice.reducer },
|
|
90
|
+
reducer: { settings: settingsSlice.reducer, lodes: lodesSlice.reducer },
|
|
79
91
|
})
|
package/src/utils/index.ts
CHANGED
package/src/utils/lodeUtils.ts
CHANGED
|
@@ -38,17 +38,17 @@ const fetchLode = async (lodeUrl: string) => {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
interface FullLode {
|
|
41
|
-
examples
|
|
41
|
+
examples?: IExampleMine
|
|
42
42
|
declarations?: IDeclarationMine
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export const getLoded = async (
|
|
46
|
-
examplesLodeUrl
|
|
46
|
+
examplesLodeUrl?: string,
|
|
47
47
|
declarationsLodeUrl?: string
|
|
48
48
|
): Promise<FullLode> => {
|
|
49
49
|
// First try to load from the apix-files server
|
|
50
50
|
let examples = await fetchLode(`${apixFilesHost}/examplesIndex.json`)
|
|
51
|
-
if (!examples) {
|
|
51
|
+
if (!examples && examplesLodeUrl) {
|
|
52
52
|
examples = await fetchLode(examplesLodeUrl)
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -57,9 +57,7 @@ export const getLoded = async (
|
|
|
57
57
|
declarations = await fetchLode(declarationsLodeUrl)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
const lode: FullLode = {
|
|
61
|
-
examples: { commitHash: '', nuggets: {}, remoteOrigin: '', summaries: {} },
|
|
62
|
-
}
|
|
60
|
+
const lode: FullLode = { examples: undefined, declarations: undefined }
|
|
63
61
|
if (examples) {
|
|
64
62
|
lode.examples = JSON.parse(examples)
|
|
65
63
|
}
|
package/webpack.dev.config.js
CHANGED
|
@@ -30,6 +30,9 @@ const base = require('../../webpack.base.config')(__dirname)
|
|
|
30
30
|
const browser = require('../../webpack.browser.config')()
|
|
31
31
|
|
|
32
32
|
module.exports = merge(base, browser, {
|
|
33
|
+
entry: {
|
|
34
|
+
app: path.join(__dirname, 'src/App.tsx'),
|
|
35
|
+
},
|
|
33
36
|
mode: 'development',
|
|
34
37
|
devServer: {
|
|
35
38
|
contentBase: path.join(__dirname, 'public'),
|
package/webpack.prod.config.js
CHANGED
|
@@ -23,10 +23,14 @@
|
|
|
23
23
|
SOFTWARE.
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
|
+
const path = require('path')
|
|
26
27
|
const { merge } = require('webpack-merge')
|
|
27
28
|
const base = require('../../webpack.base.config')(__dirname)
|
|
28
29
|
const browser = require('../../webpack.browser.config')()
|
|
29
30
|
|
|
30
31
|
module.exports = merge(base, browser, {
|
|
32
|
+
entry: {
|
|
33
|
+
app: path.join(__dirname, 'src/index.ts'),
|
|
34
|
+
},
|
|
31
35
|
mode: 'production',
|
|
32
36
|
})
|
package/lib/context/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { LodeContext, defaultLodeContextValue } from './lode';
|
package/lib/context/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "LodeContext", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _lode.LodeContext;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "defaultLodeContextValue", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _lode.defaultLodeContextValue;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var _lode = require("./lode");
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
package/lib/context/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAyBA","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nexport { LodeContext, defaultLodeContextValue } from './lode'\n"],"file":"index.js"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { IDeclarationMine, IExampleMine } from '@looker/sdk-codegen';
|
|
3
|
-
interface LodeContextProps {
|
|
4
|
-
examples: IExampleMine;
|
|
5
|
-
declarations?: IDeclarationMine;
|
|
6
|
-
}
|
|
7
|
-
export declare const defaultLodeContextValue: LodeContextProps;
|
|
8
|
-
export declare const LodeContext: import("react").Context<LodeContextProps>;
|
|
9
|
-
export {};
|