Skip to content

Commit

Permalink
Restyled by prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed Dec 17, 2019
1 parent 45e958b commit 01b5613
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
48 changes: 25 additions & 23 deletions client/app/pages/queries/QueryView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,33 @@ import useVisualizationTabHandler from "./utils/useVisualizationTabHandler";
function QueryView(props) {
const [query, setQuery] = useState(props.query);
const [selectedTab, setSelectedTab] = useVisualizationTabHandler(query.visualizations);
const currentVisualization = useMemo(() => find(query.visualizations, { id: selectedTab }), [query.visualizations, selectedTab])
const currentVisualization = useMemo(() => find(query.visualizations, { id: selectedTab }), [
query.visualizations,
selectedTab,
]);
const parameters = useMemo(() => query.getParametersDefs(), [query]);
const [dataSource, setDataSource] = useState();
const queryResult = useMemo(() => query.getQueryResult(), [query]);
const queryResultData = useQueryResult(queryResult);

const saveDescription = useCallback(
(description) => {
description => {
recordEvent("edit_description", "query", query.id);
saveQuery(query, { description }).then(setQuery);
},
[query],
[query]
);

const openVisualizationEditor = useCallback(
() => {
EditVisualizationDialog.showModal({
query,
visualization: currentVisualization,
queryResult,
}).result.then(visualization => {
setSelectedTab(visualization.id);
// TODO: Properly update state
});
},
[currentVisualization, query, queryResult, setSelectedTab],
);
const openVisualizationEditor = useCallback(() => {
EditVisualizationDialog.showModal({
query,
visualization: currentVisualization,
queryResult,
}).result.then(visualization => {
setSelectedTab(visualization.id);
// TODO: Properly update state
});
}, [currentVisualization, query, queryResult, setSelectedTab]);

useEffect(() => {
DataSource.get({ id: query.data_source_id }).$promise.then(setDataSource);
Expand Down Expand Up @@ -99,7 +99,8 @@ function QueryView(props) {
)}
<span className="flex-fill" />
<div className="query-property">
<i className="zmdi zmdi-refresh m-r-5" />Refresh Schedule
<i className="zmdi zmdi-refresh m-r-5" />
Refresh Schedule
<a className="clickable m-l-5">
<SchedulePhrase schedule={query.schedule} isNew={false} />
</a>
Expand All @@ -124,11 +125,13 @@ function QueryView(props) {
queryResult={queryResult}
queryExecuting={false} /* TODO: Replace with executing state */
showEmbedDialog={() => EmbedQueryDialog.showEmbedDialog({ query, visualization: currentVisualization })}
openAddToDashboardForm={() => AddToDashboardDialog.showModal({
visualization: currentVisualization,
})}
openAddToDashboardForm={() =>
AddToDashboardDialog.showModal({
visualization: currentVisualization,
})
}
/>
{(queryResult && queryResultData) && (
{queryResult && queryResultData && (
<>
<span className="m-l-10">
<strong>{queryResultData.rows.length}</strong> {pluralize("row", queryResultData.rows.length)}
Expand All @@ -142,8 +145,7 @@ function QueryView(props) {
<span className="flex-fill" />
{queryResult && (
<span className="m-r-10 hidden-xs">
Updated{" "}
<TimeAgo date={queryResult.query_result.retrieved_at} />
Updated <TimeAgo date={queryResult.query_result.retrieved_at} />
</span>
)}
<Button type="primary">Execute</Button>
Expand Down
10 changes: 8 additions & 2 deletions client/app/pages/queries/components/QueryVisualizationTabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ import Button from "antd/lib/button";

const { TabPane } = Tabs;

export default function QueryVisualizationTabs({ visualizations, queryResult, selectedTab,
showNewVisualizationButton, onChangeTab, onClickNewVisualization }) {
export default function QueryVisualizationTabs({
visualizations,
queryResult,
selectedTab,
showNewVisualizationButton,
onChangeTab,
onClickNewVisualization,
}) {
const tabsProps = {};
if (find(visualizations, { id: selectedTab })) {
tabsProps.activeKey = `${selectedTab}`;
Expand Down

0 comments on commit 01b5613

Please sign in to comment.