Skip to content

Commit

Permalink
Merge branch 'main' into split-types-from-code-on-kbn-test
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Feb 3, 2022
2 parents d627147 + 1185a33 commit 01f2b25
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$tvbLineColor: transparentize($euiColorFullShade, .8);
$tvbLineColorReversed: transparentize($euiColorEmptyShade, .6);

$tvbTextColor: transparentize($euiColorFullShade, .6);
$tvbTextColor: transparentize($euiColorFullShade, .4);
$tvbTextColorReversed: transparentize($euiColorEmptyShade, .4);

$tvbValueColor: transparentize($euiColorFullShade, .3);
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/infra/common/http_api/metadata_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const InfraMetadataHostRT = rt.partial({
name: rt.string,
hostname: rt.string,
id: rt.string,
ip: rt.array(rt.string),
mac: rt.array(rt.string),
ip: rt.union([rt.array(rt.string), rt.string]),
mac: rt.union([rt.array(rt.string), rt.string]),
os: InfraMetadataOSRT,
architecture: rt.string,
containerized: rt.boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ import { isColumnFormatted, isColumnOfType } from './operations/definitions/help

type OriginalColumn = { id: string } & GenericIndexPatternColumn;

declare global {
interface Window {
/**
* Debug setting to make requests complete slower than normal. data.search.aggs.shardDelay.enabled has to be set via settings for this to work
*/
ELASTIC_LENS_DELAY_SECONDS?: number;
}
}

function getExpressionForLayer(
layer: IndexPatternLayer,
indexPattern: IndexPattern,
Expand Down Expand Up @@ -139,8 +148,27 @@ function getExpressionForLayer(
}
});

if (window.ELASTIC_LENS_DELAY_SECONDS) {
aggs.push(
buildExpression({
type: 'expression',
chain: [
buildExpressionFunction('aggShardDelay', {
id: 'the-delay',
enabled: true,
schema: 'metric',
delay: `${window.ELASTIC_LENS_DELAY_SECONDS}s`,
}).toAst(),
],
})
);
}

const idMap = esAggEntries.reduce((currentIdMap, [colId, column], index) => {
const esAggsId = `col-${index}-${index}`;
const esAggsId = window.ELASTIC_LENS_DELAY_SECONDS
? `col-${index + (column.isBucketed ? 0 : 1)}-${index}`
: `col-${index}-${index}`;

return {
...currentIdMap,
[esAggsId]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,26 @@ describe('contextMiddleware', () => {
expect(store.dispatch).not.toHaveBeenCalled();
expect(next).toHaveBeenCalledWith(action);
});

it('does not trigger another update on active data update', () => {
const data = mockDataPlugin();
(data.nowProvider.get as jest.Mock).mockReturnValue(new Date(Date.now() - 30000));
(data.query.timefilter.timefilter.getTime as jest.Mock).mockReturnValue({
from: 'now-2m',
to: 'now',
});
(data.query.timefilter.timefilter.getBounds as jest.Mock).mockReturnValue({
min: moment(Date.now() - 100000),
max: moment(Date.now() - 30000),
});
const { next, invoke, store } = createMiddleware(data);
const action = {
type: 'lens/onActiveDataChange',
payload: {},
};
invoke(action);
expect(store.dispatch).not.toHaveBeenCalled();
expect(next).toHaveBeenCalledWith(action);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { setState, LensDispatch, LensStoreDeps, navigateAway } from '..';
import { LensAppState } from '../types';
import { getResolvedDateRange, containsDynamicMath } from '../../utils';
import { subscribeToExternalContext } from './subscribe_to_external_context';
import { onActiveDataChange } from '../lens_slice';

export const contextMiddleware = (storeDeps: LensStoreDeps) => (store: MiddlewareAPI) => {
const unsubscribeFromExternalContext = subscribeToExternalContext(
Expand All @@ -20,7 +21,7 @@ export const contextMiddleware = (storeDeps: LensStoreDeps) => (store: Middlewar
store.dispatch
);
return (next: Dispatch) => (action: PayloadAction<Partial<LensAppState>>) => {
if (!action.payload?.searchSessionId) {
if (!action.payload?.searchSessionId && !onActiveDataChange.match(action)) {
updateTimeRange(storeDeps.lensServices.data, store.dispatch);
}
if (navigateAway.match(action)) {
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/lens/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Run all tests from the `x-pack` root directory

Lens state is kept in the Redux Store. To enable redux logger, open Chrome Developer Tools and type in the console: `window.ELASTIC_LENS_LOGGER=true`.

To simulate long running searches, set `data.search.aggs.shardDelay.enabled` in your `kibana.dev.yml` to true and set the dealy via console in the browser (e.g. for a 20 seconds delay): `window.ELASTIC_LENS_DELAY_SECONDS=20`.

## UI Terminology

Lens has a lot of UI elements – to make it easier to refer to them in issues or bugs, this is a hopefully complete list:
Expand Down

0 comments on commit 01f2b25

Please sign in to comment.