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
[1988] Add support for optional help text on widgets #2011
Conversation
351349f
to
12128fb
Compare
281a777
to
cb34647
Compare
The helpExpression doesn't work for slider, I think the |
The helpExpression is not display for |
...nts-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java
Outdated
Show resolved
Hide resolved
.../org/eclipse/sirius/components/collaborative/forms/handlers/HelpTextRequestEventHandler.java
Outdated
Show resolved
Hide resolved
...ackend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/Select.java
Outdated
Show resolved
Hide resolved
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.
I have not tested it but what is that git all
file exactly?
...se/sirius/components/forms/graphql/datafetchers/form/FormDescriptionHelpTextDataFetcher.java
Outdated
Show resolved
Hide resolved
@@ -96,6 +96,8 @@ public static final class Builder { | |||
|
|||
private List<Diagnostic> diagnostics; | |||
|
|||
private Supplier<String> helpTextProvider; |
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.
I suspect this is what you were talking about with the modification of dozens of files with widgets, components, descriptions to set that up. In the diagram representation, we went the other way by removing the description as the sole mean to carry information for a service and instead try to use its content only for the rendering.
You could have introduced something like that to ask for the help text and use it in the handler:
public interface IWidgetHelpTextProvider {
String getHelpText(...)
}
When the frontend would ask for the help text, you would just ask this service which could then leverage the view model to find the relevant information. Here, the converters needs to setup everything first. Which is why you have to make the help text provider optional because it needs to carry two pieces of informations at once:
- is there some help text? (for the rendering)
- what is the value of the help text?
You could have simply used a boolean to carry the information relevant for the rendering.
We could also introduce a common AbstractWidgetBuilder
which would be inherited by all the Builders of the widgets. It could encapsulate things like the id, presence of help text, diagnostics, label. I don't see any issues with having some simple inheritance for builders like that since builders are 99% data structure.
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.
You could have simply used a boolean to carry the information relevant for the rendering.
Yes, but I would still have needed about the same amount of changes to carry the boolean (instead of the Supplier<String>
), wouldn't I?
I don't see any issues with having some simple inheritance for builders like that since builders are 99% data structure.
AFAICT, it's forbidden by the rules you setup: immutableClassesShouldHaveANestedBuilder
, and HaveAValidBuilderCondition
requires the builder class to be final
.
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.
When the frontend would ask for the help text, you would just ask this service which could then leverage the view model
What about widgets created programatically which do not come from a View model?
There was a little more missing, but done. |
42bf953
to
e21eda7
Compare
I've added help support for toolbarActions. The tooltip is associated to the button itself instead of a separate "?" icon (there is not really any room for such an icon in this case). |
e21eda7
to
d33c1db
Compare
d33c1db
to
78b2bb5
Compare
78b2bb5
to
b26d9a3
Compare
b26d9a3
to
8ae7820
Compare
Bug: #1988 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
8ae7820
to
2ec6907
Compare
editingContextId: string; | ||
formId: string; | ||
widgetId: string; | ||
children?: any; |
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.
React.ReactElement would work here
const [open, setOpen] = useState(false); | ||
const [content, setContent] = useState<JSX.Element>(null); |
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.
You could consolidate both state into one.
{lines.map((line) => ( | ||
<> | ||
{line} | ||
<br /> | ||
</> | ||
))} |
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.
Use React.Fragment
to have access to the key
props to remove the warning
<Tooltip | ||
open={open && content !== null} | ||
onClose={handleClose} | ||
onOpen={handleOpen} | ||
title={content || ''} | ||
arrow | ||
placement={'top'}> | ||
{props.children || <HelpOutlineOutlined color="secondary" style={{ marginLeft: 8, fontSize: 16 }} />} | ||
</Tooltip> | ||
); |
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.
I'm still not sure why but moving the cursor a tiny bit can trigger a lot of HTTP request to reload the tooltip. I wonder if there is some options in MUI which would prevent so many open/close events
Pull request template
General purpose
What is the main goal of this pull request?
Project management
priority:
andpr:
labels been added to the pull request? (In case of doubt, start with the labelspriority: low
andpr: to review later
)area:
,difficulty:
,type:
)CHANGELOG.adoc
been updated to reference the relevant issues?CHANGELOG.adoc
? (Including changes in the GraphQL API)CHANGELOG.adoc
? For example indoc/screenshots/2022.5.0-my-new-feature.png
Architectural decision records (ADR)
[doc]
?CHANGELOG.adoc
?Dependencies
CHANGELOG.adoc
?CHANGELOG.adoc
?Frontend
This section is not relevant if your contribution does not come with changes to the frontend.
General purpose
Typing
We need to improve the typing of our code, as such, we require every contribution to come with proper TypeScript typing for both changes contributing new files and those modifying existing files.
Please ensure that the following statements are true for each file created or modified (this may require you to improve code outside of your contribution).
useMutation<DATA_TYPE, VARIABLE_TYPE>(…)
useQuery<DATA_TYPE, VARIABLE_TYPE>(…)
useSubscription<DATA_TYPE, VARIABLE_TYPE>(…)
useMachine<CONTEXT_TYPE, EVENTS_TYPE>(…)
useState<STATE_TYPE>(…)
?.
(if the GraphQL API specifies that a field cannot benull
, do not treat it has potentiallynull
for example)let diagram: Diagram | null = null;
)Backend
This section is not relevant if your contribution does not come with changes to the backend.
General purpose
Architecture
Review
How to test this PR?
Please describe here the various use cases to test this pull request