@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
|
@@ -29,7 +29,7 @@ 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 { TypeTagScene } from './TypeTagScene'
|
|
34
34
|
|
|
35
35
|
const opBtnNames = /ALL|SPECIFICATION|WRITE|REQUEST|ENUMERATED/
|
|
@@ -40,7 +40,7 @@ describe('TypeTagScene', () => {
|
|
|
40
40
|
Element.prototype.scrollTo = jest.fn()
|
|
41
41
|
|
|
42
42
|
test('it renders type buttons and all methods for a given type tag', () => {
|
|
43
|
-
|
|
43
|
+
renderWithRouterAndReduxProvider(
|
|
44
44
|
<Route path={path}>
|
|
45
45
|
<TypeTagScene api={api} />
|
|
46
46
|
</Route>,
|
|
@@ -61,7 +61,7 @@ describe('TypeTagScene', () => {
|
|
|
61
61
|
})
|
|
62
62
|
|
|
63
63
|
test('it only renders operation buttons for operations that exist under that tag', () => {
|
|
64
|
-
|
|
64
|
+
renderWithRouterAndReduxProvider(
|
|
65
65
|
<Route path={path}>
|
|
66
66
|
<TypeTagScene api={api} />
|
|
67
67
|
</Route>,
|
|
@@ -75,7 +75,7 @@ describe('TypeTagScene', () => {
|
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
test('it filters methods by operation type', async () => {
|
|
78
|
-
|
|
78
|
+
renderWithRouterAndReduxProvider(
|
|
79
79
|
<Route path={path}>
|
|
80
80
|
<TypeTagScene api={api} />
|
|
81
81
|
</Route>,
|
package/src/state/index.ts
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
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 ReduxSagaTester from 'redux-saga-tester'
|
|
27
|
+
import { examples, declarations } from '../../test-data'
|
|
28
|
+
import * as lodeUtils from '../../utils/lodeUtils'
|
|
29
|
+
import * as sagas from './sagas'
|
|
30
|
+
import { lodeActions, lodesSlice } from './slice'
|
|
31
|
+
|
|
32
|
+
describe('Lode sagas', () => {
|
|
33
|
+
let sagaTester: ReduxSagaTester<any>
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
jest.resetAllMocks()
|
|
37
|
+
sagaTester = new ReduxSagaTester({
|
|
38
|
+
initialState: { lodes: { examples, declarations } },
|
|
39
|
+
reducers: {
|
|
40
|
+
lodes: lodesSlice.reducer,
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
sagaTester.start(sagas.saga)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
describe('initSaga', () => {
|
|
47
|
+
const { initLodesAction, initLodesSuccessAction, initLodesFailureAction } =
|
|
48
|
+
lodeActions
|
|
49
|
+
const examplesLodeUrl = 'https://foo.com/examples.json'
|
|
50
|
+
const declarationsLodeUrl = 'https://foo.com/declarations.json'
|
|
51
|
+
|
|
52
|
+
test('sends initLodesSuccessAction with examples and declarations on success', async () => {
|
|
53
|
+
jest
|
|
54
|
+
.spyOn(lodeUtils, 'getLoded')
|
|
55
|
+
.mockResolvedValueOnce({ examples, declarations })
|
|
56
|
+
|
|
57
|
+
sagaTester.dispatch(
|
|
58
|
+
initLodesAction({ examplesLodeUrl, declarationsLodeUrl })
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
await sagaTester.waitFor('lodes/initLodesSuccessAction')
|
|
62
|
+
const calledActions = sagaTester.getCalledActions()
|
|
63
|
+
expect(calledActions).toHaveLength(2)
|
|
64
|
+
expect(calledActions[0]).toEqual(
|
|
65
|
+
initLodesAction({ examplesLodeUrl, declarationsLodeUrl })
|
|
66
|
+
)
|
|
67
|
+
expect(calledActions[1]).toEqual(
|
|
68
|
+
initLodesSuccessAction({
|
|
69
|
+
examples,
|
|
70
|
+
declarations,
|
|
71
|
+
})
|
|
72
|
+
)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test('sends initLodesFailureAction on error', async () => {
|
|
76
|
+
const error = new Error('boom')
|
|
77
|
+
jest.spyOn(lodeUtils, 'getLoded').mockRejectedValueOnce(error)
|
|
78
|
+
|
|
79
|
+
sagaTester.dispatch(
|
|
80
|
+
initLodesAction({ examplesLodeUrl, declarationsLodeUrl })
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
await sagaTester.waitFor('lodes/initLodesFailureAction')
|
|
84
|
+
const calledActions = sagaTester.getCalledActions()
|
|
85
|
+
expect(calledActions).toHaveLength(2)
|
|
86
|
+
expect(calledActions[0]).toEqual(
|
|
87
|
+
initLodesAction({ examplesLodeUrl, declarationsLodeUrl })
|
|
88
|
+
)
|
|
89
|
+
expect(calledActions[1]).toEqual(initLodesFailureAction(error))
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { call, put, takeEvery } from 'typed-redux-saga'
|
|
27
|
+
import type { PayloadAction } from '@reduxjs/toolkit'
|
|
28
|
+
|
|
29
|
+
import { getLoded } from '../../utils'
|
|
30
|
+
import type { InitPayload } from './slice'
|
|
31
|
+
import { lodeActions } from './slice'
|
|
32
|
+
|
|
33
|
+
function* initSaga(action: PayloadAction<InitPayload>) {
|
|
34
|
+
const { initLodesSuccessAction, initLodesFailureAction } = lodeActions
|
|
35
|
+
try {
|
|
36
|
+
const lode = yield* call(
|
|
37
|
+
getLoded,
|
|
38
|
+
action.payload.examplesLodeUrl,
|
|
39
|
+
action.payload.declarationsLodeUrl
|
|
40
|
+
)
|
|
41
|
+
yield* put(initLodesSuccessAction(lode))
|
|
42
|
+
} catch (error: any) {
|
|
43
|
+
yield* put(initLodesFailureAction(error))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function* saga() {
|
|
48
|
+
const { initLodesAction } = lodeActions
|
|
49
|
+
|
|
50
|
+
yield* takeEvery(initLodesAction, initSaga)
|
|
51
|
+
}
|
|
@@ -23,22 +23,20 @@
|
|
|
23
23
|
SOFTWARE.
|
|
24
24
|
|
|
25
25
|
*/
|
|
26
|
+
import { createTestStore } from '../../test-utils'
|
|
27
|
+
import { declarations, examples } from '../../test-data'
|
|
28
|
+
import { selectDeclarationsLode, selectExamplesLode } from './selectors'
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
import { createContext } from 'react'
|
|
29
|
-
import type { SearchState, SearchAction } from '../../reducers'
|
|
30
|
-
import { defaultSearchState } from '../../reducers'
|
|
30
|
+
const testStore = createTestStore({ lodes: { examples, declarations } })
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
setSearchSettings: Dispatch<SearchAction>
|
|
35
|
-
}
|
|
32
|
+
describe('Lode selectors', () => {
|
|
33
|
+
const state = testStore.getState()
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
35
|
+
test('selectExamplesLode selects', () => {
|
|
36
|
+
expect(selectExamplesLode(state)).toEqual(examples)
|
|
37
|
+
})
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
39
|
+
test('selectDeclarationsLode selects', () => {
|
|
40
|
+
expect(selectDeclarationsLode(state)).toEqual(declarations)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -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,57 +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 {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
const {
|
|
71
|
+
initSettingsAction,
|
|
72
|
+
initSettingsSuccessAction,
|
|
73
|
+
initSettingsFailureAction,
|
|
74
|
+
} = settingActions
|
|
75
|
+
|
|
76
|
+
test('sends initSuccess action with defaults on success if no persisted settings are found', async () => {
|
|
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
|
-
|
|
80
|
-
|
|
83
|
+
initSettingsSuccessAction({
|
|
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({
|
|
101
|
+
...defaultSettings,
|
|
97
102
|
sdkLanguage: 'Go',
|
|
98
103
|
})
|
|
99
104
|
)
|
|
100
105
|
})
|
|
101
106
|
|
|
102
|
-
test('sends
|
|
107
|
+
test('sends initSettingsFailureAction on error', async () => {
|
|
103
108
|
const error = new Error('boom')
|
|
104
109
|
jest
|
|
105
110
|
.spyOn(getEnvAdaptor(), 'localStorageGetItem')
|
|
106
111
|
.mockRejectedValueOnce(error)
|
|
107
112
|
|
|
108
|
-
sagaTester.dispatch(
|
|
109
|
-
await sagaTester.waitFor('settings/
|
|
113
|
+
sagaTester.dispatch(initSettingsAction())
|
|
114
|
+
await sagaTester.waitFor('settings/initSettingsFailureAction')
|
|
110
115
|
const calledActions = sagaTester.getCalledActions()
|
|
111
116
|
expect(calledActions).toHaveLength(2)
|
|
112
|
-
expect(calledActions[0]).toEqual(
|
|
113
|
-
expect(calledActions[1]).toEqual(
|
|
117
|
+
expect(calledActions[0]).toEqual(initSettingsAction())
|
|
118
|
+
expect(calledActions[1]).toEqual(initSettingsFailureAction(error))
|
|
114
119
|
})
|
|
115
120
|
})
|
|
116
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,10 +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
|
+
|
|
33
|
+
export const selectSearchPattern = (state: RootState) =>
|
|
34
|
+
selectSettingsState(state).searchPattern
|
|
35
|
+
|
|
36
|
+
export const selectSearchCriteria = (state: RootState) =>
|
|
37
|
+
selectSettingsState(state).searchCriteria
|
|
32
38
|
|
|
33
39
|
export const isInitialized = (state: RootState) =>
|
|
34
|
-
|
|
40
|
+
selectSettingsState(state).initialized
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
import { createSlice } from '@reduxjs/toolkit'
|
|
27
27
|
import type { PayloadAction } from '@reduxjs/toolkit'
|
|
28
28
|
import { createSliceHooks } from '@looker/redux'
|
|
29
|
+
import type { SearchCriterionTerm } from '@looker/sdk-codegen'
|
|
30
|
+
import { SearchAll, setToCriteria } from '@looker/sdk-codegen'
|
|
31
|
+
|
|
29
32
|
import { saga } from './sagas'
|
|
30
33
|
|
|
31
34
|
export interface UserDefinedSettings {
|
|
@@ -33,12 +36,16 @@ export interface UserDefinedSettings {
|
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
export interface SettingState extends UserDefinedSettings {
|
|
39
|
+
searchPattern: string
|
|
40
|
+
searchCriteria: SearchCriterionTerm[]
|
|
36
41
|
initialized: boolean
|
|
37
42
|
error?: Error
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
export const defaultSettings = {
|
|
41
46
|
sdkLanguage: 'Python',
|
|
47
|
+
searchPattern: '',
|
|
48
|
+
searchCriteria: setToCriteria(SearchAll) as SearchCriterionTerm[],
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
export const defaultSettingsState: SettingState = {
|
|
@@ -46,32 +53,42 @@ export const defaultSettingsState: SettingState = {
|
|
|
46
53
|
initialized: false,
|
|
47
54
|
}
|
|
48
55
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
56
|
+
type SetSearchPatternAction = Pick<SettingState, 'searchPattern'>
|
|
57
|
+
type SetSdkLanguageAction = Pick<SettingState, 'sdkLanguage'>
|
|
52
58
|
|
|
53
59
|
export type InitSuccessPayload = UserDefinedSettings
|
|
54
60
|
|
|
55
|
-
export const
|
|
61
|
+
export const settingsSlice = createSlice({
|
|
56
62
|
name: 'settings',
|
|
57
63
|
initialState: defaultSettingsState,
|
|
58
64
|
reducers: {
|
|
59
65
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
initSettingsAction() {},
|
|
67
|
+
initSettingsSuccessAction(
|
|
68
|
+
state,
|
|
69
|
+
action: PayloadAction<InitSuccessPayload>
|
|
70
|
+
) {
|
|
62
71
|
state.sdkLanguage = action.payload.sdkLanguage
|
|
63
72
|
state.initialized = true
|
|
64
73
|
},
|
|
65
|
-
|
|
74
|
+
initSettingsFailureAction(state, action: PayloadAction<Error>) {
|
|
66
75
|
state.error = action.payload
|
|
67
76
|
state.initialized = false
|
|
68
77
|
},
|
|
69
78
|
setSdkLanguageAction(state, action: PayloadAction<SetSdkLanguageAction>) {
|
|
70
79
|
state.sdkLanguage = action.payload.sdkLanguage
|
|
71
80
|
},
|
|
81
|
+
setSearchPatternAction(
|
|
82
|
+
state,
|
|
83
|
+
action: PayloadAction<SetSearchPatternAction>
|
|
84
|
+
) {
|
|
85
|
+
state.searchPattern = action.payload.searchPattern
|
|
86
|
+
},
|
|
72
87
|
},
|
|
73
88
|
})
|
|
74
89
|
|
|
75
|
-
export const
|
|
76
|
-
export const {
|
|
77
|
-
|
|
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
|
}
|