Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
DataFrameAnalyticsConfig,
EsFieldName,
INDEX_STATUS,
MAX_COLUMNS,
defaultSearchQuery,
} from '../../../../common';
import { isKeywordAndTextType } from '../../../../common/fields';
Expand Down Expand Up @@ -198,7 +199,7 @@ export const useExploreData = (jobId: string): UseExploreDataReturnType => {

if (selectedFields.length === 0) {
const newSelectedFields = getDefaultSelectableFields(docs, resultsField);
setSelectedFields(newSelectedFields);
setSelectedFields(newSelectedFields.sort().splice(0, MAX_COLUMNS));
}

// Create a version of the doc's source with flattened field names.
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/transform/public/app/common/data_grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import { EuiDataGridStyle } from '@elastic/eui';

export const INIT_MAX_COLUMNS = 20;

export const euiDataGridStyle: EuiDataGridStyle = {
border: 'all',
fontSize: 's',
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/transform/public/app/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

export { AggName, isAggName } from './aggregations';
export { euiDataGridStyle, euiDataGridToolbarSettings } from './data_grid';
export { euiDataGridStyle, euiDataGridToolbarSettings, INIT_MAX_COLUMNS } from './data_grid';
export {
getDefaultSelectableFields,
getFlattenedFields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
PivotGroupByConfig,
PivotGroupByConfigDict,
PivotQuery,
INIT_MAX_COLUMNS,
} from '../../common';
import { SearchItems } from '../../hooks/use_search_items';

Expand Down Expand Up @@ -131,12 +132,12 @@ export const PivotPreview: FC<PivotPreviewProps> = React.memo(
columnKeys.sort(sortColumns(groupByArr));

// Column visibility
const [visibleColumns, setVisibleColumns] = useState<EsFieldName[]>(columnKeys);
const [visibleColumns, setVisibleColumns] = useState<EsFieldName[]>([]);

useEffect(() => {
setVisibleColumns(columnKeys);
setVisibleColumns(columnKeys.splice(0, INIT_MAX_COLUMNS));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [JSON.stringify(columnKeys)]);
}, [columnKeys.join()]);

const [pagination, setPagination] = useState(defaultPagination);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import moment from 'moment-timezone';
import React, { useCallback, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';

import { i18n } from '@kbn/i18n';

Expand All @@ -32,6 +32,7 @@ import {
euiDataGridToolbarSettings,
EsFieldName,
PivotQuery,
INIT_MAX_COLUMNS,
} from '../../../../common';
import { SearchItems } from '../../../../hooks/use_search_items';
import { useToastNotifications } from '../../../../app_dependencies';
Expand Down Expand Up @@ -76,7 +77,12 @@ export const SourceIndexPreview: React.FC<Props> = React.memo(({ indexPattern, q
});

// Column visibility
const [visibleColumns, setVisibleColumns] = useState<EsFieldName[]>(indexPatternFields);
const [visibleColumns, setVisibleColumns] = useState<EsFieldName[]>([]);

useEffect(() => {
setVisibleColumns(indexPatternFields.splice(0, INIT_MAX_COLUMNS));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [indexPatternFields.join()]);

const {
errorMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function({ getService }: FtrProviderContext) {
progress: '100',
},
sourcePreview: {
columns: 45,
columns: 20,
rows: 5,
},
},
Expand Down Expand Up @@ -143,7 +143,7 @@ export default function({ getService }: FtrProviderContext) {
progress: '100',
},
sourcePreview: {
columns: 45,
columns: 20,
rows: 5,
},
},
Expand Down