Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.11] Closes #83663 by adding a prepend label to the search bar in service overview (#86143) #86298

Merged
merged 1 commit into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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