Skip to content

Commit

Permalink
Merge branch 'master' into add-force-to-add-remove-integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
John Schulz authored Apr 12, 2021
2 parents f7c53f9 + d338f1c commit 5d9033e
Show file tree
Hide file tree
Showing 156 changed files with 1,670 additions and 1,141 deletions.
28 changes: 23 additions & 5 deletions docs/settings/search-sessions-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,33 @@ Configure the search session settings in your `kibana.yml` configuration file.
[cols="2*<"]
|===
a| `xpack.data_enhanced.`
`search.sessions.enabled`
`search.sessions.enabled` {ess-icon}
| Set to `true` (default) to enable search sessions.

a| `xpack.data_enhanced.`
`search.sessions.trackingInterval`
| The frequency for updating the state of a search session. The default is 10s.
`search.sessions.trackingInterval` {ess-icon}
| The frequency for updating the state of a search session. The default is `10s`.

a| `xpack.data_enhanced.`
`search.sessions.defaultExpiration`
`search.sessions.pageSize` {ess-icon}
| How many search sessions {kib} processes at once while monitoring
session progress. The default is `100`.

a| `xpack.data_enhanced.`
`search.sessions.notTouchedTimeout` {ess-icon}
| How long {kib} stores search results from unsaved sessions,
after the last search in the session completes. The default is `5m`.

a| `xpack.data_enhanced.`
`search.sessions.notTouchedInProgressTimeout` {ess-icon}
| How long a search session can run after a user navigates away without saving a session. The default is `1m`.

a| `xpack.data_enhanced.`
`search.sessions.maxUpdateRetries` {ess-icon}
| How many retries {kib} can perform while attempting to save a search session. The default is `3`.

a| `xpack.data_enhanced.`
`search.sessions.defaultExpiration` {ess-icon}
| How long search session results are stored before they are deleted.
Extending a search session resets the expiration by the same value. The default is 7d.
Extending a search session resets the expiration by the same value. The default is `7d`.
|===
3 changes: 2 additions & 1 deletion src/plugins/discover/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"urlForwarding",
"navigation",
"uiActions",
"savedObjects"
"savedObjects",
"indexPatternFieldEditor"
],
"optionalPlugins": ["home", "share", "usageCollection"],
"requiredBundles": ["kibanaUtils", "home", "kibanaReact"]
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/discover/public/application/angular/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,13 @@ function discoverController($route, $scope) {
$scope.fetchStatus = fetchStatuses.COMPLETE;
}

$scope.refreshAppState = async () => {
$scope.hits = [];
$scope.rows = [];
$scope.fieldCounts = {};
await refetch$.next();
};

function getRequestResponder({ searchSessionId = null } = { searchSessionId: null }) {
inspectorAdapters.requests.reset();
const title = i18n.translate('discover.inspectorRequestDataTitle', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
top-nav-menu="topNavMenu"
use-new-fields-api="useNewFieldsApi"
unmapped-fields-config="unmappedFieldsConfig"
refresh-app-state="refreshAppState"
>
</discover>
</discover-app>
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function getState({
},
uiSettings
);
// todo filter source depending on fields fetchinbg flag (if no columns remain and source fetching is enabled, use default columns)
// todo filter source depending on fields fetching flag (if no columns remain and source fetching is enabled, use default columns)
let previousAppState: AppState;
const appStateContainer = createStateContainer<AppState>(initialAppState);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ describe('Row formatter', () => {
},
{
'object.value': [5, 10],
getByName: jest.fn(),
},
indexPattern
).trim()
Expand All @@ -107,7 +108,7 @@ describe('Row formatter', () => {
});
const formatted = formatTopLevelObject(
{ fields: { 'a.zzz': [100], 'a.ccc': [50] } },
{ 'a.zzz': [100], 'a.ccc': [50] },
{ 'a.zzz': [100], 'a.ccc': [50], getByName: jest.fn() },
indexPattern
).trim();
expect(formatted.indexOf('<dt>a.ccc:</dt>')).toBeLessThan(formatted.indexOf('<dt>a.zzz:</dt>'));
Expand All @@ -134,6 +135,7 @@ describe('Row formatter', () => {
{
'object.value': [5, 10],
'object.keys': ['a', 'b'],
getByName: jest.fn(),
},
indexPattern
).trim()
Expand All @@ -154,6 +156,7 @@ describe('Row formatter', () => {
},
{
'object.value': [5, 10],
getByName: jest.fn(),
},
indexPattern
).trim()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ export const formatRow = (hit: Record<string, any>, indexPattern: IndexPattern)
const highlights = hit?.highlight ?? {};
// Keys are sorted in the hits object
const formatted = indexPattern.formatHit(hit);
const fields = indexPattern.fields;
const highlightPairs: Array<[string, unknown]> = [];
const sourcePairs: Array<[string, unknown]> = [];
Object.entries(formatted).forEach(([key, val]) => {
const displayKey = fields.getByName ? fields.getByName(key)?.displayName : undefined;
const pairs = highlights[key] ? highlightPairs : sourcePairs;
pairs.push([key, val]);
pairs.push([displayKey ? displayKey : key, val]);
});
return doTemplate({ defPairs: [...highlightPairs, ...sourcePairs] });
};
Expand All @@ -48,9 +50,11 @@ export const formatTopLevelObject = (
const sorted = Object.entries(fields).sort(([keyA], [keyB]) => keyA.localeCompare(keyB));
sorted.forEach(([key, values]) => {
const field = indexPattern.getFieldByName(key);
const displayKey = fields.getByName ? fields.getByName(key)?.displayName : undefined;
const formatter = field
? indexPattern.getFormatterForField(field)
: { convert: (v: string, ...rest: unknown[]) => String(v) };
if (!values.map) return;
const formatted = values
.map((val: unknown) =>
formatter.convert(val, 'html', {
Expand All @@ -61,7 +65,7 @@ export const formatTopLevelObject = (
)
.join(', ');
const pairs = highlights[key] ? highlightPairs : sourcePairs;
pairs.push([key, formatted]);
pairs.push([displayKey ? displayKey : key, formatted]);
});
return doTemplate({ defPairs: [...highlightPairs, ...sourcePairs] });
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export function createDiscoverDirective(reactDirective: any) {
['updateQuery', { watchDepth: 'reference' }],
['updateSavedQueryId', { watchDepth: 'reference' }],
['unmappedFieldsConfig', { watchDepth: 'value' }],
['refreshAppState', { watchDepth: 'reference' }],
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export function Discover({
searchSource,
state,
unmappedFieldsConfig,
refreshAppState,
}: DiscoverProps) {
const [expandedDoc, setExpandedDoc] = useState<ElasticSearchHit | undefined>(undefined);
const scrollableDesktop = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -203,6 +204,12 @@ export function Discover({
[opts, state]
);

const onEditRuntimeField = () => {
if (refreshAppState) {
refreshAppState();
}
};

const columns = useMemo(() => {
if (!state.columns) {
return [];
Expand Down Expand Up @@ -245,6 +252,7 @@ export function Discover({
trackUiMetric={trackUiMetric}
unmappedFieldsConfig={unmappedFieldsConfig}
useNewFieldsApi={useNewFieldsApi}
onEditRuntimeField={onEditRuntimeField}
/>
</EuiFlexItem>
<EuiHideFor sizes={['xs', 's']}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export const getRenderCellValueFn = (
const sourcePairs: Array<[string, string]> = [];
Object.entries(innerColumns).forEach(([key, values]) => {
const subField = indexPattern.getFieldByName(key);
const displayKey = indexPattern.fields.getByName
? indexPattern.fields.getByName(key)?.displayName
: undefined;
const formatter = subField
? indexPattern.getFormatterForField(subField)
: { convert: (v: string, ...rest: unknown[]) => String(v) };
Expand All @@ -90,7 +93,7 @@ export const getRenderCellValueFn = (
)
.join(', ');
const pairs = highlights[key] ? highlightPairs : sourcePairs;
pairs.push([key, formatted]);
pairs.push([displayKey ? displayKey : key, formatted]);
});

return (
Expand Down Expand Up @@ -130,7 +133,10 @@ export const getRenderCellValueFn = (

Object.entries(formatted).forEach(([key, val]) => {
const pairs = highlights[key] ? highlightPairs : sourcePairs;
pairs.push([key, val as string]);
const displayKey = indexPattern.fields.getByName
? indexPattern.fields.getByName(key)?.displayName
: undefined;
pairs.push([displayKey ? displayKey : key, val as string]);
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
EuiToolTip,
EuiTitle,
EuiIcon,
EuiFlexGroup,
EuiFlexItem,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { UiCounterMetricType } from '@kbn/analytics';
Expand Down Expand Up @@ -69,6 +71,8 @@ export interface DiscoverFieldProps {
trackUiMetric?: (metricType: UiCounterMetricType, eventName: string | string[]) => void;

multiFields?: Array<{ field: IndexPatternField; isSelected: boolean }>;

onEditField?: (fieldName: string) => void;
}

export function DiscoverField({
Expand All @@ -82,6 +86,7 @@ export function DiscoverField({
selected,
trackUiMetric,
multiFields,
onEditField,
}: DiscoverFieldProps) {
const addLabelAria = i18n.translate('discover.fieldChooser.discoverField.addButtonAriaLabel', {
defaultMessage: 'Add {field} to table',
Expand Down Expand Up @@ -250,7 +255,6 @@ export function DiscoverField({
};

const fieldInfoIcon = getFieldInfoIcon();

const shouldRenderMultiFields = !!multiFields;
const renderMultiFields = () => {
if (!multiFields) {
Expand Down Expand Up @@ -282,6 +286,35 @@ export function DiscoverField({
);
};

const isRuntimeField = Boolean(indexPattern.getFieldByName(field.name)?.runtimeField);
const isUnknownField = field.type === 'unknown' || field.type === 'unknown_selected';
const canEditField = onEditField && (!isUnknownField || isRuntimeField);
const displayNameGrow = canEditField ? 9 : 10;
const popoverTitle = (
<EuiPopoverTitle style={{ textTransform: 'none' }} className="eui-textBreakWord">
<EuiFlexGroup responsive={false}>
<EuiFlexItem grow={displayNameGrow}>{field.displayName}</EuiFlexItem>
{canEditField && (
<EuiFlexItem grow={1} data-test-subj="discoverFieldListPanelEditItem">
<EuiButtonIcon
onClick={() => {
if (onEditField) {
togglePopover();
onEditField(field.name);
}
}}
iconType="pencil"
data-test-subj={`discoverFieldListPanelEdit-${field.name}`}
aria-label={i18n.translate('discover.fieldChooser.discoverField.editFieldLabel', {
defaultMessage: 'Edit index pattern field',
})}
/>
</EuiFlexItem>
)}
</EuiFlexGroup>
</EuiPopoverTitle>
);

return (
<EuiPopover
display="block"
Expand All @@ -305,9 +338,7 @@ export function DiscoverField({
anchorPosition="rightUp"
panelClassName="dscSidebarItem__fieldPopoverPanel"
>
<EuiPopoverTitle style={{ textTransform: 'none' }} className="eui-textBreakWord">
{field.displayName}
</EuiPopoverTitle>
{popoverTitle}
<EuiTitle size="xxxs">
<h5>
{i18n.translate('discover.fieldChooser.discoverField.fieldTopValuesLabel', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ const mockServices = ({
}
},
},
indexPatternFieldEditor: {
openEditor: jest.fn(),
userPermissions: {
editIndexPattern: jest.fn(),
},
},
} as unknown) as DiscoverServices;

jest.mock('../../../kibana_services', () => ({
Expand Down Expand Up @@ -102,6 +108,7 @@ function getCompProps(): DiscoverSidebarProps {
fieldFilter: getDefaultFieldFilter(),
setFieldFilter: jest.fn(),
setAppState: jest.fn(),
onEditRuntimeField: jest.fn(),
};
}

Expand Down
Loading

0 comments on commit 5d9033e

Please sign in to comment.