Skip to content

Commit

Permalink
Merge branch 'master' into chore/cypress-context
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jan 7, 2021
2 parents 219823f + 130a8e7 commit 142d65a
Show file tree
Hide file tree
Showing 43 changed files with 567 additions and 311 deletions.
24 changes: 24 additions & 0 deletions src/plugins/home/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"common/**/*",
"public/**/*",
"server/**/*",
"config.ts",
],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../data/tsconfig.json" },
{ "path": "../kibana_react/tsconfig.json" },
{ "path": "../url_forwarding/tsconfig.json" },
{ "path": "../usage_collection/tsconfig.json" },
{ "path": "../telemetry/tsconfig.json" },
]
}
18 changes: 18 additions & 0 deletions src/plugins/saved_objects_tagging_oss/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"common/**/*",
"public/**/*",
],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../saved_objects/tsconfig.json" },
]
}
19 changes: 19 additions & 0 deletions test/functional/page_objects/dashboard_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
const dashboardAddPanel = getService('dashboardAddPanel');
const renderable = getService('renderable');
const listingTable = getService('listingTable');
const elasticChart = getService('elasticChart');
const PageObjects = getPageObjects(['common', 'header', 'visualize']);

interface SaveDashboardOptions {
Expand Down Expand Up @@ -275,6 +276,20 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
}
}

public async isColorSyncOn() {
log.debug('isColorSyncOn');
await this.openOptions();
return await testSubjects.getAttribute('dashboardSyncColorsCheckbox', 'checked');
}

public async useColorSync(on = true) {
await this.openOptions();
const isColorSyncOn = await this.isColorSyncOn();
if (isColorSyncOn !== 'on') {
return await testSubjects.click('dashboardSyncColorsCheckbox');
}
}

public async gotoDashboardEditMode(dashboardName: string) {
await this.loadSavedDashboard(dashboardName);
await this.switchToEditMode();
Expand Down Expand Up @@ -554,6 +569,10 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
return 0;
}
}

public async getPanelChartDebugState(panelIndex: number) {
return await elasticChart.getChartDebugData(undefined, panelIndex);
}
}

return new DashboardPage();
Expand Down
17 changes: 12 additions & 5 deletions test/functional/services/visualizations/elastic_chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,23 @@ export function ElasticChartProvider({ getService }: FtrProviderContext) {
}
}

private async getChart(dataTestSubj?: string, timeout?: number): Promise<WebElementWrapper> {
private async getChart(
dataTestSubj?: string,
timeout?: number,
match: number = 0
): Promise<WebElementWrapper> {
if (dataTestSubj) {
if (!(await testSubjects.exists(dataTestSubj, { timeout }))) {
throw Error(`Failed to find an elastic-chart with testSubject '${dataTestSubj}'`);
}

return await testSubjects.find(dataTestSubj);
return (await testSubjects.findAll(dataTestSubj))[match];
} else {
const charts = await this.getAllCharts(timeout);
if (charts.length === 0) {
throw Error(`Failed to find any elastic-charts on the page`);
} else {
return charts[0];
return charts[match];
}
}
}
Expand All @@ -106,8 +110,11 @@ export function ElasticChartProvider({ getService }: FtrProviderContext) {
* used to get chart data from `@elastic/charts`
* requires `window._echDebugStateFlag` to be true
*/
public async getChartDebugData(dataTestSubj?: string): Promise<DebugState | null> {
const chart = await this.getChart(dataTestSubj);
public async getChartDebugData(
dataTestSubj?: string,
match: number = 0
): Promise<DebugState | null> {
const chart = await this.getChart(dataTestSubj, undefined, match);

try {
const visContainer = await chart.findByCssSelector('.echChartStatus');
Expand Down
2 changes: 2 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
{ "path": "../src/plugins/bfetch/tsconfig.json" },
{ "path": "../src/plugins/embeddable/tsconfig.json" },
{ "path": "../src/plugins/expressions/tsconfig.json" },
{ "path": "../src/plugins/home/tsconfig.json" },
{ "path": "../src/plugins/inspector/tsconfig.json" },
{ "path": "../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../src/plugins/kibana_usage_collection/tsconfig.json" },
{ "path": "../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../src/plugins/navigation/tsconfig.json" },
{ "path": "../src/plugins/newsfeed/tsconfig.json" },
{ "path": "../src/plugins/saved_objects/tsconfig.json" },
{ "path": "../src/plugins/saved_objects_tagging_oss/tsconfig.json" },
{ "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" },
{ "path": "../src/plugins/telemetry/tsconfig.json" },
{ "path": "../src/plugins/ui_actions/tsconfig.json" },
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"src/plugins/dev_tools/**/*",
"src/plugins/embeddable/**/*",
"src/plugins/expressions/**/*",
"src/plugins/home/**/*",
"src/plugins/inspector/**/*",
"src/plugins/kibana_legacy/**/*",
"src/plugins/kibana_react/**/*",
Expand All @@ -21,6 +22,7 @@
"src/plugins/newsfeed/**/*",
"src/plugins/saved_objects/**/*",
"src/plugins/security_oss/**/*",
"src/plugins/saved_objects_tagging_oss/**/*",
"src/plugins/share/**/*",
"src/plugins/telemetry/**/*",
"src/plugins/telemetry_collection_manager/**/*",
Expand All @@ -40,6 +42,7 @@
{ "path": "./src/plugins/dev_tools/tsconfig.json" },
{ "path": "./src/plugins/embeddable/tsconfig.json" },
{ "path": "./src/plugins/expressions/tsconfig.json" },
{ "path": "./src/plugins/home/tsconfig.json" },
{ "path": "./src/plugins/inspector/tsconfig.json" },
{ "path": "./src/plugins/kibana_legacy/tsconfig.json" },
{ "path": "./src/plugins/kibana_react/tsconfig.json" },
Expand All @@ -48,6 +51,7 @@
{ "path": "./src/plugins/navigation/tsconfig.json" },
{ "path": "./src/plugins/newsfeed/tsconfig.json" },
{ "path": "./src/plugins/saved_objects/tsconfig.json" },
{ "path": "./src/plugins/saved_objects_tagging_oss/tsconfig.json" },
{ "path": "./src/plugins/security_oss/tsconfig.json" },
{ "path": "./src/plugins/share/tsconfig.json" },
{ "path": "./src/plugins/telemetry/tsconfig.json" },
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.refs.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{ "path": "./src/plugins/dev_tools/tsconfig.json" },
{ "path": "./src/plugins/embeddable/tsconfig.json" },
{ "path": "./src/plugins/expressions/tsconfig.json" },
{ "path": "./src/plugins/home/tsconfig.json" },
{ "path": "./src/plugins/inspector/tsconfig.json" },
{ "path": "./src/plugins/kibana_legacy/tsconfig.json" },
{ "path": "./src/plugins/kibana_react/tsconfig.json" },
Expand All @@ -15,6 +16,7 @@
{ "path": "./src/plugins/navigation/tsconfig.json" },
{ "path": "./src/plugins/newsfeed/tsconfig.json" },
{ "path": "./src/plugins/saved_objects/tsconfig.json" },
{ "path": "./src/plugins/saved_objects_tagging_oss/tsconfig.json" },
{ "path": "./src/plugins/security_oss/tsconfig.json" },
{ "path": "./src/plugins/share/tsconfig.json" },
{ "path": "./src/plugins/telemetry/tsconfig.json" },
Expand Down
45 changes: 25 additions & 20 deletions x-pack/plugins/alerts/server/invalidate_pending_api_keys/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SavedObjectsClientContract,
} from 'kibana/server';
import { EncryptedSavedObjectsClient } from '../../../encrypted_saved_objects/server';
import { InvalidateAPIKeyParams, SecurityPluginStart } from '../../../security/server';
import { InvalidateAPIKeysParams, SecurityPluginStart } from '../../../security/server';
import {
RunContext,
TaskManagerSetupContract,
Expand All @@ -27,8 +27,8 @@ import { InvalidatePendingApiKey } from '../types';
const TASK_TYPE = 'alerts_invalidate_api_keys';
export const TASK_ID = `Alerts-${TASK_TYPE}`;

const invalidateAPIKey = async (
params: InvalidateAPIKeyParams,
const invalidateAPIKeys = async (
params: InvalidateAPIKeysParams,
securityPluginStart?: SecurityPluginStart
): Promise<InvalidateAPIKeyResult> => {
if (!securityPluginStart) {
Expand Down Expand Up @@ -193,30 +193,35 @@ async function invalidateApiKeys(
encryptedSavedObjectsClient: EncryptedSavedObjectsClient,
securityPluginStart?: SecurityPluginStart
) {
// TODO: This could probably send a single request to ES now that the invalidate API supports multiple ids in a single request
let totalInvalidated = 0;
await Promise.all(
const apiKeyIds = await Promise.all(
apiKeysToInvalidate.saved_objects.map(async (apiKeyObj) => {
const decryptedApiKey = await encryptedSavedObjectsClient.getDecryptedAsInternalUser<InvalidatePendingApiKey>(
'api_key_pending_invalidation',
apiKeyObj.id
);
const apiKeyId = decryptedApiKey.attributes.apiKeyId;
const response = await invalidateAPIKey({ id: apiKeyId }, securityPluginStart);
if (response.apiKeysEnabled === true && response.result.error_count > 0) {
logger.error(`Failed to invalidate API Key [id="${apiKeyObj.attributes.apiKeyId}"]`);
} else {
try {
await savedObjectsClient.delete('api_key_pending_invalidation', apiKeyObj.id);
totalInvalidated++;
} catch (err) {
logger.error(
`Failed to cleanup api key "${apiKeyObj.attributes.apiKeyId}". Error: ${err.message}`
);
}
}
return decryptedApiKey.attributes.apiKeyId;
})
);
logger.debug(`Total invalidated api keys "${totalInvalidated}"`);
if (apiKeyIds.length > 0) {
const response = await invalidateAPIKeys({ ids: apiKeyIds }, securityPluginStart);
if (response.apiKeysEnabled === true && response.result.error_count > 0) {
logger.error(`Failed to invalidate API Keys [ids="${apiKeyIds.join(', ')}"]`);
} else {
await Promise.all(
apiKeysToInvalidate.saved_objects.map(async (apiKeyObj) => {
try {
await savedObjectsClient.delete('api_key_pending_invalidation', apiKeyObj.id);
totalInvalidated++;
} catch (err) {
logger.error(
`Failed to delete invalidated API key "${apiKeyObj.attributes.apiKeyId}". Error: ${err.message}`
);
}
})
);
}
}
logger.debug(`Total invalidated API keys "${totalInvalidated}"`);
return totalInvalidated;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { Transaction } from '../../../../../../../typings/es_schemas/ui/transaction';
import { TransactionDetailLink } from '../../../../../shared/Links/apm/TransactionDetailLink';
import { StickyProperties } from '../../../../../shared/StickyProperties';
import { ServiceOrTransactionsOverviewLink } from '../../../../../shared/Links/apm/service_transactions_overview';
import { ServiceOrTransactionsOverviewLink } from '../../../../../shared/Links/apm/service_transactions_overview_link';

interface Props {
transaction?: Transaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { NOT_AVAILABLE_LABEL } from '../../../../../../../../common/i18n';
import { Span } from '../../../../../../../../typings/es_schemas/ui/span';
import { StickyProperties } from '../../../../../../shared/StickyProperties';
import { ServiceOrTransactionsOverviewLink } from '../../../../../../shared/Links/apm/service_transactions_overview';
import { ServiceOrTransactionsOverviewLink } from '../../../../../../shared/Links/apm/service_transactions_overview_link';
import { TransactionDetailLink } from '../../../../../../shared/Links/apm/TransactionDetailLink';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import React, { ReactNode } from 'react';
import { isJavaAgentName, isRumAgentName } from '../../../../common/agent_name';
import { enableServiceOverview } from '../../../../common/ui_settings_keys';
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';
import { useApmServiceContext } from '../../../context/apm_service/use_apm_service_context';
import { useErrorOverviewHref } from '../../shared/Links/apm/ErrorOverviewLink';
import { useMetricOverviewHref } from '../../shared/Links/apm/MetricOverviewLink';
import { useServiceMapHref } from '../../shared/Links/apm/ServiceMapLink';
import { useServiceNodeOverviewHref } from '../../shared/Links/apm/ServiceNodeOverviewLink';
import { useServiceOverviewHref } from '../../shared/Links/apm/service_overview_link';
import { useServiceOrTransactionsOverviewHref } from '../../shared/Links/apm/service_transactions_overview';
import { useTransactionsOverviewHref } from '../../shared/Links/apm/transaction_overview_link';
import { MainTabs } from '../../shared/main_tabs';
import { ErrorGroupOverview } from '../ErrorGroupOverview';
import { ServiceMap } from '../ServiceMap';
import { ServiceMetrics } from '../service_metrics';
import { ServiceNodeOverview } from '../ServiceNodeOverview';
import { ServiceMetrics } from '../service_metrics';
import { ServiceOverview } from '../service_overview';
import { TransactionOverview } from '../transaction_overview';
import { useApmServiceContext } from '../../../context/apm_service/use_apm_service_context';

interface Tab {
key: string;
Expand Down Expand Up @@ -60,7 +60,7 @@ export function ServiceDetailTabs({ serviceName, tab }: Props) {

const transactionsTab = {
key: 'transactions',
href: useServiceOrTransactionsOverviewHref(serviceName),
href: useTransactionsOverviewHref(serviceName),
text: i18n.translate('xpack.apm.serviceDetails.transactionsTabLabel', {
defaultMessage: 'Transactions',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { NOT_AVAILABLE_LABEL } from '../../../../../common/i18n';
import { fontSizes, px, truncate, unit } from '../../../../style/variables';
import { ManagedTable, ITableColumn } from '../../../shared/ManagedTable';
import { EnvironmentBadge } from '../../../shared/EnvironmentBadge';
import { ServiceOrTransactionsOverviewLink } from '../../../shared/Links/apm/service_transactions_overview';
import { ServiceOrTransactionsOverviewLink } from '../../../shared/Links/apm/service_transactions_overview_link';
import { AgentIcon } from '../../../shared/AgentIcon';
import { HealthBadge } from './HealthBadge';
import { ServiceListMetric } from './ServiceListMetric';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { px, unit } from '../../../../style/variables';
import { SparkPlot } from '../../../shared/charts/spark_plot';
import { ImpactBar } from '../../../shared/ImpactBar';
import { TransactionDetailLink } from '../../../shared/Links/apm/TransactionDetailLink';
import { TransactionOverviewLink } from '../../../shared/Links/apm/transaction_overview_ink';
import { TransactionOverviewLink } from '../../../shared/Links/apm/transaction_overview_link';
import { TableFetchWrapper } from '../../../shared/table_fetch_wrapper';
import { TruncateWithTooltip } from '../../../shared/truncate_with_tooltip';
import { ServiceOverviewTableContainer } from '../service_overview_table_container';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { EuiLink } from '@elastic/eui';
import React from 'react';
import { pickKeys } from '../../../../../common/utils/pick_keys';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { APMQueryParams } from '../url_helpers';
import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink';
import { APMLinkExtendProps, useAPMHref } from './APMLink';

const persistedFilters: Array<keyof APMQueryParams> = [
'host',
Expand All @@ -25,13 +24,6 @@ interface Props extends APMLinkExtendProps {
}

export function MetricOverviewLink({ serviceName, ...rest }: Props) {
const { urlParams } = useUrlParams();

return (
<APMLink
path={`/services/${serviceName}/metrics`}
query={pickKeys(urlParams as APMQueryParams, ...persistedFilters)}
{...rest}
/>
);
const href = useMetricOverviewHref(serviceName);
return <EuiLink href={href} {...rest} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { EuiLink } from '@elastic/eui';
import React from 'react';
import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink';

function pathFor(serviceName?: string) {
return serviceName ? `/services/${serviceName}/service-map` : '/service-map';
}
import { APMLinkExtendProps, useAPMHref } from './APMLink';

export function useServiceMapHref(serviceName?: string) {
return useAPMHref(pathFor(serviceName));
const pathFor = serviceName
? `/services/${serviceName}/service-map`
: '/service-map';
return useAPMHref(pathFor);
}

interface ServiceMapLinkProps extends APMLinkExtendProps {
serviceName?: string;
}

export function ServiceMapLink({ serviceName, ...rest }: ServiceMapLinkProps) {
const path = pathFor(serviceName);
return <APMLink path={path} {...rest} />;
const href = useServiceMapHref(serviceName);
return <EuiLink href={href} {...rest} />;
}
Loading

0 comments on commit 142d65a

Please sign in to comment.