mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* navtree.go: update Data sources title and subtitle * DataSourceList: move add button to header * DataSourcesList: add buttons to items The action buttons are added inside `<Card.Tags>` so that they end up at the right end of the card, as it was designed. The "Build a Dashboard" button's functionality is not defined yet. * DataSourcesListHeader: add sort picker * fix css * tests: look for the updated "Add new data source" text * tests: use an async test method to verify component updates are wrapped in an act() * update e2e selector for add data source button * fix DataSourceList{,Page} tests * add comment for en dash character * simplify sorting * add link to Build a Dashboard button * fix test * test build a dashboard and explore buttons * test sorting data source elements * DataSourceAddButton: hide button when user has no permission * PageActionBar: remove unneeded '?' * DataSourcesList: hide explore button if user has no permission * DataSourcesListPage.test: make setup prop explicit * DataSourcesList: use theme.spacing * datasources: assure explore url includes appSubUrl * fix tests and add test case for missing permissions Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
|
|
import { SelectableValue } from '@grafana/data';
|
|
import { LinkButton, FilterInput } from '@grafana/ui';
|
|
|
|
import { SortPicker } from '../Select/SortPicker';
|
|
|
|
export interface Props {
|
|
searchQuery: string;
|
|
setSearchQuery: (value: string) => void;
|
|
linkButton?: { href: string; title: string; disabled?: boolean };
|
|
target?: string;
|
|
placeholder?: string;
|
|
sortPicker?: {
|
|
onChange: (sortValue: SelectableValue) => void;
|
|
value?: string;
|
|
getSortOptions?: () => Promise<SelectableValue[]>;
|
|
};
|
|
}
|
|
|
|
export default class PageActionBar extends PureComponent<Props> {
|
|
render() {
|
|
const {
|
|
searchQuery,
|
|
linkButton,
|
|
setSearchQuery,
|
|
target,
|
|
placeholder = 'Search by name or type',
|
|
sortPicker,
|
|
} = this.props;
|
|
const linkProps: typeof LinkButton.defaultProps = { href: linkButton?.href, disabled: linkButton?.disabled };
|
|
|
|
if (target) {
|
|
linkProps.target = target;
|
|
}
|
|
|
|
return (
|
|
<div className="page-action-bar">
|
|
<div className="gf-form gf-form--grow">
|
|
<FilterInput value={searchQuery} onChange={setSearchQuery} placeholder={placeholder} />
|
|
</div>
|
|
{sortPicker && (
|
|
<SortPicker
|
|
onChange={sortPicker.onChange}
|
|
value={sortPicker.value}
|
|
getSortOptions={sortPicker.getSortOptions}
|
|
/>
|
|
)}
|
|
{linkButton && <LinkButton {...linkProps}>{linkButton.title}</LinkButton>}
|
|
</div>
|
|
);
|
|
}
|
|
}
|