Skip to content

Commit

Permalink
[Fleet + Integrations UI] Integrations UI Cleanup (elastic#104641)
Browse files Browse the repository at this point in the history
* Remove Beta wording from Fleet messaging in ingestion tutorials

* Rename fleet feature registration to include integrations

* Pluralize + sentence case assets and expand dashboards by default

* Update global search from packages -> integrations

* Expand auth settings by default in package policy add agent flyout

* Update wording for various fleet modules

* Fix i18n

* Fix unit test

* Fix failing tests
# Conflicts:
#	x-pack/plugins/translations/translations/ja-JP.json
#	x-pack/plugins/translations/translations/zh-CN.json
  • Loading branch information
kpollich committed Jul 7, 2021
1 parent 8b4cc2d commit 5021530
Show file tree
Hide file tree
Showing 1,071 changed files with 59,146 additions and 10,099 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ConfigSchema = schema.object({

export type ActionParamsType = TypeOf<typeof ParamsSchema>;

// see: https://www.elastic.co/guide/en/elastic-stack-overview/current/actions-index.html
// see: https://www.elastic.co/guide/en/elasticsearch/reference/current/actions-index.html
// - timeout not added here, as this seems to be a generic thing we want to do
// eventually: https://github.com/elastic/kibana/projects/26#card-24087404
const ParamsSchema = schema.object({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class ActionsPlugin implements Plugin<PluginSetupContract, PluginStartCon
private readonly kibanaIndexConfig: { kibana: { index: string } };

constructor(initContext: PluginInitializerContext) {
this.logger = initContext.logger.get('actions');
this.logger = initContext.logger.get();
this.actionsConfig = getValidatedConfig(
this.logger,
resolveCustomHosts(this.logger, initContext.config.get<ActionsConfig>())
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/alerting/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class AlertingPlugin {

constructor(initializerContext: PluginInitializerContext) {
this.config = initializerContext.config.create<AlertsConfig>().pipe(first()).toPromise();
this.logger = initializerContext.logger.get('plugins', 'alerting');
this.logger = initializerContext.logger.get();
this.taskRunnerFactory = new TaskRunnerFactory();
this.alertsClientFactory = new AlertsClientFactory();
this.alertingAuthorizationClientFactory = new AlertingAuthorizationClientFactory();
Expand Down
11 changes: 7 additions & 4 deletions x-pack/plugins/apm/common/elasticsearch_fieldnames.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/

import { get } from 'lodash';
import { AllowUnknownProperties } from '../typings/common';
import { APMError } from '../typings/es_schemas/ui/apm_error';
import { Span } from '../typings/es_schemas/ui/span';
import { Transaction } from '../typings/es_schemas/ui/transaction';
import * as fieldnames from './elasticsearch_fieldnames';

describe('Transaction', () => {
const transaction: Transaction = {
const transaction: AllowUnknownProperties<Transaction> = {
'@timestamp': new Date().toString(),
'@metadata': 'whatever',
observer: {
Expand Down Expand Up @@ -69,7 +70,7 @@ describe('Transaction', () => {
});

describe('Span', () => {
const span: Span = {
const span: AllowUnknownProperties<Span> = {
'@timestamp': new Date().toString(),
'@metadata': 'whatever',
observer: {
Expand Down Expand Up @@ -123,7 +124,7 @@ describe('Span', () => {
});

describe('Error', () => {
const errorDoc: APMError = {
const errorDoc: AllowUnknownProperties<APMError> = {
'@metadata': 'whatever',
observer: {
name: 'an observer',
Expand Down Expand Up @@ -185,7 +186,9 @@ describe('Error', () => {
matchSnapshot(errorDoc);
});

function matchSnapshot(obj: Span | Transaction | APMError) {
function matchSnapshot(
obj: AllowUnknownProperties<Span | Transaction | APMError>
) {
Object.entries(fieldnames).forEach(([key, longKey]) => {
const value = get(obj, longKey);
it(key, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Updating functional tests archives

Some of our API tests use an archive generated by the [`esarchiver`](https://www.elastic.co/guide/en/kibana/current/development-functional-tests.html) script. Updating the main archive (`apm_8.0.0`) is a scripted process, where a 30m snapshot is downloaded from a cluster running the [APM Integration Testing server](https://github.com/elastic/apm-integration-testing). The script will copy the generated archives into the `fixtures/es_archiver` folders of our test suites (currently `basic` and `trial`). It will also generate a file that contains metadata about the archive, that can be imported to get the time range of the snapshot.
Some of our API tests use an archive generated by the [`esarchiver`](https://www.elastic.co/guide/en/kibana/current/development-tests.html#development-functional-tests) script. Updating the main archive (`apm_8.0.0`) is a scripted process, where a 30m snapshot is downloaded from a cluster running the [APM Integration Testing server](https://github.com/elastic/apm-integration-testing). The script will copy the generated archives into the `fixtures/es_archiver` folders of our test suites (currently `basic` and `trial`). It will also generate a file that contains metadata about the archive, that can be imported to get the time range of the snapshot.

Usage:
`node x-pack/plugins/apm/scripts/create-functional-tests-archive --es-url=https://admin:changeme@localhost:9200 --kibana-url=https://localhost:5601`
Expand Down
10 changes: 2 additions & 8 deletions x-pack/plugins/apm/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@
],
"server": true,
"ui": true,
"configPath": [
"xpack",
"apm"
],
"extraPublicDirs": [
"public/style/variables"
],
"configPath": ["xpack", "apm"],
"requiredBundles": [
"fleet",
"home",
Expand All @@ -44,4 +38,4 @@
"ml",
"observability"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { MockUrlParamsContextProvider } from '../../../context/url_params_context/mock_url_params_context_provider';

export default {
title: 'app/TransactionDurationAlertTrigger',
title: 'alerting/TransactionDurationAlertTrigger',
component: TransactionDurationAlertTrigger,
decorators: [
(Story: ComponentType) => {
Expand All @@ -26,7 +26,7 @@ export default {
http: {
get: (endpoint: string) => {
if (endpoint === '/api/apm/environments') {
return Promise.resolve(['production']);
return Promise.resolve({ environments: ['production'] });
} else {
return Promise.resolve({
transactionTypes: ['request'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import {
EuiDescribedFormGroup,
EuiSelectOption,
EuiFormRow,
} from '@elastic/eui';
import { SelectWithPlaceholder } from '../../../../../shared/SelectWithPlaceholder';

interface Props {
title: string;
description: string;
fieldLabel: string;
isLoading: boolean;
options?: EuiSelectOption[];
value?: string;
disabled: boolean;
onChange: (event: React.ChangeEvent<HTMLSelectElement>) => void;
}

export function FormRowSelect({
title,
description,
fieldLabel,
isLoading,
options,
value,
disabled,
onChange,
}: Props) {
return (
<EuiDescribedFormGroup
fullWidth
title={<h3>{title}</h3>}
description={description}
>
<EuiFormRow label={fieldLabel}>
<SelectWithPlaceholder
isLoading={isLoading}
options={options}
value={value}
disabled={disabled}
onChange={onChange}
/>
</EuiFormRow>
</EuiDescribedFormGroup>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiButton } from '@elastic/eui';
import React from 'react';
import { i18n } from '@kbn/i18n';
import { isString } from 'lodash';
import { EuiButtonEmpty } from '@elastic/eui';
import { AgentConfigurationIntake } from '../../../../../../../common/agent_configuration/configuration_types';
import {
omitAllOption,
getOptionLabel,
} from '../../../../../../../common/agent_configuration/all_option';
import { useFetcher, FETCH_STATUS } from '../../../../../../hooks/use_fetcher';
import { FormRowSelect } from './FormRowSelect';
import { APMLink } from '../../../../../shared/Links/apm/APMLink';

interface Props {
newConfig: AgentConfigurationIntake;
setNewConfig: React.Dispatch<React.SetStateAction<AgentConfigurationIntake>>;
onClickNext: () => void;
}

export function ServicePage({ newConfig, setNewConfig, onClickNext }: Props) {
const { data: serviceNamesData, status: serviceNamesStatus } = useFetcher(
(callApmApi) => {
return callApmApi({
endpoint: 'GET /api/apm/settings/agent-configuration/services',
isCachable: true,
});
},
[],
{ preservePreviousData: false }
);
const serviceNames = serviceNamesData?.serviceNames ?? [];

const { data: environmentsData, status: environmentsStatus } = useFetcher(
(callApmApi) => {
if (newConfig.service.name) {
return callApmApi({
endpoint: 'GET /api/apm/settings/agent-configuration/environments',
params: {
query: { serviceName: omitAllOption(newConfig.service.name) },
},
});
}
},
[newConfig.service.name],
{ preservePreviousData: false }
);

const environments = environmentsData?.environments ?? [];

const { status: agentNameStatus } = useFetcher(
async (callApmApi) => {
const serviceName = newConfig.service.name;

if (!isString(serviceName) || serviceName.length === 0) {
return;
}

const { agentName } = await callApmApi({
endpoint: 'GET /api/apm/settings/agent-configuration/agent_name',
params: { query: { serviceName } },
});

setNewConfig((prev) => ({ ...prev, agent_name: agentName }));
},
[newConfig.service.name, setNewConfig]
);

const ALREADY_CONFIGURED_TRANSLATED = i18n.translate(
'xpack.apm.agentConfig.servicePage.alreadyConfiguredOption',
{ defaultMessage: 'already configured' }
);

const serviceNameOptions = serviceNames.map((name) => ({
text: getOptionLabel(name),
value: name,
}));
const environmentOptions = environments.map(
({ name, alreadyConfigured }) => ({
disabled: alreadyConfigured,
text: `${getOptionLabel(name)} ${
alreadyConfigured ? `(${ALREADY_CONFIGURED_TRANSLATED})` : ''
}`,
value: name,
})
);

return (
<>
{/* Service name options */}
<FormRowSelect
title={i18n.translate(
'xpack.apm.agentConfig.servicePage.service.title',
{ defaultMessage: 'Service' }
)}
description={i18n.translate(
'xpack.apm.agentConfig.servicePage.service.description',
{ defaultMessage: 'Choose the service you want to configure.' }
)}
fieldLabel={i18n.translate(
'xpack.apm.agentConfig.servicePage.service.fieldLabel',
{ defaultMessage: 'Service name' }
)}
isLoading={serviceNamesStatus === FETCH_STATUS.LOADING}
options={serviceNameOptions}
value={newConfig.service.name}
disabled={serviceNamesStatus === FETCH_STATUS.LOADING}
onChange={(e) => {
e.preventDefault();
const name = e.target.value;
setNewConfig((prev) => ({
...prev,
service: { name, environment: '' },
}));
}}
/>

{/* Environment options */}
<FormRowSelect
title={i18n.translate(
'xpack.apm.agentConfig.servicePage.environment.title',
{ defaultMessage: 'Environment' }
)}
description={i18n.translate(
'xpack.apm.agentConfig.servicePage.environment.description',
{
defaultMessage:
'Only a single environment per configuration is supported.',
}
)}
fieldLabel={i18n.translate(
'xpack.apm.agentConfig.servicePage.environment.fieldLabel',
{ defaultMessage: 'Service environment' }
)}
isLoading={environmentsStatus === FETCH_STATUS.LOADING}
options={environmentOptions}
value={newConfig.service.environment}
disabled={
!newConfig.service.name || environmentsStatus === FETCH_STATUS.LOADING
}
onChange={(e) => {
e.preventDefault();
const environment = e.target.value;
setNewConfig((prev) => ({
...prev,
service: { name: prev.service.name, environment },
}));
}}
/>

<EuiSpacer />

<EuiFlexGroup justifyContent="flexEnd">
{/* Cancel button */}
<EuiFlexItem grow={false}>
<APMLink path="/settings/agent-configuration">
<EuiButtonEmpty color="primary">
{i18n.translate(
'xpack.apm.agentConfig.servicePage.cancelButton',
{ defaultMessage: 'Cancel' }
)}
</EuiButtonEmpty>
</APMLink>
</EuiFlexItem>

{/* Next button */}
<EuiFlexItem grow={false}>
<EuiButton
type="submit"
fill
onClick={onClickNext}
isLoading={agentNameStatus === FETCH_STATUS.LOADING}
isDisabled={
!newConfig.service.name ||
!newConfig.service.environment ||
agentNameStatus === FETCH_STATUS.LOADING
}
>
{i18n.translate(
'xpack.apm.agentConfig.saveConfigurationButtonLabel',
{ defaultMessage: 'Next step' }
)}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</>
);
}
Loading

0 comments on commit 5021530

Please sign in to comment.