Skip to content

Commit

Permalink
Merge branch 'main' into detection-engine/esql-popover
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliidm authored Oct 16, 2023
2 parents b3baceb + 3488c83 commit fa888e1
Show file tree
Hide file tree
Showing 18 changed files with 307 additions and 77 deletions.
110 changes: 106 additions & 4 deletions packages/kbn-search-connectors/types/native_connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,111 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
validations: [],
value: '',
},
use_domain_wide_delegation_for_sync: {
default_value: null,
depends_on: [],
display: DisplayType.TOGGLE,
label: i18n.translate(
'searchConnectors.nativeConnectors.gdrive.useDomainWideDelegation.label',
{
defaultMessage: 'Use domain-wide delegation for data sync',
}
),
options: [],
order: 2,
required: true,
sensitive: false,
tooltip: i18n.translate(
'searchConnectors.nativeConnectors.gdrive.useDomainWideDelegation.tooltip',
{
defaultMessage:
'Enable domain-wide delegation to automatically sync content from all shared and personal drives in the Google workspace. This eliminates the need to manually share Google Drive data with your service account, though it may increase sync time. If disabled, only items and folders manually shared with the service account will be synced. Please refer to the connector documentation to ensure domain-wide delegation is correctly configured and has the appropriate scopes.',
}
),
type: FieldType.BOOLEAN,
ui_restrictions: [],
validations: [],
value: false,
},
google_workspace_admin_email_for_data_sync: {
default_value: null,
depends_on: [
{
field: 'use_domain_wide_delegation_for_sync',
value: true,
},
],
display: DisplayType.TEXTBOX,
label: i18n.translate(
'searchConnectors.nativeConnectors.gdrive.workspaceAdminEmailDataSync.label',
{
defaultMessage: 'Google Workspace admin email',
}
),
options: [],
order: 3,
required: true,
sensitive: false,
tooltip: i18n.translate(
'searchConnectors.nativeConnectors.gdrive.workspaceAdminEmailDataSync.tooltip',
{
defaultMessage:
'Provide the admin email to be used with domain-wide delegation for data sync. This email enables the connector to utilize the Admin Directory API for listing organization users. Please refer to the connector documentation to ensure domain-wide delegation is correctly configured and has the appropriate scopes.',
}
),
type: FieldType.STRING,
ui_restrictions: [],
validations: [
{
type: 'regex',
constraint: '^\\S+@\\S+\\.\\S+$',
},
],
value: '',
},
google_workspace_email_for_shared_drives_sync: {
default_value: null,
depends_on: [
{
field: 'use_domain_wide_delegation_for_sync',
value: true,
},
],
display: DisplayType.TEXTBOX,
label: i18n.translate(
'searchConnectors.nativeConnectors.gdrive.workspaceEmailSharedDrivesSync.label',
{
defaultMessage: 'Google Workspace email for syncing shared drives',
}
),
options: [],
order: 4,
required: true,
sensitive: false,
tooltip: i18n.translate(
'searchConnectors.nativeConnectors.gdrive.workspaceEmailSharedDrivesSync.tooltip',
{
defaultMessage:
'Provide the Google Workspace user email for discovery and syncing of shared drives. Only the shared drives this user has access to will be synced.',
}
),
type: FieldType.STRING,
ui_restrictions: [],
validations: [
{
type: 'regex',
constraint: '^\\S+@\\S+\\.\\S+$',
},
],
value: '',
},
use_document_level_security: {
default_value: null,
depends_on: [],
display: DisplayType.TOGGLE,
label: ENABLE_DOCUMENT_LEVEL_SECURITY_LABEL,
options: [],
order: 2,
order: 5,
required: true,
sensitive: false,
tooltip: ENABLE_DOCUMENT_LEVEL_SECURITY_TOOLTIP,
Expand All @@ -798,14 +896,18 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
field: 'use_document_level_security',
value: true,
},
{
field: 'use_domain_wide_delegation_for_sync',
value: false,
},
],
display: DisplayType.TEXTBOX,
label: i18n.translate(
'searchConnectors.nativeConnectors.gdrive.workspaceAdminEmail.label',
{ defaultMessage: 'Google Workspace admin email' }
),
options: [],
order: 3,
order: 6,
required: true,
sensitive: false,
tooltip: i18n.translate(
Expand Down Expand Up @@ -833,7 +935,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
defaultMessage: 'Maximum concurrent HTTP requests',
}),
options: [],
order: 4,
order: 7,
required: false,
sensitive: false,
tooltip: i18n.translate('searchConnectors.nativeConnectors.gdrive.maxHTTPRequest.tooltip', {
Expand All @@ -856,7 +958,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
display: DisplayType.TOGGLE,
label: USE_TEXT_EXTRACTION_SERVICE_LABEL,
options: [],
order: 5,
order: 8,
required: true,
sensitive: false,
tooltip: USE_TEXT_EXTRACTION_SERVICE_TOOLTIP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,7 @@ const executeActionSubFeature: SubFeatureConfig = {
description: i18n.translate(
'securitySolutionPackages.features.featureRegistry.subFeatures.executeOperations.description',
{
// TODO: Update this description before 8.8 FF
defaultMessage: 'Perform script execution on the endpoint.',
defaultMessage: 'Perform script execution response actions in the response console.',
}
),
privilegeGroups: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ export type TestSubjects =
| 'filter-option-h'
| 'infiniteRetentionPeriod.input'
| 'saveButton'
| 'dataRetentionDetail'
| 'createIndexSaveButton';
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export const createDataStreamPayload = (dataStream: Partial<DataStream>): DataSt
},
hidden: false,
lifecycle: {
enabled: true,
data_retention: '7d',
},
...dataStream,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,55 @@ describe('Data Streams tab', () => {
});

describe('update data retention', () => {
test('Should show disabled or infinite retention period accordingly in table and flyout', async () => {
const { setLoadDataStreamsResponse, setLoadDataStreamResponse } = httpRequestsMockHelpers;

const ds1 = createDataStreamPayload({
name: 'dataStream1',
lifecycle: {
enabled: false,
},
});
const ds2 = createDataStreamPayload({
name: 'dataStream2',
lifecycle: {
enabled: true,
},
});

setLoadDataStreamsResponse([ds1, ds2]);
setLoadDataStreamResponse(ds1.name, ds1);

testBed = await setup(httpSetup, {
history: createMemoryHistory(),
url: urlServiceMock,
});
await act(async () => {
testBed.actions.goToDataStreamsList();
});
testBed.component.update();

const { actions, find, table } = testBed;
const { tableCellsValues } = table.getMetaData('dataStreamTable');

expect(tableCellsValues).toEqual([
['', 'dataStream1', 'green', '1', 'Disabled', 'Delete'],
['', 'dataStream2', 'green', '1', '', 'Delete'],
]);

await actions.clickNameAt(0);
expect(find('dataRetentionDetail').text()).toBe('Disabled');

await act(async () => {
testBed.find('closeDetailsButton').simulate('click');
});
testBed.component.update();

setLoadDataStreamResponse(ds2.name, ds2);
await actions.clickNameAt(1);
expect(find('dataRetentionDetail').text()).toBe('Keep data indefinitely');
});

test('can set data retention period', async () => {
const {
actions: { clickNameAt, clickEditDataRetentionButton },
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/index_management/common/types/data_streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export interface DataStream {
_meta?: Metadata;
privileges: Privileges;
hidden: boolean;
lifecycle?: IndicesDataLifecycleWithRollover;
lifecycle?: IndicesDataLifecycleWithRollover & {
enabled?: boolean;
};
}

export interface DataStreamIndex {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 { getLifecycleValue } from './data_streams';

describe('Data stream helpers', () => {
describe('getLifecycleValue', () => {
it('Knows when it should be marked as disabled', () => {
expect(
getLifecycleValue({
enabled: false,
})
).toBe('Disabled');

expect(getLifecycleValue()).toBe('Disabled');
});

it('knows when it should be marked as infinite', () => {
expect(
getLifecycleValue({
enabled: true,
})
).toBe('Keep data indefinitely');
});

it('knows when it has a defined data retention period', () => {
expect(
getLifecycleValue({
enabled: true,
data_retention: '2d',
})
).toBe('2d');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
* 2.0.
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiIcon, EuiToolTip } from '@elastic/eui';

import { DataStream } from '../../../common';

export const isFleetManaged = (dataStream: DataStream): boolean => {
Expand Down Expand Up @@ -38,3 +42,37 @@ export const isSelectedDataStreamHidden = (
?.hidden
);
};

export const getLifecycleValue = (
lifecycle?: DataStream['lifecycle'],
inifniteAsIcon?: boolean
) => {
if (!lifecycle?.enabled) {
return i18n.translate('xpack.idxMgmt.dataStreamList.dataRetentionDisabled', {
defaultMessage: 'Disabled',
});
} else if (!lifecycle?.data_retention) {
const infiniteDataRetention = i18n.translate(
'xpack.idxMgmt.dataStreamList.dataRetentionInfinite',
{
defaultMessage: 'Keep data indefinitely',
}
);

if (inifniteAsIcon) {
return (
<EuiToolTip
data-test-subj="infiniteRetention"
position="top"
content={infiniteDataRetention}
>
<EuiIcon type="infinity" />
</EuiToolTip>
);
}

return infiniteDataRetention;
}

return lifecycle?.data_retention;
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from '@elastic/eui';

import { DiscoverLink } from '../../../../lib/discover_link';
import { getLifecycleValue } from '../../../../lib/data_streams';
import { SectionLoading, reactRouterNavigate } from '../../../../../shared_imports';
import { SectionError, Error, DataHealth } from '../../../../components';
import { useLoadDataStream } from '../../../../services/api';
Expand Down Expand Up @@ -147,19 +148,6 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
const getManagementDetails = () => {
const managementDetails = [];

if (lifecycle?.data_retention) {
managementDetails.push({
name: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.dataRetentionTitle', {
defaultMessage: 'Data retention',
}),
toolTip: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.dataRetentionToolTip', {
defaultMessage: 'The amount of time to retain the data in the data stream.',
}),
content: lifecycle.data_retention,
dataTestSubj: 'dataRetentionDetail',
});
}

if (ilmPolicyName) {
managementDetails.push({
name: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.ilmPolicyTitle', {
Expand Down Expand Up @@ -278,6 +266,16 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
),
dataTestSubj: 'indexTemplateDetail',
},
{
name: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.dataRetentionTitle', {
defaultMessage: 'Data retention',
}),
toolTip: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.dataRetentionToolTip', {
defaultMessage: 'The amount of time to retain the data in the data stream.',
}),
content: getLifecycleValue(lifecycle),
dataTestSubj: 'dataRetentionDetail',
},
];

const managementDetails = getManagementDetails();
Expand Down Expand Up @@ -376,7 +374,7 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
}
}}
dataStreamName={dataStreamName}
dataRetention={dataStream?.lifecycle?.data_retention as string}
lifecycle={dataStream?.lifecycle}
/>
)}

Expand Down
Loading

0 comments on commit fa888e1

Please sign in to comment.