Skip to content

Commit

Permalink
Merge branch 'master' into migrate-router-to-react
Browse files Browse the repository at this point in the history
  • Loading branch information
kravets-levko committed Jan 13, 2020
2 parents d2e0f98 + 5e01211 commit 824ef59
Show file tree
Hide file tree
Showing 104 changed files with 1,354 additions and 2,076 deletions.
13 changes: 0 additions & 13 deletions .circleci/docker-compose.cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,12 @@ services:
REDASH_LOG_LEVEL: "INFO"
REDASH_REDIS_URL: "redis://redis:6379/0"
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
celery_worker:
build: ../
command: celery_worker
depends_on:
- server
environment:
PYTHONUNBUFFERED: 0
REDASH_LOG_LEVEL: "INFO"
REDASH_REDIS_URL: "redis://redis:6379/0"
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
QUEUES: "queries,scheduled_queries"
WORKERS_COUNT: 2
cypress:
build:
context: ../
dockerfile: .circleci/Dockerfile.cypress
depends_on:
- server
- celery_worker
- worker
- scheduler
environment:
Expand Down
37 changes: 0 additions & 37 deletions bin/docker-entrypoint
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
#!/bin/bash
set -e

celery_worker() {
WORKERS_COUNT=${WORKERS_COUNT:-2}
QUEUES=${QUEUES:-queries,scheduled_queries}
WORKER_EXTRA_OPTIONS=${WORKER_EXTRA_OPTIONS:-}

echo "Starting $WORKERS_COUNT workers for queues: $QUEUES..."
exec /usr/local/bin/celery worker --app=redash.worker -c$WORKERS_COUNT -Q$QUEUES -linfo --max-tasks-per-child=10 -Ofair $WORKER_EXTRA_OPTIONS
}

scheduler() {
echo "Starting RQ scheduler..."

Expand Down Expand Up @@ -37,15 +28,6 @@ dev_worker() {
exec watchmedo auto-restart --directory=./redash/ --pattern=*.py --recursive -- ./manage.py rq worker $QUEUES
}

dev_celery_worker() {
WORKERS_COUNT=${WORKERS_COUNT:-2}
QUEUES=${QUEUES:-queries,scheduled_queries}

echo "Starting $WORKERS_COUNT workers for queues: $QUEUES..."

exec watchmedo auto-restart --directory=./redash/ --pattern=*.py --recursive -- /usr/local/bin/celery worker --app=redash.worker -c$WORKERS_COUNT -Q$QUEUES -linfo --max-tasks-per-child=10 -Ofair
}

server() {
# 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}
Expand All @@ -57,10 +39,6 @@ create_db() {
exec /app/manage.py database create_tables
}

celery_healthcheck() {
exec /usr/local/bin/celery inspect ping --app=redash.worker -d celery@$HOSTNAME
}

rq_healthcheck() {
exec /app/manage.py rq healthcheck
}
Expand All @@ -72,13 +50,10 @@ help() {
echo ""

echo "server -- start Redash server (with gunicorn)"
echo "celery_worker -- start Celery worker"
echo "dev_celery_worker -- start Celery worker process which picks up code changes and reloads"
echo "worker -- start a single RQ worker"
echo "dev_worker -- start a single RQ worker with code reloading"
echo "scheduler -- start an rq-scheduler instance"
echo "dev_scheduler -- start an rq-scheduler instance with code reloading"
echo "celery_healthcheck -- runs a Celery healthcheck. Useful for Docker's HEALTHCHECK mechanism."
echo "rq_healthcheck -- runs a RQ healthcheck that verifies that all local workers are active. Useful for Docker's HEALTHCHECK mechanism."
echo ""
echo "shell -- open shell"
Expand Down Expand Up @@ -117,14 +92,6 @@ case "$1" in
shift
dev_scheduler
;;
celery_worker)
shift
celery_worker
;;
dev_celery_worker)
shift
dev_celery_worker
;;
dev_worker)
shift
dev_worker
Expand All @@ -133,10 +100,6 @@ case "$1" in
shift
rq_healthcheck
;;
celery_healthcheck)
shift
celery_healthcheck
;;
dev_server)
export FLASK_DEBUG=1
exec /app/manage.py runserver --debugger --reload -h 0.0.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function FavoritesDropdown({ fetch, urlTemplate }) {
(showLoadingState = true) => {
setLoading(showLoadingState);
fetch()
.$promise.then(({ results }) => {
.then(({ results }) => {
setItems(results);
})
.finally(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function DesktopNavbar() {
<a href="query_snippets">Query Snippets</a>
</Menu.Item>
)}
{currentUser.hasPermission("list_users") && (
{currentUser.isAdmin && (
<Menu.Item key="destinations">
<a href="destinations">Alert Destinations</a>
</Menu.Item>
Expand Down
4 changes: 1 addition & 3 deletions client/app/components/EditParameterSettingsDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ function EditParameterSettingsDialog(props) {
useEffect(() => {
const queryId = props.parameter.queryId;
if (queryId) {
Query.get({ id: queryId }, query => {
setInitialQuery(query);
});
Query.get({ id: queryId }).then(setInitialQuery);
}
}, [props.parameter.queryId]);

Expand Down
2 changes: 1 addition & 1 deletion client/app/components/FavoritesControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class FavoritesControl extends React.Component {
};

toggleItem(event, item, callback) {
const action = item.is_favorite ? item.$unfavorite.bind(item) : item.$favorite.bind(item);
const action = item.is_favorite ? item.unfavorite.bind(item) : item.favorite.bind(item);
const savedIsFavorite = item.is_favorite;

action().then(() => {
Expand Down
4 changes: 2 additions & 2 deletions client/app/components/HtmlContent.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import PropTypes from "prop-types";
import { $sanitize } from "@/services/ng";
import { sanitize } from "dompurify";

export default function HtmlContent({ children, ...props }) {
return (
<div
{...props}
dangerouslySetInnerHTML={{ __html: $sanitize(children) }} // eslint-disable-line react/no-danger
dangerouslySetInnerHTML={{ __html: sanitize(children) }} // eslint-disable-line react/no-danger
/>
);
}
Expand Down
12 changes: 6 additions & 6 deletions client/app/components/PermissionsEditorDialog/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect, useCallback } from "react";
import { axios } from "@/services/axios";
import PropTypes from "prop-types";
import { each, debounce, get, find } from "lodash";
import Button from "antd/lib/button";
Expand All @@ -8,12 +9,11 @@ import Select from "antd/lib/select";
import Tag from "antd/lib/tag";
import Tooltip from "antd/lib/tooltip";
import { wrap as wrapDialog, DialogPropType } from "@/components/DialogWrapper";
import { $http } from "@/services/ng";
import { toHuman } from "@/lib/utils";
import HelpTrigger from "@/components/HelpTrigger";
import { UserPreviewCard } from "@/components/PreviewCard";
import notification from "@/services/notification";
import { User } from "@/services/user";
import User from "@/services/user";

import "./index.less";

Expand All @@ -23,7 +23,7 @@ const DEBOUNCE_SEARCH_DURATION = 200;
function useGrantees(url) {
const loadGrantees = useCallback(
() =>
$http.get(url).then(({ data }) => {
axios.get(url).then(data => {
const resultGrantees = [];
each(data, (grantees, accessType) => {
grantees.forEach(grantee => {
Expand All @@ -38,15 +38,15 @@ function useGrantees(url) {

const addPermission = useCallback(
(userId, accessType = "modify") =>
$http
axios
.post(url, { access_type: accessType, user_id: userId })
.catch(() => notification.error("Could not grant permission to the user")),
[url]
);

const removePermission = useCallback(
(userId, accessType = "modify") =>
$http
axios
.delete(url, { data: { access_type: accessType, user_id: userId } })
.catch(() => notification.error("Could not remove permission from the user")),
[url]
Expand All @@ -57,7 +57,7 @@ function useGrantees(url) {

const searchUsers = searchTerm =>
User.query({ q: searchTerm })
.$promise.then(({ results }) => results)
.then(({ results }) => results)
.catch(() => []);

function PermissionsEditorDialogHeader({ context }) {
Expand Down
7 changes: 2 additions & 5 deletions client/app/components/QuerySelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ const { Option } = Select;
function search(term) {
// get recent
if (!term) {
return Query.recent().$promise.then(results => {
const filteredResults = results.filter(item => !item.is_draft); // filter out draft
return Promise.resolve(filteredResults);
});
return Query.recent().then(results => results.filter(item => !item.is_draft)); // filter out draft
}

// search by query
return Query.query({ q: term }).$promise.then(({ results }) => Promise.resolve(results));
return Query.query({ q: term }).then(({ results }) => results);
}

export default function QuerySelector(props) {
Expand Down
14 changes: 9 additions & 5 deletions client/app/components/SettingsWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ function wrapSettingsTab(options, WrappedComponent) {
<PageHeader title="Settings" />
<div className="bg-white tiled">
<Menu selectedKeys={[activeItem && activeItem.title]} selectable={false} mode="horizontal">
{settingsMenu.items.map(item => (
<Menu.Item key={item.title}>
<a href={item.path}>{item.title}</a>
</Menu.Item>
))}
{settingsMenu.items
.filter(item => item.isAvailable())
.map(item => (
<Menu.Item key={item.title}>
<a href={item.path} data-test="SettingsScreenItem">
{item.title}
</a>
</Menu.Item>
))}
</Menu>
<div className="p-15">
<div>
Expand Down
89 changes: 0 additions & 89 deletions client/app/components/admin/CeleryStatus.jsx

This file was deleted.

3 changes: 0 additions & 3 deletions client/app/components/admin/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ export default function Layout({ activeTab, children }) {
<Tabs.TabPane key="system_status" tab={<a href="admin/status">System Status</a>}>
{activeTab === "system_status" ? children : null}
</Tabs.TabPane>
<Tabs.TabPane key="tasks" tab={<a href="admin/queries/tasks">Celery Status</a>}>
{activeTab === "tasks" ? children : null}
</Tabs.TabPane>
<Tabs.TabPane key="jobs" tab={<a href="admin/queries/jobs">RQ Status</a>}>
{activeTab === "jobs" ? children : null}
</Tabs.TabPane>
Expand Down
25 changes: 25 additions & 0 deletions client/app/components/admin/RQStatus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,34 @@ import React from "react";
import PropTypes from "prop-types";

import Badge from "antd/lib/badge";
import Card from "antd/lib/card";
import Spin from "antd/lib/spin";
import Table from "antd/lib/table";
import { Columns } from "@/components/items-list/components/ItemsTable";

// CounterCard

export function CounterCard({ title, value, loading }) {
return (
<Spin spinning={loading}>
<Card>
{title}
<div className="f-20">{value}</div>
</Card>
</Spin>
);
}

CounterCard.propTypes = {
title: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
loading: PropTypes.bool.isRequired,
};

CounterCard.defaultProps = {
value: "",
};

// Tables

const otherJobsColumns = [
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/dashboards/AddWidgetDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AddWidgetDialog extends React.Component {
});

if (selectedQuery) {
Query.get({ id: selectedQuery.id }, query => {
Query.get({ id: selectedQuery.id }).then(query => {
if (query) {
const existingParamNames = map(this.props.dashboard.getParametersDefs(), param => param.name);
this.setState({
Expand Down
Loading

0 comments on commit 824ef59

Please sign in to comment.