Skip to content

Commit

Permalink
Disabled edit alert button on management ui for non registered UI ale…
Browse files Browse the repository at this point in the history
…rt types (#60439)
  • Loading branch information
YulNaumenko authored Mar 17, 2020
1 parent 8412ab6 commit 2e6c76f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
10 changes: 0 additions & 10 deletions x-pack/plugins/alerting/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,6 @@ export class AlertingPlugin {
muteAlertInstanceRoute(router, this.licenseState);
unmuteAlertInstanceRoute(router, this.licenseState);

alertTypeRegistry.register({
id: 'test',
actionGroups: [{ id: 'default', name: 'Default' }],
defaultActionGroupId: 'default',
name: 'Test',
executor: async options => {
return { status: 'ok' };
},
});

return {
registerType: alertTypeRegistry.register.bind(alertTypeRegistry),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ describe('alerts_list component with items', () => {
alertTypeRegistry: alertTypeRegistry as any,
};

alertTypeRegistry.has.mockReturnValue(true);

wrapper = mountWithIntl(
<AppContextProvider appDeps={deps}>
<AlertsList />
Expand All @@ -257,11 +259,15 @@ describe('alerts_list component with items', () => {
expect(loadActionTypes).toHaveBeenCalled();
}

it('renders table of connectors', async () => {
it('renders table of alerts', async () => {
await setup();
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 @@ -455,6 +461,8 @@ describe('alerts_list with show only capability', () => {
alertTypeRegistry: alertTypeRegistry as any,
};

alertTypeRegistry.has.mockReturnValue(false);

wrapper = mountWithIntl(
<AppContextProvider appDeps={deps}>
<AlertsList />
Expand All @@ -473,4 +481,8 @@ 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 @@ -225,7 +225,7 @@ export const AlertsList: React.FunctionComponent = () => {
? [
{
render: (item: AlertTableItem) => {
return (
return alertTypeRegistry.has(item.alertTypeId) ? (
<EuiLink
data-test-subj="alertsTableCell-editLink"
color="primary"
Expand All @@ -236,6 +236,8 @@ export const AlertsList: React.FunctionComponent = () => {
id="xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.editLinkTitle"
/>
</EuiLink>
) : (
<></>
);
},
},
Expand Down

0 comments on commit 2e6c76f

Please sign in to comment.