@@ -4,6 +4,7 @@ import * as React from "react";
4
4
import { useDispatch , useSelector } from "react-redux" ;
5
5
6
6
import { TertiaryButton } from "../Buttons" ;
7
+ import { ContextualMenuItemType } from "../ContextMenu" ;
7
8
import { ModalType } from "../Modal" ;
8
9
import Tutorial from "../../entity/Tutorial" ;
9
10
import { interaction , selection } from "../../state" ;
@@ -23,6 +24,8 @@ interface Props {
23
24
export default function QueryFooter ( props : Props ) {
24
25
const dispatch = useDispatch ( ) ;
25
26
27
+ const fileFilters = useSelector ( selection . selectors . getFileFilters ) ;
28
+ const isQueryingAicsFms = useSelector ( selection . selectors . isQueryingAicsFms ) ;
26
29
const url = useSelector ( selection . selectors . getEncodedFileExplorerUrl ) ;
27
30
28
31
const isEmptyQuery = ! props . query . parts . sources . length ;
@@ -69,6 +72,47 @@ export default function QueryFooter(props: Props) {
69
72
onClick : props . onQueryDelete ,
70
73
} ,
71
74
] ;
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
+ ] ;
72
116
73
117
const onRefresh = throttle (
74
118
( ) => {
@@ -80,6 +124,13 @@ export default function QueryFooter(props: Props) {
80
124
81
125
return (
82
126
< div className = { styles . container } >
127
+ < TertiaryButton
128
+ invertColor
129
+ disabled = { isEmptyQuery }
130
+ iconName = "Saveas"
131
+ menuItems = { saveQueryAsOptions }
132
+ title = "Save query result as..."
133
+ />
83
134
< TertiaryButton
84
135
invertColor
85
136
disabled = { isEmptyQuery }
0 commit comments