Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualizations customizable settings #4793

Merged
merged 14 commits into from
Apr 25, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ function EditVisualizationDialog({ dialog, visualization, query, queryResult })
options={options}
visualizationName={name}
onOptionsChange={onOptionsChanged}
context="query"
/>
</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions client/app/components/visualizations/VisualizationRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { map, find } from "lodash";
import React, { useState, useMemo, useEffect, useRef } from "react";
import PropTypes from "prop-types";
import getQueryResultData from "@/lib/getQueryResultData";
import { getColumnCleanName } from "@/services/query-result";
import Filters, { FiltersType, filterData } from "@/components/Filters";
import { VisualizationType } from "@/visualizations/prop-types";
import { Renderer } from "@/components/visualizations/visualizationComponents";
Expand Down Expand Up @@ -42,12 +43,17 @@ export default function VisualizationRenderer(props) {
setFilters(combineFilters(filtersRef.current, props.filters));
}, [props.filters]);

const cleanColumnNames = useMemo(
() => map(data.columns, col => ({ ...col, name: getColumnCleanName(col.friendly_name) })),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kravets-levko it seemed to make sense to move getColumnCleanName out of Table vis and rather apply it to all visualizations, do you see any problems may happen with this change? (that method is used to remove ::filter from column names for example)

[data.columns]
);

const filteredData = useMemo(
() => ({
columns: data.columns,
columns: cleanColumnNames,
rows: filterData(data.rows, filters),
}),
[data, filters]
[cleanColumnNames, data.rows, filters]
);

const { showFilters, visualization } = props;
Expand Down
3 changes: 1 addition & 2 deletions client/app/visualizations/table/getOptions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _ from "lodash";
import { getColumnCleanName } from "@/services/query-result";
import { clientConfig } from "@/services/auth";

const DEFAULT_OPTIONS = {
Expand All @@ -26,7 +25,7 @@ function getDefaultColumnsOptions(columns) {
displayAs: displayAs[col.type] || "string",
visible: true,
order: 100000 + index,
title: getColumnCleanName(col.name),
title: col.name,
allowSearch: false,
alignContent: getColumnContentAlignment(col.type),
// `string` cell options
Expand Down