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

Remove edit alert button from alerts list #64643

Merged
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
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -15905,7 +15905,6 @@
"xpack.triggersActionsUI.sections.alertsList.actionTypeFilterLabel": "アクションタイプ",
"xpack.triggersActionsUI.sections.alertsList.addActionButtonLabel": "アラートの作成",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.alertTypeTitle": "タイプ",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.editLinkTitle": "編集",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.intervalTitle": "次の間隔で実行",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.nameTitle": "名前",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.tagsText": "タグ",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -15910,7 +15910,6 @@
"xpack.triggersActionsUI.sections.alertsList.actionTypeFilterLabel": "操作类型",
"xpack.triggersActionsUI.sections.alertsList.addActionButtonLabel": "创建告警",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.alertTypeTitle": "类型",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.editLinkTitle": "编辑",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.intervalTitle": "运行间隔",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.nameTitle": "名称",
"xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.tagsText": "标记",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,25 @@ describe('alert_form', () => {
const alertTypeSelectOptions = wrapper.find('[data-test-subj="selectedAlertTypeTitle"]');
expect(alertTypeSelectOptions.exists()).toBeTruthy();
});

it('should update throttle value', async () => {
const newThrottle = 17;
await setup();
const throttleField = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleField.exists()).toBeTruthy();
throttleField.at(1).simulate('change', { target: { value: newThrottle.toString() } });
const throttleFieldAfterUpdate = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleFieldAfterUpdate.at(1).prop('value')).toEqual(newThrottle);
});

it('should unset throttle value', async () => {
const newThrottle = '';
await setup();
const throttleField = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleField.exists()).toBeTruthy();
throttleField.at(1).simulate('change', { target: { value: newThrottle } });
const throttleFieldAfterUpdate = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleFieldAfterUpdate.at(1).prop('value')).toEqual(newThrottle);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ describe('alerts_list component with items', () => {
expect(wrapper.find('EuiBasicTable')).toHaveLength(1);
expect(wrapper.find('EuiTableRow')).toHaveLength(2);
});
it('renders edit button for registered alert types', async () => {
await setup();
expect(wrapper.find('[data-test-subj="alertsTableCell-editLink"]').length).toBeGreaterThan(0);
});
});

describe('alerts_list component empty with show only capability', () => {
Expand Down Expand Up @@ -442,8 +438,4 @@ describe('alerts_list with show only capability', () => {
expect(wrapper.find('EuiTableRow')).toHaveLength(2);
// TODO: check delete button
});
it('not renders edit button for non registered alert types', async () => {
await setup();
expect(wrapper.find('[data-test-subj="alertsTableCell-editLink"]').length).toBe(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { isEmpty } from 'lodash';
import { AlertsContextProvider } from '../../../context/alerts_context';
import { useAppDependencies } from '../../../app_context';
import { ActionType, Alert, AlertTableItem, AlertTypeIndex, Pagination } from '../../../../types';
import { AlertAdd, AlertEdit } from '../../alert_form';
import { AlertAdd } from '../../alert_form';
import { BulkOperationPopover } from '../../common/components/bulk_operation_popover';
import { AlertQuickEditButtonsWithApi as AlertQuickEditButtons } from '../../common/components/alert_quick_edit_buttons';
import { CollapsedItemActionsWithApi as CollapsedItemActions } from './collapsed_item_actions';
Expand Down Expand Up @@ -85,8 +85,6 @@ export const AlertsList: React.FunctionComponent = () => {
data: [],
totalItemCount: 0,
});
const [editedAlertItem, setEditedAlertItem] = useState<AlertTableItem | undefined>(undefined);
const [editFlyoutVisible, setEditFlyoutVisibility] = useState<boolean>(false);
const [alertsToDelete, setAlertsToDelete] = useState<string[]>([]);

useEffect(() => {
Expand Down Expand Up @@ -162,11 +160,6 @@ export const AlertsList: React.FunctionComponent = () => {
}
}

async function editItem(alertTableItem: AlertTableItem) {
setEditedAlertItem(alertTableItem);
setEditFlyoutVisibility(true);
}

const alertsTableColumns = [
{
field: 'name',
Expand Down Expand Up @@ -219,27 +212,6 @@ export const AlertsList: React.FunctionComponent = () => {
truncateText: false,
'data-test-subj': 'alertsTableCell-interval',
},
{
name: '',
width: '50px',
render(item: AlertTableItem) {
if (!canSave || !alertTypeRegistry.has(item.alertTypeId)) {
return;
}
return (
<EuiLink
data-test-subj="alertsTableCell-editLink"
color="primary"
onClick={() => editItem(item)}
>
<FormattedMessage
defaultMessage="Edit"
id="xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.editLinkTitle"
/>
</EuiLink>
);
},
},
{
name: '',
width: '40px',
Expand Down Expand Up @@ -453,14 +425,6 @@ export const AlertsList: React.FunctionComponent = () => {
addFlyoutVisible={alertFlyoutVisible}
setAddFlyoutVisibility={setAlertFlyoutVisibility}
/>
{editFlyoutVisible && editedAlertItem ? (
<AlertEdit
key={editedAlertItem.id}
initialAlert={editedAlertItem}
editFlyoutVisible={editFlyoutVisible}
setEditFlyoutVisibility={setEditFlyoutVisibility}
/>
) : null}
</AlertsContextProvider>
</section>
);
Expand Down
187 changes: 0 additions & 187 deletions x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,193 +126,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
]);
});

it('should edit an alert', async () => {
const createdAlert = await createAlert({
alertTypeId: '.index-threshold',
name: generateUniqueKey(),
params: {
aggType: 'count',
termSize: 5,
thresholdComparator: '>',
timeWindowSize: 5,
timeWindowUnit: 'm',
groupBy: 'all',
threshold: [1000, 5000],
index: ['.kibana_1'],
timeField: 'alert',
},
});
await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);

const searchResults = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResults).to.eql([
{
name: createdAlert.name,
tagsText: 'foo, bar',
alertType: 'Index threshold',
interval: '1m',
},
]);
const editLink = await testSubjects.findAll('alertsTableCell-editLink');
await editLink[0].click();

const updatedAlertName = `Changed Alert Name ${generateUniqueKey()}`;
await testSubjects.setValue('alertNameInput', updatedAlertName, { clearWithKeyboard: true });

await find.clickByCssSelector('[data-test-subj="saveEditedAlertButton"]:not(disabled)');

const toastTitle = await pageObjects.common.closeToast();
expect(toastTitle).to.eql(`Updated '${updatedAlertName}'`);
await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(updatedAlertName);

const searchResultsAfterEdit = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResultsAfterEdit).to.eql([
{
name: updatedAlertName,
tagsText: 'foo, bar',
alertType: 'Index threshold',
interval: '1m',
},
]);
});

it('should set an alert throttle', async () => {
const alertName = `edit throttle ${generateUniqueKey()}`;
const createdAlert = await createAlert({
alertTypeId: '.index-threshold',
name: alertName,
params: {
aggType: 'count',
termSize: 5,
thresholdComparator: '>',
timeWindowSize: 5,
timeWindowUnit: 'm',
groupBy: 'all',
threshold: [1000, 5000],
index: ['.kibana_1'],
timeField: 'alert',
},
});
await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);

const searchResults = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResults).to.eql([
{
name: createdAlert.name,
tagsText: 'foo, bar',
alertType: 'Index threshold',
interval: '1m',
},
]);

const editLink = await testSubjects.findAll('alertsTableCell-editLink');
await editLink[0].click();

await testSubjects.setValue('throttleInput', '1', { clearWithKeyboard: true });

await find.clickByCssSelector('[data-test-subj="saveEditedAlertButton"]:not(disabled)');

expect(await pageObjects.common.closeToast()).to.eql(`Updated '${createdAlert.name}'`);

await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
await (await testSubjects.findAll('alertsTableCell-editLink'))[0].click();
const throttleInput = await testSubjects.find('throttleInput');
expect(await throttleInput.getAttribute('value')).to.eql('1');
});

it('should unset an alert throttle', async () => {
const alertName = `edit throttle ${generateUniqueKey()}`;
const createdAlert = await createAlert({
alertTypeId: '.index-threshold',
name: alertName,
throttle: '10m',
params: {
aggType: 'count',
termSize: 5,
thresholdComparator: '>',
timeWindowSize: 5,
timeWindowUnit: 'm',
groupBy: 'all',
threshold: [1000, 5000],
index: ['.kibana_1'],
timeField: 'alert',
},
});
await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);

const searchResults = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResults).to.eql([
{
name: createdAlert.name,
tagsText: 'foo, bar',
alertType: 'Index threshold',
interval: '1m',
},
]);

const editLink = await testSubjects.findAll('alertsTableCell-editLink');
await editLink[0].click();

const throttleInputToUnsetValue = await testSubjects.find('throttleInput');

expect(await throttleInputToUnsetValue.getAttribute('value')).to.eql('10');
await throttleInputToUnsetValue.click();
await throttleInputToUnsetValue.clearValueWithKeyboard();

expect(await throttleInputToUnsetValue.getAttribute('value')).to.eql('');

await find.clickByCssSelector('[data-test-subj="saveEditedAlertButton"]:not(disabled)');

expect(await pageObjects.common.closeToast()).to.eql(`Updated '${createdAlert.name}'`);

await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
await (await testSubjects.findAll('alertsTableCell-editLink'))[0].click();
const throttleInput = await testSubjects.find('throttleInput');
expect(await throttleInput.getAttribute('value')).to.eql('');
});

it('should reset alert when canceling an edit', async () => {
const createdAlert = await createAlert({
alertTypeId: '.index-threshold',
name: generateUniqueKey(),
params: {
aggType: 'count',
termSize: 5,
thresholdComparator: '>',
timeWindowSize: 5,
timeWindowUnit: 'm',
groupBy: 'all',
threshold: [1000, 5000],
index: ['.kibana_1'],
timeField: 'alert',
},
});
await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);

const editLink = await testSubjects.findAll('alertsTableCell-editLink');
await editLink[0].click();

const updatedAlertName = `Changed Alert Name ${generateUniqueKey()}`;
await testSubjects.setValue('alertNameInput', updatedAlertName);

await testSubjects.click('cancelSaveEditedAlertButton');
await find.waitForDeletedByCssSelector('[data-test-subj="cancelSaveEditedAlertButton"]');

const editLinkPostCancel = await testSubjects.findAll('alertsTableCell-editLink');
await editLinkPostCancel[0].click();

const nameInputAfterCancel = await testSubjects.find('alertNameInput');
const textAfterCancel = await nameInputAfterCancel.getAttribute('value');
expect(textAfterCancel).to.eql(createdAlert.name);
});

it('should search for tags', async () => {
const createdAlert = await createAlert();
await pageObjects.common.navigateToApp('triggersActions');
Expand Down