@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,340 @@
|
|
|
1
|
+
@import '../../styles/mixins.scss';
|
|
2
|
+
|
|
3
|
+
.apiKey-view-title {
|
|
4
|
+
|
|
5
|
+
font-style: normal;
|
|
6
|
+
font-weight: 700;
|
|
7
|
+
font-size: 24px;
|
|
8
|
+
line-height: 28px;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
padding-bottom: 20px;
|
|
12
|
+
|
|
13
|
+
color: $black;
|
|
14
|
+
|
|
15
|
+
flex: none;
|
|
16
|
+
flex-grow: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.apiKey-view-paragraph {
|
|
20
|
+
font-style: normal;
|
|
21
|
+
font-weight: 400;
|
|
22
|
+
font-size: 16px;
|
|
23
|
+
line-height: 24px;
|
|
24
|
+
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
|
|
28
|
+
color: $black;
|
|
29
|
+
|
|
30
|
+
padding-bottom: 65px;
|
|
31
|
+
|
|
32
|
+
flex: none;
|
|
33
|
+
flex-grow: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.apiKey-view-container {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
align-items: flex-start;
|
|
40
|
+
padding: 40px 30px;
|
|
41
|
+
margin: 20px 20px;
|
|
42
|
+
gap: 20px;
|
|
43
|
+
box-shadow: 0 0 6px gray;
|
|
44
|
+
min-width: 400px;
|
|
45
|
+
|
|
46
|
+
background: $white;
|
|
47
|
+
|
|
48
|
+
flex: none;
|
|
49
|
+
align-self: stretch;
|
|
50
|
+
flex-grow: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.apiKey-view-generate-button {
|
|
54
|
+
@include button();
|
|
55
|
+
display: flex;
|
|
56
|
+
|
|
57
|
+
padding: 1rem;
|
|
58
|
+
background-color: $light-blue;
|
|
59
|
+
color: white;
|
|
60
|
+
letter-spacing: 0.05rem;
|
|
61
|
+
margin: 1rem 1rem 1rem 0rem;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.modal-container {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
align-items: flex-start;
|
|
68
|
+
position: absolute;
|
|
69
|
+
top: 50%;
|
|
70
|
+
left: 50%;
|
|
71
|
+
transform: translate(-50%, -50%);
|
|
72
|
+
|
|
73
|
+
padding: 40px 30px;
|
|
74
|
+
margin: 20px 20px;
|
|
75
|
+
gap: 20px;
|
|
76
|
+
box-shadow: 0 0 6px gray;
|
|
77
|
+
max-width: 800px;
|
|
78
|
+
|
|
79
|
+
background: $white;
|
|
80
|
+
|
|
81
|
+
align-self: stretch;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.modal-header-box {
|
|
85
|
+
display: flex;
|
|
86
|
+
width: 100%;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.MuiSvgIcon-root.modal-close-button {
|
|
90
|
+
|
|
91
|
+
height: 1.5em;
|
|
92
|
+
width: 1.5em;
|
|
93
|
+
|
|
94
|
+
&:hover {
|
|
95
|
+
background-color: $light-gray;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.modal-title {
|
|
100
|
+
font-style: normal;
|
|
101
|
+
font-weight: 700;
|
|
102
|
+
font-size: 24px;
|
|
103
|
+
line-height: 28px;
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
text-transform: capitalize;
|
|
107
|
+
|
|
108
|
+
color: $black;
|
|
109
|
+
|
|
110
|
+
flex: none;
|
|
111
|
+
flex: 9
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.modal-paragraph {
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-direction: row;
|
|
117
|
+
align-items: center;
|
|
118
|
+
padding: 20px 13px;
|
|
119
|
+
margin-bottom: 100px;
|
|
120
|
+
gap: 10px;
|
|
121
|
+
|
|
122
|
+
background: $warning-background;
|
|
123
|
+
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
124
|
+
border-radius: 2px;
|
|
125
|
+
|
|
126
|
+
flex: none;
|
|
127
|
+
flex-grow: 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
hr.solid {
|
|
131
|
+
border: 1px solid $light-gray;
|
|
132
|
+
width: 100%;
|
|
133
|
+
flex: none;
|
|
134
|
+
align-self: stretch;
|
|
135
|
+
flex-grow: 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.apikey-modal-warning-icon-container {
|
|
139
|
+
display: flex;
|
|
140
|
+
flex: 1;
|
|
141
|
+
width: 100%;
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.MuiSvgIcon-root.apikey-modal-warning-icon {
|
|
146
|
+
|
|
147
|
+
height: 2em;
|
|
148
|
+
width: 2em;
|
|
149
|
+
color: $error-color;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.paragraph-text {
|
|
153
|
+
display: flex;
|
|
154
|
+
|
|
155
|
+
flex: 15;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.modal-button-group {
|
|
159
|
+
display: flex;
|
|
160
|
+
justify-content: space-between;
|
|
161
|
+
width: 100%;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.modal-confirm-button {
|
|
165
|
+
box-sizing: border-box;
|
|
166
|
+
|
|
167
|
+
display: flex;
|
|
168
|
+
flex-direction: row;
|
|
169
|
+
align-items: center;
|
|
170
|
+
padding: 15px 50px;
|
|
171
|
+
gap: 10px;
|
|
172
|
+
|
|
173
|
+
border: 1px solid $error-color;
|
|
174
|
+
|
|
175
|
+
flex: none;
|
|
176
|
+
flex-grow: 0;
|
|
177
|
+
|
|
178
|
+
font-style: normal;
|
|
179
|
+
font-weight: 700;
|
|
180
|
+
font-size: 20px;
|
|
181
|
+
|
|
182
|
+
color: $error-color;
|
|
183
|
+
|
|
184
|
+
background: none;
|
|
185
|
+
|
|
186
|
+
&:hover {
|
|
187
|
+
background-color: $error-color;
|
|
188
|
+
color: white;
|
|
189
|
+
border: 1px solid $error-color;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.modal-cancel-button {
|
|
195
|
+
|
|
196
|
+
display: flex;
|
|
197
|
+
flex-direction: row;
|
|
198
|
+
justify-content: center;
|
|
199
|
+
align-items: center;
|
|
200
|
+
padding: 15px 50px;
|
|
201
|
+
gap: 10px;
|
|
202
|
+
|
|
203
|
+
flex: none;
|
|
204
|
+
flex-grow: 0;
|
|
205
|
+
|
|
206
|
+
font-style: normal;
|
|
207
|
+
font-weight: 700;
|
|
208
|
+
font-size: 20px;
|
|
209
|
+
|
|
210
|
+
background: none;
|
|
211
|
+
|
|
212
|
+
border: none;
|
|
213
|
+
|
|
214
|
+
&:hover {
|
|
215
|
+
background: $light-grey;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.loading-spinner-container {
|
|
221
|
+
position: absolute;
|
|
222
|
+
top: 0;
|
|
223
|
+
left: 0;
|
|
224
|
+
width: 100%;
|
|
225
|
+
height: 100%;
|
|
226
|
+
background-color: rgba(255, 255, 255, 0.6);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.loading-spinner {
|
|
230
|
+
position: absolute;
|
|
231
|
+
top: 40%;
|
|
232
|
+
left: 40%;
|
|
233
|
+
width: 20%;
|
|
234
|
+
height: 20%;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.apiKey-view-sub-title {
|
|
238
|
+
font-style: normal;
|
|
239
|
+
font-weight: 700;
|
|
240
|
+
font-size: 20px;
|
|
241
|
+
line-height: 23px;
|
|
242
|
+
text-transform: capitalize;
|
|
243
|
+
padding-bottom: 20px;
|
|
244
|
+
|
|
245
|
+
color: #333333;
|
|
246
|
+
|
|
247
|
+
flex: none;
|
|
248
|
+
order: 3;
|
|
249
|
+
flex-grow: 0;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.apiKey-view-display-page-display-window-container {
|
|
253
|
+
display: flex;
|
|
254
|
+
flex-direction: row;
|
|
255
|
+
padding-bottom: 50px;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.apiKey-view-display-page-display-window {
|
|
259
|
+
box-sizing: border-box;
|
|
260
|
+
|
|
261
|
+
display: flex;
|
|
262
|
+
flex-direction: row;
|
|
263
|
+
align-items: center;
|
|
264
|
+
padding: 1px 1px 1px 10px;
|
|
265
|
+
gap: 10px;
|
|
266
|
+
|
|
267
|
+
width: 340px;
|
|
268
|
+
height: 73px;
|
|
269
|
+
|
|
270
|
+
background: #F0F0F0;
|
|
271
|
+
|
|
272
|
+
border: 1px solid #595959;
|
|
273
|
+
border-radius: 10px 0px 0px 10px;
|
|
274
|
+
|
|
275
|
+
flex: none;
|
|
276
|
+
flex-grow: 0;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.apiKey-view-display-page-copy-button {
|
|
280
|
+
display: flex;
|
|
281
|
+
flex-direction: column;
|
|
282
|
+
align-items: center;
|
|
283
|
+
padding: 10px;
|
|
284
|
+
color: white;
|
|
285
|
+
font-style: normal;
|
|
286
|
+
font-weight: 400;
|
|
287
|
+
font-size: 16px;
|
|
288
|
+
line-height: 24px;
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
text-align: center;
|
|
292
|
+
|
|
293
|
+
width: 76px;
|
|
294
|
+
height: 73px;
|
|
295
|
+
|
|
296
|
+
background-color: $light-blue;
|
|
297
|
+
|
|
298
|
+
border-radius: 0px 9px 9px 0px;
|
|
299
|
+
border-style: none;
|
|
300
|
+
|
|
301
|
+
flex: none;
|
|
302
|
+
flex-grow: 0;
|
|
303
|
+
|
|
304
|
+
&:hover {
|
|
305
|
+
color: white;
|
|
306
|
+
background-color: $almost-black;
|
|
307
|
+
cursor: pointer;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.apiKey-view-display-page-return-button {
|
|
312
|
+
@include button();
|
|
313
|
+
|
|
314
|
+
display: flex;
|
|
315
|
+
|
|
316
|
+
padding: 1rem;
|
|
317
|
+
background-color: $light-blue;
|
|
318
|
+
color: white;
|
|
319
|
+
letter-spacing: 0.05rem;
|
|
320
|
+
|
|
321
|
+
font-style: normal;
|
|
322
|
+
font-weight: 700;
|
|
323
|
+
font-size: 16px;
|
|
324
|
+
line-height: 16px;
|
|
325
|
+
border: 1px;
|
|
326
|
+
border-radius: 2px;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.apiKey-view-display-page-return-button-link {
|
|
330
|
+
display: flex;
|
|
331
|
+
text-decoration: none;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.apiKey-view-display-page-return-button-container {
|
|
335
|
+
display: flex;
|
|
336
|
+
text-decoration: none;
|
|
337
|
+
|
|
338
|
+
flex-direction: column;
|
|
339
|
+
align-items: flex-start;
|
|
340
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactRedux = require("react-redux");
|
|
8
|
+
var _apikeyView = _interopRequireDefault(require("./apikey-view"));
|
|
9
|
+
var _selectors = require("../../store/selectors");
|
|
10
|
+
var _actions = require("../../store/actions");
|
|
11
|
+
var _reactRouterDom = require("react-router-dom");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
var mapStateToProps = function mapStateToProps(state) {
|
|
14
|
+
return {
|
|
15
|
+
apiKey: (0, _selectors.getApiKeyState)(state),
|
|
16
|
+
isLoading: (0, _selectors.determineIfLoading)(state),
|
|
17
|
+
isError: (0, _selectors.getGlobalErrorState)(state),
|
|
18
|
+
errorMessage: (0, _selectors.getGlobalErrorMessage)(state)
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
var mapDispatchToProps = function mapDispatchToProps(dispatch) {
|
|
22
|
+
return {
|
|
23
|
+
generate: function generate() {
|
|
24
|
+
return dispatch((0, _actions.generateApiKey)());
|
|
25
|
+
},
|
|
26
|
+
dismissGlobalError: function dismissGlobalError() {
|
|
27
|
+
return dispatch((0, _actions.setGlobalErrorState)(false, ''));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
var _default = exports.default = (0, _reactRouterDom.withRouter)((0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_apikeyView.default));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _connector = _interopRequireDefault(require("./connector"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = _connector.default;
|
|
@@ -0,0 +1,92 @@
|
|
|
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.default = void 0;
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
require("./chart-view.scss");
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
require("react-chart-editor/lib/react-chart-editor.ie.css");
|
|
12
|
+
var _lib = _interopRequireWildcard(require("react-chart-editor/lib"));
|
|
13
|
+
var _plotly = _interopRequireDefault(require("plotly.js/dist/plotly"));
|
|
14
|
+
var _lodash = require("lodash");
|
|
15
|
+
var _loadingElement = _interopRequireDefault(require("../../components/generic-elements/loading-element"));
|
|
16
|
+
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); }
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
var hasDataSources = function hasDataSources(dataSources) {
|
|
19
|
+
return dataSources && Object.keys(dataSources).length > 0;
|
|
20
|
+
};
|
|
21
|
+
var getDataSourceOptions = function getDataSourceOptions(dataSources) {
|
|
22
|
+
return Object.keys(dataSources).map(function (name) {
|
|
23
|
+
return {
|
|
24
|
+
value: name,
|
|
25
|
+
label: name
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var ChartView = function ChartView(props) {
|
|
30
|
+
var dataSources = props.dataSources,
|
|
31
|
+
isLoading = props.isLoading,
|
|
32
|
+
shouldAutoExecuteQuery = props.shouldAutoExecuteQuery,
|
|
33
|
+
executeQuery = props.executeQuery,
|
|
34
|
+
setChartInformation = props.setChartInformation,
|
|
35
|
+
chart = props.chart;
|
|
36
|
+
var data = chart.data,
|
|
37
|
+
layout = chart.layout,
|
|
38
|
+
frames = chart.frames;
|
|
39
|
+
_react.default.useEffect(function () {
|
|
40
|
+
if (shouldAutoExecuteQuery) {
|
|
41
|
+
executeQuery();
|
|
42
|
+
}
|
|
43
|
+
}, [shouldAutoExecuteQuery]);
|
|
44
|
+
_react.default.useEffect(function () {
|
|
45
|
+
var clonedData = (0, _lodash.cloneDeep)(data);
|
|
46
|
+
(0, _lib.dereference)(clonedData, dataSources);
|
|
47
|
+
setChartInformation({
|
|
48
|
+
data: clonedData,
|
|
49
|
+
layout: layout,
|
|
50
|
+
frames: frames
|
|
51
|
+
});
|
|
52
|
+
}, [dataSources]);
|
|
53
|
+
if (isLoading) {
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement("chart-view", null, /*#__PURE__*/_react.default.createElement(_loadingElement.default, null));
|
|
55
|
+
}
|
|
56
|
+
if (!hasDataSources(dataSources)) {
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement("chart-view", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
58
|
+
className: "no-data-message"
|
|
59
|
+
}, "Unable to load data. You may need to revise your query."));
|
|
60
|
+
}
|
|
61
|
+
var onUpdate = function onUpdate(data, layout, frames) {
|
|
62
|
+
setChartInformation({
|
|
63
|
+
data: data,
|
|
64
|
+
layout: layout,
|
|
65
|
+
frames: frames
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
return /*#__PURE__*/_react.default.createElement("chart-view", null, /*#__PURE__*/_react.default.createElement(_lib.default, {
|
|
69
|
+
data: data,
|
|
70
|
+
layout: layout,
|
|
71
|
+
frames: frames,
|
|
72
|
+
dataSources: dataSources,
|
|
73
|
+
dataSourceOptions: getDataSourceOptions(dataSources),
|
|
74
|
+
plotly: _plotly.default,
|
|
75
|
+
onUpdate: onUpdate,
|
|
76
|
+
advancedTraceTypeSelector: true,
|
|
77
|
+
useResizeHandler: true,
|
|
78
|
+
config: {
|
|
79
|
+
mapboxAccessToken: window.MAPBOX_ACCESS_TOKEN
|
|
80
|
+
},
|
|
81
|
+
"data-testid": "plotly-editor"
|
|
82
|
+
}, /*#__PURE__*/_react.default.createElement(_lib.DefaultEditor, {
|
|
83
|
+
logoSrc: window.LOGO_URL
|
|
84
|
+
})));
|
|
85
|
+
};
|
|
86
|
+
ChartView.propTypes = {
|
|
87
|
+
dataSources: _propTypes.default.object.isRequired,
|
|
88
|
+
isQueryLoading: _propTypes.default.bool,
|
|
89
|
+
shouldAutoExecuteQuery: _propTypes.default.bool,
|
|
90
|
+
executeQuery: _propTypes.default.func.isRequired
|
|
91
|
+
};
|
|
92
|
+
var _default = exports.default = ChartView;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@import "../../styles/mixins.scss";
|
|
2
|
+
@import "../../styles/variables.scss";
|
|
3
|
+
|
|
4
|
+
main-app-element {
|
|
5
|
+
overflow-y: scroll;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
chart-view {
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 85vh;
|
|
11
|
+
align-self: center;
|
|
12
|
+
|
|
13
|
+
loading-element {
|
|
14
|
+
@include default-loading-icon();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.no-data-message {
|
|
18
|
+
padding: 5rem;
|
|
19
|
+
text-align: center;
|
|
20
|
+
color: $almost-black;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.plotly-editor--theme-provider {
|
|
25
|
+
--color-button-primary-base-fill: hsl(205, 100%, 30%);
|
|
26
|
+
--color-button-primary-hover-fill: hsl(205, 87%, 30%);
|
|
27
|
+
--color-button-primary-active-fill: hsl(205, 87%, 20%);
|
|
28
|
+
--color-text-light: #595959;
|
|
29
|
+
--color-text-placeholder: #595959;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.editor_controls .rich-text-editor__editor .public-DraftEditorPlaceholder-root,
|
|
33
|
+
.editor_controls .rich-text-editor__editor .public-DraftEditor-content {
|
|
34
|
+
color: #595959;
|
|
35
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { shallow } from 'enzyme'
|
|
2
|
+
|
|
3
|
+
import ChartView from './chart-view'
|
|
4
|
+
import PlotlyEditor, { DefaultEditor } from 'react-chart-editor'
|
|
5
|
+
import LoadingElement from '../../components/generic-elements/loading-element'
|
|
6
|
+
import * as ReactChartLibrary from 'react-chart-editor/lib'
|
|
7
|
+
|
|
8
|
+
// Currently, shallow rendering is not compatible with React hooks.
|
|
9
|
+
// We've utilized a strategy found here https://blog.carbonfive.com/2019/08/05/shallow-testing-hooks-with-enzyme/
|
|
10
|
+
// which should become unneccessary in the near future
|
|
11
|
+
const runUseEffect = () => {
|
|
12
|
+
const useEffect = jest.spyOn(React, 'useEffect')
|
|
13
|
+
useEffect.mockImplementation(f => f())
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe('chart view', () => {
|
|
17
|
+
const chartDataSources = { data: ['sources'] }
|
|
18
|
+
|
|
19
|
+
let subject
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
runUseEffect()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('before load', () => {
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
subject = createSubject({ isLoading: true })
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('shows full page loading icon', () => {
|
|
31
|
+
expect(subject.find(LoadingElement).length).toBe(1)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('does not display a Plotly chart', () => {
|
|
35
|
+
expect(subject.find(PlotlyEditor).length).toBe(0)
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
describe('after load', () => {
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
subject = createSubject({ dataSources: chartDataSources, isLoading: false })
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('does not show full page loading icon', () => {
|
|
45
|
+
expect(subject.find(LoadingElement).length).toBe(0)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('displays a Plotly chart with the provided data sources', () => {
|
|
49
|
+
expect(subject.find(PlotlyEditor).props().dataSources).toBe(chartDataSources)
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
describe('with empty dataSources', () => {
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
subject = createSubject({ dataSources: {} })
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('does not render a Plotly chart', () => {
|
|
59
|
+
expect(subject.find(PlotlyEditor).length).toBe(0)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('displays a message that data has not been loaded', () => {
|
|
63
|
+
expect(subject.text()).toContain('Unable to load data')
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('does not automatically execute the query when instructed not to', () => {
|
|
68
|
+
const executeQuery = jest.fn()
|
|
69
|
+
|
|
70
|
+
subject = createSubject({ shouldAutoExecuteQuery: false, executeQuery })
|
|
71
|
+
|
|
72
|
+
expect(executeQuery).toHaveBeenCalledTimes(0)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('automatically executes the query when instructed to', () => {
|
|
76
|
+
const executeQuery = jest.fn()
|
|
77
|
+
|
|
78
|
+
subject = createSubject({ shouldAutoExecuteQuery: true, executeQuery })
|
|
79
|
+
|
|
80
|
+
expect(executeQuery).toHaveBeenCalledTimes(1)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
describe('with dataSources', () => {
|
|
84
|
+
const dataSources = {
|
|
85
|
+
col1: [1, 2, 3],
|
|
86
|
+
col2: [4, 5, 6]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
beforeEach(() => {
|
|
90
|
+
window.LOGO_URL = 'https://placekitten.com/530/530'
|
|
91
|
+
window.MAPBOX_ACCESS_TOKEN = 'secret key'
|
|
92
|
+
subject = createSubject({ dataSources: dataSources })
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('renders a chart editor', () => {
|
|
96
|
+
expect(subject.find(PlotlyEditor).length).toBe(1)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('configures the editor with empty data by default', () => {
|
|
100
|
+
expect(subject.find(PlotlyEditor).props().data).toEqual([])
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('configures the editor with empty layout by default', () => {
|
|
104
|
+
expect(subject.find(PlotlyEditor).props().layout).toEqual({})
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('configures the editor with empty frames by default', () => {
|
|
108
|
+
expect(subject.find(PlotlyEditor).props().frames).toEqual([])
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('automcatically updates the editor when dataSources change', () => {
|
|
112
|
+
const newDataSources = {
|
|
113
|
+
col1: [1, 2],
|
|
114
|
+
col2: [3, 4]
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
subject.setProps({ dataSources: newDataSources })
|
|
118
|
+
|
|
119
|
+
expect(subject.find(PlotlyEditor).props().dataSources).toBe(newDataSources)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('converts data sources to options for editor', () => {
|
|
123
|
+
expect(subject.find(PlotlyEditor).props().dataSourceOptions).toEqual([
|
|
124
|
+
{ value: 'col1', label: 'col1' },
|
|
125
|
+
{ value: 'col2', label: 'col2' }
|
|
126
|
+
])
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
it('configures the editor with the provided logo', () => {
|
|
130
|
+
expect(subject.find(DefaultEditor).length).toBe(1)
|
|
131
|
+
expect(subject.find(DefaultEditor).props().logoSrc).toBe(window.LOGO_URL)
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('configures the editor with the provided mapbox api token', () => {
|
|
135
|
+
expect(subject.find(PlotlyEditor).props().config.mapboxAccessToken).toBe('secret key')
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
describe('when datasources are updated', () => {
|
|
140
|
+
const dataSources = {
|
|
141
|
+
col1: [1, 2, 3],
|
|
142
|
+
col2: [4, 5, 6]
|
|
143
|
+
}
|
|
144
|
+
const plotlyData = [
|
|
145
|
+
{
|
|
146
|
+
type: 'scatter',
|
|
147
|
+
mode: 'markers',
|
|
148
|
+
x: [1, 2, 3],
|
|
149
|
+
xsrc: 'col1',
|
|
150
|
+
meta: { columnNames: { x: 'col1', y: 'col2' } },
|
|
151
|
+
y: [4, 5, 6],
|
|
152
|
+
ysrc: 'col2'
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
|
|
156
|
+
let setChartInformation
|
|
157
|
+
|
|
158
|
+
beforeEach(() => {
|
|
159
|
+
setChartInformation = jest.fn()
|
|
160
|
+
subject = createSubject({ dataSources: dataSources, chart: { data: plotlyData, frames: [], layout: {} }, setChartInformation })
|
|
161
|
+
setChartInformation.mockClear()
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('sets updated data for the chart', () => {
|
|
165
|
+
const newDataSources = {
|
|
166
|
+
col1: [1, 2],
|
|
167
|
+
col2: [3, 4]
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
subject.setProps({ dataSources: newDataSources })
|
|
171
|
+
|
|
172
|
+
expect(setChartInformation).toHaveBeenCalledTimes(1)
|
|
173
|
+
const firstPlotData = plotlyData[0]
|
|
174
|
+
const expected = { ...firstPlotData, ...{ x: newDataSources.col1, y: newDataSources.col2 } }
|
|
175
|
+
expect(setChartInformation).toHaveBeenCalledWith({ data: [expected], layout: {}, frames: [] })
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
describe('save chart', () => {
|
|
180
|
+
it('sends a save chart event', () => {
|
|
181
|
+
const setChartInformation = jest.fn()
|
|
182
|
+
const subject = createSubject({ setChartInformation })
|
|
183
|
+
setChartInformation.mockClear()
|
|
184
|
+
|
|
185
|
+
const data = [{ x: [1, 2, 3], xsrc: 'col1' }]
|
|
186
|
+
subject.find(PlotlyEditor).props().onUpdate(data, {}, [])
|
|
187
|
+
|
|
188
|
+
expect(setChartInformation).toHaveBeenCalledTimes(1)
|
|
189
|
+
expect(setChartInformation).toHaveBeenCalledWith({ data: data, layout: {}, frames: [] })
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
function createSubject (params = {}) {
|
|
195
|
+
const defaultParams = {
|
|
196
|
+
chart: { data: [], layout: {}, frames: [] },
|
|
197
|
+
isLoading: false,
|
|
198
|
+
dataSources: { data: ['sources'] },
|
|
199
|
+
shouldAutoExecuteQuery: false,
|
|
200
|
+
executeQuery: jest.fn(),
|
|
201
|
+
setChartInformation: jest.fn()
|
|
202
|
+
}
|
|
203
|
+
const paramsWithDefaults = Object.assign({}, defaultParams, params)
|
|
204
|
+
|
|
205
|
+
return shallow(<ChartView {...paramsWithDefaults} />)
|
|
206
|
+
}
|