@urbanos/react-discovery-ui 2.1.43

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 (316) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +118 -0
  3. package/lib/ReactDiscoveryUI.js +103 -0
  4. package/lib/ReactDiscoveryUI.scss +13 -0
  5. package/lib/assets/arrow.svg +6 -0
  6. package/lib/assets/blk-database.svg +48 -0
  7. package/lib/assets/chart.svg +1 -0
  8. package/lib/assets/down.png +0 -0
  9. package/lib/assets/down.svg +1 -0
  10. package/lib/assets/folder_icon.png +0 -0
  11. package/lib/assets/folder_icon.svg +1 -0
  12. package/lib/assets/ic_arrow.svg +15 -0
  13. package/lib/assets/loadingicon.svg +57 -0
  14. package/lib/assets/no_image.png +0 -0
  15. package/lib/assets/plus.png +0 -0
  16. package/lib/assets/plus.svg +1 -0
  17. package/lib/assets/user.svg +1 -0
  18. package/lib/auth/auth0-client-provider.js +37 -0
  19. package/lib/auth/auth0-client-provider.test.js +33 -0
  20. package/lib/auth/auth0-wrapper.js +155 -0
  21. package/lib/auth/auth0-wrapper.test.js +100 -0
  22. package/lib/components/auth0-login-zone/auth0-login-zone.js +147 -0
  23. package/lib/components/auth0-login-zone/auth0-login-zone.test.js +177 -0
  24. package/lib/components/auth0-login-zone/index.js +9 -0
  25. package/lib/components/code-editor/code-editor.css +173 -0
  26. package/lib/components/code-editor/code-editor.js +64 -0
  27. package/lib/components/code-editor/index.js +9 -0
  28. package/lib/components/collapsable-box/collapsable-box.js +81 -0
  29. package/lib/components/collapsable-box/collapsable-box.scss +39 -0
  30. package/lib/components/collapsable-box/collapsable-box.test.js +87 -0
  31. package/lib/components/collapsable-box/index.js +9 -0
  32. package/lib/components/data-card/data-card.js +63 -0
  33. package/lib/components/data-card/data-card.scss +93 -0
  34. package/lib/components/data-card/data-card.test.js +74 -0
  35. package/lib/components/data-card/index.js +9 -0
  36. package/lib/components/data-view/data-view.js +194 -0
  37. package/lib/components/data-view/data-view.scss +39 -0
  38. package/lib/components/data-view/data-view.test.js +155 -0
  39. package/lib/components/data-view/index.js +9 -0
  40. package/lib/components/dataset-api-doc/api-example.js +120 -0
  41. package/lib/components/dataset-api-doc/api-example.scss +84 -0
  42. package/lib/components/dataset-api-doc/api-example.test.js +88 -0
  43. package/lib/components/dataset-api-doc/dataset-api-doc.js +117 -0
  44. package/lib/components/dataset-api-doc/dataset-api-doc.scss +8 -0
  45. package/lib/components/dataset-api-doc/dataset-api-doc.test.js +42 -0
  46. package/lib/components/dataset-api-doc/index.js +9 -0
  47. package/lib/components/dataset-details/dataset-details.js +64 -0
  48. package/lib/components/dataset-details/dataset-details.scss +58 -0
  49. package/lib/components/dataset-details/dataset-details.test.js +38 -0
  50. package/lib/components/dataset-details/index.js +9 -0
  51. package/lib/components/dataset-dictionary/dataset-dictionary.js +127 -0
  52. package/lib/components/dataset-dictionary/dataset-dictionary.scss +42 -0
  53. package/lib/components/dataset-dictionary/dataset-dictionary.test.js +286 -0
  54. package/lib/components/dataset-dictionary/index.js +9 -0
  55. package/lib/components/dataset-list/dataset-list.js +22 -0
  56. package/lib/components/dataset-list/dataset-list.scss +9 -0
  57. package/lib/components/dataset-list/dataset-list.test.js +16 -0
  58. package/lib/components/dataset-list/index.js +9 -0
  59. package/lib/components/dataset-metadata/dataset-metadata.js +169 -0
  60. package/lib/components/dataset-metadata/dataset-metadata.scss +34 -0
  61. package/lib/components/dataset-metadata/dataset-metadata.test.js +24 -0
  62. package/lib/components/dataset-metadata/index.js +9 -0
  63. package/lib/components/dataset-preview/connector.js +26 -0
  64. package/lib/components/dataset-preview/dataset-preview.js +58 -0
  65. package/lib/components/dataset-preview/dataset-preview.scss +24 -0
  66. package/lib/components/dataset-preview/dataset-preview.test.js +34 -0
  67. package/lib/components/dataset-preview/index.js +9 -0
  68. package/lib/components/dataset-quality/dataset-quality.js +56 -0
  69. package/lib/components/dataset-quality/dataset-quality.scss +24 -0
  70. package/lib/components/dataset-quality/dataset-quality.test.js +34 -0
  71. package/lib/components/dataset-quality/index.js +9 -0
  72. package/lib/components/dataset-recommendations/connector.js +24 -0
  73. package/lib/components/dataset-recommendations/dataset-recommendations.js +47 -0
  74. package/lib/components/dataset-recommendations/dataset-recommendations.scss +17 -0
  75. package/lib/components/dataset-recommendations/dataset-recommendations.test.js +37 -0
  76. package/lib/components/dataset-recommendations/index.js +9 -0
  77. package/lib/components/detail-toggle-icon/detail-toggle-icon.js +41 -0
  78. package/lib/components/detail-toggle-icon/detail-toggle-icon.scss +13 -0
  79. package/lib/components/detail-toggle-icon/detail-toggle-icon.test.js +20 -0
  80. package/lib/components/detail-toggle-icon/index.js +9 -0
  81. package/lib/components/facet-list/facet-list.js +47 -0
  82. package/lib/components/facet-list/facet-list.scss +19 -0
  83. package/lib/components/facet-list/facet-list.test.js +94 -0
  84. package/lib/components/facet-list/index.js +9 -0
  85. package/lib/components/facet-sidebar/facet-sidebar.js +101 -0
  86. package/lib/components/facet-sidebar/facet-sidebar.scss +129 -0
  87. package/lib/components/facet-sidebar/facet-sidebar.test.js +93 -0
  88. package/lib/components/facet-sidebar/index.js +9 -0
  89. package/lib/components/generic-elements/alert-component/alert-component.js +51 -0
  90. package/lib/components/generic-elements/alert-component/alert-component.scss +26 -0
  91. package/lib/components/generic-elements/alert-component/alert-component.test.js +26 -0
  92. package/lib/components/generic-elements/alert-component/index.js +9 -0
  93. package/lib/components/generic-elements/arrow-button/arrow-button.js +30 -0
  94. package/lib/components/generic-elements/arrow-button/index.js +9 -0
  95. package/lib/components/generic-elements/auto-anchoring-popover/index.js +61 -0
  96. package/lib/components/generic-elements/back-button/back-button.js +14 -0
  97. package/lib/components/generic-elements/back-button/back-button.scss +14 -0
  98. package/lib/components/generic-elements/back-button/index.js +9 -0
  99. package/lib/components/generic-elements/call-to-action-button/call-to-action-button.js +118 -0
  100. package/lib/components/generic-elements/call-to-action-button/call-to-action-button.scss +19 -0
  101. package/lib/components/generic-elements/call-to-action-button/call-to-action-button.test.js +68 -0
  102. package/lib/components/generic-elements/call-to-action-button/index.js +9 -0
  103. package/lib/components/generic-elements/chart-icon/index.js +23 -0
  104. package/lib/components/generic-elements/checkbox/checkbox.js +50 -0
  105. package/lib/components/generic-elements/checkbox/checkbox.scss +44 -0
  106. package/lib/components/generic-elements/checkbox/checkbox.test.js +71 -0
  107. package/lib/components/generic-elements/checkbox/index.js +9 -0
  108. package/lib/components/generic-elements/error-component/error-component.js +21 -0
  109. package/lib/components/generic-elements/error-component/error-component.scss +16 -0
  110. package/lib/components/generic-elements/error-component/error-component.test.js +12 -0
  111. package/lib/components/generic-elements/error-component/index.js +9 -0
  112. package/lib/components/generic-elements/folder-icon/index.js +23 -0
  113. package/lib/components/generic-elements/generated-link/generated-link.js +25 -0
  114. package/lib/components/generic-elements/generated-link/index.js +13 -0
  115. package/lib/components/generic-elements/loading-element/index.js +9 -0
  116. package/lib/components/generic-elements/loading-element/loading-element.js +22 -0
  117. package/lib/components/generic-elements/loading-element/loading-element.scss +6 -0
  118. package/lib/components/generic-elements/loading-element/loading-element.test.js +11 -0
  119. package/lib/components/generic-elements/paginator/index.js +9 -0
  120. package/lib/components/generic-elements/paginator/paginator.js +84 -0
  121. package/lib/components/generic-elements/paginator/paginator.scss +38 -0
  122. package/lib/components/generic-elements/paginator/paginator.test.js +140 -0
  123. package/lib/components/generic-elements/plus-icon/index.js +21 -0
  124. package/lib/components/generic-elements/save-indicator/index.js +9 -0
  125. package/lib/components/generic-elements/save-indicator/save-indicator.js +39 -0
  126. package/lib/components/generic-elements/save-indicator/save-indicator.scss +31 -0
  127. package/lib/components/generic-elements/save-indicator/save-indicator.test.js +89 -0
  128. package/lib/components/generic-elements/search/index.js +9 -0
  129. package/lib/components/generic-elements/search/search.js +93 -0
  130. package/lib/components/generic-elements/search/search.scss +90 -0
  131. package/lib/components/generic-elements/search/search.test.js +41 -0
  132. package/lib/components/generic-elements/select/index.js +9 -0
  133. package/lib/components/generic-elements/select/select.js +44 -0
  134. package/lib/components/generic-elements/select/select.scss +22 -0
  135. package/lib/components/generic-elements/select/select.test.js +34 -0
  136. package/lib/components/generic-elements/share-link/index.js +9 -0
  137. package/lib/components/generic-elements/share-link/share-link.js +23 -0
  138. package/lib/components/generic-elements/share-link/share-link.scss +17 -0
  139. package/lib/components/generic-elements/share-link/share-link.test.js +28 -0
  140. package/lib/components/generic-elements/sql-icon/index.js +20 -0
  141. package/lib/components/generic-elements/tab-button/index.js +9 -0
  142. package/lib/components/generic-elements/tab-button/tab-button.js +25 -0
  143. package/lib/components/generic-elements/tab-button/tab-button.scss +27 -0
  144. package/lib/components/generic-elements/visualize-button/index.js +9 -0
  145. package/lib/components/generic-elements/visualize-button/visualize-button.js +37 -0
  146. package/lib/components/generic-elements/visualize-button/visualize-button.scss +14 -0
  147. package/lib/components/login-zone/connector.js +25 -0
  148. package/lib/components/login-zone/index.js +9 -0
  149. package/lib/components/login-zone/login-svgs-and-text.js +39 -0
  150. package/lib/components/login-zone/login-zone.js +21 -0
  151. package/lib/components/login-zone/login-zone.scss +115 -0
  152. package/lib/components/login-zone/login-zone.test.js +17 -0
  153. package/lib/components/login-zone/login.js +48 -0
  154. package/lib/components/login-zone/logout.js +39 -0
  155. package/lib/components/network-loading-element/connector.js +17 -0
  156. package/lib/components/network-loading-element/index.js +9 -0
  157. package/lib/components/network-loading-element/network-loading-element.js +23 -0
  158. package/lib/components/network-loading-element/network-loading-element.scss +21 -0
  159. package/lib/components/network-loading-element/network-loading-element.test.js +34 -0
  160. package/lib/components/organization/index.js +9 -0
  161. package/lib/components/organization/organization.js +27 -0
  162. package/lib/components/organization/organization.scss +32 -0
  163. package/lib/components/protected-route/protected-route.js +101 -0
  164. package/lib/components/protected-route/protected-route.scss +4 -0
  165. package/lib/components/protected-route/protected-route.test.js +63 -0
  166. package/lib/components/query-form/index.js +9 -0
  167. package/lib/components/query-form/query-form.js +262 -0
  168. package/lib/components/query-form/query-form.scss +167 -0
  169. package/lib/components/query-form/query-form.test.js +248 -0
  170. package/lib/components/recommendation-list/index.js +9 -0
  171. package/lib/components/recommendation-list/recommendation-list.js +72 -0
  172. package/lib/components/recommendation-list/recommendation-list.scss +61 -0
  173. package/lib/components/recommendation-list/recommendation-list.test.js +38 -0
  174. package/lib/components/remote-toggle/__snapshots__/remote-toggle.test.js.snap +3 -0
  175. package/lib/components/remote-toggle/index.js +13 -0
  176. package/lib/components/remote-toggle/remote-toggle.js +35 -0
  177. package/lib/components/remote-toggle/remote-toggle.scss +0 -0
  178. package/lib/components/remote-toggle/remote-toggle.test.js +10 -0
  179. package/lib/components/share/index.js +9 -0
  180. package/lib/components/share/share.js +109 -0
  181. package/lib/components/share/share.scss +66 -0
  182. package/lib/components/streaming-api-doc/index.js +9 -0
  183. package/lib/components/streaming-api-doc/streaming-api-doc.js +76 -0
  184. package/lib/components/streaming-api-doc/streaming-api-doc.scss +23 -0
  185. package/lib/components/streaming-api-doc/streaming-api-doc.test.js +24 -0
  186. package/lib/components/tooltip/index.js +9 -0
  187. package/lib/components/tooltip/tooltip.js +17 -0
  188. package/lib/components/tooltip/tooltip.scss +16 -0
  189. package/lib/components/tooltip/tooltip.test.js +19 -0
  190. package/lib/components/visualization-list-menu-item/index.js +9 -0
  191. package/lib/components/visualization-list-menu-item/visualization-list-menu-item.js +53 -0
  192. package/lib/components/visualization-list-menu-item/visualization-list-menu-item.scss +21 -0
  193. package/lib/components/visualization-list-menu-item/visualization-list-menu-item.test.js +42 -0
  194. package/lib/components/visualization-save-menu-item/index.js +9 -0
  195. package/lib/components/visualization-save-menu-item/visualization-save-menu-item.js +101 -0
  196. package/lib/components/visualization-save-menu-item/visualization-save-menu-item.scss +37 -0
  197. package/lib/components/visualization-save-menu-item/visualization-save-menu-item.test.js +185 -0
  198. package/lib/components/visualizations/geojson/connector.js +29 -0
  199. package/lib/components/visualizations/geojson/geojson-visualization.js +151 -0
  200. package/lib/components/visualizations/geojson/geojson-visualization.scss +24 -0
  201. package/lib/components/visualizations/geojson/geojson-visualization.test.js +238 -0
  202. package/lib/components/visualizations/geojson/index.js +9 -0
  203. package/lib/pages/apikey-view/apiKey-view.test.js +204 -0
  204. package/lib/pages/apikey-view/apikey-view.js +166 -0
  205. package/lib/pages/apikey-view/apikey-view.scss +340 -0
  206. package/lib/pages/apikey-view/connector.js +31 -0
  207. package/lib/pages/apikey-view/index.js +9 -0
  208. package/lib/pages/chart-view/chart-view.js +92 -0
  209. package/lib/pages/chart-view/chart-view.scss +35 -0
  210. package/lib/pages/chart-view/chart-view.test.js +206 -0
  211. package/lib/pages/chart-view/connector.js +30 -0
  212. package/lib/pages/chart-view/index.js +9 -0
  213. package/lib/pages/dataset-detail-view/connector.js +38 -0
  214. package/lib/pages/dataset-detail-view/dataset-detail-view-connector.test.js +42 -0
  215. package/lib/pages/dataset-detail-view/dataset-detail-view.js +99 -0
  216. package/lib/pages/dataset-detail-view/dataset-detail-view.scss +190 -0
  217. package/lib/pages/dataset-detail-view/dataset-detail-view.test.js +305 -0
  218. package/lib/pages/dataset-detail-view/index.js +9 -0
  219. package/lib/pages/dataset-list-view/connector.js +30 -0
  220. package/lib/pages/dataset-list-view/dataset-list-view.js +132 -0
  221. package/lib/pages/dataset-list-view/dataset-list-view.scss +242 -0
  222. package/lib/pages/dataset-list-view/dataset-list-view.test.js +162 -0
  223. package/lib/pages/dataset-list-view/index.js +9 -0
  224. package/lib/pages/dataset-view/connector.js +55 -0
  225. package/lib/pages/dataset-view/dataset-view-connector.test.js +78 -0
  226. package/lib/pages/dataset-view/dataset-view.js +175 -0
  227. package/lib/pages/dataset-view/dataset-view.scss +95 -0
  228. package/lib/pages/dataset-view/dataset-view.test.js +157 -0
  229. package/lib/pages/dataset-view/index.js +9 -0
  230. package/lib/pages/login-view/connector.js +25 -0
  231. package/lib/pages/login-view/index.js +9 -0
  232. package/lib/pages/login-view/login-view.js +83 -0
  233. package/lib/pages/login-view/login-view.scss +62 -0
  234. package/lib/pages/login-view/login-view.test.js +23 -0
  235. package/lib/pages/oauth-error-view/index.js +9 -0
  236. package/lib/pages/oauth-error-view/oauth-error-view.js +25 -0
  237. package/lib/pages/oauth-error-view/oauth-error-view.scss +13 -0
  238. package/lib/pages/oauth-error-view/oauth-error-view.test.js +13 -0
  239. package/lib/pages/oauth-view/connector.js +22 -0
  240. package/lib/pages/oauth-view/index.js +9 -0
  241. package/lib/pages/oauth-view/oauth-view.js +124 -0
  242. package/lib/pages/oauth-view/oauth-view.scss +7 -0
  243. package/lib/pages/oauth-view/oauth-view.test.js +195 -0
  244. package/lib/pages/query-view/connector.js +40 -0
  245. package/lib/pages/query-view/index.js +9 -0
  246. package/lib/pages/query-view/query-view.js +80 -0
  247. package/lib/pages/query-view/query-view.scss +39 -0
  248. package/lib/pages/query-view/query-view.test.js +104 -0
  249. package/lib/pages/user-profile-view/connector.js +39 -0
  250. package/lib/pages/user-profile-view/index.js +9 -0
  251. package/lib/pages/user-profile-view/user-profile-view.js +154 -0
  252. package/lib/pages/user-profile-view/user-profile-view.scss +81 -0
  253. package/lib/pages/user-profile-view/user-profile-view.test.js +129 -0
  254. package/lib/pages/visualization-view/connector.js +52 -0
  255. package/lib/pages/visualization-view/index.js +9 -0
  256. package/lib/pages/visualization-view/visualization-view-connector.test.js +62 -0
  257. package/lib/pages/visualization-view/visualization-view.js +128 -0
  258. package/lib/pages/visualization-view/visualization-view.scss +115 -0
  259. package/lib/pages/visualization-view/visualization-view.test.js +188 -0
  260. package/lib/routes.js +18 -0
  261. package/lib/search-params/search-params-manager.js +171 -0
  262. package/lib/search-params/search-params-manager.test.js +490 -0
  263. package/lib/store/actions.js +428 -0
  264. package/lib/store/dataset-selectors.js +47 -0
  265. package/lib/store/dataset-selectors.test.js +154 -0
  266. package/lib/store/query-selectors.js +53 -0
  267. package/lib/store/query-selectors.test.js +153 -0
  268. package/lib/store/reducers/index.js +20 -0
  269. package/lib/store/reducers/query-reducer.js +52 -0
  270. package/lib/store/reducers/query-reducer.test.js +89 -0
  271. package/lib/store/reducers/reducers.js +196 -0
  272. package/lib/store/reducers/reducers.test.js +309 -0
  273. package/lib/store/reducers/visualization-reducer.js +167 -0
  274. package/lib/store/reducers/visualization-reducer.test.js +426 -0
  275. package/lib/store/sagas/api-invoker.js +79 -0
  276. package/lib/store/sagas/api-invoker.test.js +139 -0
  277. package/lib/store/sagas/apiKey-saga.js +81 -0
  278. package/lib/store/sagas/apiKey-saga.test.js +57 -0
  279. package/lib/store/sagas/dataset-download-saga.js +43 -0
  280. package/lib/store/sagas/dataset-list-saga.js +49 -0
  281. package/lib/store/sagas/dataset-list-saga.test.js +72 -0
  282. package/lib/store/sagas/dataset-preview-saga.js +44 -0
  283. package/lib/store/sagas/dataset-query-saga.js +43 -0
  284. package/lib/store/sagas/dataset-recommendation-saga.js +40 -0
  285. package/lib/store/sagas/dataset-saga.js +50 -0
  286. package/lib/store/sagas/freestyle-query-saga.js +127 -0
  287. package/lib/store/sagas/freestyle-query-saga.test.js +145 -0
  288. package/lib/store/sagas/index.js +44 -0
  289. package/lib/store/sagas/login-saga.js +85 -0
  290. package/lib/store/sagas/login-saga.test.js +84 -0
  291. package/lib/store/sagas/logout-saga.js +96 -0
  292. package/lib/store/sagas/oauth-saga.js +78 -0
  293. package/lib/store/sagas/oauth-saga.test.js +51 -0
  294. package/lib/store/sagas/process-login-saga.js +62 -0
  295. package/lib/store/sagas/process-login-saga.test.js +83 -0
  296. package/lib/store/sagas/visualization-saga.js +371 -0
  297. package/lib/store/sagas/visualization-saga.test.js +388 -0
  298. package/lib/store/selectors.js +83 -0
  299. package/lib/store/visualization-selectors.js +85 -0
  300. package/lib/store/visualization-selectors.test.js +195 -0
  301. package/lib/styles/mixins.scss +117 -0
  302. package/lib/styles/variables.scss +41 -0
  303. package/lib/utils/file-type-utils.js +18 -0
  304. package/lib/utils/file-type-utils.test.js +29 -0
  305. package/lib/utils/geojson-utils.js +70 -0
  306. package/lib/utils/geojson-utils.test.js +129 -0
  307. package/lib/utils/http-clients.js +218 -0
  308. package/lib/utils/http-clients.test.js +88 -0
  309. package/lib/utils/index.js +34 -0
  310. package/lib/utils/modified-date-string-builder.js +29 -0
  311. package/lib/utils/modified-date-string-builder.test.js +93 -0
  312. package/lib/utils/query-string-builder.js +38 -0
  313. package/lib/utils/query-string-builder.test.js +33 -0
  314. package/lib/utils/recommendation-utils.js +12 -0
  315. package/lib/utils/recommendation-utils.test.js +9 -0
  316. package/package.json +172 -0
@@ -0,0 +1,153 @@
1
+ import {
2
+ getFreestyleQueryText,
3
+ getVisualizationDataSources,
4
+ shouldAutoExecuteQuery,
5
+ isQueryDataAvailable
6
+ } from './query-selectors'
7
+
8
+ describe('get visualization data sources', () => {
9
+ it('returns empty data sources when data query result is missing', () => {
10
+ const state = { queryReducer: {} }
11
+
12
+ const dataSources = getVisualizationDataSources(state)
13
+
14
+ expect(dataSources).toEqual({})
15
+ })
16
+
17
+ it('returns empty data sources when data query result is empty', () => {
18
+ const state = { queryReducer: { datasetQueryResult: [] } }
19
+
20
+ const dataSources = getVisualizationDataSources(state)
21
+
22
+ expect(dataSources).toEqual({})
23
+ })
24
+
25
+ it('returns data sources as a list of values for each column in query result', () => {
26
+ const state = {
27
+ queryReducer: {
28
+ queryData: [
29
+ {
30
+ bob: 'bob\'s bob',
31
+ thing: 'bob\'s thing'
32
+ },
33
+ {
34
+ bob: 'sally\'s bob',
35
+ thing: 'sally\'s thing'
36
+ },
37
+ {
38
+ bob: undefined,
39
+ thing: 'un\'s thing'
40
+ }
41
+ ]
42
+ }
43
+ }
44
+
45
+ const dataSources = getVisualizationDataSources(state)
46
+
47
+ expect(dataSources).toEqual({
48
+ bob: ['bob\'s bob', 'sally\'s bob', undefined],
49
+ thing: ['bob\'s thing', 'sally\'s thing', 'un\'s thing']
50
+ })
51
+ })
52
+ })
53
+
54
+ describe('getFreestyleQueryText', () => {
55
+ let state
56
+
57
+ describe('for a dataset', () => {
58
+ const tableName = 'org1__table2'
59
+
60
+ beforeEach(() => {
61
+ state = {
62
+ queryReducer: {
63
+ queryText: ''
64
+ },
65
+ datasetReducer: {
66
+ dataset: {
67
+ systemName: tableName
68
+ }
69
+ }
70
+ }
71
+ })
72
+
73
+ it('returns the default query when freestyleQueryText is empty', () => {
74
+ const expectedQuery = `SELECT * FROM ${tableName}\nLIMIT 200`
75
+
76
+ const receivedQuery = getFreestyleQueryText(state)
77
+
78
+ expect(receivedQuery).toBe(expectedQuery)
79
+ })
80
+
81
+ it('returns the freestyleQueryText when it is not empty', () => {
82
+ const expectedQuery = 'SELECT something FROM somewhere LIMIT your_dreams'
83
+ state.queryReducer.queryText = expectedQuery
84
+
85
+ const receivedQuery = getFreestyleQueryText(state)
86
+
87
+ expect(receivedQuery).toBe(expectedQuery)
88
+ })
89
+ })
90
+
91
+ describe('with no dataset and no query text', () => {
92
+ it('returns an empty string', () => {
93
+ state = {
94
+ queryReducer: {},
95
+ datasetReducer: {}
96
+ }
97
+
98
+ const receivedQuery = getFreestyleQueryText(state)
99
+
100
+ expect(receivedQuery).toBe('')
101
+ })
102
+ })
103
+ })
104
+
105
+ describe('shouldAutoExecuteQuery', () => {
106
+ let state
107
+
108
+ beforeEach(() => {
109
+ state = {
110
+ queryReducer: {}
111
+ }
112
+ })
113
+
114
+ it('returns true when query has not been executed', () => {
115
+ state.queryReducer.queryHasBeenExecuted = false
116
+
117
+ expect(shouldAutoExecuteQuery(state)).toBe(true)
118
+ })
119
+
120
+ it('returns false when query has been executed', () => {
121
+ state.queryReducer.queryHasBeenExecuted = true
122
+
123
+ expect(shouldAutoExecuteQuery(state)).toBe(false)
124
+ })
125
+ })
126
+
127
+ describe('isQueryDataAvailable', () => {
128
+ let state
129
+
130
+ beforeEach(() => {
131
+ state = {
132
+ queryReducer: {}
133
+ }
134
+ })
135
+
136
+ it('returns true when query result data is available', () => {
137
+ state.queryReducer.queryData = ['some data']
138
+
139
+ expect(isQueryDataAvailable(state)).toBe(true)
140
+ })
141
+
142
+ it('returns true when query result data is available but empty', () => {
143
+ state.queryReducer.queryData = []
144
+
145
+ expect(isQueryDataAvailable(state)).toBe(true)
146
+ })
147
+
148
+ it('returns false when query result data has never been set', () => {
149
+ state.queryReducer.queryData = null
150
+
151
+ expect(isQueryDataAvailable(state)).toBe(false)
152
+ })
153
+ })
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _reducers.default;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "reducers", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _reducers.reducers;
17
+ }
18
+ });
19
+ var _reducers = _interopRequireWildcard(require("./reducers"));
20
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _actions = require("../actions");
8
+ var defaultQueryState = {
9
+ queryText: '',
10
+ queryData: null,
11
+ queryFailureMessage: '',
12
+ isQueryLoading: false,
13
+ cancelToken: null,
14
+ queryHasBeenExecuted: false
15
+ };
16
+ var _default = exports.default = function _default() {
17
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultQueryState;
18
+ var action = arguments.length > 1 ? arguments[1] : undefined;
19
+ switch (action.type) {
20
+ case _actions.SET_QUERY_TEXT:
21
+ return Object.assign({}, state, {
22
+ queryText: action.queryText
23
+ });
24
+ case _actions.CLEAR_QUERY_TEXT:
25
+ return Object.assign({}, state, {
26
+ queryText: ''
27
+ });
28
+ case _actions.SET_QUERY_SUCCESS:
29
+ return Object.assign({}, state, {
30
+ queryData: action.queryData,
31
+ queryFailureMessage: '',
32
+ isQueryLoading: false,
33
+ cancelToken: null
34
+ });
35
+ case _actions.SET_QUERY_FAILURE:
36
+ return Object.assign({}, state, {
37
+ queryFailureMessage: action.failureMessage,
38
+ isQueryLoading: false,
39
+ cancelToken: null
40
+ });
41
+ case _actions.SET_QUERY_IN_PROGRESS:
42
+ return Object.assign({}, state, {
43
+ isQueryLoading: true,
44
+ cancelToken: action.cancelToken,
45
+ queryHasBeenExecuted: true
46
+ });
47
+ case _actions.RESET_QUERY:
48
+ return defaultQueryState;
49
+ default:
50
+ return state;
51
+ }
52
+ };
@@ -0,0 +1,89 @@
1
+ import reducer from './query-reducer'
2
+
3
+ import { setQueryText, clearQueryText, setQuerySuccess, setQueryFailure, setQueryInProgress, resetQuery } from '../actions'
4
+
5
+ describe('queryReducer', () => {
6
+ it('setQueryText triggers an action that sets the queryText', () => {
7
+ const currentState = { queryText: '' }
8
+ const queryText = 'SELECT something FROM somewhere'
9
+
10
+ const newState = reducer(currentState, setQueryText(queryText))
11
+
12
+ expect(newState.queryText).toEqual(queryText)
13
+ })
14
+
15
+ it('clearQueryText triggers an action that clears the queryText', () => {
16
+ const currentState = { queryText: 'SELECT something FROM somewhere' }
17
+ const newState = reducer(currentState, clearQueryText())
18
+
19
+ expect(newState.queryText).toEqual('')
20
+ })
21
+
22
+ it('setQuerySuccess triggers an action that sets the queryData', () => {
23
+ const currentState = {
24
+ queryData: {},
25
+ queryFailureMessage: 'Maybe something',
26
+ isQueryLoading: true,
27
+ cancelToken: jest.fn()
28
+ }
29
+ const expectedData = { some: 'data' }
30
+ const newState = reducer(currentState, setQuerySuccess(expectedData))
31
+
32
+ expect(newState.queryData).toEqual(expectedData)
33
+ expect(newState.queryFailureMessage).toEqual('')
34
+ expect(newState.isQueryLoading).toBe(false)
35
+ expect(newState.cancelToken).toBe(null)
36
+ })
37
+
38
+ it('setQueryFailure triggers an action that sets the queryFailureMessage', () => {
39
+ const currentState = {
40
+ queryData: { a: 5 },
41
+ queryFailureMessage: '',
42
+ isQueryLoading: true,
43
+ cancelToken: jest.fn()
44
+ }
45
+ const expectedMessage = 'Ya done goofed'
46
+ const newState = reducer(currentState, setQueryFailure(expectedMessage))
47
+
48
+ expect(newState.queryFailureMessage).toEqual(expectedMessage)
49
+ expect(newState.queryData).toEqual(currentState.queryData)
50
+ expect(newState.isQueryLoading).toBe(false)
51
+ expect(newState.cancelToken).toBe(null)
52
+ })
53
+
54
+ it('setQueryInProgress triggers an action that sets the isQueryLoading and cancelToken', () => {
55
+ const currentState = {
56
+ isQueryLoading: false,
57
+ cancelToken: null
58
+ }
59
+ const expectedCancel = jest.fn()
60
+ const newState = reducer(currentState, setQueryInProgress(expectedCancel))
61
+
62
+ expect(newState.cancelToken).toBe(expectedCancel)
63
+ expect(newState.isQueryLoading).toBe(true)
64
+ expect(newState.queryHasBeenExecuted).toBe(true)
65
+ })
66
+
67
+ it('resetQuery resets to the default state', () => {
68
+ const currentState = {
69
+ queryText: 'select * from lucky_charms',
70
+ queryData: ['stuff'],
71
+ queryFailureMessage: 'oh noooooo',
72
+ isQueryLoading: true,
73
+ cancelToken: 'cancelled',
74
+ queryHasBeenExecuted: true
75
+ }
76
+
77
+ const newState = reducer(currentState, resetQuery())
78
+
79
+ const expected = {
80
+ queryText: '',
81
+ queryData: null,
82
+ queryFailureMessage: '',
83
+ isQueryLoading: false,
84
+ cancelToken: null,
85
+ queryHasBeenExecuted: false
86
+ }
87
+ expect(newState).toEqual(expected)
88
+ })
89
+ })
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.reducers = exports.default = void 0;
8
+ var _redux = require("redux");
9
+ var _lodash = _interopRequireDefault(require("lodash"));
10
+ var _actions = require("../actions");
11
+ var _visualizationReducer = _interopRequireDefault(require("./visualization-reducer"));
12
+ var _queryReducer = _interopRequireDefault(require("./query-reducer"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
18
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
20
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
21
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
22
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
23
+ var defaultDatasetState = {
24
+ datasets: [],
25
+ total: 0,
26
+ datasetError: false
27
+ };
28
+ var datasetReducer = function datasetReducer() {
29
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultDatasetState;
30
+ var action = arguments.length > 1 ? arguments[1] : undefined;
31
+ switch (action.type) {
32
+ case _actions.DISPLAY_ERROR:
33
+ return Object.assign({}, state, {
34
+ datasetError: true
35
+ });
36
+ case _actions.DATASET_DETAILS:
37
+ return Object.assign({}, state, {
38
+ dataset: action.value
39
+ });
40
+ case _actions.DATASET_RECOMMENDATIONS_SUCCEEDED:
41
+ return Object.assign({}, state, {
42
+ recommendations: action.value
43
+ });
44
+ case _actions.CLEAR_DATASET_DETAILS:
45
+ return Object.assign({}, state, {
46
+ dataset: undefined,
47
+ downloadedDataset: undefined,
48
+ recommendations: []
49
+ });
50
+ case _actions.DOWNLOAD_DATASET_SUCCEEDED:
51
+ return Object.assign({}, state, {
52
+ downloadedDataset: action.value
53
+ });
54
+ case _actions.DOWNLOAD_DATASET_FAILED:
55
+ return Object.assign({}, state, {
56
+ downloadedDatasetError: true
57
+ });
58
+ default:
59
+ return state;
60
+ }
61
+ };
62
+ var defaultPresentationState = {
63
+ isLoading: false,
64
+ isVisualizationQueryLoading: false,
65
+ dataset_preview: {},
66
+ datasetReferences: {},
67
+ apiKey: ''
68
+ };
69
+ var presentationReducer = function presentationReducer() {
70
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultPresentationState;
71
+ var action = arguments.length > 1 ? arguments[1] : undefined;
72
+ switch (action.type) {
73
+ case _actions.RETRIEVE_DATA_LIST:
74
+ case _actions.RETRIEVE_DATASET:
75
+ return Object.assign({}, state, {
76
+ isVisualizationQueryLoading: true
77
+ });
78
+ case _actions.RETRIEVE_DATASET_PREVIEW:
79
+ return Object.assign({}, state, {
80
+ previewLoading: true
81
+ });
82
+ case _actions.DATASET_PREVIEW:
83
+ state.dataset_preview[action.value.format] = action.value.data;
84
+ return Object.assign({}, state, {
85
+ previewLoading: false
86
+ });
87
+ case _actions.DATASET_REFERENCE:
88
+ var _action$value = action.value,
89
+ name = _action$value.name,
90
+ title = _action$value.title,
91
+ id = _action$value.id,
92
+ organization = _action$value.organization;
93
+ var clonedReferences = Object.assign({}, state.datasetReferences);
94
+ clonedReferences[action.value.id] = {
95
+ name: name,
96
+ title: title,
97
+ id: id,
98
+ org: organization.name
99
+ };
100
+ return Object.assign({}, state, {
101
+ datasetReferences: clonedReferences
102
+ });
103
+ case _actions.RESET_DATASET_REFERENCES:
104
+ return Object.assign({}, state, {
105
+ datasetReferences: {}
106
+ });
107
+ case _actions.CLEAR_DATASET_PREVIEW:
108
+ return Object.assign({}, state, {
109
+ dataset_preview: {},
110
+ previewLoading: false
111
+ });
112
+ case _actions.DATASET_DETAILS:
113
+ return Object.assign({}, state, {
114
+ isLoading: false
115
+ });
116
+ case _actions.LOGIN:
117
+ return Object.assign({}, state, {
118
+ isLoading: true
119
+ });
120
+ case _actions.LOGIN_SUCCESS:
121
+ return Object.assign({}, state, {
122
+ lastLoginAttemptFailed: false,
123
+ isLoading: false
124
+ });
125
+ case _actions.LOGIN_FAILURE:
126
+ return Object.assign({}, state, {
127
+ lastLoginAttemptFailed: true,
128
+ isLoading: false
129
+ });
130
+ case _actions.SET_GLOBAL_ERROR_STATE:
131
+ return Object.assign({}, state, {
132
+ isError: action.value.isGlobalError,
133
+ errorMessage: action.value.globalErrorMessage
134
+ });
135
+ case _actions.GENERATE_API_KEY:
136
+ return Object.assign({}, state, {
137
+ isLoading: true
138
+ });
139
+ case _actions.GENERATE_API_KEY_SUCCEEDED:
140
+ return Object.assign({}, state, {
141
+ apiKey: action.value.apiKey,
142
+ isLoading: false
143
+ });
144
+ default:
145
+ return state;
146
+ }
147
+ };
148
+ var defaultSearchState = {
149
+ isRunning: false,
150
+ searchResults: [],
151
+ searchMetadata: {}
152
+ };
153
+ var searchReducer = function searchReducer() {
154
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultSearchState;
155
+ var action = arguments.length > 1 ? arguments[1] : undefined;
156
+ switch (action.type) {
157
+ case _actions.DATASET_SEARCH:
158
+ return Object.assign({}, state, {
159
+ isRunning: true
160
+ });
161
+ case _actions.DATASET_SEARCH_SUCCEEDED:
162
+ return Object.assign({}, state, {
163
+ isRunning: false,
164
+ searchResults: action.value.results,
165
+ searchMetadata: action.value.metadata
166
+ });
167
+ default:
168
+ return state;
169
+ }
170
+ };
171
+ var updateFacets = function updateFacets(existingFacets, facetUpdates) {
172
+ var _loop = function _loop() {
173
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
174
+ facetCategory = _Object$entries$_i[0],
175
+ facetList = _Object$entries$_i[1];
176
+ facetList.forEach(function (facetValue) {
177
+ toggleFacetValue(existingFacets, facetCategory, facetValue);
178
+ });
179
+ };
180
+ for (var _i = 0, _Object$entries = Object.entries(facetUpdates || {}); _i < _Object$entries.length; _i++) {
181
+ _loop();
182
+ }
183
+ return existingFacets;
184
+ };
185
+ var toggleFacetValue = function toggleFacetValue(facets, facetCategory, facetValue) {
186
+ var facetValues = _lodash.default.get(facets, facetCategory);
187
+ Object.assign(facets || {}, _defineProperty({}, facetCategory, _lodash.default.xor(facetValues, [facetValue])));
188
+ };
189
+ var reducers = exports.reducers = {
190
+ datasetReducer: datasetReducer,
191
+ presentation: presentationReducer,
192
+ queryReducer: _queryReducer.default,
193
+ visualization: _visualizationReducer.default,
194
+ searchReducer: searchReducer
195
+ };
196
+ var combined = exports.default = (0, _redux.combineReducers)(reducers);