mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[8.8] add 'user-managed' label to the rule details page for the api keys created by users (#155699) (#157792)
# Backport This will backport the following commits from `main` to `8.8`: - [add 'user-managed' label to the rule details page for the api keys created by users (#155699)](https://github.com/elastic/kibana/pull/155699) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Ersin Erdal","email":"92688503+ersin-erdal@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-05-15T19:33:48Z","message":"add 'user-managed' label to the rule details page for the api keys created by users (#155699)\n\nResolves: #154581\r\n\r\nThis PR adds 'user-managed' label next to the API key owner name when\r\nthe API key is created by the user.\r\n\r\n<img width=\"813\" alt=\"Screenshot 2023-05-06 at 19 02 08\"\r\nsrc=\"https://user-images.githubusercontent.com/92688503/236637767-d0c0ee00-1314-4824-b97a-b7bdf1b7f43b.png\">","sha":"d297a9949fc603a797faebc997ea92bee1001fee","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","ui-copy","v8.8.0","v8.9.0"],"number":155699,"url":"https://github.com/elastic/kibana/pull/155699","mergeCommit":{"message":"add 'user-managed' label to the rule details page for the api keys created by users (#155699)\n\nResolves: #154581\r\n\r\nThis PR adds 'user-managed' label next to the API key owner name when\r\nthe API key is created by the user.\r\n\r\n<img width=\"813\" alt=\"Screenshot 2023-05-06 at 19 02 08\"\r\nsrc=\"https://user-images.githubusercontent.com/92688503/236637767-d0c0ee00-1314-4824-b97a-b7bdf1b7f43b.png\">","sha":"d297a9949fc603a797faebc997ea92bee1001fee"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/155699","number":155699,"mergeCommit":{"message":"add 'user-managed' label to the rule details page for the api keys created by users (#155699)\n\nResolves: #154581\r\n\r\nThis PR adds 'user-managed' label next to the API key owner name when\r\nthe API key is created by the user.\r\n\r\n<img width=\"813\" alt=\"Screenshot 2023-05-06 at 19 02 08\"\r\nsrc=\"https://user-images.githubusercontent.com/92688503/236637767-d0c0ee00-1314-4824-b97a-b7bdf1b7f43b.png\">","sha":"d297a9949fc603a797faebc997ea92bee1001fee"}}]}] BACKPORT--> Co-authored-by: Ersin Erdal <92688503+ersin-erdal@users.noreply.github.com>
This commit is contained in:
parent
4c2b4a091f
commit
0a574d319c
3 changed files with 33 additions and 8 deletions
|
@ -63,6 +63,7 @@ export const transformRule: RewriteRequestCase<Rule> = ({
|
|||
created_at: createdAt,
|
||||
updated_at: updatedAt,
|
||||
api_key_owner: apiKeyOwner,
|
||||
api_key_created_by_user: apiKeyCreatedByUser,
|
||||
notify_when: notifyWhen,
|
||||
mute_all: muteAll,
|
||||
muted_alert_ids: mutedInstanceIds,
|
||||
|
@ -95,6 +96,7 @@ export const transformRule: RewriteRequestCase<Rule> = ({
|
|||
activeSnoozes,
|
||||
...(lastRun ? { lastRun: transformLastRun(lastRun) } : {}),
|
||||
...(nextRun ? { nextRun } : {}),
|
||||
...(apiKeyCreatedByUser !== undefined ? { apiKeyCreatedByUser } : {}),
|
||||
...rest,
|
||||
});
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@ import {
|
|||
import { useKibana } from '../../../../common/lib/kibana';
|
||||
import { ruleTypeRegistryMock } from '../../../rule_type_registry.mock';
|
||||
|
||||
export const DATE_9999 = '9999-12-31T12:34:56.789Z';
|
||||
|
||||
jest.mock('../../../../common/lib/kibana');
|
||||
|
||||
jest.mock('../../../../common/lib/config_api', () => ({
|
||||
|
@ -110,12 +108,21 @@ describe('rule_details', () => {
|
|||
});
|
||||
|
||||
it('renders the API key owner badge when user can manage API keys', () => {
|
||||
const rule = mockRule();
|
||||
expect(
|
||||
shallow(
|
||||
<RuleDetails rule={rule} ruleType={ruleType} actionTypes={[]} {...mockRuleApis} />
|
||||
).find(<EuiBadge>{rule.apiKeyOwner}</EuiBadge>)
|
||||
).toBeTruthy();
|
||||
const rule = mockRule({ apiKeyOwner: 'elastic' });
|
||||
const wrapper = mountWithIntl(
|
||||
<RuleDetails rule={rule} ruleType={ruleType} actionTypes={[]} {...mockRuleApis} />
|
||||
);
|
||||
expect(wrapper.find('[data-test-subj="apiKeyOwnerLabel"]').first().text()).toBe('elastic');
|
||||
});
|
||||
|
||||
it('renders the user-managed icon when apiKeyCreatedByUser is true', async () => {
|
||||
const rule = mockRule({ apiKeyOwner: 'elastic', apiKeyCreatedByUser: true });
|
||||
const wrapper = mountWithIntl(
|
||||
<RuleDetails rule={rule} ruleType={ruleType} actionTypes={[]} {...mockRuleApis} />
|
||||
);
|
||||
expect(wrapper.find('[data-test-subj="apiKeyOwnerLabel"]').first().text()).toBe(
|
||||
'elastic Info'
|
||||
);
|
||||
});
|
||||
|
||||
it(`doesn't render the API key owner badge when user can't manage API keys`, () => {
|
||||
|
@ -819,6 +826,7 @@ describe('rule_details', () => {
|
|||
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
|
||||
},
|
||||
revision: 0,
|
||||
apiKeyCreatedByUser: false,
|
||||
...overloads,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import {
|
|||
EuiButton,
|
||||
EuiIcon,
|
||||
EuiLink,
|
||||
EuiIconTip,
|
||||
} from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { toMountPoint } from '@kbn/kibana-react-plugin/public';
|
||||
|
@ -366,6 +367,20 @@ export const RuleDetails: React.FunctionComponent<RuleDetailsProps> = ({
|
|||
<EuiFlexItem grow={false}>
|
||||
<EuiText size="s" data-test-subj="apiKeyOwnerLabel">
|
||||
<b>{rule.apiKeyOwner}</b>
|
||||
{rule.apiKeyCreatedByUser ? (
|
||||
<>
|
||||
|
||||
<EuiIconTip
|
||||
position="right"
|
||||
content={i18n.translate(
|
||||
'xpack.triggersActionsUI.sections.ruleDetails.userManagedApikey',
|
||||
{
|
||||
defaultMessage: 'This rule is associated with an API key.',
|
||||
}
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
</EuiText>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue