@looker/api-explorer 0.9.36 → 0.9.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/dist/bundle.js +1 -1
  3. package/dist/bundle.js.map +1 -1
  4. package/e2e/MethodScene.spec.ts +80 -0
  5. package/e2e/diffScene.spec.ts +28 -20
  6. package/e2e/e2e.spec.ts +45 -7
  7. package/lib/ApiExplorer.js +17 -6
  8. package/lib/ApiExplorer.js.map +1 -1
  9. package/lib/components/DocMarkdown/DocMarkdown.js +3 -1
  10. package/lib/components/DocMarkdown/DocMarkdown.js.map +1 -1
  11. package/lib/components/DocSDKs/DocDeclarations.js +10 -15
  12. package/lib/components/DocSDKs/DocDeclarations.js.map +1 -1
  13. package/lib/components/SelectorContainer/ApiSpecSelector.js +3 -1
  14. package/lib/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
  15. package/lib/components/SelectorContainer/SdkLanguageSelector.js +20 -21
  16. package/lib/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
  17. package/lib/components/SelectorContainer/SelectorContainer.js +4 -1
  18. package/lib/components/SelectorContainer/SelectorContainer.js.map +1 -1
  19. package/lib/components/SelectorContainer/utils.d.ts +2 -0
  20. package/lib/components/SelectorContainer/utils.js +32 -0
  21. package/lib/components/SelectorContainer/utils.js.map +1 -0
  22. package/lib/components/SideNav/SideNav.js +20 -9
  23. package/lib/components/SideNav/SideNav.js.map +1 -1
  24. package/lib/components/SideNav/SideNavMethods.js +7 -6
  25. package/lib/components/SideNav/SideNavMethods.js.map +1 -1
  26. package/lib/components/SideNav/SideNavTypes.js +5 -4
  27. package/lib/components/SideNav/SideNavTypes.js.map +1 -1
  28. package/lib/components/index.d.ts +0 -1
  29. package/lib/components/index.js +0 -8
  30. package/lib/components/index.js.map +1 -1
  31. package/lib/esm/ApiExplorer.js +19 -8
  32. package/lib/esm/ApiExplorer.js.map +1 -1
  33. package/lib/esm/components/DocMarkdown/DocMarkdown.js +3 -1
  34. package/lib/esm/components/DocMarkdown/DocMarkdown.js.map +1 -1
  35. package/lib/esm/components/DocSDKs/DocDeclarations.js +9 -14
  36. package/lib/esm/components/DocSDKs/DocDeclarations.js.map +1 -1
  37. package/lib/esm/components/SelectorContainer/ApiSpecSelector.js +3 -1
  38. package/lib/esm/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
  39. package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js +16 -18
  40. package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
  41. package/lib/esm/components/SelectorContainer/SelectorContainer.js +5 -2
  42. package/lib/esm/components/SelectorContainer/SelectorContainer.js.map +1 -1
  43. package/lib/esm/components/SelectorContainer/utils.js +22 -0
  44. package/lib/esm/components/SelectorContainer/utils.js.map +1 -0
  45. package/lib/esm/components/SideNav/SideNav.js +20 -10
  46. package/lib/esm/components/SideNav/SideNav.js.map +1 -1
  47. package/lib/esm/components/SideNav/SideNavMethods.js +8 -7
  48. package/lib/esm/components/SideNav/SideNavMethods.js.map +1 -1
  49. package/lib/esm/components/SideNav/SideNavTypes.js +6 -5
  50. package/lib/esm/components/SideNav/SideNavTypes.js.map +1 -1
  51. package/lib/esm/components/index.js +0 -1
  52. package/lib/esm/components/index.js.map +1 -1
  53. package/lib/esm/routes/AppRouter.js +6 -4
  54. package/lib/esm/routes/AppRouter.js.map +1 -1
  55. package/lib/esm/scenes/DiffScene/DiffScene.js +9 -7
  56. package/lib/esm/scenes/DiffScene/DiffScene.js.map +1 -1
  57. package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js +3 -1
  58. package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
  59. package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js +4 -4
  60. package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
  61. package/lib/esm/scenes/ErrorDetailScene/ErrorDetailScene.js +31 -0
  62. package/lib/esm/scenes/ErrorDetailScene/ErrorDetailScene.js.map +1 -0
  63. package/lib/esm/scenes/ErrorDetailScene/index.js +2 -0
  64. package/lib/esm/scenes/ErrorDetailScene/index.js.map +1 -0
  65. package/lib/esm/scenes/MethodScene/MethodScene.js +28 -9
  66. package/lib/esm/scenes/MethodScene/MethodScene.js.map +1 -1
  67. package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.js +1 -1
  68. package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponseTypes.js.map +1 -0
  69. package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponses.js +73 -0
  70. package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponses.js.map +1 -0
  71. package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/index.js +0 -0
  72. package/lib/esm/scenes/MethodScene/components/DocResponses/index.js.map +1 -0
  73. package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/utils.js +0 -0
  74. package/lib/esm/scenes/MethodScene/components/DocResponses/utils.js.map +1 -0
  75. package/lib/esm/scenes/MethodScene/components/index.js +1 -0
  76. package/lib/esm/scenes/MethodScene/components/index.js.map +1 -1
  77. package/lib/esm/scenes/MethodTagScene/MethodTagScene.js +38 -11
  78. package/lib/esm/scenes/MethodTagScene/MethodTagScene.js.map +1 -1
  79. package/lib/esm/scenes/TypeScene/TypeScene.js +3 -1
  80. package/lib/esm/scenes/TypeScene/TypeScene.js.map +1 -1
  81. package/lib/esm/scenes/TypeTagScene/TypeTagScene.js +37 -10
  82. package/lib/esm/scenes/TypeTagScene/TypeTagScene.js.map +1 -1
  83. package/lib/esm/scenes/index.js +1 -0
  84. package/lib/esm/scenes/index.js.map +1 -1
  85. package/lib/esm/scenes/utils/hooks/index.js +2 -0
  86. package/lib/esm/scenes/utils/hooks/index.js.map +1 -0
  87. package/lib/esm/scenes/utils/hooks/tagStoreSync.js +37 -0
  88. package/lib/esm/scenes/utils/hooks/tagStoreSync.js.map +1 -0
  89. package/lib/esm/scenes/utils/index.js +2 -0
  90. package/lib/esm/scenes/utils/index.js.map +1 -0
  91. package/lib/esm/state/settings/selectors.js +1 -0
  92. package/lib/esm/state/settings/selectors.js.map +1 -1
  93. package/lib/esm/state/settings/slice.js +6 -1
  94. package/lib/esm/state/settings/slice.js.map +1 -1
  95. package/lib/esm/utils/hooks/globalStoreSync.js +53 -0
  96. package/lib/esm/utils/hooks/globalStoreSync.js.map +1 -0
  97. package/lib/esm/utils/hooks/index.js +4 -0
  98. package/lib/esm/utils/hooks/index.js.map +1 -0
  99. package/lib/esm/utils/hooks/navigation.js +72 -0
  100. package/lib/esm/utils/hooks/navigation.js.map +1 -0
  101. package/lib/esm/utils/hooks/useQuery.js +9 -0
  102. package/lib/esm/utils/hooks/useQuery.js.map +1 -0
  103. package/lib/esm/utils/index.js +2 -1
  104. package/lib/esm/utils/index.js.map +1 -1
  105. package/lib/esm/utils/path.js +21 -0
  106. package/lib/esm/utils/path.js.map +1 -1
  107. package/lib/esm/utils/sdkLanguage.js +42 -0
  108. package/lib/esm/utils/sdkLanguage.js.map +1 -0
  109. package/lib/routes/AppRouter.d.ts +1 -2
  110. package/lib/routes/AppRouter.js +5 -3
  111. package/lib/routes/AppRouter.js.map +1 -1
  112. package/lib/scenes/DiffScene/DiffScene.d.ts +0 -2
  113. package/lib/scenes/DiffScene/DiffScene.js +8 -6
  114. package/lib/scenes/DiffScene/DiffScene.js.map +1 -1
  115. package/lib/scenes/DiffScene/DocDiff/DiffItem.js +3 -1
  116. package/lib/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
  117. package/lib/scenes/DiffScene/DocDiff/DocDiff.js +4 -4
  118. package/lib/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
  119. package/lib/scenes/ErrorDetailScene/ErrorDetailScene.d.ts +7 -0
  120. package/lib/scenes/ErrorDetailScene/ErrorDetailScene.js +47 -0
  121. package/lib/scenes/ErrorDetailScene/ErrorDetailScene.js.map +1 -0
  122. package/lib/scenes/ErrorDetailScene/index.d.ts +1 -0
  123. package/lib/scenes/ErrorDetailScene/index.js +14 -0
  124. package/lib/{components/DocResponses → scenes/ErrorDetailScene}/index.js.map +1 -1
  125. package/lib/scenes/MethodScene/MethodScene.js +23 -4
  126. package/lib/scenes/MethodScene/MethodScene.js.map +1 -1
  127. package/lib/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.d.ts +2 -2
  128. package/lib/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.js +2 -2
  129. package/lib/scenes/MethodScene/components/DocResponses/DocResponseTypes.js.map +1 -0
  130. package/lib/scenes/MethodScene/components/DocResponses/DocResponses.d.ts +9 -0
  131. package/lib/scenes/MethodScene/components/DocResponses/DocResponses.js +93 -0
  132. package/lib/scenes/MethodScene/components/DocResponses/DocResponses.js.map +1 -0
  133. package/lib/{components → scenes/MethodScene/components}/DocResponses/index.d.ts +0 -0
  134. package/lib/{components → scenes/MethodScene/components}/DocResponses/index.js +0 -0
  135. package/lib/scenes/MethodScene/components/DocResponses/index.js.map +1 -0
  136. package/lib/{components → scenes/MethodScene/components}/DocResponses/utils.d.ts +0 -0
  137. package/lib/{components → scenes/MethodScene/components}/DocResponses/utils.js +0 -0
  138. package/lib/scenes/MethodScene/components/DocResponses/utils.js.map +1 -0
  139. package/lib/scenes/MethodScene/components/index.d.ts +1 -0
  140. package/lib/scenes/MethodScene/components/index.js +8 -0
  141. package/lib/scenes/MethodScene/components/index.js.map +1 -1
  142. package/lib/scenes/MethodTagScene/MethodTagScene.js +42 -12
  143. package/lib/scenes/MethodTagScene/MethodTagScene.js.map +1 -1
  144. package/lib/scenes/TypeScene/TypeScene.js +3 -1
  145. package/lib/scenes/TypeScene/TypeScene.js.map +1 -1
  146. package/lib/scenes/TypeTagScene/TypeTagScene.js +41 -11
  147. package/lib/scenes/TypeTagScene/TypeTagScene.js.map +1 -1
  148. package/lib/scenes/index.d.ts +1 -0
  149. package/lib/scenes/index.js +8 -0
  150. package/lib/scenes/index.js.map +1 -1
  151. package/lib/scenes/utils/hooks/index.d.ts +1 -0
  152. package/lib/scenes/utils/hooks/index.js +14 -0
  153. package/lib/scenes/utils/hooks/index.js.map +1 -0
  154. package/lib/scenes/utils/hooks/tagStoreSync.d.ts +1 -0
  155. package/lib/scenes/utils/hooks/tagStoreSync.js +51 -0
  156. package/lib/scenes/utils/hooks/tagStoreSync.js.map +1 -0
  157. package/lib/scenes/utils/index.d.ts +1 -0
  158. package/lib/scenes/utils/index.js +14 -0
  159. package/lib/scenes/utils/index.js.map +1 -0
  160. package/lib/state/settings/selectors.d.ts +2 -1
  161. package/lib/state/settings/selectors.js +5 -1
  162. package/lib/state/settings/selectors.js.map +1 -1
  163. package/lib/state/settings/slice.d.ts +7 -1
  164. package/lib/state/settings/slice.js +6 -1
  165. package/lib/state/settings/slice.js.map +1 -1
  166. package/lib/test-data/index.d.ts +1 -0
  167. package/lib/test-data/index.js +14 -0
  168. package/lib/test-data/index.js.map +1 -1
  169. package/lib/test-data/sdkLanguages.d.ts +10 -0
  170. package/lib/test-data/sdkLanguages.js +19 -0
  171. package/lib/test-data/sdkLanguages.js.map +1 -0
  172. package/lib/utils/hooks/globalStoreSync.d.ts +1 -0
  173. package/lib/utils/hooks/globalStoreSync.js +67 -0
  174. package/lib/utils/hooks/globalStoreSync.js.map +1 -0
  175. package/lib/utils/hooks/index.d.ts +3 -0
  176. package/lib/utils/hooks/index.js +30 -0
  177. package/lib/utils/hooks/index.js.map +1 -0
  178. package/lib/utils/hooks/navigation.d.ts +11 -0
  179. package/lib/utils/hooks/navigation.js +83 -0
  180. package/lib/utils/hooks/navigation.js.map +1 -0
  181. package/lib/utils/hooks/useQuery.d.ts +1 -0
  182. package/lib/utils/hooks/useQuery.js +20 -0
  183. package/lib/utils/hooks/useQuery.js.map +1 -0
  184. package/lib/utils/index.d.ts +2 -1
  185. package/lib/utils/index.js +29 -1
  186. package/lib/utils/index.js.map +1 -1
  187. package/lib/utils/path.d.ts +4 -0
  188. package/lib/utils/path.js +32 -1
  189. package/lib/utils/path.js.map +1 -1
  190. package/lib/utils/sdkLanguage.d.ts +6 -0
  191. package/lib/utils/sdkLanguage.js +59 -0
  192. package/lib/utils/sdkLanguage.js.map +1 -0
  193. package/package.json +14 -14
  194. package/src/ApiExplorer.tsx +13 -8
  195. package/src/components/DocMarkdown/DocMarkdown.tsx +1 -1
  196. package/src/components/DocSDKs/DocDeclarations.tsx +11 -22
  197. package/src/components/DocSDKs/DocSDKs.spec.tsx +4 -1
  198. package/src/components/Header/Header.spec.tsx +1 -1
  199. package/src/components/SelectorContainer/ApiSpecSelector.tsx +1 -1
  200. package/src/components/SelectorContainer/SdkLanguageSelector.spec.tsx +60 -33
  201. package/src/components/SelectorContainer/SdkLanguageSelector.tsx +15 -22
  202. package/src/components/SelectorContainer/SelectorContainer.spec.tsx +1 -1
  203. package/src/components/SelectorContainer/SelectorContainer.tsx +18 -15
  204. package/src/{utils/hooks.ts → components/SelectorContainer/utils.ts} +13 -21
  205. package/src/components/SideNav/SideNav.tsx +26 -14
  206. package/src/components/SideNav/SideNavMethods.spec.tsx +6 -8
  207. package/src/components/SideNav/SideNavMethods.tsx +8 -12
  208. package/src/components/SideNav/SideNavTypes.tsx +5 -10
  209. package/src/components/index.ts +0 -1
  210. package/src/routes/AppRouter.tsx +7 -5
  211. package/src/scenes/DiffScene/DiffScene.tsx +8 -8
  212. package/src/scenes/DiffScene/DocDiff/DiffItem.tsx +1 -1
  213. package/src/scenes/DiffScene/DocDiff/DocDiff.spec.tsx +73 -2
  214. package/src/scenes/DiffScene/DocDiff/DocDiff.tsx +4 -4
  215. package/src/scenes/ErrorDetailScene/ErrorDetailScene.tsx +72 -0
  216. package/src/scenes/ErrorDetailScene/index.ts +26 -0
  217. package/src/scenes/MethodScene/MethodScene.tsx +21 -7
  218. package/src/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.tsx +3 -6
  219. package/src/scenes/MethodScene/components/DocResponses/DocResponses.spec.tsx +153 -0
  220. package/src/scenes/MethodScene/components/DocResponses/DocResponses.tsx +103 -0
  221. package/src/{components → scenes/MethodScene/components}/DocResponses/index.ts +0 -0
  222. package/src/{components → scenes/MethodScene/components}/DocResponses/utils.spec.ts +1 -1
  223. package/src/{components → scenes/MethodScene/components}/DocResponses/utils.ts +0 -0
  224. package/src/scenes/MethodScene/components/index.ts +1 -0
  225. package/src/scenes/MethodTagScene/MethodTagScene.spec.tsx +25 -14
  226. package/src/scenes/MethodTagScene/MethodTagScene.tsx +42 -11
  227. package/src/scenes/TypeScene/TypeScene.tsx +1 -1
  228. package/src/scenes/TypeTagScene/TypeTagScene.spec.tsx +21 -11
  229. package/src/scenes/TypeTagScene/TypeTagScene.tsx +44 -11
  230. package/src/scenes/index.ts +1 -0
  231. package/src/scenes/utils/hooks/index.ts +27 -0
  232. package/src/scenes/utils/hooks/tagStoreSync.spec.ts +102 -0
  233. package/src/scenes/utils/hooks/tagStoreSync.ts +68 -0
  234. package/src/scenes/utils/index.ts +27 -0
  235. package/src/state/settings/selectors.spec.ts +5 -1
  236. package/src/state/settings/selectors.ts +3 -0
  237. package/src/state/settings/slice.ts +6 -0
  238. package/src/test-data/index.ts +1 -0
  239. package/src/test-data/sdkLanguages.ts +36 -0
  240. package/src/utils/hooks/globalStoreSync.spec.tsx +146 -0
  241. package/src/utils/hooks/globalStoreSync.ts +77 -0
  242. package/src/utils/hooks/index.ts +28 -0
  243. package/src/utils/hooks/navigation.spec.ts +118 -0
  244. package/src/utils/hooks/navigation.ts +121 -0
  245. package/src/utils/hooks/useQuery.ts +36 -0
  246. package/src/utils/index.ts +2 -1
  247. package/src/utils/path.spec.ts +67 -1
  248. package/src/utils/path.ts +35 -0
  249. package/src/utils/sdkLanguage.spec.ts +69 -0
  250. package/src/utils/sdkLanguage.ts +63 -0
  251. package/lib/components/DocResponses/DocResponseTypes.js.map +0 -1
  252. package/lib/components/DocResponses/DocResponses.d.ts +0 -8
  253. package/lib/components/DocResponses/DocResponses.js +0 -46
  254. package/lib/components/DocResponses/DocResponses.js.map +0 -1
  255. package/lib/components/DocResponses/utils.js.map +0 -1
  256. package/lib/esm/components/DocResponses/DocResponseTypes.js.map +0 -1
  257. package/lib/esm/components/DocResponses/DocResponses.js +0 -30
  258. package/lib/esm/components/DocResponses/DocResponses.js.map +0 -1
  259. package/lib/esm/components/DocResponses/index.js.map +0 -1
  260. package/lib/esm/components/DocResponses/utils.js.map +0 -1
  261. package/lib/esm/utils/hooks.js +0 -26
  262. package/lib/esm/utils/hooks.js.map +0 -1
  263. package/lib/utils/hooks.d.ts +0 -3
  264. package/lib/utils/hooks.js +0 -36
  265. package/lib/utils/hooks.js.map +0 -1
  266. package/src/components/DocResponses/DocResponses.spec.tsx +0 -60
  267. package/src/components/DocResponses/DocResponses.tsx +0 -69
  268. package/src/utils/hooks.spec.ts +0 -78
@@ -0,0 +1,121 @@
1
+ /*
2
+
3
+ MIT License
4
+
5
+ Copyright (c) 2022 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 { useHistory } from 'react-router-dom'
27
+
28
+ const GLOBAL_PARAMS = ['s', 'sdk']
29
+
30
+ interface QueryParamProps {
31
+ /** Search Query **/
32
+ s?: string | null
33
+ /** Chosen SDK Language **/
34
+ sdk?: string | null
35
+ /** Tag Scene Filter **/
36
+ t?: string | null
37
+ }
38
+
39
+ /**
40
+ * Hook for navigating to given route with query params
41
+ */
42
+ export const useNavigation = () => {
43
+ const history = useHistory()
44
+
45
+ /**
46
+ * Navigates to path including provided search parameters
47
+ *
48
+ * @param path Pathname to navigate to
49
+ * @param queryParams Hash of query param name/value pairs to include in the destination url
50
+ */
51
+ const navigate = (path: string, queryParams?: QueryParamProps | null) => {
52
+ const urlParams = new URLSearchParams(history.location.search)
53
+
54
+ if (queryParams === undefined) {
55
+ // if params passed in is undefined, maintain existing parameters in the URL
56
+ history.push({ pathname: path, search: urlParams.toString() })
57
+ } else if (queryParams === null) {
58
+ // if params passed in is null, remove all parameters from the URL
59
+ history.push({ pathname: path })
60
+ } else {
61
+ // push each key as new param to URL, excluding entries with value null
62
+ Object.keys(queryParams).forEach((key) => {
63
+ if (queryParams[key] === null || queryParams[key] === '') {
64
+ urlParams.delete(key)
65
+ } else {
66
+ urlParams.set(key, queryParams[key])
67
+ }
68
+ })
69
+ history.push({ pathname: path, search: urlParams.toString() })
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Builds path to a scene and removes any scene-specific URL parameters
75
+ *
76
+ * @param path the destination path
77
+ * @param otherParams other query parameters to append to url
78
+ * @returns a path excluding scene-specific search parameters
79
+ */
80
+ const buildPathWithGlobalParams = (path: string, otherParams = {}) => {
81
+ const params = new URLSearchParams(history.location.search)
82
+
83
+ for (const key of params.keys()) {
84
+ if (!GLOBAL_PARAMS.includes(key)) {
85
+ params.delete(key)
86
+ }
87
+ }
88
+ const globalParams = params.toString()
89
+
90
+ let additionalParams = ''
91
+ Object.entries(otherParams).forEach(([key, value]) => {
92
+ additionalParams += `${key}=${value}`
93
+ })
94
+
95
+ let queryString = ''
96
+ if (globalParams) {
97
+ queryString = globalParams
98
+ }
99
+
100
+ if (additionalParams) {
101
+ queryString += globalParams ? `&${additionalParams}` : additionalParams
102
+ }
103
+
104
+ return `${path}${queryString ? `?${queryString}` : ''}`
105
+ }
106
+
107
+ /**
108
+ * Navigates to a scene removing any scene-specific URL parameters
109
+ *
110
+ * @param path Pathname to navigate to
111
+ */
112
+ const navigateWithGlobalParams = (path: string) => {
113
+ history.push(buildPathWithGlobalParams(path))
114
+ }
115
+
116
+ return {
117
+ navigate,
118
+ navigateWithGlobalParams,
119
+ buildPathWithGlobalParams,
120
+ }
121
+ }
@@ -0,0 +1,36 @@
1
+ /*
2
+
3
+ MIT License
4
+
5
+ Copyright (c) 2022 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 { useMemo } from 'react'
27
+ import { useLocation } from 'react-router-dom'
28
+
29
+ /**
30
+ * Hook for retrieving query params
31
+ */
32
+ export const useQuery = () => {
33
+ const { search } = useLocation()
34
+
35
+ return useMemo(() => new URLSearchParams(search), [search])
36
+ }
@@ -25,8 +25,9 @@
25
25
  */
26
26
  export { highlightHTML } from './highlight'
27
27
  export * from './path'
28
+ export * from './sdkLanguage'
28
29
  export { getLoded } from './lodeUtils'
29
30
  export { useWindowSize } from './useWindowSize'
30
31
  export * from './apixAdaptor'
31
32
  export * from './adaptorUtils'
32
- export { useNavigation } from './hooks'
33
+ export { useNavigation, useGlobalStoreSync, useQuery } from './hooks'
@@ -25,7 +25,13 @@
25
25
  */
26
26
 
27
27
  import { api } from '../test-data'
28
- import { buildMethodPath, buildPath, buildTypePath } from './path'
28
+ import {
29
+ buildMethodPath,
30
+ buildPath,
31
+ buildTypePath,
32
+ getSceneType,
33
+ isValidFilter,
34
+ } from './path'
29
35
 
30
36
  describe('path utils', () => {
31
37
  const testParam = 's=test'
@@ -74,4 +80,64 @@ describe('path utils', () => {
74
80
  expect(path).toEqual('/3.1/types/Dashboard/Dashboard')
75
81
  })
76
82
  })
83
+
84
+ describe('getSceneType', () => {
85
+ test('returns correct scene type given location with pathname', () => {
86
+ const methodPath = '/3.1/methods/RandomMethod'
87
+ const typePath = '/3.1/types/RandomType'
88
+ expect(getSceneType(methodPath)).toEqual('methods')
89
+ expect(getSceneType(typePath)).toEqual('types')
90
+ })
91
+ test('returns empty string if there is no scene type', () => {
92
+ const noSceneTypePath = '/'
93
+ expect(getSceneType(noSceneTypePath)).toEqual('')
94
+ })
95
+ })
96
+
97
+ describe('isValidFilter', () => {
98
+ const methodPath = '/3.1/methods/RandomMethod'
99
+ const typePath = '/3.1/types/RandomType'
100
+
101
+ test("validates 'all' as a valid filter for methods and types", () => {
102
+ expect(isValidFilter(methodPath, 'ALL')).toBe(true)
103
+ expect(isValidFilter(typePath, 'ALL')).toBe(true)
104
+ })
105
+
106
+ const methodFilters = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']
107
+ const typeFilters = ['SPECIFICATION', 'WRITE', 'REQUEST', 'ENUMERATED']
108
+
109
+ test.each(methodFilters)(
110
+ 'validates %s as a valid method filter',
111
+ (filter) => {
112
+ expect(isValidFilter(methodPath, filter)).toBe(true)
113
+ }
114
+ )
115
+
116
+ test.each(methodFilters)(
117
+ 'invalidates %s when containing extra characters',
118
+ (filter) => {
119
+ expect(isValidFilter(methodPath, filter + 'x')).toBe(false)
120
+ }
121
+ )
122
+
123
+ test.each(typeFilters)('validates %s as a valid type filter', (filter) => {
124
+ expect(isValidFilter(typePath, filter)).toBe(true)
125
+ })
126
+
127
+ test.each(typeFilters)(
128
+ 'invalidates %s when containing extra characters',
129
+ (filter) => {
130
+ expect(isValidFilter(typePath, filter + 'x')).toBe(false)
131
+ }
132
+ )
133
+
134
+ test('invalidates wrong parameter for methods and types', () => {
135
+ expect(isValidFilter(methodPath, 'INVALID')).toBe(false)
136
+ expect(isValidFilter(typePath, 'INVALID')).toBe(false)
137
+ })
138
+
139
+ test.each(typeFilters)('validates %s as a valid type filter', (filter) => {
140
+ expect(isValidFilter(typePath, filter)).toBe(true)
141
+ })
142
+ })
77
143
  })
package/src/utils/path.ts CHANGED
@@ -27,6 +27,10 @@
27
27
  import type { ApiModel, IMethod, IType } from '@looker/sdk-codegen'
28
28
  import { firstMethodRef } from '@looker/sdk-codegen'
29
29
  import type { Location as HLocation } from 'history'
30
+ import { matchPath } from 'react-router'
31
+
32
+ export const methodFilterOptions = /GET$|POST$|PUT$|PATCH$|DELETE$/i
33
+ export const typeFilterOptions = /SPECIFICATION$|WRITE$|REQUEST$|ENUMERATED$/i
30
34
 
31
35
  /**
32
36
  * Builds a path matching the route used by MethodScene
@@ -128,3 +132,34 @@ export const getSpecKey = (location: HLocation | Location): string | null => {
128
132
  }
129
133
  return match?.groups?.specKey || null
130
134
  }
135
+
136
+ /**
137
+ * Gets the scene type of the current page
138
+ * @param path path of browser location
139
+ * @returns string representing the scene type
140
+ */
141
+ export const getSceneType = (path: string) => {
142
+ const match = matchPath<{ tagType: string }>(path, {
143
+ path: '/:specKey/:tagType',
144
+ })
145
+ return match ? match!.params.tagType : ''
146
+ }
147
+
148
+ /**
149
+ * Confirms if filter is valid for a given method/type tag
150
+ * @param path browser location pathname
151
+ * @param filter filter tag for page
152
+ */
153
+ export const isValidFilter = (path: string, filter: string) => {
154
+ let isValid
155
+ const sceneType = getSceneType(path)
156
+ if (!sceneType) isValid = false
157
+ else if (!filter.localeCompare('all', 'en', { sensitivity: 'base' }))
158
+ isValid = true
159
+ else if (sceneType === 'methods') {
160
+ isValid = methodFilterOptions.test(filter)
161
+ } else {
162
+ isValid = typeFilterOptions.test(filter)
163
+ }
164
+ return isValid
165
+ }
@@ -0,0 +1,69 @@
1
+ /*
2
+
3
+ MIT License
4
+
5
+ Copyright (c) 2022 Looker Data Sciences, Inc.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+
25
+ */
26
+
27
+ import { codeGenerators } from '@looker/sdk-codegen'
28
+ import { allSdkLanguages, findSdk } from '../utils'
29
+ import { sdkLanguageMapping } from '../test-data'
30
+
31
+ describe('SDK Language Utils', () => {
32
+ test('allSdkLanguages gets all sdk languages', () => {
33
+ const actual = allSdkLanguages()
34
+ const aliases = Object.keys(actual)
35
+ expect(Object.keys(actual)).toHaveLength(codeGenerators.length + 1)
36
+ aliases.forEach((alias) =>
37
+ expect(actual[alias]).toEqual(sdkLanguageMapping[alias])
38
+ )
39
+ })
40
+
41
+ describe('findSdk', () => {
42
+ test('it is not case sensitive', () => {
43
+ const actual = findSdk('pY')
44
+ expect(actual.language).toEqual('Python')
45
+ })
46
+
47
+ test("it returns 'All' option if provided bogus input", () => {
48
+ const actual = findSdk('random')
49
+ expect(actual.language).toEqual('All')
50
+ expect(actual.alias).toEqual('all')
51
+ })
52
+
53
+ test.each(Object.entries(sdkLanguageMapping))(
54
+ `it finds language for alias %s`,
55
+ (alias, language) => {
56
+ const actual = findSdk(alias)
57
+ expect(actual.language).toEqual(language)
58
+ }
59
+ )
60
+
61
+ test.each(Object.entries(sdkLanguageMapping))(
62
+ `it finds alias for language %s`,
63
+ (alias, language) => {
64
+ const actual = findSdk(language)
65
+ expect(actual.alias).toEqual(alias)
66
+ }
67
+ )
68
+ })
69
+ })
@@ -0,0 +1,63 @@
1
+ /*
2
+
3
+ MIT License
4
+
5
+ Copyright (c) 2021 Looker Data Sciences, Inc.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+
25
+ */
26
+
27
+ import { codeGenerators } from '@looker/sdk-codegen'
28
+
29
+ export const allAlias = 'all'
30
+
31
+ /**
32
+ * Gets all supported sdk languages
33
+ * @returns mapping of sdk language aliases to name
34
+ */
35
+ export const allSdkLanguages = (): Record<string, string> => {
36
+ const languages = {}
37
+ codeGenerators.forEach((gen) => {
38
+ const alias = gen.extension.toString().match(/\.(\w+)\b/)![1]
39
+ languages[alias] = gen.language
40
+ })
41
+
42
+ return { ...languages, [allAlias]: 'All' }
43
+ }
44
+
45
+ /**
46
+ * Searches for sdk language details given label
47
+ * @param label label to search by
48
+ * @returns language name and alias
49
+ */
50
+ export const findSdk = (label: string) => {
51
+ const languages = allSdkLanguages()
52
+ let match = { alias: allAlias, language: languages[allAlias] }
53
+ for (const [alias, language] of Object.entries(languages)) {
54
+ if (
55
+ !label.localeCompare(alias, 'en', { sensitivity: 'base' }) ||
56
+ !label.localeCompare(language, 'en', { sensitivity: 'base' })
57
+ ) {
58
+ match = { alias, language }
59
+ break
60
+ }
61
+ }
62
+ return match
63
+ }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/DocResponses/DocResponseTypes.tsx"],"names":["DocResponseTypes","api","responses","mediaTypes","Object","keys","selectedMediaType","setSelectedMediaType","resps","setResps","map","mediaType","overflow","type"],"mappings":";;;;;;;AA2BA;;AACA;;AAOA;;;;;;AAYO,IAAMA,gBAA2C,GAAG,QAGrD;AAAA,MAHsD;AAC1DC,IAAAA,GAD0D;AAE1DC,IAAAA;AAF0D,GAGtD;AACJ,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAP,CAAYH,SAAZ,CAAnB;AACA,MAAM,CAACI,iBAAD,EAAoBC,oBAApB,IAA4C,qBAASJ,UAAU,CAAC,CAAD,CAAnB,CAAlD;AACA,MAAM,CAACK,KAAD,EAAQC,QAAR,IAAoB,qBAASP,SAAT,CAA1B;AAEA,wBAAU,MAAM;AAEdK,IAAAA,oBAAoB,CAACJ,UAAU,CAAC,CAAD,CAAX,CAApB;AACAM,IAAAA,QAAQ,CAACP,SAAD,CAAR;AACD,GAJD,EAIG,CAACA,SAAD,EAAYC,UAAZ,CAJH;AAOA,SACE,4DACE,6BAAC,wBAAD;AACE,IAAA,KAAK,EAAEG,iBADT;AAEE,IAAA,QAAQ,EAAEC,oBAFZ;AAGE,IAAA,EAAE,EAAC,OAHL;AAIE,IAAA,EAAE,EAAC;AAJL,KAMGJ,UAAU,CAACO,GAAX,CAAgBC,SAAD,IACd,6BAAC,sBAAD;AAAY,IAAA,GAAG,EAAEA;AAAjB,KAA6BA,SAA7B,CADD,CANH,CADF,EAWE;AAAK,IAAA,KAAK,EAAE;AAAEC,MAAAA,QAAQ,EAAE;AAAZ;AAAZ,KACE,6BAAC,aAAD;AACE,IAAA,GAAG,EAAEX,GADP;AAEE,IAAA,GAAG,EAAEK,iBAFP;AAGE,IAAA,IAAI,EAAEE,KAAK,CAACF,iBAAD,CAAL,CAAyBO,IAHjC;AAIE,IAAA,IAAI,EAAE,IAJR;AAKE,IAAA,QAAQ,EAAE;AALZ,IADF,CAXF,CADF;AAuBD,CAtCM","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 */\n\nimport type { FC } from 'react'\nimport React, { useState, useEffect } from 'react'\nimport { ButtonToggle, ButtonItem } from '@looker/components'\nimport type {\n ApiModel,\n KeyedCollection,\n IMethodResponse,\n} from '@looker/sdk-codegen'\n\nimport { ExploreType } from '..'\n\ninterface DocResponseTypesProps {\n api: ApiModel\n responses: KeyedCollection<IMethodResponse>\n}\n\n/**\n * Given a collection of media types (keys) and responses (values) for a response code, generate a group of buttons for\n * toggling media type and render the response\n * @param response\n */\nexport const DocResponseTypes: FC<DocResponseTypesProps> = ({\n api,\n responses,\n}) => {\n const mediaTypes = Object.keys(responses)\n const [selectedMediaType, setSelectedMediaType] = useState(mediaTypes[0])\n const [resps, setResps] = useState(responses)\n\n useEffect(() => {\n /** When new responses are passed, update the default selected media type */\n setSelectedMediaType(mediaTypes[0])\n setResps(responses)\n }, [responses, mediaTypes])\n\n // TODO: Account for endpoints with no responses (e.g. delete a custom cmd)\n return (\n <>\n <ButtonToggle\n value={selectedMediaType}\n onChange={setSelectedMediaType}\n mt=\"large\"\n mb=\"large\"\n >\n {mediaTypes.map((mediaType) => (\n <ButtonItem key={mediaType}>{mediaType}</ButtonItem>\n ))}\n </ButtonToggle>\n <div style={{ overflow: 'auto' }}>\n <ExploreType\n api={api}\n key={selectedMediaType}\n type={resps[selectedMediaType].type}\n link={true}\n maxDepth={2}\n />\n </div>\n </>\n )\n}\n"],"file":"DocResponseTypes.js"}
@@ -1,8 +0,0 @@
1
- import type { FC } from 'react';
2
- import type { IMethodResponse, ApiModel } from '@looker/sdk-codegen';
3
- interface DocResponsesProps {
4
- responses: IMethodResponse[];
5
- api: ApiModel;
6
- }
7
- export declare const DocResponses: FC<DocResponsesProps>;
8
- export {};
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DocResponses = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _components = require("@looker/components");
11
-
12
- var _runIt = require("@looker/run-it");
13
-
14
- var _DocResponseTypes = require("./DocResponseTypes");
15
-
16
- var _utils = require("./utils");
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
21
-
22
- var DocResponses = _ref => {
23
- var {
24
- api,
25
- responses
26
- } = _ref;
27
- var tabs = (0, _components.useTabs)();
28
- if (responses.length === 0) return _react.default.createElement(_react.default.Fragment, null);
29
- var responseTree = (0, _utils.buildResponseTree)(responses);
30
- return _react.default.createElement(_runIt.CollapserCard, {
31
- heading: "Response Models",
32
- id: "response models"
33
- }, _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_components.TabList, tabs, Object.keys(responseTree).map((statusCode, index) => _react.default.createElement(_components.Tab, {
34
- key: index
35
- }, statusCode))), _react.default.createElement(_components.TabPanels, _extends({}, tabs, {
36
- pt: "0"
37
- }), Object.values(responseTree).map((responses, index) => _react.default.createElement(_components.TabPanel, {
38
- key: index
39
- }, _react.default.createElement(_DocResponseTypes.DocResponseTypes, {
40
- api: api,
41
- responses: responses
42
- }))))));
43
- };
44
-
45
- exports.DocResponses = DocResponses;
46
- //# sourceMappingURL=DocResponses.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/DocResponses/DocResponses.tsx"],"names":["DocResponses","api","responses","tabs","length","responseTree","Object","keys","map","statusCode","index","values"],"mappings":";;;;;;;AA2BA;;AACA;;AAGA;;AACA;;AACA;;;;;;AAUO,IAAMA,YAAmC,GAAG,QAAwB;AAAA,MAAvB;AAAEC,IAAAA,GAAF;AAAOC,IAAAA;AAAP,GAAuB;AACzE,MAAMC,IAAI,GAAG,0BAAb;AAEA,MAAID,SAAS,CAACE,MAAV,KAAqB,CAAzB,EAA4B,OAAO,2DAAP;AAE5B,MAAMC,YAAY,GAAG,8BAAkBH,SAAlB,CAArB;AAEA,SACE,6BAAC,oBAAD;AAAe,IAAA,OAAO,EAAC,iBAAvB;AAAyC,IAAA,EAAE,EAAC;AAA5C,KACE,4DACE,6BAAC,mBAAD,EAAaC,IAAb,EACGG,MAAM,CAACC,IAAP,CAAYF,YAAZ,EAA0BG,GAA1B,CAA8B,CAACC,UAAD,EAAaC,KAAb,KAC7B,6BAAC,eAAD;AAAK,IAAA,GAAG,EAAEA;AAAV,KAAkBD,UAAlB,CADD,CADH,CADF,EAME,6BAAC,qBAAD,eAAeN,IAAf;AAAqB,IAAA,EAAE,EAAC;AAAxB,MACGG,MAAM,CAACK,MAAP,CAAcN,YAAd,EAA4BG,GAA5B,CAAgC,CAACN,SAAD,EAAYQ,KAAZ,KAC/B,6BAAC,oBAAD;AAAU,IAAA,GAAG,EAAEA;AAAf,KACE,6BAAC,kCAAD;AAAkB,IAAA,GAAG,EAAET,GAAvB;AAA4B,IAAA,SAAS,EAAEC;AAAvC,IADF,CADD,CADH,CANF,CADF,CADF;AAkBD,CAzBM","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 */\n\nimport type { FC } from 'react'\nimport React from 'react'\nimport { Tab, TabList, TabPanel, TabPanels, useTabs } from '@looker/components'\nimport type { IMethodResponse, ApiModel } from '@looker/sdk-codegen'\n\nimport { CollapserCard } from '@looker/run-it'\nimport { DocResponseTypes } from './DocResponseTypes'\nimport { buildResponseTree } from './utils'\n\ninterface DocResponsesProps {\n responses: IMethodResponse[]\n api: ApiModel\n}\n\n/**\n * Renders a tab list and tab panels for different method response types\n */\nexport const DocResponses: FC<DocResponsesProps> = ({ api, responses }) => {\n const tabs = useTabs()\n\n if (responses.length === 0) return <></>\n\n const responseTree = buildResponseTree(responses)\n\n return (\n <CollapserCard heading=\"Response Models\" id=\"response models\">\n <>\n <TabList {...tabs}>\n {Object.keys(responseTree).map((statusCode, index) => (\n <Tab key={index}>{statusCode}</Tab>\n ))}\n </TabList>\n <TabPanels {...tabs} pt=\"0\">\n {Object.values(responseTree).map((responses, index) => (\n <TabPanel key={index}>\n <DocResponseTypes api={api} responses={responses} />\n </TabPanel>\n ))}\n </TabPanels>\n </>\n </CollapserCard>\n )\n}\n"],"file":"DocResponses.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/DocResponses/utils.ts"],"names":["buildResponseTree","responses","tree","Object","values","forEach","response","node","statusCode","description","mediaType"],"mappings":";;;;;;;AAiCO,IAAMA,iBAAiB,GAC5BC,SAD+B,IAEuB;AACtD,MAAMC,IAAI,GAAG,EAAb;AACAC,EAAAA,MAAM,CAACC,MAAP,CAAcH,SAAd,EAAyBI,OAAzB,CAAkCC,QAAD,IAAc;AAC7C,QAAMC,IAAI,aAAMD,QAAQ,CAACE,UAAf,eAA8BF,QAAQ,CAACG,WAAvC,CAAV;AACA,QAAI,EAAEF,IAAI,IAAIL,IAAV,CAAJ,EAAqBA,IAAI,CAACK,IAAD,CAAJ,GAAa,EAAb;AACrBL,IAAAA,IAAI,CAACK,IAAD,CAAJ,CAAWD,QAAQ,CAACI,SAApB,IAAiCJ,QAAjC;AACD,GAJD;AAKA,SAAOJ,IAAP;AACD,CAVM","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 */\n\nimport type { IMethodResponse, KeyedCollection } from '@looker/sdk-codegen'\n\n/**\n * Given an array of method responses, group them by statusCode. The value of each status code is a collection of\n * media types (keys) and responses (values)\n * @param responses An array of method responses\n */\nexport const buildResponseTree = (\n responses: IMethodResponse[]\n): KeyedCollection<KeyedCollection<IMethodResponse>> => {\n const tree = {}\n Object.values(responses).forEach((response) => {\n const node = `${response.statusCode}: ${response.description}`\n if (!(node in tree)) tree[node] = {}\n tree[node][response.mediaType] = response\n })\n return tree\n}\n"],"file":"utils.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/components/DocResponses/DocResponseTypes.tsx"],"names":["React","useState","useEffect","ButtonToggle","ButtonItem","ExploreType","DocResponseTypes","api","responses","mediaTypes","Object","keys","selectedMediaType","setSelectedMediaType","resps","setResps","map","mediaType","overflow","type"],"mappings":"AA2BA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,oBAAzC;AAOA,SAASC,WAAT,QAA4B,IAA5B;AAYA,OAAO,IAAMC,gBAA2C,GAAG,QAGrD;AAAA,MAHsD;AAC1DC,IAAAA,GAD0D;AAE1DC,IAAAA;AAF0D,GAGtD;AACJ,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAP,CAAYH,SAAZ,CAAnB;AACA,MAAM,CAACI,iBAAD,EAAoBC,oBAApB,IAA4CZ,QAAQ,CAACQ,UAAU,CAAC,CAAD,CAAX,CAA1D;AACA,MAAM,CAACK,KAAD,EAAQC,QAAR,IAAoBd,QAAQ,CAACO,SAAD,CAAlC;AAEAN,EAAAA,SAAS,CAAC,MAAM;AAEdW,IAAAA,oBAAoB,CAACJ,UAAU,CAAC,CAAD,CAAX,CAApB;AACAM,IAAAA,QAAQ,CAACP,SAAD,CAAR;AACD,GAJQ,EAIN,CAACA,SAAD,EAAYC,UAAZ,CAJM,CAAT;AAOA,SACE,0CACE,oBAAC,YAAD;AACE,IAAA,KAAK,EAAEG,iBADT;AAEE,IAAA,QAAQ,EAAEC,oBAFZ;AAGE,IAAA,EAAE,EAAC,OAHL;AAIE,IAAA,EAAE,EAAC;AAJL,KAMGJ,UAAU,CAACO,GAAX,CAAgBC,SAAD,IACd,oBAAC,UAAD;AAAY,IAAA,GAAG,EAAEA;AAAjB,KAA6BA,SAA7B,CADD,CANH,CADF,EAWE;AAAK,IAAA,KAAK,EAAE;AAAEC,MAAAA,QAAQ,EAAE;AAAZ;AAAZ,KACE,oBAAC,WAAD;AACE,IAAA,GAAG,EAAEX,GADP;AAEE,IAAA,GAAG,EAAEK,iBAFP;AAGE,IAAA,IAAI,EAAEE,KAAK,CAACF,iBAAD,CAAL,CAAyBO,IAHjC;AAIE,IAAA,IAAI,EAAE,IAJR;AAKE,IAAA,QAAQ,EAAE;AALZ,IADF,CAXF,CADF;AAuBD,CAtCM","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 */\n\nimport type { FC } from 'react'\nimport React, { useState, useEffect } from 'react'\nimport { ButtonToggle, ButtonItem } from '@looker/components'\nimport type {\n ApiModel,\n KeyedCollection,\n IMethodResponse,\n} from '@looker/sdk-codegen'\n\nimport { ExploreType } from '..'\n\ninterface DocResponseTypesProps {\n api: ApiModel\n responses: KeyedCollection<IMethodResponse>\n}\n\n/**\n * Given a collection of media types (keys) and responses (values) for a response code, generate a group of buttons for\n * toggling media type and render the response\n * @param response\n */\nexport const DocResponseTypes: FC<DocResponseTypesProps> = ({\n api,\n responses,\n}) => {\n const mediaTypes = Object.keys(responses)\n const [selectedMediaType, setSelectedMediaType] = useState(mediaTypes[0])\n const [resps, setResps] = useState(responses)\n\n useEffect(() => {\n /** When new responses are passed, update the default selected media type */\n setSelectedMediaType(mediaTypes[0])\n setResps(responses)\n }, [responses, mediaTypes])\n\n // TODO: Account for endpoints with no responses (e.g. delete a custom cmd)\n return (\n <>\n <ButtonToggle\n value={selectedMediaType}\n onChange={setSelectedMediaType}\n mt=\"large\"\n mb=\"large\"\n >\n {mediaTypes.map((mediaType) => (\n <ButtonItem key={mediaType}>{mediaType}</ButtonItem>\n ))}\n </ButtonToggle>\n <div style={{ overflow: 'auto' }}>\n <ExploreType\n api={api}\n key={selectedMediaType}\n type={resps[selectedMediaType].type}\n link={true}\n maxDepth={2}\n />\n </div>\n </>\n )\n}\n"],"file":"DocResponseTypes.js"}
@@ -1,30 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React from 'react';
4
- import { Tab, TabList, TabPanel, TabPanels, useTabs } from '@looker/components';
5
- import { CollapserCard } from '@looker/run-it';
6
- import { DocResponseTypes } from './DocResponseTypes';
7
- import { buildResponseTree } from './utils';
8
- export var DocResponses = _ref => {
9
- var {
10
- api,
11
- responses
12
- } = _ref;
13
- var tabs = useTabs();
14
- if (responses.length === 0) return React.createElement(React.Fragment, null);
15
- var responseTree = buildResponseTree(responses);
16
- return React.createElement(CollapserCard, {
17
- heading: "Response Models",
18
- id: "response models"
19
- }, React.createElement(React.Fragment, null, React.createElement(TabList, tabs, Object.keys(responseTree).map((statusCode, index) => React.createElement(Tab, {
20
- key: index
21
- }, statusCode))), React.createElement(TabPanels, _extends({}, tabs, {
22
- pt: "0"
23
- }), Object.values(responseTree).map((responses, index) => React.createElement(TabPanel, {
24
- key: index
25
- }, React.createElement(DocResponseTypes, {
26
- api: api,
27
- responses: responses
28
- }))))));
29
- };
30
- //# sourceMappingURL=DocResponses.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/components/DocResponses/DocResponses.tsx"],"names":["React","Tab","TabList","TabPanel","TabPanels","useTabs","CollapserCard","DocResponseTypes","buildResponseTree","DocResponses","api","responses","tabs","length","responseTree","Object","keys","map","statusCode","index","values"],"mappings":";;AA2BA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,GAAT,EAAcC,OAAd,EAAuBC,QAAvB,EAAiCC,SAAjC,EAA4CC,OAA5C,QAA2D,oBAA3D;AAGA,SAASC,aAAT,QAA8B,gBAA9B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,iBAAT,QAAkC,SAAlC;AAUA,OAAO,IAAMC,YAAmC,GAAG,QAAwB;AAAA,MAAvB;AAAEC,IAAAA,GAAF;AAAOC,IAAAA;AAAP,GAAuB;AACzE,MAAMC,IAAI,GAAGP,OAAO,EAApB;AAEA,MAAIM,SAAS,CAACE,MAAV,KAAqB,CAAzB,EAA4B,OAAO,yCAAP;AAE5B,MAAMC,YAAY,GAAGN,iBAAiB,CAACG,SAAD,CAAtC;AAEA,SACE,oBAAC,aAAD;AAAe,IAAA,OAAO,EAAC,iBAAvB;AAAyC,IAAA,EAAE,EAAC;AAA5C,KACE,0CACE,oBAAC,OAAD,EAAaC,IAAb,EACGG,MAAM,CAACC,IAAP,CAAYF,YAAZ,EAA0BG,GAA1B,CAA8B,CAACC,UAAD,EAAaC,KAAb,KAC7B,oBAAC,GAAD;AAAK,IAAA,GAAG,EAAEA;AAAV,KAAkBD,UAAlB,CADD,CADH,CADF,EAME,oBAAC,SAAD,eAAeN,IAAf;AAAqB,IAAA,EAAE,EAAC;AAAxB,MACGG,MAAM,CAACK,MAAP,CAAcN,YAAd,EAA4BG,GAA5B,CAAgC,CAACN,SAAD,EAAYQ,KAAZ,KAC/B,oBAAC,QAAD;AAAU,IAAA,GAAG,EAAEA;AAAf,KACE,oBAAC,gBAAD;AAAkB,IAAA,GAAG,EAAET,GAAvB;AAA4B,IAAA,SAAS,EAAEC;AAAvC,IADF,CADD,CADH,CANF,CADF,CADF;AAkBD,CAzBM","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 */\n\nimport type { FC } from 'react'\nimport React from 'react'\nimport { Tab, TabList, TabPanel, TabPanels, useTabs } from '@looker/components'\nimport type { IMethodResponse, ApiModel } from '@looker/sdk-codegen'\n\nimport { CollapserCard } from '@looker/run-it'\nimport { DocResponseTypes } from './DocResponseTypes'\nimport { buildResponseTree } from './utils'\n\ninterface DocResponsesProps {\n responses: IMethodResponse[]\n api: ApiModel\n}\n\n/**\n * Renders a tab list and tab panels for different method response types\n */\nexport const DocResponses: FC<DocResponsesProps> = ({ api, responses }) => {\n const tabs = useTabs()\n\n if (responses.length === 0) return <></>\n\n const responseTree = buildResponseTree(responses)\n\n return (\n <CollapserCard heading=\"Response Models\" id=\"response models\">\n <>\n <TabList {...tabs}>\n {Object.keys(responseTree).map((statusCode, index) => (\n <Tab key={index}>{statusCode}</Tab>\n ))}\n </TabList>\n <TabPanels {...tabs} pt=\"0\">\n {Object.values(responseTree).map((responses, index) => (\n <TabPanel key={index}>\n <DocResponseTypes api={api} responses={responses} />\n </TabPanel>\n ))}\n </TabPanels>\n </>\n </CollapserCard>\n )\n}\n"],"file":"DocResponses.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/components/DocResponses/index.ts"],"names":["DocResponses"],"mappings":"AAyBA,SAASA,YAAT,QAA6B,gBAA7B","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 { DocResponses } from './DocResponses'\n"],"file":"index.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/components/DocResponses/utils.ts"],"names":["buildResponseTree","responses","tree","Object","values","forEach","response","node","statusCode","description","mediaType"],"mappings":"AAiCA,OAAO,IAAMA,iBAAiB,GAC5BC,SAD+B,IAEuB;AACtD,MAAMC,IAAI,GAAG,EAAb;AACAC,EAAAA,MAAM,CAACC,MAAP,CAAcH,SAAd,EAAyBI,OAAzB,CAAkCC,QAAD,IAAc;AAC7C,QAAMC,IAAI,aAAMD,QAAQ,CAACE,UAAf,eAA8BF,QAAQ,CAACG,WAAvC,CAAV;AACA,QAAI,EAAEF,IAAI,IAAIL,IAAV,CAAJ,EAAqBA,IAAI,CAACK,IAAD,CAAJ,GAAa,EAAb;AACrBL,IAAAA,IAAI,CAACK,IAAD,CAAJ,CAAWD,QAAQ,CAACI,SAApB,IAAiCJ,QAAjC;AACD,GAJD;AAKA,SAAOJ,IAAP;AACD,CAVM","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 */\n\nimport type { IMethodResponse, KeyedCollection } from '@looker/sdk-codegen'\n\n/**\n * Given an array of method responses, group them by statusCode. The value of each status code is a collection of\n * media types (keys) and responses (values)\n * @param responses An array of method responses\n */\nexport const buildResponseTree = (\n responses: IMethodResponse[]\n): KeyedCollection<KeyedCollection<IMethodResponse>> => {\n const tree = {}\n Object.values(responses).forEach((response) => {\n const node = `${response.statusCode}: ${response.description}`\n if (!(node in tree)) tree[node] = {}\n tree[node][response.mediaType] = response\n })\n return tree\n}\n"],"file":"utils.js"}
@@ -1,26 +0,0 @@
1
- import { useHistory } from 'react-router-dom';
2
- export var useNavigation = () => {
3
- var history = useHistory();
4
-
5
- var navigate = (path, queryParams) => {
6
- if (queryParams === undefined) {
7
- var curParams = new URLSearchParams(history.location.search);
8
- history.push({
9
- pathname: path,
10
- search: curParams.toString()
11
- });
12
- } else if (queryParams === null || Object.keys(queryParams).length === 0) {
13
- history.push({
14
- pathname: path
15
- });
16
- } else {
17
- history.push({
18
- pathname: path,
19
- search: queryParams.search
20
- });
21
- }
22
- };
23
-
24
- return navigate;
25
- };
26
- //# sourceMappingURL=hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/hooks.ts"],"names":["useHistory","useNavigation","history","navigate","path","queryParams","undefined","curParams","URLSearchParams","location","search","push","pathname","toString","Object","keys","length"],"mappings":"AAyBA,SAASA,UAAT,QAA2B,kBAA3B;AASA,OAAO,IAAMC,aAAa,GAAG,MAAM;AACjC,MAAMC,OAAO,GAAGF,UAAU,EAA1B;;AAEA,MAAMG,QAAQ,GAAG,CAACC,IAAD,EAAeC,WAAf,KAA4D;AAC3E,QAAIA,WAAW,KAAKC,SAApB,EAA+B;AAE7B,UAAMC,SAAS,GAAG,IAAIC,eAAJ,CAAoBN,OAAO,CAACO,QAAR,CAAiBC,MAArC,CAAlB;AACAR,MAAAA,OAAO,CAACS,IAAR,CAAa;AAAEC,QAAAA,QAAQ,EAAER,IAAZ;AAAkBM,QAAAA,MAAM,EAAEH,SAAS,CAACM,QAAV;AAA1B,OAAb;AACD,KAJD,MAIO,IAAIR,WAAW,KAAK,IAAhB,IAAwBS,MAAM,CAACC,IAAP,CAAYV,WAAZ,EAAyBW,MAAzB,KAAoC,CAAhE,EAAmE;AAExEd,MAAAA,OAAO,CAACS,IAAR,CAAa;AAAEC,QAAAA,QAAQ,EAAER;AAAZ,OAAb;AACD,KAHM,MAGA;AAELF,MAAAA,OAAO,CAACS,IAAR,CAAa;AAAEC,QAAAA,QAAQ,EAAER,IAAZ;AAAkBM,QAAAA,MAAM,EAAEL,WAAW,CAACK;AAAtC,OAAb;AACD;AACF,GAZD;;AAcA,SAAOP,QAAP;AACD,CAlBM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 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 */\nimport { useHistory } from 'react-router-dom'\n\n/**\n * Hook for navigating to given route with specified query params\n *\n * @param path Pathname to navigate to\n * @param queryParams Hash of query param name/value pairs to include in the destination url\n */\n\nexport const useNavigation = () => {\n const history = useHistory()\n\n const navigate = (path: string, queryParams?: { search?: string } | null) => {\n if (queryParams === undefined) {\n // if params passed in is undefined, maintain existing parameters in the URL\n const curParams = new URLSearchParams(history.location.search)\n history.push({ pathname: path, search: curParams.toString() })\n } else if (queryParams === null || Object.keys(queryParams).length === 0) {\n // if params passed in is null or empty, remove all parameters from the URL\n history.push({ pathname: path })\n } else {\n // if we have new parameters passed in, push them to the URL\n history.push({ pathname: path, search: queryParams.search })\n }\n }\n\n return navigate\n}\n"],"file":"hooks.js"}
@@ -1,3 +0,0 @@
1
- export declare const useNavigation: () => (path: string, queryParams?: {
2
- search?: string | undefined;
3
- } | null | undefined) => void;