Skip to content

Commit

Permalink
Merge branch 'main' into alerting/lazy-load-dataviews-searchsource
Browse files Browse the repository at this point in the history
  • Loading branch information
doakalexi committed Aug 19, 2024
2 parents 1997649 + d0c1349 commit dc60120
Show file tree
Hide file tree
Showing 128 changed files with 2,608 additions and 1,044 deletions.
1 change: 1 addition & 0 deletions .buildkite/ftr_security_serverless_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enabled:
- x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.basic.ts
- x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.essentials.ts
- x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.agentless.ts
- x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.agentless_api.ts
- x-pack/test_serverless/functional/test_suites/security/config.saved_objects_management.ts
- x-pack/test_serverless/functional/test_suites/security/config.context_awareness.ts
- x-pack/test_serverless/functional/test_suites/security/common_configs/config.group1.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ function buildRootCrumb({
color="text"
iconType="gear"
data-test-subj="manageDeploymentBtn"
size="s"
>
{i18n.translate('core.ui.primaryNav.cloud.breadCrumbDropdown.manageDeploymentLabel', {
defaultMessage: 'Manage this deployment',
Expand All @@ -157,16 +158,17 @@ function buildRootCrumb({
color="text"
iconType="spaces"
data-test-subj="viewDeploymentsBtn"
size="s"
>
{cloudLinks.deployments.title}
</EuiButtonEmpty>
)}
</>
),
popoverProps: {
panelPaddingSize: 'm',
panelPaddingSize: 's',
zIndex: 6000,
panelStyle: { width: 260 },
panelStyle: { maxWidth: 240 },
panelProps: {
'data-test-subj': 'deploymentLinksPanel',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@

import React from 'react';
import './field_name.scss';
import {
EuiBadge,
EuiFlexGroup,
EuiFlexItem,
EuiToolTip,
EuiHighlight,
EuiIcon,
} from '@elastic/eui';
import { EuiBadge, EuiFlexGroup, EuiFlexItem, EuiToolTip, EuiHighlight } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import { FieldIcon, FieldIconProps } from '@kbn/react-field';
Expand All @@ -30,7 +23,6 @@ interface Props {
fieldIconProps?: Omit<FieldIconProps, 'type'>;
scripted?: boolean;
highlight?: string;
isPinned?: boolean;
}

export function FieldName({
Expand All @@ -40,7 +32,6 @@ export function FieldName({
fieldIconProps,
scripted = false,
highlight = '',
isPinned = false,
}: Props) {
const typeName = getFieldTypeName(fieldType);
const displayName =
Expand All @@ -63,17 +54,6 @@ export function FieldName({
<EuiFlexItem grow={false}>
<FieldIcon type={fieldType!} label={typeName} scripted={scripted} {...fieldIconProps} />
</EuiFlexItem>
{isPinned && (
<EuiFlexItem grow={false}>
<EuiIcon
type="pinFilled"
size="s"
aria-label={i18n.translate('unifiedDocViewer.pinnedFieldTooltipContent', {
defaultMessage: 'Pinned field',
})}
/>
</EuiFlexItem>
)}
</EuiFlexGroup>
</EuiFlexItem>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ export function AlertsPopover({
button={anchorElement}
closePopover={onClose}
isOpen={!alertFlyoutVisible}
panelPaddingSize="s"
>
<EuiContextMenu initialPanelId="mainPanel" panels={panels} />
<EuiContextMenu initialPanelId="mainPanel" size="s" panels={panels} />
</EuiWrappingPopover>
</>
);
Expand Down

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
@@ -0,0 +1,63 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import React from 'react';
import { render, screen } from '@testing-library/react';
import { DataViewField } from '@kbn/data-views-plugin/common';
import { TableRow } from './table_cell_actions';
import { getPinColumnControl } from './get_pin_control';
import { EuiDataGridCellValueElementProps } from '@elastic/eui/src/components/datagrid/data_grid_types';

describe('getPinControl', () => {
const rows: TableRow[] = [
{
action: {
onFilter: jest.fn(),
flattenedField: 'flattenedField',
onToggleColumn: jest.fn(),
},
field: {
pinned: true,
onTogglePinned: jest.fn(),
field: 'message',
fieldMapping: new DataViewField({
type: 'keyword',
name: 'message',
searchable: true,
aggregatable: true,
}),
fieldType: 'keyword',
displayName: 'message',
scripted: false,
},
value: {
ignored: undefined,
formattedValue: 'test',
},
},
];

it('should render correctly', () => {
const control = getPinColumnControl({ rows });
const Cell = control.rowCellRender as React.FC<EuiDataGridCellValueElementProps>;
render(
<Cell
rowIndex={0}
columnId="test"
setCellProps={jest.fn()}
colIndex={0}
isDetails={false}
isExpanded={false}
isExpandable={false}
/>
);

screen.getByTestId('unifiedDocViewer_pinControlButton_message').click();

expect(rows[0].field.onTogglePinned).toHaveBeenCalledWith('message');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import {
EuiButtonIcon,
EuiDataGridControlColumn,
EuiScreenReaderOnly,
EuiToolTip,
useEuiTheme,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { css } from '@emotion/react';
import type { TableRow } from './table_cell_actions';

interface PinControlCellProps {
row: TableRow;
}

const PinControlCell: React.FC<PinControlCellProps> = React.memo(({ row }) => {
const { euiTheme } = useEuiTheme();

const fieldName = row.field.field;
const isPinned = row.field.pinned;
const label = isPinned
? i18n.translate('unifiedDocViewer.docViews.table.unpinFieldLabel', {
defaultMessage: 'Unpin field',
})
: i18n.translate('unifiedDocViewer.docViews.table.pinFieldLabel', {
defaultMessage: 'Pin field',
});

return (
<div
data-test-subj={`unifiedDocViewer_pinControl_${fieldName}`}
className={!isPinned ? 'kbnDocViewer__fieldsGrid__pinAction' : undefined}
css={css`
margin-left: ${isPinned ? '-1px' : 0}; // to align filled/unfilled pin icons better
width: ${euiTheme.size.l};
height: ${euiTheme.size.l};
overflow: hidden;
`}
>
<EuiToolTip content={label} delay="long">
<EuiButtonIcon
data-test-subj={`unifiedDocViewer_pinControlButton_${fieldName}`}
iconSize="m"
iconType={isPinned ? 'pinFilled' : 'pin'}
color="text"
aria-label={label}
onClick={() => {
row.field.onTogglePinned(fieldName);
}}
/>
</EuiToolTip>
</div>
);
});

export const getPinColumnControl = ({ rows }: { rows: TableRow[] }): EuiDataGridControlColumn => {
return {
id: 'pin_field',
width: 32,
headerCellRender: () => (
<EuiScreenReaderOnly>
<span>
{i18n.translate('unifiedDocViewer.fieldsTable.pinControlColumnHeader', {
defaultMessage: 'Pin field column',
})}
</span>
</EuiScreenReaderOnly>
),
rowCellRender: ({ rowIndex }) => {
const row = rows[rowIndex];
if (!row) {
return null;
}
return <PinControlCell key={`control-${row.field.field}`} row={row} />;
},
};
};
Loading

0 comments on commit dc60120

Please sign in to comment.