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

162224 fix action menu overlaps flyout #162664

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fd03232
[Observability][Apm][Traces] Fix action menu overlap with custom link…
Ruhshan Jul 27, 2023
cef16ad
[Observability][Apm][Trace] Refactor create custom link flyout handle…
Ruhshan Jul 27, 2023
ce269eb
[Observability][Apm][Trace] Remove unused import from transaction act…
Ruhshan Jul 27, 2023
14c4df0
Merge branch 'main' into 162224-fix-action-menu-overlaps-flyout
Ruhshan Jul 27, 2023
51909c0
Merge branch 'main' into 162224-fix-action-menu-overlaps-flyout
Ruhshan Aug 1, 2023
ba950de
Merge branch 'main' into 162224-fix-action-menu-overlaps-flyout
achyutjhunjhunwala Aug 8, 2023
ad2d1a6
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Aug 8, 2023
4efa488
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 8, 2023
0ee5275
Merge branch 'elastic:main' into 162224-fix-action-menu-overlaps-flyout
Ruhshan Aug 8, 2023
148e29c
[Observability][Apm][Traces] Implement feedbaks from PR
Ruhshan Aug 8, 2023
6999d89
Merge branch 'main' into 162224-fix-action-menu-overlaps-flyout
Ruhshan Aug 8, 2023
7ed1aad
Merge branch 'main' into 162224-fix-action-menu-overlaps-flyout
achyutjhunjhunwala Aug 9, 2023
96d0dca
Merge branch 'elastic:main' into 162224-fix-action-menu-overlaps-flyout
Ruhshan Aug 10, 2023
de6f6c9
[Observability][Apm] Fix tsconfig to prevend circular dependency
Ruhshan Aug 10, 2023
cb7a9b6
[Observability][Apm][Traces] Fix custom link menu section test
Ruhshan Aug 10, 2023
c57c97d
Merge branch 'main' into 162224-fix-action-menu-overlaps-flyout
achyutjhunjhunwala Aug 10, 2023
6984dd4
FIX noop import from lodash
achyutjhunjhunwala Aug 10, 2023
296c439
Merge branch 'main' into 162224-fix-action-menu-overlaps-flyout
achyutjhunjhunwala Aug 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { useMemo } from 'react';
import React from 'react';
import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
import { Filter } from '../../../../common/custom_link/custom_link_types';
import { useFetcher } from '../../../hooks/use_fetcher';
import { convertFiltersToQuery } from '../../app/settings/custom_link/create_edit_custom_link_flyout/helper';
import { CreateEditCustomLinkFlyout } from '../../app/settings/custom_link/create_edit_custom_link_flyout';

export function CustomLinkFlyout({
transaction,
isOpen,
onClose,
}: {
transaction?: Transaction;
isOpen: boolean;
onClose: () => void;
}) {
const filters = useMemo(
() =>
[
{ key: 'service.name', value: transaction?.service.name },
{ key: 'service.environment', value: transaction?.service.environment },
{ key: 'transaction.name', value: transaction?.transaction.name },
{ key: 'transaction.type', value: transaction?.transaction.type },
].filter((filter): filter is Filter => typeof filter.value === 'string'),
[transaction]
);

const { refetch } = useFetcher(
(callApmApi) =>
callApmApi('GET /internal/apm/settings/custom_links', {
isCachable: false,
params: { query: convertFiltersToQuery(filters) },
}),
[filters]
);

return (
<>
{isOpen && (
<CreateEditCustomLinkFlyout
defaults={{ filters }}
onClose={() => {
onClose();
}}
onSave={() => {
onClose();
refetch();
}}
onDelete={() => {
onClose();
refetch();
}}
/>
)}
</>
);
}
Expand Up @@ -30,7 +30,6 @@ import {
import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
import { FETCH_STATUS, useFetcher } from '../../../../hooks/use_fetcher';
import { CreateEditCustomLinkFlyout } from '../../../app/settings/custom_link/create_edit_custom_link_flyout';
import { convertFiltersToQuery } from '../../../app/settings/custom_link/create_edit_custom_link_flyout/helper';
import { LoadingStatePrompt } from '../../loading_state_prompt';
import { CustomLinkToolbar } from './custom_link_toolbar';
Expand All @@ -40,11 +39,12 @@ const DEFAULT_LINKS_TO_SHOW = 3;

export function CustomLinkMenuSection({
transaction,
openCreateCustomLinkFlyout,
}: {
transaction?: Transaction;
openCreateCustomLinkFlyout: () => void;
}) {
const [showAllLinks, setShowAllLinks] = useState(false);
const [isCreateEditFlyoutOpen, setIsCreateEditFlyoutOpen] = useState(false);

const filters = useMemo(
() =>
Expand All @@ -57,7 +57,7 @@ export function CustomLinkMenuSection({
[transaction]
);

const { data, status, refetch } = useFetcher(
const { data, status } = useFetcher(
(callApmApi) =>
callApmApi('GET /internal/apm/settings/custom_links', {
isCachable: false,
Expand All @@ -70,23 +70,6 @@ export function CustomLinkMenuSection({

return (
<>
{isCreateEditFlyoutOpen && (
<CreateEditCustomLinkFlyout
defaults={{ filters }}
onClose={() => {
setIsCreateEditFlyoutOpen(false);
}}
onSave={() => {
setIsCreateEditFlyoutOpen(false);
refetch();
}}
onDelete={() => {
setIsCreateEditFlyoutOpen(false);
refetch();
}}
/>
)}

<ActionMenuDivider />

<Section>
Expand All @@ -103,7 +86,7 @@ export function CustomLinkMenuSection({
</EuiFlexItem>
<EuiFlexItem>
<CustomLinkToolbar
onClickCreate={() => setIsCreateEditFlyoutOpen(true)}
onClickCreate={openCreateCustomLinkFlyout}
showCreateButton={customLinks.length > 0}
/>
</EuiFlexItem>
Expand Down Expand Up @@ -131,7 +114,7 @@ export function CustomLinkMenuSection({
customLinks={customLinks}
showAllLinks={showAllLinks}
toggleShowAll={() => setShowAllLinks((show) => !show)}
onClickCreate={() => setIsCreateEditFlyoutOpen(true)}
onClickCreate={openCreateCustomLinkFlyout}
/>
</Section>
</>
Expand Down
Expand Up @@ -32,6 +32,7 @@ import { useApmRouter } from '../../../hooks/use_apm_router';
import { useProfilingPlugin } from '../../../hooks/use_profiling_plugin';
import { CustomLinkMenuSection } from './custom_link_menu_section';
import { getSections } from './sections';
import { CustomLinkFlyout } from './custom_link_flyout';

interface Props {
readonly transaction?: Transaction;
Expand Down Expand Up @@ -69,8 +70,21 @@ export function TransactionActionMenu({ transaction, isLoading }: Props) {
const { isProfilingPluginInitialized, profilingLocators } =
useProfilingPlugin();

const [isCreateEditFlyoutOpen, setIsCreateEditFlyoutOpen] = useState(false);

function openCustomLinkFlyout() {
setIsCreateEditFlyoutOpen(true);
setIsActionPopoverOpen(false);
}

return (
<>
<CustomLinkFlyout
transaction={transaction}
isOpen={isCreateEditFlyoutOpen}
onClose={() => setIsCreateEditFlyoutOpen(false)}
/>

<ActionMenu
id="transactionActionMenu"
closePopover={() => setIsActionPopoverOpen(false)}
Expand All @@ -91,7 +105,12 @@ export function TransactionActionMenu({ transaction, isLoading }: Props) {
transaction={transaction}
profilingLocators={profilingLocators}
/>
{hasGoldLicense && <CustomLinkMenuSection transaction={transaction} />}
{hasGoldLicense && (
<CustomLinkMenuSection
transaction={transaction}
openCreateCustomLinkFlyout={openCustomLinkFlyout}
/>
)}
</ActionMenu>
</>
);
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/apm/tsconfig.json
Expand Up @@ -96,7 +96,8 @@
"@kbn/logs-shared-plugin",
"@kbn/unified-field-list",
"@kbn/discover-plugin",
"@kbn/observability-ai-assistant-plugin"
"@kbn/observability-ai-assistant-plugin",
"@kbn/apm-plugin"
achyutjhunjhunwala marked this conversation as resolved.
Show resolved Hide resolved
],
"exclude": ["target/**/*"]
}