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 5be69ab commit 5bc7dcd
Showing 1 changed file with 25 additions and 23 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);
updateQuery(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(() => {
document.title = query.name;
Expand Down Expand Up @@ -103,7 +103,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 @@ -128,11 +129,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 @@ -146,8 +149,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

0 comments on commit 5bc7dcd

Please sign in to comment.