Skip to content

Commit

Permalink
Migrate Dashboard and Public Dashboard to React (#4228)
Browse files Browse the repository at this point in the history
* Initial React Rendering with useDashboard

* Make sure widgets refresh + useCallback

* Rename collectFilters and add refreshRate

* Fix error updates not being rendered

* Only render widget bottom when queryResults exists

* Cleanup

* Add useCallback to refreshDashboard

* Make sure Promise.all have all promises done

* Start migrating Dashoard to React
- initial rendering
- some actions
- temporary updated less file

* Fullscreen handler added

* Separate refreshRateHandler hook

* Add a few tooltips

* Separate DashboardControl and normalize btn width

* Share Button

* Fix serach params not updating

* Enumerate More Options

* Toggle Publish options

* Archive Dashboard

* Parameters + Filters

* Prepare Manage Permissions

* Start to create edit mode

* Add Edit Mode functionalities

* Use previous state when updating dashboard

* Mobile adjustments

* PermissionsEditorDialog + Dashboard page title

* Update Dashboard spec

* Fix other specs

* Break dashboard.less

* Hide publish button on mobile

* Angular Cleaning

* Keep edit state when changing resolution

* Bug fix: Dashboard Level Filters not updating

* Remove prepareWidgetsForDashboard

* Revert "Remove prepareWidgetsForDashboard"

This reverts commit b434f03.

* Avoid saving layout changes out of editing mode

* Apply policy for enabled refresh rates

* Disable loadDashboard deps

* Restyled by prettier (#4459)

* Update title when dashboard name updates

Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and arikfr committed Dec 24, 2019
1 parent 49dcb7f commit 38b6b47
Show file tree
Hide file tree
Showing 35 changed files with 1,578 additions and 1,365 deletions.
21 changes: 2 additions & 19 deletions client/app/assets/less/inc/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ text.slicetext {
}

// page
.page-header--new .btn-favourite, .page-header--new .btn-archive {
font-size: 19px;
}

.page-title {
display: flex;
align-items: center;
Expand All @@ -232,23 +228,10 @@ text.slicetext {
display: inline-block;
}

favorites-control {
.favorites-control {
font-size: 19px;
margin-right: 5px;
}

@media (max-width: 767px) {
display: block;

favorites-control {
float: left;
}

h3 {
width: 100%;
margin-bottom: 5px !important;
display: block !important;
}
}
}

.page-header-wrapper, .page-header--new {
Expand Down
11 changes: 11 additions & 0 deletions client/app/assets/less/redash/query.less
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ edit-in-place p.editable:hover {
margin-left: 15px;
margin-right: 15px;
}

.tags-control a {
opacity: 0;
transition: opacity 0.2s ease-in-out;
}

&:hover {
.tags-control a {
opacity: 1;
}
}
}

a.label-tag {
Expand Down
9 changes: 2 additions & 7 deletions client/app/components/BigMessage.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from "react";
import PropTypes from "prop-types";
import { react2angular } from "react2angular";

export function BigMessage({ message, icon, children, className }) {
function BigMessage({ message, icon, children, className }) {
return (
<div className={"p-15 text-center " + className}>
<h3 className="m-t-0 m-b-0">
Expand All @@ -28,8 +27,4 @@ BigMessage.defaultProps = {
className: "tiled bg-white",
};

export default function init(ngModule) {
ngModule.component("bigMessage", react2angular(BigMessage));
}

init.init = true;
export default BigMessage;
5 changes: 4 additions & 1 deletion client/app/components/FavoritesControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export class FavoritesControl extends React.Component {
const icon = item.is_favorite ? "fa fa-star" : "fa fa-star-o";
const title = item.is_favorite ? "Remove from favorites" : "Add to favorites";
return (
<a title={title} className="btn-favourite" onClick={event => this.toggleItem(event, item, onChange)}>
<a
title={title}
className="favorites-control btn-favourite"
onClick={event => this.toggleItem(event, item, onChange)}>
<i className={icon} aria-hidden="true" />
</a>
);
Expand Down
9 changes: 2 additions & 7 deletions client/app/components/Filters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { isArray, indexOf, get, map, includes, every, some, toNumber } from "lod
import moment from "moment";
import React from "react";
import PropTypes from "prop-types";
import { react2angular } from "react2angular";
import Select from "antd/lib/select";
import { formatColumnValue } from "@/filters";

Expand Down Expand Up @@ -67,7 +66,7 @@ export function filterData(rows, filters = []) {
return result;
}

export function Filters({ filters, onChange }) {
function Filters({ filters, onChange }) {
if (filters.length === 0) {
return null;
}
Expand Down Expand Up @@ -138,8 +137,4 @@ Filters.defaultProps = {
onChange: () => {},
};

export default function init(ngModule) {
ngModule.component("filters", react2angular(Filters));
}

init.init = true;
export default Filters;
2 changes: 1 addition & 1 deletion client/app/components/HelpTrigger.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import cx from "classnames";
import Tooltip from "antd/lib/tooltip";
import Drawer from "antd/lib/drawer";
import Icon from "antd/lib/icon";
import { BigMessage } from "@/components/BigMessage";
import BigMessage from "@/components/BigMessage";
import DynamicComponent from "@/components/DynamicComponent";

import "./HelpTrigger.less";
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/NoTaggedObjectsFound.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import PropTypes from "prop-types";
import { react2angular } from "react2angular";
import { BigMessage } from "@/components/BigMessage";
import BigMessage from "@/components/BigMessage";
import { TagsControl } from "@/components/tags-control/TagsControl";

export function NoTaggedObjectsFound({ objectType, tags }) {
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/SelectItemsDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Input from "antd/lib/input";
import List from "antd/lib/list";
import Button from "antd/lib/button";
import { wrap as wrapDialog, DialogPropType } from "@/components/DialogWrapper";
import { BigMessage } from "@/components/BigMessage";
import BigMessage from "@/components/BigMessage";

import LoadingState from "@/components/items-list/components/LoadingState";
import notification from "@/services/notification";
Expand Down
7 changes: 1 addition & 6 deletions client/app/components/dashboards/DashboardGrid.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import { chain, cloneDeep, find } from "lodash";
import { react2angular } from "react2angular";
import cx from "classnames";
import { Responsive, WidthProvider } from "react-grid-layout";
import { VisualizationWidget, TextboxWidget, RestrictedWidget } from "@/components/dashboards/dashboard-widget";
Expand Down Expand Up @@ -242,8 +241,4 @@ class DashboardGrid extends React.Component {
}
}

export default function init(ngModule) {
ngModule.component("dashboardGrid", react2angular(DashboardGrid));
}

init.init = true;
export default DashboardGrid;
115 changes: 115 additions & 0 deletions client/app/components/dashboards/dashboard-grid.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,118 @@
.dashboard-wrapper {
flex-grow: 1;
margin-bottom: 70px;

.layout {
margin: -15px -15px 0;
}

.tile {
display: flex;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
width: auto;
height: auto;
overflow: hidden;
margin: 0;
padding: 0;
}

.pivot-table-visualization-container > table,
.visualization-renderer > .visualization-renderer-wrapper {
overflow: visible;
}

&.preview-mode {
.widget-menu-regular {
display: block;
}
.widget-menu-remove {
display: none;
}
}

&.editing-mode {
/* Y axis lines */
background: linear-gradient(to right, transparent, transparent 1px, #F6F8F9 1px, #F6F8F9), linear-gradient(to bottom, #B3BABF, #B3BABF 1px, transparent 1px, transparent);
background-size: 5px 50px;
background-position-y: -8px;

/* X axis lines */
&::before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 85px;
right: 15px;
background: linear-gradient(to bottom, transparent, transparent 2px, #F6F8F9 2px, #F6F8F9 5px), linear-gradient(to left, #B3BABF, #B3BABF 1px, transparent 1px, transparent);
background-size: calc((100vw - 15px) / 6) 5px;
background-position: -7px 1px;
}
}

.dashboard-widget-wrapper:not(.widget-auto-height-enabled) {
.visualization-renderer {
display: flex;
flex-direction: column;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;

> .visualization-renderer-wrapper {
flex-grow: 1;
position: relative;
}

> .filters-wrapper {
flex-grow: 0;
}
}

.sunburst-visualization-container,
.sankey-visualization-container,
.map-visualization-container,
.word-cloud-visualization-container,
.box-plot-deprecated-visualization-container,
.chart-visualization-container {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
width: auto;
height: auto;
overflow: hidden;
}

.counter-visualization-content {
position: absolute;
left: 10px;
top: 15px;
right: 10px;
bottom: 15px;
height: auto;
overflow: hidden;
padding: 0;
}
}

.widget-auto-height-enabled {
.spinner {
position: static;
}

.scrollbox {
overflow-y: hidden;
}
}
}

.react-grid-layout {
&.disable-animations {
& > .react-grid-item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function VisualizationWidgetFooter({ widget, isPublic, onRefresh, onExpand }) {
}
};

return (
return widgetQueryResult ? (
<>
<span>
{!isPublic && !!widgetQueryResult && (
Expand Down Expand Up @@ -158,7 +158,7 @@ function VisualizationWidgetFooter({ widget, isPublic, onRefresh, onExpand }) {
</a>
</span>
</>
);
) : null;
}

VisualizationWidgetFooter.propTypes = {
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/items-list/components/EmptyState.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { BigMessage } from "@/components/BigMessage";
import BigMessage from "@/components/BigMessage";

// Default "list empty" message for list pages
export default function EmptyState(props) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { BigMessage } from "@/components/BigMessage";
import BigMessage from "@/components/BigMessage";

// Default "loading" message for list pages
export default function LoadingState(props) {
Expand Down
1 change: 0 additions & 1 deletion client/app/components/tags-control/TagsControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export const DashboardTagsControl = modelTagsControl({

export default function init(ngModule) {
ngModule.component("queryTagsControl", react2angular(QueryTagsControl));
ngModule.component("dashboardTagsControl", react2angular(DashboardTagsControl));
}

init.init = true;
2 changes: 1 addition & 1 deletion client/app/pages/dashboards/DashboardListEmptyState.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import { BigMessage } from "@/components/BigMessage";
import BigMessage from "@/components/BigMessage";
import { NoTaggedObjectsFound } from "@/components/NoTaggedObjectsFound";
import EmptyState from "@/components/empty-state/EmptyState";

Expand Down
Loading

0 comments on commit 38b6b47

Please sign in to comment.