Skip to content

Commit

Permalink
Merge branch 'main' into eui/v98.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mgadewoll authored Dec 19, 2024
2 parents b2344c1 + 87d15ba commit 7ba64c4
Show file tree
Hide file tree
Showing 71 changed files with 2,350 additions and 977 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/

import React from 'react';
import { useMemo, useEffect, useState } from 'react';
import { debounce } from 'lodash';
import { EuiButtonIcon, EuiRangeTick, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';

import { TimeSliderStrings } from './time_slider_strings';
Expand All @@ -27,29 +29,63 @@ interface Props {
compressed: boolean;
}

export function TimeSliderPopoverContent(props: Props) {
const rangeInput = props.isAnchored ? (
export function TimeSliderPopoverContent({
isAnchored,
setIsAnchored,
value,
onChange,
stepSize,
ticks,
timeRangeMin,
timeRangeMax,
compressed,
}: Props) {
const [displayedValue, setDisplayedValue] = useState<Timeslice>(value);

const debouncedOnChange = useMemo(
() =>
debounce((updateTimeslice: Timeslice | undefined) => {
onChange(updateTimeslice);
}, 750),
[onChange]
);

/**
* The following `useEffect` ensures that the changes to the value that come from the embeddable (for example,
* from the `clear` button on the dashboard) are reflected in the displayed value
*/
useEffect(() => {
setDisplayedValue(value);
}, [value]);

const rangeInput = isAnchored ? (
<TimeSliderAnchoredRange
value={props.value}
onChange={props.onChange}
stepSize={props.stepSize}
ticks={props.ticks}
timeRangeMin={props.timeRangeMin}
timeRangeMax={props.timeRangeMax}
compressed={props.compressed}
value={[displayedValue[0] || timeRangeMin, displayedValue[1] || timeRangeMax]}
onChange={(newValue) => {
setDisplayedValue(newValue as Timeslice);
debouncedOnChange(newValue);
}}
stepSize={stepSize}
ticks={ticks}
timeRangeMin={timeRangeMin}
timeRangeMax={timeRangeMax}
compressed={compressed}
/>
) : (
<TimeSliderSlidingWindowRange
value={props.value}
onChange={props.onChange}
stepSize={props.stepSize}
ticks={props.ticks}
timeRangeMin={props.timeRangeMin}
timeRangeMax={props.timeRangeMax}
compressed={props.compressed}
value={[displayedValue[0] || timeRangeMin, displayedValue[1] || timeRangeMax]}
onChange={(newValue) => {
setDisplayedValue(newValue as Timeslice);
debouncedOnChange(newValue);
}}
stepSize={stepSize}
ticks={ticks}
timeRangeMin={timeRangeMin}
timeRangeMax={timeRangeMax}
compressed={compressed}
/>
);
const anchorStartToggleButtonLabel = props.isAnchored
const anchorStartToggleButtonLabel = isAnchored
? TimeSliderStrings.control.getUnpinStart()
: TimeSliderStrings.control.getPinStart();

Expand All @@ -59,17 +95,24 @@ export function TimeSliderPopoverContent(props: Props) {
gutterSize="none"
data-test-subj="timeSlider-popoverContents"
responsive={false}
onMouseUp={() => {
// when the pin is dropped (on mouse up), cancel any pending debounced changes and force the change
// in value to happen instantly (which, in turn, will re-calculate the from/to for the slider due to
// the `useEffect` above.
debouncedOnChange.cancel();
onChange(displayedValue);
}}
>
<EuiFlexItem grow={false}>
<EuiToolTip content={anchorStartToggleButtonLabel} position="left">
<EuiButtonIcon
iconType={props.isAnchored ? 'pinFilled' : 'pin'}
iconType={isAnchored ? 'pinFilled' : 'pin'}
onClick={() => {
const nextIsAnchored = !props.isAnchored;
const nextIsAnchored = !isAnchored;
if (nextIsAnchored) {
props.onChange([props.timeRangeMin, props.value[1]]);
onChange([timeRangeMin, value[1]]);
}
props.setIsAnchored(nextIsAnchored);
setIsAnchored(nextIsAnchored);
}}
aria-label={anchorStartToggleButtonLabel}
data-test-subj="timeSlider__anchorStartToggleButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ export const getTimesliderControlFactory = (): ControlFactory<
Component: (controlPanelClassNames) => {
const [isAnchored, isPopoverOpen, timeRangeMeta, timeslice] =
useBatchedPublishingSubjects(isAnchored$, isPopoverOpen$, timeRangeMeta$, timeslice$);

useEffect(() => {
return () => {
cleanupTimeRangeSubscription();
Expand All @@ -284,6 +283,9 @@ export const getTimesliderControlFactory = (): ControlFactory<
const to = useMemo(() => {
return timeslice ? timeslice[TO_INDEX] : timeRangeMeta.timeRangeMax;
}, [timeslice, timeRangeMeta.timeRangeMax]);
const value: Timeslice = useMemo(() => {
return [from, to];
}, [from, to]);

return (
<EuiInputPopover
Expand All @@ -306,7 +308,7 @@ export const getTimesliderControlFactory = (): ControlFactory<
<TimeSliderPopoverContent
isAnchored={typeof isAnchored === 'boolean' ? isAnchored : false}
setIsAnchored={setIsAnchored}
value={[from, to]}
value={value}
onChange={onChange}
stepSize={timeRangeMeta.stepSize}
ticks={timeRangeMeta.ticks}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { encode, decode } from '@kbn/cbor';
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
import { ContentStream, ContentStreamEncoding, ContentStreamParameters } from './content_stream';
import type { GetResponse } from '@elastic/elasticsearch/lib/api/types';
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import * as estypes from '@elastic/elasticsearch/lib/api/types';
import { FileDocument } from '../../../../file_client/file_metadata_client/adapters/es_index';
import { IndexRequest } from '@elastic/elasticsearch/lib/api/types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ByteSizeValue } from '@kbn/config-schema';
import { defaults } from 'lodash';
import { Duplex, Writable, Readable } from 'stream';

import { GetResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { GetResponse } from '@elastic/elasticsearch/lib/api/types';
import { inspect } from 'util';
import { wrapErrorAndReThrow } from '../../../../file_client/utils';
import type { FileChunkDocument } from '../mappings';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type {
MappingTypeMapping,
MappingProperty,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { MappingTypeMapping, MappingProperty } from '@elastic/elasticsearch/lib/api/types';

/**
* These are the fields we expect to find a given document acting as a file chunk.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { MockedLogger } from '@kbn/logging-mocks';
import { createEsFileClient } from './create_es_file_client';
import { FileClient } from './types';
import { ElasticsearchBlobStorageClient } from '../blob_storage_service';
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import * as estypes from '@elastic/elasticsearch/lib/api/types';
import { FileDocument } from './file_metadata_client/adapters/es_index';

describe('When initializing file client via createESFileClient()', () => {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/kibana_overview/public/components/_index.scss

This file was deleted.

10 changes: 9 additions & 1 deletion src/plugins/kibana_overview/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { I18nProvider } from '@kbn/i18n-react';
import type { NavigationPublicPluginStart } from '@kbn/navigation-plugin/public';
import type { FetchResult } from '@kbn/newsfeed-plugin/public';
import { Route, Routes } from '@kbn/shared-ux-router';
import { withSuspense } from '@kbn/shared-ux-utility';
import React, { useEffect, useState } from 'react';
import { HashRouter as Router } from 'react-router-dom';
import useObservable from 'react-use/lib/useObservable';
import type { Observable } from 'rxjs';
import { Overview } from './overview';

interface KibanaOverviewAppDeps {
basename: string;
Expand Down Expand Up @@ -48,6 +48,14 @@ export const KibanaOverviewApp = ({
}
}, [newsfeed$]);

const Overview = withSuspense(
React.lazy(() =>
import('./overview').then(({ Overview: OverviewComponent }) => {
return { default: OverviewComponent };
})
)
);

return (
<Router basename={basename}>
<I18nProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import './overview.scss';

import { snakeCase } from 'lodash';
import React, { FC, useState, useEffect } from 'react';
import useObservable from 'react-use/lib/useObservable';
Expand Down
1 change: 0 additions & 1 deletion src/plugins/kibana_overview/public/index.scss

This file was deleted.

2 changes: 0 additions & 2 deletions src/plugins/kibana_overview/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import './index.scss';

import { KibanaOverviewPlugin } from './plugin';

// This exports static code and TypeScript types,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,5 @@ export const edgeDataSchema = schema.object({
source: schema.string(),
target: schema.string(),
color: colorSchema,
type: schema.maybe(schema.oneOf([schema.literal('solid'), schema.literal('dashed')])),
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
EuiFlexGroup,
EuiFlexItem,
EUI_MODAL_CONFIRM_BUTTON,
EuiSpacer,
} from '@elastic/eui';

import type { DeleteAction } from './use_delete_action';
Expand Down Expand Up @@ -79,16 +80,22 @@ export const DeleteActionModal: FC<DeleteAction> = ({
</EuiFlexItem>
<EuiFlexItem>
{userCanDeleteIndex && dataViewExists && (
<EuiSwitch
data-test-subj="mlAnalyticsJobDeleteDataViewSwitch"
label={i18n.translate('xpack.ml.dataframe.analyticsList.deleteTargetDataViewTitle', {
defaultMessage: 'Delete data view {dataView}',
values: { dataView: indexName },
})}
checked={deleteDataView}
onChange={toggleDeleteDataView}
disabled={userCanDeleteDataView === false}
/>
<>
<EuiSpacer size="s" />
<EuiSwitch
data-test-subj="mlAnalyticsJobDeleteDataViewSwitch"
label={i18n.translate(
'xpack.ml.dataframe.analyticsList.deleteTargetDataViewTitle',
{
defaultMessage: 'Delete data view {dataView}',
values: { dataView: indexName },
}
)}
checked={deleteDataView}
onChange={toggleDeleteDataView}
disabled={userCanDeleteDataView === false}
/>
</>
)}
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,18 @@ export function AnalyticsIdSelector({
</EuiFlyoutHeader>
<EuiFlyoutBody data-test-subj={'mlJobSelectorFlyoutBody'}>{renderTabs()}</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiFlexGroup>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
iconType="cross"
onClick={closeFlyout}
data-test-subj="mlFlyoutAnalyticsSelectorButtonClose"
>
{i18n.translate('xpack.ml.analyticsSelector.closeFlyoutButton', {
defaultMessage: 'Close',
})}
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
onClick={applySelection}
Expand All @@ -295,17 +306,6 @@ export function AnalyticsIdSelector({
/>
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
iconType="cross"
onClick={closeFlyout}
data-test-subj="mlFlyoutAnalyticsSelectorButtonClose"
>
{i18n.translate('xpack.ml.analyticsSelector.closeFlyoutButton', {
defaultMessage: 'Close',
})}
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlyoutFooter>
</EuiFlyout>
Expand Down
12 changes: 6 additions & 6 deletions x-pack/plugins/reporting/server/lib/store/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import * as estypes from '@elastic/elasticsearch/lib/api/types';
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
import { JOB_STATUS } from '@kbn/reporting-common';
import { ReportDocument } from '@kbn/reporting-common/types';
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('ReportingStore', () => {

const [[updateCall]] = mockEsClient.update.mock.calls;

const response = (updateCall as estypes.UpdateRequest).body?.doc as Report;
const response = (updateCall as estypes.UpdateRequest)?.doc as Report;
expect(response.migration_version).toBe(`7.14.0`);
expect(response.status).toBe(`processing`);
expect(updateCall.if_seq_no).toBe(42);
Expand Down Expand Up @@ -242,7 +242,7 @@ describe('ReportingStore', () => {
await store.setReportFailed(report, { errors: 'yes' } as any);

const [[updateCall]] = mockEsClient.update.mock.calls;
const response = (updateCall as estypes.UpdateRequest).body?.doc as Report;
const response = (updateCall as estypes.UpdateRequest)?.doc as Report;
expect(response.migration_version).toBe(`7.14.0`);
expect(response.status).toBe(`failed`);
expect(updateCall.if_seq_no).toBe(43);
Expand Down Expand Up @@ -272,7 +272,7 @@ describe('ReportingStore', () => {
await store.setReportError(report, { errors: 'yes' } as any);

const [[updateCall]] = mockEsClient.update.mock.calls;
const response = (updateCall as estypes.UpdateRequest).body?.doc as Report;
const response = (updateCall as estypes.UpdateRequest)?.doc as Report;
expect(response.migration_version).toBe(`7.14.0`);
expect(updateCall.if_seq_no).toBe(43);
expect(updateCall.if_primary_term).toBe(10002);
Expand Down Expand Up @@ -301,7 +301,7 @@ describe('ReportingStore', () => {
await store.setReportCompleted(report, { certainly_completed: 'yes' } as any);

const [[updateCall]] = mockEsClient.update.mock.calls;
const response = (updateCall as estypes.UpdateRequest).body?.doc as Report;
const response = (updateCall as estypes.UpdateRequest)?.doc as Report;
expect(response.migration_version).toBe(`7.14.0`);
expect(response.status).toBe(`completed`);
expect(updateCall.if_seq_no).toBe(44);
Expand Down Expand Up @@ -336,7 +336,7 @@ describe('ReportingStore', () => {
} as any);

const [[updateCall]] = mockEsClient.update.mock.calls;
const response = (updateCall as estypes.UpdateRequest).body?.doc as Report;
const response = (updateCall as estypes.UpdateRequest)?.doc as Report;

expect(response.migration_version).toBe(`7.14.0`);
expect(response.status).toBe(`completed_with_warnings`);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/reporting/server/lib/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const esDocForUpdate = (
if_seq_no: report._seq_no,
if_primary_term: report._primary_term,
refresh: 'wait_for' as estypes.Refresh,
body: { doc },
doc,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Writable } from 'stream';
import { finished } from 'stream/promises';
import { setTimeout } from 'timers/promises';

import { UpdateResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { UpdateResponse } from '@elastic/elasticsearch/lib/api/types';
import type { Logger } from '@kbn/core/server';
import {
CancellationToken,
Expand Down
Loading

0 comments on commit 7ba64c4

Please sign in to comment.