Skip to content

Commit

Permalink
Merge branch 'master' into issue-115422-improve-space-deletion-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Oct 19, 2021
2 parents 9be4f61 + 083a2b9 commit e36c906
Show file tree
Hide file tree
Showing 283 changed files with 4,167 additions and 9,432 deletions.
2 changes: 1 addition & 1 deletion docs/getting-started/quick-start-guide.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ image::images/dashboard_sampleDataAddFilter_7.15.0.png[The [eCommerce] Revenue D
[[quick-start-whats-next]]
== What's next?

*Add your own data.* Ready to add your own data? Go to {fleet-guide}/fleet-quick-start.html[Quick start: Get logs and metrics into the Elastic Stack] to learn how to ingest your data, or go to <<connect-to-elasticsearch,Add data to {kib}>> and learn about all the other ways you can add data.
*Add your own data.* Ready to add your own data? Go to {observability-guide}/ingest-logs-metrics-uptime.html[Ingest logs, metrics, and uptime data with {agent}], or go to <<connect-to-elasticsearch,Add data to {kib}>> and learn about all the other ways you can add data.

*Explore your own data in Discover.* Ready to learn more about exploring your data in *Discover*? Go to <<discover, Discover>>.

Expand Down
2 changes: 1 addition & 1 deletion docs/osquery/osquery.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ The following is an example of an **error response** for an undefined action que
== System requirements

* {fleet-guide}/fleet-overview.html[Fleet] is enabled on your cluster, and
one or more {fleet-guide}/elastic-agent-installation-configuration.html[Elastic Agents] is enrolled.
one or more {fleet-guide}/elastic-agent-installation.html[Elastic Agents] is enrolled.
* The https://docs.elastic.co/en/integrations/osquery_manager[*Osquery Manager*] integration
has been added and configured
for an agent policy through Fleet.
Expand Down
2 changes: 1 addition & 1 deletion docs/setup/connect-to-elasticsearch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ so you can quickly get insights into your data, and {fleet} mode offers several
image::images/addData_fleet_7.15.0.png[Add data using Fleet]

To get started, refer to
{fleet-guide}/fleet-quick-start.html[Quick start: Get logs and metrics into the Elastic Stack].
{observability-guide}/ingest-logs-metrics-uptime.html[Ingest logs, metrics, and uptime data with {agent}].

[discrete]
[[upload-data-kibana]]
Expand Down
2 changes: 1 addition & 1 deletion docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ that the {kib} server uses to perform maintenance on the {kib} index at startup.
is an alternative to `elasticsearch.username` and `elasticsearch.password`.

| `enterpriseSearch.host`
| The URL of your Enterprise Search instance
| The http(s) URL of your Enterprise Search instance. For example, in a local self-managed setup, set this to `http://localhost:3002`. Authentication between Kibana and the Enterprise Search host URL, such as via OAuth, is not supported. You can also {enterprise-search-ref}/configure-ssl-tls.html#configure-ssl-tls-in-kibana[configure Kibana to trust your Enterprise Search TLS certificate authority].

| `interpreter.enableInVisualize`
| Enables use of interpreter in Visualize. *Default: `true`*
Expand Down
1 change: 1 addition & 0 deletions src/plugins/custom_integrations/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const INTEGRATION_CATEGORY_DISPLAY = {
project_management: 'Project Management',
software_development: 'Software Development',
upload_file: 'Upload a file',
website_search: 'Website Search',
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,142 +13,82 @@ import { i18n } from '@kbn/i18n';

import {
EuiBadge,
EuiButtonEmpty,
EuiContextMenuPanel,
EuiContextMenuItem,
EuiComboBox,
EuiComboBoxOptionOption,
EuiFlexGroup,
EuiFlexItem,
EuiLoadingSpinner,
EuiPopover,
EuiTextColor,
EuiToolTip,
} from '@elastic/eui';

import { RequestStatus } from '../../../../common/adapters';
import { Request } from '../../../../common/adapters/request/types';

interface RequestSelectorState {
isPopoverOpen: boolean;
}

interface RequestSelectorProps {
requests: Request[];
selectedRequest: Request;
onRequestChanged: Function;
onRequestChanged: (request: Request) => void;
}

export class RequestSelector extends Component<RequestSelectorProps, RequestSelectorState> {
export class RequestSelector extends Component<RequestSelectorProps> {
static propTypes = {
requests: PropTypes.array.isRequired,
selectedRequest: PropTypes.object.isRequired,
onRequestChanged: PropTypes.func,
};

state = {
isPopoverOpen: false,
};
handleSelected = (selectedOptions: Array<EuiComboBoxOptionOption<string>>) => {
const selectedOption = this.props.requests.find(
(request) => request.id === selectedOptions[0].value
);

togglePopover = () => {
this.setState((prevState: RequestSelectorState) => ({
isPopoverOpen: !prevState.isPopoverOpen,
}));
if (selectedOption) {
this.props.onRequestChanged(selectedOption);
}
};

closePopover = () => {
this.setState({
isPopoverOpen: false,
renderRequestCombobox() {
const options = this.props.requests.map((item) => {
const hasFailed = item.status === RequestStatus.ERROR;
const testLabel = item.name.replace(/\s+/, '_');

return {
'data-test-subj': `inspectorRequestChooser${testLabel}`,
label: hasFailed
? `${item.name} ${i18n.translate('inspector.requests.failedLabel', {
defaultMessage: ' (failed)',
})}`
: item.name,
value: item.id,
};
});
};

renderRequestDropdownItem = (request: Request, index: number) => {
const hasFailed = request.status === RequestStatus.ERROR;
const inProgress = request.status === RequestStatus.PENDING;

return (
<EuiContextMenuItem
key={index}
icon={request === this.props.selectedRequest ? 'check' : 'empty'}
onClick={() => {
this.props.onRequestChanged(request);
this.closePopover();
}}
toolTipContent={request.description}
toolTipPosition="left"
data-test-subj={`inspectorRequestChooser${request.name}`}
>
<EuiTextColor color={hasFailed ? 'danger' : 'default'}>
{request.name}

{hasFailed && (
<FormattedMessage id="inspector.requests.failedLabel" defaultMessage=" (failed)" />
)}

{inProgress && (
<EuiLoadingSpinner
size="s"
aria-label={i18n.translate('inspector.requests.requestInProgressAriaLabel', {
defaultMessage: 'Request in progress',
})}
className="insRequestSelector__menuSpinner"
/>
)}
</EuiTextColor>
</EuiContextMenuItem>
);
};

renderRequestDropdown() {
const button = (
<EuiButtonEmpty
iconType="arrowDown"
iconSide="right"
size="s"
onClick={this.togglePopover}
<EuiComboBox
data-test-subj="inspectorRequestChooser"
>
{this.props.selectedRequest.name}
</EuiButtonEmpty>
);

return (
<EuiPopover
fullWidth={true}
id="inspectorRequestChooser"
button={button}
isOpen={this.state.isPopoverOpen}
closePopover={this.closePopover}
panelPaddingSize="none"
anchorPosition="downLeft"
repositionOnScroll
>
<EuiContextMenuPanel
items={this.props.requests.map(this.renderRequestDropdownItem)}
data-test-subj="inspectorRequestChooserMenuPanel"
/>
</EuiPopover>
isClearable={false}
onChange={this.handleSelected}
options={options}
prepend="Request"
selectedOptions={[
{
label: this.props.selectedRequest.name,
value: this.props.selectedRequest.id,
},
]}
singleSelection={{ asPlainText: true }}
/>
);
}

render() {
const { selectedRequest, requests } = this.props;

return (
<EuiFlexGroup alignItems="center" gutterSize="xs">
<EuiFlexItem grow={false}>
<strong>
<FormattedMessage id="inspector.requests.requestLabel" defaultMessage="Request:" />
</strong>
</EuiFlexItem>
<EuiFlexItem grow={true}>
{requests.length <= 1 && (
<div
className="insRequestSelector__singleRequest"
data-test-subj="inspectorRequestName"
>
{selectedRequest.name}
</div>
)}
{requests.length > 1 && this.renderRequestDropdown()}
</EuiFlexItem>
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={true}>{requests.length && this.renderRequestCombobox()}</EuiFlexItem>
<EuiFlexItem grow={false}>
{selectedRequest.status !== RequestStatus.PENDING && (
<EuiToolTip
Expand Down
1 change: 1 addition & 0 deletions src/plugins/vis_types/table/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ export interface TableVisParams {
showTotal: boolean;
totalFunc: AggTypes;
percentageCol: string;
autoFitRowToContent?: boolean;
row?: boolean;
}

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

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 @@ -67,6 +67,7 @@ describe('TableVisBasic', () => {
});

it('should sort rows by column and pass the sorted rows for consumers', () => {
(createTableVisCell as jest.Mock).mockClear();
const uiStateProps = {
...props.uiStateProps,
sort: {
Expand Down Expand Up @@ -96,7 +97,7 @@ describe('TableVisBasic', () => {
visConfig={{ ...props.visConfig, showToolbar: true }}
/>
);
expect(createTableVisCell).toHaveBeenCalledWith(sortedRows, table.formattedColumns);
expect(createTableVisCell).toHaveBeenCalledWith(sortedRows, table.formattedColumns, undefined);
expect(createGridColumns).toHaveBeenCalledWith(
table.columns,
sortedRows,
Expand Down
36 changes: 33 additions & 3 deletions src/plugins/vis_types/table/public/components/table_vis_basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import React, { memo, useCallback, useMemo } from 'react';
import React, { memo, useCallback, useMemo, useEffect, useState, useRef } from 'react';
import { EuiDataGrid, EuiDataGridProps, EuiDataGridSorting, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { orderBy } from 'lodash';
Expand Down Expand Up @@ -47,8 +47,16 @@ export const TableVisBasic = memo(

// renderCellValue is a component which renders a cell based on column and row indexes
const renderCellValue = useMemo(
() => createTableVisCell(sortedRows, formattedColumns),
[formattedColumns, sortedRows]
() => createTableVisCell(sortedRows, formattedColumns, visConfig.autoFitRowToContent),
[formattedColumns, sortedRows, visConfig.autoFitRowToContent]
);

const rowHeightsOptions = useMemo(
() =>
visConfig.autoFitRowToContent
? ({ defaultHeight: 'auto' } as unknown as EuiDataGridProps['rowHeightsOptions'])
: undefined,
[visConfig.autoFitRowToContent]
);

// Columns config
Expand Down Expand Up @@ -103,6 +111,26 @@ export const TableVisBasic = memo(
[columns, setColumnsWidth]
);

const firstRender = useRef(true);
const [dataGridUpdateCounter, setDataGridUpdateCounter] = useState(0);

// key was added as temporary solution to force re-render if we change autoFitRowToContent or we get new data
// cause we have problem with correct updating height cache in EUI datagrid when we use auto-height
// will be removed as soon as fix problem on EUI side
useEffect(() => {
// skip first render
if (firstRender.current) {
firstRender.current = false;
return;
}
// skip if auto height was turned off
if (!visConfig.autoFitRowToContent) {
return;
}
// update counter to remount grid from scratch
setDataGridUpdateCounter((counter) => counter + 1);
}, [visConfig.autoFitRowToContent, table, sort, pagination, columnsWidth]);

return (
<>
{title && (
Expand All @@ -111,12 +139,14 @@ export const TableVisBasic = memo(
</EuiTitle>
)}
<EuiDataGrid
key={String(dataGridUpdateCounter)}
aria-label={dataGridAriaLabel}
columns={gridColumns}
gridStyle={{
border: 'horizontal',
header: 'underline',
}}
rowHeightsOptions={rowHeightsOptions}
rowCount={rows.length}
columnVisibility={{
visibleColumns: columns.map(({ id }) => id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DatatableRow } from 'src/plugins/expressions';
import { FormattedColumns } from '../types';

export const createTableVisCell =
(rows: DatatableRow[], formattedColumns: FormattedColumns) =>
(rows: DatatableRow[], formattedColumns: FormattedColumns, autoFitRowToContent?: boolean) =>
({ rowIndex, columnId }: EuiDataGridCellValueElementProps) => {
const rowValue = rows[rowIndex][columnId];
const column = formattedColumns[columnId];
Expand All @@ -28,7 +28,7 @@ export const createTableVisCell =
*/
dangerouslySetInnerHTML={{ __html: content }} // eslint-disable-line react/no-danger
data-test-subj="tbvChartCellContent"
className="tbvChartCellContent"
className={autoFitRowToContent ? '' : 'tbvChartCellContent'}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ function TableOptions({
data-test-subj="showMetricsAtAllLevels"
/>

<SwitchOption
label={i18n.translate('visTypeTable.params.autoFitRow', {
defaultMessage: 'Auto fit rows to content',
})}
paramName="autoFitRowToContent"
value={stateParams.autoFitRowToContent}
setValue={setValue}
data-test-subj="autoFitRowToContent"
/>

<SwitchOption
label={i18n.translate('visTypeTable.params.showPartialRowsLabel', {
defaultMessage: 'Show partial rows',
Expand Down
1 change: 1 addition & 0 deletions src/plugins/vis_types/table/public/table_vis_fn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('interpreter/functions#table', () => {
splitColumn: undefined,
splitRow: undefined,
showMetricsAtAllLevels: false,
autoFitRowToContent: false,
sort: {
columnIndex: null,
direction: null,
Expand Down
Loading

0 comments on commit e36c906

Please sign in to comment.