Skip to content

Commit

Permalink
app file
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Feb 4, 2025
1 parent 4490ea4 commit bf0f334
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 129 deletions.
40 changes: 0 additions & 40 deletions x-pack/platform/plugins/shared/lens/public/app_plugin/app.scss

This file was deleted.

14 changes: 12 additions & 2 deletions x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* 2.0.
*/

import './app.scss';
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
import { i18n } from '@kbn/i18n';
import type { TimeRange } from '@kbn/es-query';
import { EuiConfirmModal } from '@elastic/eui';
import { useExecutionContext, useKibana } from '@kbn/kibana-react-plugin/public';
import { OnSaveProps } from '@kbn/saved-objects-plugin/public';
import type { VisualizeFieldContext } from '@kbn/ui-actions-plugin/public';
import { css } from '@emotion/react';
import { LensAppProps, LensAppServices } from './types';
import { LensTopNavMenu } from './lens_top_nav';
import { AddUserMessages, EditorFrameInstance, Simplify, UserMessagesGetter } from '../types';
Expand Down Expand Up @@ -437,7 +437,17 @@ export function App({

return (
<>
<div className="lnsApp" data-test-subj="lnsApp" role="main">
<div
data-test-subj="lnsApp"
role="main"
css={css`
flex: 1 1 auto;
display: flex;
flex-direction: column;
height: 100%;
overflow: hidden;
`}
>
<LensTopNavMenu
initialInput={initialInput}
redirectToOrigin={redirectToOrigin}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import { useKibana } from '@kbn/kibana-react-plugin/public';
import { DataViewPickerProps } from '@kbn/unified-search-plugin/public';
import { getManagedContentBadge } from '@kbn/managed-content-badge';
import moment from 'moment';
import { EuiCallOut } from '@elastic/eui';
import { EuiCallOut, UseEuiTheme, useEuiBreakpoint } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { SerializedStyles, css } from '@emotion/react';
import { LENS_APP_LOCATOR } from '../../common/locator/locator';
import { LENS_APP_NAME } from '../../common/constants';
import { LensAppServices, LensTopNavActions, LensTopNavMenuProps } from './types';
Expand Down Expand Up @@ -102,6 +103,27 @@ function getSaveButtonMeta({
}
}

const NavItemWithDividerStyles = ({ euiTheme }: UseEuiTheme) => css`
@include euiBreakpoint('m', 'l', 'xl') {
margin-right: $euiSizeM;
position: relative;
}
${useEuiBreakpoint(['m', 'l', 'xl'])} {
margin-right: ${euiTheme.size.m};
position: relative;
&:after {
border-right: ${euiTheme.border.thin};
bottom: 0;
content: '';
display: block;
pointer-events: none;
position: absolute;
right: -${euiTheme.size.s};
top: 0;
}
}
`;

function getLensTopNavConfig(options: {
isByValueMode: boolean;
actions: LensTopNavActions;
Expand All @@ -123,7 +145,10 @@ function getLensTopNavConfig(options: {
contextFromEmbeddable,
isByValueMode,
} = options;
const topNavMenu: TopNavMenuData[] = [];

const topNavMenu: Array<
TopNavMenuData | ({ css: ({ euiTheme }: UseEuiTheme) => SerializedStyles } & TopNavMenuData)
> = [];

const showSaveAndReturn = actions.saveAndReturn.visible;

Expand All @@ -150,13 +175,13 @@ function getLensTopNavConfig(options: {
values: { contextOriginatingApp },
}),
run: actions.goBack.execute,
className: 'lnsNavItem__withDivider',
testId: 'lnsApp_goBackToAppButton',
description: i18n.translate('xpack.lens.app.goBackLabel', {
defaultMessage: `Go back to {contextOriginatingApp}`,
values: { contextOriginatingApp },
}),
disableButton: !actions.goBack.enabled,
css: NavItemWithDividerStyles,
});
}

Expand All @@ -169,12 +194,12 @@ function getLensTopNavConfig(options: {
label: exploreDataInDiscoverLabel,
run: actions.getUnderlyingDataUrl.execute,
testId: 'lnsApp_openInDiscover',
className: 'lnsNavItem__withDivider',
description: exploreDataInDiscoverLabel,
disableButton: !actions.getUnderlyingDataUrl.enabled,
tooltip: actions.getUnderlyingDataUrl.tooltip,
target: '_blank',
href: actions.getUnderlyingDataUrl.getLink?.(),
css: NavItemWithDividerStyles,
});
}

Expand Down Expand Up @@ -210,11 +235,11 @@ function getLensTopNavConfig(options: {
defaultMessage: 'Settings',
}),
run: actions.openSettings.execute,
className: 'lnsNavItem__withDivider',
testId: 'lnsApp_settingsButton',
description: i18n.translate('xpack.lens.app.settingsAriaLabel', {
defaultMessage: 'Open the Lens settings menu',
}),
css: NavItemWithDividerStyles,
});

if (actions.cancel.visible) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,6 @@ export async function mountApp(
window.dispatchEvent(new HashChangeEvent('hashchange'));
});

params.element.classList.add('lnsAppWrapper');

render(
<KibanaRenderContextProvider {...coreStart}>
<KibanaContextProvider services={lensServices}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import {
EuiWrappingPopoverProps,
EuiPopoverTitle,
EuiText,
useEuiTheme,
UseEuiTheme,
} from '@elastic/eui';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { css } from '@emotion/react';
import { StartServices } from '../../types';

export const HelpPopoverButton = ({
Expand All @@ -29,43 +28,37 @@ export const HelpPopoverButton = ({
children: string;
onClick: EuiLinkButtonProps['onClick'];
}) => {
const { euiTheme } = useEuiTheme();
return (
<EuiText size="xs">
<EuiLink onClick={onClick}>
<EuiIcon
size="s"
type="help"
css={css`
margin-right: ${euiTheme.size.xs};
`}
/>

<EuiIcon size="s" type="help" css={HelpPopoverStyles.button} />
{children}
</EuiLink>
</EuiText>
);
};

const HelpPopoverContent = ({ title, children }: { title?: string; children: ReactNode }) => {
const { euiTheme } = useEuiTheme();
return (
<>
{title && <EuiPopoverTitle paddingSize="m">{title}</EuiPopoverTitle>}
<EuiText
className="eui-yScroll"
size="s"
css={css`
max-height: 40vh;
padding: ${euiTheme.size.m};
`}
>
<EuiText className="eui-yScroll" size="s" css={HelpPopoverStyles.content}>
{children}
</EuiText>
</>
);
};

const HelpPopoverStyles = {
button: ({ euiTheme }: UseEuiTheme) => `
margin-right: ${euiTheme.size.xs};
`,
content: ({ euiTheme }: UseEuiTheme) => `
max-height: 40vh;
padding: ${euiTheme.size.m};
`,
};

export const HelpPopover = ({
anchorPosition,
button,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { useState } from 'react';
import { EuiPopover, EuiSpacer } from '@elastic/eui';
import { EuiPopover, EuiSpacer, euiTextBreakWord, useEuiFontSize, UseEuiTheme } from '@elastic/eui';
import type { Query } from '@kbn/es-query';
// Need to keep it separate to make it work Jest mocks in dimension_panel tests
// import { QueryInput } from '../../../../shared_components/query_input';
Expand Down Expand Up @@ -100,3 +100,13 @@ export const FilterPopover = ({
</EuiPopover>
);
};

export const DraggablePopoverButtonStyles = ({ euiTheme }: UseEuiTheme) => {
const euiFontSize = useEuiFontSize('s');
return `
${euiTextBreakWord()};
${euiFontSize};
min-height: ${euiTheme.size.xl};
width: 100%;
`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
import React, { useState } from 'react';
import { omit } from 'lodash';
import { i18n } from '@kbn/i18n';
import {
EuiFormRow,
EuiLink,
euiTextBreakWord,
htmlIdGenerator,
useEuiFontSize,
useEuiTheme,
} from '@elastic/eui';
import { EuiFormRow, EuiLink, htmlIdGenerator } from '@elastic/eui';
import type { Query } from '@kbn/es-query';
import type { AggFunctionsMapping } from '@kbn/data-plugin/public';
import { queryFilterToAst } from '@kbn/data-plugin/common';
Expand All @@ -26,12 +19,11 @@ import {
DraggableBucketContainer,
isQueryValid,
} from '@kbn/visualization-ui-components';
import { css } from '@emotion/react';
import { IndexPattern } from '../../../../../types';
import { updateColumnParam } from '../../layer_helpers';
import type { OperationDefinition } from '..';
import type { BaseIndexPatternColumn } from '../column_types';
import { FilterPopover } from './filter_popover';
import { DraggablePopoverButtonStyles, FilterPopover } from './filter_popover';
import { TermsIndexPatternColumn } from '../terms';
import { isColumnOfType } from '../helpers';

Expand Down Expand Up @@ -188,8 +180,6 @@ export const FilterList = ({
indexPattern: IndexPattern;
defaultQuery: Filter;
}) => {
const { euiTheme } = useEuiTheme();
const euiFontSize = useEuiFontSize('s');
const [activeFilterId, setActiveFilterId] = useState('');
const [localFilters, setLocalFilters] = useState(() =>
filters.map((filter) => ({ ...filter, id: generateId() }))
Expand Down Expand Up @@ -284,12 +274,7 @@ export const FilterList = ({
title={i18n.translate('xpack.lens.indexPattern.filters.clickToEdit', {
defaultMessage: 'Click to edit',
})}
css={css`
${euiTextBreakWord()};
${euiFontSize};
min-height: ${euiTheme.size.xl};
width: 100%;
`}
css={DraggablePopoverButtonStyles}
>
{filter.label || (filter.input.query as string) || defaultLabel}
</EuiLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import {
EuiToolTip,
htmlIdGenerator,
keys,
euiTextBreakWord,
useEuiTheme,
useEuiFontSize,
} from '@elastic/eui';
import { IFieldFormat } from '@kbn/field-formats-plugin/common';
import {
Expand All @@ -35,6 +32,7 @@ import { RangeTypeLens, isValidRange } from './ranges';
import { FROM_PLACEHOLDER, TO_PLACEHOLDER, TYPING_DEBOUNCE_TIME } from './constants';
import { LabelInput } from '../shared_components';
import { isValidNumber } from '../helpers';
import { DraggablePopoverButtonStyles } from '../filters/filter_popover';

const generateId = htmlIdGenerator();

Expand Down Expand Up @@ -242,9 +240,6 @@ export const AdvancedRangeEditor = ({
setActiveRangeId(newRangeId);
}, [localRanges]);

const { euiTheme } = useEuiTheme();
const euiFontSize = useEuiFontSize('s');

const changeActiveRange = (rangeId: string) => {
let newActiveRangeId = rangeId;
if (activeRangeId === rangeId) {
Expand Down Expand Up @@ -313,12 +308,7 @@ export const AdvancedRangeEditor = ({
color="text"
onClick={() => changeActiveRange(range.id)}
data-test-subj="dataView-ranges-popover-trigger"
css={css`
${euiTextBreakWord()};
${euiFontSize};
min-height: ${euiTheme.size.xl};
width: 100%;
`}
css={DraggablePopoverButtonStyles}
>
<EuiText
size="s"
Expand Down
Loading

0 comments on commit bf0f334

Please sign in to comment.