-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Alerting UI] Fixed display permissions for edit/delete buttons when …
…user has read only access. (#107996) (#108130) * [Alerting UI] Fixed display permissions for Edit/delete buttons when user has read only access * fixed due to comments
- Loading branch information
1 parent
d08b49f
commit 331a27c
Showing
5 changed files
with
145 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...ctions_ui/public/application/sections/alerts_list/components/rule_enabled_switch.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { mountWithIntl } from '@kbn/test/jest'; | ||
import { RuleEnabledSwitch, ComponentOpts } from './rule_enabled_switch'; | ||
|
||
describe('RuleEnabledSwitch', () => { | ||
const enableAlert = jest.fn(); | ||
const props: ComponentOpts = { | ||
disableAlert: jest.fn(), | ||
enableAlert, | ||
item: { | ||
id: '1', | ||
name: 'test alert', | ||
tags: ['tag1'], | ||
enabled: true, | ||
alertTypeId: 'test_alert_type', | ||
schedule: { interval: '5d' }, | ||
actions: [], | ||
params: { name: 'test alert type name' }, | ||
createdBy: null, | ||
updatedBy: null, | ||
apiKeyOwner: null, | ||
throttle: '1m', | ||
muteAll: false, | ||
mutedInstanceIds: [], | ||
executionStatus: { | ||
status: 'active', | ||
lastExecutionDate: new Date('2020-08-20T19:23:38Z'), | ||
}, | ||
consumer: 'test', | ||
actionsCount: 0, | ||
alertType: 'test_alert_type', | ||
createdAt: new Date('2020-08-20T19:23:38Z'), | ||
enabledInLicense: true, | ||
isEditable: false, | ||
notifyWhen: null, | ||
tagsText: 'test', | ||
updatedAt: new Date('2020-08-20T19:23:38Z'), | ||
}, | ||
onAlertChanged: jest.fn(), | ||
}; | ||
|
||
beforeEach(() => jest.resetAllMocks()); | ||
|
||
test('renders switch control as disabled when rule is not editable', () => { | ||
const wrapper = mountWithIntl(<RuleEnabledSwitch {...props} />); | ||
expect(wrapper.find('[data-test-subj="enableSwitch"]').first().props().disabled).toBeTruthy(); | ||
}); | ||
|
||
test('renders switch control', () => { | ||
const wrapper = mountWithIntl( | ||
<RuleEnabledSwitch | ||
{...{ | ||
...props, | ||
item: { | ||
id: '1', | ||
name: 'test alert', | ||
tags: ['tag1'], | ||
enabled: false, | ||
alertTypeId: 'test_alert_type', | ||
schedule: { interval: '5d' }, | ||
actions: [], | ||
params: { name: 'test alert type name' }, | ||
createdBy: null, | ||
updatedBy: null, | ||
apiKeyOwner: null, | ||
throttle: '1m', | ||
muteAll: false, | ||
mutedInstanceIds: [], | ||
executionStatus: { | ||
status: 'active', | ||
lastExecutionDate: new Date('2020-08-20T19:23:38Z'), | ||
}, | ||
consumer: 'test', | ||
actionsCount: 0, | ||
alertType: 'test_alert_type', | ||
createdAt: new Date('2020-08-20T19:23:38Z'), | ||
enabledInLicense: true, | ||
isEditable: true, | ||
notifyWhen: null, | ||
tagsText: 'test', | ||
updatedAt: new Date('2020-08-20T19:23:38Z'), | ||
}, | ||
}} | ||
/> | ||
); | ||
expect(wrapper.find('[data-test-subj="enableSwitch"]').first().props().checked).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters