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

Disabled edit button in management ui for non registered UI alert types #60439

Merged
Show file tree
Hide file tree
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
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({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused as to why this was in this file in the first place! Did it get left in from a previous PR, someone was using to test with? Good find!

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