[Discover] Display toast when adding columns and filters from document flyout (#97270)
This commit is contained in:
parent
042fa1a2ce
commit
69edee5b75
|
@ -178,15 +178,29 @@ export function DiscoverGridFlyout({
|
||||||
indexPattern={indexPattern}
|
indexPattern={indexPattern}
|
||||||
filter={(mapping, value, mode) => {
|
filter={(mapping, value, mode) => {
|
||||||
onFilter(mapping, value, mode);
|
onFilter(mapping, value, mode);
|
||||||
onClose();
|
services.toastNotifications.addSuccess(
|
||||||
|
i18n.translate('discover.grid.flyout.toastFilterAdded', {
|
||||||
|
defaultMessage: `Filter was added`,
|
||||||
|
})
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
onRemoveColumn={(columnName: string) => {
|
onRemoveColumn={(columnName: string) => {
|
||||||
onRemoveColumn(columnName);
|
onRemoveColumn(columnName);
|
||||||
onClose();
|
services.toastNotifications.addSuccess(
|
||||||
|
i18n.translate('discover.grid.flyout.toastColumnRemoved', {
|
||||||
|
defaultMessage: `Column '{columnName}' was removed`,
|
||||||
|
values: { columnName },
|
||||||
|
})
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
onAddColumn={(columnName: string) => {
|
onAddColumn={(columnName: string) => {
|
||||||
onAddColumn(columnName);
|
onAddColumn(columnName);
|
||||||
onClose();
|
services.toastNotifications.addSuccess(
|
||||||
|
i18n.translate('discover.grid.flyout.toastColumnAdded', {
|
||||||
|
defaultMessage: `Column '{columnName}' was added`,
|
||||||
|
values: { columnName },
|
||||||
|
})
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</EuiFlyoutBody>
|
</EuiFlyoutBody>
|
||||||
|
|
|
@ -155,7 +155,7 @@ describe('DocViewTable at Discover', () => {
|
||||||
const elementExist = check[element];
|
const elementExist = check[element];
|
||||||
|
|
||||||
if (typeof elementExist === 'boolean') {
|
if (typeof elementExist === 'boolean') {
|
||||||
const btn = findTestSubject(rowComponent, element);
|
const btn = findTestSubject(rowComponent, element, '^=');
|
||||||
|
|
||||||
it(`renders ${element} for '${check._property}' correctly`, () => {
|
it(`renders ${element} for '${check._property}' correctly`, () => {
|
||||||
const disabled = btn.length ? btn.props().disabled : true;
|
const disabled = btn.length ? btn.props().disabled : true;
|
||||||
|
|
|
@ -65,7 +65,11 @@ export function DocViewTableRow({
|
||||||
onClick={() => onFilter(fieldMapping, valueRaw, '-')}
|
onClick={() => onFilter(fieldMapping, valueRaw, '-')}
|
||||||
/>
|
/>
|
||||||
{typeof onToggleColumn === 'function' && (
|
{typeof onToggleColumn === 'function' && (
|
||||||
<DocViewTableRowBtnToggleColumn active={isColumnActive} onClick={onToggleColumn} />
|
<DocViewTableRowBtnToggleColumn
|
||||||
|
active={isColumnActive}
|
||||||
|
onClick={onToggleColumn}
|
||||||
|
fieldname={String(key)}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<DocViewTableRowBtnFilterExists
|
<DocViewTableRowBtnFilterExists
|
||||||
disabled={!fieldMapping || !fieldMapping.filterable}
|
disabled={!fieldMapping || !fieldMapping.filterable}
|
||||||
|
|
|
@ -15,9 +15,15 @@ export interface Props {
|
||||||
active: boolean;
|
active: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
|
fieldname: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DocViewTableRowBtnToggleColumn({ onClick, active, disabled = false }: Props) {
|
export function DocViewTableRowBtnToggleColumn({
|
||||||
|
onClick,
|
||||||
|
active,
|
||||||
|
disabled = false,
|
||||||
|
fieldname = '',
|
||||||
|
}: Props) {
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
return (
|
return (
|
||||||
<EuiButtonIcon
|
<EuiButtonIcon
|
||||||
|
@ -48,7 +54,7 @@ export function DocViewTableRowBtnToggleColumn({ onClick, active, disabled = fal
|
||||||
aria-pressed={active}
|
aria-pressed={active}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className="kbnDocViewer__actionButton"
|
className="kbnDocViewer__actionButton"
|
||||||
data-test-subj="toggleColumnButton"
|
data-test-subj={`toggleColumnButton_${fieldname}`}
|
||||||
iconType={'listAdd'}
|
iconType={'listAdd'}
|
||||||
iconSize={'s'}
|
iconSize={'s'}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -22,6 +22,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
defaultIndex: 'logstash-*',
|
defaultIndex: 'logstash-*',
|
||||||
'doc_table:legacy': false,
|
'doc_table:legacy': false,
|
||||||
};
|
};
|
||||||
|
const testSubjects = getService('testSubjects');
|
||||||
|
|
||||||
describe('discover data grid doc table', function describeIndexTests() {
|
describe('discover data grid doc table', function describeIndexTests() {
|
||||||
before(async function () {
|
before(async function () {
|
||||||
|
@ -102,6 +103,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
await dataGrid.closeFlyout();
|
await dataGrid.closeFlyout();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should show allow adding columns from the detail panel', async function () {
|
||||||
|
await retry.try(async function () {
|
||||||
|
await dataGrid.clickRowToggle({ isAnchorRow: false, rowIndex: rowToInspect - 1 });
|
||||||
|
|
||||||
|
// add columns
|
||||||
|
const fields = ['_id', '_index', 'agent'];
|
||||||
|
for (const field of fields) {
|
||||||
|
await testSubjects.click(`toggleColumnButton_${field}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerWithFields = await dataGrid.getHeaderFields();
|
||||||
|
expect(headerWithFields.join(' ')).to.contain(fields.join(' '));
|
||||||
|
|
||||||
|
// remove columns
|
||||||
|
for (const field of fields) {
|
||||||
|
await testSubjects.click(`toggleColumnButton_${field}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerWithoutFields = await dataGrid.getHeaderFields();
|
||||||
|
expect(headerWithoutFields.join(' ')).not.to.contain(fields.join(' '));
|
||||||
|
|
||||||
|
await dataGrid.closeFlyout();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('add and remove columns', function () {
|
describe('add and remove columns', function () {
|
||||||
|
|
Loading…
Reference in a new issue