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, List } from '@material-ui/core';
7 import { SearchView } from '~/store/search-bar/search-bar-reducer';
8 import { RecentQueriesItem, RenderSavedQueries } from '~/views-components/search-bar/search-bar-view';
10 type CssRules = 'advanced' | 'searchQueryList' | 'list' | 'searchView';
12 const styles: StyleRulesCallback<CssRules> = theme => {
16 justifyContent: 'flex-end',
17 paddingRight: theme.spacing.unit * 2,
18 paddingBottom: theme.spacing.unit,
21 color: theme.palette.primary.main
24 padding: `${theme.spacing.unit / 2}px ${theme.spacing.unit}px `,
25 background: '#f2f2f2',
32 color: theme.palette.common.black,
33 borderRadius: `0 0 ${theme.spacing.unit / 2}px ${theme.spacing.unit / 2}px`
38 interface SearchBarBasicViewProps {
39 setView: (currentView: string) => void;
40 recentQueries: () => string[];
41 deleteSavedQuery: (id: number) => void;
42 savedQueries: string[];
45 export const SearchBarBasicView = withStyles(styles)(
46 ({ classes, setView, recentQueries, deleteSavedQuery, savedQueries }: SearchBarBasicViewProps & WithStyles<CssRules>) =>
47 <Paper className={classes.searchView}>
48 <div className={classes.searchQueryList}>Recent search queries</div>
49 <List component="nav" className={classes.list}>
50 {recentQueries().map((query, index) => <RecentQueriesItem key={index} text={query} />)}
52 <div className={classes.searchQueryList}>Saved search queries</div>
53 <List component="nav" className={classes.list}>
54 {savedQueries.map((query, index) => <RenderSavedQueries key={index} text={query} id={index} deleteSavedQuery={deleteSavedQuery} />)}
56 <div className={classes.advanced} onClick={() => setView(SearchView.ADVANCED)}>Advanced search</div>