From 56d3be2248dfef1ff4b0ac52f25053db2cc9ba93 Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Wed, 11 Dec 2019 17:05:38 +0200 Subject: [PATCH] Prettier all the Javascript code & GitHub Action (#4433) * Prettier all the JS files * Add GitHub Action to autoformat code pushed to master * Fix eslint violation due to formatting. * Remove GitHub actions for styling * Add restyled.io config --- .github/workflows/black.yml | 31 -- .restyled.yaml | 61 ++++ client/app/.eslintrc.js | 2 +- client/app/__tests__/enzyme_setup.js | 4 +- client/app/__tests__/mocks.js | 4 +- client/app/components/AceEditorInput.jsx | 6 +- client/app/components/AutocompleteToggle.jsx | 33 +- client/app/components/BeaconConsent.jsx | 34 +- client/app/components/BigMessage.jsx | 16 +- client/app/components/CodeBlock.jsx | 27 +- client/app/components/Collapse.jsx | 19 +- client/app/components/ColorBox.jsx | 8 +- client/app/components/ColorPicker/Input.jsx | 26 +- client/app/components/ColorPicker/Label.jsx | 23 +- client/app/components/ColorPicker/Swatch.jsx | 26 +- client/app/components/ColorPicker/index.jsx | 85 +++-- client/app/components/ColorPicker/utils.js | 6 +- client/app/components/CreateSourceDialog.jsx | 142 ++++---- client/app/components/DateInput.jsx | 22 +- client/app/components/DateRangeInput.jsx | 24 +- client/app/components/DateTimeInput.jsx | 24 +- client/app/components/DateTimeRangeInput.jsx | 64 ++-- client/app/components/DialogWrapper.jsx | 12 +- client/app/components/DynamicComponent.jsx | 10 +- client/app/components/EditInPlace.jsx | 38 +-- .../EditParameterSettingsDialog.jsx | 168 +++++----- .../QueryControlDropdown.jsx | 40 +-- .../QueryResultsLink.jsx | 20 +- .../EditVisualizationButton/index.jsx | 27 +- .../app/components/EmailSettingsWarning.jsx | 28 +- client/app/components/FavoritesControl.jsx | 34 +- client/app/components/Filters.jsx | 81 ++--- client/app/components/HelpTrigger.jsx | 152 +++------ client/app/components/HtmlContent.jsx | 8 +- client/app/components/InputWithCopy.jsx | 28 +- .../app/components/NoTaggedObjectsFound.jsx | 20 +- client/app/components/PageHeader.jsx | 10 +- client/app/components/Paginator.jsx | 30 +- .../app/components/ParameterApplyButton.jsx | 14 +- .../app/components/ParameterMappingInput.jsx | 269 +++++++-------- client/app/components/ParameterValueInput.jsx | 83 ++--- client/app/components/Parameters.jsx | 64 ++-- client/app/components/PreviewCard.jsx | 22 +- .../components/QueryBasedParameterInput.jsx | 33 +- client/app/components/QueryEditor.jsx | 154 +++++---- client/app/components/QueryLink.jsx | 15 +- client/app/components/QuerySelector.jsx | 101 +++--- client/app/components/SelectItemsDialog.jsx | 83 +++-- client/app/components/SettingsWrapper.jsx | 15 +- client/app/components/SortIcon.jsx | 12 +- client/app/components/TagsList.jsx | 26 +- .../components/TextAlignmentSelect/index.jsx | 23 +- client/app/components/TimeAgo.jsx | 43 ++- client/app/components/Timer.jsx | 25 +- client/app/components/admin/CeleryStatus.jsx | 88 +++-- client/app/components/admin/Layout.jsx | 20 +- client/app/components/admin/RQStatus.jsx | 80 ++--- client/app/components/admin/StatusBlock.jsx | 91 +++-- .../app/components/app-header/AppHeader.jsx | 127 +++---- .../components/FavoritesDropdown.jsx | 44 ++- .../app/components/app-view/error-handler.js | 7 +- client/app/components/app-view/index.js | 31 +- .../components/cancel-query-button/index.js | 12 +- .../app/components/cards-list/CardsList.jsx | 33 +- .../components/dashboards/AddWidgetDialog.jsx | 82 +++-- .../dashboards/AutoHeightController.js | 43 +-- .../dashboards/CreateDashboardDialog.jsx | 45 +-- .../components/dashboards/DashboardGrid.jsx | 69 ++-- .../EditParameterMappingsDialog.jsx | 33 +- .../dashboards/ExpandedWidgetDialog.jsx | 24 +- .../components/dashboards/TextboxDialog.jsx | 51 ++- .../dashboard-widget/RestrictedWidget.jsx | 12 +- .../dashboard-widget/TextboxWidget.jsx | 24 +- .../dashboard-widget/VisualizationWidget.jsx | 123 ++++--- .../dashboards/dashboard-widget/Widget.jsx | 55 ++- .../dashboards/dashboard-widget/index.js | 6 +- .../components/dynamic-form/DynamicForm.jsx | 163 ++++----- .../dynamic-form/dynamicFormHelper.js | 50 +-- .../dynamic-parameters/DateParameter.jsx | 60 ++-- .../dynamic-parameters/DateRangeParameter.jsx | 199 +++++++---- .../dynamic-parameters/DynamicButton.jsx | 42 +-- .../app/components/empty-state/EmptyState.jsx | 24 +- .../components/groups/CreateGroupDialog.jsx | 20 +- .../components/groups/DeleteGroupButton.jsx | 38 ++- .../components/groups/DetailsPageSidebar.jsx | 38 ++- client/app/components/groups/GroupName.jsx | 10 +- .../app/components/groups/ListItemAddon.jsx | 14 +- .../app/components/items-list/ItemsList.jsx | 32 +- .../items-list/classes/ItemsFetcher.js | 33 +- .../items-list/classes/ItemsSource.js | 39 +-- .../items-list/classes/Paginator.js | 8 +- .../components/items-list/classes/Sorter.js | 12 +- .../items-list/classes/StateStorage.js | 27 +- .../items-list/components/EmptyState.jsx | 4 +- .../items-list/components/ItemsTable.jsx | 163 +++++---- .../items-list/components/LoadingState.jsx | 4 +- .../items-list/components/Sidebar.jsx | 66 ++-- .../JsonViewInteractive.jsx | 45 +-- client/app/components/keywordBuilder.js | 16 +- .../components/layouts/ContentWithSidebar.jsx | 18 +- client/app/components/overlay.js | 2 +- .../PermissionsEditorDialog.jsx | 137 ++++---- client/app/components/proptypes.js | 36 +- .../queries/AddToDashboardDialog.jsx | 93 +++--- .../components/queries/EmbedQueryDialog.jsx | 32 +- .../app/components/queries/ScheduleDialog.jsx | 68 ++-- .../components/queries/ScheduleDialog.test.js | 156 ++++----- .../app/components/queries/SchedulePhrase.jsx | 24 +- .../queries/alert-unsaved-changes.js | 14 +- .../app/components/queries/api-key-dialog.js | 14 +- .../app/components/queries/schema-browser.js | 28 +- .../components/queries/visualization-embed.js | 26 +- .../query-snippets/QuerySnippetDialog.jsx | 66 ++-- client/app/components/rd-tab/index.js | 17 +- client/app/components/sortable/index.jsx | 30 +- client/app/components/tab-nav/index.js | 13 +- .../tags-control/EditTagsDialog.jsx | 28 +- .../components/tags-control/TagsControl.jsx | 66 ++-- .../components/users/ChangePasswordDialog.jsx | 86 ++--- .../app/components/users/CreateUserDialog.jsx | 36 +- client/app/components/users/UserEdit.jsx | 218 ++++++------ client/app/components/users/UserShow.jsx | 33 +- client/app/components/users/UserShow.test.js | 16 +- .../visualizations/editor/ContextHelp.jsx | 33 +- .../visualizations/editor/Section.jsx | 14 +- .../visualizations/editor/Switch.jsx | 24 +- .../editor/createTabbedEditor.jsx | 28 +- .../components/visualizations/editor/index.js | 33 +- .../editor/withControlLabel.jsx | 35 +- client/app/config/antd-spinner.jsx | 4 +- client/app/config/index.js | 122 ++++--- client/app/directives/autofocus.js | 2 +- client/app/directives/compare-to.js | 14 +- client/app/directives/index.js | 10 +- client/app/directives/resizable-toggle.js | 63 ++-- client/app/directives/resize-event.js | 8 +- client/app/directives/title.js | 18 +- client/app/directives/utils.js | 7 +- client/app/filters/datetime.js | 16 +- client/app/filters/index.js | 44 +-- client/app/filters/markdown.js | 26 +- client/app/index.js | 10 +- .../app/lib/chooseTextColorForBackground.js | 6 +- client/app/lib/hooks/useForceUpdate.js | 2 +- .../app/lib/hooks/useMemoWithDeepCompare.js | 4 +- client/app/lib/hooks/useQueryResult.js | 21 +- client/app/lib/hooks/useSearchResults.js | 27 +- client/app/lib/localOptions.js | 2 +- client/app/lib/pagination/index.js | 2 +- client/app/lib/pagination/paginator.js | 4 +- client/app/lib/promise-rejection-error.js | 4 +- client/app/lib/utils.js | 6 +- client/app/lib/value-format.js | 32 +- client/app/pages/admin/Jobs.jsx | 81 ++--- client/app/pages/admin/OutdatedQueries.jsx | 221 ++++++------ client/app/pages/admin/SystemStatus.jsx | 60 ++-- client/app/pages/admin/Tasks.jsx | 67 ++-- client/app/pages/alert/Alert.jsx | 217 ++++++------ client/app/pages/alert/AlertEdit.jsx | 28 +- client/app/pages/alert/AlertNew.jsx | 26 +- client/app/pages/alert/AlertView.jsx | 82 +++-- .../alert/components/AlertDestinations.jsx | 123 +++---- .../app/pages/alert/components/Criteria.jsx | 72 ++-- .../alert/components/HorizontalFormItem.jsx | 12 +- .../app/pages/alert/components/MenuButton.jsx | 40 +-- .../alert/components/NotificationTemplate.jsx | 45 ++- client/app/pages/alert/components/Query.jsx | 60 ++-- client/app/pages/alert/components/Rearm.jsx | 61 ++-- client/app/pages/alert/components/Title.jsx | 24 +- client/app/pages/alerts/AlertsList.jsx | 201 +++++------ client/app/pages/dashboards/DashboardList.jsx | 163 ++++----- .../dashboards/DashboardListEmptyState.jsx | 44 ++- .../pages/dashboards/ShareDashboardDialog.jsx | 45 ++- client/app/pages/dashboards/dashboard.js | 169 +++++----- .../pages/dashboards/public-dashboard-page.js | 52 +-- .../pages/data-sources/DataSourcesList.jsx | 163 +++++---- .../app/pages/data-sources/EditDataSource.jsx | 129 +++---- .../pages/destinations/DestinationsList.jsx | 155 +++++---- .../pages/destinations/EditDestination.jsx | 97 +++--- client/app/pages/groups/GroupDataSources.jsx | 282 ++++++++-------- client/app/pages/groups/GroupMembers.jsx | 256 +++++++------- client/app/pages/groups/GroupsList.jsx | 239 ++++++------- client/app/pages/home/Home.jsx | 89 ++--- client/app/pages/queries-list/QueriesList.jsx | 257 +++++++------- .../queries-list/QueriesListEmptyState.jsx | 64 ++-- client/app/pages/queries/source-view.js | 86 +++-- client/app/pages/queries/view.js | 210 ++++++------ .../query-snippets/QuerySnippetsList.jsx | 305 +++++++++-------- .../pages/settings/OrganizationSettings.jsx | 198 ++++++----- client/app/pages/users/UserProfile.jsx | 54 +-- client/app/pages/users/UsersList.jsx | 316 ++++++++++-------- client/app/pages/users/index.js | 104 +++--- client/app/services/alert-dialog.js | 18 +- client/app/services/alert-subscription.js | 8 +- client/app/services/alert.js | 57 ++-- client/app/services/auth.js | 58 ++-- client/app/services/dashboard.js | 88 +++-- client/app/services/data-source.js | 27 +- client/app/services/destination.js | 18 +- client/app/services/events.js | 4 +- client/app/services/getTags.js | 2 +- client/app/services/group.js | 37 +- client/app/services/keyboard-shortcuts.js | 22 +- client/app/services/navigateTo.js | 6 +- client/app/services/ng.js | 18 +- client/app/services/notification.js | 9 +- client/app/services/notifications.js | 25 +- client/app/services/offline-listener.js | 14 +- client/app/services/organizationSettings.js | 25 +- client/app/services/organizationStatus.js | 4 +- .../app/services/parameters/DateParameter.js | 22 +- .../services/parameters/DateRangeParameter.js | 100 ++++-- .../app/services/parameters/EnumParameter.js | 12 +- .../services/parameters/NumberParameter.js | 4 +- client/app/services/parameters/Parameter.js | 38 ++- .../parameters/QueryBasedDropdownParameter.js | 12 +- .../app/services/parameters/TextParameter.js | 4 +- client/app/services/parameters/index.js | 14 +- .../parameters/tests/DateParameter.test.js | 66 ++-- .../tests/DateRangeParameter.test.js | 66 ++-- .../parameters/tests/EnumParameter.test.js | 46 +-- .../parameters/tests/NumberParameter.test.js | 18 +- .../parameters/tests/Parameter.test.js | 39 ++- .../tests/QueryBasedDropdownParameter.test.js | 40 +-- .../parameters/tests/TextParameter.test.js | 24 +- client/app/services/policy/DefaultPolicy.js | 10 +- client/app/services/policy/index.js | 2 +- client/app/services/query-result.js | 163 ++++----- client/app/services/query-snippet.js | 10 +- client/app/services/query.js | 178 +++++----- client/app/services/recordEvent.js | 6 +- client/app/services/resizeObserver.js | 5 +- client/app/services/settingsMenu.js | 10 +- client/app/services/user.js | 74 ++-- client/app/services/visualization.js | 4 +- client/app/services/widget.js | 70 ++-- client/app/unsupportedRedirect.js | 6 +- client/app/visualizations/ColorPalette.js | 42 +-- .../EditVisualizationDialog.jsx | 114 ++++--- .../app/visualizations/VisualizationName.jsx | 12 +- .../visualizations/VisualizationRenderer.jsx | 33 +- client/app/visualizations/box-plot/Editor.jsx | 10 +- .../app/visualizations/box-plot/Renderer.jsx | 135 ++++---- client/app/visualizations/box-plot/d3box.js | 186 +++++------ client/app/visualizations/box-plot/index.js | 10 +- .../chart/Editor/AxisSettings.jsx | 41 ++- .../chart/Editor/ChartTypeSelect.jsx | 26 +- .../chart/Editor/ColorsSettings.jsx | 10 +- .../chart/Editor/ColorsSettings.test.js | 145 ++++---- .../chart/Editor/ColumnMappingSelect.jsx | 41 +-- .../chart/Editor/CustomChartSettings.jsx | 14 +- .../chart/Editor/DataLabelsSettings.jsx | 74 ++-- .../chart/Editor/DataLabelsSettings.test.js | 107 +++--- .../chart/Editor/DefaultColorsSettings.jsx | 79 ++--- .../chart/Editor/GeneralSettings.jsx | 102 +++--- .../chart/Editor/GeneralSettings.test.js | 223 +++++++----- .../chart/Editor/HeatmapColorsSettings.jsx | 37 +- .../chart/Editor/PieColorsSettings.jsx | 83 ++--- .../chart/Editor/SeriesSettings.jsx | 128 +++---- .../chart/Editor/SeriesSettings.test.js | 87 +++-- .../chart/Editor/XAxisSettings.jsx | 17 +- .../chart/Editor/XAxisSettings.test.js | 105 +++--- .../chart/Editor/YAxisSettings.jsx | 18 +- .../chart/Editor/YAxisSettings.test.js | 156 +++++---- .../app/visualizations/chart/Editor/index.jsx | 48 +-- .../visualizations/chart/Editor/index.test.js | 59 ++-- .../chart/Renderer/CustomPlotlyChart.jsx | 23 +- .../chart/Renderer/PlotlyChart.jsx | 14 +- .../visualizations/chart/Renderer/index.jsx | 14 +- .../app/visualizations/chart/getChartData.js | 26 +- .../visualizations/chart/getChartData.test.js | 24 +- client/app/visualizations/chart/getOptions.js | 41 ++- client/app/visualizations/chart/index.js | 12 +- .../chart/plotly/applyLayoutFixes.js | 68 ++-- .../chart/plotly/customChartUtils.js | 8 +- .../app/visualizations/chart/plotly/index.js | 24 +- .../chart/plotly/prepareData.js | 17 +- .../chart/plotly/prepareData.test.js | 114 +++---- .../chart/plotly/prepareDefaultData.js | 78 +++-- .../chart/plotly/prepareHeatmapData.js | 46 +-- .../chart/plotly/prepareLayout.js | 70 ++-- .../chart/plotly/prepareLayout.test.js | 44 +-- .../chart/plotly/preparePieData.js | 56 ++-- .../visualizations/chart/plotly/updateData.js | 90 ++--- .../app/visualizations/chart/plotly/utils.js | 16 +- .../visualizations/choropleth/ColorPalette.js | 17 +- .../choropleth/Editor/BoundsSettings.jsx | 57 ++-- .../choropleth/Editor/ColorsSettings.jsx | 35 +- .../choropleth/Editor/FormatSettings.jsx | 104 ++++-- .../choropleth/Editor/GeneralSettings.jsx | 77 +++-- .../visualizations/choropleth/Editor/index.js | 18 +- .../visualizations/choropleth/Editor/utils.js | 4 +- .../choropleth/Renderer/Legend.jsx | 22 +- .../choropleth/Renderer/index.jsx | 54 +-- .../choropleth/Renderer/initChoropleth.js | 77 ++--- .../choropleth/Renderer/utils.js | 41 ++- .../visualizations/choropleth/getOptions.js | 32 +- client/app/visualizations/choropleth/index.js | 12 +- .../app/visualizations/cohort/Cornelius.jsx | 108 +++--- .../cohort/Editor/ColumnsSettings.jsx | 36 +- .../cohort/Editor/OptionsSettings.jsx | 32 +- .../app/visualizations/cohort/Editor/index.js | 10 +- client/app/visualizations/cohort/Renderer.jsx | 31 +- .../app/visualizations/cohort/getOptions.js | 12 +- client/app/visualizations/cohort/index.js | 12 +- .../app/visualizations/cohort/prepareData.js | 20 +- .../counter/Editor/FormatSettings.jsx | 11 +- .../counter/Editor/GeneralSettings.jsx | 25 +- .../visualizations/counter/Editor/index.js | 10 +- .../app/visualizations/counter/Renderer.jsx | 42 ++- client/app/visualizations/counter/index.js | 20 +- client/app/visualizations/counter/utils.js | 26 +- .../app/visualizations/counter/utils.test.js | 124 +++---- .../details/DetailsRenderer.jsx | 20 +- client/app/visualizations/details/index.js | 8 +- .../funnel/Editor/AppearanceSettings.jsx | 22 +- .../funnel/Editor/GeneralSettings.jsx | 47 +-- .../app/visualizations/funnel/Editor/index.js | 10 +- .../funnel/Renderer/FunnelBar.jsx | 21 +- .../visualizations/funnel/Renderer/index.jsx | 67 ++-- .../funnel/Renderer/prepareData.js | 6 +- .../app/visualizations/funnel/getOptions.js | 10 +- client/app/visualizations/funnel/index.js | 12 +- client/app/visualizations/index.js | 16 +- .../map/Editor/GeneralSettings.jsx | 42 +-- .../map/Editor/GroupsSettings.jsx | 78 +++-- .../map/Editor/StyleSettings.jsx | 129 +++---- client/app/visualizations/map/Editor/index.js | 14 +- client/app/visualizations/map/Renderer.jsx | 28 +- client/app/visualizations/map/getOptions.js | 20 +- client/app/visualizations/map/index.js | 12 +- client/app/visualizations/map/initMap.js | 75 ++--- client/app/visualizations/map/prepareData.js | 40 ++- client/app/visualizations/pivot/Editor.jsx | 19 +- client/app/visualizations/pivot/Renderer.jsx | 59 ++-- client/app/visualizations/pivot/index.js | 12 +- client/app/visualizations/sankey/Editor.jsx | 26 +- client/app/visualizations/sankey/Renderer.jsx | 12 +- client/app/visualizations/sankey/d3sankey.js | 11 +- client/app/visualizations/sankey/index.js | 10 +- .../app/visualizations/sankey/initSankey.js | 127 +++---- client/app/visualizations/sunburst/Editor.jsx | 52 ++- .../app/visualizations/sunburst/Renderer.jsx | 12 +- client/app/visualizations/sunburst/index.js | 10 +- .../visualizations/sunburst/initSunburst.js | 169 +++++----- .../table/Editor/ColumnEditor.jsx | 26 +- .../table/Editor/ColumnsSettings.jsx | 42 +-- .../table/Editor/ColumnsSettings.test.js | 73 ++-- .../table/Editor/GridSettings.jsx | 15 +- .../table/Editor/GridSettings.test.js | 35 +- .../app/visualizations/table/Editor/index.jsx | 12 +- client/app/visualizations/table/Renderer.jsx | 59 ++-- .../visualizations/table/columns/boolean.jsx | 27 +- .../table/columns/boolean.test.js | 54 +-- .../visualizations/table/columns/datetime.jsx | 22 +- .../table/columns/datetime.test.js | 35 +- .../visualizations/table/columns/image.jsx | 47 ++- .../table/columns/image.test.js | 92 +++-- .../app/visualizations/table/columns/index.js | 14 +- .../app/visualizations/table/columns/json.jsx | 17 +- .../app/visualizations/table/columns/link.jsx | 45 ++- .../visualizations/table/columns/link.test.js | 92 +++-- .../visualizations/table/columns/number.jsx | 22 +- .../table/columns/number.test.js | 35 +- .../app/visualizations/table/columns/text.jsx | 21 +- .../visualizations/table/columns/text.test.js | 58 ++-- client/app/visualizations/table/getOptions.js | 68 ++-- client/app/visualizations/table/index.js | 12 +- client/app/visualizations/table/utils.js | 92 ++--- .../app/visualizations/word-cloud/Editor.jsx | 30 +- .../visualizations/word-cloud/Renderer.jsx | 95 +++--- client/app/visualizations/word-cloud/index.js | 16 +- client/cypress/plugins/index.js | 6 +- client/cypress/support/commands.js | 71 ++-- client/cypress/support/index.js | 2 +- 375 files changed, 10069 insertions(+), 9198 deletions(-) delete mode 100644 .github/workflows/black.yml create mode 100644 .restyled.yaml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml deleted file mode 100644 index 9909382d46..0000000000 --- a/.github/workflows/black.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Python Code Formatting (Black) - -on: - push: - branches: - - master - -jobs: - format: - runs-on: ubuntu-latest - - container: - image: python:3.7.4-alpine - - steps: - - uses: actions/checkout@v1 - - name: Install Black - run: apk add gcc musl-dev && pip install black - - name: Run Black - run: black redash tests migrations/versions - - name: Commit formatted code - uses: EndBug/add-and-commit@v2.1.0 - with: - author_name: Black - author_email: team@redash.io - message: "Autoformatted Python code with Black" - path: "." - pattern: "*.py" - force: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.restyled.yaml b/.restyled.yaml new file mode 100644 index 0000000000..daa9ca7972 --- /dev/null +++ b/.restyled.yaml @@ -0,0 +1,61 @@ +enabled: true + +auto: false + +# Open Restyle PRs? +pull_requests: true + +# Leave comments on the original PR linking to the Restyle PR? +comments: true + +# Set commit statuses on the original PR? +statuses: + # Red status in the case of differences found + differences: true + # Green status in the case of no differences found + no_differences: true + # Red status if we encounter errors restyling + error: true + +# Request review on the Restyle PR? +# +# Possible values: +# +# author: From the author of the original PR +# owner: From the owner of the repository +# none: Don't +# +# One value will apply to both origin and forked PRs, but you can also specify +# separate values. +# +# request_review: +# origin: author +# forked: owner +# +request_review: author + +# Add labels to any created Restyle PRs +# +# These can be used to tell other automation to avoid our PRs. +# +labels: ["Skip CI"] + +# Labels to ignore +# +# PRs with any of these labels will be ignored by Restyled. +# +# ignore_labels: +# - restyled-ignore + +# Restylers to run, and how +restylers: + - name: black: + include: + - redash + - tests + - migrations/versions + - name: prettier: + include: + - client/app/**/*.js + - client/app/**/*.jsx + - client/cypress/**/*.js \ No newline at end of file diff --git a/client/app/.eslintrc.js b/client/app/.eslintrc.js index 92ff4972b2..85a37b82a3 100644 --- a/client/app/.eslintrc.js +++ b/client/app/.eslintrc.js @@ -7,4 +7,4 @@ module.exports = { rules: { "jest/no-focused-tests": "off", }, -}; \ No newline at end of file +}; diff --git a/client/app/__tests__/enzyme_setup.js b/client/app/__tests__/enzyme_setup.js index 82edfc9e5a..6f413a40b8 100644 --- a/client/app/__tests__/enzyme_setup.js +++ b/client/app/__tests__/enzyme_setup.js @@ -1,4 +1,4 @@ -import { configure } from 'enzyme'; -import Adapter from 'enzyme-adapter-react-16'; +import { configure } from "enzyme"; +import Adapter from "enzyme-adapter-react-16"; configure({ adapter: new Adapter() }); diff --git a/client/app/__tests__/mocks.js b/client/app/__tests__/mocks.js index 14fccbe90b..d4025fbe83 100644 --- a/client/app/__tests__/mocks.js +++ b/client/app/__tests__/mocks.js @@ -1,5 +1,5 @@ -import MockDate from 'mockdate'; +import MockDate from "mockdate"; -const date = new Date('2000-01-01T02:00:00.000'); +const date = new Date("2000-01-01T02:00:00.000"); MockDate.set(date); diff --git a/client/app/components/AceEditorInput.jsx b/client/app/components/AceEditorInput.jsx index 49c55aa93a..eee7e08305 100644 --- a/client/app/components/AceEditorInput.jsx +++ b/client/app/components/AceEditorInput.jsx @@ -1,7 +1,7 @@ -import React, { forwardRef } from 'react'; -import AceEditor from 'react-ace'; +import React, { forwardRef } from "react"; +import AceEditor from "react-ace"; -import './AceEditorInput.less'; +import "./AceEditorInput.less"; function AceEditorInput(props, ref) { return ( diff --git a/client/app/components/AutocompleteToggle.jsx b/client/app/components/AutocompleteToggle.jsx index 5a4c9bff20..7698157f87 100644 --- a/client/app/components/AutocompleteToggle.jsx +++ b/client/app/components/AutocompleteToggle.jsx @@ -1,24 +1,24 @@ -import React from 'react'; -import Tooltip from 'antd/lib/tooltip'; -import PropTypes from 'prop-types'; -import '@/redash-font/style.less'; -import recordEvent from '@/services/recordEvent'; +import React from "react"; +import Tooltip from "antd/lib/tooltip"; +import PropTypes from "prop-types"; +import "@/redash-font/style.less"; +import recordEvent from "@/services/recordEvent"; export default function AutocompleteToggle({ state, disabled, onToggle }) { - let tooltipMessage = 'Live Autocomplete Enabled'; - let icon = 'icon-flash'; + let tooltipMessage = "Live Autocomplete Enabled"; + let icon = "icon-flash"; if (!state) { - tooltipMessage = 'Live Autocomplete Disabled'; - icon = 'icon-flash-off'; + tooltipMessage = "Live Autocomplete Disabled"; + icon = "icon-flash-off"; } if (disabled) { - tooltipMessage = 'Live Autocomplete Not Available (Use Ctrl+Space to Trigger)'; - icon = 'icon-flash-off'; + tooltipMessage = "Live Autocomplete Not Available (Use Ctrl+Space to Trigger)"; + icon = "icon-flash-off"; } - const toggle = (newState) => { - recordEvent('toggle_autocomplete', 'screen', 'query_editor', { state: newState }); + const toggle = newState => { + recordEvent("toggle_autocomplete", "screen", "query_editor", { state: newState }); onToggle(newState); }; @@ -26,11 +26,10 @@ export default function AutocompleteToggle({ state, disabled, onToggle }) { ); diff --git a/client/app/components/BeaconConsent.jsx b/client/app/components/BeaconConsent.jsx index 5756d36d28..4db162f326 100644 --- a/client/app/components/BeaconConsent.jsx +++ b/client/app/components/BeaconConsent.jsx @@ -1,11 +1,11 @@ -import React, { useState } from 'react'; -import Card from 'antd/lib/card'; -import Button from 'antd/lib/button'; -import Typography from 'antd/lib/typography'; -import { clientConfig } from '@/services/auth'; -import HelpTrigger from '@/components/HelpTrigger'; -import DynamicComponent from '@/components/DynamicComponent'; -import OrgSettings from '@/services/organizationSettings'; +import React, { useState } from "react"; +import Card from "antd/lib/card"; +import Button from "antd/lib/button"; +import Typography from "antd/lib/typography"; +import { clientConfig } from "@/services/auth"; +import HelpTrigger from "@/components/HelpTrigger"; +import DynamicComponent from "@/components/DynamicComponent"; +import OrgSettings from "@/services/organizationSettings"; const Text = Typography.Text; @@ -21,11 +21,11 @@ function BeaconConsent() { setHide(true); }; - const confirmConsent = (confirm) => { - let message = '🙏 Thank you.'; + const confirmConsent = confirm => { + let message = "🙏 Thank you."; if (!confirm) { - message = 'Settings Saved.'; + message = "Settings Saved."; } OrgSettings.save({ beacon_consent: confirm }, message) @@ -40,14 +40,13 @@ function BeaconConsent() {
- Would you be ok with sharing anonymous usage data with the Redash team?{' '} + Would you be ok with sharing anonymous usage data with the Redash team?{" "} - )} - bordered={false} - > + } + bordered={false}> Help Redash improve by automatically sending anonymous usage data:
    @@ -66,7 +65,8 @@ function BeaconConsent() {
- You can change this setting anytime from the Organization Settings page. + You can change this setting anytime from the Organization Settings{" "} + page.
diff --git a/client/app/components/BigMessage.jsx b/client/app/components/BigMessage.jsx index 1063c1c950..c9ff3f0a9c 100644 --- a/client/app/components/BigMessage.jsx +++ b/client/app/components/BigMessage.jsx @@ -1,12 +1,12 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { react2angular } from 'react2angular'; +import React from "react"; +import PropTypes from "prop-types"; +import { react2angular } from "react2angular"; export function BigMessage({ message, icon, children, className }) { return ( -
+

- +


{message} @@ -23,13 +23,13 @@ BigMessage.propTypes = { }; BigMessage.defaultProps = { - message: '', + message: "", children: null, - className: 'tiled bg-white', + className: "tiled bg-white", }; export default function init(ngModule) { - ngModule.component('bigMessage', react2angular(BigMessage)); + ngModule.component("bigMessage", react2angular(BigMessage)); } init.init = true; diff --git a/client/app/components/CodeBlock.jsx b/client/app/components/CodeBlock.jsx index 53b65589aa..b2947894e9 100644 --- a/client/app/components/CodeBlock.jsx +++ b/client/app/components/CodeBlock.jsx @@ -1,8 +1,8 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import Button from 'antd/lib/button'; -import Tooltip from 'antd/lib/tooltip'; -import './CodeBlock.less'; +import React from "react"; +import PropTypes from "prop-types"; +import Button from "antd/lib/button"; +import Tooltip from "antd/lib/tooltip"; +import "./CodeBlock.less"; export default class CodeBlock extends React.Component { static propTypes = { @@ -20,7 +20,7 @@ export default class CodeBlock extends React.Component { constructor(props) { super(props); this.ref = React.createRef(); - this.copyFeatureEnabled = props.copyable && document.queryCommandSupported('copy'); + this.copyFeatureEnabled = props.copyable && document.queryCommandSupported("copy"); this.resetCopyState = null; } @@ -36,14 +36,14 @@ export default class CodeBlock extends React.Component { // copy try { - const success = document.execCommand('copy'); + const success = document.execCommand("copy"); if (!success) { throw new Error(); } - this.setState({ copied: 'Copied!' }); + this.setState({ copied: "Copied!" }); } catch (err) { this.setState({ - copied: 'Copy failed', + copied: "Copy failed", }); } @@ -58,13 +58,8 @@ export default class CodeBlock extends React.Component { const { copyable, children, ...props } = this.props; const copyButton = ( - - ), - (), - ] : [ - (), - ( - - ), - ]} - > + footer={ + currentStep === StepEnum.SELECT_TYPE + ? [ + , + , + ] + : [ + , + , + ] + }>
{currentStep === StepEnum.CONFIGURE_IT ? ( - Type Selection} - className="clickable" - onClick={this.resetType} - /> - ) : ()} + Type Selection} className="clickable" onClick={this.resetType} /> + ) : ( + + )} diff --git a/client/app/components/DateInput.jsx b/client/app/components/DateInput.jsx index 80b97660f1..fd2961395c 100644 --- a/client/app/components/DateInput.jsx +++ b/client/app/components/DateInput.jsx @@ -1,17 +1,11 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import DatePicker from 'antd/lib/date-picker'; -import { clientConfig } from '@/services/auth'; -import { Moment } from '@/components/proptypes'; +import React from "react"; +import PropTypes from "prop-types"; +import DatePicker from "antd/lib/date-picker"; +import { clientConfig } from "@/services/auth"; +import { Moment } from "@/components/proptypes"; -const DateInput = React.forwardRef(({ - defaultValue, - value, - onSelect, - className, - ...props -}, ref) => { - const format = clientConfig.dateFormat || 'YYYY-MM-DD'; +const DateInput = React.forwardRef(({ defaultValue, value, onSelect, className, ...props }, ref) => { + const format = clientConfig.dateFormat || "YYYY-MM-DD"; const additionalAttributes = {}; if (defaultValue && defaultValue.isValid()) { additionalAttributes.defaultValue = defaultValue; @@ -43,7 +37,7 @@ DateInput.defaultProps = { defaultValue: null, value: undefined, onSelect: () => {}, - className: '', + className: "", }; export default DateInput; diff --git a/client/app/components/DateRangeInput.jsx b/client/app/components/DateRangeInput.jsx index 0cdd9e6a3b..e0ccea1851 100644 --- a/client/app/components/DateRangeInput.jsx +++ b/client/app/components/DateRangeInput.jsx @@ -1,20 +1,14 @@ -import { isArray } from 'lodash'; -import React from 'react'; -import PropTypes from 'prop-types'; -import DatePicker from 'antd/lib/date-picker'; -import { clientConfig } from '@/services/auth'; -import { Moment } from '@/components/proptypes'; +import { isArray } from "lodash"; +import React from "react"; +import PropTypes from "prop-types"; +import DatePicker from "antd/lib/date-picker"; +import { clientConfig } from "@/services/auth"; +import { Moment } from "@/components/proptypes"; const { RangePicker } = DatePicker; -const DateRangeInput = React.forwardRef(({ - defaultValue, - value, - onSelect, - className, - ...props -}, ref) => { - const format = clientConfig.dateFormat || 'YYYY-MM-DD'; +const DateRangeInput = React.forwardRef(({ defaultValue, value, onSelect, className, ...props }, ref) => { + const format = clientConfig.dateFormat || "YYYY-MM-DD"; const additionalAttributes = {}; if (isArray(defaultValue) && defaultValue[0].isValid() && defaultValue[1].isValid()) { additionalAttributes.defaultValue = defaultValue; @@ -45,7 +39,7 @@ DateRangeInput.defaultProps = { defaultValue: null, value: undefined, onSelect: () => {}, - className: '', + className: "", }; export default DateRangeInput; diff --git a/client/app/components/DateTimeInput.jsx b/client/app/components/DateTimeInput.jsx index 8cb60d397d..088ae52859 100644 --- a/client/app/components/DateTimeInput.jsx +++ b/client/app/components/DateTimeInput.jsx @@ -1,19 +1,11 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import DatePicker from 'antd/lib/date-picker'; -import { clientConfig } from '@/services/auth'; -import { Moment } from '@/components/proptypes'; +import React from "react"; +import PropTypes from "prop-types"; +import DatePicker from "antd/lib/date-picker"; +import { clientConfig } from "@/services/auth"; +import { Moment } from "@/components/proptypes"; -const DateTimeInput = React.forwardRef(({ - defaultValue, - value, - withSeconds, - onSelect, - className, - ...props -}, ref) => { - const format = (clientConfig.dateFormat || 'YYYY-MM-DD') + - (withSeconds ? ' HH:mm:ss' : ' HH:mm'); +const DateTimeInput = React.forwardRef(({ defaultValue, value, withSeconds, onSelect, className, ...props }, ref) => { + const format = (clientConfig.dateFormat || "YYYY-MM-DD") + (withSeconds ? " HH:mm:ss" : " HH:mm"); const additionalAttributes = {}; if (defaultValue && defaultValue.isValid()) { additionalAttributes.defaultValue = defaultValue; @@ -48,7 +40,7 @@ DateTimeInput.defaultProps = { value: undefined, withSeconds: false, onSelect: () => {}, - className: '', + className: "", }; export default DateTimeInput; diff --git a/client/app/components/DateTimeRangeInput.jsx b/client/app/components/DateTimeRangeInput.jsx index f019a3a86b..00d6130ab1 100644 --- a/client/app/components/DateTimeRangeInput.jsx +++ b/client/app/components/DateTimeRangeInput.jsx @@ -1,41 +1,35 @@ -import { isArray } from 'lodash'; -import React from 'react'; -import PropTypes from 'prop-types'; -import DatePicker from 'antd/lib/date-picker'; -import { clientConfig } from '@/services/auth'; -import { Moment } from '@/components/proptypes'; +import { isArray } from "lodash"; +import React from "react"; +import PropTypes from "prop-types"; +import DatePicker from "antd/lib/date-picker"; +import { clientConfig } from "@/services/auth"; +import { Moment } from "@/components/proptypes"; const { RangePicker } = DatePicker; -const DateTimeRangeInput = React.forwardRef(({ - defaultValue, - value, - withSeconds, - onSelect, - className, - ...props -}, ref) => { - const format = (clientConfig.dateFormat || 'YYYY-MM-DD') + - (withSeconds ? ' HH:mm:ss' : ' HH:mm'); - const additionalAttributes = {}; - if (isArray(defaultValue) && defaultValue[0].isValid() && defaultValue[1].isValid()) { - additionalAttributes.defaultValue = defaultValue; +const DateTimeRangeInput = React.forwardRef( + ({ defaultValue, value, withSeconds, onSelect, className, ...props }, ref) => { + const format = (clientConfig.dateFormat || "YYYY-MM-DD") + (withSeconds ? " HH:mm:ss" : " HH:mm"); + const additionalAttributes = {}; + if (isArray(defaultValue) && defaultValue[0].isValid() && defaultValue[1].isValid()) { + additionalAttributes.defaultValue = defaultValue; + } + if (value === null || (isArray(value) && value[0].isValid() && value[1].isValid())) { + additionalAttributes.value = value; + } + return ( + + ); } - if (value === null || (isArray(value) && value[0].isValid() && value[1].isValid())) { - additionalAttributes.value = value; - } - return ( - - ); -}); +); DateTimeRangeInput.propTypes = { defaultValue: PropTypes.arrayOf(Moment), @@ -50,7 +44,7 @@ DateTimeRangeInput.defaultProps = { value: undefined, withSeconds: false, onSelect: () => {}, - className: '', + className: "", }; export default DateTimeRangeInput; diff --git a/client/app/components/DialogWrapper.jsx b/client/app/components/DialogWrapper.jsx index de94a43c68..2f550802a1 100644 --- a/client/app/components/DialogWrapper.jsx +++ b/client/app/components/DialogWrapper.jsx @@ -1,7 +1,7 @@ -import { isFunction } from 'lodash'; -import React from 'react'; -import PropTypes from 'prop-types'; -import ReactDOM from 'react-dom'; +import { isFunction } from "lodash"; +import React from "react"; +import PropTypes from "prop-types"; +import ReactDOM from "react-dom"; /** Wrapper for dialogs based on Ant's component. @@ -140,7 +140,7 @@ function openDialog(DialogComponent, props) { reject: () => {}, }; - const container = document.createElement('div'); + const container = document.createElement("div"); document.body.appendChild(container); function render() { @@ -176,7 +176,7 @@ function openDialog(DialogComponent, props) { const result = { close: closeDialog, dismiss: dismissDialog, - update: (newProps) => { + update: newProps => { props = { ...props, ...newProps }; render(); }, diff --git a/client/app/components/DynamicComponent.jsx b/client/app/components/DynamicComponent.jsx index 16587b6856..98e2d78c28 100644 --- a/client/app/components/DynamicComponent.jsx +++ b/client/app/components/DynamicComponent.jsx @@ -1,15 +1,15 @@ -import { isFunction, isString } from 'lodash'; -import React from 'react'; -import PropTypes from 'prop-types'; +import { isFunction, isString } from "lodash"; +import React from "react"; +import PropTypes from "prop-types"; const componentsRegistry = new Map(); const activeInstances = new Set(); export function registerComponent(name, component) { - if (isString(name) && name !== '') { + if (isString(name) && name !== "") { componentsRegistry.set(name, isFunction(component) ? component : null); // Refresh active DynamicComponent instances which use this component - activeInstances.forEach((dynamicComponent) => { + activeInstances.forEach(dynamicComponent => { if (dynamicComponent.props.name === name) { dynamicComponent.forceUpdate(); } diff --git a/client/app/components/EditInPlace.jsx b/client/app/components/EditInPlace.jsx index 2a923b33b3..4c0727ab5d 100644 --- a/client/app/components/EditInPlace.jsx +++ b/client/app/components/EditInPlace.jsx @@ -1,7 +1,7 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { react2angular } from 'react2angular'; -import { trim } from 'lodash'; +import React from "react"; +import PropTypes from "prop-types"; +import { react2angular } from "react2angular"; +import { trim } from "lodash"; export class EditInPlace extends React.Component { static propTypes = { @@ -16,8 +16,8 @@ export class EditInPlace extends React.Component { static defaultProps = { ignoreBlanks: false, isEditable: true, - placeholder: '', - value: '', + placeholder: "", + value: "", }; constructor(props) { @@ -42,14 +42,14 @@ export class EditInPlace extends React.Component { stopEditing = () => { const newValue = trim(this.inputRef.current.value); - const ignorableBlank = this.props.ignoreBlanks && newValue === ''; + const ignorableBlank = this.props.ignoreBlanks && newValue === ""; if (!ignorableBlank && newValue !== this.props.value) { this.props.onDone(newValue); } this.setState({ editing: false }); }; - keyDown = (event) => { + keyDown = event => { if (event.keyCode === 13 && !event.shiftKey) { event.preventDefault(); this.stopEditing(); @@ -63,23 +63,23 @@ export class EditInPlace extends React.Component { role="presentation" onFocus={this.startEditing} onClick={this.startEditing} - className={this.props.isEditable ? 'editable' : ''} - > + className={this.props.isEditable ? "editable" : ""}> {this.props.value || this.props.placeholder} ); - renderEdit = () => React.createElement(this.props.editor, { - ref: this.inputRef, - className: 'rd-form-control', - defaultValue: this.props.value, - onBlur: this.stopEditing, - onKeyDown: this.keyDown, - }); + renderEdit = () => + React.createElement(this.props.editor, { + ref: this.inputRef, + className: "rd-form-control", + defaultValue: this.props.value, + onBlur: this.stopEditing, + onKeyDown: this.keyDown, + }); render() { return ( - + {this.state.editing ? this.renderEdit() : this.renderNormal()} ); @@ -87,7 +87,7 @@ export class EditInPlace extends React.Component { } export default function init(ngModule) { - ngModule.component('editInPlace', react2angular(EditInPlace)); + ngModule.component("editInPlace", react2angular(EditInPlace)); } init.init = true; diff --git a/client/app/components/EditParameterSettingsDialog.jsx b/client/app/components/EditParameterSettingsDialog.jsx index 19a67cf35e..d57c1fec67 100644 --- a/client/app/components/EditParameterSettingsDialog.jsx +++ b/client/app/components/EditParameterSettingsDialog.jsx @@ -1,23 +1,22 @@ - -import { includes, words, capitalize, clone, isNull } from 'lodash'; -import React, { useState, useEffect } from 'react'; -import PropTypes from 'prop-types'; -import Checkbox from 'antd/lib/checkbox'; -import Modal from 'antd/lib/modal'; -import Form from 'antd/lib/form'; -import Button from 'antd/lib/button'; -import Select from 'antd/lib/select'; -import Input from 'antd/lib/input'; -import Divider from 'antd/lib/divider'; -import { wrap as wrapDialog, DialogPropType } from '@/components/DialogWrapper'; -import { QuerySelector } from '@/components/QuerySelector'; -import { Query } from '@/services/query'; +import { includes, words, capitalize, clone, isNull } from "lodash"; +import React, { useState, useEffect } from "react"; +import PropTypes from "prop-types"; +import Checkbox from "antd/lib/checkbox"; +import Modal from "antd/lib/modal"; +import Form from "antd/lib/form"; +import Button from "antd/lib/button"; +import Select from "antd/lib/select"; +import Input from "antd/lib/input"; +import Divider from "antd/lib/divider"; +import { wrap as wrapDialog, DialogPropType } from "@/components/DialogWrapper"; +import { QuerySelector } from "@/components/QuerySelector"; +import { Query } from "@/services/query"; const { Option } = Select; const formItemProps = { labelCol: { span: 6 }, wrapperCol: { span: 16 } }; function getDefaultTitle(text) { - return capitalize(words(text).join(' ')); // humanize + return capitalize(words(text).join(" ")); // humanize } function isTypeDateRange(type) { @@ -26,30 +25,26 @@ function isTypeDateRange(type) { function joinExampleList(multiValuesOptions) { const { prefix, suffix } = multiValuesOptions; - return ['value1', 'value2', 'value3'] - .map(value => `${prefix}${value}${suffix}`) - .join(','); + return ["value1", "value2", "value3"].map(value => `${prefix}${value}${suffix}`).join(","); } function NameInput({ name, type, onChange, existingNames, setValidation }) { - let helpText = ''; - let validateStatus = ''; + let helpText = ""; + let validateStatus = ""; if (!name) { - helpText = 'Choose a keyword for this parameter'; + helpText = "Choose a keyword for this parameter"; setValidation(false); } else if (includes(existingNames, name)) { - helpText = 'Parameter with this name already exists'; + helpText = "Parameter with this name already exists"; setValidation(false); - validateStatus = 'error'; + validateStatus = "error"; } else { if (isTypeDateRange(type)) { helpText = ( - Appears in query as {' '} - - {`{{${name}.start}} {{${name}.end}}`} - + Appears in query as{" "} + {`{{${name}.start}} {{${name}.end}}`} ); } @@ -57,13 +52,7 @@ function NameInput({ name, type, onChange, existingNames, setValidation }) { } return ( - + onChange(e.target.value)} autoFocus /> ); @@ -88,7 +77,7 @@ function EditParameterSettingsDialog(props) { useEffect(() => { const queryId = props.parameter.queryId; if (queryId) { - Query.get({ id: queryId }, (query) => { + Query.get({ id: queryId }, query => { setInitialQuery(query); }); } @@ -101,12 +90,12 @@ function EditParameterSettingsDialog(props) { } // title - if (param.title === '') { + if (param.title === "") { return false; } // query - if (param.type === 'query' && !param.queryId) { + if (param.type === "query" && !param.queryId) { return false; } @@ -129,16 +118,22 @@ function EditParameterSettingsDialog(props) { return ( Cancel - ), ( - - )]} - > + footer={[ + , + , + ]}>
{isNew && ( - {param.type === 'enum' && ( + {param.type === "enum" && ( )} - {param.type === 'query' && ( + {param.type === "query" && ( )} - {(param.type === 'enum' || param.type === 'query') && ( + {(param.type === "enum" || param.type === "query") && ( setParam({ ...param, - multiValuesOptions: e.target.checked ? { - prefix: '', - suffix: '', - separator: ',', - } : null })} - data-test="AllowMultipleValuesCheckbox" - > - Allow multiple values + onChange={e => + setParam({ + ...param, + multiValuesOptions: e.target.checked + ? { + prefix: "", + suffix: "", + separator: ",", + } + : null, + }) + } + data-test="AllowMultipleValuesCheckbox"> + Allow multiple values )} - {(param.type === 'enum' || param.type === 'query') && param.multiValuesOptions && ( + {(param.type === "enum" || param.type === "query") && param.multiValuesOptions && ( Placed in query as: {joinExampleList(param.multiValuesOptions)} - )} - {...formItemProps} - > + } + {...formItemProps}> )} diff --git a/client/app/components/EditVisualizationButton/QueryControlDropdown.jsx b/client/app/components/EditVisualizationButton/QueryControlDropdown.jsx index 959e81a730..fd36e2eadc 100644 --- a/client/app/components/EditVisualizationButton/QueryControlDropdown.jsx +++ b/client/app/components/EditVisualizationButton/QueryControlDropdown.jsx @@ -1,13 +1,12 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import Dropdown from 'antd/lib/dropdown'; -import Menu from 'antd/lib/menu'; -import Button from 'antd/lib/button'; -import Icon from 'antd/lib/icon'; -import { react2angular } from 'react2angular'; - -import QueryResultsLink from './QueryResultsLink'; +import React from "react"; +import PropTypes from "prop-types"; +import Dropdown from "antd/lib/dropdown"; +import Menu from "antd/lib/menu"; +import Button from "antd/lib/button"; +import Icon from "antd/lib/icon"; +import { react2angular } from "react2angular"; +import QueryResultsLink from "./QueryResultsLink"; export function QueryControlDropdown(props) { const menu = ( @@ -32,8 +31,7 @@ export function QueryControlDropdown(props) { query={props.query} queryResult={props.queryResult} embed={props.embed} - apiKey={props.apiKey} - > + apiKey={props.apiKey}> Download as CSV File @@ -44,8 +42,7 @@ export function QueryControlDropdown(props) { query={props.query} queryResult={props.queryResult} embed={props.embed} - apiKey={props.apiKey} - > + apiKey={props.apiKey}> Download as Excel File @@ -53,11 +50,7 @@ export function QueryControlDropdown(props) { ); return ( - + @@ -72,22 +65,19 @@ QueryControlDropdown.propTypes = { showEmbedDialog: PropTypes.func.isRequired, embed: PropTypes.bool, apiKey: PropTypes.string, - selectedTab: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number, - ]), + selectedTab: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), openAddToDashboardForm: PropTypes.func.isRequired, }; QueryControlDropdown.defaultProps = { queryResult: {}, embed: false, - apiKey: '', - selectedTab: '', + apiKey: "", + selectedTab: "", }; export default function init(ngModule) { - ngModule.component('queryControlDropdown', react2angular(QueryControlDropdown)); + ngModule.component("queryControlDropdown", react2angular(QueryControlDropdown)); } init.init = true; diff --git a/client/app/components/EditVisualizationButton/QueryResultsLink.jsx b/client/app/components/EditVisualizationButton/QueryResultsLink.jsx index 236f59778e..f3ac4bffe2 100644 --- a/client/app/components/EditVisualizationButton/QueryResultsLink.jsx +++ b/client/app/components/EditVisualizationButton/QueryResultsLink.jsx @@ -1,9 +1,8 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - +import React from "react"; +import PropTypes from "prop-types"; export default function QueryResultsLink(props) { - let href = ''; + let href = ""; const { query, queryResult, fileType } = props; const resultId = queryResult.getId && queryResult.getId(); @@ -11,9 +10,7 @@ export default function QueryResultsLink(props) { if (resultId && resultData && query.name) { if (query.id) { - href = `api/queries/${query.id}/results/${resultId}.${fileType}${ - props.embed ? `?api_key=${props.apiKey}` : '' - }`; + href = `api/queries/${query.id}/results/${resultId}.${fileType}${props.embed ? `?api_key=${props.apiKey}` : ""}`; } else { href = `api/query_results/${resultId}.${fileType}`; } @@ -33,15 +30,12 @@ QueryResultsLink.propTypes = { disabled: PropTypes.bool.isRequired, embed: PropTypes.bool, apiKey: PropTypes.string, - children: PropTypes.oneOfType([ - PropTypes.arrayOf(PropTypes.node), - PropTypes.node, - ]).isRequired, + children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired, }; QueryResultsLink.defaultProps = { queryResult: {}, - fileType: 'csv', + fileType: "csv", embed: false, - apiKey: '', + apiKey: "", }; diff --git a/client/app/components/EditVisualizationButton/index.jsx b/client/app/components/EditVisualizationButton/index.jsx index 735abf0042..0a79605c21 100644 --- a/client/app/components/EditVisualizationButton/index.jsx +++ b/client/app/components/EditVisualizationButton/index.jsx @@ -1,39 +1,32 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import Button from 'antd/lib/button'; -import Icon from 'antd/lib/icon'; -import { react2angular } from 'react2angular'; - +import React from "react"; +import PropTypes from "prop-types"; +import Button from "antd/lib/button"; +import Icon from "antd/lib/icon"; +import { react2angular } from "react2angular"; export function EditVisualizationButton(props) { return ( ); } EditVisualizationButton.propTypes = { openVisualizationEditor: PropTypes.func.isRequired, - selectedTab: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number, - ]), + selectedTab: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), }; EditVisualizationButton.defaultProps = { - selectedTab: '', + selectedTab: "", }; export default function init(ngModule) { - ngModule.component('editVisualizationButton', react2angular(EditVisualizationButton)); + ngModule.component("editVisualizationButton", react2angular(EditVisualizationButton)); } init.init = true; diff --git a/client/app/components/EmailSettingsWarning.jsx b/client/app/components/EmailSettingsWarning.jsx index eabe0ee04d..2de6f9c194 100644 --- a/client/app/components/EmailSettingsWarning.jsx +++ b/client/app/components/EmailSettingsWarning.jsx @@ -1,10 +1,10 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import cx from 'classnames'; -import { clientConfig, currentUser } from '@/services/auth'; -import Tooltip from 'antd/lib/tooltip'; -import Alert from 'antd/lib/alert'; -import HelpTrigger from '@/components/HelpTrigger'; +import React from "react"; +import PropTypes from "prop-types"; +import cx from "classnames"; +import { clientConfig, currentUser } from "@/services/auth"; +import Tooltip from "antd/lib/tooltip"; +import Alert from "antd/lib/alert"; +import HelpTrigger from "@/components/HelpTrigger"; export default function EmailSettingsWarning({ featureName, className, mode, adminOnly }) { if (!clientConfig.mailSettingsMissing) { @@ -17,33 +17,31 @@ export default function EmailSettingsWarning({ featureName, className, mode, adm const message = ( - Your mail server isn't configured correctly, and is needed for {featureName} to work.{' '} + Your mail server isn't configured correctly, and is needed for {featureName} to work.{" "} ); - if (mode === 'icon') { + if (mode === "icon") { return ( - + ); } - return ( - - ); + return ; } EmailSettingsWarning.propTypes = { featureName: PropTypes.string.isRequired, className: PropTypes.string, - mode: PropTypes.oneOf(['alert', 'icon']), + mode: PropTypes.oneOf(["alert", "icon"]), adminOnly: PropTypes.bool, }; EmailSettingsWarning.defaultProps = { className: null, - mode: 'alert', + mode: "alert", adminOnly: false, }; diff --git a/client/app/components/FavoritesControl.jsx b/client/app/components/FavoritesControl.jsx index 9496737363..a0475b413b 100644 --- a/client/app/components/FavoritesControl.jsx +++ b/client/app/components/FavoritesControl.jsx @@ -1,7 +1,7 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { react2angular } from 'react2angular'; -import { $rootScope } from '@/services/ng'; +import React from "react"; +import PropTypes from "prop-types"; +import { react2angular } from "react2angular"; +import { $rootScope } from "@/services/ng"; export class FavoritesControl extends React.Component { static propTypes = { @@ -16,7 +16,7 @@ export class FavoritesControl extends React.Component { static defaultProps = { onChange: () => {}, - forceUpdate: '', + forceUpdate: "", }; toggleItem(event, item, callback) { @@ -26,21 +26,17 @@ export class FavoritesControl extends React.Component { action().then(() => { item.is_favorite = !savedIsFavorite; this.forceUpdate(); - $rootScope.$broadcast('reloadFavorites'); + $rootScope.$broadcast("reloadFavorites"); callback(); }); } render() { const { item, onChange } = this.props; - const icon = item.is_favorite ? 'fa fa-star' : 'fa fa-star-o'; - const title = item.is_favorite ? 'Remove from favorites' : 'Add to favorites'; + const icon = item.is_favorite ? "fa fa-star" : "fa fa-star-o"; + const title = item.is_favorite ? "Remove from favorites" : "Add to favorites"; return ( - this.toggleItem(event, item, onChange)} - > + this.toggleItem(event, item, onChange)}>