Skip to content

Commit

Permalink
Merge branch 'master' into ml-data-grid-column-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Apr 1, 2020
2 parents f410799 + 7975765 commit 5cb9a73
Show file tree
Hide file tree
Showing 288 changed files with 5,369 additions and 1,622 deletions.
2 changes: 1 addition & 1 deletion docs/canvas/canvas-elements.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ By default, most of the elements you create use demo data until you change the d

* *{es} SQL* — Access your data in {es} using SQL syntax. For information about SQL syntax, refer to {ref}/sql-spec.html[SQL language].

* *{es} raw data* — Access your raw data in {es} without the use of aggregations. Use {es} raw data when you have low volume datasets, or to plot exact, non-aggregated values.
* *{es} documents* &mdash; Access your data in {es} without using aggregations. To use, select an index and fields, and optionally enter a query using the <<lucene-query,Lucene Query Syntax>>. Use the *{es} documents* data source when you have low volume datasets, to view raw documents, or to plot exact, non-aggregated values on a chart.

* *Timelion* &mdash; Access your time series data using <<timelion,Timelion>> queries. To use Timelion queries, you can enter a query using the <<lucene-query,Lucene Query Syntax>>.

Expand Down
4 changes: 1 addition & 3 deletions examples/alerting_example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./target",
"skipLibCheck": true,
"resolveJsonModule": true
"outDir": "./target"
},
"include": [
"index.ts",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"@babel/register": "^7.9.0",
"@elastic/apm-rum": "^4.6.0",
"@elastic/charts": "^18.1.1",
"@elastic/datemath": "5.0.2",
"@elastic/datemath": "5.0.3",
"@elastic/ems-client": "7.7.1",
"@elastic/eui": "21.0.1",
"@elastic/filesaver": "1.1.2",
Expand Down
2 changes: 2 additions & 0 deletions packages/elastic-datemath/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
/test
/tsconfig.json
/.babelrc
/yarn.lock
/__tests__
5 changes: 5 additions & 0 deletions packages/elastic-datemath/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# datemath

Datemath string parser used in Kibana. This is published to NPM for use in a limited number of locations outside of Kibana, but is not regularly updated and may get seriously out of date.

If you file an issue in elastic/kibana we can probably update it for you if needed, though you probably shouldn't depend on this package for anything important.
2 changes: 1 addition & 1 deletion packages/elastic-datemath/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elastic/datemath",
"version": "5.0.2",
"version": "5.0.3",
"description": "elasticsearch datemath parser, used in kibana",
"license": "Apache-2.0",
"main": "target/index.js",
Expand Down
3 changes: 0 additions & 3 deletions packages/elastic-datemath/readme.md

This file was deleted.

8 changes: 8 additions & 0 deletions src/dev/ci_setup/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ echo " -- TEST_ES_SNAPSHOT_VERSION='$TEST_ES_SNAPSHOT_VERSION'"
echo " -- installing node.js dependencies"
yarn kbn bootstrap --prefer-offline

###
### Download es snapshots
###
echo " -- downloading es snapshot"
node scripts/es snapshot --download-only;
node scripts/es snapshot --license=oss --download-only;


###
### verify no git modifications
###
Expand Down
3 changes: 2 additions & 1 deletion test/functional/apps/context/_discover_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default function({ getService, getPageObjects }) {
const filterBar = getService('filterBar');
const PageObjects = getPageObjects(['common', 'discover', 'timePicker']);

describe('context link in discover', function contextSize() {
// FLAKY: https://github.com/elastic/kibana/issues/53308
describe.skip('context link in discover', function contextSize() {
this.tags('smoke');
before(async function() {
await PageObjects.common.navigateToApp('discover');
Expand Down
3 changes: 2 additions & 1 deletion test/functional/apps/discover/_field_visualize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
defaultIndex: 'logstash-*',
};

describe('discover field visualize button', () => {
// FLAKY: https://github.com/elastic/kibana/issues/61714
describe.skip('discover field visualize button', () => {
before(async function() {
log.debug('load kibana index with default index pattern');
await esArchiver.load('discover');
Expand Down
3 changes: 0 additions & 3 deletions test/scripts/jenkins_build_kibana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ node scripts/build_kibana_platform_plugins \
# doesn't persist, also set in kibanaPipeline.groovy
export KBN_NP_PLUGINS_BUILT=true

echo " -> downloading es snapshot"
node scripts/es snapshot --license=oss --download-only;

echo " -> Ensuring all functional tests are in a ciGroup"
yarn run grunt functionalTests:ensureAllTestsInCiGroup;

Expand Down
3 changes: 0 additions & 3 deletions test/scripts/jenkins_xpack_build_kibana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ node scripts/build_kibana_platform_plugins \
# doesn't persist, also set in kibanaPipeline.groovy
export KBN_NP_PLUGINS_BUILT=true

echo " -> downloading es snapshot"
node scripts/es snapshot --download-only;

echo " -> Ensuring all functional tests are in a ciGroup"
cd "$XPACK_DIR"
node scripts/functional_tests --assert-none-excluded \
Expand Down
25 changes: 25 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ declare module '*.html' {
export default template;
}

declare module '*.png' {
const content: string;
// eslint-disable-next-line import/no-default-export
export default content;
}

declare module '*.svg' {
const content: string;
// eslint-disable-next-line import/no-default-export
export default content;
}

// allow JSON files to be imported directly without lint errors
// see: https://github.com/palantir/tslint/issues/1264#issuecomment-228433367
// and: https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#arbitrary-expressions-are-forbidden-in-export-assignments-in-ambient-contexts
declare module '*.json' {
const json: any;
// eslint-disable-next-line import/no-default-export
export default json;
}

type MethodKeysOf<T> = {
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
}[keyof T];
Expand All @@ -37,3 +58,7 @@ type DeeplyMockedKeys<T> = {
: DeeplyMockedKeys<T[P]>;
} &
T;

type Writable<T> = {
-readonly [K in keyof T]: T[K];
};
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"xpack.features": "plugins/features",
"xpack.fileUpload": "plugins/file_upload",
"xpack.graph": ["legacy/plugins/graph", "plugins/graph"],
"xpack.grokDebugger": "legacy/plugins/grokdebugger",
"xpack.grokDebugger": "plugins/grokdebugger",
"xpack.idxMgmt": "plugins/index_management",
"xpack.indexLifecycleMgmt": "legacy/plugins/index_lifecycle_management",
"xpack.infra": "plugins/infra",
Expand Down
2 changes: 0 additions & 2 deletions x-pack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { monitoring } from './legacy/plugins/monitoring';
import { reporting } from './legacy/plugins/reporting';
import { security } from './legacy/plugins/security';
import { tilemap } from './legacy/plugins/tilemap';
import { grokdebugger } from './legacy/plugins/grokdebugger';
import { dashboardMode } from './legacy/plugins/dashboard_mode';
import { logstash } from './legacy/plugins/logstash';
import { beats } from './legacy/plugins/beats_management';
Expand Down Expand Up @@ -44,7 +43,6 @@ module.exports = function(kibana) {
spaces(kibana),
security(kibana),
tilemap(kibana),
grokdebugger(kibana),
dashboardMode(kibana),
logstash(kibana),
beats(kibana),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export function ServiceDetails({ tab }: Props) {
const canSaveAlerts = !!plugin.core.application.capabilities.apm[
'alerting:save'
];
const isAlertingPluginEnabled = 'alerting' in plugin.plugins;

const isAlertingAvailable = canReadAlerts || canSaveAlerts;
const isAlertingAvailable =
isAlertingPluginEnabled && (canReadAlerts || canSaveAlerts);

return (
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
const license = useLicense();
const { urlParams } = useUrlParams();

const { data } = useFetcher(() => {
const { data = { elements: [] } } = useFetcher(() => {
// When we don't have a license or a valid license, don't make the request.
if (!license || !isValidPlatinumLicense(license)) {
return;
}

const { start, end, environment } = urlParams;
if (start && end) {
return callApmApi({
Expand All @@ -48,7 +53,7 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
}
});
}
}, [serviceName, urlParams]);
}, [license, serviceName, urlParams]);

const { ref, height, width } = useRefDimensions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const FiltersSection = ({
</EuiFlexItem>
<EuiFlexItem>
<EuiFieldText
data-test-subj={`value-${idx}`}
data-test-subj={`${key}.value`}
fullWidth
placeholder={i18n.translate(
'xpack.apm.settings.customizeUI.customLink.flyOut.filters.defaultOption.value',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useState } from 'react';
import {
CustomLink,
Filter
} from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
import { Filter } from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
import { useApmPluginContext } from '../../../../../../hooks/useApmPluginContext';
import { FiltersSection } from './FiltersSection';
import { FlyoutFooter } from './FlyoutFooter';
Expand All @@ -28,27 +25,32 @@ import { Documentation } from './Documentation';

interface Props {
onClose: () => void;
customLinkSelected?: CustomLink;
onSave: () => void;
onDelete: () => void;
defaults?: {
url?: string;
label?: string;
filters?: Filter[];
};
customLinkId?: string;
}

const filtersEmptyState: Filter[] = [{ key: '', value: '' }];

export const CustomLinkFlyout = ({
onClose,
customLinkSelected,
onSave,
onDelete
onDelete,
defaults,
customLinkId
}: Props) => {
const { toasts } = useApmPluginContext().core.notifications;
const [isSaving, setIsSaving] = useState(false);

const [label, setLabel] = useState(customLinkSelected?.label || '');
const [url, setUrl] = useState(customLinkSelected?.url || '');
const selectedFilters = customLinkSelected?.filters;
const [label, setLabel] = useState(defaults?.label || '');
const [url, setUrl] = useState(defaults?.url || '');
const [filters, setFilters] = useState(
selectedFilters?.length
? selectedFilters
: ([{ key: '', value: '' }] as Filter[])
defaults?.filters?.length ? defaults.filters : filtersEmptyState
);

const isFormValid = !!label && !!url;
Expand All @@ -61,7 +63,7 @@ export const CustomLinkFlyout = ({
event.preventDefault();
setIsSaving(true);
await saveCustomLink({
id: customLinkSelected?.id,
id: customLinkId,
label,
url,
filters,
Expand Down Expand Up @@ -131,7 +133,7 @@ export const CustomLinkFlyout = ({
onClose={onClose}
isSaving={isSaving}
onDelete={onDelete}
customLinkId={customLinkSelected?.id}
customLinkId={customLinkId}
/>
</EuiFlyout>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export const CustomLinkOverview = () => {
{isFlyoutOpen && (
<CustomLinkFlyout
onClose={onCloseFlyout}
customLinkSelected={customLinkSelected}
defaults={customLinkSelected}
customLinkId={customLinkSelected?.id}
onSave={() => {
onCloseFlyout();
refetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import { EuiButtonEmpty } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { FunctionComponent, useMemo, useState } from 'react';
import {
CustomLink as CustomLinkType,
Filter
} from '../../../../../../../plugins/apm/common/custom_link/custom_link_types';
import { Filter } from '../../../../../../../plugins/apm/common/custom_link/custom_link_types';
import { Transaction } from '../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
import {
ActionMenu,
Expand Down Expand Up @@ -68,7 +65,7 @@ export const TransactionActionMenu: FunctionComponent<Props> = ({
{ key: 'service.environment', value: transaction?.service.environment },
{ key: 'transaction.name', value: transaction?.transaction.name },
{ key: 'transaction.type', value: transaction?.transaction.type }
] as Filter[],
].filter((filter): filter is Filter => typeof filter.value === 'string'),
[transaction]
);

Expand Down Expand Up @@ -100,7 +97,7 @@ export const TransactionActionMenu: FunctionComponent<Props> = ({
<>
{isCustomLinkFlyoutOpen && (
<CustomLinkFlyout
customLinkSelected={{ filters: { ...filters } } as CustomLinkType}
defaults={{ filters }}
onClose={toggleCustomLinkFlyout}
onSave={() => {
toggleCustomLinkFlyout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as hooks from '../../../../hooks/useFetcher';
import { LicenseContext } from '../../../../context/LicenseContext';
import { License } from '../../../../../../../../plugins/licensing/common/license';
import { MockApmPluginContextWrapper } from '../../../../context/ApmPluginContext/MockApmPluginContext';
import * as apmApi from '../../../../services/rest/createCallApmApi';

const renderTransaction = async (transaction: Record<string, any>) => {
const rendered = render(
Expand Down Expand Up @@ -142,6 +143,12 @@ describe('TransactionActionMenu component', () => {
});

describe('Custom links', () => {
beforeAll(() => {
spyOn(apmApi, 'callApmApi').and.returnValue({});
});
afterAll(() => {
jest.resetAllMocks();
});
it('doesnt show custom links when license is not valid', () => {
const license = new License({
signature: 'test signature',
Expand Down Expand Up @@ -250,5 +257,53 @@ describe('TransactionActionMenu component', () => {
});
expectTextsInDocument(component, ['Custom Links']);
});
it('opens flyout with filters prefilled', () => {
const license = new License({
signature: 'test signature',
license: {
expiryDateInMillis: 0,
mode: 'gold',
status: 'active',
type: 'gold',
uid: '1'
}
});
const component = render(
<LicenseContext.Provider value={license}>
<MockApmPluginContextWrapper>
<TransactionActionMenu
transaction={
Transactions.transactionWithMinimalData as Transaction
}
/>
</MockApmPluginContextWrapper>
</LicenseContext.Provider>
);
act(() => {
fireEvent.click(component.getByText('Actions'));
});
expectTextsInDocument(component, ['Custom Links']);
act(() => {
fireEvent.click(component.getByText('Create custom link'));
});
expectTextsInDocument(component, ['Create link']);
const getFilterKeyValue = (key: string) => {
return {
[(component.getAllByText(key)[0] as HTMLOptionElement)
.text]: (component.getAllByTestId(
`${key}.value`
)[0] as HTMLInputElement).value
};
};
expect(getFilterKeyValue('service.name')).toEqual({
'service.name': 'opbeans-go'
});
expect(getFilterKeyValue('transaction.name')).toEqual({
'transaction.name': 'GET /api/products/:id/customers'
});
expect(getFilterKeyValue('transaction.type')).toEqual({
'transaction.type': 'request'
});
});
});
});
Loading

0 comments on commit 5cb9a73

Please sign in to comment.