-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Synthetics] Fixes partial updates for params and params viewing (
#195866) (#197850) # Backport This will backport the following commits from `main` to `8.x`: - [[Synthetics] Fixes partial updates for params and params viewing (#195866)](#195866) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-25T15:06:52Z","message":"[Synthetics] Fixes partial updates for params and params viewing (#195866)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/167781\r\n\r\nIn docs we says that only key/value pairs are required, but in actual\r\nedit, that means rest of the data was being lost on edits\r\n\r\nAllow partial updates to params edit API !!\r\n\r\nThis PR makes sure prev objects is fetched and merged with new data\r\nhence allowing partial updates !!\r\n\r\nWe are also allowing the ability to view value of the secret once it's\r\nsaved via API !!\r\n\r\n### Value is hidden\r\nParam value will not be visible unless user is `super_user` or\r\n`kibana_admin`, though user can assign new value.\r\n\r\n---------\r\n\r\nCo-authored-by: Justin Kambic <[email protected]>","sha":"0ff9a8a9d9ff2bdb99562eeca29152bd0a0c4385","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-management"],"title":"[Synthetics] Fixes partial updates for params and params viewing","number":195866,"url":"https://github.com/elastic/kibana/pull/195866","mergeCommit":{"message":"[Synthetics] Fixes partial updates for params and params viewing (#195866)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/167781\r\n\r\nIn docs we says that only key/value pairs are required, but in actual\r\nedit, that means rest of the data was being lost on edits\r\n\r\nAllow partial updates to params edit API !!\r\n\r\nThis PR makes sure prev objects is fetched and merged with new data\r\nhence allowing partial updates !!\r\n\r\nWe are also allowing the ability to view value of the secret once it's\r\nsaved via API !!\r\n\r\n### Value is hidden\r\nParam value will not be visible unless user is `super_user` or\r\n`kibana_admin`, though user can assign new value.\r\n\r\n---------\r\n\r\nCo-authored-by: Justin Kambic <[email protected]>","sha":"0ff9a8a9d9ff2bdb99562eeca29152bd0a0c4385"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195866","number":195866,"mergeCommit":{"message":"[Synthetics] Fixes partial updates for params and params viewing (#195866)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/167781\r\n\r\nIn docs we says that only key/value pairs are required, but in actual\r\nedit, that means rest of the data was being lost on edits\r\n\r\nAllow partial updates to params edit API !!\r\n\r\nThis PR makes sure prev objects is fetched and merged with new data\r\nhence allowing partial updates !!\r\n\r\nWe are also allowing the ability to view value of the secret once it's\r\nsaved via API !!\r\n\r\n### Value is hidden\r\nParam value will not be visible unless user is `super_user` or\r\n`kibana_admin`, though user can assign new value.\r\n\r\n---------\r\n\r\nCo-authored-by: Justin Kambic <[email protected]>","sha":"0ff9a8a9d9ff2bdb99562eeca29152bd0a0c4385"}}]}] BACKPORT--> Co-authored-by: Shahzad <[email protected]>
- Loading branch information
1 parent
9f5ff83
commit 4c22558
Showing
12 changed files
with
355 additions
and
110 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
20 changes: 20 additions & 0 deletions
20
...lution/synthetics/public/apps/synthetics/components/settings/components/optional_text.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,20 @@ | ||
/* | ||
* 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 { EuiText } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React from 'react'; | ||
|
||
export function OptionalText() { | ||
return ( | ||
<EuiText size="xs" color="subdued"> | ||
{i18n.translate('xpack.synthetics.sloEdit.optionalLabel', { | ||
defaultMessage: 'Optional', | ||
})} | ||
</EuiText> | ||
); | ||
} |
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
78 changes: 78 additions & 0 deletions
78
...synthetics/public/apps/synthetics/components/settings/global_params/param_value_field.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,78 @@ | ||
/* | ||
* 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 { EuiCallOut, EuiFormRow, EuiSpacer, EuiTextArea } from '@elastic/eui'; | ||
import React from 'react'; | ||
import { useFormContext, useFormState } from 'react-hook-form'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { OptionalText } from '../components/optional_text'; | ||
import { ListParamItem } from './params_list'; | ||
import { SyntheticsParams } from '../../../../../../common/runtime_types'; | ||
import { VALUE_LABEL, VALUE_REQUIRED } from './add_param_form'; | ||
|
||
export const ParamValueField = ({ isEditingItem }: { isEditingItem: ListParamItem | null }) => { | ||
const { register } = useFormContext<SyntheticsParams>(); | ||
const { errors } = useFormState<SyntheticsParams>(); | ||
|
||
if (isEditingItem) { | ||
return ( | ||
<> | ||
<EuiFormRow | ||
fullWidth | ||
label={NEW_VALUE_LABEL} | ||
isInvalid={Boolean(errors?.value)} | ||
error={errors?.value?.message} | ||
labelAppend={<OptionalText />} | ||
> | ||
<EuiTextArea | ||
data-test-subj="syntheticsAddParamFormTextArea" | ||
fullWidth | ||
aria-label={NEW_VALUE_LABEL} | ||
{...register('value')} | ||
/> | ||
</EuiFormRow> | ||
<EuiSpacer size="xs" /> | ||
<EuiCallOut | ||
size="s" | ||
title={i18n.translate('xpack.synthetics.paramValueField.euiCallOut.newValue', { | ||
defaultMessage: | ||
'Assign a new value to update this parameter, or leave blank to keep the current value.', | ||
})} | ||
iconType="iInCircle" | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<EuiFormRow | ||
fullWidth | ||
label={VALUE_LABEL} | ||
isInvalid={Boolean(errors?.value)} | ||
error={errors?.value?.message} | ||
> | ||
<EuiTextArea | ||
data-test-subj="syntheticsAddParamFormTextArea" | ||
fullWidth | ||
aria-label={VALUE_LABEL} | ||
{...register('value', { | ||
required: { | ||
value: true, | ||
message: VALUE_REQUIRED, | ||
}, | ||
})} | ||
/> | ||
</EuiFormRow> | ||
); | ||
}; | ||
|
||
export const NEW_VALUE_LABEL = i18n.translate( | ||
'xpack.synthetics.monitorManagement.paramForm.newValue', | ||
{ | ||
defaultMessage: 'New value', | ||
} | ||
); |
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
Oops, something went wrong.