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

[APM] Create settings page to manage Custom Links #57788

Merged
merged 42 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d477e82
creating custom action index
cauemarcondes Feb 17, 2020
f1fe01a
reverting service form to service section
cauemarcondes Feb 17, 2020
0618007
creating useForm hooks and fields section
cauemarcondes Feb 19, 2020
d27587f
adding react-hook-form
cauemarcondes Feb 20, 2020
e49853b
refactoring
cauemarcondes Feb 20, 2020
32efd3f
validating filters
cauemarcondes Feb 20, 2020
1f2680c
fixing imports
cauemarcondes Feb 20, 2020
2475234
refactoring to NP and creating save custom action
cauemarcondes Feb 20, 2020
5c48f49
creating basic apis for custom actions
cauemarcondes Feb 21, 2020
a1e4df9
refactoring
cauemarcondes Feb 21, 2020
541a627
changing custom action filters type
cauemarcondes Feb 24, 2020
b2e5fff
adding delete option
cauemarcondes Feb 24, 2020
1d19694
removing useForm
cauemarcondes Feb 24, 2020
f9ef63a
fixing flyout view
cauemarcondes Feb 24, 2020
e4f8bdf
filters are invalid when selecting the default value
cauemarcondes Feb 24, 2020
df3dbb9
ui fixes
cauemarcondes Feb 24, 2020
5b9d7f3
ui fixes
cauemarcondes Feb 24, 2020
dc3d4e2
fixing typescript
cauemarcondes Feb 24, 2020
3925c67
fixing typescript
cauemarcondes Feb 24, 2020
b86e0cd
fixing labels and adding space btw components
cauemarcondes Feb 24, 2020
11c77e2
refactoring filters structure
cauemarcondes Feb 25, 2020
920b5be
removing reach-hook-form
cauemarcondes Feb 25, 2020
0fd2e22
removing reach-hook-form
cauemarcondes Feb 25, 2020
59c5c37
adding unit tests
cauemarcondes Feb 25, 2020
cf9edd5
adding unit tests
cauemarcondes Feb 28, 2020
0752379
create custom action index
cauemarcondes Feb 28, 2020
5ed863d
adding filter option
cauemarcondes Feb 28, 2020
6fb638f
refactoring create index, creating filter links
cauemarcondes Feb 28, 2020
5f65c1e
creating list api
cauemarcondes Mar 2, 2020
2d07b7d
rename custom action to custom link
cauemarcondes Mar 2, 2020
30ba7c5
fixing unit tests
cauemarcondes Mar 2, 2020
8e8bfc6
adding unit tests
cauemarcondes Mar 2, 2020
5f4e999
refactoring callApmApi
cauemarcondes Mar 3, 2020
5f17093
removing useCallApmApi hook
cauemarcondes Mar 3, 2020
f045527
Rename Flyoutfooter.tsx to FlyoutFooter.tsx
cauemarcondes Mar 4, 2020
0059e25
removing unused import
cauemarcondes Mar 4, 2020
de2b225
fixing typescript errors
cauemarcondes Mar 4, 2020
78c2cfb
fixing duplicate messages
cauemarcondes Mar 4, 2020
0ef4514
removing filters
cauemarcondes Mar 5, 2020
01d5196
fixing save functionality
cauemarcondes Mar 5, 2020
718fdf5
fixing pr comments
cauemarcondes Mar 5, 2020
6933e8d
fixing pr comments
cauemarcondes Mar 6, 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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { isValidPlatinumLicense } from '../../../../../../../plugins/apm/common/
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ServiceMapAPIResponse } from '../../../../../../../plugins/apm/server/lib/service_map/get_service_map';
import { useApmPluginContext } from '../../../hooks/useApmPluginContext';
import { useCallApmApi } from '../../../hooks/useCallApmApi';
import { useDeepObjectIdentity } from '../../../hooks/useDeepObjectIdentity';
import { useLicense } from '../../../hooks/useLicense';
import { useLoadingIndicator } from '../../../hooks/useLoadingIndicator';
Expand All @@ -33,6 +32,7 @@ import { getCytoscapeElements } from './get_cytoscape_elements';
import { PlatinumLicensePrompt } from './PlatinumLicensePrompt';
import { Popover } from './Popover';
import { useRefDimensions } from './useRefDimensions';
import { callApmApi } from '../../../services/rest/createCallApmApi';

interface ServiceMapProps {
serviceName?: string;
Expand Down Expand Up @@ -61,7 +61,6 @@ ${theme.euiColorLightShade}`,
const MAX_REQUESTS = 5;

export function ServiceMap({ serviceName }: ServiceMapProps) {
const callApmApi = useCallApmApi();
const license = useLicense();
const { search } = useLocation();
const { urlParams, uiFilters } = useUrlParams();
Expand Down Expand Up @@ -137,7 +136,7 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
}
}
},
[params, setIsLoading, callApmApi, responses.length, notifications.toasts]
[params, setIsLoading, responses.length, notifications.toasts]
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import React, { useState } from 'react';
import { EuiButtonEmpty } from '@elastic/eui';
import { NotificationsStart } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { useCallApmApi } from '../../../../../hooks/useCallApmApi';
import { Config } from '../index';
import { getOptionLabel } from '../../../../../../../../../plugins/apm/common/agent_configuration_constants';
import { APMClient } from '../../../../../services/rest/createCallApmApi';
import { callApmApi } from '../../../../../services/rest/createCallApmApi';
import { useApmPluginContext } from '../../../../../hooks/useApmPluginContext';

interface Props {
Expand All @@ -22,7 +21,6 @@ interface Props {
export function DeleteButton({ onDeleted, selectedConfig }: Props) {
const [isDeleting, setIsDeleting] = useState(false);
const { toasts } = useApmPluginContext().core.notifications;
const callApmApi = useCallApmApi();

return (
<EuiButtonEmpty
Expand All @@ -31,7 +29,7 @@ export function DeleteButton({ onDeleted, selectedConfig }: Props) {
iconSide="right"
onClick={async () => {
setIsDeleting(true);
await deleteConfig(callApmApi, selectedConfig, toasts);
await deleteConfig(selectedConfig, toasts);
setIsDeleting(false);
onDeleted();
}}
Expand All @@ -45,7 +43,6 @@ export function DeleteButton({ onDeleted, selectedConfig }: Props) {
}

async function deleteConfig(
callApmApi: APMClient,
selectedConfig: Config,
toasts: NotificationsStart['toasts']
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { i18n } from '@kbn/i18n';
import {
omitAllOption,
getOptionLabel
} from '../../../../../../../plugins/apm/common/agent_configuration_constants';
import { useFetcher } from '../../../hooks/useFetcher';
import { SelectWithPlaceholder } from '../SelectWithPlaceholder';
} from '../../../../../../../../../plugins/apm/common/agent_configuration_constants';
import { useFetcher } from '../../../../../hooks/useFetcher';
import { SelectWithPlaceholder } from '../../../../shared/SelectWithPlaceholder';

const SELECT_PLACEHOLDER_LABEL = `- ${i18n.translate(
'xpack.apm.settings.agentConf.flyOut.serviceForm.selectPlaceholder',
'xpack.apm.settings.agentConf.flyOut.serviceSection.selectPlaceholder',
{ defaultMessage: 'Select' }
)} -`;

Expand All @@ -27,7 +27,7 @@ interface Props {
onEnvironmentChange: (env: string) => void;
}

export function ServiceForm({
export function ServiceSection({
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
isReadOnly,
serviceName,
onServiceNameChange,
Expand Down Expand Up @@ -60,7 +60,7 @@ export function ServiceForm({
);

const ALREADY_CONFIGURED_TRANSLATED = i18n.translate(
'xpack.apm.settings.agentConf.flyOut.serviceForm.alreadyConfiguredOption',
'xpack.apm.settings.agentConf.flyOut.serviceSection.alreadyConfiguredOption',
{ defaultMessage: 'already configured' }
);

Expand All @@ -83,7 +83,7 @@ export function ServiceForm({
<EuiTitle size="xs">
<h3>
{i18n.translate(
'xpack.apm.settings.agentConf.flyOut.serviceForm.title',
'xpack.apm.settings.agentConf.flyOut.serviceSection.title',
{ defaultMessage: 'Service' }
)}
</h3>
Expand All @@ -93,13 +93,13 @@ export function ServiceForm({

<EuiFormRow
label={i18n.translate(
'xpack.apm.settings.agentConf.flyOut.serviceForm.serviceNameSelectLabel',
'xpack.apm.settings.agentConf.flyOut.serviceSection.serviceNameSelectLabel',
{ defaultMessage: 'Name' }
)}
helpText={
!isReadOnly &&
i18n.translate(
'xpack.apm.settings.agentConf.flyOut.serviceForm.serviceNameSelectHelpText',
'xpack.apm.settings.agentConf.flyOut.serviceSection.serviceNameSelectHelpText',
{ defaultMessage: 'Choose the service you want to configure.' }
)
}
Expand All @@ -124,13 +124,13 @@ export function ServiceForm({

<EuiFormRow
label={i18n.translate(
'xpack.apm.settings.agentConf.flyOut.serviceForm.serviceEnvironmentSelectLabel',
'xpack.apm.settings.agentConf.flyOut.serviceSection.serviceEnvironmentSelectLabel',
{ defaultMessage: 'Environment' }
)}
helpText={
!isReadOnly &&
i18n.translate(
'xpack.apm.settings.agentConf.flyOut.serviceForm.serviceEnvironmentSelectHelpText',
'xpack.apm.settings.agentConf.flyOut.serviceSection.serviceEnvironmentSelectHelpText',
{
defaultMessage:
'Only a single environment per configuration is supported.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ import {
import React, { useState } from 'react';
import { i18n } from '@kbn/i18n';
import { isRight } from 'fp-ts/lib/Either';
import { useCallApmApi } from '../../../../../hooks/useCallApmApi';
import { transactionSampleRateRt } from '../../../../../../../../../plugins/apm/common/runtime_types/transaction_sample_rate_rt';
import { Config } from '../index';
import { SettingsSection } from './SettingsSection';
import { ServiceForm } from '../../../../shared/ServiceForm';
import { ServiceSection } from './ServiceSection';
import { DeleteButton } from './DeleteButton';
import { transactionMaxSpansRt } from '../../../../../../../../../plugins/apm/common/runtime_types/transaction_max_spans_rt';
import { useFetcher } from '../../../../../hooks/useFetcher';
Expand Down Expand Up @@ -58,8 +57,6 @@ export function AddEditFlyout({
const { toasts } = useApmPluginContext().core.notifications;
const [isSaving, setIsSaving] = useState(false);

const callApmApiFromHook = useCallApmApi();

// get a telemetry UI event tracker
const trackApmEvent = useUiTracker({ app: 'apm' });

Expand Down Expand Up @@ -129,7 +126,6 @@ export function AddEditFlyout({
setIsSaving(true);

await saveConfig({
callApmApi: callApmApiFromHook,
serviceName,
environment,
sampleRate,
Expand Down Expand Up @@ -181,7 +177,7 @@ export function AddEditFlyout({
}
}}
>
<ServiceForm
<ServiceSection
isReadOnly={Boolean(selectedConfig)}
//
// environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { i18n } from '@kbn/i18n';
import { NotificationsStart } from 'kibana/public';
import { APMClient } from '../../../../../services/rest/createCallApmApi';
import { callApmApi } from '../../../../../services/rest/createCallApmApi';
import { isRumAgentName } from '../../../../../../../../../plugins/apm/common/agent_name';
import {
getOptionLabel,
Expand All @@ -21,7 +21,6 @@ interface Settings {
}

export async function saveConfig({
callApmApi,
serviceName,
environment,
sampleRate,
Expand All @@ -32,7 +31,6 @@ export async function saveConfig({
toasts,
trackApmEvent
}: {
callApmApi: APMClient;
serviceName: string;
environment: string;
sampleRate: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import {
EuiButtonEmpty
} from '@elastic/eui';
import { useFetcher } from '../../../../hooks/useFetcher';
import { useCallApmApi } from '../../../../hooks/useCallApmApi';
import { APMClient } from '../../../../services/rest/createCallApmApi';
import { callApmApi } from '../../../../services/rest/createCallApmApi';
import { clearCache } from '../../../../services/rest/callApi';
import { useApmPluginContext } from '../../../../hooks/useApmPluginContext';

Expand Down Expand Up @@ -68,10 +67,8 @@ const APM_INDEX_LABELS = [
];

async function saveApmIndices({
callApmApi,
apmIndices
}: {
callApmApi: APMClient;
apmIndices: Record<string, string>;
}) {
await callApmApi({
Expand All @@ -94,11 +91,11 @@ export function ApmIndices() {
const [apmIndices, setApmIndices] = useState<Record<string, string>>({});
const [isSaving, setIsSaving] = useState(false);

const callApmApiFromHook = useCallApmApi();

const { data = INITIAL_STATE, status, refetch } = useFetcher(
callApmApi =>
callApmApi({ pathname: `/api/apm/settings/apm-index-settings` }),
_callApmApi =>
_callApmApi({
pathname: `/api/apm/settings/apm-index-settings`
}),
[]
);

Expand All @@ -122,10 +119,7 @@ export function ApmIndices() {
event.preventDefault();
setIsSaving(true);
try {
await saveApmIndices({
callApmApi: callApmApiFromHook,
apmIndices
});
await saveApmIndices({ apmIndices });
toasts.addSuccess({
title: i18n.translate(
'xpack.apm.settings.apmIndices.applyChanges.succeeded.title',
Expand Down

This file was deleted.

Loading