1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { Paper, StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core';
7 import { SearchView } from '~/store/search-bar/search-bar-reducer';
9 SearchBarRecentQueries,
10 SearchBarRecentQueriesActionProps
11 } from '~/views-components/search-bar/search-bar-recent-queries';
13 SearchBarSavedQueries,
14 SearchBarSavedQueriesDataProps,
15 SearchBarSavedQueriesActionProps
16 } from '~/views-components/search-bar/search-bar-save-queries';
18 type CssRules = 'advanced' | 'label' | 'root';
20 const styles: StyleRulesCallback<CssRules> = theme => {
23 color: theme.palette.common.black,
24 borderRadius: `0 0 ${theme.spacing.unit / 2}px ${theme.spacing.unit / 2}px`
28 justifyContent: 'flex-end',
29 padding: theme.spacing.unit,
32 color: theme.palette.primary.main
36 padding: `${theme.spacing.unit}px ${theme.spacing.unit}px `,
37 color: theme.palette.grey["900"],
38 background: theme.palette.grey["200"]
43 export type SearchBarBasicViewDataProps = SearchBarSavedQueriesDataProps;
45 export type SearchBarBasicViewActionProps = {
46 onSetView: (currentView: string) => void;
47 onSearch: (searchValue: string) => void;
48 } & SearchBarRecentQueriesActionProps & SearchBarSavedQueriesActionProps;
50 type SearchBarBasicViewProps = SearchBarBasicViewDataProps & SearchBarBasicViewActionProps & WithStyles<CssRules>;
52 export const SearchBarBasicView = withStyles(styles)(
53 ({ classes, onSetView, loadRecentQueries, deleteSavedQuery, savedQueries, onSearch, editSavedQuery, selectedItem }: SearchBarBasicViewProps) =>
54 <Paper className={classes.root}>
55 <div className={classes.label}>Recent search queries</div>
56 <SearchBarRecentQueries
58 loadRecentQueries={loadRecentQueries}
59 selectedItem={selectedItem} />
60 <div className={classes.label}>Saved search queries</div>
61 <SearchBarSavedQueries
63 savedQueries={savedQueries}
64 editSavedQuery={editSavedQuery}
65 deleteSavedQuery={deleteSavedQuery}
66 selectedItem={selectedItem} />
67 <div className={classes.advanced} onClick={() => onSetView(SearchView.ADVANCED)}>Advanced search</div>