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

[CSM] Url search #77516

Merged
merged 34 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6bc0adf
WIp
shahzad31 Sep 14, 2020
1ec079d
Merge branch 'master' into url-search
shahzad31 Sep 15, 2020
860053b
add url search
shahzad31 Sep 15, 2020
b9acb06
Merge branch 'master' into url-search
shahzad31 Sep 15, 2020
c48e591
added test for url search
shahzad31 Sep 16, 2020
b1426d5
Merge branch 'master' into url-search
shahzad31 Sep 16, 2020
d146242
added a button
shahzad31 Sep 16, 2020
1aad1c4
Merge branch 'master' into url-search
shahzad31 Sep 16, 2020
88ed419
added query
shahzad31 Sep 17, 2020
b0f52bf
fix type
shahzad31 Sep 17, 2020
17a9627
Merge branch 'master' into url-search
shahzad31 Sep 17, 2020
a592dcf
improve test
shahzad31 Sep 17, 2020
691440f
update test and states
shahzad31 Sep 17, 2020
10ce21d
fix type
shahzad31 Sep 17, 2020
04f1637
improve formatting
shahzad31 Sep 17, 2020
eecc7ee
fix type
shahzad31 Sep 17, 2020
58b37b0
Merge branch 'master' into url-search
elasticmachine Sep 18, 2020
ba134db
Update x-pack/plugins/apm/e2e/cypress/integration/csm_dashboard.feature
shahzad31 Sep 18, 2020
a71619c
Update x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm/ur…
shahzad31 Sep 18, 2020
6d06c0e
Update x-pack/plugins/apm/e2e/cypress/integration/csm_dashboard.feature
shahzad31 Sep 18, 2020
4f80373
Update x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm/ur…
shahzad31 Sep 18, 2020
1c2859b
Merge branch 'master' into url-search
shahzad31 Sep 18, 2020
ecfc910
update label
shahzad31 Sep 18, 2020
fbd9ec8
Merge branch 'url-search' of https://github.com/shahzad31/kibana into…
shahzad31 Sep 18, 2020
5d00c79
reduce concurrency
shahzad31 Sep 18, 2020
90124f4
improve code owners
shahzad31 Sep 18, 2020
1897bd3
Merge branch 'master' into url-search
shahzad31 Sep 21, 2020
00d7283
update test
shahzad31 Sep 21, 2020
9551efe
fix broken e2e
shahzad31 Sep 21, 2020
a0ca1e1
Merge branch 'master' into url-search
shahzad31 Sep 21, 2020
a5c8775
update usage of selectable
shahzad31 Sep 22, 2020
369b505
type fix
shahzad31 Sep 22, 2020
ed58bd1
imrpove e2e test
shahzad31 Sep 22, 2020
7dbcc4b
Merge branch 'master' into url-search
shahzad31 Sep 23, 2020
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
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@

# Client Side Monitoring (lives in APM directories but owned by Uptime)
/x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm @elastic/uptime
/x-pack/plugins/apm/e2e/cypress/integration/csm_dashboard.feature @elastic/uptime
/x-pack/plugins/apm/public/application/csmApp.tsx @elastic/uptime
/x-pack/plugins/apm/public/components/app/RumDashboard @elastic/uptime
/x-pack/plugins/apm/server/lib/rum_client @elastic/uptime
/x-pack/plugins/apm/server/routes/rum_client.ts @elastic/uptime
/x-pack/plugins/apm/server/projections/rum_overview.ts @elastic/uptime
/x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts @elastic/uptime

# Beats
/x-pack/legacy/plugins/beats_management/ @elastic/beats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ Feature: CSM Dashboard
Given a user clicks the page load breakdown filter
When the user selected the breakdown
Then breakdown series should appear in chart

Scenario: Search by url filter focus
When a user clicks inside url search field
Then it displays top pages in the suggestion popover

Scenario: Search by url filter
When a user enters a query in url search field
Then it should filter results based on query
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { When, Then } from 'cypress-cucumber-preprocessor/steps';
import { DEFAULT_TIMEOUT } from './csm_dashboard';

When(`a user clicks inside url search field`, () => {
// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
cy.get('.euiStat__title-isLoading').should('not.be.visible');
cy.get('span[data-cy=csmUrlFilter]', DEFAULT_TIMEOUT).within(() => {
cy.get('input.euiFieldSearch').click();
});
});

Then(`it displays top pages in the suggestion popover`, () => {
cy.get('kbnLoadingIndicator').should('not.be.visible');

cy.get('div.euiPopover__panel-isOpen', DEFAULT_TIMEOUT).within(() => {
const listOfUrls = cy.get('li.euiSelectableListItem');
listOfUrls.should('have.length', 5);

const actualUrlsText = [
'http://opbeans-node:3000/dashboardPage views: 17Page load duration: 109 ms ',
'http://opbeans-node:3000/ordersPage views: 14Page load duration: 72 ms',
];

cy.get('li.euiSelectableListItem')
.eq(0)
.should('have.text', actualUrlsText[0]);
cy.get('li.euiSelectableListItem')
.eq(1)
.should('have.text', actualUrlsText[1]);
});
});

When(`a user enters a query in url search field`, () => {
cy.get('kbnLoadingIndicator').should('not.be.visible');

cy.get('[data-cy=csmUrlFilter]').within(() => {
cy.get('input.euiSelectableSearch').type('cus');
});

cy.get('kbnLoadingIndicator').should('not.be.visible');
});

Then(`it should filter results based on query`, () => {
cy.get('kbnLoadingIndicator').should('not.be.visible');

cy.get('div.euiPopover__panel-isOpen', DEFAULT_TIMEOUT).within(() => {
const listOfUrls = cy.get('li.euiSelectableListItem');
listOfUrls.should('have.length', 1);

const actualUrlsText = [
'http://opbeans-node:3000/customersPage views: 10Page load duration: 76 ms ',
];

cy.get('li.euiSelectableListItem')
.eq(0)
.should('have.text', actualUrlsText[0]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ClFlexGroup = styled(EuiFlexGroup)`
export function ClientMetrics() {
const { urlParams, uiFilters } = useUrlParams();

const { start, end } = urlParams;
const { start, end, searchTerm } = urlParams;

const { data, status } = useFetcher(
(callApmApi) => {
Expand All @@ -31,13 +31,18 @@ export function ClientMetrics() {
return callApmApi({
pathname: '/api/apm/rum/client-metrics',
params: {
query: { start, end, uiFilters: JSON.stringify(uiFilters) },
query: {
start,
end,
uiFilters: JSON.stringify(uiFilters),
urlQuery: searchTerm,
},
},
});
}
return Promise.resolve(null);
},
[start, end, uiFilters]
[start, end, uiFilters, searchTerm]
);

const STAT_STYLE = { width: '240px' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface PercentileRange {
export function PageLoadDistribution() {
const { urlParams, uiFilters } = useUrlParams();

const { start, end } = urlParams;
const { start, end, searchTerm } = urlParams;

const [percentileRange, setPercentileRange] = useState<PercentileRange>({
min: null,
Expand All @@ -41,6 +41,7 @@ export function PageLoadDistribution() {
start,
end,
uiFilters: JSON.stringify(uiFilters),
urlQuery: searchTerm,
...(percentileRange.min && percentileRange.max
? {
minPercentile: String(percentileRange.min),
Expand All @@ -53,7 +54,14 @@ export function PageLoadDistribution() {
}
return Promise.resolve(null);
},
[end, start, uiFilters, percentileRange.min, percentileRange.max]
[
end,
start,
uiFilters,
percentileRange.min,
percentileRange.max,
searchTerm,
]
);

const onPercentileChange = (min: number, max: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface Props {
export const useBreakdowns = ({ percentileRange, field, value }: Props) => {
const { urlParams, uiFilters } = useUrlParams();

const { start, end } = urlParams;
const { start, end, searchTerm } = urlParams;

const { min: minP, max: maxP } = percentileRange ?? {};

Expand All @@ -32,6 +32,7 @@ export const useBreakdowns = ({ percentileRange, field, value }: Props) => {
end,
breakdown: value,
uiFilters: JSON.stringify(uiFilters),
urlQuery: searchTerm,
...(minP && maxP
? {
minPercentile: String(minP),
Expand All @@ -43,6 +44,6 @@ export const useBreakdowns = ({ percentileRange, field, value }: Props) => {
});
}
},
[end, start, uiFilters, field, value, minP, maxP]
[end, start, uiFilters, field, value, minP, maxP, searchTerm]
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { BreakdownItem } from '../../../../../typings/ui_filters';
export function PageViewsTrend() {
const { urlParams, uiFilters } = useUrlParams();

const { start, end } = urlParams;
const { start, end, searchTerm } = urlParams;

const [breakdown, setBreakdown] = useState<BreakdownItem | null>(null);

Expand All @@ -30,6 +30,7 @@ export function PageViewsTrend() {
start,
end,
uiFilters: JSON.stringify(uiFilters),
urlQuery: searchTerm,
...(breakdown
? {
breakdowns: JSON.stringify(breakdown),
Expand All @@ -41,7 +42,7 @@ export function PageViewsTrend() {
}
return Promise.resolve(undefined);
},
[end, start, uiFilters, breakdown]
[end, start, uiFilters, breakdown, searchTerm]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
import { i18n } from '@kbn/i18n';
import React, { useEffect, useCallback } from 'react';
import { useHistory } from 'react-router-dom';
import { useUrlParams } from '../../../../hooks/useUrlParams';
import { fromQuery, toQuery } from '../../Links/url_helpers';
import { useUrlParams } from '../../../../../hooks/useUrlParams';
import { fromQuery, toQuery } from '../../../../shared/Links/url_helpers';

interface Props {
serviceNames: string[];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React, { ReactNode } from 'react';
import classNames from 'classnames';
import { EuiHighlight, EuiSelectableOption } from '@elastic/eui';
import styled from 'styled-components';
import euiLightVars from '@elastic/eui/dist/eui_theme_light.json';

const StyledSpan = styled.span`
color: ${euiLightVars.euiColorSecondaryText};
font-weight: 500;
:not(:last-of-type)::after {
content: '•';
margin: 0 4px;
}
`;

const StyledListSpan = styled.span`
display: block;
margin-top: 4px;
font-size: 12px;
`;
export type UrlOption<T = { [key: string]: any }> = {
meta?: string[];
} & EuiSelectableOption<T>;

export const formatOptions = (options: EuiSelectableOption[]) => {
return options.map((item: EuiSelectableOption) => ({
title: item.label,
...item,
className: classNames(
'euiSelectableTemplateSitewide__listItem',
item.className
),
}));
};

export function selectableRenderOptions(
option: UrlOption,
searchValue: string
) {
return (
<>
<EuiHighlight
className="euiSelectableTemplateSitewide__listItemTitle"
search={searchValue}
>
{option.label}
</EuiHighlight>
{renderOptionMeta(option.meta)}
</>
);
}

function renderOptionMeta(meta?: string[]): ReactNode {
if (!meta || meta.length < 1) return;
return (
<StyledListSpan>
{meta.map((item: string) => (
<StyledSpan key={item}>{item}</StyledSpan>
))}
</StyledListSpan>
);
}
Loading