Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[osci23] implmented advance setting in Dicover: MODIFY_COLUMN_ON_SWITCH #5508

Merged
merged 13 commits into from
Dec 21, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
modify to match discover legacy behavior, columns from previous colum…
…n are only shown in canvas area

Signed-off-by: qiwen li <[email protected]>
MadaniKK committed Nov 21, 2023
commit 517eeebe7ce07e2d6e13b809ff3fd10a3baa1820
Original file line number Diff line number Diff line change
@@ -103,14 +103,9 @@ export function DiscoverSidebar({
const uiSettings = services.uiSettings;

useEffect(() => {
const newFields = getIndexPatternFieldList(
uiSettings.get(MODIFY_COLUMNS_ON_SWITCH),
selectedIndexPattern,
fieldCounts
);
const newFields = getIndexPatternFieldList(selectedIndexPattern, fieldCounts);
setFields(newFields);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedIndexPattern, fieldCounts, hits, services, uiSettings.get(MODIFY_COLUMNS_ON_SWITCH)]);
}, [selectedIndexPattern, fieldCounts, hits, services]);

const onChangeFieldSearch = useCallback(
(field: string, value: string | boolean | undefined) => {
Original file line number Diff line number Diff line change
@@ -32,25 +32,9 @@ import { difference } from 'lodash';
import { IndexPattern, IndexPatternField } from 'src/plugins/data/public';

export function getIndexPatternFieldList(
modifyColumn: boolean,
indexPattern?: IndexPattern,
fieldCounts?: Record<string, number>
) {
if (!indexPattern || !fieldCounts) return [];
if (modifyColumn) {
return [...indexPattern.fields.getAll()];
}
const fieldNamesInDocs = Object.keys(fieldCounts);
const fieldNamesInIndexPattern = indexPattern.fields.getAll().map((fld) => fld.name);
const unknownTypes: IndexPatternField[] = [];

difference(fieldNamesInDocs, fieldNamesInIndexPattern).forEach((unknownFieldName) => {
unknownTypes.push({
displayName: String(unknownFieldName),
name: String(unknownFieldName),
type: 'unknown',
} as IndexPatternField);
});

return [...indexPattern.fields.getAll(), ...unknownTypes];
return [...indexPattern.fields.getAll()];
}