mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.14`: - [[Cloud Security] Patch fix for Column label on Cloud Security Data table (#186425)](https://github.com/elastic/kibana/pull/186425) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Rickyanto Ang","email":"rickyangwyn@gmail.com"},"sourceCommit":{"committedDate":"2024-06-20T15:30:19Z","message":"[Cloud Security] Patch fix for Column label on Cloud Security Data table (#186425)\n\n## Summary\r\n<img width=\"1478\" alt=\"Screenshot 2024-06-18 at 6 10 05 PM\"\r\nsrc=\"f095591d
-f0ee-41bd-8b7d-07880bcf61d9\">\r\n\r\n\r\nCurrently we have an issue where if user already has localStorageKey\r\nfrom previous version where we still use Update for our Column Label and\r\nthen proceed to upgrading to version where we no longer use that, the\r\ncolumn name in Findings table will show field name (it shows resource.id\r\ninstead of Resource ID)\r\n\r\nalso because we changed the logic and not allow users to change the\r\ncolumn headers in the data grid, option to **edit data view field** is\r\nremoved for Cloud Security Table\r\n<img width=\"741\" alt=\"Screenshot 2024-06-19 at 9 16 06 AM\"\r\nsrc=\"df1ec765
-89de-4f43-a723-daf9558af135\">\r\n\r\n\r\nThis patch fixes that issues\r\n\r\nRelated to #184295","sha":"7304484cf4f160b92d477f85b59815d8d0c56986","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Cloud Security","backport:prev-minor","v8.15.0","v8.14.2"],"title":"[Cloud Security] Patch fix for Column label on Cloud Security Data table","number":186425,"url":"https://github.com/elastic/kibana/pull/186425","mergeCommit":{"message":"[Cloud Security] Patch fix for Column label on Cloud Security Data table (#186425)\n\n## Summary\r\n<img width=\"1478\" alt=\"Screenshot 2024-06-18 at 6 10 05 PM\"\r\nsrc=\"f095591d
-f0ee-41bd-8b7d-07880bcf61d9\">\r\n\r\n\r\nCurrently we have an issue where if user already has localStorageKey\r\nfrom previous version where we still use Update for our Column Label and\r\nthen proceed to upgrading to version where we no longer use that, the\r\ncolumn name in Findings table will show field name (it shows resource.id\r\ninstead of Resource ID)\r\n\r\nalso because we changed the logic and not allow users to change the\r\ncolumn headers in the data grid, option to **edit data view field** is\r\nremoved for Cloud Security Table\r\n<img width=\"741\" alt=\"Screenshot 2024-06-19 at 9 16 06 AM\"\r\nsrc=\"df1ec765
-89de-4f43-a723-daf9558af135\">\r\n\r\n\r\nThis patch fixes that issues\r\n\r\nRelated to #184295","sha":"7304484cf4f160b92d477f85b59815d8d0c56986"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"main","label":"v8.15.0","branchLabelMappingKey":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/186425","number":186425,"mergeCommit":{"message":"[Cloud Security] Patch fix for Column label on Cloud Security Data table (#186425)\n\n## Summary\r\n<img width=\"1478\" alt=\"Screenshot 2024-06-18 at 6 10 05 PM\"\r\nsrc=\"f095591d
-f0ee-41bd-8b7d-07880bcf61d9\">\r\n\r\n\r\nCurrently we have an issue where if user already has localStorageKey\r\nfrom previous version where we still use Update for our Column Label and\r\nthen proceed to upgrading to version where we no longer use that, the\r\ncolumn name in Findings table will show field name (it shows resource.id\r\ninstead of Resource ID)\r\n\r\nalso because we changed the logic and not allow users to change the\r\ncolumn headers in the data grid, option to **edit data view field** is\r\nremoved for Cloud Security Table\r\n<img width=\"741\" alt=\"Screenshot 2024-06-19 at 9 16 06 AM\"\r\nsrc=\"df1ec765
-89de-4f43-a723-daf9558af135\">\r\n\r\n\r\nThis patch fixes that issues\r\n\r\nRelated to #184295","sha":"7304484cf4f160b92d477f85b59815d8d0c56986"}},{"branch":"8.14","label":"v8.14.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Rickyanto Ang <rickyangwyn@gmail.com>
This commit is contained in:
parent
db83390d0b
commit
876a76b4ff
4 changed files with 35 additions and 35 deletions
|
@ -265,7 +265,7 @@ export interface UnifiedDataTableProps {
|
|||
theme: ThemeServiceStart;
|
||||
fieldFormats: FieldFormatsStart;
|
||||
uiSettings: IUiSettingsClient;
|
||||
dataViewFieldEditor: DataViewFieldEditorStart;
|
||||
dataViewFieldEditor?: DataViewFieldEditorStart;
|
||||
toastNotifications: ToastsStart;
|
||||
storage: Storage;
|
||||
data: DataPublicPluginStart;
|
||||
|
@ -625,7 +625,7 @@ export const UnifiedDataTable = ({
|
|||
() =>
|
||||
onFieldEdited
|
||||
? (fieldName: string) => {
|
||||
closeFieldEditor.current = services.dataViewFieldEditor.openEditor({
|
||||
closeFieldEditor.current = services?.dataViewFieldEditor?.openEditor({
|
||||
ctx: {
|
||||
dataView,
|
||||
},
|
||||
|
@ -636,7 +636,7 @@ export const UnifiedDataTable = ({
|
|||
});
|
||||
}
|
||||
: undefined,
|
||||
[dataView, onFieldEdited, services.dataViewFieldEditor]
|
||||
[dataView, onFieldEdited, services?.dataViewFieldEditor]
|
||||
);
|
||||
|
||||
const timeFieldName = dataView.timeFieldName;
|
||||
|
@ -730,7 +730,8 @@ export const UnifiedDataTable = ({
|
|||
uiSettings,
|
||||
toastNotifications,
|
||||
},
|
||||
hasEditDataViewPermission: () => dataViewFieldEditor.userPermissions.editIndexPattern(),
|
||||
hasEditDataViewPermission: () =>
|
||||
Boolean(dataViewFieldEditor?.userPermissions?.editIndexPattern()),
|
||||
valueToStringConverter,
|
||||
onFilter,
|
||||
editField,
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
* 2.0.
|
||||
*/
|
||||
import React, { useState, useMemo } from 'react';
|
||||
import { UnifiedDataTableSettings, useColumns } from '@kbn/unified-data-table';
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
UnifiedDataTableSettings,
|
||||
UnifiedDataTableSettingsColumn,
|
||||
useColumns,
|
||||
} from '@kbn/unified-data-table';
|
||||
import { UnifiedDataTable, DataLoadingState } from '@kbn/unified-data-table';
|
||||
import { CellActionsProvider } from '@kbn/cell-actions';
|
||||
import { SHOW_MULTIFIELDS, SORT_DEFAULT_ORDER_SETTING } from '@kbn/discover-utils';
|
||||
|
@ -111,20 +116,34 @@ export const CloudSecurityDataTable = ({
|
|||
columnsLocalStorageKey,
|
||||
defaultColumns.map((c) => c.id)
|
||||
);
|
||||
const [settings, setSettings] = useLocalStorage<UnifiedDataTableSettings>(
|
||||
const [persistedSettings, setPersistedSettings] = useLocalStorage<UnifiedDataTableSettings>(
|
||||
`${columnsLocalStorageKey}:settings`,
|
||||
{
|
||||
columns: defaultColumns.reduce((prev, curr) => {
|
||||
const columnDefaultSettings = curr.width
|
||||
? { width: curr.width, display: columnHeaders?.[curr.id] }
|
||||
: { display: columnHeaders?.[curr.id] };
|
||||
const newColumn = { [curr.id]: columnDefaultSettings };
|
||||
return { ...prev, ...newColumn };
|
||||
columns: defaultColumns.reduce((columnSettings, column) => {
|
||||
const columnDefaultSettings = column.width ? { width: column.width } : {};
|
||||
const newColumn = { [column.id]: columnDefaultSettings };
|
||||
return { ...columnSettings, ...newColumn };
|
||||
}, {} as UnifiedDataTableSettings['columns']),
|
||||
}
|
||||
);
|
||||
|
||||
const { dataView, dataViewIsRefetching, dataViewRefetch } = useDataViewContext();
|
||||
const settings = useMemo(() => {
|
||||
return {
|
||||
columns: Object.keys(persistedSettings?.columns as UnifiedDataTableSettings).reduce(
|
||||
(columnSettings, columnId) => {
|
||||
const newColumn: UnifiedDataTableSettingsColumn = {
|
||||
..._.pick(persistedSettings?.columns?.[columnId], ['width']),
|
||||
display: columnHeaders?.[columnId],
|
||||
};
|
||||
|
||||
return { ...columnSettings, [columnId]: newColumn };
|
||||
},
|
||||
{} as UnifiedDataTableSettings['columns']
|
||||
),
|
||||
};
|
||||
}, [persistedSettings, columnHeaders]);
|
||||
|
||||
const { dataView, dataViewIsRefetching } = useDataViewContext();
|
||||
|
||||
const [expandedDoc, setExpandedDoc] = useState<DataTableRecord | undefined>(undefined);
|
||||
|
||||
|
@ -142,7 +161,6 @@ export const CloudSecurityDataTable = ({
|
|||
fieldFormats,
|
||||
toastNotifications,
|
||||
storage,
|
||||
dataViewFieldEditor,
|
||||
} = useKibana().services;
|
||||
|
||||
const styles = useStyles();
|
||||
|
@ -157,7 +175,6 @@ export const CloudSecurityDataTable = ({
|
|||
toastNotifications,
|
||||
storage,
|
||||
data,
|
||||
dataViewFieldEditor,
|
||||
};
|
||||
|
||||
const {
|
||||
|
@ -197,14 +214,13 @@ export const CloudSecurityDataTable = ({
|
|||
);
|
||||
|
||||
const onResize = (colSettings: { columnId: string; width: number }) => {
|
||||
const grid = settings || {};
|
||||
const grid = persistedSettings || {};
|
||||
const newColumns = { ...(grid.columns || {}) };
|
||||
newColumns[colSettings.columnId] = {
|
||||
width: Math.round(colSettings.width),
|
||||
display: columnHeaders?.[colSettings.columnId],
|
||||
};
|
||||
const newGrid = { ...grid, columns: newColumns };
|
||||
setSettings(newGrid);
|
||||
setPersistedSettings(newGrid);
|
||||
};
|
||||
|
||||
const externalCustomRenderers = useMemo(() => {
|
||||
|
@ -290,7 +306,6 @@ export const CloudSecurityDataTable = ({
|
|||
gridStyleOverride={gridStyle}
|
||||
rowLineHeightOverride="24px"
|
||||
controlColumnIds={controlColumnIds}
|
||||
onFieldEdited={dataViewRefetch}
|
||||
/>
|
||||
</div>
|
||||
</CellActionsProvider>
|
||||
|
|
|
@ -236,14 +236,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('DataTable features', () => {
|
||||
it('Edit data view field option is Enabled', async () => {
|
||||
await latestFindingsTable.toggleEditDataViewFieldsOption('result.evaluation');
|
||||
expect(await testSubjects.find('gridEditFieldButton')).to.be.ok();
|
||||
await latestFindingsTable.toggleEditDataViewFieldsOption('result.evaluation');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Findings - Fields selector', () => {
|
||||
const CSP_FIELDS_SELECTOR_MODAL = 'cloudSecurityFieldsSelectorModal';
|
||||
const CSP_FIELDS_SELECTOR_OPEN_BUTTON = 'cloudSecurityFieldsSelectorOpenButton';
|
||||
|
|
|
@ -93,14 +93,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('DataTable features', () => {
|
||||
it('Edit data view field option is Enabled', async () => {
|
||||
await latestVulnerabilitiesTable.toggleEditDataViewFieldsOption('vulnerability.id');
|
||||
expect(await testSubjects.find('gridEditFieldButton')).to.be.ok();
|
||||
await latestVulnerabilitiesTable.toggleEditDataViewFieldsOption('vulnerability.id');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Vulnerabilities - Fields selector', () => {
|
||||
const CSP_FIELDS_SELECTOR_MODAL = 'cloudSecurityFieldsSelectorModal';
|
||||
const CSP_FIELDS_SELECTOR_OPEN_BUTTON = 'cloudSecurityFieldsSelectorOpenButton';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue