-
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.
Merge branch '8.x' into backport/8.x/pr-207654
- Loading branch information
Showing
83 changed files
with
1,794 additions
and
990 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20.15.1 | ||
20.18.2 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
20.15.1 | ||
20.18.2 |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
15 changes: 15 additions & 0 deletions
15
...platform/packages/shared/response-ops/rule_form/src/hooks/use_rule_form_screen_context.ts
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,15 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { useContext } from 'react'; | ||
import { RuleFormScreenContext } from '../rule_form_screen_context'; | ||
|
||
export const useRuleFormScreenContext = () => { | ||
return useContext(RuleFormScreenContext); | ||
}; |
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
10 changes: 10 additions & 0 deletions
10
src/platform/packages/shared/response-ops/rule_form/src/request_code_block/index.ts
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,10 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
export * from './request_code_block'; |
67 changes: 67 additions & 0 deletions
67
...form/packages/shared/response-ops/rule_form/src/request_code_block/request_code_block.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,67 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { omit, pick } from 'lodash'; | ||
import React, { useMemo } from 'react'; | ||
import { EuiCodeBlock } from '@elastic/eui'; | ||
import { | ||
CreateRuleBody, | ||
UPDATE_FIELDS_WITH_ACTIONS, | ||
UpdateRuleBody, | ||
transformCreateRuleBody, | ||
transformUpdateRuleBody, | ||
} from '../common/apis'; | ||
import { BASE_ALERTING_API_PATH } from '../constants'; | ||
import { useRuleFormState } from '../hooks'; | ||
import { SHOW_REQUEST_MODAL_ERROR } from '../translations'; | ||
import { RuleFormData } from '../types'; | ||
|
||
const stringifyBodyRequest = ({ | ||
formData, | ||
isEdit, | ||
}: { | ||
formData: RuleFormData; | ||
isEdit: boolean; | ||
}): string => { | ||
try { | ||
const request = isEdit | ||
? transformUpdateRuleBody(pick(formData, UPDATE_FIELDS_WITH_ACTIONS) as UpdateRuleBody) | ||
: transformCreateRuleBody(omit(formData, 'id') as CreateRuleBody); | ||
return JSON.stringify(request, null, 2); | ||
} catch { | ||
return SHOW_REQUEST_MODAL_ERROR; | ||
} | ||
}; | ||
|
||
interface RequestCodeBlockProps { | ||
isEdit: boolean; | ||
'data-test-subj'?: string; | ||
} | ||
export const RequestCodeBlock = (props: RequestCodeBlockProps) => { | ||
const { isEdit, 'data-test-subj': dataTestSubj } = props; | ||
const { formData, id, multiConsumerSelection } = useRuleFormState(); | ||
|
||
const formattedRequest = useMemo(() => { | ||
return stringifyBodyRequest({ | ||
formData: { | ||
...formData, | ||
...(multiConsumerSelection ? { consumer: multiConsumerSelection } : {}), | ||
}, | ||
isEdit, | ||
}); | ||
}, [formData, isEdit, multiConsumerSelection]); | ||
|
||
return ( | ||
<EuiCodeBlock language="json" isCopyable data-test-subj={dataTestSubj}> | ||
{`${isEdit ? 'PUT' : 'POST'} kbn:${BASE_ALERTING_API_PATH}/rule${ | ||
isEdit ? `/${id}` : '' | ||
}\n${formattedRequest}`} | ||
</EuiCodeBlock> | ||
); | ||
}; |
Oops, something went wrong.