@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,74 @@
|
|
|
1
|
+
import { shallow } from 'enzyme'
|
|
2
|
+
import DataCard from './data-card'
|
|
3
|
+
import { Link } from 'react-router-dom'
|
|
4
|
+
import SanitizedHTML from 'react-sanitized-html'
|
|
5
|
+
import ReactImageFallback from 'react-image-fallback'
|
|
6
|
+
|
|
7
|
+
let subject
|
|
8
|
+
const dataset = {
|
|
9
|
+
id: 'c21e1562-c44b-4d65-b8ec-cac3dcbb133b',
|
|
10
|
+
name: 'someName',
|
|
11
|
+
title: 'someTitle',
|
|
12
|
+
sourceType: 'ingest',
|
|
13
|
+
organization_name: 'org_name',
|
|
14
|
+
organization_title: 'Organization Title',
|
|
15
|
+
organization_image_url: 'logo.png',
|
|
16
|
+
description: 'somedescription',
|
|
17
|
+
fileTypes: ['foo', 'bar'],
|
|
18
|
+
modified: '2018-06-21'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe('data card element', () => {
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
subject = shallow(<DataCard dataset={dataset} />)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('card to render text based on props', () => {
|
|
27
|
+
expect(
|
|
28
|
+
subject
|
|
29
|
+
.find(SanitizedHTML)
|
|
30
|
+
.dive()
|
|
31
|
+
.render()
|
|
32
|
+
.text()
|
|
33
|
+
).toEqual(dataset.description)
|
|
34
|
+
expect(subject.find('.file-type').length).toEqual(dataset.fileTypes.length)
|
|
35
|
+
expect(subject.find(Link).at(1).props().to).toEqual(
|
|
36
|
+
`/dataset/${dataset.organization_name}/${dataset.name}`
|
|
37
|
+
)
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
describe('data card element with logo', () => {
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
subject = shallow(<DataCard dataset={dataset} />)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('card to render logo with correct url and alt text', () => {
|
|
47
|
+
expect(subject.find(ReactImageFallback).prop('alt')).toEqual('The logo for Organization Title')
|
|
48
|
+
expect(subject.find(ReactImageFallback).prop('src')).toEqual(dataset.organization_image_url)
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe('data card element with html description', () => {
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
const datasetWithHtmlDescription = Object.assign({}, dataset, {
|
|
55
|
+
description: '<table></table>somedescription'
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
subject = shallow(<DataCard dataset={datasetWithHtmlDescription} />)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
test('tags not in the whitelist are removed', () => {
|
|
62
|
+
expect(
|
|
63
|
+
subject
|
|
64
|
+
.find(SanitizedHTML)
|
|
65
|
+
.dive()
|
|
66
|
+
.render()
|
|
67
|
+
.text()
|
|
68
|
+
).toEqual(dataset.description)
|
|
69
|
+
expect(subject.find('.file-type').length).toEqual(dataset.fileTypes.length)
|
|
70
|
+
expect(subject.find(Link).at(1).props().to).toEqual(
|
|
71
|
+
`/dataset/${dataset.organization_name}/${dataset.name}`
|
|
72
|
+
)
|
|
73
|
+
})
|
|
74
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _dataCard = _interopRequireDefault(require("./data-card"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = _dataCard.default;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _variables = _interopRequireDefault(require("../../styles/variables.scss"));
|
|
9
|
+
require("./data-view.scss");
|
|
10
|
+
var _reactTable = _interopRequireDefault(require("react-table"));
|
|
11
|
+
require("react-table/react-table.css");
|
|
12
|
+
var _reactJsonView = _interopRequireDefault(require("react-json-view"));
|
|
13
|
+
var _loadingElement = _interopRequireDefault(require("../../components/generic-elements/loading-element"));
|
|
14
|
+
var _reactTabs = require("react-tabs");
|
|
15
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
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); }
|
|
18
|
+
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); }
|
|
19
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
20
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
22
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
23
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
24
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
25
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
26
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
27
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
28
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
29
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
30
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
31
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
32
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
33
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
34
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
35
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
36
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
37
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
38
|
+
var _default = exports.default = /*#__PURE__*/function (_Component) {
|
|
39
|
+
function _default() {
|
|
40
|
+
var _this;
|
|
41
|
+
_classCallCheck(this, _default);
|
|
42
|
+
_this = _callSuper(this, _default);
|
|
43
|
+
_this.state = {
|
|
44
|
+
index: 0
|
|
45
|
+
};
|
|
46
|
+
return _this;
|
|
47
|
+
}
|
|
48
|
+
_inherits(_default, _Component);
|
|
49
|
+
return _createClass(_default, [{
|
|
50
|
+
key: "render",
|
|
51
|
+
value: function render() {
|
|
52
|
+
var _this2 = this;
|
|
53
|
+
var isGeojson = this.props.format == 'geojson';
|
|
54
|
+
var cleanData = isGeojson ? undefined : this.getCleanData(this.props.data);
|
|
55
|
+
var columns = this.props.columns.map(function (column) {
|
|
56
|
+
return {
|
|
57
|
+
Header: column,
|
|
58
|
+
id: column,
|
|
59
|
+
accessor: function accessor(row) {
|
|
60
|
+
return row[column];
|
|
61
|
+
},
|
|
62
|
+
headerClassName: 'table-header'
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
66
|
+
id: "data-view"
|
|
67
|
+
}, /*#__PURE__*/_react.default.createElement(_reactTabs.Tabs, {
|
|
68
|
+
selectedIndex: this.state.index,
|
|
69
|
+
onSelect: function onSelect(tabIndex) {
|
|
70
|
+
return _this2.setState({
|
|
71
|
+
index: tabIndex
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, /*#__PURE__*/_react.default.createElement(_reactTabs.TabList, {
|
|
75
|
+
className: "header"
|
|
76
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
77
|
+
className: "tab-area"
|
|
78
|
+
}, !isGeojson && /*#__PURE__*/_react.default.createElement(_reactTabs.Tab, {
|
|
79
|
+
"data-testid": "data-table"
|
|
80
|
+
}, "Table"), /*#__PURE__*/_react.default.createElement(_reactTabs.Tab, {
|
|
81
|
+
"data-testid": "data-json"
|
|
82
|
+
}, "JSON"))), !isGeojson && /*#__PURE__*/_react.default.createElement(_reactTabs.TabPanel, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
83
|
+
id: "data-view-table"
|
|
84
|
+
}, /*#__PURE__*/_react.default.createElement(_reactTable.default, {
|
|
85
|
+
data: cleanData,
|
|
86
|
+
columns: columns,
|
|
87
|
+
loading: this.props.loading,
|
|
88
|
+
defaultPageSize: 50,
|
|
89
|
+
style: {
|
|
90
|
+
height: '400px'
|
|
91
|
+
},
|
|
92
|
+
className: "-striped -highlight",
|
|
93
|
+
page: this.props.page,
|
|
94
|
+
onPageChange: this.props.onNextPageClicked
|
|
95
|
+
}))), /*#__PURE__*/_react.default.createElement(_reactTabs.TabPanel, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
96
|
+
id: "data-view-raw"
|
|
97
|
+
}, this.renderJsonOrLoading(this.props.loading)))));
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "cleanseData",
|
|
101
|
+
value: function cleanseData(data) {
|
|
102
|
+
var _this3 = this;
|
|
103
|
+
if (!data.map) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
return data.map(function (row) {
|
|
107
|
+
return _this3.cleanseRow(row);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "cleanseRow",
|
|
112
|
+
value: function cleanseRow(row) {
|
|
113
|
+
var _this4 = this;
|
|
114
|
+
var deconstructedObject = Object.entries(row);
|
|
115
|
+
var listOfKeyValues = deconstructedObject.map(function (field) {
|
|
116
|
+
return _defineProperty({}, field[0], _this4.cleanseField(field[1]));
|
|
117
|
+
});
|
|
118
|
+
var reconstructedObject = Object.assign.apply(Object, [{}].concat(_toConsumableArray(listOfKeyValues)));
|
|
119
|
+
return reconstructedObject;
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "cleanseField",
|
|
123
|
+
value: function cleanseField(value) {
|
|
124
|
+
if (typeof value === 'boolean') {
|
|
125
|
+
return value.toString();
|
|
126
|
+
} else if (_lodash.default.isNull(value) || _lodash.default.isNaN(value)) {
|
|
127
|
+
return '';
|
|
128
|
+
} else if (_typeof(value) === 'object') {
|
|
129
|
+
return JSON.stringify(value);
|
|
130
|
+
} else {
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "getCleanData",
|
|
136
|
+
value: function getCleanData(queryData) {
|
|
137
|
+
return queryData ? this.cleanseData(queryData) : queryData;
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "renderJsonOrLoading",
|
|
141
|
+
value: function renderJsonOrLoading(isLoading) {
|
|
142
|
+
if (isLoading) {
|
|
143
|
+
return /*#__PURE__*/_react.default.createElement(_loadingElement.default, {
|
|
144
|
+
className: "spinner"
|
|
145
|
+
});
|
|
146
|
+
} else {
|
|
147
|
+
return /*#__PURE__*/_react.default.createElement(_reactJsonView.default, {
|
|
148
|
+
src: this.props.data,
|
|
149
|
+
theme: this.getTheme(),
|
|
150
|
+
collapsed: 2
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
155
|
+
key: "getTheme",
|
|
156
|
+
value: function getTheme() {
|
|
157
|
+
// react-json-view uses the 'base16' theme structure:
|
|
158
|
+
// https://github.com/chriskempson/base16/blob/master/styling.md
|
|
159
|
+
return {
|
|
160
|
+
base00: 'white',
|
|
161
|
+
// Default Background
|
|
162
|
+
base01: 'white',
|
|
163
|
+
// Lighter Background
|
|
164
|
+
base02: _variables.default.headerGrey,
|
|
165
|
+
// Null background
|
|
166
|
+
base03: _variables.default.almostBlack,
|
|
167
|
+
// Null Text
|
|
168
|
+
base04: _variables.default.mediumGrey,
|
|
169
|
+
// Item counts
|
|
170
|
+
base05: _variables.default.darkGrey,
|
|
171
|
+
// Unused
|
|
172
|
+
base06: _variables.default.darkGrey,
|
|
173
|
+
// Unused
|
|
174
|
+
base07: _variables.default.lightBlue,
|
|
175
|
+
// Field names
|
|
176
|
+
base08: _variables.default.darkGrey,
|
|
177
|
+
// Unused
|
|
178
|
+
base09: _variables.default.green,
|
|
179
|
+
// Field values
|
|
180
|
+
base0A: _variables.default.darkGrey,
|
|
181
|
+
// Unused
|
|
182
|
+
base0B: _variables.default.darkGrey,
|
|
183
|
+
// Unused
|
|
184
|
+
base0C: _variables.default.darkGrey,
|
|
185
|
+
// Unused
|
|
186
|
+
base0D: _variables.default.darkGrey,
|
|
187
|
+
// Expanders
|
|
188
|
+
base0E: _variables.default.darkGrey,
|
|
189
|
+
// Expanders
|
|
190
|
+
base0F: _variables.default.darkGrey // Expanders
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}]);
|
|
194
|
+
}(_react.Component);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@import '../../styles/variables.scss';
|
|
2
|
+
@import '../../styles/mixins.scss';
|
|
3
|
+
|
|
4
|
+
#data-view {
|
|
5
|
+
.header-container {
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ReactTable .rt-noData {
|
|
11
|
+
color: black;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.header-text-items {
|
|
15
|
+
margin: 1rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.preview-header {
|
|
19
|
+
@include header();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#data-view-table {
|
|
23
|
+
color: $almost-black;
|
|
24
|
+
|
|
25
|
+
.table-header {
|
|
26
|
+
background-color: $header-grey;
|
|
27
|
+
text-align: left;
|
|
28
|
+
font-weight: 800;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#data-view-raw {
|
|
33
|
+
overflow: scroll;
|
|
34
|
+
max-height: 30rem;
|
|
35
|
+
min-height: 10rem;
|
|
36
|
+
padding: 1rem;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mount
|
|
3
|
+
} from 'enzyme'
|
|
4
|
+
import DataView from './data-view'
|
|
5
|
+
import { Tab, TabPanel } from 'react-tabs'
|
|
6
|
+
import ReactTable from 'react-table'
|
|
7
|
+
import ReactJson from 'react-json-view'
|
|
8
|
+
import LoadingElement from '../../components/generic-elements/loading-element'
|
|
9
|
+
|
|
10
|
+
describe('data view', () => {
|
|
11
|
+
describe('ui', () => {
|
|
12
|
+
let subject
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
const data = [{
|
|
15
|
+
firstName: 'Joe',
|
|
16
|
+
lastName: 'Smith',
|
|
17
|
+
enrolled: true,
|
|
18
|
+
'firstName.lastName': 'Joe Smith'
|
|
19
|
+
}, {
|
|
20
|
+
firstName: 'Jane',
|
|
21
|
+
lastName: 'Doe',
|
|
22
|
+
enrolled: false,
|
|
23
|
+
'firstName.lastName': 'Jane Doe'
|
|
24
|
+
}]
|
|
25
|
+
const columns = ['firstName', 'lastName', 'enrolled', 'firstName.lastName']
|
|
26
|
+
subject = mount(<DataView data={data} columns={columns} />)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('should render table headers including column names with dots in them', () => {
|
|
30
|
+
const headers = subject.find('.rt-resizable-header-content')
|
|
31
|
+
const actual = headers.map(x => x.text())
|
|
32
|
+
|
|
33
|
+
expect(actual).toContain('firstName', 'lastName', 'enrolled', 'firstName.lastName')
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
test('should render table rows including data for column names with dots', () => {
|
|
37
|
+
const table_elements = subject.find('.rt-tr .rt-td')
|
|
38
|
+
const expected = [
|
|
39
|
+
'Joe', 'Smith', 'true', 'Joe Smith',
|
|
40
|
+
'Jane', 'Doe', 'false', 'Jane Doe'
|
|
41
|
+
]
|
|
42
|
+
const actual = table_elements.map((x) => x.text())
|
|
43
|
+
|
|
44
|
+
expect(actual).toContain(...expected)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('should render two tabs', () => {
|
|
48
|
+
expect(subject.find(Tab).length).toEqual(2)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('has two tab panels', () => {
|
|
52
|
+
expect(subject.find(TabPanel).length).toEqual(2)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('has a react table component on the first tab, and it is shown by default', () => {
|
|
56
|
+
expect(subject.find(ReactTable).length).toEqual(1)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('has a react json component on the second tab', () => {
|
|
60
|
+
subject.setState({ index: 1 })
|
|
61
|
+
expect(subject.find(ReactJson).length).toEqual(1)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
describe('geojson', () => {
|
|
66
|
+
let subject
|
|
67
|
+
beforeEach(() => {
|
|
68
|
+
const data = {}
|
|
69
|
+
const columns = []
|
|
70
|
+
subject = mount(<DataView data={data} columns={columns} format='geojson' />)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('should render one tab', () => {
|
|
74
|
+
expect(subject.find(Tab).length).toEqual(1)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('has one tab panel', () => {
|
|
78
|
+
expect(subject.find(TabPanel).length).toEqual(1)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('does not have a react table component', () => {
|
|
82
|
+
expect(subject.find(ReactTable).length).toEqual(0)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('has a react json component on the first tab', () => {
|
|
86
|
+
expect(subject.find(ReactJson).length).toEqual(1)
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
describe('json loading', () => {
|
|
91
|
+
let subject
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
const data = []
|
|
94
|
+
const columns = ['firstName', 'lastName', 'enrolled', 'firstName.lastName']
|
|
95
|
+
subject = mount(<DataView data={data} columns={columns} loading />)
|
|
96
|
+
subject.setState({ index: 1 })
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('does not render a react json component', () => {
|
|
100
|
+
expect(subject.find(ReactJson).length).toEqual(0)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('does render a loading element', () => {
|
|
104
|
+
expect(subject.find(LoadingElement).length).toEqual(1)
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
describe('data table', () => {
|
|
109
|
+
it('converts unrenderable values to strings only for the react table', () => {
|
|
110
|
+
const queryData = [
|
|
111
|
+
{ object: { value: 1 }, boolean: true, array: [1], nan: NaN, null: null },
|
|
112
|
+
{ object: { value: 2 }, boolean: false, array: [2, 3], nan: NaN, null: null }
|
|
113
|
+
]
|
|
114
|
+
const columns = ['object', 'boolean', 'array', 'nan', 'null']
|
|
115
|
+
|
|
116
|
+
const subject = mount(<DataView data={queryData} columns={columns} />)
|
|
117
|
+
|
|
118
|
+
const expectedData = [
|
|
119
|
+
{ object: '{\"value\":1}', boolean: 'true', array: '[1]', nan: '', null: '' },
|
|
120
|
+
{ object: '{\"value\":2}', boolean: 'false', array: '[2,3]', nan: '', null: '' }
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
expect(subject.find(ReactTable).prop('data')).toEqual(expectedData)
|
|
124
|
+
expect(subject.prop('data')).toEqual(queryData)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it('can handle column names with dots (.) by giving a custom accessor', () => {
|
|
128
|
+
const queryData = [
|
|
129
|
+
{ 'first.name': 'Mark', 'last.name': 'Johnson' },
|
|
130
|
+
{ 'first.name': 'George', 'last.name': 'Lakoff' }
|
|
131
|
+
]
|
|
132
|
+
const columns = [
|
|
133
|
+
'first.name',
|
|
134
|
+
'last.name'
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
const subject = mount(<DataView data={queryData} columns={columns} />)
|
|
138
|
+
|
|
139
|
+
const stringifyAccessor = column => {
|
|
140
|
+
column.accessor = column.accessor.toString().replace(/\s/g, '')
|
|
141
|
+
return column
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const expectedColumns = [
|
|
145
|
+
{ Header: 'first.name', id: 'first.name', accessor: (row) => row[column], headerClassName: 'table-header' },
|
|
146
|
+
{ Header: 'last.name', id: 'last.name', accessor: (row) => row[column], headerClassName: 'table-header' }
|
|
147
|
+
]
|
|
148
|
+
expectedColumns.map(stringifyAccessor)
|
|
149
|
+
|
|
150
|
+
const actualColumns = subject.find(ReactTable).prop('columns').map(stringifyAccessor)
|
|
151
|
+
|
|
152
|
+
expect(actualColumns).toEqual(expectedColumns)
|
|
153
|
+
})
|
|
154
|
+
})
|
|
155
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _dataView = _interopRequireDefault(require("./data-view"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = _dataView.default;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
require("./api-example.scss");
|
|
8
|
+
var _FilterNone = _interopRequireDefault(require("@material-ui/icons/FilterNone"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
var defaultHeaders = [{
|
|
11
|
+
name: 'api_key',
|
|
12
|
+
default: '',
|
|
13
|
+
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.',
|
|
14
|
+
required: false
|
|
15
|
+
}];
|
|
16
|
+
var _default = exports.default = function _default(_ref) {
|
|
17
|
+
var title = _ref.title,
|
|
18
|
+
descriptionHtml = _ref.descriptionHtml,
|
|
19
|
+
action = _ref.action,
|
|
20
|
+
url = _ref.url,
|
|
21
|
+
params = _ref.params,
|
|
22
|
+
examples = _ref.examples,
|
|
23
|
+
_ref$headers = _ref.headers,
|
|
24
|
+
headers = _ref$headers === void 0 ? defaultHeaders : _ref$headers;
|
|
25
|
+
return /*#__PURE__*/React.createElement("api-example", null, /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
className: "example-container"
|
|
27
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
className: "example-title"
|
|
29
|
+
}, title), descriptionHtml, /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: "example-code"
|
|
31
|
+
}, /*#__PURE__*/React.createElement("code", {
|
|
32
|
+
"data-testid": "".concat(title, "-api-example"),
|
|
33
|
+
className: "example-element"
|
|
34
|
+
}, "".concat(action, ": ").concat(url))), params && renderParameters(params), renderHeaders(headers), examples && renderExamples(examples, url)));
|
|
35
|
+
};
|
|
36
|
+
function renderParameters(params) {
|
|
37
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
className: "example-header"
|
|
39
|
+
}, "Optional Parameters"), /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
className: "example-parameters"
|
|
41
|
+
}, /*#__PURE__*/React.createElement("table", {
|
|
42
|
+
className: "example-table"
|
|
43
|
+
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Name"), /*#__PURE__*/React.createElement("th", null, "Default"), /*#__PURE__*/React.createElement("th", null, "Example"), /*#__PURE__*/React.createElement("th", null, "Description"))), /*#__PURE__*/React.createElement("tbody", null, params.map(renderParameter)))));
|
|
44
|
+
}
|
|
45
|
+
function renderParameter(parameter) {
|
|
46
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
47
|
+
key: "".concat(parameter.name)
|
|
48
|
+
}, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", {
|
|
49
|
+
className: "pill"
|
|
50
|
+
}, parameter.name)), /*#__PURE__*/React.createElement("td", null, parameter.default), /*#__PURE__*/React.createElement("td", {
|
|
51
|
+
className: "parameter-example"
|
|
52
|
+
}, parameter.example), /*#__PURE__*/React.createElement("td", null, parameter.description));
|
|
53
|
+
}
|
|
54
|
+
function renderHeaders(headers) {
|
|
55
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
className: "example-header"
|
|
57
|
+
}, "Headers"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("table", {
|
|
58
|
+
className: "example-table"
|
|
59
|
+
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Name"), /*#__PURE__*/React.createElement("th", null, "Required"), /*#__PURE__*/React.createElement("th", null, "Default"), /*#__PURE__*/React.createElement("th", null, "Description"))), /*#__PURE__*/React.createElement("tbody", null, headers.map(renderHeader)))));
|
|
60
|
+
}
|
|
61
|
+
function renderHeader(header) {
|
|
62
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
63
|
+
key: "".concat(header.name)
|
|
64
|
+
}, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", {
|
|
65
|
+
className: "pill"
|
|
66
|
+
}, header.name)), /*#__PURE__*/React.createElement("td", {
|
|
67
|
+
className: "required-marker"
|
|
68
|
+
}, header.required ? "Yes" : "No"), /*#__PURE__*/React.createElement("td", null, header.default), /*#__PURE__*/React.createElement("td", null, header.description));
|
|
69
|
+
}
|
|
70
|
+
function renderExamples(examples, url) {
|
|
71
|
+
examples = examples.map(function (example) {
|
|
72
|
+
example.curl = createCurlCommand(example, url);
|
|
73
|
+
return example;
|
|
74
|
+
});
|
|
75
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
className: "example-header"
|
|
77
|
+
}, "Example Bodies"), examples.map(renderExample));
|
|
78
|
+
}
|
|
79
|
+
function renderExample(example, index) {
|
|
80
|
+
var copyToClipboard = function copyToClipboard(event) {
|
|
81
|
+
var textField = document.createElement('textarea');
|
|
82
|
+
textField.innerText = example.curl;
|
|
83
|
+
document.body.appendChild(textField);
|
|
84
|
+
textField.select();
|
|
85
|
+
document.execCommand('copy');
|
|
86
|
+
textField.remove();
|
|
87
|
+
event.target.focus();
|
|
88
|
+
};
|
|
89
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: "example-body",
|
|
91
|
+
key: index
|
|
92
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
93
|
+
className: "example-description"
|
|
94
|
+
}, example.description), /*#__PURE__*/React.createElement("div", {
|
|
95
|
+
className: "example-code"
|
|
96
|
+
}, /*#__PURE__*/React.createElement("code", {
|
|
97
|
+
"data-testid": "curl-example-".concat(index),
|
|
98
|
+
className: "example-element"
|
|
99
|
+
}, example.body), /*#__PURE__*/React.createElement("div", {
|
|
100
|
+
className: "example-element curl",
|
|
101
|
+
onClick: function onClick(event) {
|
|
102
|
+
return copyToClipboard(event);
|
|
103
|
+
},
|
|
104
|
+
onKeyDownCapture: function onKeyDownCapture(event) {
|
|
105
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
106
|
+
event.preventDefault() && copyToClipboard(event);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
role: "button",
|
|
110
|
+
tabIndex: "0",
|
|
111
|
+
"aria-label": "cURL ".concat(index)
|
|
112
|
+
}, "cURL", /*#__PURE__*/React.createElement(_FilterNone.default, {
|
|
113
|
+
className: "copy-FilterNoneIcon"
|
|
114
|
+
}, "filter_none"), /*#__PURE__*/React.createElement("div", {
|
|
115
|
+
className: "secret-curl-field"
|
|
116
|
+
}, example.curl))));
|
|
117
|
+
}
|
|
118
|
+
function createCurlCommand(example, url) {
|
|
119
|
+
return "curl -X POST '".concat(url, "' -H 'Content-Type: text/plain' -H 'api_key: USER_API_KEY_HERE' -d '").concat(example.body, "'");
|
|
120
|
+
}
|