Skip to content

Commit

Permalink
Merge branch 'main' into files-upload-component-KS-2425
Browse files Browse the repository at this point in the history
* main:
  [SearchBar] Allow show refresh button as an icon (elastic#141088)
  [Files] Added usage counters for delete, unshare and download (elastic#140091)
  Fix removing a single field formatter  (elastic#141078)
  [APM] Move service metric config  to kibana advanced settings (elastic#141147)
  Synthetics project update improvements (elastic#140990)
  • Loading branch information
jloleysens committed Sep 21, 2022
2 parents 3357c16 + f64c9c9 commit e333d3b
Show file tree
Hide file tree
Showing 38 changed files with 765 additions and 433 deletions.
3 changes: 0 additions & 3 deletions docs/settings/apm-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ Maximum number of child items displayed when viewing trace details. Defaults to
`xpack.observability.annotations.index` {ess-icon}::
Index name where Observability annotations are stored. Defaults to `observability-annotations`.

`xpack.apm.searchAggregatedServiceMetrics` {ess-icon}::
Enables Service metrics. Defaults to `false`. When set to `true`, additional configuration in APM Server is required.

`xpack.apm.searchAggregatedTransactions` {ess-icon}::
Enables Transaction histogram metrics. Defaults to `auto` so the UI will use metric indices over transaction indices for transactions if aggregated transactions are found. When set to `always`, additional configuration in APM Server is required. When set to `never` and aggregated transactions are not used.
+
Expand Down
7 changes: 2 additions & 5 deletions src/plugins/data_views/common/data_views/data_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
} from '@kbn/field-formats-plugin/common';
import { castEsToKbnFieldTypeName, ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
import { CharacterNotAllowedInField } from '@kbn/kibana-utils-plugin/common';
import _, { cloneDeep, each, reject } from 'lodash';
import { cloneDeep, each, reject } from 'lodash';
import type { DataViewAttributes, FieldAttrs, FieldAttrSet } from '..';
import type { DataViewField, IIndexPatternFieldList } from '../fields';
import { fieldList } from '../fields';
Expand Down Expand Up @@ -407,9 +407,6 @@ export class DataView implements DataViewBase {
* Returns index pattern as saved object body for saving
*/
getAsSavedObjectBody(): DataViewAttributes {
const fieldFormatMap = _.isEmpty(this.fieldFormatMap)
? undefined
: JSON.stringify(this.fieldFormatMap);
const fieldAttrs = this.getFieldAttrs();
const runtimeFieldMap = this.runtimeFieldMap;

Expand All @@ -419,7 +416,7 @@ export class DataView implements DataViewBase {
timeFieldName: this.timeFieldName,
sourceFilters: this.sourceFilters ? JSON.stringify(this.sourceFilters) : undefined,
fields: JSON.stringify(this.fields?.filter((field) => field.scripted) ?? []),
fieldFormatMap,
fieldFormatMap: this.fieldFormatMap ? JSON.stringify(this.fieldFormatMap) : undefined,
type: this.type!,
typeMeta: JSON.stringify(this.typeMeta ?? {}),
allowNoIndex: this.allowNoIndex ? this.allowNoIndex : undefined,
Expand Down
20 changes: 20 additions & 0 deletions src/plugins/data_views/common/data_views/data_views.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,26 @@ describe('IndexPatterns', () => {
expect(async () => await indexPatterns.get(id)).toBeDefined();
});

test('can set and remove field format', async () => {
const id = 'id';
setDocsourcePayload(id, savedObject);
const dataView = await indexPatterns.get(id);
dataView.setFieldFormat('field', { id: 'formatId' });
await indexPatterns.updateSavedObject(dataView);
let lastCall = (savedObjectsClient.update as jest.Mock).mock.calls.pop() ?? [];
let [, , attrs] = lastCall;
expect(attrs).toHaveProperty('fieldFormatMap');
expect(attrs.fieldFormatMap).toMatchInlineSnapshot(`"{\\"field\\":{\\"id\\":\\"formatId\\"}}"`);
dataView.deleteFieldFormat('field');
await indexPatterns.updateSavedObject(dataView);
lastCall = (savedObjectsClient.update as jest.Mock).mock.calls.pop() ?? [];
[, , attrs] = lastCall;

// https://github.com/elastic/kibana/issues/134873: must keep an empty object and not delete it
expect(attrs).toHaveProperty('fieldFormatMap');
expect(attrs.fieldFormatMap).toMatchInlineSnapshot(`"{}"`);
});

describe('getDefaultDataView', () => {
beforeEach(() => {
indexPatterns.clearCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'observability:apmEnableServiceMetrics': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'banners:placement': {
type: 'keyword',
_meta: { description: 'Non-default value of setting.' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface UsageStats {
'observability:maxSuggestions': number;
'observability:enableComparisonByDefault': boolean;
'observability:enableServiceGroups': boolean;
'observability:apmEnableServiceMetrics': boolean;
'observability:enableInfrastructureHostsView': boolean;
'visualize:enableLabs': boolean;
'visualization:heatmap:maxBuckets': number;
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8702,6 +8702,12 @@
"description": "Non-default value of setting."
}
},
"observability:apmEnableServiceMetrics": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"banners:placement": {
"type": "keyword",
"_meta": {
Expand Down Expand Up @@ -10323,4 +10329,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -566,4 +566,46 @@ storiesOf('SearchBar', module)
},
isDisabled: true,
} as SearchBarProps)
)
.add('no submit button', () =>
wrapSearchBarInContext({
dataViewPickerComponentProps: {
currentDataViewId: '1234',
trigger: {
'data-test-subj': 'dataView-switch-link',
label: 'logstash-*',
title: 'logstash-*',
},
onChangeDataView: action('onChangeDataView'),
},
showSubmitButton: false,
} as SearchBarProps)
)
.add('submit button always as icon', () =>
wrapSearchBarInContext({
dataViewPickerComponentProps: {
currentDataViewId: '1234',
trigger: {
'data-test-subj': 'dataView-switch-link',
label: 'logstash-*',
title: 'logstash-*',
},
onChangeDataView: action('onChangeDataView'),
},
submitButtonStyle: 'iconOnly',
} as SearchBarProps)
)
.add('submit button always as a full button', () =>
wrapSearchBarInContext({
dataViewPickerComponentProps: {
currentDataViewId: '1234',
trigger: {
'data-test-subj': 'dataView-switch-link',
label: 'logstash-*',
title: 'logstash-*',
},
onChangeDataView: action('onChangeDataView'),
},
submitButtonStyle: 'full',
} as SearchBarProps)
);
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,23 @@ describe('QueryBarTopRowTopRow', () => {
expect(component.find(TIMEPICKER_SELECTOR).length).toBe(1);
});

it('Should render update button as icon button', () => {
const component = mount(
wrapQueryBarTopRowInContext({
isDirty: false,
screenTitle: 'Another Screen',
showDatePicker: true,
showSubmitButton: true,
submitButtonStyle: 'iconOnly',
dateRangeFrom: 'now-7d',
dateRangeTo: 'now',
timeHistory: mockTimeHistory,
})
);

expect(component.find(REFRESH_BUTTON_SELECTOR).prop('iconOnly')).toBe(true);
});

it('Should render the timefilter duration container for sharing', () => {
const component = mount(
wrapQueryBarTopRowInContext({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { Filter, TimeRange, Query, AggregateQuery } from '@kbn/es-query';
import { getAggregateQueryMode, isOfQueryType, isOfAggregateQueryType } from '@kbn/es-query';
import { EMPTY } from 'rxjs';
import { map } from 'rxjs/operators';
import { throttle } from 'lodash';
import {
EuiFlexGroup,
EuiFlexItem,
Expand Down Expand Up @@ -93,6 +94,13 @@ export interface QueryBarTopRowProps<QT extends Query | AggregateQuery = Query>
filterBar?: React.ReactNode;
showDatePickerAsBadge?: boolean;
showSubmitButton?: boolean;
/**
* Style of the submit button
* `iconOnly` - use IconButton
* `full` - use SuperUpdateButton
* (default) `auto` - `iconOnly` on smaller screens, and `full` on larger screens
*/
submitButtonStyle?: 'auto' | 'iconOnly' | 'full';
suggestionsSize?: SuggestionsListSize;
isScreenshotMode?: boolean;
onTextLangQuerySubmit: (query?: Query | AggregateQuery) => void;
Expand Down Expand Up @@ -142,18 +150,23 @@ export const QueryBarTopRow = React.memo(
const isMobile = useIsWithinBreakpoints(['xs', 's']);
const [isXXLarge, setIsXXLarge] = useState<boolean>(false);
const [codeEditorIsExpanded, setCodeEditorIsExpanded] = useState<boolean>(false);
const submitButtonStyle: QueryBarTopRowProps['submitButtonStyle'] =
props.submitButtonStyle ?? 'auto';
const submitButtonIconOnly =
submitButtonStyle === 'auto' ? !isXXLarge : submitButtonStyle === 'iconOnly';

useEffect(() => {
function handleResize() {
if (submitButtonStyle !== 'auto') return;

const handleResize = throttle(() => {
setIsXXLarge(window.innerWidth >= 1440);
}
}, 50);

window.removeEventListener('resize', handleResize);
window.addEventListener('resize', handleResize);
handleResize();

return () => window.removeEventListener('resize', handleResize);
}, []);
}, [submitButtonStyle]);

const {
showQueryInput = true,
Expand Down Expand Up @@ -404,7 +417,7 @@ export const QueryBarTopRow = React.memo(
<EuiFlexItem grow={false}>
<EuiSuperUpdateButton
iconType={props.isDirty ? iconDirty : 'refresh'}
iconOnly={!isXXLarge}
iconOnly={submitButtonIconOnly}
aria-label={props.isLoading ? buttonLabelUpdate : buttonLabelRefresh}
isDisabled={isDateRangeInvalid || props.isDisabled}
isLoading={props.isLoading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ export function createSearchBar({
showQueryBar={props.showQueryBar}
showQueryInput={props.showQueryInput}
showSaveQuery={props.showSaveQuery}
showSubmitButton={props.showSubmitButton}
submitButtonStyle={props.submitButtonStyle}
isDisabled={props.isDisabled}
screenTitle={props.screenTitle}
indexPatterns={props.indexPatterns}
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/unified_search/public/search_bar/search_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { SavedQueryMeta, SaveQueryForm } from '../saved_query_form';
import { SavedQueryManagementList } from '../saved_query_management';
import { QueryBarMenu, QueryBarMenuProps } from '../query_string_input/query_bar_menu';
import type { DataViewPickerProps, OnSaveTextLanguageQueryProps } from '../dataview_picker';
import QueryBarTopRow from '../query_string_input/query_bar_top_row';
import QueryBarTopRow, { QueryBarTopRowProps } from '../query_string_input/query_bar_top_row';
import { FilterBar, FilterItems } from '../filter_bar';
import type { SuggestionsListSize } from '../typeahead/suggestions_component';
import { searchBarStyles } from './search_bar.styles';
Expand Down Expand Up @@ -93,6 +93,7 @@ export interface SearchBarOwnProps<QT extends AggregateQuery | Query = Query> {
textBasedLanguageModeErrors?: Error[];
onTextBasedSavedAndExit?: ({ onSave }: OnSaveTextLanguageQueryProps) => void;
showSubmitButton?: boolean;
submitButtonStyle?: QueryBarTopRowProps['submitButtonStyle'];
// defines size of suggestions query popover
suggestionsSize?: SuggestionsListSize;
isScreenshotMode?: boolean;
Expand Down Expand Up @@ -544,6 +545,7 @@ class SearchBarUI<QT extends (Query | AggregateQuery) | Query = Query> extends C
this.props.customSubmitButton ? this.props.customSubmitButton : undefined
}
showSubmitButton={this.props.showSubmitButton}
submitButtonStyle={this.props.submitButtonStyle}
dataTestSubj={this.props.dataTestSubj}
indicateNoData={this.props.indicateNoData}
placeholder={this.props.placeholder}
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/apm/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ const configSchema = schema.object({
transactionGroupBucketSize: schema.number({ defaultValue: 1000 }),
maxTraceItems: schema.number({ defaultValue: 1000 }),
}),
searchAggregatedServiceMetrics: schema.boolean({
defaultValue: false,
}),
searchAggregatedTransactions: schema.oneOf(
[
schema.literal(SearchAggregatedTransactionSetting.auto),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import { APMConfig } from '../..';

export async function getServiceInventorySearchSource({
config,
serviceMetricsEnabled,
apmEventClient,
start,
end,
kuery,
}: {
serviceMetricsEnabled: boolean;
config: APMConfig;
apmEventClient: APMEventClient;
start: number;
Expand All @@ -26,16 +28,18 @@ export async function getServiceInventorySearchSource({
searchAggregatedServiceMetrics: boolean;
}> {
const commonProps = {
config,
apmEventClient,
kuery,
start,
end,
};
const [searchAggregatedTransactions, searchAggregatedServiceMetrics] =
await Promise.all([
getSearchAggregatedTransactions(commonProps),
getSearchAggregatedServiceMetrics(commonProps),
getSearchAggregatedTransactions({ ...commonProps, config }),
getSearchAggregatedServiceMetrics({
...commonProps,
serviceMetricsEnabled,
}),
]);

return {
Expand Down

0 comments on commit e333d3b

Please sign in to comment.