@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.
- package/LICENSE +201 -0
- package/README.md +118 -0
- package/lib/ReactDiscoveryUI.js +103 -0
- package/lib/ReactDiscoveryUI.scss +13 -0
- package/lib/assets/arrow.svg +6 -0
- package/lib/assets/blk-database.svg +48 -0
- package/lib/assets/chart.svg +1 -0
- package/lib/assets/down.png +0 -0
- package/lib/assets/down.svg +1 -0
- package/lib/assets/folder_icon.png +0 -0
- package/lib/assets/folder_icon.svg +1 -0
- package/lib/assets/ic_arrow.svg +15 -0
- package/lib/assets/loadingicon.svg +57 -0
- package/lib/assets/no_image.png +0 -0
- package/lib/assets/plus.png +0 -0
- package/lib/assets/plus.svg +1 -0
- package/lib/assets/user.svg +1 -0
- package/lib/auth/auth0-client-provider.js +37 -0
- package/lib/auth/auth0-client-provider.test.js +33 -0
- package/lib/auth/auth0-wrapper.js +155 -0
- package/lib/auth/auth0-wrapper.test.js +100 -0
- package/lib/components/auth0-login-zone/auth0-login-zone.js +147 -0
- package/lib/components/auth0-login-zone/auth0-login-zone.test.js +177 -0
- package/lib/components/auth0-login-zone/index.js +9 -0
- package/lib/components/code-editor/code-editor.css +173 -0
- package/lib/components/code-editor/code-editor.js +64 -0
- package/lib/components/code-editor/index.js +9 -0
- package/lib/components/collapsable-box/collapsable-box.js +81 -0
- package/lib/components/collapsable-box/collapsable-box.scss +39 -0
- package/lib/components/collapsable-box/collapsable-box.test.js +87 -0
- package/lib/components/collapsable-box/index.js +9 -0
- package/lib/components/data-card/data-card.js +63 -0
- package/lib/components/data-card/data-card.scss +93 -0
- package/lib/components/data-card/data-card.test.js +74 -0
- package/lib/components/data-card/index.js +9 -0
- package/lib/components/data-view/data-view.js +194 -0
- package/lib/components/data-view/data-view.scss +39 -0
- package/lib/components/data-view/data-view.test.js +155 -0
- package/lib/components/data-view/index.js +9 -0
- package/lib/components/dataset-api-doc/api-example.js +120 -0
- package/lib/components/dataset-api-doc/api-example.scss +84 -0
- package/lib/components/dataset-api-doc/api-example.test.js +88 -0
- package/lib/components/dataset-api-doc/dataset-api-doc.js +117 -0
- package/lib/components/dataset-api-doc/dataset-api-doc.scss +8 -0
- package/lib/components/dataset-api-doc/dataset-api-doc.test.js +42 -0
- package/lib/components/dataset-api-doc/index.js +9 -0
- package/lib/components/dataset-details/dataset-details.js +64 -0
- package/lib/components/dataset-details/dataset-details.scss +58 -0
- package/lib/components/dataset-details/dataset-details.test.js +38 -0
- package/lib/components/dataset-details/index.js +9 -0
- package/lib/components/dataset-dictionary/dataset-dictionary.js +127 -0
- package/lib/components/dataset-dictionary/dataset-dictionary.scss +42 -0
- package/lib/components/dataset-dictionary/dataset-dictionary.test.js +286 -0
- package/lib/components/dataset-dictionary/index.js +9 -0
- package/lib/components/dataset-list/dataset-list.js +22 -0
- package/lib/components/dataset-list/dataset-list.scss +9 -0
- package/lib/components/dataset-list/dataset-list.test.js +16 -0
- package/lib/components/dataset-list/index.js +9 -0
- package/lib/components/dataset-metadata/dataset-metadata.js +169 -0
- package/lib/components/dataset-metadata/dataset-metadata.scss +34 -0
- package/lib/components/dataset-metadata/dataset-metadata.test.js +24 -0
- package/lib/components/dataset-metadata/index.js +9 -0
- package/lib/components/dataset-preview/connector.js +26 -0
- package/lib/components/dataset-preview/dataset-preview.js +58 -0
- package/lib/components/dataset-preview/dataset-preview.scss +24 -0
- package/lib/components/dataset-preview/dataset-preview.test.js +34 -0
- package/lib/components/dataset-preview/index.js +9 -0
- package/lib/components/dataset-quality/dataset-quality.js +56 -0
- package/lib/components/dataset-quality/dataset-quality.scss +24 -0
- package/lib/components/dataset-quality/dataset-quality.test.js +34 -0
- package/lib/components/dataset-quality/index.js +9 -0
- package/lib/components/dataset-recommendations/connector.js +24 -0
- package/lib/components/dataset-recommendations/dataset-recommendations.js +47 -0
- package/lib/components/dataset-recommendations/dataset-recommendations.scss +17 -0
- package/lib/components/dataset-recommendations/dataset-recommendations.test.js +37 -0
- package/lib/components/dataset-recommendations/index.js +9 -0
- package/lib/components/detail-toggle-icon/detail-toggle-icon.js +41 -0
- package/lib/components/detail-toggle-icon/detail-toggle-icon.scss +13 -0
- package/lib/components/detail-toggle-icon/detail-toggle-icon.test.js +20 -0
- package/lib/components/detail-toggle-icon/index.js +9 -0
- package/lib/components/facet-list/facet-list.js +47 -0
- package/lib/components/facet-list/facet-list.scss +19 -0
- package/lib/components/facet-list/facet-list.test.js +94 -0
- package/lib/components/facet-list/index.js +9 -0
- package/lib/components/facet-sidebar/facet-sidebar.js +101 -0
- package/lib/components/facet-sidebar/facet-sidebar.scss +129 -0
- package/lib/components/facet-sidebar/facet-sidebar.test.js +93 -0
- package/lib/components/facet-sidebar/index.js +9 -0
- package/lib/components/generic-elements/alert-component/alert-component.js +51 -0
- package/lib/components/generic-elements/alert-component/alert-component.scss +26 -0
- package/lib/components/generic-elements/alert-component/alert-component.test.js +26 -0
- package/lib/components/generic-elements/alert-component/index.js +9 -0
- package/lib/components/generic-elements/arrow-button/arrow-button.js +30 -0
- package/lib/components/generic-elements/arrow-button/index.js +9 -0
- package/lib/components/generic-elements/auto-anchoring-popover/index.js +61 -0
- package/lib/components/generic-elements/back-button/back-button.js +14 -0
- package/lib/components/generic-elements/back-button/back-button.scss +14 -0
- package/lib/components/generic-elements/back-button/index.js +9 -0
- package/lib/components/generic-elements/call-to-action-button/call-to-action-button.js +118 -0
- package/lib/components/generic-elements/call-to-action-button/call-to-action-button.scss +19 -0
- package/lib/components/generic-elements/call-to-action-button/call-to-action-button.test.js +68 -0
- package/lib/components/generic-elements/call-to-action-button/index.js +9 -0
- package/lib/components/generic-elements/chart-icon/index.js +23 -0
- package/lib/components/generic-elements/checkbox/checkbox.js +50 -0
- package/lib/components/generic-elements/checkbox/checkbox.scss +44 -0
- package/lib/components/generic-elements/checkbox/checkbox.test.js +71 -0
- package/lib/components/generic-elements/checkbox/index.js +9 -0
- package/lib/components/generic-elements/error-component/error-component.js +21 -0
- package/lib/components/generic-elements/error-component/error-component.scss +16 -0
- package/lib/components/generic-elements/error-component/error-component.test.js +12 -0
- package/lib/components/generic-elements/error-component/index.js +9 -0
- package/lib/components/generic-elements/folder-icon/index.js +23 -0
- package/lib/components/generic-elements/generated-link/generated-link.js +25 -0
- package/lib/components/generic-elements/generated-link/index.js +13 -0
- package/lib/components/generic-elements/loading-element/index.js +9 -0
- package/lib/components/generic-elements/loading-element/loading-element.js +22 -0
- package/lib/components/generic-elements/loading-element/loading-element.scss +6 -0
- package/lib/components/generic-elements/loading-element/loading-element.test.js +11 -0
- package/lib/components/generic-elements/paginator/index.js +9 -0
- package/lib/components/generic-elements/paginator/paginator.js +84 -0
- package/lib/components/generic-elements/paginator/paginator.scss +38 -0
- package/lib/components/generic-elements/paginator/paginator.test.js +140 -0
- package/lib/components/generic-elements/plus-icon/index.js +21 -0
- package/lib/components/generic-elements/save-indicator/index.js +9 -0
- package/lib/components/generic-elements/save-indicator/save-indicator.js +39 -0
- package/lib/components/generic-elements/save-indicator/save-indicator.scss +31 -0
- package/lib/components/generic-elements/save-indicator/save-indicator.test.js +89 -0
- package/lib/components/generic-elements/search/index.js +9 -0
- package/lib/components/generic-elements/search/search.js +93 -0
- package/lib/components/generic-elements/search/search.scss +90 -0
- package/lib/components/generic-elements/search/search.test.js +41 -0
- package/lib/components/generic-elements/select/index.js +9 -0
- package/lib/components/generic-elements/select/select.js +44 -0
- package/lib/components/generic-elements/select/select.scss +22 -0
- package/lib/components/generic-elements/select/select.test.js +34 -0
- package/lib/components/generic-elements/share-link/index.js +9 -0
- package/lib/components/generic-elements/share-link/share-link.js +23 -0
- package/lib/components/generic-elements/share-link/share-link.scss +17 -0
- package/lib/components/generic-elements/share-link/share-link.test.js +28 -0
- package/lib/components/generic-elements/sql-icon/index.js +20 -0
- package/lib/components/generic-elements/tab-button/index.js +9 -0
- package/lib/components/generic-elements/tab-button/tab-button.js +25 -0
- package/lib/components/generic-elements/tab-button/tab-button.scss +27 -0
- package/lib/components/generic-elements/visualize-button/index.js +9 -0
- package/lib/components/generic-elements/visualize-button/visualize-button.js +37 -0
- package/lib/components/generic-elements/visualize-button/visualize-button.scss +14 -0
- package/lib/components/login-zone/connector.js +25 -0
- package/lib/components/login-zone/index.js +9 -0
- package/lib/components/login-zone/login-svgs-and-text.js +39 -0
- package/lib/components/login-zone/login-zone.js +21 -0
- package/lib/components/login-zone/login-zone.scss +115 -0
- package/lib/components/login-zone/login-zone.test.js +17 -0
- package/lib/components/login-zone/login.js +48 -0
- package/lib/components/login-zone/logout.js +39 -0
- package/lib/components/network-loading-element/connector.js +17 -0
- package/lib/components/network-loading-element/index.js +9 -0
- package/lib/components/network-loading-element/network-loading-element.js +23 -0
- package/lib/components/network-loading-element/network-loading-element.scss +21 -0
- package/lib/components/network-loading-element/network-loading-element.test.js +34 -0
- package/lib/components/organization/index.js +9 -0
- package/lib/components/organization/organization.js +27 -0
- package/lib/components/organization/organization.scss +32 -0
- package/lib/components/protected-route/protected-route.js +101 -0
- package/lib/components/protected-route/protected-route.scss +4 -0
- package/lib/components/protected-route/protected-route.test.js +63 -0
- package/lib/components/query-form/index.js +9 -0
- package/lib/components/query-form/query-form.js +262 -0
- package/lib/components/query-form/query-form.scss +167 -0
- package/lib/components/query-form/query-form.test.js +248 -0
- package/lib/components/recommendation-list/index.js +9 -0
- package/lib/components/recommendation-list/recommendation-list.js +72 -0
- package/lib/components/recommendation-list/recommendation-list.scss +61 -0
- package/lib/components/recommendation-list/recommendation-list.test.js +38 -0
- package/lib/components/remote-toggle/__snapshots__/remote-toggle.test.js.snap +3 -0
- package/lib/components/remote-toggle/index.js +13 -0
- package/lib/components/remote-toggle/remote-toggle.js +35 -0
- package/lib/components/remote-toggle/remote-toggle.scss +0 -0
- package/lib/components/remote-toggle/remote-toggle.test.js +10 -0
- package/lib/components/share/index.js +9 -0
- package/lib/components/share/share.js +109 -0
- package/lib/components/share/share.scss +66 -0
- package/lib/components/streaming-api-doc/index.js +9 -0
- package/lib/components/streaming-api-doc/streaming-api-doc.js +76 -0
- package/lib/components/streaming-api-doc/streaming-api-doc.scss +23 -0
- package/lib/components/streaming-api-doc/streaming-api-doc.test.js +24 -0
- package/lib/components/tooltip/index.js +9 -0
- package/lib/components/tooltip/tooltip.js +17 -0
- package/lib/components/tooltip/tooltip.scss +16 -0
- package/lib/components/tooltip/tooltip.test.js +19 -0
- package/lib/components/visualization-list-menu-item/index.js +9 -0
- package/lib/components/visualization-list-menu-item/visualization-list-menu-item.js +53 -0
- package/lib/components/visualization-list-menu-item/visualization-list-menu-item.scss +21 -0
- package/lib/components/visualization-list-menu-item/visualization-list-menu-item.test.js +42 -0
- package/lib/components/visualization-save-menu-item/index.js +9 -0
- package/lib/components/visualization-save-menu-item/visualization-save-menu-item.js +101 -0
- package/lib/components/visualization-save-menu-item/visualization-save-menu-item.scss +37 -0
- package/lib/components/visualization-save-menu-item/visualization-save-menu-item.test.js +185 -0
- package/lib/components/visualizations/geojson/connector.js +29 -0
- package/lib/components/visualizations/geojson/geojson-visualization.js +151 -0
- package/lib/components/visualizations/geojson/geojson-visualization.scss +24 -0
- package/lib/components/visualizations/geojson/geojson-visualization.test.js +238 -0
- package/lib/components/visualizations/geojson/index.js +9 -0
- package/lib/pages/apikey-view/apiKey-view.test.js +204 -0
- package/lib/pages/apikey-view/apikey-view.js +166 -0
- package/lib/pages/apikey-view/apikey-view.scss +340 -0
- package/lib/pages/apikey-view/connector.js +31 -0
- package/lib/pages/apikey-view/index.js +9 -0
- package/lib/pages/chart-view/chart-view.js +92 -0
- package/lib/pages/chart-view/chart-view.scss +35 -0
- package/lib/pages/chart-view/chart-view.test.js +206 -0
- package/lib/pages/chart-view/connector.js +30 -0
- package/lib/pages/chart-view/index.js +9 -0
- package/lib/pages/dataset-detail-view/connector.js +38 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view-connector.test.js +42 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view.js +99 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view.scss +190 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view.test.js +305 -0
- package/lib/pages/dataset-detail-view/index.js +9 -0
- package/lib/pages/dataset-list-view/connector.js +30 -0
- package/lib/pages/dataset-list-view/dataset-list-view.js +132 -0
- package/lib/pages/dataset-list-view/dataset-list-view.scss +242 -0
- package/lib/pages/dataset-list-view/dataset-list-view.test.js +162 -0
- package/lib/pages/dataset-list-view/index.js +9 -0
- package/lib/pages/dataset-view/connector.js +55 -0
- package/lib/pages/dataset-view/dataset-view-connector.test.js +78 -0
- package/lib/pages/dataset-view/dataset-view.js +175 -0
- package/lib/pages/dataset-view/dataset-view.scss +95 -0
- package/lib/pages/dataset-view/dataset-view.test.js +157 -0
- package/lib/pages/dataset-view/index.js +9 -0
- package/lib/pages/login-view/connector.js +25 -0
- package/lib/pages/login-view/index.js +9 -0
- package/lib/pages/login-view/login-view.js +83 -0
- package/lib/pages/login-view/login-view.scss +62 -0
- package/lib/pages/login-view/login-view.test.js +23 -0
- package/lib/pages/oauth-error-view/index.js +9 -0
- package/lib/pages/oauth-error-view/oauth-error-view.js +25 -0
- package/lib/pages/oauth-error-view/oauth-error-view.scss +13 -0
- package/lib/pages/oauth-error-view/oauth-error-view.test.js +13 -0
- package/lib/pages/oauth-view/connector.js +22 -0
- package/lib/pages/oauth-view/index.js +9 -0
- package/lib/pages/oauth-view/oauth-view.js +124 -0
- package/lib/pages/oauth-view/oauth-view.scss +7 -0
- package/lib/pages/oauth-view/oauth-view.test.js +195 -0
- package/lib/pages/query-view/connector.js +40 -0
- package/lib/pages/query-view/index.js +9 -0
- package/lib/pages/query-view/query-view.js +80 -0
- package/lib/pages/query-view/query-view.scss +39 -0
- package/lib/pages/query-view/query-view.test.js +104 -0
- package/lib/pages/user-profile-view/connector.js +39 -0
- package/lib/pages/user-profile-view/index.js +9 -0
- package/lib/pages/user-profile-view/user-profile-view.js +154 -0
- package/lib/pages/user-profile-view/user-profile-view.scss +81 -0
- package/lib/pages/user-profile-view/user-profile-view.test.js +129 -0
- package/lib/pages/visualization-view/connector.js +52 -0
- package/lib/pages/visualization-view/index.js +9 -0
- package/lib/pages/visualization-view/visualization-view-connector.test.js +62 -0
- package/lib/pages/visualization-view/visualization-view.js +128 -0
- package/lib/pages/visualization-view/visualization-view.scss +115 -0
- package/lib/pages/visualization-view/visualization-view.test.js +188 -0
- package/lib/routes.js +18 -0
- package/lib/search-params/search-params-manager.js +171 -0
- package/lib/search-params/search-params-manager.test.js +490 -0
- package/lib/store/actions.js +428 -0
- package/lib/store/dataset-selectors.js +47 -0
- package/lib/store/dataset-selectors.test.js +154 -0
- package/lib/store/query-selectors.js +53 -0
- package/lib/store/query-selectors.test.js +153 -0
- package/lib/store/reducers/index.js +20 -0
- package/lib/store/reducers/query-reducer.js +52 -0
- package/lib/store/reducers/query-reducer.test.js +89 -0
- package/lib/store/reducers/reducers.js +196 -0
- package/lib/store/reducers/reducers.test.js +309 -0
- package/lib/store/reducers/visualization-reducer.js +167 -0
- package/lib/store/reducers/visualization-reducer.test.js +426 -0
- package/lib/store/sagas/api-invoker.js +79 -0
- package/lib/store/sagas/api-invoker.test.js +139 -0
- package/lib/store/sagas/apiKey-saga.js +81 -0
- package/lib/store/sagas/apiKey-saga.test.js +57 -0
- package/lib/store/sagas/dataset-download-saga.js +43 -0
- package/lib/store/sagas/dataset-list-saga.js +49 -0
- package/lib/store/sagas/dataset-list-saga.test.js +72 -0
- package/lib/store/sagas/dataset-preview-saga.js +44 -0
- package/lib/store/sagas/dataset-query-saga.js +43 -0
- package/lib/store/sagas/dataset-recommendation-saga.js +40 -0
- package/lib/store/sagas/dataset-saga.js +50 -0
- package/lib/store/sagas/freestyle-query-saga.js +127 -0
- package/lib/store/sagas/freestyle-query-saga.test.js +145 -0
- package/lib/store/sagas/index.js +44 -0
- package/lib/store/sagas/login-saga.js +85 -0
- package/lib/store/sagas/login-saga.test.js +84 -0
- package/lib/store/sagas/logout-saga.js +96 -0
- package/lib/store/sagas/oauth-saga.js +78 -0
- package/lib/store/sagas/oauth-saga.test.js +51 -0
- package/lib/store/sagas/process-login-saga.js +62 -0
- package/lib/store/sagas/process-login-saga.test.js +83 -0
- package/lib/store/sagas/visualization-saga.js +371 -0
- package/lib/store/sagas/visualization-saga.test.js +388 -0
- package/lib/store/selectors.js +83 -0
- package/lib/store/visualization-selectors.js +85 -0
- package/lib/store/visualization-selectors.test.js +195 -0
- package/lib/styles/mixins.scss +117 -0
- package/lib/styles/variables.scss +41 -0
- package/lib/utils/file-type-utils.js +18 -0
- package/lib/utils/file-type-utils.test.js +29 -0
- package/lib/utils/geojson-utils.js +70 -0
- package/lib/utils/geojson-utils.test.js +129 -0
- package/lib/utils/http-clients.js +218 -0
- package/lib/utils/http-clients.test.js +88 -0
- package/lib/utils/index.js +34 -0
- package/lib/utils/modified-date-string-builder.js +29 -0
- package/lib/utils/modified-date-string-builder.test.js +93 -0
- package/lib/utils/query-string-builder.js +38 -0
- package/lib/utils/query-string-builder.test.js +33 -0
- package/lib/utils/recommendation-utils.js +12 -0
- package/lib/utils/recommendation-utils.test.js +9 -0
- package/package.json +172 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import reducer from './index'
|
|
2
|
+
import {
|
|
3
|
+
DISPLAY_ERROR,
|
|
4
|
+
DATASET_DETAILS,
|
|
5
|
+
RETRIEVE_DATASET_PREVIEW,
|
|
6
|
+
DATASET_PREVIEW,
|
|
7
|
+
DATASET_REFERENCE,
|
|
8
|
+
RESET_DATASET_REFERENCES,
|
|
9
|
+
CLEAR_DATASET_DETAILS,
|
|
10
|
+
LOGIN,
|
|
11
|
+
LOGIN_SUCCESS,
|
|
12
|
+
LOGIN_FAILURE,
|
|
13
|
+
DOWNLOAD_DATASET_SUCCEEDED,
|
|
14
|
+
CLEAR_DATASET_PREVIEW,
|
|
15
|
+
DATASET_SEARCH,
|
|
16
|
+
DATASET_SEARCH_SUCCEEDED, GENERATE_API_KEY_SUCCEEDED, GENERATE_API_KEY
|
|
17
|
+
} from '../actions'
|
|
18
|
+
import datasetStub from '../../../stubs/dataset-details-stub'
|
|
19
|
+
|
|
20
|
+
describe('Dataset Reducer', () => {
|
|
21
|
+
it('DISPLAY_ERROR sets datasetError to true', () => {
|
|
22
|
+
const currentState = {
|
|
23
|
+
datasetReducer: {
|
|
24
|
+
datasetError: false
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const newState = reducer(currentState, { type: DISPLAY_ERROR })
|
|
28
|
+
|
|
29
|
+
expect(newState.datasetReducer.datasetError).toEqual(true)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('DATASET_DETAILS places dataset in the state', () => {
|
|
33
|
+
const currentState = {}
|
|
34
|
+
const newState = reducer(currentState, {
|
|
35
|
+
type: DATASET_DETAILS,
|
|
36
|
+
value: datasetStub
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
expect(newState.datasetReducer.dataset).toEqual(datasetStub)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('DOWNLOAD_DATASET_SUCCEEDED places downloaded data in state', () => {
|
|
43
|
+
const currentState = {}
|
|
44
|
+
const response = { id: 123 }
|
|
45
|
+
|
|
46
|
+
const newState = reducer(currentState, {
|
|
47
|
+
type: DOWNLOAD_DATASET_SUCCEEDED,
|
|
48
|
+
value: response
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
expect(newState.datasetReducer.downloadedDataset).toEqual(response)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
describe('CLEAR_DATASET_DETAILS', () => {
|
|
55
|
+
const currentState = {
|
|
56
|
+
datasetReducer: {
|
|
57
|
+
dataset: { id: 123 },
|
|
58
|
+
downloadedDataset: { id: 123 },
|
|
59
|
+
recommendations: [{ id: 123 }]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
let newState
|
|
63
|
+
|
|
64
|
+
beforeEach(() => {
|
|
65
|
+
newState = reducer(currentState, { type: CLEAR_DATASET_DETAILS })
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('clears dataset', () => {
|
|
69
|
+
expect(newState.datasetReducer.dataset).toEqual(undefined)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('clears downloadedDataset', () => {
|
|
73
|
+
expect(newState.datasetReducer.downloadedDataset).toEqual(undefined)
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('clears recommendations', () => {
|
|
77
|
+
expect(newState.datasetReducer.recommendations).toEqual([])
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
describe('UI Reducer', () => {
|
|
83
|
+
it('RETRIEVE_DATASET_PREVIEW sets previewLoading to true', () => {
|
|
84
|
+
const currentState = {
|
|
85
|
+
presentation: {
|
|
86
|
+
previewLoading: false
|
|
87
|
+
},
|
|
88
|
+
queryReducer: {
|
|
89
|
+
isVisualizationQueryLoading: false
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const newState = reducer(currentState, { type: RETRIEVE_DATASET_PREVIEW })
|
|
93
|
+
|
|
94
|
+
expect(newState.presentation.previewLoading).toEqual(true)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('DATASET_PREIVEW sets previewLoading to false', () => {
|
|
98
|
+
const currentState = {
|
|
99
|
+
presentation: {
|
|
100
|
+
previewLoading: true,
|
|
101
|
+
dataset_preview: {}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const newState = reducer(currentState, { value: {}, type: DATASET_PREVIEW })
|
|
105
|
+
|
|
106
|
+
expect(newState.presentation.previewLoading).toEqual(false)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('DATASET_PREVIEW sets dataset_preview', () => {
|
|
110
|
+
const currentState = {
|
|
111
|
+
presentation: { dataset_preview: {} }
|
|
112
|
+
}
|
|
113
|
+
const expectedData = {
|
|
114
|
+
firstName: 'Joe',
|
|
115
|
+
lastName: 'Smith'
|
|
116
|
+
}
|
|
117
|
+
const actionValue = {
|
|
118
|
+
data: expectedData,
|
|
119
|
+
format: 'json'
|
|
120
|
+
}
|
|
121
|
+
const newState = reducer(currentState, {
|
|
122
|
+
type: DATASET_PREVIEW,
|
|
123
|
+
value: actionValue
|
|
124
|
+
})
|
|
125
|
+
expect(newState.presentation.dataset_preview.json).toEqual(expectedData)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('CLEAR_DATASET_PREVIEW clears out preview data', () => {
|
|
129
|
+
const currentState = {
|
|
130
|
+
presentation: {
|
|
131
|
+
dataset_preview: 'something',
|
|
132
|
+
previewLoading: true
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const expectedData = {
|
|
136
|
+
dataset_preview: {},
|
|
137
|
+
previewLoading: false
|
|
138
|
+
}
|
|
139
|
+
const newState = reducer(currentState, { type: CLEAR_DATASET_PREVIEW })
|
|
140
|
+
|
|
141
|
+
expect(newState.presentation).toEqual(expectedData)
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('DATASET_REFERENCE sets datasetReferences', () => {
|
|
145
|
+
const currentState = {
|
|
146
|
+
presentation: { datasetReferences: {} }
|
|
147
|
+
}
|
|
148
|
+
const dataset = {
|
|
149
|
+
name: 'dName',
|
|
150
|
+
title: 'Title D#',
|
|
151
|
+
id: '123',
|
|
152
|
+
organization: {
|
|
153
|
+
name: 'oName'
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const expectedData = {
|
|
157
|
+
123: { name: 'dName', org: 'oName', title: 'Title D#', id: '123' }
|
|
158
|
+
}
|
|
159
|
+
const actionValue = dataset
|
|
160
|
+
const newState = reducer(currentState, {
|
|
161
|
+
type: DATASET_REFERENCE,
|
|
162
|
+
value: actionValue
|
|
163
|
+
})
|
|
164
|
+
expect(newState.presentation.datasetReferences).toEqual(expectedData)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it('RESET_DATASET_REFERENCES removes all dataset references', () => {
|
|
168
|
+
const currentState = {
|
|
169
|
+
presentation: {
|
|
170
|
+
datasetReferences: {
|
|
171
|
+
123: { name: 'dName', org: 'oName', title: 'Title D#', id: '123' }
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const dataset = {
|
|
176
|
+
name: 'dName',
|
|
177
|
+
title: 'Title D#',
|
|
178
|
+
id: '123',
|
|
179
|
+
organization: {
|
|
180
|
+
name: 'oName'
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const expectedData = {}
|
|
184
|
+
const actionValue = dataset
|
|
185
|
+
const newState = reducer(currentState, {
|
|
186
|
+
type: RESET_DATASET_REFERENCES,
|
|
187
|
+
value: actionValue
|
|
188
|
+
})
|
|
189
|
+
expect(newState.presentation.datasetReferences).toEqual(expectedData)
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
it('LOGIN sets loading to true', () => {
|
|
193
|
+
const currentState = {
|
|
194
|
+
presentation: {
|
|
195
|
+
isLoading: false
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const newState = reducer(currentState, { type: LOGIN })
|
|
199
|
+
|
|
200
|
+
expect(newState.presentation.isLoading).toEqual(true)
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
it('LOGIN_SUCCESS sets lastLoginAttemptFailed to false', () => {
|
|
204
|
+
const currentState = {
|
|
205
|
+
presentation: {
|
|
206
|
+
lastLoginAttemptFailed: true
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const newState = reducer(currentState, { type: LOGIN_SUCCESS })
|
|
210
|
+
|
|
211
|
+
expect(newState.presentation.lastLoginAttemptFailed).toEqual(false)
|
|
212
|
+
expect(newState.presentation.isLoading).toEqual(false)
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
it('LOGIN_FAILURE sets lastLoginAttemptFailed to true', () => {
|
|
216
|
+
const currentState = {
|
|
217
|
+
presentation: {
|
|
218
|
+
lastLoginAttemptFailed: false
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const newState = reducer(currentState, { type: LOGIN_FAILURE })
|
|
222
|
+
|
|
223
|
+
expect(newState.presentation.lastLoginAttemptFailed).toEqual(true)
|
|
224
|
+
expect(newState.presentation.isLoading).toEqual(false)
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
it('GENERATE_API_KEY sets isLoading to true', () => {
|
|
228
|
+
const currentState = {
|
|
229
|
+
presentation: {
|
|
230
|
+
isLoading: false
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const newState = reducer(currentState, { value: { }, type: GENERATE_API_KEY })
|
|
234
|
+
|
|
235
|
+
expect(newState.presentation.isLoading).toEqual(true)
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
it('GENERATE_API_KEY_SUCCEEDED sets apiKey to the obtained value', () => {
|
|
239
|
+
const expectedApiKey = 'newApiKey'
|
|
240
|
+
const currentState = {
|
|
241
|
+
presentation: {
|
|
242
|
+
apiKey: 'oldApiKey'
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const newState = reducer(currentState, { value: { apiKey: expectedApiKey }, type: GENERATE_API_KEY_SUCCEEDED })
|
|
246
|
+
|
|
247
|
+
expect(newState.presentation.apiKey).toEqual(expectedApiKey)
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
it('GENERATE_API_KEY_SUCCEEDED sets isLoading to false', () => {
|
|
251
|
+
const currentState = {
|
|
252
|
+
presentation: {
|
|
253
|
+
isLoading: true
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const newState = reducer(currentState, { value: { }, type: GENERATE_API_KEY_SUCCEEDED })
|
|
257
|
+
|
|
258
|
+
expect(newState.presentation.isLoading).toEqual(false)
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
describe('Search Reducer', () => {
|
|
263
|
+
it('DATASET_SEARCH sets isRunning to true', () => {
|
|
264
|
+
const currentState = {
|
|
265
|
+
searchReducer: {
|
|
266
|
+
isRunning: false
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const newState = reducer(currentState, { type: DATASET_SEARCH })
|
|
270
|
+
|
|
271
|
+
expect(newState.searchReducer.isRunning).toEqual(true)
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
it('DATASET_SEARCH_SUCCEEDED sets searchResults and metadata in the state', () => {
|
|
275
|
+
const currentState = {
|
|
276
|
+
searchReducer: {
|
|
277
|
+
searchResults: {}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const expectedData = {
|
|
281
|
+
results: [{ this: 'bob', that: 'joe' }],
|
|
282
|
+
metadata: ['metadata']
|
|
283
|
+
}
|
|
284
|
+
const newState = reducer(currentState, {
|
|
285
|
+
type: DATASET_SEARCH_SUCCEEDED,
|
|
286
|
+
value: expectedData
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
expect(newState.searchReducer.searchResults).toEqual(expectedData.results)
|
|
290
|
+
expect(newState.searchReducer.searchMetadata).toEqual(
|
|
291
|
+
expectedData.metadata
|
|
292
|
+
)
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
it('DATASET_SEARCH_SUCCEEDED sets isRunning to false', () => {
|
|
296
|
+
const currentState = {
|
|
297
|
+
searchReducer: {
|
|
298
|
+
isRunning: true
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const expectedData = []
|
|
302
|
+
const newState = reducer(currentState, {
|
|
303
|
+
type: DATASET_SEARCH_SUCCEEDED,
|
|
304
|
+
value: expectedData
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
expect(newState.searchReducer.isRunning).toEqual(false)
|
|
308
|
+
})
|
|
309
|
+
})
|
|
@@ -0,0 +1,167 @@
|
|
|
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 _lodash = require("lodash");
|
|
9
|
+
var _reactRouterDom = require("react-router-dom");
|
|
10
|
+
var _luxon = require("luxon");
|
|
11
|
+
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); }
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return 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
|
+
var defaultVisualizationState = {
|
|
18
|
+
visualization: {
|
|
19
|
+
id: undefined
|
|
20
|
+
},
|
|
21
|
+
chart: {
|
|
22
|
+
data: [],
|
|
23
|
+
layout: {},
|
|
24
|
+
frames: []
|
|
25
|
+
},
|
|
26
|
+
loading: false,
|
|
27
|
+
loadSuccess: false,
|
|
28
|
+
loadFailure: false,
|
|
29
|
+
saving: false,
|
|
30
|
+
saveSuccess: false,
|
|
31
|
+
saveFailure: false,
|
|
32
|
+
deleting: false,
|
|
33
|
+
deleteSuccess: false,
|
|
34
|
+
deleteFailure: false
|
|
35
|
+
};
|
|
36
|
+
var visualizationReducer = function visualizationReducer() {
|
|
37
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultVisualizationState;
|
|
38
|
+
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
39
|
+
switch (action.type) {
|
|
40
|
+
case _actions.VISUALIZATION_LOAD:
|
|
41
|
+
return Object.assign({}, state, {
|
|
42
|
+
loading: true,
|
|
43
|
+
loadSuccess: false,
|
|
44
|
+
loadFailure: false
|
|
45
|
+
});
|
|
46
|
+
case _actions.VISUALIZATION_LOAD_SUCCESS:
|
|
47
|
+
return Object.assign({}, state, {
|
|
48
|
+
visualization: action.value,
|
|
49
|
+
loading: false,
|
|
50
|
+
loadSuccess: true,
|
|
51
|
+
loadFailure: false
|
|
52
|
+
});
|
|
53
|
+
case _actions.VISUALIZATION_LOAD_FAILURE:
|
|
54
|
+
return Object.assign({}, state, {
|
|
55
|
+
loading: false,
|
|
56
|
+
loadSuccess: false,
|
|
57
|
+
loadFailure: true
|
|
58
|
+
});
|
|
59
|
+
case _actions.VISUALIZATIONS_LOAD_ALL:
|
|
60
|
+
return Object.assign({}, state, {
|
|
61
|
+
loading: true,
|
|
62
|
+
loadSuccess: false,
|
|
63
|
+
loadFailure: false
|
|
64
|
+
});
|
|
65
|
+
case _actions.VISUALIZATIONS_LOAD_ALL_SUCCESS:
|
|
66
|
+
return Object.assign({}, state, {
|
|
67
|
+
userVisualizations: formatVisualizationsForTable(action.value),
|
|
68
|
+
loading: false,
|
|
69
|
+
loadSuccess: true,
|
|
70
|
+
loadFailure: false
|
|
71
|
+
});
|
|
72
|
+
case _actions.VISUALIZATIONS_LOAD_ALL_FAILURE:
|
|
73
|
+
return Object.assign({}, state, {
|
|
74
|
+
loading: false,
|
|
75
|
+
loadSuccess: false,
|
|
76
|
+
loadFailure: true
|
|
77
|
+
});
|
|
78
|
+
case _actions.VISUALIZATION_DELETE:
|
|
79
|
+
return Object.assign({}, state, {
|
|
80
|
+
deleteFailure: false,
|
|
81
|
+
deleteSuccess: false,
|
|
82
|
+
deleting: true
|
|
83
|
+
});
|
|
84
|
+
case _actions.VISUALIZATION_DELETE_FAILURE:
|
|
85
|
+
return Object.assign({}, state, {
|
|
86
|
+
deleteFailure: true,
|
|
87
|
+
deleting: false
|
|
88
|
+
});
|
|
89
|
+
case _actions.VISUALIZATION_DELETE_SUCCESS:
|
|
90
|
+
return Object.assign({}, state, {
|
|
91
|
+
deleteSuccess: true,
|
|
92
|
+
deleting: false
|
|
93
|
+
});
|
|
94
|
+
case _actions.VISUALIZATION_DELETE_CLEAR:
|
|
95
|
+
return Object.assign({}, state, {
|
|
96
|
+
deleteSuccess: false,
|
|
97
|
+
deleteFailure: false,
|
|
98
|
+
deleting: false
|
|
99
|
+
});
|
|
100
|
+
case _actions.VISUALIZATION_SAVE:
|
|
101
|
+
return Object.assign({}, state, {
|
|
102
|
+
saving: true,
|
|
103
|
+
saveSuccess: false,
|
|
104
|
+
saveFailure: false
|
|
105
|
+
});
|
|
106
|
+
case _actions.VISUALIZATION_SAVE_SUCCESS:
|
|
107
|
+
return Object.assign({}, state, {
|
|
108
|
+
visualization: action.value,
|
|
109
|
+
saving: false,
|
|
110
|
+
saveSuccess: true,
|
|
111
|
+
saveFailure: false
|
|
112
|
+
});
|
|
113
|
+
case _actions.VISUALIZATION_SAVE_FAILURE:
|
|
114
|
+
return Object.assign({}, state, {
|
|
115
|
+
saving: false,
|
|
116
|
+
saveSuccess: false,
|
|
117
|
+
saveFailure: true
|
|
118
|
+
});
|
|
119
|
+
case _actions.SET_CHART_INFORMATION:
|
|
120
|
+
return Object.assign({}, state, {
|
|
121
|
+
chart: constructValidChart(action.value)
|
|
122
|
+
});
|
|
123
|
+
case _actions.VISUALIZATION_RESET:
|
|
124
|
+
return defaultVisualizationState;
|
|
125
|
+
default:
|
|
126
|
+
return state;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
var constructValidChart = function constructValidChart(_ref) {
|
|
130
|
+
var data = _ref.data,
|
|
131
|
+
frames = _ref.frames,
|
|
132
|
+
layout = _ref.layout;
|
|
133
|
+
return {
|
|
134
|
+
data: isValidChartData(data) ? data : [],
|
|
135
|
+
frames: isValidChartFrames(frames) ? frames : [],
|
|
136
|
+
layout: isValidChartLayout(layout) ? layout : {}
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
var isValidChartData = function isValidChartData(data) {
|
|
140
|
+
return (0, _lodash.isArray)(data) && data.every(_lodash.isPlainObject);
|
|
141
|
+
};
|
|
142
|
+
var isValidChartFrames = function isValidChartFrames(frames) {
|
|
143
|
+
return (0, _lodash.isArray)(frames) && frames.every(_lodash.isPlainObject);
|
|
144
|
+
};
|
|
145
|
+
var isValidChartLayout = function isValidChartLayout(layout) {
|
|
146
|
+
return (0, _lodash.isPlainObject)(layout);
|
|
147
|
+
};
|
|
148
|
+
var utcToLocalTime = function utcToLocalTime(utcString) {
|
|
149
|
+
return _luxon.DateTime.fromISO(utcString, {
|
|
150
|
+
zone: 'utc'
|
|
151
|
+
}).toLocal().toISO({
|
|
152
|
+
includeOffset: false,
|
|
153
|
+
suppressMilliseconds: true
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
var formatVisualizationsForTable = function formatVisualizationsForTable(visualizations) {
|
|
157
|
+
return visualizations.map(function (visualization) {
|
|
158
|
+
return _objectSpread(_objectSpread({}, visualization), {}, {
|
|
159
|
+
title: /*#__PURE__*/React.createElement(_reactRouterDom.Link, {
|
|
160
|
+
to: "/visualization/".concat(visualization.id)
|
|
161
|
+
}, visualization.title),
|
|
162
|
+
created: utcToLocalTime(visualization.created),
|
|
163
|
+
updated: utcToLocalTime(visualization.updated)
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
var _default = exports.default = visualizationReducer;
|