@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,238 @@
|
|
|
1
|
+
import { shallow } from 'enzyme'
|
|
2
|
+
import { Map } from 'react-leaflet'
|
|
3
|
+
import GeoJSONVisualization from './geojson-visualization'
|
|
4
|
+
import Checkbox from '../../../components/generic-elements/checkbox'
|
|
5
|
+
|
|
6
|
+
describe('<GeoJSONVisualization />', () => {
|
|
7
|
+
let wrapper, downloadDataset, previewDataset
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
downloadDataset = jest.fn()
|
|
11
|
+
previewDataset = jest.fn()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('calls to preview and download dataset on mount', () => {
|
|
15
|
+
wrapper = shallow(<GeoJSONVisualization
|
|
16
|
+
previewDataset={previewDataset}
|
|
17
|
+
downloadDataset={downloadDataset}
|
|
18
|
+
datasetId='345'
|
|
19
|
+
/>)
|
|
20
|
+
|
|
21
|
+
expect(previewDataset).toHaveBeenCalledWith('345', 'geojson')
|
|
22
|
+
expect(downloadDataset).toHaveBeenCalledWith('345', 'geojson')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('with a downloaded dataset error', () => {
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
wrapper = shallow(<GeoJSONVisualization
|
|
28
|
+
previewDataset={previewDataset}
|
|
29
|
+
downloadDataset={downloadDataset}
|
|
30
|
+
downloadedDatasetError
|
|
31
|
+
/>)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('renders an error component', () => {
|
|
35
|
+
expect(wrapper.find('ErrorComponent').length).toEqual(1)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('does not render maps', () => {
|
|
39
|
+
expect(wrapper.find('[test-id="preview-map"]').length).toEqual(0)
|
|
40
|
+
expect(wrapper.find('[test-id="downloaded-map"]').length).toEqual(0)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('does not render a loader', () => {
|
|
44
|
+
expect(wrapper.find('LoadingElement').length).toEqual(0)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
describe('without downloaded or previewed geoJsonData and error', () => {
|
|
49
|
+
it('renders loader', () => {
|
|
50
|
+
wrapper = shallow(<GeoJSONVisualization
|
|
51
|
+
previewDataset={previewDataset}
|
|
52
|
+
downloadDataset={downloadDataset}
|
|
53
|
+
/>)
|
|
54
|
+
|
|
55
|
+
expect(wrapper.find('LoadingElement').length).toEqual(1)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('renders an error component', () => {
|
|
59
|
+
expect(wrapper.find('ErrorComponent').length).toEqual(0)
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
describe('with geoJsonData present', () => {
|
|
64
|
+
const downloadedGeoJsonData = {
|
|
65
|
+
features: [{
|
|
66
|
+
geometry: {
|
|
67
|
+
type: 'MultiLineString',
|
|
68
|
+
coordinates: [[[1, 2], [3, 4], [5, 6]]]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
geometry: {
|
|
73
|
+
type: 'MultiLineString',
|
|
74
|
+
coordinates: [[[2, 3], [4, 5], [6, 7]]]
|
|
75
|
+
}
|
|
76
|
+
}]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const previewedGeoJsonData = {
|
|
80
|
+
features: [{
|
|
81
|
+
geometry: {
|
|
82
|
+
type: 'MultiLineString',
|
|
83
|
+
coordinates: [[[1, 2], [3, 4], [5, 6]]]
|
|
84
|
+
}
|
|
85
|
+
}]
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
describe('and both previewed and downloaded geojson data available', () => {
|
|
89
|
+
beforeEach(() => {
|
|
90
|
+
wrapper = shallow(<GeoJSONVisualization
|
|
91
|
+
previewDataset={previewDataset}
|
|
92
|
+
downloadDataset={downloadDataset}
|
|
93
|
+
downloadedGeoJsonData={downloadedGeoJsonData}
|
|
94
|
+
previewedGeoJsonData={previewedGeoJsonData}
|
|
95
|
+
/>)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('renders map', () => {
|
|
99
|
+
expect(wrapper.find(Map).length).toEqual(2)
|
|
100
|
+
expect(wrapper.find('LoadingElement').length).toEqual(0)
|
|
101
|
+
expect(wrapper.find('ErrorComponent').length).toEqual(0)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('transposes preview data bounding value to appropriate format for leaflet', () => {
|
|
105
|
+
const previewMapWrapper = wrapper.find('[test-id="preview-map"]')
|
|
106
|
+
expect(previewMapWrapper.find(Map).props().bounds).toEqual([[2, 1], [6, 5]])
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('shows the preview data by default', () => {
|
|
110
|
+
expect(isPreviewMapRendered(wrapper)).toBeTruthy()
|
|
111
|
+
expect(isDownloadedMapRendered(wrapper)).toBeTruthy()
|
|
112
|
+
expect(isPreviewMapHidden(wrapper)).toBeFalsy()
|
|
113
|
+
expect(isDownloadedMapHidden(wrapper)).toBeTruthy()
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('the show full data toggle is enabled', () => {
|
|
117
|
+
expect(wrapper.find(Checkbox).props().disabled).toBeFalsy()
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('shows the downloaded data when toggle is clicked', () => {
|
|
121
|
+
wrapper.find(Checkbox).props().clickHandler()
|
|
122
|
+
expect(isPreviewMapHidden(wrapper)).toBeTruthy()
|
|
123
|
+
expect(isDownloadedMapHidden(wrapper)).toBeFalsy()
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
describe('and only previewed geojson data available', () => {
|
|
128
|
+
beforeEach(() => {
|
|
129
|
+
wrapper = shallow(<GeoJSONVisualization
|
|
130
|
+
previewDataset={previewDataset}
|
|
131
|
+
downloadDataset={downloadDataset}
|
|
132
|
+
previewedGeoJsonData={previewedGeoJsonData}
|
|
133
|
+
/>)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
it('renders map', () => {
|
|
137
|
+
expect(isPreviewMapRendered(wrapper)).toBeTruthy()
|
|
138
|
+
expect(isDownloadedMapRendered(wrapper)).toBeFalsy()
|
|
139
|
+
expect(wrapper.find('LoadingElement').length).toEqual(0)
|
|
140
|
+
expect(wrapper.find('ErrorComponent').length).toEqual(0)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('transposes preview data bounding value to appropriate format for leaflet', () => {
|
|
144
|
+
const previewMapWrapper = wrapper.find('[test-id="preview-map"]')
|
|
145
|
+
expect(previewMapWrapper.find(Map).props().bounds).toEqual([[2, 1], [6, 5]])
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
it('shows the preview data by default', () => {
|
|
149
|
+
expect(isPreviewMapRendered(wrapper)).toBeTruthy()
|
|
150
|
+
expect(isDownloadedMapRendered(wrapper)).toBeFalsy()
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it('the show full data toggle is disabled', () => {
|
|
154
|
+
expect(wrapper.find(Checkbox).props().disabled).toBeTruthy()
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
describe('and only downloaded geojson data available', () => {
|
|
159
|
+
beforeEach(() => {
|
|
160
|
+
wrapper = shallow(<GeoJSONVisualization
|
|
161
|
+
previewDataset={previewDataset}
|
|
162
|
+
downloadDataset={downloadDataset}
|
|
163
|
+
downloadedGeoJsonData={downloadedGeoJsonData}
|
|
164
|
+
/>)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it('renders map', () => {
|
|
168
|
+
expect(isPreviewMapRendered(wrapper)).toBeFalsy()
|
|
169
|
+
expect(isDownloadedMapRendered(wrapper)).toBeTruthy()
|
|
170
|
+
expect(wrapper.find('LoadingElement').length).toEqual(0)
|
|
171
|
+
expect(wrapper.find('ErrorComponent').length).toEqual(0)
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
it('transposes downloaded data bounding value to appropriate format for leaflet', () => {
|
|
175
|
+
const downloadedMapWrapper = wrapper.find('[test-id="downloaded-map"]')
|
|
176
|
+
expect(downloadedMapWrapper.find(Map).props().bounds).toEqual([[2, 1], [7, 6]])
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('shows the downloaded data by default', () => {
|
|
180
|
+
expect(isPreviewMapRendered(wrapper)).toBeFalsy()
|
|
181
|
+
expect(isDownloadedMapRendered(wrapper)).toBeTruthy()
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('the show full data toggle is disabled', () => {
|
|
185
|
+
expect(wrapper.find(Checkbox).props().disabled).toBeTruthy()
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
describe('with geoJsonData with no coordinates', () => {
|
|
191
|
+
it('displays a default bounding box', () => {
|
|
192
|
+
const previewedGeoJsonData = { features: [] }
|
|
193
|
+
const downloadedGeoJsonData = { features: [], bbox: [null, null, null, null] }
|
|
194
|
+
wrapper = shallow(
|
|
195
|
+
<GeoJSONVisualization
|
|
196
|
+
previewDataset={previewDataset}
|
|
197
|
+
downloadDataset={downloadDataset}
|
|
198
|
+
previewedGeoJsonData={previewedGeoJsonData}
|
|
199
|
+
downloadedGeoJsonData={downloadedGeoJsonData}
|
|
200
|
+
/>)
|
|
201
|
+
|
|
202
|
+
const previewMapWrapper = wrapper.find('[test-id="preview-map"]')
|
|
203
|
+
expect(previewMapWrapper.find(Map).props().bounds).toEqual([[38.483320, -84.811309], [41.971108, -80.541532]])
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
describe('with no geoJsonData', () => {
|
|
208
|
+
it('the show full data toggle is disabled', () => {
|
|
209
|
+
wrapper = shallow(
|
|
210
|
+
<GeoJSONVisualization
|
|
211
|
+
previewDataset={previewDataset}
|
|
212
|
+
downloadDataset={downloadDataset}
|
|
213
|
+
previewedGeoJsonData={undefined}
|
|
214
|
+
downloadedGeoJsonData={undefined}
|
|
215
|
+
/>)
|
|
216
|
+
|
|
217
|
+
expect(wrapper.find(Checkbox).props().disabled).toBeTruthy()
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
function isPreviewMapHidden (wrapper) {
|
|
223
|
+
const previewMapWrapper = wrapper.find('[test-id="preview-map"]')
|
|
224
|
+
return previewMapWrapper.hasClass('hidden')
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function isDownloadedMapHidden (wrapper) {
|
|
228
|
+
const dowloadedMapWrapper = wrapper.find('[test-id="downloaded-map"]')
|
|
229
|
+
return dowloadedMapWrapper.hasClass('hidden')
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function isPreviewMapRendered (wrapper) {
|
|
233
|
+
return wrapper.find('[test-id="preview-map"]').exists()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function isDownloadedMapRendered (wrapper) {
|
|
237
|
+
return wrapper.find('[test-id="downloaded-map"]').exists()
|
|
238
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _connector = _interopRequireDefault(require("./connector"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = _connector.default;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { screen, render, fireEvent } from '@testing-library/react'
|
|
3
|
+
import ApiKeyView from './apikey-view'
|
|
4
|
+
import '@testing-library/jest-dom'
|
|
5
|
+
|
|
6
|
+
describe('apiKeyView component', () => {
|
|
7
|
+
describe('generate page', () => {
|
|
8
|
+
const fakeProps = {
|
|
9
|
+
apiKey: '',
|
|
10
|
+
isLoading: false,
|
|
11
|
+
generate: jest.fn(),
|
|
12
|
+
dismissGlobalError: jest.fn()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
jest.resetAllMocks()
|
|
17
|
+
render(<ApiKeyView {...fakeProps} />)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('Contains a header', () => {
|
|
21
|
+
const subject = screen.getByText('Generate API Key')
|
|
22
|
+
|
|
23
|
+
expect(subject).toBeInTheDocument()
|
|
24
|
+
expect(subject).toHaveClass('apiKey-view-title')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('Contains instruction text', () => {
|
|
28
|
+
const expectedText = 'Your API key should be kept secure and never shared. For security reasons, we do not display your API key.'
|
|
29
|
+
const expectedText2 = 'For first time API Key creation or if you lose your API key, you can generate a new key here.'
|
|
30
|
+
|
|
31
|
+
const subject = screen.getByText(expectedText)
|
|
32
|
+
const subject2 = screen.getByText(expectedText2)
|
|
33
|
+
|
|
34
|
+
expect(subject).toBeInTheDocument()
|
|
35
|
+
expect(subject2).toBeInTheDocument()
|
|
36
|
+
|
|
37
|
+
expect(subject).toHaveClass('apiKey-view-paragraph')
|
|
38
|
+
expect(subject2).toHaveClass('apiKey-view-paragraph')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('Contains a generate api key button', () => {
|
|
42
|
+
const expectedText = 'Generate'
|
|
43
|
+
|
|
44
|
+
const subject = screen.getByRole('button', { name: expectedText })
|
|
45
|
+
|
|
46
|
+
expect(subject).toBeInTheDocument()
|
|
47
|
+
|
|
48
|
+
expect(subject).toHaveClass('apiKey-view-generate-button')
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe('confirmation modal', () => {
|
|
53
|
+
let modal
|
|
54
|
+
const fakeProps = {
|
|
55
|
+
apiKey: '',
|
|
56
|
+
isLoading: false,
|
|
57
|
+
generate: jest.fn(),
|
|
58
|
+
dismissGlobalError: jest.fn()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
beforeEach(async () => {
|
|
62
|
+
jest.resetAllMocks()
|
|
63
|
+
render(<ApiKeyView {...fakeProps} />)
|
|
64
|
+
|
|
65
|
+
const generateButton = screen.getByRole('button', { name: 'Generate' })
|
|
66
|
+
fireEvent.click(generateButton)
|
|
67
|
+
|
|
68
|
+
modal = await screen.findByRole('dialog', { hidden: true })
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('Is opened from the Generate button', () => {
|
|
72
|
+
expect(modal).toBeInTheDocument()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('Contains a generate button', () => {
|
|
76
|
+
const modalGenerateButton = screen.getByRole('button', { name: 'Confirm', hidden: true })
|
|
77
|
+
expect(modalGenerateButton).toBeInTheDocument()
|
|
78
|
+
|
|
79
|
+
expect(modalGenerateButton).toHaveClass('modal-confirm-button')
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it('Generates the API key when the generate button is clicked', () => {
|
|
83
|
+
const modalGenerateButton = screen.getByRole('button', { name: 'Confirm', hidden: true })
|
|
84
|
+
expect(modalGenerateButton).toBeInTheDocument()
|
|
85
|
+
expect(modalGenerateButton).toHaveClass('modal-confirm-button')
|
|
86
|
+
|
|
87
|
+
fireEvent.click(modalGenerateButton)
|
|
88
|
+
|
|
89
|
+
expect(fakeProps.generate).toHaveBeenCalled()
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('Contains a cancel button', () => {
|
|
93
|
+
const modalCancelButton = screen.getByRole('button', { name: 'Cancel', hidden: true })
|
|
94
|
+
|
|
95
|
+
expect(modalCancelButton).toBeInTheDocument()
|
|
96
|
+
expect(modalCancelButton).toHaveClass('modal-cancel-button')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('Closes the modal when cancel button is clicked', () => {
|
|
100
|
+
const modalCancelButton = screen.getByRole('button', { name: 'Cancel', hidden: true })
|
|
101
|
+
expect(modalCancelButton).toBeInTheDocument()
|
|
102
|
+
expect(modalCancelButton).toHaveClass('modal-cancel-button')
|
|
103
|
+
|
|
104
|
+
fireEvent.click(modalCancelButton)
|
|
105
|
+
|
|
106
|
+
expect(modal).not.toBeInTheDocument()
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
describe('when isLoading', () => {
|
|
111
|
+
const fakeProps = {
|
|
112
|
+
apiKey: '',
|
|
113
|
+
isLoading: true,
|
|
114
|
+
generate: jest.fn(),
|
|
115
|
+
dismissGlobalError: jest.fn()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
beforeEach(async () => {
|
|
119
|
+
jest.resetAllMocks()
|
|
120
|
+
render(<ApiKeyView {...fakeProps} />)
|
|
121
|
+
const generateButton = screen.getByRole('button', { name: 'Generate' })
|
|
122
|
+
fireEvent.click(generateButton)
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('Displays a loading spinner when the generate button is clicked', () => {
|
|
126
|
+
const loadingSpinner = screen.getByTestId('loading-spinner', { hidden: true })
|
|
127
|
+
expect(loadingSpinner).toBeInTheDocument()
|
|
128
|
+
expect(loadingSpinner).toHaveClass('loading-spinner')
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
describe('display page', () => {
|
|
133
|
+
const fakeProps = {
|
|
134
|
+
apiKey: 'someFakeApiKey',
|
|
135
|
+
isLoading: false,
|
|
136
|
+
generate: jest.fn(),
|
|
137
|
+
dismissGlobalError: jest.fn()
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
beforeEach(() => {
|
|
141
|
+
jest.resetAllMocks()
|
|
142
|
+
render(<ApiKeyView {...fakeProps} />)
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
it('Contains a header', () => {
|
|
146
|
+
const subject = screen.getByText('Your API Key')
|
|
147
|
+
|
|
148
|
+
expect(subject).toBeInTheDocument()
|
|
149
|
+
expect(subject).toHaveClass('apiKey-view-title')
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
it('Contains instruction text', () => {
|
|
153
|
+
const expectedText = 'This API key will only be displayed once. Please store it somewhere secure. If you lose it, you will need to reset your key to get a new one.'
|
|
154
|
+
|
|
155
|
+
const subject = screen.getByText(expectedText)
|
|
156
|
+
|
|
157
|
+
expect(subject).toBeInTheDocument()
|
|
158
|
+
|
|
159
|
+
expect(subject).toHaveClass('apiKey-view-paragraph')
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
it('Contains a sub-header', () => {
|
|
163
|
+
const subject = screen.getByText('API Key')
|
|
164
|
+
|
|
165
|
+
expect(subject).toBeInTheDocument()
|
|
166
|
+
expect(subject).toHaveClass('apiKey-view-sub-title')
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
it('Contains an display window for the api key', () => {
|
|
170
|
+
const subject = screen.getByDisplayValue(fakeProps.apiKey)
|
|
171
|
+
|
|
172
|
+
expect(subject).toBeInTheDocument()
|
|
173
|
+
expect(subject).toHaveClass('apiKey-view-display-page-display-window')
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('Contains a copy button for the api key', () => {
|
|
177
|
+
const subject = screen.getByText('Copy')
|
|
178
|
+
|
|
179
|
+
expect(subject).toBeInTheDocument()
|
|
180
|
+
expect(subject).toHaveClass('apiKey-view-display-page-copy-button')
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
it('Copies the api key when clicking on the copy button', () => {
|
|
184
|
+
navigator.clipboard = {
|
|
185
|
+
writeText: jest.fn()
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const copyButton = screen.getByText('Copy')
|
|
189
|
+
expect(copyButton).toBeInTheDocument()
|
|
190
|
+
expect(copyButton).toHaveClass('apiKey-view-display-page-copy-button')
|
|
191
|
+
|
|
192
|
+
fireEvent.click(copyButton)
|
|
193
|
+
|
|
194
|
+
expect(navigator.clipboard.writeText).toHaveBeenCalledWith(fakeProps.apiKey)
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
it('Contains a return home button', () => {
|
|
198
|
+
const subject = screen.getByText('Return Home')
|
|
199
|
+
|
|
200
|
+
expect(subject).toBeInTheDocument()
|
|
201
|
+
expect(subject).toHaveClass('apiKey-view-display-page-return-button')
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
})
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
require("./apikey-view.scss");
|
|
9
|
+
var _reactAriaModal = _interopRequireDefault(require("react-aria-modal"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _ReportProblemOutlined = _interopRequireDefault(require("@material-ui/icons/ReportProblemOutlined"));
|
|
12
|
+
var _loadingElement = _interopRequireDefault(require("../../components/generic-elements/loading-element"));
|
|
13
|
+
var _alertComponent = _interopRequireDefault(require("../../components/generic-elements/alert-component"));
|
|
14
|
+
var _routes = _interopRequireDefault(require("../../routes"));
|
|
15
|
+
var _FileCopy = _interopRequireDefault(require("@material-ui/icons/FileCopy"));
|
|
16
|
+
var _Close = _interopRequireDefault(require("@material-ui/icons/Close"));
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { throw: 1, return: 2, break: 3, continue: 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, catch: function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
|
|
19
|
+
function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
|
|
20
|
+
function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
|
|
21
|
+
function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
|
|
22
|
+
function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
|
|
23
|
+
function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
|
|
24
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
25
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
26
|
+
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
27
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
28
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
29
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
30
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
31
|
+
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; } }
|
|
32
|
+
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; }
|
|
33
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
34
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
35
|
+
var ApiKeyView = function ApiKeyView(_ref) {
|
|
36
|
+
var apiKey = _ref.apiKey,
|
|
37
|
+
isLoading = _ref.isLoading,
|
|
38
|
+
isError = _ref.isError,
|
|
39
|
+
errorMessage = _ref.errorMessage,
|
|
40
|
+
generate = _ref.generate,
|
|
41
|
+
dismissGlobalError = _ref.dismissGlobalError;
|
|
42
|
+
var _useState = (0, _react.useState)(false),
|
|
43
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
44
|
+
modalIsOpen = _useState2[0],
|
|
45
|
+
setIsOpen = _useState2[1];
|
|
46
|
+
var openModal = function openModal() {
|
|
47
|
+
setIsOpen(true);
|
|
48
|
+
};
|
|
49
|
+
var closeModal = function closeModal() {
|
|
50
|
+
setIsOpen(false);
|
|
51
|
+
};
|
|
52
|
+
var copyApiKeyToClipboard = /*#__PURE__*/function () {
|
|
53
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
54
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
55
|
+
while (1) switch (_context.prev = _context.next) {
|
|
56
|
+
case 0:
|
|
57
|
+
if (!('clipboard' in navigator)) {
|
|
58
|
+
_context.next = 6;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
_context.next = 3;
|
|
62
|
+
return navigator.clipboard.writeText(apiKey);
|
|
63
|
+
case 3:
|
|
64
|
+
return _context.abrupt("return", _context.sent);
|
|
65
|
+
case 6:
|
|
66
|
+
return _context.abrupt("return", document.execCommand('copy', true, apiKey));
|
|
67
|
+
case 7:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee);
|
|
72
|
+
}));
|
|
73
|
+
return function copyApiKeyToClipboard() {
|
|
74
|
+
return _ref2.apply(this, arguments);
|
|
75
|
+
};
|
|
76
|
+
}();
|
|
77
|
+
var renderModal = function renderModal() {
|
|
78
|
+
return modalIsOpen ? /*#__PURE__*/React.createElement(_reactAriaModal.default, {
|
|
79
|
+
isOpen: modalIsOpen,
|
|
80
|
+
titleText: "Generate API Key"
|
|
81
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
className: "modal-container"
|
|
83
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
className: "modal-header-box"
|
|
85
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
86
|
+
className: "modal-title"
|
|
87
|
+
}, "Generate API Key"), /*#__PURE__*/React.createElement(_Close.default, {
|
|
88
|
+
className: "modal-close-button",
|
|
89
|
+
onClick: closeModal
|
|
90
|
+
})), /*#__PURE__*/React.createElement("hr", {
|
|
91
|
+
className: "solid"
|
|
92
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
93
|
+
className: "modal-paragraph"
|
|
94
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
95
|
+
className: "apikey-modal-warning-icon-container"
|
|
96
|
+
}, /*#__PURE__*/React.createElement(_ReportProblemOutlined.default, {
|
|
97
|
+
className: "apikey-modal-warning-icon"
|
|
98
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
99
|
+
className: "paragraph-text"
|
|
100
|
+
}, "Please note that generating a new API key will invalidate any existing API configurations. You will need to update any system using your API key with the newly generated key."), isLoading && /*#__PURE__*/React.createElement("div", {
|
|
101
|
+
className: "loading-spinner-container"
|
|
102
|
+
}, /*#__PURE__*/React.createElement(_loadingElement.default, {
|
|
103
|
+
className: "loading-spinner"
|
|
104
|
+
}))), /*#__PURE__*/React.createElement("hr", {
|
|
105
|
+
className: "solid"
|
|
106
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: "modal-button-group"
|
|
108
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
109
|
+
className: "modal-confirm-button",
|
|
110
|
+
onClick: generate
|
|
111
|
+
}, "Confirm"), /*#__PURE__*/React.createElement("button", {
|
|
112
|
+
className: "modal-cancel-button",
|
|
113
|
+
onClick: closeModal
|
|
114
|
+
}, "Cancel")))) : false;
|
|
115
|
+
};
|
|
116
|
+
var renderGeneratePage = function renderGeneratePage() {
|
|
117
|
+
return /*#__PURE__*/React.createElement("div", null, renderModal(), /*#__PURE__*/React.createElement("h1", {
|
|
118
|
+
className: "apiKey-view-title"
|
|
119
|
+
}, "Generate API Key ", apiKey), /*#__PURE__*/React.createElement("div", {
|
|
120
|
+
className: "apiKey-view-paragraph"
|
|
121
|
+
}, "Your API key should be kept secure and never shared. For security reasons, we do not display your API key."), /*#__PURE__*/React.createElement("div", {
|
|
122
|
+
className: "apiKey-view-paragraph"
|
|
123
|
+
}, "For first time API Key creation or if you lose your API key, you can generate a new key here."), /*#__PURE__*/React.createElement("button", {
|
|
124
|
+
className: "apiKey-view-generate-button primary-background-color",
|
|
125
|
+
onClick: openModal
|
|
126
|
+
}, "Generate"));
|
|
127
|
+
};
|
|
128
|
+
var renderDisplayPage = function renderDisplayPage() {
|
|
129
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", {
|
|
130
|
+
className: "apiKey-view-title"
|
|
131
|
+
}, "Your API Key"), /*#__PURE__*/React.createElement("div", {
|
|
132
|
+
className: "apiKey-view-paragraph"
|
|
133
|
+
}, "This API key will only be displayed once. Please store it somewhere secure. If you lose it, you will need to reset your key to get a new one."), /*#__PURE__*/React.createElement("label", {
|
|
134
|
+
className: "apiKey-view-sub-title",
|
|
135
|
+
for: "apiKey"
|
|
136
|
+
}, "API Key"), /*#__PURE__*/React.createElement("div", {
|
|
137
|
+
className: "apiKey-view-display-page-display-window-container"
|
|
138
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
139
|
+
className: "apiKey-view-display-page-display-window",
|
|
140
|
+
id: "apiKey",
|
|
141
|
+
type: "text",
|
|
142
|
+
value: apiKey,
|
|
143
|
+
readOnly: true
|
|
144
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
145
|
+
className: "apiKey-view-display-page-copy-button primary-background-color",
|
|
146
|
+
onClick: copyApiKeyToClipboard
|
|
147
|
+
}, "Copy", /*#__PURE__*/React.createElement(_FileCopy.default, null))), /*#__PURE__*/React.createElement("div", {
|
|
148
|
+
className: "apiKey-view-display-page-return-button-container"
|
|
149
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
150
|
+
role: "link",
|
|
151
|
+
className: "apiKey-view-display-page-return-button-link",
|
|
152
|
+
tabIndex: "-1",
|
|
153
|
+
href: _routes.default.root
|
|
154
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
155
|
+
className: "apiKey-view-display-page-return-button primary-background-color"
|
|
156
|
+
}, " Return Home"))));
|
|
157
|
+
};
|
|
158
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
159
|
+
className: "apiKey-view-container"
|
|
160
|
+
}, /*#__PURE__*/React.createElement(_alertComponent.default, {
|
|
161
|
+
errorMessage: errorMessage,
|
|
162
|
+
closeFunction: dismissGlobalError,
|
|
163
|
+
showAlert: isError
|
|
164
|
+
}), !apiKey && renderGeneratePage(), apiKey && renderDisplayPage());
|
|
165
|
+
};
|
|
166
|
+
var _default = exports.default = ApiKeyView;
|