-
Notifications
You must be signed in to change notification settings - Fork 166
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
feat: add MenuConfiguration #20138
feat: add MenuConfiguration #20138
Conversation
0042e6b
to
42cc7ce
Compare
42cc7ce
to
4ff26d4
Compare
@Artur- do you have any feedback regarding this new public Menu API called |
Is there a reason I should call |
If you don't see reason, we might not need to do it this way. What do you think if I'm not so sure how useful |
From the writing of the ticket the target was to get |
And MenuOption name was picked because MenuItem was already reserved by components. Let's wait if @mshabarov had some idea with splitting in MenuOptions and MenuOption in ticket requirements. Maybe we can remove MenuOptions. Naming properly is still a bit challenging here. |
I was thinking that
Thus, I agree that we could simplify it to have just a collection of |
Possible alternatives are How about |
|
* | ||
* @return the {@link MenuOptions} instance | ||
*/ | ||
public static MenuOptions getMenuOptions() { |
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.
this probably should expose the same method, but with Locale
(to allows alphabetical order based on exact translation)
* | ||
* @return the {@link MenuOptions} instance | ||
*/ | ||
public static MenuOptions getMenuOptions() { |
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 don't see MenuRegistry
javadocs update, these are needed to highlight it's internal use.
* path to the icon. E.g. 'line-awesome/svg/lock-open-solid.svg'. | ||
* @param menuClass | ||
* the source class with {@link com.vaadin.flow.router.Menu} | ||
* annotation or null if not available |
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.
Worth to mention that for menu entries pointing to Hilla/TypeScript views, this will be null
/** | ||
* Data class for menu item information. | ||
* <p> | ||
* Only for read as data is immutable. | ||
*/ | ||
public record MenuData(String title, Double order, boolean exclude, String icon) implements Serializable { | ||
public record MenuData(String title, Double order, boolean exclude, String icon, Class<? extends Component> menuClass) implements Serializable { |
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.
This should be deprecated and marked for internal use. We can't delete it as it's already shipped with 24.4, but we either shouldn't encourage it to be used in public API.
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.
Good point. Someone might use it already with 24.4 so need to keep and deprecate old. But it's also part of the public RouteData API which is not internal API and it's in 24.4. Marking it internal now is not possible afaik.
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.
Hmm, okay, let's keep it as is then.
|
||
/** | ||
* Menu configuration helper class to retrieve available menu entries for | ||
* application main menu. |
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.
Add "since 24.5" note
* | ||
* @since 24.5 | ||
*/ | ||
public class MenuConfiguration { |
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.
nit: this can be final class
New public API for building application menu: adds `MenuConfiguration`, `MenuOptions` and `MenuOption` where `MenuConfiguration` is the main entry point to access menu data to build main menu. Fixes: #20063
Renamed MenuOption to MenuEntry.
Removed Serializable from MenuConfiguration.
bb3fa46
to
920c818
Compare
Quality Gate passedIssues Measures |
Drafted PR that updates imports in Hilla: vaadin/hilla#2794 |
* feat: add MenuConfiguration New public API for building application menu: adds `MenuConfiguration`, `MenuOptions` and `MenuOption` where `MenuConfiguration` is the main entry point to access menu data to build main menu. Fixes: #20063 * chore: renamed classes and removed MenuOptions Renamed MenuOption to MenuEntry. * chore: updated javadocs * chore: moved MenuRegistry to internal package Removed Serializable from MenuConfiguration. * chore: added javadoc and deprecated MenuData constructor * chore: use new constructor * chore: make MenuConfiguration final
* feat: add MenuConfiguration New public API for building application menu: adds `MenuConfiguration`, `MenuOptions` and `MenuOption` where `MenuConfiguration` is the main entry point to access menu data to build main menu. Fixes: #20063 * chore: renamed classes and removed MenuOptions Renamed MenuOption to MenuEntry. * chore: updated javadocs * chore: moved MenuRegistry to internal package Removed Serializable from MenuConfiguration. * chore: added javadoc and deprecated MenuData constructor * chore: use new constructor * chore: make MenuConfiguration final Co-authored-by: Tomi Virtanen <[email protected]>
New public API for building application menu: adds
MenuConfiguration
,MenuOptions
andMenuOption
whereMenuConfiguration
is the main entry point to access menu data to build main menu.Fixes: #20063