Skip to content

Commit

Permalink
[8.x] [SR] Add tooltips for disabled fields on managed SLM repository…
Browse files Browse the repository at this point in the history
… and policy (#196565) (#197882)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[SR] Add tooltips for disabled fields on managed SLM repository and
policy (#196565)](#196565)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Francois-Clement
Brossard","email":"renshuki@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-25T17:43:33Z","message":"[SR]
Add tooltips for disabled fields on managed SLM repository and policy
(#196565)\n\n##
Summary\r\n\r\nCloses\r\nhttps://github.com//issues/173124#issuecomment-2352968634\r\nby
adding tooltips details when hovering the disabled SLM repository
or\r\npolicy fields.\r\n\r\n### Screenshots\r\n\r\n**SLM managed
repository**\r\n![Screenshot 2024-10-16 at 1
38\r\n19](https://github.com/user-attachments/assets/3bd11ea5-f846-433f-8615-b51de184336b)\r\n\r\n**SLM
managed policy**\r\n![Screenshot 2024-10-16 at 1
37\r\n57](https://github.com/user-attachments/assets/d11757bd-bda5-4b4f-8c1e-e795e01b1fa2)\r\n\r\n###
Checklist\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n###
For maintainers\r\n\r\n- [x] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n-
[x] This will appear in the **Release Notes** and follow
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Elena Stoeva
<59341489+ElenaStoeva@users.noreply.github.com>","sha":"3ce8b74c48a0bbee3fcabf6ec9fcae8ab1c88dcc","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Kibana
Management","release_note:skip","Feature:Snapshot and
Restore","v9.0.0","ui-copy","backport:prev-minor","v8.17.0"],"title":"[SR]
Add tooltips for disabled fields on managed SLM repository and
policy","number":196565,"url":"https://github.com/elastic/kibana/pull/196565","mergeCommit":{"message":"[SR]
Add tooltips for disabled fields on managed SLM repository and policy
(#196565)\n\n##
Summary\r\n\r\nCloses\r\nhttps://github.com//issues/173124#issuecomment-2352968634\r\nby
adding tooltips details when hovering the disabled SLM repository
or\r\npolicy fields.\r\n\r\n### Screenshots\r\n\r\n**SLM managed
repository**\r\n![Screenshot 2024-10-16 at 1
38\r\n19](https://github.com/user-attachments/assets/3bd11ea5-f846-433f-8615-b51de184336b)\r\n\r\n**SLM
managed policy**\r\n![Screenshot 2024-10-16 at 1
37\r\n57](https://github.com/user-attachments/assets/d11757bd-bda5-4b4f-8c1e-e795e01b1fa2)\r\n\r\n###
Checklist\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n###
For maintainers\r\n\r\n- [x] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n-
[x] This will appear in the **Release Notes** and follow
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Elena Stoeva
<59341489+ElenaStoeva@users.noreply.github.com>","sha":"3ce8b74c48a0bbee3fcabf6ec9fcae8ab1c88dcc"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196565","number":196565,"mergeCommit":{"message":"[SR]
Add tooltips for disabled fields on managed SLM repository and policy
(#196565)\n\n##
Summary\r\n\r\nCloses\r\nhttps://github.com//issues/173124#issuecomment-2352968634\r\nby
adding tooltips details when hovering the disabled SLM repository
or\r\npolicy fields.\r\n\r\n### Screenshots\r\n\r\n**SLM managed
repository**\r\n![Screenshot 2024-10-16 at 1
38\r\n19](https://github.com/user-attachments/assets/3bd11ea5-f846-433f-8615-b51de184336b)\r\n\r\n**SLM
managed policy**\r\n![Screenshot 2024-10-16 at 1
37\r\n57](https://github.com/user-attachments/assets/d11757bd-bda5-4b4f-8c1e-e795e01b1fa2)\r\n\r\n###
Checklist\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n###
For maintainers\r\n\r\n- [x] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n-
[x] This will appear in the **Release Notes** and follow
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Elena Stoeva
<59341489+ElenaStoeva@users.noreply.github.com>","sha":"3ce8b74c48a0bbee3fcabf6ec9fcae8ab1c88dcc"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Francois-Clement Brossard <renshuki@users.noreply.github.com>
  • Loading branch information
kibanamachine and renshuki authored Oct 25, 2024
1 parent 07c7f72 commit 837bfe9
Show file tree
Hide file tree
Showing 5 changed files with 247 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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, { ReactElement } from 'react';
import { EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

export const MANAGED_REPOSITORY_TOOLTIP_MESSAGE = i18n.translate(
'xpack.snapshotRestore.repositoryForm.disableToolTip',
{
defaultMessage: 'This field is disabled because you are editing a managed repository.',
}
);

export const MANAGED_POLICY_TOOLTIP_MESSAGE = i18n.translate(
'xpack.snapshotRestore.policyForm.disableToolTip',
{
defaultMessage: 'This field is disabled because you are editing a managed policy.',
}
);

interface Props {
isManaged?: boolean;
tooltipMessage: string;
component: ReactElement;
}

/**
* Component that wraps a given component (disabled field) with a tooltip if a repository
* or policy is managed (isManaged === true).
*
* @param {boolean} isManaged - Determines if the tooltip should be displayed.
* @param {string} tooltipMessage - The message to display inside the tooltip.
* @param {React.ReactElement} component - The component to wrap with the tooltip.
*/
export const DisableToolTip: React.FunctionComponent<Props> = ({
isManaged,
tooltipMessage,
component,
}) => {
return isManaged ? (
<EuiToolTip content={tooltipMessage} display="block">
{component}
</EuiToolTip>
) : (
component
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { useLoadRepositories } from '../../../services/http';
import { linkToAddRepository } from '../../../services/navigation';
import { InlineLoading } from '../..';
import { StepProps } from '.';
import { DisableToolTip, MANAGED_POLICY_TOOLTIP_MESSAGE } from '../../disable_tooltip';

export const PolicyStepLogistics: React.FunctionComponent<StepProps> = ({
policy,
Expand Down Expand Up @@ -258,22 +259,28 @@ export const PolicyStepLogistics: React.FunctionComponent<StepProps> = ({
}

return (
<EuiSelect
options={repositories.map(({ name }: Repository) => ({
value: name,
text: name,
}))}
hasNoInitialSelection={!doesRepositoryExist}
value={!doesRepositoryExist ? '' : policy.repository}
onBlur={() => setTouched({ ...touched, repository: true })}
onChange={(e) => {
updatePolicy({
repository: e.target.value,
});
}}
fullWidth
data-test-subj="repositorySelect"
disabled={policy?.isManagedPolicy && isEditing}
<DisableToolTip
isManaged={policy?.isManagedPolicy}
tooltipMessage={MANAGED_POLICY_TOOLTIP_MESSAGE}
component={
<EuiSelect
options={repositories.map(({ name }: Repository) => ({
value: name,
text: name,
}))}
hasNoInitialSelection={!doesRepositoryExist}
value={!doesRepositoryExist ? '' : policy.repository}
onBlur={() => setTouched({ ...touched, repository: true })}
onChange={(e) => {
updatePolicy({
repository: e.target.value,
});
}}
fullWidth
data-test-subj="repositorySelect"
disabled={policy?.isManagedPolicy && isEditing}
/>
}
/>
);
};
Expand Down Expand Up @@ -325,25 +332,31 @@ export const PolicyStepLogistics: React.FunctionComponent<StepProps> = ({
}
fullWidth
>
<EuiFieldText
defaultValue={policy.snapshotName}
fullWidth
onChange={(e) => {
updatePolicy({
snapshotName: e.target.value,
});
}}
onBlur={() => setTouched({ ...touched, snapshotName: true })}
placeholder={i18n.translate(
'xpack.snapshotRestore.policyForm.stepLogistics.policySnapshotNamePlaceholder',
{
defaultMessage: `'<daily-snap-{now/d}>'`,
description:
'Example date math snapshot name. Keeping the same syntax is important: <SOME-TRANSLATION-{now/d}>',
}
)}
data-test-subj="snapshotNameInput"
disabled={policy?.isManagedPolicy && isEditing}
<DisableToolTip
isManaged={policy?.isManagedPolicy}
tooltipMessage={MANAGED_POLICY_TOOLTIP_MESSAGE}
component={
<EuiFieldText
defaultValue={policy.snapshotName}
fullWidth
onChange={(e) => {
updatePolicy({
snapshotName: e.target.value,
});
}}
onBlur={() => setTouched({ ...touched, snapshotName: true })}
placeholder={i18n.translate(
'xpack.snapshotRestore.policyForm.stepLogistics.policySnapshotNamePlaceholder',
{
defaultMessage: `'<daily-snap-{now/d}>'`,
description:
'Example date math snapshot name. Keeping the same syntax is important: <SOME-TRANSLATION-{now/d}>',
}
)}
data-test-subj="snapshotNameInput"
disabled={policy?.isManagedPolicy && isEditing}
/>
}
/>
</EuiFormRow>
</EuiDescribedFormGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { AzureRepository, Repository } from '../../../../../common/types';
import { RepositorySettingsValidation } from '../../../services/validation';
import { ChunkSizeField, MaxSnapshotsField, MaxRestoreField } from './common';
import { DisableToolTip, MANAGED_REPOSITORY_TOOLTIP_MESSAGE } from '../../disable_tooltip';

interface Props {
repository: AzureRepository;
Expand Down Expand Up @@ -94,16 +95,22 @@ export const AzureSettings: React.FunctionComponent<Props> = ({
isInvalid={Boolean(hasErrors && settingErrors.client)}
error={settingErrors.client}
>
<EuiFieldText
defaultValue={client || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
client: e.target.value,
});
}}
data-test-subj="clientInput"
disabled={isManagedRepository}
<DisableToolTip
isManaged={isManagedRepository}
tooltipMessage={MANAGED_REPOSITORY_TOOLTIP_MESSAGE}
component={
<EuiFieldText
defaultValue={client || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
client: e.target.value,
});
}}
data-test-subj="clientInput"
disabled={isManagedRepository}
/>
}
/>
</EuiFormRow>
</EuiDescribedFormGroup>
Expand Down Expand Up @@ -139,16 +146,22 @@ export const AzureSettings: React.FunctionComponent<Props> = ({
isInvalid={Boolean(hasErrors && settingErrors.container)}
error={settingErrors.container}
>
<EuiFieldText
defaultValue={container || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
container: e.target.value,
});
}}
data-test-subj="containerInput"
disabled={isManagedRepository}
<DisableToolTip
isManaged={isManagedRepository}
tooltipMessage={MANAGED_REPOSITORY_TOOLTIP_MESSAGE}
component={
<EuiFieldText
defaultValue={container || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
container: e.target.value,
});
}}
data-test-subj="containerInput"
disabled={isManagedRepository}
/>
}
/>
</EuiFormRow>
</EuiDescribedFormGroup>
Expand Down Expand Up @@ -184,16 +197,22 @@ export const AzureSettings: React.FunctionComponent<Props> = ({
isInvalid={Boolean(hasErrors && settingErrors.basePath)}
error={settingErrors.basePath}
>
<EuiFieldText
defaultValue={basePath || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
basePath: e.target.value,
});
}}
data-test-subj="basePathInput"
disabled={isManagedRepository}
<DisableToolTip
isManaged={isManagedRepository}
tooltipMessage={MANAGED_REPOSITORY_TOOLTIP_MESSAGE}
component={
<EuiFieldText
defaultValue={basePath || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
basePath: e.target.value,
});
}}
data-test-subj="basePathInput"
disabled={isManagedRepository}
/>
}
/>
</EuiFormRow>
</EuiDescribedFormGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { EuiDescribedFormGroup, EuiFieldText, EuiFormRow, EuiSwitch, EuiTitle }
import { GCSRepository, Repository } from '../../../../../common/types';
import { RepositorySettingsValidation } from '../../../services/validation';
import { ChunkSizeField, MaxSnapshotsField, MaxRestoreField } from './common';
import { DisableToolTip, MANAGED_REPOSITORY_TOOLTIP_MESSAGE } from '../../disable_tooltip';

interface Props {
repository: GCSRepository;
Expand Down Expand Up @@ -82,16 +83,22 @@ export const GCSSettings: React.FunctionComponent<Props> = ({
isInvalid={Boolean(hasErrors && settingErrors.client)}
error={settingErrors.client}
>
<EuiFieldText
defaultValue={client || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
client: e.target.value,
});
}}
data-test-subj="clientInput"
disabled={isManagedRepository}
<DisableToolTip
isManaged={isManagedRepository}
tooltipMessage={MANAGED_REPOSITORY_TOOLTIP_MESSAGE}
component={
<EuiFieldText
defaultValue={client || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
client: e.target.value,
});
}}
data-test-subj="clientInput"
disabled={isManagedRepository}
/>
}
/>
</EuiFormRow>
</EuiDescribedFormGroup>
Expand Down Expand Up @@ -127,16 +134,22 @@ export const GCSSettings: React.FunctionComponent<Props> = ({
isInvalid={Boolean(hasErrors && settingErrors.bucket)}
error={settingErrors.bucket}
>
<EuiFieldText
defaultValue={bucket || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
bucket: e.target.value,
});
}}
data-test-subj="bucketInput"
disabled={isManagedRepository}
<DisableToolTip
isManaged={isManagedRepository}
tooltipMessage={MANAGED_REPOSITORY_TOOLTIP_MESSAGE}
component={
<EuiFieldText
defaultValue={bucket || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
bucket: e.target.value,
});
}}
data-test-subj="bucketInput"
disabled={isManagedRepository}
/>
}
/>
</EuiFormRow>
</EuiDescribedFormGroup>
Expand Down Expand Up @@ -172,16 +185,22 @@ export const GCSSettings: React.FunctionComponent<Props> = ({
isInvalid={Boolean(hasErrors && settingErrors.basePath)}
error={settingErrors.basePath}
>
<EuiFieldText
defaultValue={basePath || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
basePath: e.target.value,
});
}}
data-test-subj="basePathInput"
disabled={isManagedRepository}
<DisableToolTip
isManaged={isManagedRepository}
tooltipMessage={MANAGED_REPOSITORY_TOOLTIP_MESSAGE}
component={
<EuiFieldText
defaultValue={basePath || ''}
fullWidth
onChange={(e) => {
updateRepositorySettings({
basePath: e.target.value,
});
}}
data-test-subj="basePathInput"
disabled={isManagedRepository}
/>
}
/>
</EuiFormRow>
</EuiDescribedFormGroup>
Expand Down
Loading

0 comments on commit 837bfe9

Please sign in to comment.