@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,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
require("./query-form.scss");
|
|
10
|
+
require("@trendmicro/react-buttons/dist/react-buttons.css");
|
|
11
|
+
require("@trendmicro/react-dropdown/dist/react-dropdown.css");
|
|
12
|
+
var _reactDropdown2 = _interopRequireWildcard(require("@trendmicro/react-dropdown"));
|
|
13
|
+
var _loadingElement = _interopRequireDefault(require("../generic-elements/loading-element"));
|
|
14
|
+
var _recommendationList = _interopRequireDefault(require("../recommendation-list"));
|
|
15
|
+
var _reactTooltip = _interopRequireDefault(require("react-tooltip"));
|
|
16
|
+
var _InfoOutlined = _interopRequireDefault(require("@material-ui/icons/InfoOutlined"));
|
|
17
|
+
var _MergeType = _interopRequireDefault(require("@material-ui/icons/MergeType"));
|
|
18
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
19
|
+
var _reactRouterDom = require("react-router-dom");
|
|
20
|
+
var _codeEditor = _interopRequireDefault(require("../code-editor"));
|
|
21
|
+
var _js2xmlparser = require("js2xmlparser");
|
|
22
|
+
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); }
|
|
23
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
|
+
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); }
|
|
25
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
26
|
+
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."); }
|
|
27
|
+
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; } }
|
|
28
|
+
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; }
|
|
29
|
+
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; } }
|
|
30
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
31
|
+
var QueryForm = function QueryForm(props) {
|
|
32
|
+
var queryText = props.queryText,
|
|
33
|
+
recommendations = props.recommendations,
|
|
34
|
+
usedDatasets = props.usedDatasets,
|
|
35
|
+
datasetReferences = props.datasetReferences,
|
|
36
|
+
isQueryLoading = props.isQueryLoading,
|
|
37
|
+
queryFailureMessage = props.queryFailureMessage,
|
|
38
|
+
isQueryDataAvailable = props.isQueryDataAvailable,
|
|
39
|
+
queryData = props.queryData,
|
|
40
|
+
executeQuery = props.executeQuery,
|
|
41
|
+
cancelQuery = props.cancelQuery,
|
|
42
|
+
setQueryText = props.setQueryText;
|
|
43
|
+
var _useState = (0, _react.useState)(queryText),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
localQueryText = _useState2[0],
|
|
46
|
+
setLocalQueryText = _useState2[1];
|
|
47
|
+
React.useEffect(function () {
|
|
48
|
+
setLocalQueryText(queryText);
|
|
49
|
+
}, [queryText]);
|
|
50
|
+
var updateReduxQueryText = function updateReduxQueryText(e) {
|
|
51
|
+
setQueryText(e.target.value);
|
|
52
|
+
setLocalQueryText(e.target.value);
|
|
53
|
+
};
|
|
54
|
+
var submit = function submit() {
|
|
55
|
+
executeQuery(localQueryText);
|
|
56
|
+
};
|
|
57
|
+
var cancel = function cancel() {
|
|
58
|
+
cancelQuery();
|
|
59
|
+
};
|
|
60
|
+
var textArea = /*#__PURE__*/React.createElement(_codeEditor.default, {
|
|
61
|
+
code: localQueryText,
|
|
62
|
+
onBlur: updateReduxQueryText,
|
|
63
|
+
"data-testid": "query-input",
|
|
64
|
+
"aria-label": "SQL Query Input"
|
|
65
|
+
});
|
|
66
|
+
var submitButton = /*#__PURE__*/React.createElement("button", {
|
|
67
|
+
"data-testid": "submit-query-button",
|
|
68
|
+
className: "action-button",
|
|
69
|
+
disabled: isQueryLoading,
|
|
70
|
+
onClick: submit
|
|
71
|
+
}, "Submit");
|
|
72
|
+
var cancelButton = /*#__PURE__*/React.createElement("button", {
|
|
73
|
+
"data-testid": "cancel-query-button",
|
|
74
|
+
className: "action-button",
|
|
75
|
+
disabled: !isQueryLoading,
|
|
76
|
+
onClick: cancel
|
|
77
|
+
}, "Cancel");
|
|
78
|
+
var showSuccessMessage = !queryFailureMessage && isQueryDataAvailable && !isQueryLoading;
|
|
79
|
+
var successMessage = showSuccessMessage && /*#__PURE__*/React.createElement("span", {
|
|
80
|
+
"data-testid": "success-message",
|
|
81
|
+
className: "success-message"
|
|
82
|
+
}, "Query successful");
|
|
83
|
+
var showFailureMessage = queryFailureMessage && !isQueryLoading;
|
|
84
|
+
var failureMessage = showFailureMessage && /*#__PURE__*/React.createElement("span", {
|
|
85
|
+
"data-testid": "error-message",
|
|
86
|
+
className: "error-message"
|
|
87
|
+
}, /*#__PURE__*/React.createElement("span", null, "Query Failed"), /*#__PURE__*/React.createElement("div", null, queryFailureMessage));
|
|
88
|
+
var recommendationSection = function recommendationSection() {
|
|
89
|
+
var toolTipText = 'These datasets have related fields or columns that may be suitable for joining in your query';
|
|
90
|
+
if (!_lodash.default.isEmpty(recommendations)) {
|
|
91
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: "recommendation-section link-list"
|
|
93
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: "title"
|
|
95
|
+
}, /*#__PURE__*/React.createElement("span", null, "Recommendations"), /*#__PURE__*/React.createElement(_reactTooltip.default, {
|
|
96
|
+
effect: "solid"
|
|
97
|
+
}), /*#__PURE__*/React.createElement(_InfoOutlined.default, {
|
|
98
|
+
className: "info-icon",
|
|
99
|
+
"data-tip": toolTipText
|
|
100
|
+
})), /*#__PURE__*/React.createElement(_recommendationList.default, {
|
|
101
|
+
recommendations: recommendations
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var createDatasetLinks = function createDatasetLinks(datasetIds) {
|
|
106
|
+
return datasetIds.map(function (datasetId) {
|
|
107
|
+
var dataset = datasetReferences[datasetId];
|
|
108
|
+
if (!dataset) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
112
|
+
className: "dataset-reference",
|
|
113
|
+
key: datasetId
|
|
114
|
+
}, /*#__PURE__*/React.createElement(_MergeType.default, {
|
|
115
|
+
className: "icon"
|
|
116
|
+
}), /*#__PURE__*/React.createElement(_reactRouterDom.Link, {
|
|
117
|
+
target: "_blank",
|
|
118
|
+
to: "/dataset/".concat(dataset.org, "/").concat(dataset.name)
|
|
119
|
+
}, dataset.title));
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
var usedDatasetsSection = function usedDatasetsSection() {
|
|
123
|
+
var toolTipText = 'These datasets are used in the query. This list is regenerated whenever the visualization is saved.';
|
|
124
|
+
if (!_lodash.default.isEmpty(usedDatasets)) {
|
|
125
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
126
|
+
className: "link-list"
|
|
127
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
128
|
+
className: "title"
|
|
129
|
+
}, /*#__PURE__*/React.createElement("span", null, "Used Datasets"), /*#__PURE__*/React.createElement(_reactTooltip.default, {
|
|
130
|
+
effect: "solid"
|
|
131
|
+
}), /*#__PURE__*/React.createElement(_InfoOutlined.default, {
|
|
132
|
+
className: "info-icon",
|
|
133
|
+
"data-tip": toolTipText
|
|
134
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
135
|
+
className: "used-datasets-section"
|
|
136
|
+
}, createDatasetLinks(usedDatasets)));
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
var dataObj, data, tempLink;
|
|
140
|
+
var queryDataDownloadLinkAsCsv = function queryDataDownloadLinkAsCsv() {
|
|
141
|
+
dataObj = queryDataToCSV(queryData);
|
|
142
|
+
data = new Blob([dataObj], {
|
|
143
|
+
type: "application/json"
|
|
144
|
+
});
|
|
145
|
+
tempLink = document.createElement('a');
|
|
146
|
+
tempLink.href = window.URL.createObjectURL(data);
|
|
147
|
+
tempLink.setAttribute('download', 'query_results.csv');
|
|
148
|
+
tempLink.click();
|
|
149
|
+
};
|
|
150
|
+
var queryDataDownloadLinkAsJson = function queryDataDownloadLinkAsJson() {
|
|
151
|
+
dataObj = JSON.stringify(queryData);
|
|
152
|
+
data = new Blob([dataObj], {
|
|
153
|
+
type: "text/csv"
|
|
154
|
+
});
|
|
155
|
+
tempLink = document.createElement('a');
|
|
156
|
+
tempLink.href = window.URL.createObjectURL(data);
|
|
157
|
+
tempLink.setAttribute('download', 'query_results.json');
|
|
158
|
+
tempLink.click();
|
|
159
|
+
};
|
|
160
|
+
var queryDataDownloadLinkAsXml = function queryDataDownloadLinkAsXml() {
|
|
161
|
+
dataObj = (0, _js2xmlparser.parse)("results", queryData);
|
|
162
|
+
data = new Blob([dataObj], {
|
|
163
|
+
type: "application/xml"
|
|
164
|
+
});
|
|
165
|
+
tempLink = document.createElement('a');
|
|
166
|
+
tempLink.href = window.URL.createObjectURL(data);
|
|
167
|
+
tempLink.setAttribute('download', 'query_results.xml');
|
|
168
|
+
tempLink.click();
|
|
169
|
+
};
|
|
170
|
+
var keys, csv, row;
|
|
171
|
+
var queryDataToCSV = function queryDataToCSV(dataObj) {
|
|
172
|
+
if (dataObj == undefined || dataObj == null || dataObj == []) return '';
|
|
173
|
+
row = dataObj[0];
|
|
174
|
+
if (row == undefined || row == null) return '';
|
|
175
|
+
keys = Object.keys(row);
|
|
176
|
+
csv = keys.join(',') + '\n';
|
|
177
|
+
dataObj.forEach(function (row) {
|
|
178
|
+
Object.values(row).forEach(function (colVal) {
|
|
179
|
+
colVal = parseJsonStringField(colVal);
|
|
180
|
+
colVal = prepareFieldForCSV(colVal);
|
|
181
|
+
csv += colVal + ',';
|
|
182
|
+
});
|
|
183
|
+
csv += '\n';
|
|
184
|
+
});
|
|
185
|
+
return csv;
|
|
186
|
+
};
|
|
187
|
+
var prepareFieldForCSV = function prepareFieldForCSV(colVal) {
|
|
188
|
+
if (colVal == null) {
|
|
189
|
+
colVal = '';
|
|
190
|
+
} else if (_typeof(colVal) === 'object') {
|
|
191
|
+
colVal = JSON.stringify(colVal);
|
|
192
|
+
colVal = colVal.replaceAll('"', '""');
|
|
193
|
+
colVal = "\"".concat(colVal, "\"");
|
|
194
|
+
} else {
|
|
195
|
+
colVal = "\"".concat(colVal, "\"");
|
|
196
|
+
}
|
|
197
|
+
return colVal;
|
|
198
|
+
};
|
|
199
|
+
var parseJsonStringField = function parseJsonStringField(stringifiedJson) {
|
|
200
|
+
try {
|
|
201
|
+
return JSON.parse(stringifiedJson);
|
|
202
|
+
} catch (error) {
|
|
203
|
+
return stringifiedJson;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
var downloadButtonColor = window.PRIMARY_COLOR || '#0F64B3';
|
|
207
|
+
return /*#__PURE__*/React.createElement("query-form", null, /*#__PURE__*/React.createElement("h1", null, "Query Dataset"), /*#__PURE__*/React.createElement("div", {
|
|
208
|
+
className: "user-input"
|
|
209
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
210
|
+
className: "sql-section"
|
|
211
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
212
|
+
for: "code-editor",
|
|
213
|
+
className: "sql-title"
|
|
214
|
+
}, "Enter your SQL query below. For best performance, you should limit your results to no more than 20,000 rows."), textArea), /*#__PURE__*/React.createElement("div", {
|
|
215
|
+
className: "query-info"
|
|
216
|
+
}, recommendationSection(), usedDatasetsSection())), /*#__PURE__*/React.createElement("div", {
|
|
217
|
+
className: "query-form__btn-group"
|
|
218
|
+
}, submitButton, cancelButton, successMessage, /*#__PURE__*/React.createElement(_reactDropdown2.default, {
|
|
219
|
+
className: "download-dropdown",
|
|
220
|
+
disabled: isQueryLoading
|
|
221
|
+
}, /*#__PURE__*/React.createElement(_reactDropdown2.default.Toggle, {
|
|
222
|
+
title: "Download Returned Results",
|
|
223
|
+
style: {
|
|
224
|
+
background: downloadButtonColor,
|
|
225
|
+
color: 'white',
|
|
226
|
+
border: 'none',
|
|
227
|
+
padding: '1rem'
|
|
228
|
+
}
|
|
229
|
+
}), /*#__PURE__*/React.createElement(_reactDropdown2.default.MenuWrapper, null, /*#__PURE__*/React.createElement(_reactDropdown2.default.Menu, null, /*#__PURE__*/React.createElement(_reactDropdown2.MenuItem, {
|
|
230
|
+
onKeyDown: function onKeyDown(event) {
|
|
231
|
+
return (event.key === ' ' || event.key === 'Enter') && queryDataDownloadLinkAsCsv();
|
|
232
|
+
},
|
|
233
|
+
onClick: function onClick() {
|
|
234
|
+
return queryDataDownloadLinkAsCsv();
|
|
235
|
+
}
|
|
236
|
+
}, "CSV"), /*#__PURE__*/React.createElement(_reactDropdown2.MenuItem, {
|
|
237
|
+
onKeyDown: function onKeyDown(event) {
|
|
238
|
+
return (event.key === ' ' || event.key === 'Enter') && queryDataDownloadLinkAsJson();
|
|
239
|
+
},
|
|
240
|
+
onClick: function onClick() {
|
|
241
|
+
return queryDataDownloadLinkAsJson();
|
|
242
|
+
}
|
|
243
|
+
}, "JSON"), /*#__PURE__*/React.createElement(_reactDropdown2.MenuItem, {
|
|
244
|
+
onKeyDown: function onKeyDown(event) {
|
|
245
|
+
return (event.key === ' ' || event.key === 'Enter') && queryDataDownloadLinkAsJson();
|
|
246
|
+
},
|
|
247
|
+
onClick: function onClick() {
|
|
248
|
+
return queryDataDownloadLinkAsXml();
|
|
249
|
+
}
|
|
250
|
+
}, "XML")))), failureMessage, isQueryLoading && /*#__PURE__*/React.createElement(_loadingElement.default, null)));
|
|
251
|
+
};
|
|
252
|
+
QueryForm.propTypes = {
|
|
253
|
+
queryText: _propTypes.default.string,
|
|
254
|
+
recommendations: _propTypes.default.array,
|
|
255
|
+
queryFailureMessage: _propTypes.default.string,
|
|
256
|
+
isQueryDataAvailable: _propTypes.default.bool,
|
|
257
|
+
isQueryLoading: _propTypes.default.bool.isRequired,
|
|
258
|
+
executeQuery: _propTypes.default.func.isRequired,
|
|
259
|
+
cancelQuery: _propTypes.default.func.isRequired,
|
|
260
|
+
setQueryText: _propTypes.default.func.isRequired
|
|
261
|
+
};
|
|
262
|
+
var _default = exports.default = QueryForm;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
@import "../../styles/variables.scss";
|
|
2
|
+
@import "../../styles/mixins.scss";
|
|
3
|
+
|
|
4
|
+
query-form {
|
|
5
|
+
$default-margin: 1.25rem;
|
|
6
|
+
|
|
7
|
+
margin: $default-margin;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
|
|
12
|
+
.action-button {
|
|
13
|
+
@include button();
|
|
14
|
+
padding: 1rem;
|
|
15
|
+
background-color: $light-blue;
|
|
16
|
+
color: white;
|
|
17
|
+
letter-spacing: 0.05rem;
|
|
18
|
+
margin: 1rem 1rem 1rem 0rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.download-dropdown {
|
|
22
|
+
float: right;
|
|
23
|
+
margin-top: 1rem;
|
|
24
|
+
|
|
25
|
+
.dropdown---caret---3CkEt {
|
|
26
|
+
border-top: 4px dashed $super-light-grey;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.dropdown---dropdown-menu-wrapper---3gX-X,
|
|
30
|
+
.dropdown---dropdown-menu---1fkH0 {
|
|
31
|
+
width: -webkit-fill-available;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.dropdown---menu-item---1LjoL {
|
|
35
|
+
text-align: right;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
a {
|
|
39
|
+
text-decoration: none;
|
|
40
|
+
color: black;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.query-form__btn-group {
|
|
45
|
+
width: 100%;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
button:disabled,
|
|
49
|
+
button:disabled:hover {
|
|
50
|
+
background: #efefef;
|
|
51
|
+
border: 1px solid #b1bbc9;
|
|
52
|
+
color: #a2a9b3;
|
|
53
|
+
text-decoration: none;
|
|
54
|
+
cursor: default;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.error-message {
|
|
58
|
+
color: $error-color;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
loading-element {
|
|
62
|
+
display: inline-block;
|
|
63
|
+
width: 3rem;
|
|
64
|
+
margin: 0;
|
|
65
|
+
vertical-align: middle;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.recommended-dataset {
|
|
69
|
+
width: 20em;
|
|
70
|
+
display: inline-block;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
textarea {
|
|
74
|
+
width: 100%;
|
|
75
|
+
border-color: black;
|
|
76
|
+
resize: none;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.user-input {
|
|
80
|
+
width: 100%;
|
|
81
|
+
display: flex;
|
|
82
|
+
margin-right: 2rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.dataset-reference {
|
|
86
|
+
margin-bottom: 0.7rem;
|
|
87
|
+
display: block;
|
|
88
|
+
|
|
89
|
+
.icon {
|
|
90
|
+
vertical-align: top;
|
|
91
|
+
margin-right: 0.4rem;
|
|
92
|
+
width: 10%;
|
|
93
|
+
height: 1.4rem;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
a {
|
|
97
|
+
@include link();
|
|
98
|
+
color: $dark-blue;
|
|
99
|
+
|
|
100
|
+
&:hover {
|
|
101
|
+
color: $almost-black;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&:active {
|
|
105
|
+
color: $medium-grey
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.sql-title {
|
|
111
|
+
margin-bottom: $default-margin;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.sql-textbox {
|
|
115
|
+
padding: 0.5rem;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.sql-section {
|
|
119
|
+
width: 70%;
|
|
120
|
+
flex-grow: 3;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.query-info {
|
|
124
|
+
width: 30%;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.link-list {
|
|
128
|
+
margin-left: 3rem;
|
|
129
|
+
padding-bottom: 1rem;
|
|
130
|
+
flex-grow: 1;
|
|
131
|
+
|
|
132
|
+
.title {
|
|
133
|
+
margin-bottom: $default-margin;
|
|
134
|
+
|
|
135
|
+
span {
|
|
136
|
+
font-weight: bold;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.info-icon {
|
|
140
|
+
height: 1rem;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.used-datasets-section {
|
|
146
|
+
border: 1px solid $light-grey;
|
|
147
|
+
max-height: 100%;
|
|
148
|
+
overflow-y: auto;
|
|
149
|
+
border: 1px solid $almost-black;
|
|
150
|
+
display: inline-block;
|
|
151
|
+
padding: 0.5rem;
|
|
152
|
+
|
|
153
|
+
&::-webkit-scrollbar {
|
|
154
|
+
-webkit-appearance: none;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
&::-webkit-scrollbar:vertical {
|
|
158
|
+
width: 11px;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&::-webkit-scrollbar-thumb {
|
|
162
|
+
border-radius: 8px;
|
|
163
|
+
border: 2px solid white;
|
|
164
|
+
background-color: $almost-black;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { mount } from 'enzyme'
|
|
2
|
+
import QueryForm from './query-form'
|
|
3
|
+
import { BrowserRouter as Router } from 'react-router-dom'
|
|
4
|
+
import LoadingElement from '../generic-elements/loading-element'
|
|
5
|
+
import RecommendationList from '../recommendation-list'
|
|
6
|
+
import { recommendations } from '../../../test-helpers/recommendations'
|
|
7
|
+
|
|
8
|
+
let subject, queryCallback, updateCallback
|
|
9
|
+
|
|
10
|
+
describe('QueryForm', () => {
|
|
11
|
+
describe('on initial running query', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
subject = createSubject({ isQueryLoaded: false, isQueryLoading: true })
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('shows loading component', () => {
|
|
17
|
+
expect(subject.find(LoadingElement).length).toEqual(1)
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('on user editing query', () => {
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
updateCallback = jest.fn()
|
|
24
|
+
subject = createSubject({ setQueryText: updateCallback })
|
|
25
|
+
subject.find('textarea').simulate('blur')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('triggers query update callback', () => {
|
|
29
|
+
expect(updateCallback).toHaveBeenCalled()
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
describe('on user submitted running query', () => {
|
|
34
|
+
const cancelCallback = jest.fn()
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
queryCallback = jest.fn()
|
|
37
|
+
subject = createSubject({ executeQuery: queryCallback, isQueryLoading: true, cancelQuery: cancelCallback })
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test('shows loading component', () => {
|
|
41
|
+
expect(subject.find(LoadingElement).length).toEqual(1)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test('hides success and error text', () => {
|
|
45
|
+
expect(subject.find('.success-message').length).toEqual(0)
|
|
46
|
+
expect(subject.find('.error-message').length).toEqual(0)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
test('sets the cancel button to enabled', () => {
|
|
50
|
+
const button = getButton(subject, 'Cancel')
|
|
51
|
+
expect(button.find('[disabled=false]').length).toEqual(1)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('sets the submit button to disabled', () => {
|
|
55
|
+
const button = getButton(subject, 'Submit')
|
|
56
|
+
expect(button.find('[disabled=true]').length).toEqual(1)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('sets the download button to disabled', () => {
|
|
60
|
+
const button = subject.find('.download-dropdown button')
|
|
61
|
+
expect(button.find('[disabled=true]').length).toEqual(1)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('cancelling the query invokes a provided cancel handler', () => {
|
|
65
|
+
getButton(subject, 'Cancel').simulate('click')
|
|
66
|
+
expect(cancelCallback).toHaveBeenCalled()
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
describe('after cancel button click', () => {
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
subject = createSubject({ isQueryLoading: true })
|
|
73
|
+
|
|
74
|
+
getButton(subject, 'Cancel').simulate('click')
|
|
75
|
+
subject.setProps({ queryFailureMessage: 'Query cancelled by user.' })
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('cancelling the query sets the cancelled state to true', () => {
|
|
79
|
+
subject.setProps({ isQueryLoading: false })
|
|
80
|
+
expect(subject.find('.error-message').text()).toContain('Query cancelled by user.')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
test('resubmitting the query sets the cancelled state to false', () => {
|
|
84
|
+
getButton(subject, 'Submit').simulate('click')
|
|
85
|
+
subject.setProps({ isLoading: true })
|
|
86
|
+
|
|
87
|
+
expect(subject.find('.error-message').length).toEqual(0)
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
describe('after initial load', () => {
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
subject = createSubject({ isQueryLoaded: false })
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
test('do not show success text', () => {
|
|
97
|
+
expect(subject.find('.success-message').length).toEqual(0)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
test('defaults the query input field to use the default query', () => {
|
|
101
|
+
expect(subject.find('textarea').render().text()).toEqual('SELECT * FROM sky')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
test('defaults the cancel button to disabled', () => {
|
|
105
|
+
const button = getButton(subject, 'Cancel')
|
|
106
|
+
expect(button.find('[disabled=true]').length).toEqual(1)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
test('defaults the submit button to enabled', () => {
|
|
110
|
+
const button = getButton(subject, 'Submit')
|
|
111
|
+
expect(button.find('[disabled=false]').length).toEqual(1)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
test('defaults the download button to enabled', () => {
|
|
115
|
+
const button = subject.find('.download-dropdown button')
|
|
116
|
+
expect(button.find('[disabled=false]').length).toEqual(1)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
test('disables cancel button', () => {
|
|
120
|
+
const button = getButton(subject, 'Cancel')
|
|
121
|
+
expect(button.find('[disabled=true]').length).toEqual(1)
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
describe('on success', () => {
|
|
126
|
+
beforeEach(() => {
|
|
127
|
+
subject = createSubject({ isQueryLoading: false, isQueryLoaded: true, isQueryDataAvailable: true })
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
test('calls the submit handler on click of the submit button', () => {
|
|
131
|
+
const newText = 'SELECT * FROM great_org__awesome_dataset LIMIT 55'
|
|
132
|
+
const queryInput = subject.find('textarea')
|
|
133
|
+
queryInput.instance().value = newText
|
|
134
|
+
queryInput.simulate('blur')
|
|
135
|
+
|
|
136
|
+
getButton(subject, 'Submit').simulate('click')
|
|
137
|
+
expect(queryCallback).toHaveBeenCalledWith(newText)
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
test('hides loading element', () => {
|
|
141
|
+
expect(subject.find(LoadingElement).length).toEqual(0)
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
test('shows success text', () => {
|
|
145
|
+
expect(subject.find('.success-message').length).toEqual(1)
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
describe('on failure', () => {
|
|
150
|
+
beforeEach(() => {
|
|
151
|
+
subject = createSubject({ queryFailureMessage: 'the bad thing happened', isQueryLoaded: false })
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
test('shows error message', () => {
|
|
155
|
+
expect(subject.find('.error-message')).toHaveLength(1)
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
test('hides success text', () => {
|
|
159
|
+
expect(subject.find('.success-message').length).toEqual(0)
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
test('hides loading element', () => {
|
|
163
|
+
expect(subject.find(LoadingElement).length).toEqual(0)
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
describe('recommendations', () => {
|
|
168
|
+
test('do not render if none are provided', () => {
|
|
169
|
+
subject = createSubject({ recommendations: undefined })
|
|
170
|
+
expect(subject.exists(RecommendationList)).toBeFalsy()
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
describe('recommendations', () => {
|
|
175
|
+
test('do not render if none are available', () => {
|
|
176
|
+
subject = createSubject({ recommendations: [] })
|
|
177
|
+
expect(subject.exists('.recommendation-section')).toBeFalsy()
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
test('do not render if undefined', () => {
|
|
181
|
+
subject = createSubject({ recommendations: undefined })
|
|
182
|
+
expect(subject.exists('.recommendation-section')).toBeFalsy()
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
describe('used datasets', () => {
|
|
187
|
+
let subject
|
|
188
|
+
beforeEach(() => {
|
|
189
|
+
const fakeDataset1 = { org: 'org_name_1', name: 'data_name_1', title: 'Dataset 1', id: '123' }
|
|
190
|
+
const fakeDataset2 = { org: 'org_name_2', name: 'data_name_2', title: 'Dataset 2', id: '456' }
|
|
191
|
+
const datasetReferences = { [fakeDataset1.id]: fakeDataset1, [fakeDataset2.id]: fakeDataset2 }
|
|
192
|
+
const usedDatasets = [fakeDataset1.id, fakeDataset2.id, 'no_ref']
|
|
193
|
+
subject = createSubject({ usedDatasets, datasetReferences })
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
test('do not render if none are provided', () => {
|
|
197
|
+
const subject_with_no_datasets = createSubject({ usedDatasets: undefined })
|
|
198
|
+
expect(subject_with_no_datasets.exists('.used-datasets-section')).toBeFalsy()
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
test('shows the used datasets section', () => {
|
|
202
|
+
expect(subject.exists('.used-datasets-section')).toBeTruthy()
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
test('renders a link per dataset with a reference', () => {
|
|
206
|
+
const links = subject.find('.dataset-reference Link')
|
|
207
|
+
expect(links.length).toEqual(2)
|
|
208
|
+
expect(links.at(0).prop('to')).toEqual('/dataset/org_name_1/data_name_1')
|
|
209
|
+
expect(links.at(0).text()).toEqual('Dataset 1')
|
|
210
|
+
expect(links.at(1).prop('to')).toEqual('/dataset/org_name_2/data_name_2')
|
|
211
|
+
expect(links.at(1).text()).toEqual('Dataset 2')
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
function createSubject(params) {
|
|
217
|
+
const defaults = {
|
|
218
|
+
queryText: 'SELECT * FROM sky',
|
|
219
|
+
queryData: [],
|
|
220
|
+
recommendations: recommendations,
|
|
221
|
+
usedDatasets: [],
|
|
222
|
+
datasetReferences: {},
|
|
223
|
+
queryFailureMessage: '',
|
|
224
|
+
isQueryDataAvailable: false,
|
|
225
|
+
isQueryLoading: false,
|
|
226
|
+
isQueryLoaded: true,
|
|
227
|
+
executeQuery: queryCallback || jest.fn(),
|
|
228
|
+
cancelQuery: jest.fn(),
|
|
229
|
+
setQueryText: updateCallback || jest.fn()
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const paramsWithDefaults = Object.assign({}, defaults, params)
|
|
233
|
+
|
|
234
|
+
// This allows us to set properties on a component wrapped in a provider
|
|
235
|
+
return mount(React.createElement(
|
|
236
|
+
props => (
|
|
237
|
+
<Router>
|
|
238
|
+
<QueryForm {...props} />
|
|
239
|
+
</Router>
|
|
240
|
+
),
|
|
241
|
+
paramsWithDefaults)
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function getButton(subject, text) {
|
|
246
|
+
const isButton = x => x.type() === 'button' && x.text() === text
|
|
247
|
+
return subject.findWhere(isButton)
|
|
248
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _recommendationList = _interopRequireDefault(require("./recommendation-list"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = _recommendationList.default;
|