@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,84 @@
|
|
|
1
|
+
@import '../../styles/mixins.scss';
|
|
2
|
+
@import '../../styles/variables.scss';
|
|
3
|
+
|
|
4
|
+
api-example {
|
|
5
|
+
.example-container {
|
|
6
|
+
justify-content: space-between;
|
|
7
|
+
padding: 1.5rem;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.example-code {
|
|
11
|
+
border-radius: 5px;
|
|
12
|
+
border: $medium-grey solid 1px;
|
|
13
|
+
background-color: $super-light-grey;
|
|
14
|
+
word-wrap: break-word;
|
|
15
|
+
word-break: break-word;
|
|
16
|
+
display: table;
|
|
17
|
+
width: 100%
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.example-element {
|
|
21
|
+
display: table-cell;
|
|
22
|
+
padding: 10px;
|
|
23
|
+
vertical-align: middle;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.curl {
|
|
27
|
+
width: 3.5rem;
|
|
28
|
+
background-color: $light-blue;
|
|
29
|
+
color: white;
|
|
30
|
+
text-align: center;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.curl:hover {
|
|
34
|
+
background-color: $almost-black
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.curl:active {
|
|
38
|
+
background-color: $dark-grey
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.secret-curl-field {
|
|
42
|
+
display: none
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.example-title {
|
|
46
|
+
font-weight: bold;
|
|
47
|
+
font-size: 1.3rem;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.example-header {
|
|
51
|
+
font-weight: bold;
|
|
52
|
+
margin-top: 2rem
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.parameter-example {
|
|
56
|
+
white-space: nowrap;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.example-table {
|
|
60
|
+
border-collapse: collapse;
|
|
61
|
+
width: 100%
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.example-table td {
|
|
65
|
+
padding: 5px
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.example-table td,
|
|
69
|
+
th {
|
|
70
|
+
border: 1px solid $light-grey;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.example-body {
|
|
74
|
+
padding-top: 1.5rem
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.example-description {
|
|
78
|
+
margin-bottom: 0.5rem
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.required-marker {
|
|
82
|
+
text-align: center;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme'
|
|
2
|
+
import ApiExample from './api-example'
|
|
3
|
+
|
|
4
|
+
describe('api example', () => {
|
|
5
|
+
it('renders parameters and headers in tables', () => {
|
|
6
|
+
const params = [
|
|
7
|
+
{
|
|
8
|
+
name: 'bob',
|
|
9
|
+
default: 'smith',
|
|
10
|
+
description: 'a guy named bob',
|
|
11
|
+
example: 'robert'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'bill',
|
|
15
|
+
default: 'johnson',
|
|
16
|
+
description: 'a guy named bill',
|
|
17
|
+
example: 'william'
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
const wrapper = shallow(<ApiExample params={params} />)
|
|
22
|
+
|
|
23
|
+
const cells = wrapper.find('td')
|
|
24
|
+
|
|
25
|
+
expect(cells.length).toBe(12)
|
|
26
|
+
expect(cells.at(0).text()).toBe('bob')
|
|
27
|
+
expect(cells.at(1).text()).toBe('smith')
|
|
28
|
+
expect(cells.at(2).text()).toBe('robert')
|
|
29
|
+
expect(cells.at(3).text()).toBe('a guy named bob')
|
|
30
|
+
expect(cells.at(4).text()).toBe('bill')
|
|
31
|
+
expect(cells.at(5).text()).toBe('johnson')
|
|
32
|
+
expect(cells.at(6).text()).toBe('william')
|
|
33
|
+
expect(cells.at(7).text()).toBe('a guy named bill')
|
|
34
|
+
expect(cells.at(8).text()).toBe('api_key')
|
|
35
|
+
expect(cells.at(9).text()).toBe('No')
|
|
36
|
+
expect(cells.at(10).text()).toBe('')
|
|
37
|
+
expect(cells.at(11).text()).toBe('Include your unique api key as the value. You can generate your key by navigating to the “API Key” item on the “My Account” menu.')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('does not render a table of params if no params are provided', () => {
|
|
41
|
+
const wrapper = shallow(<ApiExample />)
|
|
42
|
+
const parameters = wrapper.find('.example-parameters')
|
|
43
|
+
|
|
44
|
+
expect(parameters.length).toBe(0)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('renders examples as formatted code with descriptions', () => {
|
|
48
|
+
const examples = [
|
|
49
|
+
{
|
|
50
|
+
description: 'This is how we query a thing',
|
|
51
|
+
body: 'select * from thing'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
description: 'This is how we query a bob with another bob',
|
|
55
|
+
body: 'select * from bob join bobi using (bob_id)'
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
const wrapper = mount(<ApiExample examples={examples} />)
|
|
60
|
+
|
|
61
|
+
const exampleDivs = wrapper.find('div.example-body')
|
|
62
|
+
|
|
63
|
+
expect(exampleDivs.length).toBe(2)
|
|
64
|
+
expect(exampleDivs.at(0).find('.example-description').text()).toBe('This is how we query a thing')
|
|
65
|
+
expect(exampleDivs.at(0).find('code').text()).toBe('select * from thing')
|
|
66
|
+
expect(exampleDivs.at(1).find('.example-description').text()).toBe('This is how we query a bob with another bob')
|
|
67
|
+
expect(exampleDivs.at(1).find('code').text()).toBe('select * from bob join bobi using (bob_id)')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('creates a curl command for each example', () => {
|
|
71
|
+
const examples = [
|
|
72
|
+
{
|
|
73
|
+
description: 'This is how we query a thing',
|
|
74
|
+
body: 'select * from thing'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
description: 'This is how we query a bob with another bob',
|
|
78
|
+
body: 'select * from bob join bobi using (bob_id)'
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
const wrapper = mount(<ApiExample examples={examples} url='localhost:5000/api' />)
|
|
83
|
+
const curlDivs = wrapper.find('div.secret-curl-field')
|
|
84
|
+
expect(curlDivs.length).toBe(2)
|
|
85
|
+
expect(curlDivs.at(0).text()).toBe("curl -X POST 'localhost:5000/api' -H 'Content-Type: text/plain' -H 'api_key: USER_API_KEY_HERE' -d 'select * from thing'")
|
|
86
|
+
expect(curlDivs.at(1).text()).toBe("curl -X POST 'localhost:5000/api' -H 'Content-Type: text/plain' -H 'api_key: USER_API_KEY_HERE' -d 'select * from bob join bobi using (bob_id)'")
|
|
87
|
+
})
|
|
88
|
+
})
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
require("./dataset-api-doc.scss");
|
|
8
|
+
var _collapsableBox = _interopRequireDefault(require("../../components/collapsable-box"));
|
|
9
|
+
var _apiExample = _interopRequireDefault(require("./api-example"));
|
|
10
|
+
var _fileTypeUtils = require("../../utils/file-type-utils");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
var simpleApiParams = [{
|
|
13
|
+
name: 'columns',
|
|
14
|
+
default: '*',
|
|
15
|
+
description: 'A list of columns from the dataset to be included in the query.',
|
|
16
|
+
example: 'column1,column2,column3'
|
|
17
|
+
}, {
|
|
18
|
+
name: 'where',
|
|
19
|
+
default: '',
|
|
20
|
+
description: 'A set of conditions to filter rows by. Multiple conditions can be added, separated by AND or OR.',
|
|
21
|
+
example: "column1='a value' OR column1='another value'"
|
|
22
|
+
}, {
|
|
23
|
+
name: 'groupBy',
|
|
24
|
+
default: '',
|
|
25
|
+
description: 'A column (or comma-separated list of columns) to group the results by.',
|
|
26
|
+
example: 'column1'
|
|
27
|
+
}, {
|
|
28
|
+
name: 'orderBy',
|
|
29
|
+
default: '',
|
|
30
|
+
description: "A column (or comma separated list of columns) to order the results by and one of 'ASC' or 'DESC' to determine the direction of each.",
|
|
31
|
+
example: 'column1 ASC, column2 DESC'
|
|
32
|
+
}, {
|
|
33
|
+
name: 'limit',
|
|
34
|
+
default: '',
|
|
35
|
+
description: 'A whole number limiting the total rows returned. The API does not guarantee the same list of rows every time when limited this way.',
|
|
36
|
+
example: '200'
|
|
37
|
+
}, {
|
|
38
|
+
name: '_format',
|
|
39
|
+
default: 'CSV',
|
|
40
|
+
description: 'The format of data returned by a query. ',
|
|
41
|
+
example: 'json'
|
|
42
|
+
}];
|
|
43
|
+
var freestyleApiParams = [{
|
|
44
|
+
name: '_format',
|
|
45
|
+
default: 'CSV',
|
|
46
|
+
description: 'The format of data returned by a query.',
|
|
47
|
+
example: 'json'
|
|
48
|
+
}];
|
|
49
|
+
var apiHeaders = [{
|
|
50
|
+
name: 'api_key',
|
|
51
|
+
default: '',
|
|
52
|
+
description: 'Include your unique api key as the value. You can generate your key by navigating to the “API Key” item on the “My Account” menu.',
|
|
53
|
+
required: window.REQUIRE_API_KEY === 'true'
|
|
54
|
+
}];
|
|
55
|
+
function getFreestyleApiExamples(dataset) {
|
|
56
|
+
return [{
|
|
57
|
+
body: "SELECT * FROM ".concat(dataset.systemName, " LIMIT 200"),
|
|
58
|
+
description: 'Get 200 rows with all columns of data from the dataset.'
|
|
59
|
+
}, {
|
|
60
|
+
body: "SELECT ".concat(dataset.schema[0].name, " FROM ").concat(dataset.systemName, " WHERE ").concat(dataset.schema[0].name, " IS NOT NULL LIMIT 200"),
|
|
61
|
+
description: "Get only the column ".concat(dataset.schema[0].name, " from the dataset where ").concat(dataset.schema[0].name, " contains data.")
|
|
62
|
+
}, {
|
|
63
|
+
body: 'SELECT t1.example_column, t2.joined_column FROM example_dataset_one t1 INNER JOIN example_dataset_two t2 ON t1.example_id = t2.example_id LIMIT 200',
|
|
64
|
+
description: 'Get rows from two example datasets where the example_id columns match. Get example_column from one and joined_column from the other.'
|
|
65
|
+
}];
|
|
66
|
+
}
|
|
67
|
+
function freestyleDescription() {
|
|
68
|
+
return /*#__PURE__*/React.createElement("div", null, "This query supports the full ANSI SQL syntax, and only selects from the tables specified in the query.", /*#__PURE__*/React.createElement("br", null), "The query to run must be submitted as plain text in the body of the request.", /*#__PURE__*/React.createElement("br", null), "Documentation can be found at:", /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("a", {
|
|
69
|
+
role: "link",
|
|
70
|
+
className: "primary-color",
|
|
71
|
+
href: "https://en.wikipedia.org/wiki/SQL_syntax",
|
|
72
|
+
target: "_blank"
|
|
73
|
+
}, "SQL Syntax (Wikipedia)")), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("a", {
|
|
74
|
+
role: "link",
|
|
75
|
+
className: "primary-color",
|
|
76
|
+
href: "https://www.w3schools.com/sql/sql_quickref.asp",
|
|
77
|
+
target: "_blank"
|
|
78
|
+
}, "Quick Reference (W3 Schools)")), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("a", {
|
|
79
|
+
role: "link",
|
|
80
|
+
className: "primary-color",
|
|
81
|
+
href: "https://prestodb.github.io/docs/current/sql/select.html",
|
|
82
|
+
target: "_blank"
|
|
83
|
+
}, "PrestoDB Specific Syntax"))));
|
|
84
|
+
}
|
|
85
|
+
function renderHeader() {
|
|
86
|
+
return /*#__PURE__*/React.createElement("div", null, "Access Operating System data with supported queries. All supported clauses follow standard ANSI SQL standards.");
|
|
87
|
+
}
|
|
88
|
+
function renderExamples(dataset) {
|
|
89
|
+
var format = (0, _fileTypeUtils.getDefaultFormat)(dataset);
|
|
90
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_apiExample.default, {
|
|
91
|
+
title: "Simple query",
|
|
92
|
+
descriptionHtml: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, "This query selects all columns from the dataset, limited to 200 rows returned."), /*#__PURE__*/React.createElement("div", null, "If this dataset is private, or the system is in \"API Key Required\" mode, you'll need to include your key in the value of the \"api_key\" header."), /*#__PURE__*/React.createElement("div", null, "Additional examples of API key usage are in the curl examples below.")),
|
|
93
|
+
url: "".concat(window.DISC_API_URL, "/api/v1/organization/").concat(dataset.organization.name, "/dataset/").concat(dataset.name, "/query?limit=200&_format=").concat(format),
|
|
94
|
+
action: "GET",
|
|
95
|
+
params: simpleApiParams,
|
|
96
|
+
headers: apiHeaders
|
|
97
|
+
}), /*#__PURE__*/React.createElement(_apiExample.default, {
|
|
98
|
+
title: "Freestyle query",
|
|
99
|
+
descriptionHtml: freestyleDescription(),
|
|
100
|
+
url: "".concat(window.DISC_API_URL, "/api/v1/query?_format=").concat(format),
|
|
101
|
+
action: "POST",
|
|
102
|
+
params: freestyleApiParams,
|
|
103
|
+
examples: getFreestyleApiExamples(dataset),
|
|
104
|
+
headers: apiHeaders
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
var _default = exports.default = function _default(_ref) {
|
|
108
|
+
var expanded = _ref.expanded,
|
|
109
|
+
dataset = _ref.dataset;
|
|
110
|
+
return /*#__PURE__*/React.createElement("dataset-api-doc", {
|
|
111
|
+
class: "dataset-api-doc"
|
|
112
|
+
}, /*#__PURE__*/React.createElement(_collapsableBox.default, {
|
|
113
|
+
title: "API Examples",
|
|
114
|
+
headerHtml: renderHeader(),
|
|
115
|
+
expanded: expanded
|
|
116
|
+
}, renderExamples(dataset)));
|
|
117
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { render } from 'enzyme'
|
|
2
|
+
import DatasetApiDoc from './dataset-api-doc'
|
|
3
|
+
|
|
4
|
+
describe('dataset api doc ', () => {
|
|
5
|
+
const dataset = {
|
|
6
|
+
id: 'coda_stuff',
|
|
7
|
+
name: 'data_name',
|
|
8
|
+
fileTypes: ['CSV'],
|
|
9
|
+
systemName: 'test__dataset',
|
|
10
|
+
organization: { name: 'coda_name' },
|
|
11
|
+
schema: [{ name: 'id' }]
|
|
12
|
+
}
|
|
13
|
+
let subject
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
const matchMedia = jest.fn()
|
|
17
|
+
Object.defineProperty(window, 'matchMedia', {
|
|
18
|
+
writable: true,
|
|
19
|
+
value: jest.fn().mockImplementation(query => ({
|
|
20
|
+
matches: true
|
|
21
|
+
}))
|
|
22
|
+
})
|
|
23
|
+
subject = render(<DatasetApiDoc dataset={dataset} />)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('renders the example url with the dataset id', () => {
|
|
27
|
+
expect(subject.find('.example-code').text()).toMatch('/api/v1/organization/coda_name/dataset/data_name/query?limit=200&_format=csv')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('renders the freestyle query example body with the correct table and column name', () => {
|
|
31
|
+
expect(subject.text()).toContain(`SELECT ${dataset.schema[0].name} FROM ${dataset.systemName}`)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
describe('with gtfs format', () => {
|
|
35
|
+
test('the example url maps _format to json', () => {
|
|
36
|
+
const gtfsDataset = { ...dataset, ...{ fileTypes: ['GTFS'] } }
|
|
37
|
+
subject = render(<DatasetApiDoc dataset={gtfsDataset} />)
|
|
38
|
+
|
|
39
|
+
expect(subject.find('.example-code').text()).toMatch('/api/v1/organization/coda_name/dataset/data_name/query?limit=200&_format=json')
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _datasetApiDoc = _interopRequireDefault(require("./dataset-api-doc"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = _datasetApiDoc.default;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
require("./dataset-details.scss");
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
+
var _reactSanitizedHtml = _interopRequireDefault(require("react-sanitized-html"));
|
|
10
|
+
var _utils = require("../../utils");
|
|
11
|
+
var _callToActionButton = _interopRequireDefault(require("../generic-elements/call-to-action-button"));
|
|
12
|
+
var _fileTypeUtils = require("../../utils/file-type-utils");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
var DatasetDetails = function DatasetDetails(_ref) {
|
|
15
|
+
var dataset = _ref.dataset,
|
|
16
|
+
downloadUrl = _ref.downloadUrl;
|
|
17
|
+
if (!dataset) {
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", null);
|
|
19
|
+
}
|
|
20
|
+
return /*#__PURE__*/React.createElement("dataset-details", {
|
|
21
|
+
class: "dataset-details"
|
|
22
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
className: "dataset-details-header"
|
|
24
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
"data-testid": "dataset-title",
|
|
26
|
+
className: "name"
|
|
27
|
+
}, /*#__PURE__*/React.createElement("h1", null, dataset.title)), /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
className: "buttons"
|
|
29
|
+
}, /*#__PURE__*/React.createElement(_callToActionButton.default, {
|
|
30
|
+
url: downloadUrl,
|
|
31
|
+
format: (0, _fileTypeUtils.getDefaultFormat)(dataset),
|
|
32
|
+
filename: dataset.id,
|
|
33
|
+
sourceType: dataset.sourceType,
|
|
34
|
+
sourceUrl: dataset.sourceUrl
|
|
35
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
36
|
+
className: "print-api-docs-button call-to-action-button",
|
|
37
|
+
onClick: function onClick() {
|
|
38
|
+
return window.print();
|
|
39
|
+
}
|
|
40
|
+
}, "Print API Docs"))), /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
"data-testid": "dataset-description",
|
|
42
|
+
className: "description"
|
|
43
|
+
}, /*#__PURE__*/React.createElement(_reactSanitizedHtml.default, {
|
|
44
|
+
allowedAttributes: {
|
|
45
|
+
a: ['href']
|
|
46
|
+
},
|
|
47
|
+
allowedTags: ['b', 'a', 'ul', 'li', 'ol', 'p', 'em', 'i'],
|
|
48
|
+
html: dataset.description
|
|
49
|
+
})), !_lodash.default.isEmpty(dataset.keywords) && /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
"data-testid": "dataset-keywords",
|
|
51
|
+
className: "keywords"
|
|
52
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: "keyword-label"
|
|
54
|
+
}, "KEYWORDS"), dataset.keywords.map(createKeyword)));
|
|
55
|
+
};
|
|
56
|
+
var createKeyword = function createKeyword(name) {
|
|
57
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
58
|
+
key: "dataset-keyword-".concat(name),
|
|
59
|
+
className: "keyword",
|
|
60
|
+
role: "link",
|
|
61
|
+
href: "/?".concat(_utils.QueryStringBuilder.createFilterQueryString('keywords', name))
|
|
62
|
+
}, name);
|
|
63
|
+
};
|
|
64
|
+
var _default = exports.default = DatasetDetails;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
@import "../../styles/mixins.scss";
|
|
2
|
+
@import "../../styles/variables.scss";
|
|
3
|
+
|
|
4
|
+
dataset-details {
|
|
5
|
+
@include custom-element();
|
|
6
|
+
padding-bottom: 1rem;
|
|
7
|
+
|
|
8
|
+
.dataset-details-header {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.buttons {
|
|
15
|
+
display: flex;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.name {
|
|
19
|
+
@include header();
|
|
20
|
+
margin-bottom: 0.5rem;
|
|
21
|
+
h1 {
|
|
22
|
+
font-size: 20px
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.description {
|
|
27
|
+
margin-bottom: 0.75rem;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.resources {
|
|
31
|
+
margin-bottom: 0.75rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.keywords {
|
|
35
|
+
@include flex-row();
|
|
36
|
+
justify-content: flex-start;
|
|
37
|
+
flex-wrap: wrap;
|
|
38
|
+
margin-bottom: 0.75rem;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.keyword-label {
|
|
42
|
+
font-weight: bold;
|
|
43
|
+
margin-right: 0.75rem;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.keyword {
|
|
47
|
+
@include button(white);
|
|
48
|
+
color: $dark-grey;
|
|
49
|
+
padding: 0.5rem 0.75rem;
|
|
50
|
+
border: 1px solid $light-grey;
|
|
51
|
+
border-radius: 1.5rem;
|
|
52
|
+
margin-bottom: 0.5rem;
|
|
53
|
+
|
|
54
|
+
&:not(:last-child) {
|
|
55
|
+
margin-right: 0.5rem;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { shallow } from 'enzyme'
|
|
2
|
+
import DatasetDetails from './dataset-details'
|
|
3
|
+
|
|
4
|
+
describe('dataset details', () => {
|
|
5
|
+
let subject
|
|
6
|
+
jest.spyOn(window, 'print').mockReturnValue()
|
|
7
|
+
|
|
8
|
+
test('card to render text based on props', () => {
|
|
9
|
+
subject = shallow(<DatasetDetails dataset={{ keywords: ['COTA', 'Transit Stops'] }} />)
|
|
10
|
+
expect(subject.find('.keyword').length).toEqual(2)
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('card does not render keywords when not provided', () => {
|
|
14
|
+
subject = shallow(<DatasetDetails dataset={{ keywords: null }} />)
|
|
15
|
+
expect(subject.find('.keyword').length).toEqual(0)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test('card does not render keywords label when empty', () => {
|
|
19
|
+
subject = shallow(<DatasetDetails dataset={{ keywords: [] }} />)
|
|
20
|
+
expect(subject.find('.keyword-label').length).toEqual(0)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('keywords link to filtered search', () => {
|
|
24
|
+
subject = shallow(<DatasetDetails dataset={{ keywords: ['COTA', 'Transit Stops'], id: '12345' }} />)
|
|
25
|
+
expect(subject.find('.keyword').filterWhere(n => { return n.text() === 'COTA' }).prop('href')).toMatch(encodeURI('/?facets[keywords][]=COTA'))
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('button to download api docs', () => {
|
|
29
|
+
subject = shallow(<DatasetDetails dataset={{ keywords: [] }} />)
|
|
30
|
+
expect(subject.find('.print-api-docs-button').length).toEqual(1)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test('click print button to print', () => {
|
|
34
|
+
subject = shallow(<DatasetDetails dataset={{ keywords: [] }} />)
|
|
35
|
+
subject.find('.print-api-docs-button').simulate('click')
|
|
36
|
+
expect(window.print).toHaveBeenCalled()
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _datasetDetails = _interopRequireDefault(require("./dataset-details"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = _datasetDetails.default;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
require("./dataset-dictionary.scss");
|
|
9
|
+
var _reactTable = _interopRequireDefault(require("react-table"));
|
|
10
|
+
require("react-table/react-table.css");
|
|
11
|
+
var _collapsableBox = _interopRequireDefault(require("../../components/collapsable-box"));
|
|
12
|
+
var _tooltip = _interopRequireDefault(require("../tooltip"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
var expanderWidth = 35;
|
|
15
|
+
var expandedArrow = "\u25BE";
|
|
16
|
+
var collapsedArrow = "\u25B8";
|
|
17
|
+
var renderFieldNameCell = function renderFieldNameCell(schemaElement) {
|
|
18
|
+
return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
19
|
+
text: schemaElement.value
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var renderTypeCell = function renderTypeCell(schemaElement) {
|
|
23
|
+
return /*#__PURE__*/_react.default.createElement("div", null, schemaElement.value === 'list' ? "list of ".concat(schemaElement.original.itemType) : schemaElement.value);
|
|
24
|
+
};
|
|
25
|
+
var isMap = function isMap(schemaElement) {
|
|
26
|
+
return schemaElement.type === 'map' || schemaElement.itemType === 'map';
|
|
27
|
+
};
|
|
28
|
+
var renderExpander = function renderExpander(_ref) {
|
|
29
|
+
var isExpanded = _ref.isExpanded,
|
|
30
|
+
schemaElement = _ref.original;
|
|
31
|
+
var content = '';
|
|
32
|
+
if (isMap(schemaElement)) {
|
|
33
|
+
content = isExpanded ? expandedArrow : collapsedArrow;
|
|
34
|
+
}
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
36
|
+
className: "expander"
|
|
37
|
+
}, content);
|
|
38
|
+
};
|
|
39
|
+
var renderSubTable = function renderSubTable(_ref2) {
|
|
40
|
+
var schemaElement = _ref2.original;
|
|
41
|
+
return isMap(schemaElement) ? /*#__PURE__*/_react.default.createElement(SchemaTable, {
|
|
42
|
+
schema: schemaElement.subSchema,
|
|
43
|
+
parentFieldName: schemaElement.name,
|
|
44
|
+
style: {
|
|
45
|
+
marginLeft: "".concat(expanderWidth, "px")
|
|
46
|
+
}
|
|
47
|
+
}) : /*#__PURE__*/_react.default.createElement("span", null);
|
|
48
|
+
};
|
|
49
|
+
var columns = [{
|
|
50
|
+
Header: 'Field',
|
|
51
|
+
accessor: 'name',
|
|
52
|
+
headerClassName: 'table-header',
|
|
53
|
+
width: 240,
|
|
54
|
+
className: 'field-name-cell',
|
|
55
|
+
Cell: renderFieldNameCell
|
|
56
|
+
}, {
|
|
57
|
+
Header: 'Type',
|
|
58
|
+
accessor: 'type',
|
|
59
|
+
headerClassName: 'table-header',
|
|
60
|
+
width: 120,
|
|
61
|
+
Cell: renderTypeCell
|
|
62
|
+
}, {
|
|
63
|
+
Header: 'Description',
|
|
64
|
+
accessor: 'description',
|
|
65
|
+
headerClassName: 'table-header',
|
|
66
|
+
className: 'description-cell'
|
|
67
|
+
}];
|
|
68
|
+
var isEmpty = function isEmpty(schema) {
|
|
69
|
+
return !schema || schema.length < 1;
|
|
70
|
+
};
|
|
71
|
+
var SchemaTable = function SchemaTable(_ref3) {
|
|
72
|
+
var schema = _ref3.schema,
|
|
73
|
+
_ref3$parentFieldName = _ref3.parentFieldName,
|
|
74
|
+
parentFieldName = _ref3$parentFieldName === void 0 ? '' : _ref3$parentFieldName,
|
|
75
|
+
style = _ref3.style;
|
|
76
|
+
if (schema) {
|
|
77
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
78
|
+
className: "dataset-schema-table ".concat(parentFieldName)
|
|
79
|
+
}, /*#__PURE__*/_react.default.createElement(_reactTable.default, {
|
|
80
|
+
style: style,
|
|
81
|
+
data: schema,
|
|
82
|
+
columns: columns,
|
|
83
|
+
defaultPageSize: schema.length,
|
|
84
|
+
className: "-highlight",
|
|
85
|
+
showPagination: false,
|
|
86
|
+
sortable: true,
|
|
87
|
+
ExpanderComponent: renderExpander,
|
|
88
|
+
SubComponent: renderSubTable,
|
|
89
|
+
expanderDefaults: {
|
|
90
|
+
width: expanderWidth
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
93
|
+
} else {
|
|
94
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
95
|
+
className: "error"
|
|
96
|
+
}, "Schema information not found. Contact the data curator.");
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
var viewLink = function viewLink(datasetId) {
|
|
100
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
101
|
+
className: "view-link"
|
|
102
|
+
}, /*#__PURE__*/_react.default.createElement("a", {
|
|
103
|
+
href: "".concat(window.DISC_API_URL, "/api/v1/dataset/").concat(datasetId, "/dictionary"),
|
|
104
|
+
target: "_blank",
|
|
105
|
+
role: "link"
|
|
106
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
107
|
+
className: "view-text"
|
|
108
|
+
}, "View as JSON")));
|
|
109
|
+
};
|
|
110
|
+
var _default = exports.default = function _default(_ref4) {
|
|
111
|
+
var schema = _ref4.schema,
|
|
112
|
+
datasetId = _ref4.datasetId,
|
|
113
|
+
_ref4$expanded = _ref4.expanded,
|
|
114
|
+
expanded = _ref4$expanded === void 0 ? true : _ref4$expanded;
|
|
115
|
+
var title = 'Data Dictionary';
|
|
116
|
+
if (isEmpty(schema)) {
|
|
117
|
+
title = title + ' Unavailable';
|
|
118
|
+
}
|
|
119
|
+
return /*#__PURE__*/_react.default.createElement("dataset-dictionary", {
|
|
120
|
+
class: "dataset-dictionary"
|
|
121
|
+
}, /*#__PURE__*/_react.default.createElement(_collapsableBox.default, {
|
|
122
|
+
title: title,
|
|
123
|
+
expanded: expanded
|
|
124
|
+
}, !isEmpty(schema) && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(SchemaTable, {
|
|
125
|
+
schema: schema
|
|
126
|
+
}), viewLink(datasetId))));
|
|
127
|
+
};
|