// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import React from 'react'; import { CustomStyleRulesCallback } from 'common/custom-theme'; import { withStyles, WithStyles, List, ListItem, ListItemText, ListItemSecondaryAction, Tooltip, IconButton } from '@material-ui/core'; import { ArvadosTheme } from 'common/custom-theme'; import { RemoveIcon, EditSavedQueryIcon } from 'components/icon/icon'; import { SearchBarAdvancedFormData } from 'models/search-bar'; import { SearchBarSelectedItem } from "store/search-bar/search-bar-reducer"; import { getQueryFromAdvancedData } from "store/search-bar/search-bar-actions"; type CssRules = 'root' | 'listItem' | 'listItemText' | 'button'; const styles: CustomStyleRulesCallback = (theme: ArvadosTheme) => ({ root: { padding: '0px' }, listItem: { paddingLeft: theme.spacing(1), paddingRight: theme.spacing(2) }, listItemText: { fontSize: '0.8125rem', color: theme.palette.grey["900"] }, button: { padding: '6px', marginRight: theme.spacing(1) } }); export interface SearchBarSavedQueriesDataProps { savedQueries: SearchBarAdvancedFormData[]; selectedItem: SearchBarSelectedItem; } export interface SearchBarSavedQueriesActionProps { onSearch: (searchValue: string) => void; deleteSavedQuery: (id: number) => void; editSavedQuery: (data: SearchBarAdvancedFormData, id: number) => void; } type SearchBarSavedQueriesProps = SearchBarSavedQueriesDataProps & SearchBarSavedQueriesActionProps & WithStyles; export const SearchBarSavedQueries = withStyles(styles)( ({ classes, savedQueries, onSearch, editSavedQuery, deleteSavedQuery, selectedItem }: SearchBarSavedQueriesProps) => {savedQueries.map((query, index) => onSearch(getQueryFromAdvancedData(query))} className={classes.listItemText} /> editSavedQuery(query, index)} className={classes.button}> deleteSavedQuery(index)} className={classes.button}> )} );