Skip to content

Commit 12a59f0

Browse files
committed
add save-as option to query panel
1 parent caafd7d commit 12a59f0

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

packages/core/components/QuerySidebar/QueryFooter.tsx

+51
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as React from "react";
44
import { useDispatch, useSelector } from "react-redux";
55

66
import { TertiaryButton } from "../Buttons";
7+
import { ContextualMenuItemType } from "../ContextMenu";
78
import { ModalType } from "../Modal";
89
import Tutorial from "../../entity/Tutorial";
910
import { interaction, selection } from "../../state";
@@ -23,6 +24,8 @@ interface Props {
2324
export default function QueryFooter(props: Props) {
2425
const dispatch = useDispatch();
2526

27+
const fileFilters = useSelector(selection.selectors.getFileFilters);
28+
const isQueryingAicsFms = useSelector(selection.selectors.isQueryingAicsFms);
2629
const url = useSelector(selection.selectors.getEncodedFileExplorerUrl);
2730

2831
const isEmptyQuery = !props.query.parts.sources.length;
@@ -69,6 +72,47 @@ export default function QueryFooter(props: Props) {
6972
onClick: props.onQueryDelete,
7073
},
7174
];
75+
const saveQueryAsOptions: IContextualMenuItem[] = [
76+
{
77+
key: "Save query header",
78+
text: "DATA SOURCE TYPES",
79+
title: "Types of data sources available for export",
80+
itemType: ContextualMenuItemType.Header,
81+
},
82+
{
83+
key: "csv",
84+
text: "CSV",
85+
title: "Download a CSV containing the results of the current query",
86+
onClick() {
87+
dispatch(interaction.actions.showManifestDownloadDialog("csv", fileFilters));
88+
},
89+
},
90+
// Can't download JSON or Parquet files when querying AICS FMS
91+
...(isQueryingAicsFms
92+
? []
93+
: [
94+
{
95+
key: "json",
96+
text: "JSON",
97+
title: "Download a JSON file containing the result of the current query",
98+
onClick() {
99+
dispatch(
100+
interaction.actions.showManifestDownloadDialog("json", fileFilters)
101+
);
102+
},
103+
},
104+
{
105+
key: "parquet",
106+
text: "Parquet",
107+
title: "Download a Parquet file containing the result of the current query",
108+
onClick() {
109+
dispatch(
110+
interaction.actions.showManifestDownloadDialog("parquet", fileFilters)
111+
);
112+
},
113+
},
114+
]),
115+
];
72116

73117
const onRefresh = throttle(
74118
() => {
@@ -80,6 +124,13 @@ export default function QueryFooter(props: Props) {
80124

81125
return (
82126
<div className={styles.container}>
127+
<TertiaryButton
128+
invertColor
129+
disabled={isEmptyQuery}
130+
iconName="Saveas"
131+
menuItems={saveQueryAsOptions}
132+
title="Save query result as..."
133+
/>
83134
<TertiaryButton
84135
invertColor
85136
disabled={isEmptyQuery}

0 commit comments

Comments
 (0)