Skip to content

Commit

Permalink
Merge pull request #8 from eradman/restyled/share-link-download
Browse files Browse the repository at this point in the history
Restyled Allow CSV/TSV/Excel download from shared dashboards
  • Loading branch information
eradman authored Nov 21, 2024
2 parents ea4f81f + 93bd1bc commit f3fb796
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ function visualizationWidgetMenuOptions({ widget, canEditDashboard, onParameters
const canEditParameters = canEditDashboard && !isEmpty(invoke(widget, "query.getParametersDefs"));
const widgetQueryResult = widget.getQueryResult();
const isQueryResultEmpty = !widgetQueryResult || !widgetQueryResult.isEmpty || widgetQueryResult.isEmpty();
const parts = window.location.pathname.split('/').reverse()
const parts = window.location.pathname.split("/").reverse();
var apiKey = null;
if (parts.length > 3 && parts[2] === 'public' && parts[0].length === 40) {
if (parts.length > 3 && parts[2] === "public" && parts[0].length === 40) {
apiKey = parts[0];
}
const downloadLink = fileType => widgetQueryResult.getLink(widget.getQuery().id, fileType, apiKey);
const downloadName = fileType => widgetQueryResult.getName(widget.getQuery().name, fileType);
const downloadLink = (fileType) => widgetQueryResult.getLink(widget.getQuery().id, fileType, apiKey);
const downloadName = (fileType) => widgetQueryResult.getName(widget.getQuery().name, fileType);
return compact([
<Menu.Item key="download_csv" disabled={isQueryResultEmpty}>
{!isQueryResultEmpty ? (
Expand Down Expand Up @@ -153,7 +153,7 @@ function VisualizationWidgetFooter({ widget, isPublic, onRefresh, onExpand }) {
const updatedAt = invoke(widgetQueryResult, "getUpdatedAt");
const [refreshClickButtonId, setRefreshClickButtonId] = useState();

const refreshWidget = buttonId => {
const refreshWidget = (buttonId) => {
if (!refreshClickButtonId) {
setRefreshClickButtonId(buttonId);
onRefresh().finally(() => setRefreshClickButtonId(null));
Expand All @@ -167,7 +167,8 @@ function VisualizationWidgetFooter({ widget, isPublic, onRefresh, onExpand }) {
<PlainButton
className="refresh-button hidden-print btn btn-sm btn-default btn-transparent"
onClick={() => refreshWidget(1)}
data-test="RefreshButton">
data-test="RefreshButton"
>
<i className={cx("zmdi zmdi-refresh", { "zmdi-hc-spin": refreshClickButtonId === 1 })} aria-hidden="true" />
<span className="sr-only">
{refreshClickButtonId === 1 ? "Refreshing, please wait. " : "Press to refresh. "}
Expand All @@ -188,7 +189,8 @@ function VisualizationWidgetFooter({ widget, isPublic, onRefresh, onExpand }) {
{!isPublic && (
<PlainButton
className="btn btn-sm btn-default hidden-print btn-transparent btn__refresh"
onClick={() => refreshWidget(2)}>
onClick={() => refreshWidget(2)}
>
<i className={cx("zmdi zmdi-refresh", { "zmdi-hc-spin": refreshClickButtonId === 2 })} aria-hidden="true" />
<span className="sr-only">
{refreshClickButtonId === 2 ? "Refreshing, please wait." : "Press to refresh."}
Expand Down Expand Up @@ -254,7 +256,7 @@ class VisualizationWidget extends React.Component {
onLoad();
}

onLocalFiltersChange = localFilters => {
onLocalFiltersChange = (localFilters) => {
this.setState({ localFilters });
};

Expand All @@ -267,7 +269,7 @@ class VisualizationWidget extends React.Component {
EditParameterMappingsDialog.showModal({
dashboard,
widget,
}).onClose(valuesChanged => {
}).onClose((valuesChanged) => {
// refresh widget if any parameter value has been updated
if (valuesChanged) {
onRefresh();
Expand Down Expand Up @@ -310,7 +312,8 @@ class VisualizationWidget extends React.Component {
className="body-row-auto spinner-container"
role="status"
aria-live="polite"
aria-relevant="additions removals">
aria-relevant="additions removals"
>
<div className="spinner">
<i className="zmdi zmdi-refresh zmdi-hc-spin zmdi-hc-5x" aria-hidden="true" />
<span className="sr-only">Loading...</span>
Expand All @@ -325,7 +328,7 @@ class VisualizationWidget extends React.Component {
const { localParameters } = this.state;
const widgetQueryResult = widget.getQueryResult();
const isRefreshing = isLoading && !!(widgetQueryResult && widgetQueryResult.getStatus());
const onParametersEdit = parameters => {
const onParametersEdit = (parameters) => {
const paramOrder = map(parameters, "name");
widget.options.paramOrder = paramOrder;
widget.save("options", { paramOrder });
Expand Down Expand Up @@ -358,7 +361,8 @@ class VisualizationWidget extends React.Component {
onExpand={this.expandWidget}
/>
}
tileProps={{ "data-refreshing": isRefreshing }}>
tileProps={{ "data-refreshing": isRefreshing }}
>
{this.renderVisualization()}
</Widget>
);
Expand Down
5 changes: 3 additions & 2 deletions client/app/components/dashboards/dashboard-widget/Widget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ function WidgetDeleteButton({ onClick }) {
title="Remove From Dashboard"
onClick={onClick}
data-test="WidgetDeleteButton"
aria-label="Close">
aria-label="Close"
>
<i className="zmdi zmdi-close" aria-hidden="true" />
</PlainButton>
</div>
Expand Down Expand Up @@ -108,7 +109,7 @@ class Widget extends React.Component {

render() {
const { className, children, header, footer, canEdit, menuOptions, tileProps } = this.props;
const showDropdownButton = (canEdit || !isEmpty(menuOptions));
const showDropdownButton = canEdit || !isEmpty(menuOptions);
return (
<div className="widget-wrapper">
<div className={cx("tile body-container", className)} {...tileProps}>
Expand Down

0 comments on commit f3fb796

Please sign in to comment.