@looker/api-explorer 0.9.22 → 0.9.27
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 +126 -0
- package/e2e/e2e.spec.ts +1 -1
- package/lib/ApiExplorer.d.ts +4 -43
- package/lib/ApiExplorer.js +71 -93
- 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 +36 -53
- package/lib/StandaloneApiExplorer.js.map +1 -1
- package/lib/components/Banner/Banner.d.ts +8 -0
- package/lib/components/Banner/Banner.js +70 -0
- package/lib/components/Banner/Banner.js.map +1 -0
- package/lib/components/Banner/index.d.ts +1 -0
- package/lib/components/Banner/index.js +14 -0
- package/lib/components/Banner/index.js.map +1 -0
- package/lib/components/DocMarkdown/DocMarkdown.js +5 -5
- package/lib/components/DocMarkdown/DocMarkdown.js.map +1 -1
- package/lib/components/DocSDKs/DocSDKs.js +3 -3
- package/lib/components/DocSDKs/DocSDKs.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/ExploreType/ExploreType.js +3 -5
- package/lib/components/ExploreType/ExploreType.js.map +1 -1
- package/lib/components/Header/Header.d.ts +2 -5
- package/lib/components/Header/Header.js +1 -5
- package/lib/components/Header/Header.js.map +1 -1
- package/lib/components/SelectorContainer/ApiSpecSelector.d.ts +2 -5
- package/lib/components/SelectorContainer/ApiSpecSelector.js +5 -5
- package/lib/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
- package/lib/components/SelectorContainer/SdkLanguageSelector.js +1 -1
- package/lib/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
- package/lib/components/SelectorContainer/SelectorContainer.d.ts +2 -5
- package/lib/components/SelectorContainer/SelectorContainer.js +3 -7
- package/lib/components/SelectorContainer/SelectorContainer.js.map +1 -1
- package/lib/components/SideNav/SideNav.d.ts +2 -5
- 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/components/index.d.ts +1 -0
- package/lib/components/index.js +8 -0
- package/lib/components/index.js.map +1 -1
- package/lib/esm/ApiExplorer.js +71 -92
- 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 +36 -53
- package/lib/esm/StandaloneApiExplorer.js.map +1 -1
- package/lib/esm/components/Banner/Banner.js +54 -0
- package/lib/esm/components/Banner/Banner.js.map +1 -0
- package/lib/esm/components/Banner/index.js +2 -0
- package/lib/esm/{test-utils/envAdaptor.js.map → components/Banner/index.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/DocSDKs/DocSDKs.js +2 -2
- package/lib/esm/components/DocSDKs/DocSDKs.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/ExploreType/ExploreType.js +3 -4
- package/lib/esm/components/ExploreType/ExploreType.js.map +1 -1
- package/lib/esm/components/Header/Header.js +1 -5
- package/lib/esm/components/Header/Header.js.map +1 -1
- package/lib/esm/components/SelectorContainer/ApiSpecSelector.js +4 -5
- package/lib/esm/components/SelectorContainer/ApiSpecSelector.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/SelectorContainer/SelectorContainer.js +3 -7
- package/lib/esm/components/SelectorContainer/SelectorContainer.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/components/index.js +1 -0
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/index.js +5 -18
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/routes/AppRouter.js +3 -7
- package/lib/esm/routes/AppRouter.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DiffScene.js +43 -99
- package/lib/esm/scenes/DiffScene/DiffScene.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js +9 -13
- package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js +2 -2
- package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
- package/lib/esm/scenes/MethodScene/MethodScene.js +12 -15
- package/lib/esm/scenes/MethodScene/MethodScene.js.map +1 -1
- package/lib/esm/state/index.js +2 -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/specs/index.js +3 -0
- package/lib/esm/state/specs/index.js.map +1 -0
- package/lib/esm/state/specs/sagas.js +58 -0
- package/lib/esm/state/specs/sagas.js.map +1 -0
- package/lib/esm/state/specs/selectors.js +8 -0
- package/lib/esm/state/specs/selectors.js.map +1 -0
- package/lib/esm/state/specs/slice.js +55 -0
- package/lib/esm/state/specs/slice.js.map +1 -0
- package/lib/esm/state/store.js +57 -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 +16 -9
- package/lib/esm/test-utils/redux.js.map +1 -1
- package/lib/esm/utils/adaptorUtils.js +101 -0
- package/lib/esm/utils/adaptorUtils.js.map +1 -0
- package/lib/esm/utils/apixAdaptor.js +48 -0
- package/lib/esm/utils/apixAdaptor.js.map +1 -0
- package/lib/esm/utils/index.js +3 -2
- 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/esm/utils/path.js +27 -2
- package/lib/esm/utils/path.js.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +59 -17
- package/lib/index.js.map +1 -1
- package/lib/routes/AppRouter.d.ts +1 -5
- package/lib/routes/AppRouter.js +3 -7
- package/lib/routes/AppRouter.js.map +1 -1
- package/lib/scenes/DiffScene/DiffScene.js +45 -100
- package/lib/scenes/DiffScene/DiffScene.js.map +1 -1
- package/lib/scenes/DiffScene/DocDiff/DiffItem.js +9 -13
- package/lib/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
- package/lib/scenes/DiffScene/DocDiff/DocDiff.js +2 -2
- package/lib/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
- package/lib/scenes/MethodScene/MethodScene.d.ts +0 -4
- package/lib/scenes/MethodScene/MethodScene.js +11 -13
- package/lib/scenes/MethodScene/MethodScene.js.map +1 -1
- package/lib/state/index.d.ts +2 -0
- package/lib/state/index.js +26 -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.d.ts +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 +14 -14
- package/lib/state/settings/slice.js +13 -13
- package/lib/state/settings/slice.js.map +1 -1
- package/lib/state/specs/index.d.ts +2 -0
- package/lib/state/specs/index.js +32 -0
- package/lib/state/specs/index.js.map +1 -0
- package/lib/state/specs/sagas.d.ts +1 -0
- package/lib/state/specs/sagas.js +67 -0
- package/lib/state/specs/sagas.js.map +1 -0
- package/lib/state/specs/selectors.d.ts +4 -0
- package/lib/state/specs/selectors.js +20 -0
- package/lib/state/specs/selectors.js.map +1 -0
- package/lib/state/specs/slice.d.ts +49 -0
- package/lib/state/specs/slice.js +70 -0
- package/lib/state/specs/slice.js.map +1 -0
- package/lib/state/store.d.ts +6 -0
- package/lib/state/store.js +60 -2
- package/lib/state/store.js.map +1 -1
- package/lib/test-data/declarations.d.ts +2 -0
- package/lib/test-data/declarations.js +24 -0
- package/lib/test-data/declarations.js.map +1 -0
- package/lib/test-data/examples.d.ts +2 -0
- package/lib/test-data/index.d.ts +3 -0
- package/lib/test-data/index.js +29 -36
- package/lib/test-data/index.js.map +1 -1
- package/lib/test-data/specs.d.ts +10 -0
- package/lib/test-data/specs.js +6 -6
- package/lib/test-data/specs.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 +4 -1
- package/lib/test-utils/redux.js +18 -9
- package/lib/test-utils/redux.js.map +1 -1
- package/lib/utils/adaptorUtils.d.ts +30 -0
- package/lib/utils/adaptorUtils.js +124 -0
- package/lib/utils/adaptorUtils.js.map +1 -0
- package/lib/utils/apixAdaptor.d.ts +15 -0
- package/lib/utils/apixAdaptor.js +67 -0
- package/lib/utils/apixAdaptor.js.map +1 -0
- package/lib/utils/index.d.ts +3 -2
- package/lib/utils/index.js +30 -39
- 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/lib/utils/path.d.ts +3 -0
- package/lib/utils/path.js +32 -2
- package/lib/utils/path.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 +114 -144
- package/src/{index.tsx → App.tsx} +0 -0
- package/src/StandaloneApiExplorer.tsx +38 -61
- package/src/components/Banner/Banner.spec.tsx +99 -0
- package/src/components/Banner/Banner.tsx +87 -0
- package/src/{reducers → components/Banner}/index.ts +1 -1
- package/src/components/DocMarkdown/DocMarkdown.tsx +3 -3
- package/src/components/DocSDKs/DocSDKs.tsx +4 -5
- 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/ExploreType.spec.tsx +0 -23
- package/src/components/ExploreType/ExploreType.tsx +5 -6
- package/src/components/ExploreType/exploreUtils.spec.tsx +1 -1
- package/src/components/Header/Header.spec.tsx +9 -30
- package/src/components/Header/Header.tsx +3 -10
- package/src/components/SelectorContainer/ApiSpecSelector.spec.tsx +31 -44
- package/src/components/SelectorContainer/ApiSpecSelector.tsx +6 -12
- package/src/components/SelectorContainer/SdkLanguageSelector.spec.tsx +3 -5
- package/src/components/SelectorContainer/SdkLanguageSelector.tsx +2 -2
- package/src/components/SelectorContainer/SelectorContainer.spec.tsx +7 -26
- package/src/components/SelectorContainer/SelectorContainer.tsx +4 -10
- package/src/components/SideNav/SideNav.spec.tsx +12 -45
- package/src/components/SideNav/SideNav.tsx +3 -9
- package/src/components/common/Loader.tsx +1 -1
- package/src/components/index.ts +1 -0
- package/src/{reducers/spec/index.ts → index.ts} +4 -2
- package/src/routes/AppRouter.tsx +26 -37
- package/src/scenes/DiffScene/DiffScene.tsx +47 -84
- package/src/scenes/DiffScene/DocDiff/DiffItem.spec.tsx +9 -16
- package/src/scenes/DiffScene/DocDiff/DiffItem.tsx +11 -12
- package/src/scenes/DiffScene/DocDiff/DocDiff.tsx +2 -2
- package/src/scenes/MethodScene/MethodScene.tsx +12 -18
- package/src/state/index.ts +2 -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/{reducers/spec/actions.spec.ts → state/lodes/selectors.ts} +9 -11
- 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/{context/lode → state/specs}/index.ts +2 -1
- package/src/state/specs/sagas.spec.ts +135 -0
- package/src/state/specs/sagas.ts +81 -0
- package/src/{test-utils/envAdaptor.ts → state/specs/selectors.ts} +10 -4
- package/src/state/specs/slice.ts +109 -0
- package/src/state/store.ts +65 -2
- package/src/{context/lode/LodeContext.ts → test-data/declarations.ts} +17 -14
- package/src/test-data/index.ts +2 -8
- package/src/test-data/specs.ts +6 -6
- package/src/test-utils/index.ts +1 -5
- package/src/{reducers/spec/reducer.spec.ts → test-utils/lodes.tsx} +16 -19
- package/src/test-utils/redux.tsx +31 -8
- package/src/utils/adaptorUtils.ts +181 -0
- package/src/utils/apixAdaptor.ts +72 -0
- package/src/utils/index.ts +3 -8
- package/src/utils/lodeUtils.ts +4 -6
- package/src/utils/path.ts +25 -2
- 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/reducers/index.js +0 -2
- package/lib/esm/reducers/index.js.map +0 -1
- package/lib/esm/reducers/spec/actions.js +0 -19
- package/lib/esm/reducers/spec/actions.js.map +0 -1
- package/lib/esm/reducers/spec/index.js +0 -4
- package/lib/esm/reducers/spec/index.js.map +0 -1
- package/lib/esm/reducers/spec/reducer.js +0 -62
- package/lib/esm/reducers/spec/reducer.js.map +0 -1
- package/lib/esm/reducers/spec/utils.js +0 -74
- package/lib/esm/reducers/spec/utils.js.map +0 -1
- package/lib/esm/test-utils/envAdaptor.js +0 -5
- 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/reducers/index.d.ts +0 -1
- package/lib/reducers/index.js +0 -19
- package/lib/reducers/index.js.map +0 -1
- package/lib/reducers/spec/actions.d.ts +0 -20
- package/lib/reducers/spec/actions.js +0 -31
- package/lib/reducers/spec/actions.js.map +0 -1
- package/lib/reducers/spec/index.d.ts +0 -3
- package/lib/reducers/spec/index.js +0 -45
- package/lib/reducers/spec/index.js.map +0 -1
- package/lib/reducers/spec/reducer.d.ts +0 -7
- package/lib/reducers/spec/reducer.js +0 -73
- package/lib/reducers/spec/reducer.js.map +0 -1
- package/lib/reducers/spec/utils.d.ts +0 -7
- package/lib/reducers/spec/utils.js +0 -91
- package/lib/reducers/spec/utils.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/reducers/spec/actions.ts +0 -62
- package/src/reducers/spec/reducer.ts +0 -69
- package/src/reducers/spec/utils.spec.ts +0 -138
- package/src/reducers/spec/utils.ts +0 -123
- package/src/utils/envAdaptor.spec.ts +0 -50
- package/src/utils/envAdaptor.ts +0 -147
package/src/ApiExplorer.tsx
CHANGED
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import type { FC } from 'react'
|
|
28
|
-
import React, {
|
|
29
|
-
import { useLocation } from 'react-router'
|
|
28
|
+
import React, { useState, useEffect, useCallback } from 'react'
|
|
30
29
|
import styled, { createGlobalStyle } from 'styled-components'
|
|
31
30
|
import {
|
|
32
31
|
Aside,
|
|
@@ -38,64 +37,64 @@ import {
|
|
|
38
37
|
Page,
|
|
39
38
|
Space,
|
|
40
39
|
} from '@looker/components'
|
|
41
|
-
import type { SpecList } from '@looker/sdk-codegen'
|
|
42
|
-
import type { RunItSetter } from '@looker/run-it'
|
|
43
|
-
import { funFetch, fallbackFetch, OAuthScene } from '@looker/run-it'
|
|
44
40
|
import { FirstPage } from '@styled-icons/material/FirstPage'
|
|
45
41
|
import { LastPage } from '@styled-icons/material/LastPage'
|
|
46
|
-
|
|
47
|
-
import { LodeContext, defaultLodeContextValue } from './context'
|
|
48
|
-
import type { IApixEnvAdaptor } from './utils'
|
|
49
42
|
import {
|
|
50
|
-
getLoded,
|
|
51
|
-
oAuthPath,
|
|
52
43
|
registerEnvAdaptor,
|
|
53
44
|
unregisterEnvAdaptor,
|
|
54
|
-
} from '
|
|
45
|
+
} from '@looker/extension-utils'
|
|
46
|
+
import { useSelector } from 'react-redux'
|
|
47
|
+
import { useLocation } from 'react-router-dom'
|
|
48
|
+
|
|
49
|
+
import type { IApixAdaptor } from './utils'
|
|
55
50
|
import {
|
|
56
51
|
Header,
|
|
57
52
|
SideNav,
|
|
58
53
|
ErrorBoundary,
|
|
59
|
-
Loader,
|
|
60
54
|
SelectorContainer,
|
|
61
55
|
HEADER_TOGGLE_LABEL,
|
|
56
|
+
Loader,
|
|
57
|
+
Banner,
|
|
62
58
|
} from './components'
|
|
63
|
-
import { specReducer, initDefaultSpecState, updateSpecApi } from './reducers'
|
|
64
59
|
import { AppRouter } from './routes'
|
|
65
60
|
import { apixFilesHost } from './utils/lodeUtils'
|
|
66
|
-
import {
|
|
61
|
+
import {
|
|
62
|
+
useSettingActions,
|
|
63
|
+
useSettingStoreState,
|
|
64
|
+
useLodeActions,
|
|
65
|
+
useLodesStoreState,
|
|
66
|
+
useSpecActions,
|
|
67
|
+
useSpecStoreState,
|
|
68
|
+
selectSpecs,
|
|
69
|
+
selectCurrentSpec,
|
|
70
|
+
} from './state'
|
|
71
|
+
import { getSpecKey, diffPath } from './utils'
|
|
67
72
|
|
|
68
73
|
export interface ApiExplorerProps {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
setVersionsUrl: RunItSetter
|
|
72
|
-
exampleLodeUrl?: string
|
|
74
|
+
adaptor: IApixAdaptor
|
|
75
|
+
examplesLodeUrl?: string
|
|
73
76
|
declarationsLodeUrl?: string
|
|
74
77
|
headless?: boolean
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
const BodyOverride = createGlobalStyle` html { height: 100%; overflow: hidden; } `
|
|
78
81
|
|
|
79
|
-
const ApiExplorer: FC<ApiExplorerProps> = ({
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
setVersionsUrl,
|
|
83
|
-
exampleLodeUrl = 'https://raw.githubusercontent.com/looker-open-source/sdk-codegen/main/examplesIndex.json',
|
|
82
|
+
export const ApiExplorer: FC<ApiExplorerProps> = ({
|
|
83
|
+
adaptor,
|
|
84
|
+
examplesLodeUrl = 'https://raw.githubusercontent.com/looker-open-source/sdk-codegen/main/examplesIndex.json',
|
|
84
85
|
declarationsLodeUrl = `${apixFilesHost}/declarationsIndex.json`,
|
|
85
86
|
headless = false,
|
|
86
87
|
}) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
)
|
|
95
|
-
const { spec } = specState
|
|
96
|
-
|
|
97
|
-
const [lode, setLode] = useState(defaultLodeContextValue)
|
|
88
|
+
useSettingStoreState()
|
|
89
|
+
useLodesStoreState()
|
|
90
|
+
const { working, description } = useSpecStoreState()
|
|
91
|
+
const specs = useSelector(selectSpecs)
|
|
92
|
+
const spec = useSelector(selectCurrentSpec)
|
|
93
|
+
const { initLodesAction } = useLodeActions()
|
|
94
|
+
const { initSettingsAction } = useSettingActions()
|
|
95
|
+
const { initSpecsAction, setCurrentSpecAction } = useSpecActions()
|
|
98
96
|
|
|
97
|
+
const location = useLocation()
|
|
99
98
|
const [hasNavigation, setHasNavigation] = useState(true)
|
|
100
99
|
const toggleNavigation = (target?: boolean) =>
|
|
101
100
|
setHasNavigation(target || !hasNavigation)
|
|
@@ -106,13 +105,24 @@ const ApiExplorer: FC<ApiExplorerProps> = ({
|
|
|
106
105
|
}
|
|
107
106
|
}, [])
|
|
108
107
|
|
|
108
|
+
registerEnvAdaptor(adaptor)
|
|
109
|
+
|
|
109
110
|
useEffect(() => {
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
initSettingsAction()
|
|
112
|
+
initLodesAction({ examplesLodeUrl, declarationsLodeUrl })
|
|
112
113
|
|
|
114
|
+
const specKey = getSpecKey(location)
|
|
115
|
+
initSpecsAction({ specKey })
|
|
113
116
|
return () => unregisterEnvAdaptor()
|
|
114
117
|
}, [])
|
|
115
118
|
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
const maybeSpec = location.pathname?.split('/')[1]
|
|
121
|
+
if (spec && maybeSpec && maybeSpec !== diffPath && maybeSpec !== spec.key) {
|
|
122
|
+
setCurrentSpecAction({ currentSpecKey: maybeSpec })
|
|
123
|
+
}
|
|
124
|
+
}, [location.pathname, spec])
|
|
125
|
+
|
|
116
126
|
useEffect(() => {
|
|
117
127
|
if (headless) {
|
|
118
128
|
window.addEventListener('message', hasNavigationToggle)
|
|
@@ -124,31 +134,12 @@ const ApiExplorer: FC<ApiExplorerProps> = ({
|
|
|
124
134
|
}
|
|
125
135
|
}, [headless, hasNavigationToggle])
|
|
126
136
|
|
|
127
|
-
|
|
128
|
-
const loadSpec = async () => {
|
|
129
|
-
if (!spec.api) {
|
|
130
|
-
try {
|
|
131
|
-
const newSpec = { ...spec }
|
|
132
|
-
const api = await fallbackFetch(newSpec, funFetch)
|
|
133
|
-
if (api) {
|
|
134
|
-
spec.api = api
|
|
135
|
-
specDispatch(updateSpecApi(spec.key, api))
|
|
136
|
-
}
|
|
137
|
-
} catch (error) {
|
|
138
|
-
console.error(error)
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (!oauthReturn) {
|
|
143
|
-
loadSpec()
|
|
144
|
-
}
|
|
145
|
-
}, [spec, location])
|
|
146
|
-
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
getLoded(exampleLodeUrl, declarationsLodeUrl).then((resp) => setLode(resp))
|
|
149
|
-
}, [exampleLodeUrl, declarationsLodeUrl])
|
|
137
|
+
const themeOverrides = adaptor.themeOverrides()
|
|
150
138
|
|
|
151
|
-
|
|
139
|
+
let neededSpec = location.pathname?.split('/')[1]
|
|
140
|
+
if (!neededSpec || neededSpec === diffPath) {
|
|
141
|
+
neededSpec = spec?.key
|
|
142
|
+
}
|
|
152
143
|
|
|
153
144
|
return (
|
|
154
145
|
<>
|
|
@@ -156,91 +147,71 @@ const ApiExplorer: FC<ApiExplorerProps> = ({
|
|
|
156
147
|
loadGoogleFonts={themeOverrides.loadGoogleFonts}
|
|
157
148
|
themeCustomizations={themeOverrides.themeCustomizations}
|
|
158
149
|
>
|
|
159
|
-
{!
|
|
160
|
-
<Loader message=
|
|
150
|
+
{working || !neededSpec || neededSpec !== spec.key ? (
|
|
151
|
+
<Loader message={description} themeOverrides={themeOverrides} />
|
|
161
152
|
) : (
|
|
162
|
-
<ErrorBoundary logError={
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
px={hasNavigation ? 'u5' : '0'}
|
|
185
|
-
justifyContent={
|
|
186
|
-
hasNavigation ? 'space-between' : 'center'
|
|
187
|
-
}
|
|
188
|
-
>
|
|
189
|
-
{hasNavigation && (
|
|
190
|
-
<Heading
|
|
191
|
-
as="h2"
|
|
192
|
-
fontSize="xsmall"
|
|
193
|
-
fontWeight="bold"
|
|
194
|
-
color="text2"
|
|
195
|
-
>
|
|
196
|
-
API DOCUMENTATION
|
|
197
|
-
</Heading>
|
|
198
|
-
)}
|
|
199
|
-
<IconButton
|
|
200
|
-
size="xsmall"
|
|
201
|
-
shape="round"
|
|
202
|
-
icon={hasNavigation ? <FirstPage /> : <LastPage />}
|
|
203
|
-
label={HEADER_TOGGLE_LABEL}
|
|
204
|
-
onClick={() => toggleNavigation()}
|
|
205
|
-
/>
|
|
206
|
-
</Space>
|
|
153
|
+
<ErrorBoundary logError={adaptor.logError.bind(adaptor)}>
|
|
154
|
+
<Banner adaptor={adaptor} specs={specs} />
|
|
155
|
+
<Page style={{ overflow: 'hidden' }}>
|
|
156
|
+
{!headless && (
|
|
157
|
+
<Header spec={spec} toggleNavigation={toggleNavigation} />
|
|
158
|
+
)}
|
|
159
|
+
<Layout hasAside height="100%">
|
|
160
|
+
<AsideBorder
|
|
161
|
+
borderRight
|
|
162
|
+
isOpen={hasNavigation}
|
|
163
|
+
headless={headless}
|
|
164
|
+
>
|
|
165
|
+
{headless && (
|
|
166
|
+
<>
|
|
167
|
+
<Space
|
|
168
|
+
alignItems="center"
|
|
169
|
+
py="u3"
|
|
170
|
+
px={hasNavigation ? 'u5' : '0'}
|
|
171
|
+
justifyContent={
|
|
172
|
+
hasNavigation ? 'space-between' : 'center'
|
|
173
|
+
}
|
|
174
|
+
>
|
|
207
175
|
{hasNavigation && (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
/>
|
|
217
|
-
</>
|
|
176
|
+
<Heading
|
|
177
|
+
as="h2"
|
|
178
|
+
fontSize="xsmall"
|
|
179
|
+
fontWeight="bold"
|
|
180
|
+
color="text2"
|
|
181
|
+
>
|
|
182
|
+
API DOCUMENTATION
|
|
183
|
+
</Heading>
|
|
218
184
|
)}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
setVersionsUrl={setVersionsUrl}
|
|
239
|
-
/>
|
|
185
|
+
<IconButton
|
|
186
|
+
size="xsmall"
|
|
187
|
+
shape="round"
|
|
188
|
+
icon={hasNavigation ? <FirstPage /> : <LastPage />}
|
|
189
|
+
label={HEADER_TOGGLE_LABEL}
|
|
190
|
+
onClick={() => toggleNavigation()}
|
|
191
|
+
/>
|
|
192
|
+
</Space>
|
|
193
|
+
{hasNavigation && (
|
|
194
|
+
<>
|
|
195
|
+
<Divider mb="u3" appearance="light" />
|
|
196
|
+
<SelectorContainer
|
|
197
|
+
spec={spec}
|
|
198
|
+
ml="large"
|
|
199
|
+
mr="large"
|
|
200
|
+
/>
|
|
201
|
+
</>
|
|
202
|
+
)}
|
|
203
|
+
</>
|
|
240
204
|
)}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
205
|
+
{hasNavigation && <SideNav headless={headless} spec={spec} />}
|
|
206
|
+
</AsideBorder>
|
|
207
|
+
<AppRouter
|
|
208
|
+
specKey={spec.key}
|
|
209
|
+
api={spec.api!}
|
|
210
|
+
specs={specs}
|
|
211
|
+
toggleNavigation={toggleNavigation}
|
|
212
|
+
/>
|
|
213
|
+
</Layout>
|
|
214
|
+
</Page>
|
|
244
215
|
</ErrorBoundary>
|
|
245
216
|
)}
|
|
246
217
|
</ComponentsProvider>
|
|
@@ -249,11 +220,10 @@ const ApiExplorer: FC<ApiExplorerProps> = ({
|
|
|
249
220
|
)
|
|
250
221
|
}
|
|
251
222
|
|
|
252
|
-
|
|
223
|
+
const AsideBorder = styled(Aside)<{
|
|
253
224
|
isOpen: boolean
|
|
254
225
|
headless: boolean
|
|
255
226
|
}>`
|
|
256
227
|
width: ${({ isOpen, headless }) =>
|
|
257
228
|
isOpen ? '20rem' : headless ? '2.75rem' : '0rem'};
|
|
258
229
|
`
|
|
259
|
-
export default ApiExplorer
|
|
File without changes
|
|
@@ -26,21 +26,15 @@
|
|
|
26
26
|
|
|
27
27
|
import type { FC } from 'react'
|
|
28
28
|
import React, { useEffect, useState } from 'react'
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
initRunItSdk,
|
|
33
|
-
loadSpecsFromVersions,
|
|
34
|
-
RunItConfigKey,
|
|
35
|
-
RunItNoConfig,
|
|
36
|
-
} from '@looker/run-it'
|
|
37
|
-
import type { IAPIMethods } from '@looker/sdk-rtl'
|
|
38
|
-
import type { SpecList } from '@looker/sdk-codegen'
|
|
29
|
+
import { initRunItSdk, RunItProvider } from '@looker/run-it'
|
|
30
|
+
import type { OAuthConfigProvider } from '@looker/extension-utils'
|
|
31
|
+
import { OAuthScene } from '@looker/extension-utils'
|
|
39
32
|
import { Provider } from 'react-redux'
|
|
33
|
+
import { useLocation } from 'react-router'
|
|
40
34
|
|
|
41
|
-
import ApiExplorer from './ApiExplorer'
|
|
35
|
+
import { ApiExplorer } from './ApiExplorer'
|
|
42
36
|
import { store } from './state'
|
|
43
|
-
import {
|
|
37
|
+
import { oAuthPath, ApixAdaptor } from './utils'
|
|
44
38
|
import { Loader } from './components'
|
|
45
39
|
|
|
46
40
|
export interface StandaloneApiExplorerProps {
|
|
@@ -48,65 +42,48 @@ export interface StandaloneApiExplorerProps {
|
|
|
48
42
|
versionsUrl: string
|
|
49
43
|
}
|
|
50
44
|
|
|
51
|
-
const standaloneEnvAdaptor = new StandaloneEnvAdaptor()
|
|
52
|
-
|
|
53
|
-
const loadVersions = async (current: string) => {
|
|
54
|
-
const data = await standaloneEnvAdaptor.localStorageGetItem(RunItConfigKey)
|
|
55
|
-
const config = data ? JSON.parse(data) : RunItNoConfig
|
|
56
|
-
let url = config.base_url ? `${config.base_url}/versions` : current
|
|
57
|
-
let response = await loadSpecsFromVersions(url)
|
|
58
|
-
if (response.fetchResult) {
|
|
59
|
-
console.error(
|
|
60
|
-
`Reverting to ${current} due to ${url} error: ${response.fetchResult}`
|
|
61
|
-
)
|
|
62
|
-
// The stored server location has an error so default to current
|
|
63
|
-
url = current
|
|
64
|
-
response = await loadSpecsFromVersions(url)
|
|
65
|
-
}
|
|
66
|
-
return { url, response }
|
|
67
|
-
}
|
|
68
|
-
|
|
69
45
|
export const StandaloneApiExplorer: FC<StandaloneApiExplorerProps> = ({
|
|
70
46
|
headless = false,
|
|
71
|
-
versionsUrl = '',
|
|
72
47
|
}) => {
|
|
73
|
-
const [
|
|
74
|
-
|
|
75
|
-
|
|
48
|
+
const [browserAdaptor] = useState(
|
|
49
|
+
new ApixAdaptor(initRunItSdk(), window.origin)
|
|
50
|
+
)
|
|
51
|
+
const location = useLocation()
|
|
52
|
+
const oauthReturn = location.pathname === `/${oAuthPath}`
|
|
53
|
+
const sdk = browserAdaptor.sdk
|
|
54
|
+
const canLogin =
|
|
55
|
+
(sdk.authSession.settings as OAuthConfigProvider).authIsConfigured() &&
|
|
56
|
+
!sdk.authSession.isAuthenticated() &&
|
|
57
|
+
!oauthReturn
|
|
76
58
|
|
|
77
59
|
useEffect(() => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const response = result.response
|
|
82
|
-
setSpecs(response.specs)
|
|
83
|
-
})
|
|
84
|
-
} else {
|
|
85
|
-
setSpecs(undefined)
|
|
60
|
+
const login = async () => await browserAdaptor.login()
|
|
61
|
+
if (canLogin) {
|
|
62
|
+
login()
|
|
86
63
|
}
|
|
87
|
-
}, [
|
|
64
|
+
}, [])
|
|
88
65
|
|
|
89
|
-
const
|
|
66
|
+
const { looker_url } = (
|
|
67
|
+
sdk.authSession.settings as OAuthConfigProvider
|
|
68
|
+
).getStoredConfig()
|
|
90
69
|
|
|
91
70
|
return (
|
|
92
71
|
<Provider store={store}>
|
|
93
|
-
<RunItProvider
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
)}
|
|
109
|
-
</>
|
|
72
|
+
<RunItProvider basePath="/api/4.0">
|
|
73
|
+
{canLogin ? (
|
|
74
|
+
<Loader
|
|
75
|
+
themeOverrides={browserAdaptor.themeOverrides()}
|
|
76
|
+
message={`Configuration found. Logging into ${looker_url}`}
|
|
77
|
+
/>
|
|
78
|
+
) : (
|
|
79
|
+
<>
|
|
80
|
+
{oauthReturn ? (
|
|
81
|
+
<OAuthScene adaptor={browserAdaptor} />
|
|
82
|
+
) : (
|
|
83
|
+
<ApiExplorer adaptor={browserAdaptor} headless={headless} />
|
|
84
|
+
)}
|
|
85
|
+
</>
|
|
86
|
+
)}
|
|
110
87
|
</RunItProvider>
|
|
111
88
|
</Provider>
|
|
112
89
|
)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2021 Looker Data Sciences, Inc.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
24
|
+
|
|
25
|
+
*/
|
|
26
|
+
import React from 'react'
|
|
27
|
+
import { renderWithTheme } from '@looker/components-test-utils'
|
|
28
|
+
import { screen, fireEvent, waitFor } from '@testing-library/react'
|
|
29
|
+
import type { IEnvironmentAdaptor } from '@looker/extension-utils'
|
|
30
|
+
import type { SpecList } from '@looker/sdk-codegen'
|
|
31
|
+
import { Banner } from './Banner'
|
|
32
|
+
|
|
33
|
+
describe('Banner', () => {
|
|
34
|
+
const specs: any = {
|
|
35
|
+
'3.1': {
|
|
36
|
+
status: 'current',
|
|
37
|
+
},
|
|
38
|
+
'4.0': {
|
|
39
|
+
status: 'beta',
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
test('renders with button that opens api 4.0 dev portal link in new page', async () => {
|
|
44
|
+
const adaptor: any = {
|
|
45
|
+
localStorageGetItem: jest.fn().mockReturnValue(Promise.resolve(null)),
|
|
46
|
+
isExtension: jest.fn().mockReturnValue(true),
|
|
47
|
+
}
|
|
48
|
+
renderWithTheme(
|
|
49
|
+
<Banner
|
|
50
|
+
adaptor={adaptor as IEnvironmentAdaptor}
|
|
51
|
+
specs={specs as SpecList}
|
|
52
|
+
/>
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
await waitFor(() => {
|
|
56
|
+
expect(
|
|
57
|
+
screen.getByText('API 4.0 moves from Beta', { exact: false })
|
|
58
|
+
).toBeInTheDocument()
|
|
59
|
+
const link = screen.getByText('Announcement').closest('a')
|
|
60
|
+
expect(link).toHaveAttribute(
|
|
61
|
+
'href',
|
|
62
|
+
'https://developers.looker.com/api/advanced-usage/version-4-ga'
|
|
63
|
+
)
|
|
64
|
+
expect(link).toHaveAttribute('target', '_blank')
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('sets local storage value and unrenders on close button click', async () => {
|
|
69
|
+
const adaptor: any = {
|
|
70
|
+
localStorageGetItem: jest.fn().mockReturnValue(Promise.resolve(null)),
|
|
71
|
+
localStorageSetItem: jest.fn(),
|
|
72
|
+
isExtension: jest.fn().mockReturnValue(true),
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
renderWithTheme(
|
|
76
|
+
<Banner
|
|
77
|
+
adaptor={adaptor as IEnvironmentAdaptor}
|
|
78
|
+
specs={specs as SpecList}
|
|
79
|
+
/>
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
await waitFor(() => {
|
|
83
|
+
expect(
|
|
84
|
+
screen.getByText('API 4.0 moves from Beta', { exact: false })
|
|
85
|
+
).toBeInTheDocument()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const closeButton = screen.getByText('Dismiss Inform').closest('button')
|
|
89
|
+
fireEvent.click(closeButton as HTMLButtonElement)
|
|
90
|
+
|
|
91
|
+
expect(
|
|
92
|
+
screen.queryByText('API 4.0 moves from Beta', { exact: false })
|
|
93
|
+
).not.toBeInTheDocument()
|
|
94
|
+
expect(adaptor.localStorageSetItem).toHaveBeenCalledWith(
|
|
95
|
+
'api-40-ga-apix-banner',
|
|
96
|
+
'dismissed'
|
|
97
|
+
)
|
|
98
|
+
})
|
|
99
|
+
})
|
|
@@ -0,0 +1,87 @@
|
|
|
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 { ButtonOutline, Link, MessageBar } from '@looker/components'
|
|
27
|
+
import type { IEnvironmentAdaptor } from '@looker/extension-utils'
|
|
28
|
+
import type { SpecList } from '@looker/sdk-codegen'
|
|
29
|
+
import type { FC } from 'react'
|
|
30
|
+
import React, { useState, useEffect } from 'react'
|
|
31
|
+
|
|
32
|
+
const LOCAL_STORAGE_KEY = 'api-40-ga-apix-banner'
|
|
33
|
+
const LOCAL_STORAGE_VALUE = 'dismissed'
|
|
34
|
+
|
|
35
|
+
export interface BannerProps {
|
|
36
|
+
adaptor: IEnvironmentAdaptor
|
|
37
|
+
specs: SpecList
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Banner: FC<BannerProps> = ({ adaptor, specs }) => {
|
|
41
|
+
const [isOpen, setOpen] = useState(false)
|
|
42
|
+
useEffect(onLoad, [])
|
|
43
|
+
|
|
44
|
+
if (isOpen) {
|
|
45
|
+
return (
|
|
46
|
+
<MessageBar
|
|
47
|
+
intent="inform"
|
|
48
|
+
onPrimaryClick={onClose}
|
|
49
|
+
secondaryAction={
|
|
50
|
+
<Link
|
|
51
|
+
href="https://developers.looker.com/api/advanced-usage/version-4-ga"
|
|
52
|
+
target="_blank"
|
|
53
|
+
>
|
|
54
|
+
<ButtonOutline size="small">Announcement</ButtonOutline>
|
|
55
|
+
</Link>
|
|
56
|
+
}
|
|
57
|
+
>
|
|
58
|
+
API 4.0 moves from Beta to General Availability in Looker 22.4 with
|
|
59
|
+
additions and possible breaking changes. Read the announcement to see
|
|
60
|
+
how this affects you.
|
|
61
|
+
</MessageBar>
|
|
62
|
+
)
|
|
63
|
+
} else {
|
|
64
|
+
return null
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function onLoad() {
|
|
68
|
+
// Following best practice with inner async function
|
|
69
|
+
// https://github.com/facebook/react/issues/14326
|
|
70
|
+
async function innerOnLoad() {
|
|
71
|
+
// 4.0 is stable in Looker 22.4+. 4.0 is default or `current` in 22.4+.
|
|
72
|
+
// Still check for `stable` just in case new version comes along.
|
|
73
|
+
const is40Stable =
|
|
74
|
+
specs['4.0'].status === 'stable' || specs['4.0'].status === 'current'
|
|
75
|
+
const wasDismissed =
|
|
76
|
+
(await adaptor.localStorageGetItem(LOCAL_STORAGE_KEY)) ===
|
|
77
|
+
LOCAL_STORAGE_VALUE
|
|
78
|
+
setOpen(!is40Stable && !wasDismissed && adaptor.isExtension())
|
|
79
|
+
}
|
|
80
|
+
innerOnLoad()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function onClose() {
|
|
84
|
+
adaptor.localStorageSetItem(LOCAL_STORAGE_KEY, LOCAL_STORAGE_VALUE)
|
|
85
|
+
setOpen(false)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -29,7 +29,7 @@ import React from 'react'
|
|
|
29
29
|
import { useHistory } from 'react-router-dom'
|
|
30
30
|
import { Markdown } from '@looker/code-editor'
|
|
31
31
|
import { useSelector } from 'react-redux'
|
|
32
|
-
import { getEnvAdaptor } from '
|
|
32
|
+
import { getEnvAdaptor } from '@looker/extension-utils'
|
|
33
33
|
import { selectSearchPattern } from '../../state'
|
|
34
34
|
import { transformURL } from './utils'
|
|
35
35
|
|
|
@@ -48,8 +48,8 @@ export const DocMarkdown: FC<DocMarkdownProps> = ({ source, specKey }) => {
|
|
|
48
48
|
} else if (url.startsWith(`/${specKey}`)) {
|
|
49
49
|
history.push(url)
|
|
50
50
|
} else if (url.startsWith('https://')) {
|
|
51
|
-
const
|
|
52
|
-
|
|
51
|
+
const adaptor = getEnvAdaptor()
|
|
52
|
+
adaptor.openBrowserWindow(url)
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
return (
|