Compare commits

..

31 Commits

Author SHA1 Message Date
Gabriel Dutra
19343a0520 Clear QueryBasedParameterInput 2020-11-23 19:18:35 -03:00
Gabriel Dutra
c1ed8848f0 Merge branch 'master' into query-based-dropdown--parameters 2020-11-23 16:42:06 -03:00
Gabriel Dutra
b40070d7f5 Use LabeledValues for parameterized queries 2020-11-23 16:40:18 -03:00
Gabriel Dutra
bd9ce68f68 Don't filter out values when param has search 2020-11-20 15:14:17 -03:00
Gabriel Dutra
0c0b62ae1a Remove searchTerm from structure 2020-11-20 15:13:47 -03:00
Gabriel Dutra
08bcdf77d0 Mock query instead of query_has_parameters 2020-11-12 09:11:54 -03:00
Gabriel Dutra
aa2064b1ab Fix other dropdown_values usages to use query obj 2020-11-11 13:58:01 -03:00
Gabriel Dutra
d0a787cab1 Make NoResultFound invalid parameters 2020-11-10 22:10:47 -03:00
Gabriel Dutra
a741341938 Oops 2020-11-10 20:46:51 -03:00
Gabriel Dutra
53385fa24b Merge branch 'master' into query-based-dropdown--parameters 2020-11-10 15:19:43 -03:00
Gabriel Dutra
f396c96457 Merge branch 'master' into query-based-dropdown--parameters 2020-02-25 07:49:36 -03:00
Gabriel Dutra
8bfcbf21e3 Remove redundant import 2020-02-24 11:44:28 -03:00
Gabriel Dutra
8a1640c4e7 Separate InputPopover component 2020-02-24 11:44:18 -03:00
Gabriel Dutra
a37e7f93dc Add is_safe test for queries with params 2020-02-22 15:47:29 -03:00
Gabriel Dutra
cc34e781d3 Small updates
- Change searchTerm separator
- Add cy.wait
2020-02-22 15:23:43 -03:00
Gabriel Dutra
6aa0ea715e Invert tooltip messages order 2020-02-22 14:08:19 -03:00
Gabriel Dutra
6c27619671 Make Parameter Mapping required in UI 2020-02-21 23:00:26 -03:00
Gabriel Dutra
6eeb3b3eb2 Separate UI components 2020-02-21 15:49:23 -03:00
Gabriel Dutra
d40edb81c2 Fix backend tests 2020-02-21 14:18:59 -03:00
Gabriel Dutra
f128b4b85f Only allow search for Text Parameters 2020-02-21 13:36:06 -03:00
Gabriel Dutra
264fb5798d Merge branch 'master' into query-based-dropdown--parameters 2020-02-21 13:31:49 -03:00
Gabriel Dutra
90023ac435 Make sure Table updates correctly 2020-02-21 11:03:37 -03:00
Gabriel Dutra
df755fbc17 Add try except for NoResultFound 2020-02-21 09:40:52 -03:00
Gabriel Dutra
e555642844 Add is_safe check for parameterized query based 2020-02-21 09:27:12 -03:00
Gabriel Dutra
bdd7b146ae Change stored mapping attributes 2020-02-20 21:59:19 -03:00
Gabriel Dutra
b7478defec Don't validade query params with params 2020-02-20 19:29:43 -03:00
Gabriel Dutra
bb0d7830c9 Fixes + temp remove validation for Query param 2020-02-20 18:49:29 -03:00
Gabriel Dutra
137aa22dd4 Parameter Mapping UI (2/2) 2020-02-18 17:55:27 -03:00
Gabriel Dutra
9cf396599a Parameter Mapping UI (1/2) 2020-02-17 23:32:10 -03:00
Gabriel Dutra
b70f0fa921 Iterate over backend verification 2020-02-16 13:39:05 -03:00
Gabriel Dutra
5e3613d6cb Start experiements with a 'search' parameter 2020-02-13 16:29:50 -03:00
804 changed files with 51029 additions and 54730 deletions

View File

@@ -1,12 +0,0 @@
FROM cypress/browsers:node18.12.0-chrome106-ff106
ENV APP /usr/src/app
WORKDIR $APP
COPY package.json yarn.lock .yarnrc $APP/
COPY viz-lib $APP/viz-lib
RUN npm install yarn@1.22.22 -g && yarn --frozen-lockfile --network-concurrency 1 > /dev/null
COPY . $APP
RUN ./node_modules/.bin/cypress verify

View File

@@ -1,39 +0,0 @@
#!/bin/bash
# This script only needs to run on the main Redash repo
if [ "${GITHUB_REPOSITORY}" != "getredash/redash" ]; then
echo "Skipping image build for Docker Hub, as this isn't the main Redash repository"
exit 0
fi
if [ "${GITHUB_REF_NAME}" != "master" ] && [ "${GITHUB_REF_NAME}" != "preview-image" ]; then
echo "Skipping image build for Docker Hub, as this isn't the 'master' nor 'preview-image' branch"
exit 0
fi
if [ "x${DOCKER_USER}" = "x" ] || [ "x${DOCKER_PASS}" = "x" ]; then
echo "Skipping image build for Docker Hub, as the login details aren't available"
exit 0
fi
set -e
VERSION=$(jq -r .version package.json)
VERSION_TAG="$VERSION.b${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}"
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
docker login -u "${DOCKER_USER}" -p "${DOCKER_PASS}"
DOCKERHUB_REPO="redash/redash"
DOCKER_TAGS="-t redash/redash:preview -t redash/preview:${VERSION_TAG}"
# Build the docker container
docker build --build-arg install_groups="main,all_ds,dev" ${DOCKER_TAGS} .
# Push the container to the preview build locations
docker push "${DOCKERHUB_REPO}:preview"
docker push "redash/preview:${VERSION_TAG}"
echo "Built: ${VERSION_TAG}"

View File

@@ -1,6 +0,0 @@
#!/bin/bash
VERSION=$(jq -r .version package.json)
FULL_VERSION=${VERSION}+b${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}
sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '${FULL_VERSION}'/" redash/__init__.py
sed -i "s/dev/${GITHUB_SHA}/" client/app/version.json

View File

@@ -0,0 +1,12 @@
FROM cypress/browsers:node14.0.0-chrome84
ENV APP /usr/src/app
WORKDIR $APP
COPY package.json package-lock.json $APP/
COPY viz-lib $APP/viz-lib
RUN npm ci > /dev/null
COPY . $APP
RUN ./node_modules/.bin/cypress verify

177
.circleci/config.yml Normal file
View File

@@ -0,0 +1,177 @@
version: 2.0
build-docker-image-job: &build-docker-image-job
docker:
- image: circleci/node:12
steps:
- setup_remote_docker
- checkout
- run: sudo apt update
- run: sudo apt install python3-pip
- run: sudo pip3 install -r requirements_bundles.txt
- run: .circleci/update_version
- run: npm run bundle
- run: .circleci/docker_build
jobs:
backend-lint:
docker:
- image: circleci/python:3.7.0
steps:
- checkout
- run: sudo pip install flake8
- run: ./bin/flake8_tests.sh
backend-unit-tests:
environment:
COMPOSE_FILE: .circleci/docker-compose.circle.yml
COMPOSE_PROJECT_NAME: redash
docker:
- image: circleci/buildpack-deps:xenial
steps:
- setup_remote_docker
- checkout
- run:
name: Build Docker Images
command: |
set -x
docker-compose build --build-arg skip_ds_deps=true --build-arg skip_frontend_build=true
docker-compose up -d
sleep 10
- run:
name: Create Test Database
command: docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests;"
- run:
name: List Enabled Query Runners
command: docker-compose run --rm redash manage ds list_types
- run:
name: Run Tests
command: docker-compose run --name tests redash tests --junitxml=junit.xml --cov-report xml --cov=redash --cov-config .coveragerc tests/
- run:
name: Copy Test Results
command: |
mkdir -p /tmp/test-results/unit-tests
docker cp tests:/app/coverage.xml ./coverage.xml
docker cp tests:/app/junit.xml /tmp/test-results/unit-tests/results.xml
when: always
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: coverage.xml
frontend-lint:
environment:
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
docker:
- image: circleci/node:12
steps:
- checkout
- run: mkdir -p /tmp/test-results/eslint
- run: npm ci
- run: npm run lint:ci
- store_test_results:
path: /tmp/test-results
frontend-unit-tests:
environment:
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
docker:
- image: circleci/node:12
steps:
- checkout
- run: sudo apt update
- run: sudo apt install python3-pip
- run: sudo pip3 install -r requirements_bundles.txt
- run: npm ci
- run: npm run bundle
- run:
name: Run App Tests
command: npm test
- run:
name: Run Visualizations Tests
command: (cd viz-lib && npm test)
- run: npm run lint
frontend-e2e-tests:
environment:
COMPOSE_FILE: .circleci/docker-compose.cypress.yml
COMPOSE_PROJECT_NAME: cypress
PERCY_TOKEN_ENCODED: ZGRiY2ZmZDQ0OTdjMzM5ZWE0ZGQzNTZiOWNkMDRjOTk4Zjg0ZjMxMWRmMDZiM2RjOTYxNDZhOGExMjI4ZDE3MA==
CYPRESS_PROJECT_ID_ENCODED: OTI0Y2th
CYPRESS_RECORD_KEY_ENCODED: YzA1OTIxMTUtYTA1Yy00NzQ2LWEyMDMtZmZjMDgwZGI2ODgx
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
docker:
- image: circleci/node:12
steps:
- setup_remote_docker
- checkout
- run:
name: Enable Code Coverage report for master branch
command: |
if [ "$CIRCLE_BRANCH" = "master" ]; then
echo 'export CODE_COVERAGE=true' >> $BASH_ENV
source $BASH_ENV
fi
- run:
name: Install npm dependencies
command: |
npm ci
- run:
name: Setup Redash server
command: |
npm run cypress build
npm run cypress start -- --skip-db-seed
docker-compose run cypress npm run cypress db-seed
- run:
name: Execute Cypress tests
command: npm run cypress run-ci
- run:
name: "Failure: output container logs to console"
command: |
docker-compose logs
when: on_fail
- run:
name: Copy Code Coverage results
command: |
docker cp cypress:/usr/src/app/coverage ./coverage || true
when: always
- store_artifacts:
path: coverage
build-docker-image: *build-docker-image-job
build-preview-docker-image: *build-docker-image-job
workflows:
version: 2
build:
jobs:
- backend-lint
- backend-unit-tests:
requires:
- backend-lint
- frontend-lint
- frontend-unit-tests:
requires:
- backend-lint
- frontend-lint
- frontend-e2e-tests:
requires:
- frontend-lint
- build-preview-docker-image:
requires:
- backend-unit-tests
- frontend-unit-tests
- frontend-e2e-tests
filters:
branches:
only:
- master
- hold:
type: approval
requires:
- backend-unit-tests
- frontend-unit-tests
- frontend-e2e-tests
filters:
branches:
only:
- /release\/.*/
- build-docker-image:
requires:
- hold

View File

@@ -1,3 +1,4 @@
version: '2.2'
services: services:
redash: redash:
build: ../ build: ../
@@ -11,15 +12,11 @@ services:
PYTHONUNBUFFERED: 0 PYTHONUNBUFFERED: 0
REDASH_LOG_LEVEL: "INFO" REDASH_LOG_LEVEL: "INFO"
REDASH_REDIS_URL: "redis://redis:6379/0" REDASH_REDIS_URL: "redis://redis:6379/0"
POSTGRES_PASSWORD: "FmTKs5vX52ufKR1rd8tn4MoSP7zvCJwb" REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
REDASH_DATABASE_URL: "postgresql://postgres:FmTKs5vX52ufKR1rd8tn4MoSP7zvCJwb@postgres/postgres"
REDASH_COOKIE_SECRET: "2H9gNG9obnAQ9qnR9BDTQUph6CbXKCzF"
redis: redis:
image: redis:7-alpine image: redis:3.0-alpine
restart: unless-stopped restart: unless-stopped
postgres: postgres:
image: pgautoupgrade/pgautoupgrade:latest image: postgres:9.5.6-alpine
command: "postgres -c fsync=off -c full_page_writes=off -c synchronous_commit=OFF" command: "postgres -c fsync=off -c full_page_writes=off -c synchronous_commit=OFF"
restart: unless-stopped restart: unless-stopped
environment:
POSTGRES_HOST_AUTH_METHOD: "trust"

View File

@@ -1,17 +1,17 @@
version: "2.2"
x-redash-service: &redash-service x-redash-service: &redash-service
build: build:
context: ../ context: ../
args: args:
install_groups: "main" skip_dev_deps: "true"
skip_ds_deps: "true"
code_coverage: ${CODE_COVERAGE} code_coverage: ${CODE_COVERAGE}
x-redash-environment: &redash-environment x-redash-environment: &redash-environment
REDASH_LOG_LEVEL: "INFO" REDASH_LOG_LEVEL: "INFO"
REDASH_REDIS_URL: "redis://redis:6379/0" REDASH_REDIS_URL: "redis://redis:6379/0"
POSTGRES_PASSWORD: "FmTKs5vX52ufKR1rd8tn4MoSP7zvCJwb" REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
REDASH_DATABASE_URL: "postgresql://postgres:FmTKs5vX52ufKR1rd8tn4MoSP7zvCJwb@postgres/postgres"
REDASH_RATELIMIT_ENABLED: "false" REDASH_RATELIMIT_ENABLED: "false"
REDASH_ENFORCE_CSRF: "true" REDASH_ENFORCE_CSRF: "true"
REDASH_COOKIE_SECRET: "2H9gNG9obnAQ9qnR9BDTQUph6CbXKCzF"
services: services:
server: server:
<<: *redash-service <<: *redash-service
@@ -43,7 +43,7 @@ services:
ipc: host ipc: host
build: build:
context: ../ context: ../
dockerfile: .ci/Dockerfile.cypress dockerfile: .circleci/Dockerfile.cypress
depends_on: depends_on:
- server - server
- worker - worker
@@ -63,11 +63,9 @@ services:
CYPRESS_PROJECT_ID: ${CYPRESS_PROJECT_ID} CYPRESS_PROJECT_ID: ${CYPRESS_PROJECT_ID}
CYPRESS_RECORD_KEY: ${CYPRESS_RECORD_KEY} CYPRESS_RECORD_KEY: ${CYPRESS_RECORD_KEY}
redis: redis:
image: redis:7-alpine image: redis:3.0-alpine
restart: unless-stopped restart: unless-stopped
postgres: postgres:
image: pgautoupgrade/pgautoupgrade:latest image: postgres:9.5.6-alpine
command: "postgres -c fsync=off -c full_page_writes=off -c synchronous_commit=OFF" command: "postgres -c fsync=off -c full_page_writes=off -c synchronous_commit=OFF"
restart: unless-stopped restart: unless-stopped
environment:
POSTGRES_HOST_AUTH_METHOD: "trust"

17
.circleci/docker_build Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
VERSION=$(jq -r .version package.json)
VERSION_TAG=$VERSION.b$CIRCLE_BUILD_NUM
docker login -u $DOCKER_USER -p $DOCKER_PASS
if [ $CIRCLE_BRANCH = master ] || [ $CIRCLE_BRANCH = preview-image ]
then
docker build --build-arg skip_dev_deps=true -t redash/redash:preview -t redash/preview:$VERSION_TAG .
docker push redash/redash:preview
docker push redash/preview:$VERSION_TAG
else
docker build --build-arg skip_dev_deps=true -t redash/redash:$VERSION_TAG .
docker push redash/redash:$VERSION_TAG
fi
echo "Built: $VERSION_TAG"

6
.circleci/update_version Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
VERSION=$(jq -r .version package.json)
FULL_VERSION=$VERSION+b$CIRCLE_BUILD_NUM
sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '$FULL_VERSION'/" redash/__init__.py
sed -i "s/dev/$CIRCLE_SHA1/" client/app/version.json

View File

@@ -1,4 +1,5 @@
client/.tmp/ client/.tmp/
client/dist/
node_modules/ node_modules/
viz-lib/node_modules/ viz-lib/node_modules/
.tmp/ .tmp/

View File

@@ -7,10 +7,10 @@ about: Report reproducible software issues so we can improve
We use GitHub only for bug reports 🐛 We use GitHub only for bug reports 🐛
Anything else should be a discussion: https://github.com/getredash/redash/discussions/ 👫 Anything else should be posted to https://discuss.redash.io 👫
🚨For support, help & questions use https://github.com/getredash/redash/discussions/categories/q-a 🚨For support, help & questions use https://discuss.redash.io/c/support
💡For feature requests & ideas use https://github.com/getredash/redash/discussions/categories/ideas 💡For feature requests & ideas use https://discuss.redash.io/c/feature-requests
**Found a security vulnerability?** Please email security@redash.io to report any security vulnerabilities. We will acknowledge receipt of your vulnerability and strive to send you regular updates about our progress. If you're curious about the status of your disclosure please feel free to email us again. If you want to encrypt your disclosure email, you can use this PGP key. **Found a security vulnerability?** Please email security@redash.io to report any security vulnerabilities. We will acknowledge receipt of your vulnerability and strive to send you regular updates about our progress. If you're curious about the status of your disclosure please feel free to email us again. If you want to encrypt your disclosure email, you can use this PGP key.

View File

@@ -1,17 +1,17 @@
--- ---
name: "\U0001F4A1Anything else" name: "\U0001F4A1Anything else"
about: "For help, support, features & ideas - please use Discussions \U0001F46B " about: "For help, support, features & ideas - please use https://discuss.redash.io \U0001F46B "
labels: "Support Question" labels: "Support Question"
--- ---
We use GitHub only for bug reports 🐛 We use GitHub only for bug reports 🐛
Anything else should be a discussion: https://github.com/getredash/redash/discussions/ 👫 Anything else should be posted to https://discuss.redash.io 👫
🚨For support, help & questions use https://github.com/getredash/redash/discussions/categories/q-a 🚨For support, help & questions use https://discuss.redash.io/c/support
💡For feature requests & ideas use https://github.com/getredash/redash/discussions/categories/ideas 💡For feature requests & ideas use https://discuss.redash.io/c/feature-requests
Alternatively, check out these resources below. Thanks! 😁. Alternatively, check out these resources below. Thanks! 😁.
- [Discussions](https://github.com/getredash/redash/discussions/) - [Forum](https://disucss.redash.io)
- [Knowledge Base](https://redash.io/help) - [Knowledge Base](https://redash.io/help)

View File

@@ -1,5 +1,5 @@
## What type of PR is this? ## What type of PR is this? (check all applicable)
<!-- Check all that apply, delete what doesn't apply. --> <!-- Please leave only what's applicable -->
- [ ] Refactor - [ ] Refactor
- [ ] Feature - [ ] Feature
@@ -9,18 +9,7 @@
- [ ] Other - [ ] Other
## Description ## Description
<!-- In case of adding / modifying a query runner, please specify which version(s) you expect are compatible. -->
## How is this tested?
- [ ] Unit tests (pytest, jest)
- [ ] E2E Tests (Cypress)
- [ ] Manually
- [ ] N/A
<!-- If Manually, please describe. -->
## Related Tickets & Documents ## Related Tickets & Documents
<!-- If applicable, please include a link to your documentation PR against getredash/website -->
## Mobile & Desktop Screenshots/Recordings (if there are UI changes) ## Mobile & Desktop Screenshots/Recordings (if there are UI changes)

23
.github/support.yml vendored Normal file
View File

@@ -0,0 +1,23 @@
# Configuration for Support Requests - https://github.com/dessant/support-requests
# Label used to mark issues as support requests
supportLabel: Support Question
# Comment to post on issues marked as support requests, `{issue-author}` is an
# optional placeholder. Set to `false` to disable
supportComment: >
:wave: @{issue-author}, we use the issue tracker exclusively for bug reports
and planned work. However, this issue appears to be a support request.
Please use [our forum](https://discuss.redash.io) to get help.
# Close issues marked as support requests
close: true
# Lock issues marked as support requests
lock: false
# Assign `off-topic` as the reason for locking. Set to `false` to disable
setLockReason: true
# Repository to extend settings from
# _extends: repo

View File

@@ -1,177 +0,0 @@
name: Tests
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
NODE_VERSION: 18
YARN_VERSION: 1.22.22
jobs:
backend-lint:
runs-on: ubuntu-22.04
steps:
- if: github.event.pull_request.mergeable == 'false'
name: Exit if PR is not mergeable
run: exit 1
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-python@v5
with:
python-version: '3.8'
- run: sudo pip install black==23.1.0 ruff==0.0.287
- run: ruff check .
- run: black --check .
backend-unit-tests:
runs-on: ubuntu-22.04
needs: backend-lint
env:
COMPOSE_FILE: .ci/compose.ci.yaml
COMPOSE_PROJECT_NAME: redash
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
steps:
- if: github.event.pull_request.mergeable == 'false'
name: Exit if PR is not mergeable
run: exit 1
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: Build Docker Images
run: |
set -x
docker compose build --build-arg install_groups="main,all_ds,dev" --build-arg skip_frontend_build=true
docker compose up -d
sleep 10
- name: Create Test Database
run: docker compose -p redash run --rm postgres psql -h postgres -U postgres -c "create database tests;"
- name: List Enabled Query Runners
run: docker compose -p redash run --rm redash manage ds list_types
- name: Run Tests
run: docker compose -p redash run --name tests redash tests --junitxml=junit.xml --cov-report=xml --cov=redash --cov-config=.coveragerc tests/
- name: Copy Test Results
run: |
mkdir -p /tmp/test-results/unit-tests
docker cp tests:/app/coverage.xml ./coverage.xml
docker cp tests:/app/junit.xml /tmp/test-results/unit-tests/results.xml
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
- name: Store Test Results
uses: actions/upload-artifact@v4
with:
name: backend-test-results
path: /tmp/test-results
- name: Store Coverage Results
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.xml
frontend-lint:
runs-on: ubuntu-22.04
steps:
- if: github.event.pull_request.mergeable == 'false'
name: Exit if PR is not mergeable
run: exit 1
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install Dependencies
run: |
npm install --global --force yarn@$YARN_VERSION
yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
- name: Run Lint
run: yarn lint:ci
- name: Store Test Results
uses: actions/upload-artifact@v4
with:
name: frontend-test-results
path: /tmp/test-results
frontend-unit-tests:
runs-on: ubuntu-22.04
needs: frontend-lint
steps:
- if: github.event.pull_request.mergeable == 'false'
name: Exit if PR is not mergeable
run: exit 1
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install Dependencies
run: |
npm install --global --force yarn@$YARN_VERSION
yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
- name: Run App Tests
run: yarn test
- name: Run Visualizations Tests
run: cd viz-lib && yarn test
- run: yarn lint
frontend-e2e-tests:
runs-on: ubuntu-22.04
needs: frontend-lint
env:
COMPOSE_FILE: .ci/compose.cypress.yaml
COMPOSE_PROJECT_NAME: cypress
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
# PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
# CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
steps:
- if: github.event.pull_request.mergeable == 'false'
name: Exit if PR is not mergeable
run: exit 1
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Enable Code Coverage Report For Master Branch
if: endsWith(github.ref, '/master')
run: |
echo "CODE_COVERAGE=true" >> "$GITHUB_ENV"
- name: Install Dependencies
run: |
npm install --global --force yarn@$YARN_VERSION
yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
- name: Setup Redash Server
run: |
set -x
yarn cypress build
yarn cypress start -- --skip-db-seed
docker compose run cypress yarn cypress db-seed
- name: Execute Cypress Tests
run: yarn cypress run-ci
- name: "Failure: output container logs to console"
if: failure()
run: docker compose logs
- name: Copy Code Coverage Results
run: docker cp cypress:/usr/src/app/coverage ./coverage || true
- name: Store Coverage Results
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage

View File

@@ -1,86 +0,0 @@
name: Periodic Snapshot
on:
schedule:
- cron: '10 0 1 * *' # 10 minutes after midnight on the first day of every month
workflow_dispatch:
inputs:
bump:
description: 'Bump the last digit of the version'
required: false
type: boolean
version:
description: 'Specific version to set'
required: false
default: ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
actions: write
contents: write
jobs:
bump-version-and-tag:
runs-on: ubuntu-latest
if: github.ref_name == github.event.repository.default_branch
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.ACTION_PUSH_KEY }}
- run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
# Function to bump the version
bump_version() {
local version="$1"
local IFS=.
read -r major minor patch <<< "$version"
patch=$((patch + 1))
echo "$major.$minor.$patch-dev"
}
# Determine the new version tag
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
BUMP_INPUT="${{ github.event.inputs.bump }}"
SPECIFIC_VERSION="${{ github.event.inputs.version }}"
# Check if both bump and specific version are provided
if [ "$BUMP_INPUT" = "true" ] && [ -n "$SPECIFIC_VERSION" ]; then
echo "::error::Error: Cannot specify both bump and specific version."
exit 1
fi
if [ -n "$SPECIFIC_VERSION" ]; then
TAG_NAME="$SPECIFIC_VERSION-dev"
elif [ "$BUMP_INPUT" = "true" ]; then
CURRENT_VERSION=$(grep '"version":' package.json | awk -F\" '{print $4}')
TAG_NAME=$(bump_version "$CURRENT_VERSION")
else
echo "No version bump or specific version provided for manual dispatch."
exit 1
fi
else
TAG_NAME="$(date +%y.%m).0-dev"
fi
echo "New version tag: $TAG_NAME"
# Update version in files
gawk -i inplace -F: -v q=\" -v tag=${TAG_NAME} '/^ "version": / { print $1 FS, q tag q ","; next} { print }' package.json
gawk -i inplace -F= -v q=\" -v tag=${TAG_NAME} '/^__version__ =/ { print $1 FS, q tag q; next} { print }' redash/__init__.py
gawk -i inplace -F= -v q=\" -v tag=${TAG_NAME} '/^version =/ { print $1 FS, q tag q; next} { print }' pyproject.toml
git add package.json redash/__init__.py pyproject.toml
git commit -m "Snapshot: ${TAG_NAME}"
git tag ${TAG_NAME}
git push --atomic origin master refs/tags/${TAG_NAME}
# Run the 'preview-image' workflow if run this workflow manually
# For more information, please see the: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
if [ "$BUMP_INPUT" = "true" ] || [ -n "$SPECIFIC_VERSION" ]; then
gh workflow run preview-image.yml --ref $TAG_NAME
fi

View File

@@ -1,185 +0,0 @@
name: Preview Image
on:
push:
tags:
- '*-dev'
workflow_dispatch:
inputs:
dockerRepository:
description: 'Docker repository'
required: true
default: 'preview'
type: choice
options:
- preview
- redash
env:
NODE_VERSION: 18
jobs:
build-skip-check:
runs-on: ubuntu-22.04
outputs:
skip: ${{ steps.skip-check.outputs.skip }}
steps:
- name: Skip?
id: skip-check
run: |
if [[ "${{ vars.DOCKER_USER }}" == '' ]]; then
echo 'Docker user is empty. Skipping build+push'
echo skip=true >> "$GITHUB_OUTPUT"
elif [[ "${{ secrets.DOCKER_PASS }}" == '' ]]; then
echo 'Docker password is empty. Skipping build+push'
echo skip=true >> "$GITHUB_OUTPUT"
elif [[ "${{ vars.DOCKER_REPOSITORY }}" == '' ]]; then
echo 'Docker repository is empty. Skipping build+push'
echo skip=true >> "$GITHUB_OUTPUT"
else
echo 'Docker user and password are set and branch is `master`.'
echo 'Building + pushing `preview` image.'
echo skip=false >> "$GITHUB_OUTPUT"
fi
build-docker-image:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
include:
- arch: amd64
os: ubuntu-22.04
- arch: arm64
os: ubuntu-22.04-arm
outputs:
VERSION_TAG: ${{ steps.version.outputs.VERSION_TAG }}
needs:
- build-skip-check
if: needs.build-skip-check.outputs.skip == 'false'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.event.push.after }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Install Dependencies
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
run: |
npm install --global --force yarn@1.22.22
yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
- name: Set version
id: version
run: |
set -x
.ci/update_version
VERSION_TAG=$(jq -r .version package.json)
echo "VERSION_TAG=$VERSION_TAG" >> "$GITHUB_OUTPUT"
- name: Build and push preview image to Docker Hub
id: build-preview
uses: docker/build-push-action@v4
if: ${{ github.event.inputs.dockerRepository == 'preview' || !github.event.workflow_run }}
with:
tags: |
${{ vars.DOCKER_REPOSITORY }}/redash
${{ vars.DOCKER_REPOSITORY }}/preview
context: .
build-args: |
test_all_deps=true
outputs: type=image,push-by-digest=true,push=true
cache-from: type=gha,scope=${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
env:
DOCKER_CONTENT_TRUST: true
- name: Build and push release image to Docker Hub
id: build-release
uses: docker/build-push-action@v4
if: ${{ github.event.inputs.dockerRepository == 'redash' }}
with:
tags: |
${{ vars.DOCKER_REPOSITORY }}/redash:${{ steps.version.outputs.VERSION_TAG }}
context: .
build-args: |
test_all_deps=true
outputs: type=image,push-by-digest=true,push=true
cache-from: type=gha,scope=${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
env:
DOCKER_CONTENT_TRUST: true
- name: "Failure: output container logs to console"
if: failure()
run: docker compose logs
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
if [[ "${{ github.event.inputs.dockerRepository }}" == 'preview' || !github.event.workflow_run ]]; then
digest="${{ steps.build-preview.outputs.digest}}"
else
digest="${{ steps.build-release.outputs.digest}}"
fi
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.arch }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
merge-docker-image:
runs-on: ubuntu-22.04
needs: build-docker-image
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Create and push manifest for the preview image
if: ${{ github.event.inputs.dockerRepository == 'preview' || !github.event.workflow_run }}
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create -t ${{ vars.DOCKER_REPOSITORY }}/redash:preview \
$(printf '${{ vars.DOCKER_REPOSITORY }}/redash:preview@sha256:%s ' *)
docker buildx imagetools create -t ${{ vars.DOCKER_REPOSITORY }}/preview:${{ needs.build-docker-image.outputs.VERSION_TAG }} \
$(printf '${{ vars.DOCKER_REPOSITORY }}/preview:${{ needs.build-docker-image.outputs.VERSION_TAG }}@sha256:%s ' *)
- name: Create and push manifest for the release image
if: ${{ github.event.inputs.dockerRepository == 'redash' }}
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create -t ${{ vars.DOCKER_REPOSITORY }}/redash:${{ needs.build-docker-image.outputs.VERSION_TAG }} \
$(printf '${{ vars.DOCKER_REPOSITORY }}/redash:${{ needs.build-docker-image.outputs.VERSION_TAG }}@sha256:%s ' *)

View File

@@ -1,36 +0,0 @@
name: Restyled
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
restyled:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: restyled-io/actions/setup@v4
- id: restyler
uses: restyled-io/actions/run@v4
with:
fail-on-differences: true
- if: |
!cancelled() &&
steps.restyler.outputs.success == 'true' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-pull-request@v6
with:
base: ${{ steps.restyler.outputs.restyled-base }}
branch: ${{ steps.restyler.outputs.restyled-head }}
title: ${{ steps.restyler.outputs.restyled-title }}
body: ${{ steps.restyler.outputs.restyled-body }}
labels: "restyled"
reviewers: ${{ github.event.pull_request.user.login }}
delete-branch: true

1
.gitignore vendored
View File

@@ -17,7 +17,6 @@ client/dist
_build _build
.vscode .vscode
.env .env
.tool-versions
dump.rdb dump.rdb

1
.npmrc
View File

@@ -1 +0,0 @@
engine-strict = true

1
.nvmrc
View File

@@ -1 +0,0 @@
v18

View File

@@ -1,10 +0,0 @@
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.287"
hooks:
- id: ruff

View File

@@ -38,9 +38,7 @@ request_review: author
# #
# These can be used to tell other automation to avoid our PRs. # These can be used to tell other automation to avoid our PRs.
# #
labels: labels: ["Skip CI"]
- restyled
- "Skip CI"
# Labels to ignore # Labels to ignore
# #
@@ -52,16 +50,13 @@ labels:
# Restylers to run, and how # Restylers to run, and how
restylers: restylers:
- name: black - name: black
image: restyled/restyler-black:v24.4.2 image: restyled/restyler-black:v19.10b0
include: include:
- redash - redash
- tests - tests
- migrations/versions - migrations/versions
- name: prettier - name: prettier
image: restyled/restyler-prettier:v3.3.2-2 image: restyled/restyler-prettier:v1.19.1-2
command:
- prettier
- --write
include: include:
- client/app/**/*.js - client/app/**/*.js
- client/app/**/*.jsx - client/app/**/*.jsx

2
.yarn/.gitignore vendored
View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -1,152 +1,5 @@
# Change Log # Change Log
## V10.1.0 - 2021-11-23
This release includes patches for three security vulnerabilities:
- Insecure default configuration affects installations where REDASH_COOKIE_SECRET is not set explicitly (CVE-2021-41192)
- SSRF vulnerability affects installations that enabled URL-loading data sources (CVE-2021-43780)
- Incorrect usage of state parameter in OAuth client code affects installations where Google Login is enabled (CVE-2021-43777)
And a couple features that didn't merge in time for 10.0.0
- Big Query: Speed up schema loading (#5632)
- Add support for Firebolt data source (#5606)
- Fix: Loading schema for Sqlite DB with "Order" column name fails (#5623)
## v10.0.0 - 2021-10-01
A few changes were merged during the V10 beta period.
- New Data Source: CSV/Excel Files
- Fix: Edit Source button disappeared for users without CanEdit permissions
- We pinned our docker base image to Python3.7-slim-buster to avoid build issues
- Fix: dashboard list pagination didn't work
## v10.0.0-beta - 2021-06-16
Just over a year since our last release, the V10 beta is ready. Since we never made a non-beta release of V9, we expect many users will upgrade directly from V8 -> V10. This will bring a lot of exciting features. Please check out the V9 beta release notes below to learn more.
This V10 beta incorporates fixes for the feedback we received on the V9 beta along with a few long-requested features (horizontal bar charts!) and other changes to improve UX and reliability.
This release was made possible by contributions from 35+ people (the Github API didn't let us pull handles this time around): Alex Kovar, Alexander Rusanov, Arik Fraimovich, Ben Amor, Christopher Grant, Đặng Minh Dũng, Daniel Lang, deecay, Elad Ossadon, Gabriel Dutra, iwakiriK, Jannis Leidel, Jerry, Jesse Whitehouse, Jiajie Zhong, Jim Sparkman, Jonathan Hult, Josh Bohde, Justin Talbot, koooge, Lei Ni, Levko Kravets, Lingkai Kong, max-voronov, Mike Nason, Nolan Nichols, Omer Lachish, Patrick Yang, peterlee, Rafael Wendel, Sebastian Tramp, simonschneider-db, Tim Gates, Tobias Macey, Vipul Mathur, and Vladislav Denisov
Our special thanks to [Sohail Ahmed](https://pk.linkedin.com/in/sohail-ahmed-755776184) for reporting a vulnerability in our "forgot password" page (#5425)
### Upgrading
(This section is duplicated from the previous release - since many users will upgrade directly from V8 -> V10)
Typically, if you are running your own instance of Redash and wish to upgrade, you would simply modify the Docker tag in your `docker-compose.yml` file. Since RQ has replaced Celery in this version, there are a couple extra modifications that need to be done in your `docker-compose.yml`:
1. Under `services/scheduler/environment`, omit `QUEUES` and `WORKERS_COUNT` (and omit `environment` altogether if it is empty).
2. Under `services`, add a new service for general RQ jobs:
```yaml
worker:
<<: *redash-service
command: worker
environment:
QUEUES: "periodic emails default"
WORKERS_COUNT: 1
```
Following that, force a recreation of your containers with `docker-compose up --force-recreate --build` and you should be good to go.
### UX
- Redash now uses a vertical navbar
- Dashboard list now includes “My Dashboards” filter
- Dashboard parameters can now be re-ordered
- Queries can now be executed with Shift + Enter on all platforms.
- Added New Dashboard/Query/Alert buttons to corresponding list pages
- Dashboard text widgets now prompt to confirm before closing the text editor
- A plus sign is now shown between tags used for search
- On the queries list view “My Queries” has moved above “Archived”
- Improved behavior for filtering by tags in list views
- When a users session expires for inactivity, they are prompted to log-in with a pop-up so they dont lose their place in the app
- Numerous accessibility changes towards the a11y standard
- Hide the “Create” menu button if current user doesnt have permission to any data sources
### Visualizations
- Feature: Added support for horizontal box plots
- Feature: Added support for horizontal bar charts
- Feature: Added “Reverse” option for Chart visualization legend
- Feature: Added option to align Chart Y-axes at zero
- Feature: The table visualization header is now fixed when scrolling
- Feature: Added USA map to choropleth visualization
- Fix: Selected filters were reset when switching visualizations
- Fix: Stacked bar chart showed the wrong Y-axis range in some cases
- Fix: Bar chart with second y axis overlapped data series
- Fix: Y-axis autoscale failed when min or max was set
- Fix: Custom JS visualization was broken because of a typo
- Fix: Too large visualization caused filters block to collapse
- Fix: Sankey visualization looked inconsistent if the data source returned VARCHAR instead of numeric types
### Structural Updates
- Redash now prevents CSRF attacks
- Migration to TypeScript
- Upgrade to Antd version 4
### Data Sources
- New Data Sources: SPARQL Endpoint, Eccenca Corporate Memory, TrinoDB
- Databricks
- Custom Schema Browser that allows switching between databases
- Option added to truncate large results
- Support for multiple-statement queries
- Schema browser can now use eventlet instead of RQ
- MongoDB:
- Moved Username and Password out of the connection string so that password can be stored secretly
- Oracle:
- Fix: Annotated queries always failed. Annotation is now disabled
- Postgres/CockroachDB:
- SSL certfile/keyfile fields are now handled as secret
- Python:
- Feature: Custom built-ins are now supported
- Fix: Query runner was not compatible with Python 3
- Snowflake:
- Data source now accepts a custom host address (for use with proxies)
- TreasureData:
- API key field is now handled as secret
- Yandex:
- OAuth token field is now handled as secret
### Alerts
- Feature: Added ability to mute alerts without deleting them
- Change: Non-email alert destination details are now obfuscated to avoid leaking sensitive information (webhook URLs, tokens etc.)
- Fix: numerical comparisons failed if value from query was a string
### Parameters
- Added “Last 12 months” option for dynamic date ranges
### Bug Fixes
- Fix: Private addresses were not allowed even when enforcing was disabled
- Fix: Python query runner wasnt updated for Python 3
- Fix: Sorting queries by schedule returned the wrong order
- Fix: Counter visualization was enormous in some cases
- Fix: Dashboard URL will now change when the dashboard title changes
- Fix: URL parameters were removed when forking a query
- Fix: Create link on data sources page was broken
- Fix: Queries could be reassigned to read-only data sources
- Fix: Multi-select dropdown was very slow if there were 1k+ options
- Fix: Search Input couldnt be focused or updated while editing a dashboard
- Fix: The CLI command for “status” did not work
- Fix: The dashboard list screen displayed too few items under certain pagination configurations
### Other
- Added an environment variable to disable public sharing links for queries and dashboards
- Alert destinations are now encrypted at the database
- The base query runner now has stubs to implement result truncating for other data sources
- Static SAML configuration and assertion encryption are now supported
- Adds new component for adding extra actions to the query and dashboard pages
- Non-admins with at least view_only permission on a dashboard can now make GET requests to the data source resource
- Added a BLOCKED_DOMAINS setting to prevent sign-ups from emails at specific domains
- Added a rate limit to the “forgot password” page
- RQ workers will now shutdown gracefully for known error codes
- Scheduled execution failure counter now resets following a successful ad hoc execution
- Redash now deletes locks for cancelled queries
- Upgraded Ace Editor from v6 to v9
- Added a periodic job to remove ghost locks
- Removed content width limit on all pages
- Introduce a <Link> React component
## v9.0.0-beta - 2020-06-11 ## v9.0.0-beta - 2020-06-11
This release was long time in the making and has several major changes: This release was long time in the making and has several major changes:

View File

@@ -4,7 +4,19 @@ Thank you for taking the time to contribute! :tada::+1:
The following is a set of guidelines for contributing to Redash. These are guidelines, not rules, please use your best judgement and feel free to propose changes to this document in a pull request. The following is a set of guidelines for contributing to Redash. These are guidelines, not rules, please use your best judgement and feel free to propose changes to this document in a pull request.
:star: If you're already here and love the project, please make sure to press the Star button. :star: ## Quick Links:
- [Feature Requests](https://discuss.redash.io/c/feature-requests)
- [Documentation](https://redash.io/help/)
- [Blog](https://blog.redash.io/)
- [Twitter](https://twitter.com/getredash)
---
:star: If you already here and love the project, please make sure to press the Star button. :star:
---
## Table of Contents ## Table of Contents
[How can I contribute?](#how-can-i-contribute) [How can I contribute?](#how-can-i-contribute)
@@ -20,13 +32,6 @@ The following is a set of guidelines for contributing to Redash. These are guide
- [Release Method](#release-method) - [Release Method](#release-method)
- [Code of Conduct](#code-of-conduct) - [Code of Conduct](#code-of-conduct)
## Quick Links:
- [User Forum](https://github.com/getredash/redash/discussions)
- [Documentation](https://redash.io/help/)
---
## How can I contribute? ## How can I contribute?
### Reporting Bugs ### Reporting Bugs
@@ -34,54 +39,25 @@ The following is a set of guidelines for contributing to Redash. These are guide
When creating a new bug report, please make sure to: When creating a new bug report, please make sure to:
- Search for existing issues first. If you find a previous report of your issue, please update the existing issue with additional information instead of creating a new one. - Search for existing issues first. If you find a previous report of your issue, please update the existing issue with additional information instead of creating a new one.
- If you are not sure if your issue is really a bug or just some configuration/setup problem, please start a [Q&A discussion](https://github.com/getredash/redash/discussions/new?category=q-a) first. Unless you can provide clear steps to reproduce, it's probably better to start with a discussion and later to open an issue. - If you are not sure if your issue is really a bug or just some configuration/setup problem, please start a discussion in [the support forum](https://discuss.redash.io/c/support) first. Unless you can provide clear steps to reproduce, it's probably better to start with a thread in the forum and later to open an issue.
- If you still decide to open an issue, please review the template and guidelines and include as much details as possible. - If you still decide to open an issue, please review the template and guidelines and include as much details as possible.
### Suggesting Enhancements / Feature Requests ### Suggesting Enhancements / Feature Requests
If you would like to suggest an enhancement or ask for a new feature: If you would like to suggest an enhancement or ask for a new feature:
- Please check [the Ideas discussions](https://github.com/getredash/redash/discussions/categories/ideas) for existing threads about what you want to suggest/ask. If there is, feel free to upvote it to signal interest or add your comments. - Please check [the forum](https://discuss.redash.io/c/feature-requests/5) for existing threads about what you want to suggest/ask. If there is, feel free to upvote it to signal interest or add your comments.
- If there is no open thread, you're welcome to start one to have a discussion about what you want to suggest. Try to provide as much details and context as possible and include information about *the problem you want to solve* rather only *your proposed solution*. - If there is no open thread, you're welcome to start one to have a discussion about what you want to suggest. Try to provide as much details and context as possible and include information about *the problem you want to solve* rather only *your proposed solution*.
### Pull Requests ### Pull Requests
**Code contributions are welcomed**. For big changes or significant features, it's usually better to reach out first and discuss what you want to implement and how (we recommend reading: [Pull Request First](https://medium.com/practical-blend/pull-request-first-f6bb667a9b6#.ozlqxvj36)). This is to make sure that what you want to implement is aligned with our goals for the project and that no one else is already working on it. - **Code contributions are welcomed**. For big changes or significant features, it's usually better to reach out first and discuss what you want to implement and how (we recommend reading: [Pull Request First](https://medium.com/practical-blend/pull-request-first-f6bb667a9b6#.ozlqxvj36)). This to make sure that what you want to implement is aligned with our goals for the project and that no one else is already working on it.
- Include screenshots and animated GIFs in your pull request whenever possible.
#### Criteria for Review / Merging
When you open your pull request, please follow this repositorys PR template carefully:
- Indicate the type of change
- If you implement multiple unrelated features, bug fixes, or refactors please split them into individual pull requests.
- Describe the change
- If fixing a bug, please describe the bug or link to an existing github issue / forum discussion
- Include UI screenshots / GIFs whenever possible
- Please add [documentation](#documentation) for new features or changes in functionality along with the code. - Please add [documentation](#documentation) for new features or changes in functionality along with the code.
- Please follow existing code style: - Please follow existing code style:
- Python: we use [Black](https://github.com/psf/black) to auto format the code. - Python: we use [Black](https://github.com/psf/black) to auto format the code.
- Javascript: we use [Prettier](https://github.com/prettier/prettier) to auto-format the code. - Javascript: we use [Prettier](https://github.com/prettier/prettier) to auto-format the code.
#### Initial Review (1 week)
During this phase, a team member will apply the “Team Review” label if a pull request meets our criteria or a “Needs More Information” label if not. If more information is required, the team member will comment which criteria have not been met.
If your pull request receives the “Needs More Information” label, please make the requested changes and then remove the label. This resets the 1 week timer for an initial review.
Stale pull requests that remain untouched in “Needs More Information” for more than 4 weeks will be closed.
If a team member closes your pull request, you may reopen it after you have made the changes requested during initial review. After you make these changes, remove the “Needs More Information” label. This again resets the timer for another initial review.
#### Full Review (2 weeks)
After the “Team Review” label is applied, a member of the core team will review the PR within 2 weeks.
Reviews will approve, request changes, or ask questions to discuss areas of uncertainty. After youve responded, a member of the team will re-review within one week.
#### Merging (1 week)
After your pull request has been approved, a member of the core team will merge the pull request within a week.
### Documentation ### Documentation
The project's documentation can be found at [https://redash.io/help/](https://redash.io/help/). The [documentation sources](https://github.com/getredash/website/tree/master/src/pages/kb) are hosted on GitHub. To contribute edits / new pages, you can use GitHub's interface. Click the "Edit on GitHub" link on the documentation page to quickly open the edit interface. The project's documentation can be found at [https://redash.io/help/](https://redash.io/help/). The [documentation sources](https://github.com/getredash/website/tree/master/src/pages/kb) are hosted on GitHub. To contribute edits / new pages, you can use GitHub's interface. Click the "Edit on GitHub" link on the documentation page to quickly open the edit interface.

View File

@@ -1,6 +1,4 @@
FROM node:18-bookworm AS frontend-builder FROM node:12 as frontend-builder
RUN npm install --global --force yarn@1.22.22
# Controls whether to build the frontend assets # Controls whether to build the frontend assets
ARG skip_frontend_build ARG skip_frontend_build
@@ -12,41 +10,32 @@ RUN useradd -m -d /frontend redash
USER redash USER redash
WORKDIR /frontend WORKDIR /frontend
COPY --chown=redash package.json yarn.lock .yarnrc /frontend/ COPY --chown=redash package.json package-lock.json /frontend/
COPY --chown=redash viz-lib /frontend/viz-lib COPY --chown=redash viz-lib /frontend/viz-lib
COPY --chown=redash scripts /frontend/scripts
# Controls whether to instrument code for coverage information # Controls whether to instrument code for coverage information
ARG code_coverage ARG code_coverage
ENV BABEL_ENV=${code_coverage:+test} ENV BABEL_ENV=${code_coverage:+test}
# Avoid issues caused by lags in disk and network I/O speeds when working on top of QEMU emulation for multi-platform image building. RUN if [ "x$skip_frontend_build" = "x" ] ; then npm ci --unsafe-perm; fi
RUN yarn config set network-timeout 300000
RUN if [ "x$skip_frontend_build" = "x" ] ; then yarn --frozen-lockfile --network-concurrency 1; fi
COPY --chown=redash client /frontend/client COPY --chown=redash client /frontend/client
COPY --chown=redash webpack.config.js /frontend/ COPY --chown=redash webpack.config.js /frontend/
RUN <<EOF RUN if [ "x$skip_frontend_build" = "x" ] ; then npm run build; else mkdir -p /frontend/client/dist && touch /frontend/client/dist/multi_org.html && touch /frontend/client/dist/index.html; fi
if [ "x$skip_frontend_build" = "x" ]; then FROM python:3.7-slim
yarn build
else
mkdir -p /frontend/client/dist
touch /frontend/client/dist/multi_org.html
touch /frontend/client/dist/index.html
fi
EOF
FROM python:3.10-slim-bookworm
EXPOSE 5000 EXPOSE 5000
# Controls whether to install extra dependencies needed for all data sources.
ARG skip_ds_deps
# Controls whether to install dev dependencies.
ARG skip_dev_deps
RUN useradd --create-home redash RUN useradd --create-home redash
# Ubuntu packages # Ubuntu packages
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y --no-install-recommends \ apt-get install -y \
pkg-config \
curl \ curl \
gnupg \ gnupg \
build-essential \ build-essential \
@@ -54,8 +43,7 @@ RUN apt-get update && \
libffi-dev \ libffi-dev \
sudo \ sudo \
git-core \ git-core \
# Kerberos, needed for MS SQL Python driver to compile on arm64 wget \
libkrb5-dev \
# Postgres client # Postgres client
libpq-dev \ libpq-dev \
# ODBC support: # ODBC support:
@@ -69,51 +57,37 @@ RUN apt-get update && \
libsasl2-dev \ libsasl2-dev \
unzip \ unzip \
libsasl2-modules-gssapi-mit && \ libsasl2-modules-gssapi-mit && \
# MSSQL ODBC Driver:
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get install -y msodbcsql17 && \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
ARG databricks_odbc_driver_url=https://databricks.com/wp-content/uploads/2.6.10.1010-2/SimbaSparkODBC-2.6.10.1010-2-Debian-64bit.zip
ARG TARGETPLATFORM ADD $databricks_odbc_driver_url /tmp/simba_odbc.zip
ARG databricks_odbc_driver_url=https://databricks-bi-artifacts.s3.us-east-2.amazonaws.com/simbaspark-drivers/odbc/2.6.26/SimbaSparkODBC-2.6.26.1045-Debian-64bit.zip RUN unzip /tmp/simba_odbc.zip -d /tmp/ \
RUN <<EOF && dpkg -i /tmp/SimbaSparkODBC-*/*.deb \
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then && echo "[Simba]\nDriver = /opt/simba/spark/lib/64/libsparkodbc_sb64.so" >> /etc/odbcinst.ini \
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg && rm /tmp/simba_odbc.zip \
curl https://packages.microsoft.com/config/debian/12/prod.list > /etc/apt/sources.list.d/mssql-release.list && rm -rf /tmp/SimbaSparkODBC*
apt-get update
ACCEPT_EULA=Y apt-get install -y --no-install-recommends msodbcsql18
apt-get clean
rm -rf /var/lib/apt/lists/*
curl "$databricks_odbc_driver_url" --location --output /tmp/simba_odbc.zip
chmod 600 /tmp/simba_odbc.zip
unzip /tmp/simba_odbc.zip -d /tmp/simba
dpkg -i /tmp/simba/*.deb
printf "[Simba]\nDriver = /opt/simba/spark/lib/64/libsparkodbc_sb64.so" >> /etc/odbcinst.ini
rm /tmp/simba_odbc.zip
rm -rf /tmp/simba
fi
EOF
WORKDIR /app WORKDIR /app
ENV POETRY_VERSION=1.8.3 # Disalbe PIP Cache and Version Check
ENV POETRY_HOME=/etc/poetry ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV POETRY_VIRTUALENVS_CREATE=false ENV PIP_NO_CACHE_DIR=1
RUN curl -sSL https://install.python-poetry.org | python3 -
# Avoid crashes, including corrupted cache artifacts, when building multi-platform images with GitHub Actions. # We first copy only the requirements file, to avoid rebuilding on every file
RUN /etc/poetry/bin/poetry cache clear pypi --all # change.
COPY requirements.txt requirements_bundles.txt requirements_dev.txt requirements_all_ds.txt ./
RUN if [ "x$skip_dev_deps" = "x" ] ; then pip install -r requirements.txt -r requirements_dev.txt; else pip install -r requirements.txt; fi
RUN if [ "x$skip_ds_deps" = "x" ] ; then pip install -r requirements_all_ds.txt ; else echo "Skipping pip install -r requirements_all_ds.txt" ; fi
COPY pyproject.toml poetry.lock ./ COPY . /app
COPY --from=frontend-builder /frontend/client/dist /app/client/dist
ARG POETRY_OPTIONS="--no-root --no-interaction --no-ansi" RUN chown -R redash /app
# for LDAP authentication, install with `ldap3` group
# disabled by default due to GPL license conflict
ARG install_groups="main,all_ds,dev"
RUN /etc/poetry/bin/poetry install --only $install_groups $POETRY_OPTIONS
COPY --chown=redash . /app
COPY --from=frontend-builder --chown=redash /frontend/client/dist /app/client/dist
RUN chown redash /app
USER redash USER redash
ENTRYPOINT ["/app/bin/docker-entrypoint"] ENTRYPOINT ["/app/bin/docker-entrypoint"]

View File

@@ -1,3 +0,0 @@
The Bahrain map data used in Redash was downloaded from
https://cartographyvectors.com/map/857-bahrain-detailed-boundary in PR #6192.
* Free for personal and commercial purpose with attribution.

View File

@@ -1,80 +1,57 @@
.PHONY: compose_build up test_db create_database clean clean-all down tests lint backend-unit-tests frontend-unit-tests test build watch start redis-cli bash .PHONY: compose_build up test_db create_database clean down bundle tests lint backend-unit-tests frontend-unit-tests test build watch start redis-cli bash
compose_build: .env compose_build:
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose build docker-compose build
up: up:
docker compose up -d redis postgres --remove-orphans docker-compose up -d --build
docker compose exec -u postgres postgres psql postgres --csv \
-1tqc "SELECT table_name FROM information_schema.tables WHERE table_name = 'organizations'" 2> /dev/null \
| grep -q "organizations" || make create_database
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose up -d --build --remove-orphans
test_db: test_db:
@for i in `seq 1 5`; do \ @for i in `seq 1 5`; do \
if (docker compose exec postgres sh -c 'psql -U postgres -c "select 1;"' 2>&1 > /dev/null) then break; \ if (docker-compose exec postgres sh -c 'psql -U postgres -c "select 1;"' 2>&1 > /dev/null) then break; \
else echo "postgres initializing..."; sleep 5; fi \ else echo "postgres initializing..."; sleep 5; fi \
done done
docker compose exec postgres sh -c 'psql -U postgres -c "drop database if exists tests;" && psql -U postgres -c "create database tests;"' docker-compose exec postgres sh -c 'psql -U postgres -c "drop database if exists tests;" && psql -U postgres -c "create database tests;"'
create_database: .env create_database:
docker compose run server create_db docker-compose run server create_db
clean: clean:
docker compose down docker-compose down && docker-compose rm
docker compose --project-name cypress down
docker compose rm --stop --force
docker compose --project-name cypress rm --stop --force
docker image rm --force \
cypress-server:latest cypress-worker:latest cypress-scheduler:latest \
redash-server:latest redash-worker:latest redash-scheduler:latest
docker container prune --force
docker image prune --force
docker volume prune --force
clean-all: clean
docker image rm --force \
redash/redash:latest redis:7-alpine maildev/maildev:latest \
pgautoupgrade/pgautoupgrade:15-alpine3.8 pgautoupgrade/pgautoupgrade:latest
down: down:
docker compose down docker-compose down
.env: bundle:
printf "REDASH_COOKIE_SECRET=`pwgen -1s 32`\nREDASH_SECRET_KEY=`pwgen -1s 32`\n" >> .env docker-compose run server bin/bundle-extensions
env: .env
format:
pre-commit run --all-files
tests: tests:
docker compose run server tests docker-compose run server tests
lint: lint:
ruff check . ./bin/flake8_tests.sh
black --check . --diff
backend-unit-tests: up test_db backend-unit-tests: up test_db
docker compose run --rm --name tests server tests docker-compose run --rm --name tests server tests
frontend-unit-tests: frontend-unit-tests: bundle
CYPRESS_INSTALL_BINARY=0 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 yarn --frozen-lockfile CYPRESS_INSTALL_BINARY=0 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm ci
yarn test npm run bundle
npm test
test: backend-unit-tests frontend-unit-tests lint test: lint backend-unit-tests frontend-unit-tests
build: build: bundle
yarn build npm run build
watch: watch: bundle
yarn watch npm run watch
start: start: bundle
yarn start npm run start
redis-cli: redis-cli:
docker compose run --rm redis redis-cli -h redis docker-compose run --rm redis redis-cli -h redis
bash: bash:
docker compose run --rm server bash docker-compose run --rm server bash

View File

@@ -3,7 +3,8 @@
</p> </p>
[![Documentation](https://img.shields.io/badge/docs-redash.io/help-brightgreen.svg)](https://redash.io/help/) [![Documentation](https://img.shields.io/badge/docs-redash.io/help-brightgreen.svg)](https://redash.io/help/)
[![GitHub Build](https://github.com/getredash/redash/actions/workflows/ci.yml/badge.svg)](https://github.com/getredash/redash/actions) [![Datree](https://s3.amazonaws.com/catalog.static.datree.io/datree-badge-20px.svg)](https://datree.io/?src=badge)
[![Build Status](https://circleci.com/gh/getredash/redash.png?style=shield&circle-token=8a695aa5ec2cbfa89b48c275aea298318016f040)](https://circleci.com/gh/getredash/redash/tree/master)
Redash is designed to enable anyone, regardless of the level of technical sophistication, to harness the power of data big and small. SQL users leverage Redash to explore, query, visualize, and share data from any data sources. Their work in turn enables anybody in their organization to use the data. Every day, millions of users at thousands of organizations around the world use Redash to develop insights and make data-driven decisions. Redash is designed to enable anyone, regardless of the level of technical sophistication, to harness the power of data big and small. SQL users leverage Redash to explore, query, visualize, and share data from any data sources. Their work in turn enables anybody in their organization to use the data. Every day, millions of users at thousands of organizations around the world use Redash to develop insights and make data-driven decisions.
@@ -31,71 +32,48 @@ Redash features:
Redash supports more than 35 SQL and NoSQL [data sources](https://redash.io/help/data-sources/supported-data-sources). It can also be extended to support more. Below is a list of built-in sources: Redash supports more than 35 SQL and NoSQL [data sources](https://redash.io/help/data-sources/supported-data-sources). It can also be extended to support more. Below is a list of built-in sources:
- Amazon Athena - Amazon Athena
- Amazon CloudWatch / Insights
- Amazon DynamoDB - Amazon DynamoDB
- Amazon Redshift - Amazon Redshift
- ArangoDB
- Axibase Time Series Database - Axibase Time Series Database
- Apache Cassandra - Cassandra
- ClickHouse - ClickHouse
- CockroachDB - CockroachDB
- Couchbase
- CSV - CSV
- Databricks - Databricks (Apache Spark)
- DB2 by IBM - DB2 by IBM
- Dgraph - Druid
- Apache Drill
- Apache Druid
- e6data
- Eccenca Corporate Memory
- Elasticsearch - Elasticsearch
- Exasol
- Microsoft Excel
- Firebolt
- Databend
- Google Analytics - Google Analytics
- Google BigQuery - Google BigQuery
- Google Spreadsheets - Google Spreadsheets
- Graphite - Graphite
- Greenplum - Greenplum
- Apache Hive - Hive
- Apache Impala - Impala
- InfluxDB - InfluxDB
- InfluxDBv2 - JIRA
- IBM Netezza Performance Server
- JIRA (JQL)
- JSON - JSON
- Apache Kylin - Apache Kylin
- OmniSciDB (Formerly MapD) - OmniSciDB (Formerly MapD)
- MariaDB
- MemSQL - MemSQL
- Microsoft Azure Data Warehouse / Synapse - Microsoft Azure Data Warehouse / Synapse
- Microsoft Azure SQL Database - Microsoft Azure SQL Database
- Microsoft Azure Data Explorer / Kusto
- Microsoft SQL Server - Microsoft SQL Server
- MongoDB - MongoDB
- MySQL - MySQL
- Oracle - Oracle
- Apache Phoenix
- Apache Pinot
- PostgreSQL - PostgreSQL
- Presto - Presto
- Prometheus - Prometheus
- Python - Python
- Qubole - Qubole
- Rockset - Rockset
- RisingWave
- Salesforce - Salesforce
- ScyllaDB - ScyllaDB
- Shell Scripts - Shell Scripts
- Snowflake - Snowflake
- SPARQL
- SQLite - SQLite
- TiDB
- Tinybird
- TreasureData - TreasureData
- Trino
- Uptycs
- Vertica - Vertica
- Yandex AppMetrrica - Yandex AppMetrrica
- Yandex Metrica - Yandex Metrica
@@ -103,13 +81,12 @@ Redash supports more than 35 SQL and NoSQL [data sources](https://redash.io/help
## Getting Help ## Getting Help
* Issues: https://github.com/getredash/redash/issues * Issues: https://github.com/getredash/redash/issues
* Discussion Forum: https://github.com/getredash/redash/discussions/ * Discussion Forum: https://discuss.redash.io/
* Development Discussion: https://discord.gg/tN5MdmfGBp
## Reporting Bugs and Contributing Code ## Reporting Bugs and Contributing Code
* Want to report a bug or request a feature? Please open [an issue](https://github.com/getredash/redash/issues/new). * Want to report a bug or request a feature? Please open [an issue](https://github.com/getredash/redash/issues/new).
* Want to help us build **_Redash_**? Fork the project, edit in a [dev environment](https://github.com/getredash/redash/wiki/Local-development-setup) and make a pull request. We need all the help we can get! * Want to help us build **_Redash_**? Fork the project, edit in a [dev environment](https://redash.io/help-onpremise/dev/guide.html) and make a pull request. We need all the help we can get!
## Security ## Security

115
bin/bundle-extensions Executable file
View File

@@ -0,0 +1,115 @@
#!/usr/bin/env python3
"""Copy bundle extension files to the client/app/extension directory"""
import logging
import os
from pathlib import Path
from shutil import copy
from collections import OrderedDict as odict
import importlib_metadata
import importlib_resources
# Name of the subdirectory
BUNDLE_DIRECTORY = "bundle"
logger = logging.getLogger(__name__)
# Make a directory for extensions and set it as an environment variable
# to be picked up by webpack.
extensions_relative_path = Path("client", "app", "extensions")
extensions_directory = Path(__file__).parent.parent / extensions_relative_path
if not extensions_directory.exists():
extensions_directory.mkdir()
os.environ["EXTENSIONS_DIRECTORY"] = str(extensions_relative_path)
def entry_point_module(entry_point):
"""Returns the dotted module path for the given entry point"""
return entry_point.pattern.match(entry_point.value).group("module")
def load_bundles():
""""Load bundles as defined in Redash extensions.
The bundle entry point can be defined as a dotted path to a module
or a callable, but it won't be called but just used as a means
to find the files under its file system path.
The name of the directory it looks for files in is "bundle".
So a Python package with an extension bundle could look like this::
my_extensions/
├── __init__.py
└── wide_footer
├── __init__.py
└── bundle
├── extension.js
└── styles.css
and would then need to register the bundle with an entry point
under the "redash.bundles" group, e.g. in your setup.py::
setup(
# ...
entry_points={
"redash.bundles": [
"wide_footer = my_extensions.wide_footer",
]
# ...
},
# ...
)
"""
bundles = odict()
for entry_point in importlib_metadata.entry_points().get("redash.bundles", []):
logger.info('Loading Redash bundle "%s".', entry_point.name)
module = entry_point_module(entry_point)
# Try to get a list of bundle files
try:
bundle_dir = importlib_resources.files(module).joinpath(BUNDLE_DIRECTORY)
except (ImportError, TypeError):
# Module isn't a package, so can't have a subdirectory/-package
logger.error(
'Redash bundle module "%s" could not be imported: "%s"',
entry_point.name,
module,
)
continue
if not bundle_dir.is_dir():
logger.error(
'Redash bundle directory "%s" could not be found or is not a directory: "%s"',
entry_point.name,
bundle_dir,
)
continue
bundles[entry_point.name] = list(bundle_dir.rglob("*"))
return bundles
bundles = load_bundles().items()
if bundles:
print("Number of extension bundles found: {}".format(len(bundles)))
else:
print("No extension bundles found.")
for bundle_name, paths in bundles:
# Shortcut in case not paths were found for the bundle
if not paths:
print('No paths found for bundle "{}".'.format(bundle_name))
continue
# The destination for the bundle files with the entry point name as the subdirectory
destination = Path(extensions_directory, bundle_name)
if not destination.exists():
destination.mkdir()
# Copy the bundle directory from the module to its destination.
print('Copying "{}" bundle to {}:'.format(bundle_name, destination.resolve()))
for src_path in paths:
dest_path = destination / src_path.name
print(" - {} -> {}".format(src_path, dest_path))
copy(str(src_path), str(dest_path))

View File

@@ -22,19 +22,6 @@ worker() {
exec supervisord -c worker.conf exec supervisord -c worker.conf
} }
workers_healthcheck() {
WORKERS_COUNT=${WORKERS_COUNT}
echo "Checking active workers count against $WORKERS_COUNT..."
ACTIVE_WORKERS_COUNT=`echo $(rq info --url $REDASH_REDIS_URL -R | grep workers | grep -oP ^[0-9]+)`
if [ "$ACTIVE_WORKERS_COUNT" -lt "$WORKERS_COUNT" ]; then
echo "$ACTIVE_WORKERS_COUNT workers are active, Exiting"
exit 1
else
echo "$ACTIVE_WORKERS_COUNT workers are active"
exit 0
fi
}
dev_worker() { dev_worker() {
echo "Starting dev RQ worker..." echo "Starting dev RQ worker..."
@@ -45,8 +32,7 @@ server() {
# Recycle gunicorn workers every n-th request. See http://docs.gunicorn.org/en/stable/settings.html#max-requests for more details. # Recycle gunicorn workers every n-th request. See http://docs.gunicorn.org/en/stable/settings.html#max-requests for more details.
MAX_REQUESTS=${MAX_REQUESTS:-1000} MAX_REQUESTS=${MAX_REQUESTS:-1000}
MAX_REQUESTS_JITTER=${MAX_REQUESTS_JITTER:-100} MAX_REQUESTS_JITTER=${MAX_REQUESTS_JITTER:-100}
TIMEOUT=${REDASH_GUNICORN_TIMEOUT:-60} exec /usr/local/bin/gunicorn -b 0.0.0.0:5000 --name redash -w${REDASH_WEB_WORKERS:-4} redash.wsgi:app --max-requests $MAX_REQUESTS --max-requests-jitter $MAX_REQUESTS_JITTER
exec /usr/local/bin/gunicorn -b 0.0.0.0:5000 --name redash -w${REDASH_WEB_WORKERS:-4} redash.wsgi:app --max-requests $MAX_REQUESTS --max-requests-jitter $MAX_REQUESTS_JITTER --timeout $TIMEOUT
} }
create_db() { create_db() {
@@ -67,7 +53,7 @@ help() {
echo "" echo ""
echo "shell -- open shell" echo "shell -- open shell"
echo "dev_server -- start Flask development server with debugger and auto reload" echo "dev_server -- start Flask development server with debugger and auto reload"
echo "debug -- start Flask development server with remote debugger via debugpy" echo "debug -- start Flask development server with remote debugger via ptvsd"
echo "create_db -- create database tables" echo "create_db -- create database tables"
echo "manage -- CLI to manage redash" echo "manage -- CLI to manage redash"
echo "tests -- run tests" echo "tests -- run tests"
@@ -89,10 +75,6 @@ case "$1" in
shift shift
worker worker
;; ;;
workers_healthcheck)
shift
workers_healthcheck
;;
server) server)
shift shift
server server

9
bin/flake8_tests.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
set -o errexit # fail the build if any task fails
flake8 --version ; pip --version
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

View File

@@ -1,44 +1,35 @@
#!/bin/env python3 #!/bin/env python3
import sys
import re import re
import subprocess import subprocess
import sys
def get_change_log(previous_sha): def get_change_log(previous_sha):
args = [ args = ['git', '--no-pager', 'log', '--merges', '--grep', 'Merge pull request', '--pretty=format:"%h|%s|%b|%p"', 'master...{}'.format(previous_sha)]
"git",
"--no-pager",
"log",
"--merges",
"--grep",
"Merge pull request",
'--pretty=format:"%h|%s|%b|%p"',
"master...{}".format(previous_sha),
]
log = subprocess.check_output(args) log = subprocess.check_output(args)
changes = [] changes = []
for line in log.split("\n"): for line in log.split('\n'):
try: try:
sha, subject, body, parents = line[1:-1].split("|") sha, subject, body, parents = line[1:-1].split('|')
except ValueError: except ValueError:
continue continue
try: try:
pull_request = re.match(r"Merge pull request #(\d+)", subject).groups()[0] pull_request = re.match("Merge pull request #(\d+)", subject).groups()[0]
pull_request = " #{}".format(pull_request) pull_request = " #{}".format(pull_request)
except Exception: except Exception as ex:
pull_request = "" pull_request = ""
author = subprocess.check_output(["git", "log", "-1", '--pretty=format:"%an"', parents.split(" ")[-1]])[1:-1] author = subprocess.check_output(['git', 'log', '-1', '--pretty=format:"%an"', parents.split(' ')[-1]])[1:-1]
changes.append("{}{}: {} ({})".format(sha, pull_request, body.strip(), author)) changes.append("{}{}: {} ({})".format(sha, pull_request, body.strip(), author))
return changes return changes
if __name__ == "__main__": if __name__ == '__main__':
previous_sha = sys.argv[1] previous_sha = sys.argv[1]
changes = get_change_log(previous_sha) changes = get_change_log(previous_sha)

View File

@@ -1,20 +1,17 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import sys
import re import re
import subprocess import subprocess
import sys
from urllib.parse import urlparse
import requests import requests
import simplejson import simplejson
github_token = os.environ["GITHUB_TOKEN"] github_token = os.environ['GITHUB_TOKEN']
auth = (github_token, "x-oauth-basic") auth = (github_token, 'x-oauth-basic')
repo = "getredash/redash" repo = 'getredash/redash'
def _github_request(method, path, params=None, headers={}): def _github_request(method, path, params=None, headers={}):
if urlparse(path).hostname != "api.github.com": if not path.startswith('https://api.github.com'):
url = "https://api.github.com/{}".format(path) url = "https://api.github.com/{}".format(path)
else: else:
url = path url = path
@@ -25,18 +22,15 @@ def _github_request(method, path, params=None, headers={}):
response = requests.request(method, url, data=params, auth=auth) response = requests.request(method, url, data=params, auth=auth)
return response return response
def exception_from_error(message, response): def exception_from_error(message, response):
return Exception("({}) {}: {}".format(response.status_code, message, response.json().get("message", "?"))) return Exception("({}) {}: {}".format(response.status_code, message, response.json().get('message', '?')))
def rc_tag_name(version): def rc_tag_name(version):
return "v{}-rc".format(version) return "v{}-rc".format(version)
def get_rc_release(version): def get_rc_release(version):
tag = rc_tag_name(version) tag = rc_tag_name(version)
response = _github_request("get", "repos/{}/releases/tags/{}".format(repo, tag)) response = _github_request('get', 'repos/{}/releases/tags/{}'.format(repo, tag))
if response.status_code == 404: if response.status_code == 404:
return None return None
@@ -45,101 +39,84 @@ def get_rc_release(version):
raise exception_from_error("Unknown error while looking RC release: ", response) raise exception_from_error("Unknown error while looking RC release: ", response)
def create_release(version, commit_sha): def create_release(version, commit_sha):
tag = rc_tag_name(version) tag = rc_tag_name(version)
params = { params = {
"tag_name": tag, 'tag_name': tag,
"name": "{} - RC".format(version), 'name': "{} - RC".format(version),
"target_commitish": commit_sha, 'target_commitish': commit_sha,
"prerelease": True, 'prerelease': True
} }
response = _github_request("post", "repos/{}/releases".format(repo), params) response = _github_request('post', 'repos/{}/releases'.format(repo), params)
if response.status_code != 201: if response.status_code != 201:
raise exception_from_error("Failed creating new release", response) raise exception_from_error("Failed creating new release", response)
return response.json() return response.json()
def upload_asset(release, filepath): def upload_asset(release, filepath):
upload_url = release["upload_url"].replace("{?name,label}", "") upload_url = release['upload_url'].replace('{?name,label}', '')
filename = filepath.split("/")[-1] filename = filepath.split('/')[-1]
with open(filepath) as file_content: with open(filepath) as file_content:
headers = {"Content-Type": "application/gzip"} headers = {'Content-Type': 'application/gzip'}
response = requests.post( response = requests.post(upload_url, file_content, params={'name': filename}, headers=headers, auth=auth, verify=False)
upload_url, file_content, params={"name": filename}, headers=headers, auth=auth, verify=False
)
if response.status_code != 201: # not 200/201/... if response.status_code != 201: # not 200/201/...
raise exception_from_error("Failed uploading asset", response) raise exception_from_error('Failed uploading asset', response)
return response return response
def remove_previous_builds(release): def remove_previous_builds(release):
for asset in release["assets"]: for asset in release['assets']:
response = _github_request("delete", asset["url"]) response = _github_request('delete', asset['url'])
if response.status_code != 204: if response.status_code != 204:
raise exception_from_error("Failed deleting asset", response) raise exception_from_error("Failed deleting asset", response)
def get_changelog(commit_sha): def get_changelog(commit_sha):
latest_release = _github_request("get", "repos/{}/releases/latest".format(repo)) latest_release = _github_request('get', 'repos/{}/releases/latest'.format(repo))
if latest_release.status_code != 200: if latest_release.status_code != 200:
raise exception_from_error("Failed getting latest release", latest_release) raise exception_from_error('Failed getting latest release', latest_release)
latest_release = latest_release.json() latest_release = latest_release.json()
previous_sha = latest_release["target_commitish"] previous_sha = latest_release['target_commitish']
args = [ args = ['git', '--no-pager', 'log', '--merges', '--grep', 'Merge pull request', '--pretty=format:"%h|%s|%b|%p"', '{}...{}'.format(previous_sha, commit_sha)]
"git",
"--no-pager",
"log",
"--merges",
"--grep",
"Merge pull request",
'--pretty=format:"%h|%s|%b|%p"',
"{}...{}".format(previous_sha, commit_sha),
]
log = subprocess.check_output(args) log = subprocess.check_output(args)
changes = ["Changes since {}:".format(latest_release["name"])] changes = ["Changes since {}:".format(latest_release['name'])]
for line in log.split("\n"): for line in log.split('\n'):
try: try:
sha, subject, body, parents = line[1:-1].split("|") sha, subject, body, parents = line[1:-1].split('|')
except ValueError: except ValueError:
continue continue
try: try:
pull_request = re.match(r"Merge pull request #(\d+)", subject).groups()[0] pull_request = re.match("Merge pull request #(\d+)", subject).groups()[0]
pull_request = " #{}".format(pull_request) pull_request = " #{}".format(pull_request)
except Exception: except Exception as ex:
pull_request = "" pull_request = ""
author = subprocess.check_output(["git", "log", "-1", '--pretty=format:"%an"', parents.split(" ")[-1]])[1:-1] author = subprocess.check_output(['git', 'log', '-1', '--pretty=format:"%an"', parents.split(' ')[-1]])[1:-1]
changes.append("{}{}: {} ({})".format(sha, pull_request, body.strip(), author)) changes.append("{}{}: {} ({})".format(sha, pull_request, body.strip(), author))
return "\n".join(changes) return "\n".join(changes)
def update_release_commit_sha(release, commit_sha): def update_release_commit_sha(release, commit_sha):
params = { params = {
"target_commitish": commit_sha, 'target_commitish': commit_sha,
} }
response = _github_request("patch", "repos/{}/releases/{}".format(repo, release["id"]), params) response = _github_request('patch', 'repos/{}/releases/{}'.format(repo, release['id']), params)
if response.status_code != 200: if response.status_code != 200:
raise exception_from_error("Failed updating commit sha for existing release", response) raise exception_from_error("Failed updating commit sha for existing release", response)
return response.json() return response.json()
def update_release(version, build_filepath, commit_sha): def update_release(version, build_filepath, commit_sha):
try: try:
release = get_rc_release(version) release = get_rc_release(version)
@@ -148,22 +125,21 @@ def update_release(version, build_filepath, commit_sha):
else: else:
release = create_release(version, commit_sha) release = create_release(version, commit_sha)
print("Using release id: {}".format(release["id"])) print("Using release id: {}".format(release['id']))
remove_previous_builds(release) remove_previous_builds(release)
response = upload_asset(release, build_filepath) response = upload_asset(release, build_filepath)
changelog = get_changelog(commit_sha) changelog = get_changelog(commit_sha)
response = _github_request("patch", release["url"], {"body": changelog}) response = _github_request('patch', release['url'], {'body': changelog})
if response.status_code != 200: if response.status_code != 200:
raise exception_from_error("Failed updating release description", response) raise exception_from_error("Failed updating release description", response)
except Exception as ex: except Exception as ex:
print(ex) print(ex)
if __name__ == '__main__':
if __name__ == "__main__":
commit_sha = sys.argv[1] commit_sha = sys.argv[1]
version = sys.argv[2] version = sys.argv[2]
filepath = sys.argv[3] filepath = sys.argv[3]

242
bin/upgrade Executable file
View File

@@ -0,0 +1,242 @@
#!/usr/bin/env python3
import urllib
import argparse
import os
import subprocess
import sys
from collections import namedtuple
from fnmatch import fnmatch
import requests
try:
import semver
except ImportError:
print("Missing required library: semver.")
exit(1)
REDASH_HOME = os.environ.get('REDASH_HOME', '/opt/redash')
CURRENT_VERSION_PATH = '{}/current'.format(REDASH_HOME)
def run(cmd, cwd=None):
if not cwd:
cwd = REDASH_HOME
return subprocess.check_output(cmd, cwd=cwd, shell=True, stderr=subprocess.STDOUT)
def confirm(question):
reply = str(input(question + ' (y/n): ')).lower().strip()
if reply[0] == 'y':
return True
if reply[0] == 'n':
return False
else:
return confirm("Please use 'y' or 'n'")
def version_path(version_name):
return "{}/{}".format(REDASH_HOME, version_name)
END_CODE = '\033[0m'
def colored_string(text, color):
if sys.stdout.isatty():
return "{}{}{}".format(color, text, END_CODE)
else:
return text
def h1(text):
print(colored_string(text, '\033[4m\033[1m'))
def green(text):
print(colored_string(text, '\033[92m'))
def red(text):
print(colored_string(text, '\033[91m'))
class Release(namedtuple('Release', ('version', 'download_url', 'filename', 'description'))):
def v1_or_newer(self):
return semver.compare(self.version, '1.0.0-alpha') >= 0
def is_newer(self, version):
return semver.compare(self.version, version) > 0
@property
def version_name(self):
return self.filename.replace('.tar.gz', '')
def get_latest_release_from_ci():
response = requests.get('https://circleci.com/api/v1.1/project/github/getredash/redash/latest/artifacts?branch=master')
if response.status_code != 200:
exit("Failed getting releases (status code: %s)." % response.status_code)
tarball_asset = filter(lambda asset: asset['url'].endswith('.tar.gz'), response.json())[0]
filename = urllib.unquote(tarball_asset['pretty_path'].split('/')[-1])
version = filename.replace('redash.', '').replace('.tar.gz', '')
release = Release(version, tarball_asset['url'], filename, '')
return release
def get_release(channel):
if channel == 'ci':
return get_latest_release_from_ci()
response = requests.get('https://version.redash.io/api/releases?channel={}'.format(channel))
release = response.json()[0]
filename = release['download_url'].split('/')[-1]
release = Release(release['version'], release['download_url'], filename, release['description'])
return release
def link_to_current(version_name):
green("Linking to current version...")
run('ln -nfs {} {}'.format(version_path(version_name), CURRENT_VERSION_PATH))
def restart_services():
# We're doing this instead of simple 'supervisorctl restart all' because
# otherwise it won't notice that /opt/redash/current pointing at a different
# directory.
green("Restarting...")
try:
run('sudo /etc/init.d/redash_supervisord restart')
except subprocess.CalledProcessError as e:
run('sudo service supervisor restart')
def update_requirements(version_name):
green("Installing new Python packages (if needed)...")
new_requirements_file = '{}/requirements.txt'.format(version_path(version_name))
install_requirements = False
try:
run('diff {}/requirements.txt {}'.format(CURRENT_VERSION_PATH, new_requirements_file)) != 0
except subprocess.CalledProcessError as e:
if e.returncode != 0:
install_requirements = True
if install_requirements:
run('sudo pip install -r {}'.format(new_requirements_file))
def apply_migrations(release):
green("Running migrations (if needed)...")
if not release.v1_or_newer():
return apply_migrations_pre_v1(release.version_name)
run("sudo -u redash bin/run ./manage.py db upgrade", cwd=version_path(release.version_name))
def find_migrations(version_name):
current_migrations = set([f for f in os.listdir("{}/migrations".format(CURRENT_VERSION_PATH)) if fnmatch(f, '*_*.py')])
new_migrations = sorted([f for f in os.listdir("{}/migrations".format(version_path(version_name))) if fnmatch(f, '*_*.py')])
return [m for m in new_migrations if m not in current_migrations]
def apply_migrations_pre_v1(version_name):
new_migrations = find_migrations(version_name)
if new_migrations:
green("New migrations to run: ")
print(', '.join(new_migrations))
else:
print("No new migrations in this version.")
if new_migrations and confirm("Apply new migrations? (make sure you have backup)"):
for migration in new_migrations:
print("Applying {}...".format(migration))
run("sudo sudo -u redash PYTHONPATH=. bin/run python migrations/{}".format(migration), cwd=version_path(version_name))
def download_and_unpack(release):
directory_name = release.version_name
green("Downloading release tarball...")
run('sudo wget --header="Accept: application/octet-stream" -O {} {}'.format(release.filename, release.download_url))
green("Unpacking to: {}...".format(directory_name))
run('sudo mkdir -p {}'.format(directory_name))
run('sudo tar -C {} -xvf {}'.format(directory_name, release.filename))
green("Changing ownership to redash...")
run('sudo chown redash {}'.format(directory_name))
green("Linking .env file...")
run('sudo ln -nfs {}/.env {}/.env'.format(REDASH_HOME, version_path(directory_name)))
def current_version():
real_current_path = os.path.realpath(CURRENT_VERSION_PATH).replace('.b', '+b')
return real_current_path.replace(REDASH_HOME + '/', '').replace('redash.', '')
def verify_minimum_version():
green("Current version: " + current_version())
if semver.compare(current_version(), '0.12.0') < 0:
red("You need to have Redash v0.12.0 or newer to upgrade to post v1.0.0 releases.")
green("To upgrade to v0.12.0, run the upgrade script set to the legacy channel (--channel legacy).")
exit(1)
def show_description_and_confirm(description):
if description:
print(description)
if not confirm("Continue with upgrade?"):
red("Cancelling upgrade.")
exit(1)
def verify_newer_version(release):
if not release.is_newer(current_version()):
red("The found release is not newer than your current deployed release ({}).".format(current_version()))
if not confirm("Continue with upgrade?"):
red("Cancelling upgrade.")
exit(1)
def deploy_release(channel):
h1("Starting Redash upgrade:")
release = get_release(channel)
green("Found version: {}".format(release.version))
if release.v1_or_newer():
verify_minimum_version()
verify_newer_version(release)
show_description_and_confirm(release.description)
try:
download_and_unpack(release)
update_requirements(release.version_name)
apply_migrations(release)
link_to_current(release.version_name)
restart_services()
green("Done! Enjoy.")
except subprocess.CalledProcessError as e:
red("Failed running: {}".format(e.cmd))
red("Exit status: {}\nOutput:\n{}".format(e.returncode, e.output))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--channel", help="The channel to get release from (default: stable).", default='stable')
args = parser.parse_args()
deploy_release(args.channel)

View File

@@ -5,11 +5,10 @@ module.exports = {
"react-app", "react-app",
"plugin:compat/recommended", "plugin:compat/recommended",
"prettier", "prettier",
"plugin:jsx-a11y/recommended",
// Remove any typescript-eslint rules that would conflict with prettier // Remove any typescript-eslint rules that would conflict with prettier
"prettier/@typescript-eslint", "prettier/@typescript-eslint",
], ],
plugins: ["jest", "compat", "no-only-tests", "@typescript-eslint", "jsx-a11y"], plugins: ["jest", "compat", "no-only-tests", "@typescript-eslint"],
settings: { settings: {
"import/resolver": "webpack", "import/resolver": "webpack",
}, },
@@ -20,20 +19,7 @@ module.exports = {
rules: { rules: {
// allow debugger during development // allow debugger during development
"no-debugger": process.env.NODE_ENV === "production" ? 2 : 0, "no-debugger": process.env.NODE_ENV === "production" ? 2 : 0,
"jsx-a11y/anchor-is-valid": [ "jsx-a11y/anchor-is-valid": "off",
// TMP
"off",
{
components: ["Link"],
aspects: ["noHref", "invalidHref", "preferButton"],
},
],
"jsx-a11y/no-redundant-roles": "error",
"jsx-a11y/no-autofocus": "off",
"jsx-a11y/click-events-have-key-events": "off", // TMP
"jsx-a11y/no-static-element-interactions": "off", // TMP
"jsx-a11y/no-noninteractive-element-interactions": "off", // TMP
"no-console": ["warn", { allow: ["warn", "error"] }],
"no-restricted-imports": [ "no-restricted-imports": [
"error", "error",
{ {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -225,16 +225,6 @@
} }
} }
&-tbody > tr&-row {
&:hover,
&:focus,
&:focus-within {
& > td {
background: @table-row-hover-bg;
}
}
}
// Custom styles // Custom styles
&-headerless &-tbody > tr:first-child > td { &-headerless &-tbody > tr:first-child > td {
@@ -401,18 +391,6 @@
left: 0; left: 0;
} }
} }
&:focus,
&:focus-within {
color: @menu-highlight-color;
}
}
}
.@{dropdown-prefix-cls}-menu-item {
&:focus,
&:focus-within {
background-color: @item-hover-bg;
} }
} }

View File

@@ -98,10 +98,6 @@ strong {
.clickable { .clickable {
cursor: pointer; cursor: pointer;
button&:disabled {
cursor: not-allowed;
}
} }
.resize-vertical { .resize-vertical {

View File

@@ -1,23 +1,26 @@
.edit-in-place { .edit-in-place span {
white-space: pre-line; white-space: pre-line;
display: inline-block;
p { p {
margin-bottom: 0; margin-bottom: 0;
} }
}
.editable { .edit-in-place span.editable {
display: inline-block; display: inline-block;
cursor: pointer; cursor: pointer;
}
&:hover { .edit-in-place span.editable:hover {
background: @redash-yellow; background: @redash-yellow;
border-radius: @redash-radius; border-radius: @redash-radius;
} }
}
.edit-in-place.active input,
&.active input, .edit-in-place.active textarea {
&.active textarea { display: inline-block;
display: inline-block; }
}
.edit-in-place {
display: inline-block;
} }

View File

@@ -2,7 +2,7 @@
Generate Margin Classes (0px - 25px) Generate Margin Classes (0px - 25px)
margin, margin-top, margin-bottom, margin-left, margin-right margin, margin-top, margin-bottom, margin-left, margin-right
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.margin (@label, @size: 1, @key:1) when (@size =< 30) { .margin (@label, @size: 1, @key:1) when (@size =< 30){
.m-@{key} { .m-@{key} {
margin: @size !important; margin: @size !important;
} }
@@ -28,15 +28,15 @@
.margin(25, 0px, 0); .margin(25, 0px, 0);
.m-2 { .m-2{
margin: 2px; margin:2px;
} }
/* -------------------------------------------------------- /* --------------------------------------------------------
Generate Padding Classes (0px - 25px) Generate Padding Classes (0px - 25px)
padding, padding-top, padding-bottom, padding-left, padding-right padding, padding-top, padding-bottom, padding-left, padding-right
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.padding (@label, @size: 1, @key:1) when (@size =< 30) { .padding (@label, @size: 1, @key:1) when (@size =< 30){
.p-@{key} { .p-@{key} {
padding: @size !important; padding: @size !important;
} }
@@ -62,10 +62,11 @@
.padding(25, 0px, 0); .padding(25, 0px, 0);
/* -------------------------------------------------------- /* --------------------------------------------------------
Generate Font-Size Classes (8px - 20px) Generate Font-Size Classes (8px - 20px)
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.font-size (@label, @size: 8, @key:10) when (@size =< 20) { .font-size (@label, @size: 8, @key:10) when (@size =< 20){
.f-@{key} { .f-@{key} {
font-size: @size !important; font-size: @size !important;
} }
@@ -75,78 +76,47 @@
.font-size(20, 8px, 8); .font-size(20, 8px, 8);
.f-inherit { .f-inherit { font-size: inherit !important; }
font-size: inherit !important;
}
/* -------------------------------------------------------- /* --------------------------------------------------------
Font Weight Font Weight
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.f-300 { .f-300 { font-weight: 300 !important; }
font-weight: 300 !important; .f-400 { font-weight: 400 !important; }
} .f-500 { font-weight: 500 !important; }
.f-400 { .f-700 { font-weight: 700 !important; }
font-weight: 400 !important;
}
.f-500 {
font-weight: 500 !important;
}
.f-700 {
font-weight: 700 !important;
}
/* -------------------------------------------------------- /* --------------------------------------------------------
Position Position
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.p-relative { .p-relative { position: relative !important; }
position: relative !important; .p-absolute { position: absolute !important; }
} .p-fixed { position: fixed !important; }
.p-absolute { .p-static { position: static !important; }
position: absolute !important;
}
.p-fixed {
position: fixed !important;
}
.p-static {
position: static !important;
}
/* -------------------------------------------------------- /* --------------------------------------------------------
Overflow Overflow
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.o-hidden { .o-hidden { overflow: hidden !important; }
overflow: hidden !important; .o-visible { overflow: visible !important; }
} .o-auto { overflow: auto !important; }
.o-visible {
overflow: visible !important;
}
.o-auto {
overflow: auto !important;
}
/* -------------------------------------------------------- /* --------------------------------------------------------
Display Display
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.di-block { .di-block { display: inline-block !important; }
display: inline-block !important; .d-block { display: block; }
}
.d-block {
display: block;
}
/* -------------------------------------------------------- /* --------------------------------------------------------
Background Colors and Colors Background Colors and Colors
-----------------------------------------------------------*/ -----------------------------------------------------------*/
@array: c-white bg-white @white, c-ace bg-ace @ace, c-black bg-black @black, c-brown bg-brown @brown, @array: c-white bg-white @white, c-ace bg-ace @ace, c-black bg-black @black, c-brown bg-brown @brown, c-pink bg-pink @pink, c-red bg-red @red, c-blue bg-blue @blue, c-purple bg-purple @purple, c-deeppurple bg-deeppurple @deeppurple, c-lightblue bg-lightblue @lightblue, c-cyan bg-cyan @cyan, c-teal bg-teal @teal, c-green bg-green @green, c-lightgreen bg-lightgreen @lightgreen, c-lime bg-lime @lime, c-yellow bg-yellow @yellow, c-amber bg-amber @amber, c-orange bg-orange @orange, c-deeporange bg-deeporange @deeporange, c-gray bg-gray @gray, c-bluegray bg-bluegray @bluegray, c-indigo bg-indigo @indigo;
c-pink bg-pink @pink, c-red bg-red @red, c-blue bg-blue @blue, c-purple bg-purple @purple,
c-deeppurple bg-deeppurple @deeppurple, c-lightblue bg-lightblue @lightblue, c-cyan bg-cyan @cyan,
c-teal bg-teal @teal, c-green bg-green @green, c-lightgreen bg-lightgreen @lightgreen, c-lime bg-lime @lime,
c-yellow bg-yellow @yellow, c-amber bg-amber @amber, c-orange bg-orange @orange,
c-deeporange bg-deeporange @deeporange, c-gray bg-gray @gray, c-bluegray bg-bluegray @bluegray,
c-indigo bg-indigo @indigo;
.for(@array); .for(@array); .-each(@value) {
.-each(@value) {
@name: extract(@value, 1); @name: extract(@value, 1);
@name2: extract(@value, 2); @name2: extract(@value, 2);
@color: extract(@value, 3); @color: extract(@value, 3);
@@ -159,61 +129,36 @@
} }
} }
/* -------------------------------------------------------- /* --------------------------------------------------------
Background Colors Background Colors
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.bg-brand { .bg-brand { background-color: @brand-bg; }
background-color: @brand-bg; .bg-black-trp { background-color: rgba(0,0,0,0.12) !important; }
}
.bg-black-trp {
background-color: rgba(0, 0, 0, 0.12) !important;
}
/* -------------------------------------------------------- /* --------------------------------------------------------
Borders Borders
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.b-0 { .b-0 { border: 0 !important; }
border: 0 !important;
}
/* -------------------------------------------------------- /* --------------------------------------------------------
Width Width
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.w-100 { .w-100 { width: 100% !important; }
width: 100% !important; .w-50 { width: 50% !important; }
} .w-25 { width: 25% !important; }
.w-50 {
width: 50% !important;
}
.w-25 {
width: 25% !important;
}
/* -------------------------------------------------------- /* --------------------------------------------------------
Border Radius Border Radius
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.brd-2 { .brd-2 { border-radius: 2px; }
border-radius: 2px;
}
/* -------------------------------------------------------- /* --------------------------------------------------------
Alignment Alignment
-----------------------------------------------------------*/ -----------------------------------------------------------*/
.va-top { .va-top { vertical-align: top; }
vertical-align: top;
}
/* --------------------------------------------------------
Screen readers
-----------------------------------------------------------*/
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}

View File

@@ -1,9 +1,33 @@
div.table-name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
padding: 2px 22px 2px 10px;
border-radius: @redash-radius;
position: relative;
height: 22px;
.copy-to-editor {
display: none;
}
&:hover {
background: fade(@redash-gray, 10%);
.copy-to-editor {
display: flex;
}
}
}
.schema-container { .schema-container {
height: 100%; height: 100%;
z-index: 10; z-index: 10;
background-color: white; background-color: white;
}
.schema-browser { .schema-browser {
overflow: hidden; overflow: hidden;
border: none; border: none;
padding-top: 10px; padding-top: 10px;
@@ -22,54 +46,25 @@
} }
.copy-to-editor { .copy-to-editor {
visibility: hidden;
color: fade(@redash-gray, 90%); color: fade(@redash-gray, 90%);
cursor: pointer;
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 20px; width: 20px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
transition: none;
}
.schema-list-item {
display: flex;
border-radius: @redash-radius;
height: 22px;
.table-name {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
padding: 2px 22px 2px 10px;
}
&:hover,
&:focus,
&:focus-within {
background: fade(@redash-gray, 10%);
.copy-to-editor {
visibility: visible;
}
}
} }
.table-open { .table-open {
.table-open-item { padding: 0 22px 0 26px;
display: flex;
height: 18px;
width: calc(100% - 22px);
padding-left: 22px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
transition: none; position: relative;
height: 18px;
div:first-child {
flex: 1;
}
.column-type { .column-type {
color: fade(@text-color, 80%); color: fade(@text-color, 80%);
@@ -78,20 +73,21 @@
text-transform: uppercase; text-transform: uppercase;
} }
&:hover, .copy-to-editor {
&:focus, display: none;
&:focus-within { }
&:hover {
background: fade(@redash-gray, 10%); background: fade(@redash-gray, 10%);
.copy-to-editor { .copy-to-editor {
visibility: visible; display: flex;
}
}
} }
} }
} }
}
.schema-control { .schema-control {
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;
padding: 0; padding: 0;
@@ -99,9 +95,8 @@
.ant-btn { .ant-btn {
height: auto; height: auto;
} }
} }
.parameter-label { .parameter-label {
display: block; display: block;
}
} }

View File

@@ -103,7 +103,7 @@
padding-top: 5px !important; padding-top: 5px !important;
} }
.btn-favorite, .btn-favourite,
.btn-archive { .btn-archive {
font-size: 15px; font-size: 15px;
} }
@@ -114,23 +114,18 @@
line-height: 1.7 !important; line-height: 1.7 !important;
} }
.btn-favorite { .btn-favourite {
color: #d4d4d4; color: #d4d4d4;
transition: all 0.25s ease-in-out; transition: all 0.25s ease-in-out;
.fa-star {
color: @yellow-darker;
}
&:hover, &:hover,
&:focus { &:focus {
color: @yellow-darker; color: @yellow-darker;
cursor: pointer; cursor: pointer;
}
.fa-star { .fa-star {
filter: saturate(75%); color: @yellow-darker;
opacity: 0.75;
}
} }
} }

View File

@@ -90,23 +90,6 @@ body.fixed-layout {
.embed__vis { .embed__vis {
display: flex; display: flex;
flex-flow: column; flex-flow: column;
height: calc(~'100vh - 25px');
> .embed-heading {
flex: 0 0 auto;
}
> .query__vis {
flex: 1 1 auto;
.chart-visualization-container, .visualization-renderer-wrapper, .visualization-renderer {
height: 100%
}
}
> .tile__bottom-control {
flex: 0 0 auto;
}
width: 100%; width: 100%;
} }
@@ -144,13 +127,11 @@ body.fixed-layout {
} }
} }
.label-tag { a.label-tag {
background: fade(@redash-gray, 15%); background: fade(@redash-gray, 15%);
color: darken(@redash-gray, 15%); color: darken(@redash-gray, 15%);
&:hover, &:hover {
&:focus,
&:active {
color: darken(@redash-gray, 15%); color: darken(@redash-gray, 15%);
background: fade(@redash-gray, 25%); background: fade(@redash-gray, 25%);
} }
@@ -223,7 +204,6 @@ body.fixed-layout {
} }
.editor__left__schema { .editor__left__schema {
min-height: 120px;
flex-grow: 1; flex-grow: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@@ -1,11 +1,10 @@
import React, { useMemo } from "react"; import { first } from "lodash";
import { first, includes } from "lodash"; import React, { useState } from "react";
import Button from "antd/lib/button";
import Menu from "antd/lib/menu"; import Menu from "antd/lib/menu";
import Link from "@/components/Link"; import Link from "@/components/Link";
import PlainButton from "@/components/PlainButton";
import HelpTrigger from "@/components/HelpTrigger"; import HelpTrigger from "@/components/HelpTrigger";
import CreateDashboardDialog from "@/components/dashboards/CreateDashboardDialog"; import CreateDashboardDialog from "@/components/dashboards/CreateDashboardDialog";
import { useCurrentRoute } from "@/components/ApplicationArea/Router";
import { Auth, currentUser } from "@/services/auth"; import { Auth, currentUser } from "@/services/auth";
import settingsMenu from "@/services/settingsMenu"; import settingsMenu from "@/services/settingsMenu";
import logoUrl from "@/assets/images/redash_icon_small.png"; import logoUrl from "@/assets/images/redash_icon_small.png";
@@ -16,109 +15,83 @@ import AlertOutlinedIcon from "@ant-design/icons/AlertOutlined";
import PlusOutlinedIcon from "@ant-design/icons/PlusOutlined"; import PlusOutlinedIcon from "@ant-design/icons/PlusOutlined";
import QuestionCircleOutlinedIcon from "@ant-design/icons/QuestionCircleOutlined"; import QuestionCircleOutlinedIcon from "@ant-design/icons/QuestionCircleOutlined";
import SettingOutlinedIcon from "@ant-design/icons/SettingOutlined"; import SettingOutlinedIcon from "@ant-design/icons/SettingOutlined";
import VersionInfo from "./VersionInfo"; import MenuUnfoldOutlinedIcon from "@ant-design/icons/MenuUnfoldOutlined";
import MenuFoldOutlinedIcon from "@ant-design/icons/MenuFoldOutlined";
import VersionInfo from "./VersionInfo";
import "./DesktopNavbar.less"; import "./DesktopNavbar.less";
function NavbarSection({ children, ...props }) { function NavbarSection({ inlineCollapsed, children, ...props }) {
return ( return (
<Menu selectable={false} mode="vertical" theme="dark" {...props}> <Menu
selectable={false}
mode={inlineCollapsed ? "inline" : "vertical"}
inlineCollapsed={inlineCollapsed}
theme="dark"
{...props}>
{children} {children}
</Menu> </Menu>
); );
} }
function useNavbarActiveState() {
const currentRoute = useCurrentRoute();
return useMemo(
() => ({
dashboards: includes(
[
"Dashboards.List",
"Dashboards.Favorites",
"Dashboards.My",
"Dashboards.ViewOrEdit",
"Dashboards.LegacyViewOrEdit",
],
currentRoute.id
),
queries: includes(
[
"Queries.List",
"Queries.Favorites",
"Queries.Archived",
"Queries.My",
"Queries.View",
"Queries.New",
"Queries.Edit",
],
currentRoute.id
),
dataSources: includes(["DataSources.List"], currentRoute.id),
alerts: includes(["Alerts.List", "Alerts.New", "Alerts.View", "Alerts.Edit"], currentRoute.id),
}),
[currentRoute.id]
);
}
export default function DesktopNavbar() { export default function DesktopNavbar() {
const firstSettingsTab = first(settingsMenu.getAvailableItems()); const [collapsed, setCollapsed] = useState(true);
const activeState = useNavbarActiveState(); const firstSettingsTab = first(settingsMenu.getAvailableItems());
const canCreateQuery = currentUser.hasPermission("create_query"); const canCreateQuery = currentUser.hasPermission("create_query");
const canCreateDashboard = currentUser.hasPermission("create_dashboard"); const canCreateDashboard = currentUser.hasPermission("create_dashboard");
const canCreateAlert = currentUser.hasPermission("list_alerts"); const canCreateAlert = currentUser.hasPermission("list_alerts");
return ( return (
<nav className="desktop-navbar"> <div className="desktop-navbar">
<NavbarSection className="desktop-navbar-logo"> <NavbarSection inlineCollapsed={collapsed} className="desktop-navbar-logo">
<div role="menuitem"> <div>
<Link href="./"> <Link href="./">
<img src={logoUrl} alt="Redash" /> <img src={logoUrl} alt="Redash" />
</Link> </Link>
</div> </div>
</NavbarSection> </NavbarSection>
<NavbarSection> <NavbarSection inlineCollapsed={collapsed}>
{currentUser.hasPermission("list_dashboards") && ( {currentUser.hasPermission("list_dashboards") && (
<Menu.Item key="dashboards" className={activeState.dashboards ? "navbar-active-item" : null}> <Menu.Item key="dashboards">
<Link href="dashboards"> <Link href="dashboards">
<DesktopOutlinedIcon aria-label="Dashboard navigation button" /> <DesktopOutlinedIcon />
<span className="desktop-navbar-label">Dashboards</span> <span>Dashboards</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
)} )}
{currentUser.hasPermission("view_query") && ( {currentUser.hasPermission("view_query") && (
<Menu.Item key="queries" className={activeState.queries ? "navbar-active-item" : null}> <Menu.Item key="queries">
<Link href="queries"> <Link href="queries">
<CodeOutlinedIcon aria-label="Queries navigation button" /> <CodeOutlinedIcon />
<span className="desktop-navbar-label">Queries</span> <span>Queries</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
)} )}
{currentUser.hasPermission("list_alerts") && ( {currentUser.hasPermission("list_alerts") && (
<Menu.Item key="alerts" className={activeState.alerts ? "navbar-active-item" : null}> <Menu.Item key="alerts">
<Link href="alerts"> <Link href="alerts">
<AlertOutlinedIcon aria-label="Alerts navigation button" /> <AlertOutlinedIcon />
<span className="desktop-navbar-label">Alerts</span> <span>Alerts</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
)} )}
</NavbarSection> </NavbarSection>
<NavbarSection className="desktop-navbar-spacer"> <NavbarSection inlineCollapsed={collapsed} className="desktop-navbar-spacer">
{(canCreateQuery || canCreateDashboard || canCreateAlert) && <Menu.Divider />}
{(canCreateQuery || canCreateDashboard || canCreateAlert) && ( {(canCreateQuery || canCreateDashboard || canCreateAlert) && (
<Menu.SubMenu <Menu.SubMenu
key="create" key="create"
popupClassName="desktop-navbar-submenu" popupClassName="desktop-navbar-submenu"
data-test="CreateButton"
tabIndex={0}
title={ title={
<React.Fragment> <React.Fragment>
<span data-test="CreateButton">
<PlusOutlinedIcon /> <PlusOutlinedIcon />
<span className="desktop-navbar-label">Create</span> <span>Create</span>
</span>
</React.Fragment> </React.Fragment>
}> }>
{canCreateQuery && ( {canCreateQuery && (
@@ -130,9 +103,9 @@ export default function DesktopNavbar() {
)} )}
{canCreateDashboard && ( {canCreateDashboard && (
<Menu.Item key="new-dashboard"> <Menu.Item key="new-dashboard">
<PlainButton data-test="CreateDashboardMenuItem" onClick={() => CreateDashboardDialog.showModal()}> <a data-test="CreateDashboardMenuItem" onMouseUp={() => CreateDashboardDialog.showModal()}>
New Dashboard New Dashboard
</PlainButton> </a>
</Menu.Item> </Menu.Item>
)} )}
{canCreateAlert && ( {canCreateAlert && (
@@ -146,31 +119,32 @@ export default function DesktopNavbar() {
)} )}
</NavbarSection> </NavbarSection>
<NavbarSection> <NavbarSection inlineCollapsed={collapsed}>
<Menu.Item key="help"> <Menu.Item key="help">
<HelpTrigger showTooltip={false} type="HOME" tabIndex={0}> <HelpTrigger showTooltip={false} type="HOME">
<QuestionCircleOutlinedIcon /> <QuestionCircleOutlinedIcon />
<span className="desktop-navbar-label">Help</span> <span>Help</span>
</HelpTrigger> </HelpTrigger>
</Menu.Item> </Menu.Item>
{firstSettingsTab && ( {firstSettingsTab && (
<Menu.Item key="settings" className={activeState.dataSources ? "navbar-active-item" : null}> <Menu.Item key="settings">
<Link href={firstSettingsTab.path} data-test="SettingsLink"> <Link href={firstSettingsTab.path} data-test="SettingsLink">
<SettingOutlinedIcon /> <SettingOutlinedIcon />
<span className="desktop-navbar-label">Settings</span> <span>Settings</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
)} )}
<Menu.Divider />
</NavbarSection> </NavbarSection>
<NavbarSection className="desktop-navbar-profile-menu"> <NavbarSection inlineCollapsed={collapsed} className="desktop-navbar-profile-menu">
<Menu.SubMenu <Menu.SubMenu
key="profile" key="profile"
popupClassName="desktop-navbar-submenu" popupClassName="desktop-navbar-submenu"
tabIndex={0}
title={ title={
<span data-test="ProfileDropdown" className="desktop-navbar-profile-menu-title"> <span data-test="ProfileDropdown" className="desktop-navbar-profile-menu-title">
<img className="profile__image_thumb" src={currentUser.profile_image_url} alt={currentUser.name} /> <img className="profile__image_thumb" src={currentUser.profile_image_url} alt={currentUser.name} />
<span>{currentUser.name}</span>
</span> </span>
}> }>
<Menu.Item key="profile"> <Menu.Item key="profile">
@@ -183,16 +157,20 @@ export default function DesktopNavbar() {
)} )}
<Menu.Divider /> <Menu.Divider />
<Menu.Item key="logout"> <Menu.Item key="logout">
<PlainButton data-test="LogOutButton" onClick={() => Auth.logout()}> <a data-test="LogOutButton" onClick={() => Auth.logout()}>
Log out Log out
</PlainButton> </a>
</Menu.Item> </Menu.Item>
<Menu.Divider /> <Menu.Divider />
<Menu.Item key="version" role="presentation" disabled className="version-info"> <Menu.Item key="version" disabled className="version-info">
<VersionInfo /> <VersionInfo />
</Menu.Item> </Menu.Item>
</Menu.SubMenu> </Menu.SubMenu>
</NavbarSection> </NavbarSection>
</nav>
<Button onClick={() => setCollapsed(!collapsed)} className="desktop-navbar-collapse-button">
{collapsed ? <MenuUnfoldOutlinedIcon /> : <MenuFoldOutlinedIcon />}
</Button>
</div>
); );
} }

View File

@@ -1,17 +1,12 @@
@backgroundColor: #001529; @backgroundColor: #001529;
@dividerColor: rgba(255, 255, 255, 0.5); @dividerColor: rgba(255, 255, 255, 0.5);
@textColor: rgba(255, 255, 255, 0.75); @textColor: rgba(255, 255, 255, 0.75);
@brandColor: #ff7964; // Redash logo color
@activeItemColor: @brandColor;
@iconSize: 26px;
.desktop-navbar { .desktop-navbar {
background: @backgroundColor; background: @backgroundColor;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
width: 80px;
overflow: hidden;
&-spacer { &-spacer {
flex: 1 1 auto; flex: 1 1 auto;
@@ -26,6 +21,12 @@
height: 40px; height: 40px;
transition: all 270ms; transition: all 270ms;
} }
&.ant-menu-inline-collapsed {
img {
height: 20px;
}
}
} }
.help-trigger { .help-trigger {
@@ -33,38 +34,33 @@
} }
.ant-menu { .ant-menu {
&:not(.ant-menu-inline-collapsed) {
width: 170px;
}
&.ant-menu-inline-collapsed > .ant-menu-submenu-title span img + span,
&.ant-menu-inline-collapsed > .ant-menu-item i + span {
display: inline-block;
max-width: 0;
opacity: 0;
}
.ant-menu-item-divider {
background: @dividerColor;
}
.ant-menu-item, .ant-menu-item,
.ant-menu-submenu { .ant-menu-submenu {
font-weight: 500; font-weight: 500;
color: @textColor; color: @textColor;
&.navbar-active-item {
box-shadow: inset 3px 0 0 @activeItemColor;
.anticon {
color: @activeItemColor;
}
}
&.ant-menu-submenu-open, &.ant-menu-submenu-open,
&.ant-menu-submenu-active, &.ant-menu-submenu-active,
&:hover, &:hover,
&:active, &:active {
&:focus,
&:focus-within {
color: #fff; color: #fff;
} }
.anticon {
font-size: @iconSize;
margin: 0;
}
.desktop-navbar-label {
margin-top: 4px;
font-size: 11px;
}
a, a,
span, span,
.anticon { .anticon {
@@ -75,33 +71,21 @@
.ant-menu-submenu-arrow { .ant-menu-submenu-arrow {
display: none; display: none;
} }
.ant-menu-item,
.ant-menu-submenu {
padding: 0;
height: 60px;
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
} }
.ant-menu-submenu-title { .ant-btn.desktop-navbar-collapse-button {
width: 100%; background-color: @backgroundColor;
padding: 0; border: 0;
border-radius: 0;
color: @textColor;
&:hover,
&:active {
color: #fff;
} }
a, &:after {
&.ant-menu-vertical > .ant-menu-submenu > .ant-menu-submenu-title, animation: 0s !important;
.ant-menu-submenu-title {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
line-height: normal;
height: auto;
background: none;
color: inherit;
} }
} }
@@ -115,8 +99,37 @@
.profile__image_thumb { .profile__image_thumb {
margin: 0; margin: 0;
vertical-align: middle; vertical-align: middle;
width: @iconSize; }
height: @iconSize;
.profile__image_thumb + span {
flex: 1 1 auto;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin-left: 10px;
vertical-align: middle;
display: inline-block;
// styles from Antd
opacity: 1;
transition: opacity 0.3s cubic-bezier(0.645, 0.045, 0.355, 1),
margin-left 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), width 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}
}
&.ant-menu-inline-collapsed {
.ant-menu-submenu-title {
padding-left: 16px !important;
padding-right: 16px !important;
}
.desktop-navbar-profile-menu-title {
.profile__image_thumb + span {
opacity: 0;
max-width: 0;
margin-left: 0;
}
} }
} }
} }
@@ -133,9 +146,7 @@
color: @textColor; color: @textColor;
&:hover, &:hover,
&:active, &:active {
&:focus,
&:focus-within {
color: #fff; color: #fff;
} }
@@ -160,9 +171,7 @@
color: rgba(255, 255, 255, 0.8); color: rgba(255, 255, 255, 0.8);
&:hover, &:hover,
&:active, &:active {
&:focus,
&:focus-within {
color: rgba(255, 255, 255, 1); color: rgba(255, 255, 255, 1);
} }
} }

View File

@@ -14,8 +14,8 @@ export default function VersionInfo() {
<div className="m-t-10"> <div className="m-t-10">
{/* eslint-disable react/jsx-no-target-blank */} {/* eslint-disable react/jsx-no-target-blank */}
<Link href="https://version.redash.io/" className="update-available" target="_blank" rel="noopener"> <Link href="https://version.redash.io/" className="update-available" target="_blank" rel="noopener">
Update Available <i className="fa fa-external-link m-l-5" aria-hidden="true" /> Update Available
<span className="sr-only">(opens in a new tab)</span> <i className="fa fa-external-link m-l-5" />
</Link> </Link>
</div> </div>
)} )}

View File

@@ -49,7 +49,7 @@ export default function ErrorMessage({ error, message }) {
<div className="error-message-container" data-test="ErrorMessage" role="alert"> <div className="error-message-container" data-test="ErrorMessage" role="alert">
<div className="error-state bg-white tiled"> <div className="error-state bg-white tiled">
<div className="error-state__icon"> <div className="error-state__icon">
<i className="zmdi zmdi-alert-circle-o" aria-hidden="true" /> <i className="zmdi zmdi-alert-circle-o" />
</div> </div>
<div className="error-state__details"> <div className="error-state__details">
<DynamicComponent <DynamicComponent

View File

@@ -17,13 +17,6 @@ export default function ApplicationArea() {
useEffect(() => { useEffect(() => {
function globalErrorHandler(event) { function globalErrorHandler(event) {
event.preventDefault(); event.preventDefault();
if (event.message === "Uncaught SyntaxError: Unexpected token '<'") {
// if we see a javascript error on unexpected token where the unexpected token is '<', this usually means that a fallback html file (like index.html)
// was served as content of script rather than the expected script, give a friendlier message in the console on what could be going on
console.error(
`[Uncaught SyntaxError: Unexpected token '<'] usually means that a fallback html file was returned from server rather than the expected script. Check that the server is properly serving the file ${event.filename}.`
);
}
setUnhandledError(event.error); setUnhandledError(event.error);
} }

View File

@@ -1,4 +1,5 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
// @ts-expect-error (Must be removed after adding @redash/viz typing)
import ErrorBoundary, { ErrorBoundaryContext } from "@redash/viz/lib/components/ErrorBoundary"; import ErrorBoundary, { ErrorBoundaryContext } from "@redash/viz/lib/components/ErrorBoundary";
import { Auth } from "@/services/auth"; import { Auth } from "@/services/auth";
import { policy } from "@/services/policy"; import { policy } from "@/services/policy";
@@ -61,14 +62,11 @@ export function UserSessionWrapper<P>({ bodyClass, currentRoute, render }: UserS
return ( return (
<ApplicationLayout> <ApplicationLayout>
<React.Fragment key={currentRoute.key}> <React.Fragment key={currentRoute.key}>
{/* @ts-expect-error FIXME */}
<ErrorBoundary renderError={(error: Error) => <ErrorMessage error={error} />}> <ErrorBoundary renderError={(error: Error) => <ErrorMessage error={error} />}>
<ErrorBoundaryContext.Consumer> <ErrorBoundaryContext.Consumer>
{( {({ handleError }: { handleError: UserSessionWrapperRenderChildrenProps<P>["onError"] }) =>
{ render({ ...currentRoute.routeParams, pageTitle: currentRoute.title, onError: handleError })
handleError, }
} /* : { handleError: UserSessionWrapperRenderChildrenProps<P>["onError"] } FIXME bring back type */
) => render({ ...currentRoute.routeParams, pageTitle: currentRoute.title, onError: handleError })}
</ErrorBoundaryContext.Consumer> </ErrorBoundaryContext.Consumer>
</ErrorBoundary> </ErrorBoundary>
</React.Fragment> </React.Fragment>

View File

@@ -22,7 +22,7 @@ function BeaconConsent() {
setHide(true); setHide(true);
}; };
const confirmConsent = (confirm) => { const confirmConsent = confirm => {
let message = "🙏 Thank you."; let message = "🙏 Thank you.";
if (!confirm) { if (!confirm) {
@@ -47,8 +47,7 @@ function BeaconConsent() {
<HelpTrigger type="USAGE_DATA_SHARING" /> <HelpTrigger type="USAGE_DATA_SHARING" />
</> </>
} }
bordered={false} bordered={false}>
>
<Text>Help Redash improve by automatically sending anonymous usage data:</Text> <Text>Help Redash improve by automatically sending anonymous usage data:</Text>
<div className="m-t-5"> <div className="m-t-5">
<ul> <ul>
@@ -67,7 +66,8 @@ function BeaconConsent() {
</div> </div>
<div className="m-t-15"> <div className="m-t-15">
<Text type="secondary"> <Text type="secondary">
You can change this setting anytime from the <Link href="settings/general">Settings</Link> page. You can change this setting anytime from the{" "}
<Link href="settings/organization">Organization Settings</Link> page.
</Text> </Text>
</div> </div>
</Card> </Card>

View File

@@ -1,21 +1,14 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { useUniqueId } from "@/lib/hooks/useUniqueId";
import cx from "classnames";
function BigMessage({ message, icon, children, className }) { function BigMessage({ message, icon, children, className }) {
const messageId = useUniqueId("bm-message");
return ( return (
<div <div className={"p-15 text-center " + className}>
className={"big-message p-15 text-center " + className} <h3 className="m-t-0 m-b-0">
role="status" <i className={"fa " + icon} />
aria-live="assertive"
aria-relevant="additions removals">
<h3 className="m-t-0 m-b-0" aria-labelledby={messageId}>
<i className={cx("fa", icon)} aria-hidden="true" />
</h3> </h3>
<br /> <br />
<span id={messageId}>{message}</span> {message}
{children} {children}
</div> </div>
); );

View File

@@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import Button from "antd/lib/button"; import Button from "antd/lib/button";
import Tooltip from "@/components/Tooltip"; import Tooltip from "antd/lib/tooltip";
import CopyOutlinedIcon from "@ant-design/icons/CopyOutlined"; import CopyOutlinedIcon from "@ant-design/icons/CopyOutlined";
import "./CodeBlock.less"; import "./CodeBlock.less";

View File

@@ -1,4 +1,4 @@
@import (reference, less) "~@/assets/less/ant"; @import '~antd/lib/button/style/index';
.code-block { .code-block {
background: rgba(0, 0, 0, 0.06); background: rgba(0, 0, 0, 0.06);

View File

@@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { isEmpty, toUpper, includes, get, uniqueId } from "lodash"; import { isEmpty, toUpper, includes, get } from "lodash";
import Button from "antd/lib/button"; import Button from "antd/lib/button";
import List from "antd/lib/list"; import List from "antd/lib/list";
import Modal from "antd/lib/modal"; import Modal from "antd/lib/modal";
@@ -45,8 +45,6 @@ class CreateSourceDialog extends React.Component {
currentStep: StepEnum.SELECT_TYPE, currentStep: StepEnum.SELECT_TYPE,
}; };
formId = uniqueId("sourceForm");
selectType = selectedType => { selectType = selectedType => {
this.setState({ selectedType, currentStep: StepEnum.CONFIGURE_IT }); this.setState({ selectedType, currentStep: StepEnum.CONFIGURE_IT });
}; };
@@ -84,7 +82,6 @@ class CreateSourceDialog extends React.Component {
<div className="m-t-10"> <div className="m-t-10">
<Search <Search
placeholder="Search..." placeholder="Search..."
aria-label="Search"
onChange={e => this.setState({ searchText: e.target.value })} onChange={e => this.setState({ searchText: e.target.value })}
autoFocus autoFocus
data-test="SearchSource" data-test="SearchSource"
@@ -114,12 +111,11 @@ class CreateSourceDialog extends React.Component {
<div className="text-right"> <div className="text-right">
{HELP_TRIGGER_TYPES[helpTriggerType] && ( {HELP_TRIGGER_TYPES[helpTriggerType] && (
<HelpTrigger className="f-13" type={helpTriggerType}> <HelpTrigger className="f-13" type={helpTriggerType}>
Setup Instructions <i className="fa fa-question-circle" aria-hidden="true" /> Setup Instructions <i className="fa fa-question-circle" />
<span className="sr-only">(help)</span>
</HelpTrigger> </HelpTrigger>
)} )}
</div> </div>
<DynamicForm id={this.formId} fields={fields} onSubmit={this.createSource} feedbackIcons hideSubmitButton /> <DynamicForm id="sourceForm" fields={fields} onSubmit={this.createSource} feedbackIcons hideSubmitButton />
{selectedType.type === "databricks" && ( {selectedType.type === "databricks" && (
<small> <small>
By using the Databricks Data Source you agree to the Databricks JDBC/ODBC{" "} By using the Databricks Data Source you agree to the Databricks JDBC/ODBC{" "}
@@ -143,7 +139,7 @@ class CreateSourceDialog extends React.Component {
roundedImage={false} roundedImage={false}
data-test="PreviewItem" data-test="PreviewItem"
data-test-type={item.type}> data-test-type={item.type}>
<i className="fa fa-angle-double-right" aria-hidden="true" /> <i className="fa fa-angle-double-right" />
</PreviewCard> </PreviewCard>
</List.Item> </List.Item>
); );
@@ -173,7 +169,7 @@ class CreateSourceDialog extends React.Component {
<Button <Button
key="submit" key="submit"
htmlType="submit" htmlType="submit"
form={this.formId} form="sourceForm"
type="primary" type="primary"
loading={savingSource} loading={savingSource}
data-test="CreateSourceSaveButton"> data-test="CreateSourceSaveButton">

View File

@@ -86,7 +86,6 @@ export default class EditInPlace extends React.Component {
return ( return (
<InputComponent <InputComponent
defaultValue={value} defaultValue={value}
aria-label="Editing"
onBlur={e => this.stopEditing(e.target.value)} onBlur={e => this.stopEditing(e.target.value)}
onKeyDown={this.handleKeyDown} onKeyDown={this.handleKeyDown}
autoFocus autoFocus

View File

@@ -1,3 +0,0 @@
.input-error {
border-color: red !important;
}

View File

@@ -1,5 +1,5 @@
import { includes, words, capitalize, clone, isNull } from "lodash"; import { includes, words, capitalize, clone, isNull, map, get, find } from "lodash";
import React, { useState, useEffect } from "react"; import React, { useState, useEffect, useRef, useMemo } from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import Checkbox from "antd/lib/checkbox"; import Checkbox from "antd/lib/checkbox";
import Modal from "antd/lib/modal"; import Modal from "antd/lib/modal";
@@ -11,8 +11,8 @@ import Divider from "antd/lib/divider";
import { wrap as wrapDialog, DialogPropType } from "@/components/DialogWrapper"; import { wrap as wrapDialog, DialogPropType } from "@/components/DialogWrapper";
import QuerySelector from "@/components/QuerySelector"; import QuerySelector from "@/components/QuerySelector";
import { Query } from "@/services/query"; import { Query } from "@/services/query";
import { useUniqueId } from "@/lib/hooks/useUniqueId"; import { QueryBasedParameterMappingType } from "@/services/parameters/QueryBasedDropdownParameter";
import "./EditParameterSettingsDialog.less"; import QueryBasedParameterMappingTable from "./query-based-parameter/QueryBasedParameterMappingTable";
const { Option } = Select; const { Option } = Select;
const formItemProps = { labelCol: { span: 6 }, wrapperCol: { span: 16 } }; const formItemProps = { labelCol: { span: 6 }, wrapperCol: { span: 16 } };
@@ -27,7 +27,7 @@ function isTypeDateRange(type) {
function joinExampleList(multiValuesOptions) { function joinExampleList(multiValuesOptions) {
const { prefix, suffix } = 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 }) { function NameInput({ name, type, onChange, existingNames, setValidation }) {
@@ -55,7 +55,7 @@ function NameInput({ name, type, onChange, existingNames, setValidation }) {
return ( return (
<Form.Item required label="Keyword" help={helpText} validateStatus={validateStatus} {...formItemProps}> <Form.Item required label="Keyword" help={helpText} validateStatus={validateStatus} {...formItemProps}>
<Input onChange={(e) => onChange(e.target.value)} autoFocus /> <Input onChange={e => onChange(e.target.value)} autoFocus />
</Form.Item> </Form.Item>
); );
} }
@@ -71,19 +71,27 @@ NameInput.propTypes = {
function EditParameterSettingsDialog(props) { function EditParameterSettingsDialog(props) {
const [param, setParam] = useState(clone(props.parameter)); const [param, setParam] = useState(clone(props.parameter));
const [isNameValid, setIsNameValid] = useState(true); const [isNameValid, setIsNameValid] = useState(true);
const [initialQuery, setInitialQuery] = useState(); const [paramQuery, setParamQuery] = useState();
const [userInput, setUserInput] = useState(param.regex || ""); const mappingParameters = useMemo(
const [isValidRegex, setIsValidRegex] = useState(true); () =>
map(paramQuery && paramQuery.getParametersDefs(), mappingParam => ({
mappingParam,
existingMapping: get(param.parameterMapping, mappingParam.name, {
mappingType: QueryBasedParameterMappingType.UNDEFINED,
}),
})),
[param.parameterMapping, paramQuery]
);
const isNew = !props.parameter.name; const isNew = !props.parameter.name;
// fetch query by id // fetch query by id
const initialQueryId = useRef(props.parameter.queryId);
useEffect(() => { useEffect(() => {
const queryId = props.parameter.queryId; if (initialQueryId.current) {
if (queryId) { Query.get({ id: initialQueryId.current }).then(setParamQuery);
Query.get({ id: queryId }).then(setInitialQuery);
} }
}, [props.parameter.queryId]); }, []);
function isFulfilled() { function isFulfilled() {
// name // name
@@ -97,10 +105,16 @@ function EditParameterSettingsDialog(props) {
} }
// query // query
if (param.type === "query" && !param.queryId) { if (param.type === "query") {
if (!param.queryId) {
return false; return false;
} }
if (find(mappingParameters, { existingMapping: { mappingType: QueryBasedParameterMappingType.UNDEFINED } })) {
return false;
}
}
return true; return true;
} }
@@ -115,19 +129,6 @@ function EditParameterSettingsDialog(props) {
props.dialog.close(param); props.dialog.close(param);
} }
const paramFormId = useUniqueId("paramForm");
const handleRegexChange = (e) => {
setUserInput(e.target.value);
try {
new RegExp(e.target.value);
setParam({ ...param, regex: e.target.value });
setIsValidRegex(true);
} catch (error) {
setIsValidRegex(false);
}
};
return ( return (
<Modal <Modal
{...props.dialog.props} {...props.dialog.props}
@@ -142,18 +143,16 @@ function EditParameterSettingsDialog(props) {
htmlType="submit" htmlType="submit"
disabled={!isFulfilled()} disabled={!isFulfilled()}
type="primary" type="primary"
form={paramFormId} form="paramForm"
data-test="SaveParameterSettings" data-test="SaveParameterSettings">
>
{isNew ? "Add Parameter" : "OK"} {isNew ? "Add Parameter" : "OK"}
</Button>, </Button>,
]} ]}>
> <Form layout="horizontal" onFinish={onConfirm} id="paramForm">
<Form layout="horizontal" onFinish={onConfirm} id={paramFormId}>
{isNew && ( {isNew && (
<NameInput <NameInput
name={param.name} name={param.name}
onChange={(name) => setParam({ ...param, name })} onChange={name => setParam({ ...param, name })}
setValidation={setIsNameValid} setValidation={setIsNameValid}
existingNames={props.existingParams} existingNames={props.existingParams}
type={param.type} type={param.type}
@@ -162,16 +161,15 @@ function EditParameterSettingsDialog(props) {
<Form.Item required label="Title" {...formItemProps}> <Form.Item required label="Title" {...formItemProps}>
<Input <Input
value={isNull(param.title) ? getDefaultTitle(param.name) : param.title} value={isNull(param.title) ? getDefaultTitle(param.name) : param.title}
onChange={(e) => setParam({ ...param, title: e.target.value })} onChange={e => setParam({ ...param, title: e.target.value })}
data-test="ParameterTitleInput" data-test="ParameterTitleInput"
/> />
</Form.Item> </Form.Item>
<Form.Item label="Type" {...formItemProps}> <Form.Item label="Type" {...formItemProps}>
<Select value={param.type} onChange={(type) => setParam({ ...param, type })} data-test="ParameterTypeSelect"> <Select value={param.type} onChange={type => setParam({ ...param, type })} data-test="ParameterTypeSelect">
<Option value="text" data-test="TextParameterTypeOption"> <Option value="text" data-test="TextParameterTypeOption">
Text Text
</Option> </Option>
<Option value="text-pattern">Text Pattern</Option>
<Option value="number" data-test="NumberParameterTypeOption"> <Option value="number" data-test="NumberParameterTypeOption">
Number Number
</Option> </Option>
@@ -197,43 +195,43 @@ function EditParameterSettingsDialog(props) {
<Option value="datetime-range-with-seconds">Date and Time Range (with seconds)</Option> <Option value="datetime-range-with-seconds">Date and Time Range (with seconds)</Option>
</Select> </Select>
</Form.Item> </Form.Item>
{param.type === "text-pattern" && (
<Form.Item
label="Regex"
help={!isValidRegex ? "Invalid Regex Pattern" : "Valid Regex Pattern"}
{...formItemProps}
>
<Input
value={userInput}
onChange={handleRegexChange}
className={!isValidRegex ? "input-error" : ""}
data-test="RegexPatternInput"
/>
</Form.Item>
)}
{param.type === "enum" && ( {param.type === "enum" && (
<Form.Item label="Values" help="Dropdown list values (newline delimited)" {...formItemProps}> <Form.Item label="Values" help="Dropdown list values (newline delimited)" {...formItemProps}>
<Input.TextArea <Input.TextArea
rows={3} rows={3}
value={param.enumOptions} value={param.enumOptions}
onChange={(e) => setParam({ ...param, enumOptions: e.target.value })} onChange={e => setParam({ ...param, enumOptions: e.target.value })}
/> />
</Form.Item> </Form.Item>
)} )}
{param.type === "query" && ( {param.type === "query" && (
<Form.Item label="Query" help="Select query to load dropdown values from" {...formItemProps}> <Form.Item label="Query" help="Select query to load dropdown values from" required {...formItemProps}>
<QuerySelector <QuerySelector
selectedQuery={initialQuery} selectedQuery={paramQuery}
onChange={(q) => setParam({ ...param, queryId: q && q.id })} onChange={q => {
if (q) {
setParamQuery(q);
setParam({ ...param, queryId: q.id, parameterMapping: {} });
}
}}
type="select" type="select"
/> />
</Form.Item> </Form.Item>
)} )}
{param.type === "query" && paramQuery && paramQuery.hasParameters() && (
<Form.Item className="m-t-15 m-b-5" label="Parameters" required {...formItemProps}>
<QueryBasedParameterMappingTable
param={param}
mappingParameters={mappingParameters}
onChangeParam={setParam}
/>
</Form.Item>
)}
{(param.type === "enum" || param.type === "query") && ( {(param.type === "enum" || param.type === "query") && (
<Form.Item className="m-b-0" label=" " colon={false} {...formItemProps}> <Form.Item className="m-b-0" label=" " colon={false} {...formItemProps}>
<Checkbox <Checkbox
defaultChecked={!!param.multiValuesOptions} defaultChecked={!!param.multiValuesOptions}
onChange={(e) => onChange={e =>
setParam({ setParam({
...param, ...param,
multiValuesOptions: e.target.checked multiValuesOptions: e.target.checked
@@ -245,8 +243,7 @@ function EditParameterSettingsDialog(props) {
: null, : null,
}) })
} }
data-test="AllowMultipleValuesCheckbox" data-test="AllowMultipleValuesCheckbox">
>
Allow multiple values Allow multiple values
</Checkbox> </Checkbox>
</Form.Item> </Form.Item>
@@ -259,11 +256,10 @@ function EditParameterSettingsDialog(props) {
Placed in query as: <code>{joinExampleList(param.multiValuesOptions)}</code> Placed in query as: <code>{joinExampleList(param.multiValuesOptions)}</code>
</React.Fragment> </React.Fragment>
} }
{...formItemProps} {...formItemProps}>
>
<Select <Select
value={param.multiValuesOptions.prefix} value={param.multiValuesOptions.prefix}
onChange={(quoteOption) => onChange={quoteOption =>
setParam({ setParam({
...param, ...param,
multiValuesOptions: { multiValuesOptions: {
@@ -273,8 +269,7 @@ function EditParameterSettingsDialog(props) {
}, },
}) })
} }
data-test="QuotationSelect" data-test="QuotationSelect">
>
<Option value="">None (default)</Option> <Option value="">None (default)</Option>
<Option value="'">Single Quotation Mark</Option> <Option value="'">Single Quotation Mark</Option>
<Option value={'"'} data-test="DoubleQuotationMarkOption"> <Option value={'"'} data-test="DoubleQuotationMarkOption">

View File

@@ -0,0 +1,134 @@
import React, { useState, useEffect, useRef, useReducer } from "react";
import PropTypes from "prop-types";
import { values } from "lodash";
import Button from "antd/lib/button";
import Tooltip from "antd/lib/tooltip";
import Radio from "antd/lib/radio";
import Typography from "antd/lib/typography/Typography";
import ParameterValueInput from "@/components/ParameterValueInput";
import InputPopover from "@/components/InputPopover";
import Form from "antd/lib/form";
import { QueryBasedParameterMappingType } from "@/services/parameters/QueryBasedDropdownParameter";
import QuestionCircleFilledIcon from "@ant-design/icons/QuestionCircleFilled";
import EditOutlinedIcon from "@ant-design/icons/EditOutlined";
const { Text } = Typography;
const formItemProps = { labelCol: { span: 6 }, wrapperCol: { span: 16 } };
export default function QueryBasedParameterMappingEditor({ parameter, mapping, searchAvailable, onChange }) {
const [showPopover, setShowPopover] = useState(false);
const [newMapping, setNewMapping] = useReducer((prevState, updates) => ({ ...prevState, ...updates }), mapping);
const newMappingRef = useRef(newMapping);
useEffect(() => {
if (
mapping.mappingType !== newMappingRef.current.mappingType ||
mapping.staticValue !== newMappingRef.current.staticValue
) {
setNewMapping(mapping);
}
}, [mapping]);
const parameterRef = useRef(parameter);
useEffect(() => {
parameterRef.current.setValue(mapping.staticValue);
}, [mapping.staticValue]);
const onCancel = () => {
setNewMapping(mapping);
setShowPopover(false);
};
const onOk = () => {
onChange(newMapping);
setShowPopover(false);
};
let currentState = <Text type="secondary">Pick a type</Text>;
if (mapping.mappingType === QueryBasedParameterMappingType.DROPDOWN_SEARCH) {
currentState = "Dropdown Search";
} else if (mapping.mappingType === QueryBasedParameterMappingType.STATIC) {
currentState = `Value: ${mapping.staticValue}`;
}
return (
<>
{currentState}
<InputPopover
placement="left"
trigger="click"
header="Edit Parameter Source"
okButtonProps={{
disabled: newMapping.mappingType === QueryBasedParameterMappingType.STATIC && parameter.isEmpty,
}}
onOk={onOk}
onCancel={onCancel}
content={
<Form>
<Form.Item className="m-b-15" label="Source" {...formItemProps}>
<Radio.Group
value={newMapping.mappingType}
onChange={({ target }) => setNewMapping({ mappingType: target.value })}>
<Radio
className="radio"
value={QueryBasedParameterMappingType.DROPDOWN_SEARCH}
disabled={!searchAvailable || parameter.type !== "text"}>
Dropdown Search{" "}
{(!searchAvailable || parameter.type !== "text") && (
<Tooltip
title={
parameter.type !== "text"
? "Dropdown Search is only available for Text Parameters"
: "There is already a parameter mapped with the Dropdown Search type."
}>
<QuestionCircleFilledIcon />
</Tooltip>
)}
</Radio>
<Radio className="radio" value={QueryBasedParameterMappingType.STATIC}>
Static Value
</Radio>
</Radio.Group>
</Form.Item>
{newMapping.mappingType === QueryBasedParameterMappingType.STATIC && (
<Form.Item label="Value" required {...formItemProps}>
<ParameterValueInput
type={parameter.type}
value={parameter.normalizedValue}
enumOptions={parameter.enumOptions}
queryId={parameter.queryId}
parameter={parameter}
onSelect={value => {
parameter.setValue(value);
setNewMapping({ staticValue: parameter.getExecutionValue({ joinListValues: true }) });
}}
/>
</Form.Item>
)}
</Form>
}
visible={showPopover}
onVisibleChange={setShowPopover}>
<Button className="m-l-5" size="small" type="dashed">
<EditOutlinedIcon />
</Button>
</InputPopover>
</>
);
}
QueryBasedParameterMappingEditor.propTypes = {
parameter: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
mapping: PropTypes.shape({
mappingType: PropTypes.oneOf(values(QueryBasedParameterMappingType)),
staticValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
}),
searchAvailable: PropTypes.bool,
onChange: PropTypes.func,
};
QueryBasedParameterMappingEditor.defaultProps = {
mapping: { mappingType: QueryBasedParameterMappingType.UNDEFINED, staticValue: undefined },
searchAvailable: false,
onChange: () => {},
};

View File

@@ -0,0 +1,56 @@
import React from "react";
import { findKey } from "lodash";
import PropTypes from "prop-types";
import Table from "antd/lib/table";
import { QueryBasedParameterMappingType } from "@/services/parameters/QueryBasedDropdownParameter";
import QueryBasedParameterMappingEditor from "./QueryBasedParameterMappingEditor";
export default function QueryBasedParameterMappingTable({ param, mappingParameters, onChangeParam }) {
return (
<Table
dataSource={mappingParameters}
size="middle"
pagination={false}
rowKey={({ mappingParam }) => `param${mappingParam.name}`}>
<Table.Column title="Title" key="title" render={({ mappingParam }) => mappingParam.getTitle()} />
<Table.Column
title="Keyword"
key="keyword"
className="keyword"
render={({ mappingParam }) => <code>{`{{ ${mappingParam.name} }}`}</code>}
/>
<Table.Column
title="Value Source"
key="source"
render={({ mappingParam, existingMapping }) => (
<QueryBasedParameterMappingEditor
parameter={mappingParam.setValue(existingMapping.staticValue)}
mapping={existingMapping}
searchAvailable={
!findKey(param.parameterMapping, {
mappingType: QueryBasedParameterMappingType.DROPDOWN_SEARCH,
}) || existingMapping.mappingType === QueryBasedParameterMappingType.DROPDOWN_SEARCH
}
onChange={mapping =>
onChangeParam({
...param,
parameterMapping: { ...param.parameterMapping, [mappingParam.name]: mapping },
})
}
/>
)}
/>
</Table>
);
}
QueryBasedParameterMappingTable.propTypes = {
param: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
mappingParameters: PropTypes.arrayOf(PropTypes.object), // eslint-disable-line react/forbid-prop-types
onChangeParam: PropTypes.func,
};
QueryBasedParameterMappingTable.defaultProps = {
mappingParameters: [],
onChangeParam: () => {},
};

View File

@@ -3,7 +3,6 @@ import PropTypes from "prop-types";
import Dropdown from "antd/lib/dropdown"; import Dropdown from "antd/lib/dropdown";
import Menu from "antd/lib/menu"; import Menu from "antd/lib/menu";
import Button from "antd/lib/button"; import Button from "antd/lib/button";
import PlainButton from "@/components/PlainButton";
import { clientConfig } from "@/services/auth"; import { clientConfig } from "@/services/auth";
import PlusCircleFilledIcon from "@ant-design/icons/PlusCircleFilled"; import PlusCircleFilledIcon from "@ant-design/icons/PlusCircleFilled";
@@ -19,18 +18,16 @@ export default function QueryControlDropdown(props) {
<Menu> <Menu>
{!props.query.isNew() && (!props.query.is_draft || !props.query.is_archived) && ( {!props.query.isNew() && (!props.query.is_draft || !props.query.is_archived) && (
<Menu.Item> <Menu.Item>
<PlainButton onClick={() => props.openAddToDashboardForm(props.selectedTab)}> <a target="_self" onClick={() => props.openAddToDashboardForm(props.selectedTab)}>
<PlusCircleFilledIcon /> Add to Dashboard <PlusCircleFilledIcon /> Add to Dashboard
</PlainButton> </a>
</Menu.Item> </Menu.Item>
)} )}
{!clientConfig.disablePublicUrls && !props.query.isNew() && ( {!clientConfig.disablePublicUrls && !props.query.isNew() && (
<Menu.Item> <Menu.Item>
<PlainButton <a onClick={() => props.showEmbedDialog(props.query, props.selectedTab)} data-test="ShowEmbedDialogButton">
onClick={() => props.showEmbedDialog(props.query, props.selectedTab)}
data-test="ShowEmbedDialogButton">
<ShareAltOutlinedIcon /> Embed Elsewhere <ShareAltOutlinedIcon /> Embed Elsewhere
</PlainButton> </a>
</Menu.Item> </Menu.Item>
)} )}
<Menu.Item> <Menu.Item>

View File

@@ -1,14 +1,12 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import cx from "classnames";
import { clientConfig, currentUser } from "@/services/auth"; import { clientConfig, currentUser } from "@/services/auth";
import Tooltip from "@/components/Tooltip"; import Tooltip from "antd/lib/tooltip";
import Alert from "antd/lib/alert"; import Alert from "antd/lib/alert";
import HelpTrigger from "@/components/HelpTrigger"; import HelpTrigger from "@/components/HelpTrigger";
import { useUniqueId } from "@/lib/hooks/useUniqueId";
export default function EmailSettingsWarning({ featureName, className, mode, adminOnly }) { export default function EmailSettingsWarning({ featureName, className, mode, adminOnly }) {
const messageDescriptionId = useUniqueId("sr-mail-description");
if (!clientConfig.mailSettingsMissing) { if (!clientConfig.mailSettingsMissing) {
return null; return null;
} }
@@ -18,7 +16,7 @@ export default function EmailSettingsWarning({ featureName, className, mode, adm
} }
const message = ( const message = (
<span id={messageDescriptionId}> <span>
Your mail server isn&apos;t configured correctly, and is needed for {featureName} to work.{" "} Your mail server isn&apos;t configured correctly, and is needed for {featureName} to work.{" "}
<HelpTrigger type="MAIL_CONFIG" className="f-inherit" /> <HelpTrigger type="MAIL_CONFIG" className="f-inherit" />
</span> </span>
@@ -26,11 +24,8 @@ export default function EmailSettingsWarning({ featureName, className, mode, adm
if (mode === "icon") { if (mode === "icon") {
return ( return (
<Tooltip title={message} placement="topRight" arrowPointAtCenter> <Tooltip title={message}>
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */} <i className={cx("fa fa-exclamation-triangle", className)} />
<span className={className} aria-label="Mail alert" aria-describedby={messageDescriptionId} tabIndex={0}>
<i className={"fa fa-exclamation-triangle"} aria-hidden="true" />
</span>
</Tooltip> </Tooltip>
); );
} }

View File

@@ -1,6 +1,5 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import PlainButton from "@/components/PlainButton";
export default class FavoritesControl extends React.Component { export default class FavoritesControl extends React.Component {
static propTypes = { static propTypes = {
@@ -30,13 +29,12 @@ export default class FavoritesControl extends React.Component {
const icon = item.is_favorite ? "fa fa-star" : "fa fa-star-o"; const icon = item.is_favorite ? "fa fa-star" : "fa fa-star-o";
const title = item.is_favorite ? "Remove from favorites" : "Add to favorites"; const title = item.is_favorite ? "Remove from favorites" : "Add to favorites";
return ( return (
<PlainButton <a
title={title} title={title}
aria-label={title} className="favorites-control btn-favourite"
className="favorites-control btn-favorite"
onClick={event => this.toggleItem(event, item, onChange)}> onClick={event => this.toggleItem(event, item, onChange)}>
<i className={icon} aria-hidden="true" /> <i className={icon} aria-hidden="true" />
</PlainButton> </a>
); );
} }
} }

View File

@@ -112,11 +112,11 @@ function Filters({ filters, onChange }) {
{!filter.multiple && options} {!filter.multiple && options}
{filter.multiple && [ {filter.multiple && [
<Select.Option key={NONE_VALUES} data-test="ClearOption"> <Select.Option key={NONE_VALUES} data-test="ClearOption">
<i className="fa fa-square-o m-r-5" aria-hidden="true" /> <i className="fa fa-square-o m-r-5" />
Clear Clear
</Select.Option>, </Select.Option>,
<Select.Option key={ALL_VALUES} data-test="SelectAllOption"> <Select.Option key={ALL_VALUES} data-test="SelectAllOption">
<i className="fa fa-check-square-o m-r-5" aria-hidden="true" /> <i className="fa fa-check-square-o m-r-5" />
Select All Select All
</Select.Option>, </Select.Option>,
<Select.OptGroup key="Values" title="Values"> <Select.OptGroup key="Values" title="Values">

View File

@@ -2,10 +2,9 @@ import { startsWith, get, some, mapValues } from "lodash";
import React from "react"; import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import cx from "classnames"; import cx from "classnames";
import Tooltip from "@/components/Tooltip"; import Tooltip from "antd/lib/tooltip";
import Drawer from "antd/lib/drawer"; import Drawer from "antd/lib/drawer";
import Link from "@/components/Link"; import Link from "@/components/Link";
import PlainButton from "@/components/PlainButton";
import CloseOutlinedIcon from "@ant-design/icons/CloseOutlined"; import CloseOutlinedIcon from "@ant-design/icons/CloseOutlined";
import BigMessage from "@/components/BigMessage"; import BigMessage from "@/components/BigMessage";
import DynamicComponent, { registerComponent } from "@/components/DynamicComponent"; import DynamicComponent, { registerComponent } from "@/components/DynamicComponent";
@@ -46,7 +45,7 @@ export const TYPES = mapValues(
NUMBER_FORMAT_SPECS: ["/user-guide/visualizations/formatting-numbers", "Formatting Numbers"], NUMBER_FORMAT_SPECS: ["/user-guide/visualizations/formatting-numbers", "Formatting Numbers"],
GETTING_STARTED: ["/user-guide/getting-started", "Guide: Getting Started"], GETTING_STARTED: ["/user-guide/getting-started", "Guide: Getting Started"],
DASHBOARDS: ["/user-guide/dashboards", "Guide: Dashboards"], DASHBOARDS: ["/user-guide/dashboards", "Guide: Dashboards"],
QUERIES: ["/user-guide/querying", "Guide: Queries"], QUERIES: ["/help/user-guide/querying", "Guide: Queries"],
ALERTS: ["/user-guide/alerts", "Guide: Alerts"], ALERTS: ["/user-guide/alerts", "Guide: Alerts"],
}, },
([url, title]) => [DOMAIN + HELP_PATH + url, title] ([url, title]) => [DOMAIN + HELP_PATH + url, title]
@@ -69,7 +68,7 @@ const HelpTriggerDefaultProps = {
className: null, className: null,
showTooltip: true, showTooltip: true,
renderAsLink: false, renderAsLink: false,
children: <i className="fa fa-question-circle" aria-hidden="true" />, children: <i className="fa fa-question-circle" />,
}; };
export function helpTriggerWithTypes(types, allowedDomains = [], drawerClassName = null) { export function helpTriggerWithTypes(types, allowedDomains = [], drawerClassName = null) {
@@ -101,7 +100,7 @@ export function helpTriggerWithTypes(types, allowedDomains = [], drawerClassName
clearTimeout(this.iframeLoadingTimeout); clearTimeout(this.iframeLoadingTimeout);
} }
loadIframe = (url) => { loadIframe = url => {
clearTimeout(this.iframeLoadingTimeout); clearTimeout(this.iframeLoadingTimeout);
this.setState({ loading: true, error: false }); this.setState({ loading: true, error: false });
@@ -116,8 +115,8 @@ export function helpTriggerWithTypes(types, allowedDomains = [], drawerClassName
clearTimeout(this.iframeLoadingTimeout); clearTimeout(this.iframeLoadingTimeout);
}; };
onPostMessageReceived = (event) => { onPostMessageReceived = event => {
if (!some(allowedDomains, (domain) => startsWith(event.origin, domain))) { if (!some(allowedDomains, domain => startsWith(event.origin, domain))) {
return; return;
} }
@@ -134,7 +133,7 @@ export function helpTriggerWithTypes(types, allowedDomains = [], drawerClassName
return helpTriggerType ? helpTriggerType[0] : this.props.href; return helpTriggerType ? helpTriggerType[0] : this.props.href;
}; };
openDrawer = (e) => { openDrawer = e => {
// keep "open in new tab" behavior // keep "open in new tab" behavior
if (!e.shiftKey && !e.ctrlKey && !e.metaKey) { if (!e.shiftKey && !e.ctrlKey && !e.metaKey) {
e.preventDefault(); e.preventDefault();
@@ -144,7 +143,7 @@ export function helpTriggerWithTypes(types, allowedDomains = [], drawerClassName
} }
}; };
closeDrawer = (event) => { closeDrawer = event => {
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
@@ -161,7 +160,7 @@ export function helpTriggerWithTypes(types, allowedDomains = [], drawerClassName
const tooltip = get(types, `${this.props.type}[1]`, this.props.title); const tooltip = get(types, `${this.props.type}[1]`, this.props.title);
const className = cx("help-trigger", this.props.className); const className = cx("help-trigger", this.props.className);
const url = this.state.currentUrl; const url = this.state.currentUrl;
const isAllowedDomain = some(allowedDomains, (domain) => startsWith(url || targetUrl, domain)); const isAllowedDomain = some(allowedDomains, domain => startsWith(url || targetUrl, domain));
const shouldRenderAsLink = this.props.renderAsLink || !isAllowedDomain; const shouldRenderAsLink = this.props.renderAsLink || !isAllowedDomain;
return ( return (
@@ -171,24 +170,16 @@ export function helpTriggerWithTypes(types, allowedDomains = [], drawerClassName
this.props.showTooltip ? ( this.props.showTooltip ? (
<> <>
{tooltip} {tooltip}
{shouldRenderAsLink && ( {shouldRenderAsLink && <i className="fa fa-external-link" style={{ marginLeft: 5 }} />}
<>
{" "}
<i className="fa fa-external-link" style={{ marginLeft: 5 }} aria-hidden="true" />
<span className="sr-only">(opens in a new tab)</span>
</>
)}
</> </>
) : null ) : null
} }>
>
<Link <Link
href={url || this.getUrl()} href={url || this.getUrl()}
className={className} className={className}
rel="noopener noreferrer" rel="noopener noreferrer"
target="_blank" target="_blank"
onClick={shouldRenderAsLink ? () => {} : this.openDrawer} onClick={shouldRenderAsLink ? () => {} : this.openDrawer}>
>
{this.props.children} {this.props.children}
</Link> </Link>
</Tooltip> </Tooltip>
@@ -199,23 +190,21 @@ export function helpTriggerWithTypes(types, allowedDomains = [], drawerClassName
visible={this.state.visible} visible={this.state.visible}
className={cx("help-drawer", drawerClassName)} className={cx("help-drawer", drawerClassName)}
destroyOnClose destroyOnClose
width={400} width={400}>
>
<div className="drawer-wrapper"> <div className="drawer-wrapper">
<div className="drawer-menu"> <div className="drawer-menu">
{url && ( {url && (
<Tooltip title="Open page in a new window" placement="left"> <Tooltip title="Open page in a new window" placement="left">
{/* eslint-disable-next-line react/jsx-no-target-blank */} {/* eslint-disable-next-line react/jsx-no-target-blank */}
<Link href={url} target="_blank"> <Link href={url} target="_blank">
<i className="fa fa-external-link" aria-hidden="true" /> <i className="fa fa-external-link" />
<span className="sr-only">(opens in a new tab)</span>
</Link> </Link>
</Tooltip> </Tooltip>
)} )}
<Tooltip title="Close" placement="bottom"> <Tooltip title="Close" placement="bottom">
<PlainButton onClick={this.closeDrawer}> <a onClick={this.closeDrawer}>
<CloseOutlinedIcon /> <CloseOutlinedIcon />
</PlainButton> </a>
</Tooltip> </Tooltip>
</div> </div>

View File

@@ -1,4 +1,4 @@
@import (reference, less) "~@/assets/less/ant"; @import "~antd/lib/drawer/style/drawer";
@help-doc-bg: #f7f7f7; // according to https://github.com/getredash/website/blob/13daff2d8b570956565f482236f6245042e8477f/src/scss/_components/_variables.scss#L15 @help-doc-bg: #f7f7f7; // according to https://github.com/getredash/website/blob/13daff2d8b570956565f482236f6245042e8477f/src/scss/_components/_variables.scss#L15
@@ -38,8 +38,7 @@
border: 2px solid @help-doc-bg; border: 2px solid @help-doc-bg;
display: flex; display: flex;
a, a {
.plain-button {
height: 26px; height: 26px;
width: 26px; width: 26px;
display: flex; display: flex;

View File

@@ -0,0 +1,57 @@
import React from "react";
import PropTypes from "prop-types";
import Button from "antd/lib/button";
import Popover from "antd/lib/popover";
import "./index.less";
export default function InputPopover({
header,
content,
children,
okButtonProps,
cancelButtonProps,
onCancel,
onOk,
...props
}) {
return (
<Popover
{...props}
content={
<div className="input-popover-content" data-test="InputPopoverContent">
{header && <header>{header}</header>}
{content}
<footer>
<Button onClick={onCancel} {...cancelButtonProps}>
Cancel
</Button>
<Button onClick={onOk} type="primary" {...okButtonProps}>
OK
</Button>
</footer>
</div>
}>
{children}
</Popover>
);
}
InputPopover.propTypes = {
header: PropTypes.node,
content: PropTypes.node,
children: PropTypes.node,
okButtonProps: PropTypes.object,
cancelButtonProps: PropTypes.object,
onOk: PropTypes.func,
onCancel: PropTypes.func,
};
InputPopover.defaultProps = {
header: null,
children: null,
okButtonProps: null,
cancelButtonProps: null,
onOk: () => {},
onCancel: () => {},
};

View File

@@ -0,0 +1,37 @@
@import "~antd/lib/modal/style/index"; // for ant @vars
.input-popover-content {
width: 390px;
.radio {
display: block;
height: 30px;
line-height: 30px;
}
.form-item {
margin-bottom: 10px;
}
header {
padding: 0 16px 10px;
margin: 0 -16px 20px;
border-bottom: @border-width-base @border-style-base @border-color-split;
font-size: @font-size-lg;
font-weight: 500;
color: @heading-color;
display: flex;
justify-content: space-between;
}
footer {
border-top: @border-width-base @border-style-base @border-color-split;
padding: 10px 16px 0;
margin: 0 -16px;
text-align: right;
button {
margin-left: 8px;
}
}
}

View File

@@ -1,8 +1,7 @@
import React from "react"; import React from "react";
import Input from "antd/lib/input"; import Input from "antd/lib/input";
import CopyOutlinedIcon from "@ant-design/icons/CopyOutlined"; import CopyOutlinedIcon from "@ant-design/icons/CopyOutlined";
import Tooltip from "@/components/Tooltip"; import Tooltip from "antd/lib/tooltip";
import PlainButton from "./PlainButton";
export default class InputWithCopy extends React.Component { export default class InputWithCopy extends React.Component {
constructor(props) { constructor(props) {
@@ -43,10 +42,7 @@ export default class InputWithCopy extends React.Component {
render() { render() {
const copyButton = ( const copyButton = (
<Tooltip title={this.state.copied || "Copy"}> <Tooltip title={this.state.copied || "Copy"}>
<PlainButton onClick={this.copy}> <CopyOutlinedIcon style={{ cursor: "pointer" }} onClick={this.copy} />
{/* TODO: lacks visual feedback */}
<CopyOutlinedIcon />
</PlainButton>
</Tooltip> </Tooltip>
); );

View File

@@ -0,0 +1,26 @@
import React from "react";
import Button from "antd/lib/button";
function DefaultLinkComponent(props) {
return <a {...props} />; // eslint-disable-line jsx-a11y/anchor-has-content
}
function Link(props) {
return <Link.Component {...props} />;
}
Link.Component = DefaultLinkComponent;
function DefaultButtonLinkComponent(props) {
return <Button role="button" {...props} />;
}
function ButtonLink(props) {
return <ButtonLink.Component {...props} />;
}
ButtonLink.Component = DefaultButtonLinkComponent;
Link.Button = ButtonLink;
export default Link;

View File

@@ -1,61 +0,0 @@
import React from "react";
import Button, { ButtonProps as AntdButtonProps } from "antd/lib/button";
function DefaultLinkComponent({ children, ...props }: React.AnchorHTMLAttributes<HTMLAnchorElement>) {
return <a {...props}>{children}</a>;
}
Link.Component = DefaultLinkComponent;
interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "role" | "type" | "target"> {
href: string;
}
function Link({ children, ...props }: LinkProps) {
return <Link.Component {...props}>{children}</Link.Component>;
}
interface LinkWithIconProps extends LinkProps {
children: string;
icon: JSX.Element;
alt: string;
target?: "_self" | "_blank" | "_parent" | "_top";
}
function LinkWithIcon({ icon, alt, children, ...props }: LinkWithIconProps) {
return (
<Link.Component {...props}>
{children} {icon} <span className="sr-only">{alt}</span>
</Link.Component>
);
}
Link.WithIcon = LinkWithIcon;
function ExternalLink({
icon = <i className="fa fa-external-link" aria-hidden="true" />,
alt = "(opens in a new tab)",
...props
}: Omit<LinkWithIconProps, "target">) {
return <Link.WithIcon target="_blank" rel="noopener noreferrer" icon={icon} alt={alt} {...props} />;
}
Link.External = ExternalLink;
// Ant Button will render an <a> if href is present.
function DefaultButtonLinkComponent(props: ButtonProps) {
return <Button {...props} />;
}
ButtonLink.Component = DefaultButtonLinkComponent;
interface ButtonProps extends AntdButtonProps {
href: string;
}
function ButtonLink(props: ButtonProps) {
return <ButtonLink.Component {...props} />;
}
Link.Button = ButtonLink;
export default Link;

Some files were not shown because too many files have changed in this diff Show More