Skip to content

Commit

Permalink
Closes elastic#83663 by adding a prepend label to the search bar in s…
Browse files Browse the repository at this point in the history
…ervice overview (elastic#86143) (elastic#86298)
  • Loading branch information
ogupte authored Dec 17, 2020
1 parent a5d6faf commit 74c2ebc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
*/

import { EuiFlexGroup, EuiFlexItem, EuiPage, EuiPanel } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { useTrackPageview } from '../../../../../observability/public';
import { isRumAgentName } from '../../../../common/agent_name';
import { AnnotationsContextProvider } from '../../../context/annotations/annotations_context';
import { useApmServiceContext } from '../../../context/apm_service/use_apm_service_context';
import { ChartPointerEventContextProvider } from '../../../context/chart_pointer_event/chart_pointer_event_context';
import { LatencyChart } from '../../shared/charts/latency_chart';
import { TransactionBreakdownChart } from '../../shared/charts/transaction_breakdown_chart';
Expand Down Expand Up @@ -38,10 +40,16 @@ export function ServiceOverview({
useTrackPageview({ app: 'apm', path: 'service_overview' });
useTrackPageview({ app: 'apm', path: 'service_overview', delay: 15000 });

const { transactionType } = useApmServiceContext();
const transactionTypeLabel = i18n.translate(
'xpack.apm.serviceOverview.searchBar.transactionTypeLabel',
{ defaultMessage: 'Type: {transactionType}', values: { transactionType } }
);

return (
<AnnotationsContextProvider>
<ChartPointerEventContextProvider>
<SearchBar />
<SearchBar prepend={transactionTypeLabel} />
<EuiPage>
<EuiFlexGroup direction="column" gutterSize="s">
<EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,13 @@ export class Typeahead extends Component {
};

render() {
const { placeholder } = this.props;
const {
disabled,
isLoading,
placeholder,
prepend,
suggestions,
} = this.props;

return (
<ClickOutside
Expand All @@ -175,17 +181,18 @@ export class Typeahead extends Component {
this.inputRef = node;
}
}}
disabled={this.props.disabled}
disabled={disabled}
value={this.state.value}
onKeyDown={this.onKeyDown}
onKeyUp={this.onKeyUp}
onChange={this.onChangeInputValue}
onClick={this.onClickInput}
autoComplete="off"
spellCheck={false}
prepend={prepend}
/>

{this.props.isLoading && (
{isLoading && (
<EuiProgress
size="xs"
color="accent"
Expand All @@ -200,7 +207,7 @@ export class Typeahead extends Component {

<Suggestions
show={this.state.isSuggestionsVisible}
suggestions={this.props.suggestions}
suggestions={suggestions}
index={this.state.index}
onClick={this.onClickSuggestion}
onMouseEnter={this.onMouseEnterSuggestion}
Expand All @@ -218,6 +225,7 @@ Typeahead.propTypes = {
onSubmit: PropTypes.func.isRequired,
suggestions: PropTypes.array.isRequired,
placeholder: PropTypes.string.isRequired,
prepend: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
};

Typeahead.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function convertKueryToEsQuery(kuery: string, indexPattern: IIndexPattern) {
return esKuery.toElasticsearchQuery(ast, indexPattern);
}

export function KueryBar() {
export function KueryBar(props: { prepend?: React.ReactNode | string }) {
const { groupId, serviceName } = useParams<{
groupId?: string;
serviceName?: string;
Expand Down Expand Up @@ -152,6 +152,7 @@ export function KueryBar() {
onSubmit={onSubmit}
suggestions={state.suggestions}
placeholder={placeholder}
prepend={props.prepend}
/>
</Container>
);
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/apm/public/components/shared/search_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const SearchBarFlexGroup = styled(EuiFlexGroup)`
`${theme.eui.euiSizeM} ${theme.eui.euiSizeM} -${theme.eui.gutterTypes.gutterMedium} ${theme.eui.euiSizeM}`};
`;

export function SearchBar() {
export function SearchBar(props: { prepend?: React.ReactNode | string }) {
return (
<SearchBarFlexGroup alignItems="flexStart" gutterSize="s">
<EuiFlexItem grow={3}>
<KueryBar />
<KueryBar prepend={props.prepend} />
</EuiFlexItem>
<EuiFlexItem grow={1}>
<DatePicker />
Expand Down

0 comments on commit 74c2ebc

Please sign in to comment.