-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR] Add tooltips for disabled fields on managed SLM repository and policy #196565
Merged
ElenaStoeva
merged 7 commits into
elastic:main
from
renshuki:tooltips-managed-repository-slm
Oct 25, 2024
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b0a4084
Add tooltips for disabled fields on managed SLM repository and policy
renshuki c7a1fc0
Create a DisableTooltip component for repositories and add i18n.trans…
renshuki 0f88555
Refactor DisableToolTip component
renshuki 612540f
Move tooltip messages to constants
renshuki 5dd3b62
Adjust documentation message for DisableToolTip
renshuki 1dc3d07
Keep constants with DisableToolTip component
renshuki ba592b9
Merge branch 'main' into tooltips-managed-repository-slm
ElenaStoeva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 33 additions & 0 deletions
33
x-pack/plugins/snapshot_restore/public/application/components/repository_disable_tooltip.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,33 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { EuiToolTip } from '@elastic/eui'; | ||
|
||
interface Props { | ||
isManagedRepository?: boolean; | ||
component: ReactElement; | ||
} | ||
|
||
export const DisableToolTip: React.FunctionComponent<Props> = ({ | ||
isManagedRepository, | ||
component, | ||
}) => { | ||
return isManagedRepository ? ( | ||
<EuiToolTip | ||
content={i18n.translate('xpack.snapshotRestore.repositoryForm.disableToolTipContent', { | ||
defaultMessage: 'This field is disabled because you are editing a managed repository.', | ||
})} | ||
display="block" | ||
> | ||
{component} | ||
</EuiToolTip> | ||
) : ( | ||
component | ||
); | ||
}; |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we reuse the new
DisableToolTip
component here instead of this function?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because the tooltip message is different for the managed repository and the managed policy. But if we want to handle both cases (managed repository and managed policy) within the same component, I guess we can refactor the
DisableTooltip
component to something like:x-pack/plugins/snapshot_restore/public/application/components/disable_tooltip.tsx
Let me know what you think 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see... I would suggest that you pass the message as a prop to the component and rename the
isManagedRepository
prop to justisManaged
. Something like this:Also, could you please add documentation above this component to explain what we use it for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and add a
const tooltipMessage
to define the tooltip message for each of the files, correct? (i.e.azure_settings.tsx
,gcs_settings.tsx
,s3_settings.tsx
andstep_logistics.tsx
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it would be nice to add two constants (one for the repo message and one for the policy message) in
x-pack/plugins/snapshot_restore/public/application/constants/index.ts
. You could name them something more descriptive likemanaged<Policy/Repository>FieldTooltipMessage
for example.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ElenaStoeva I pushed the latest changes (component refactor + constants definition) to the branch with the documentation for the component.