Skip to content
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

Added section to describe how parts of the UI can be hidden based on user role #940

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

schiwekM
Copy link
Contributor

Hi @renejeglinsky,

a few newcomers mentioned the lack of documentation on how parts of the UI can be hidden based on roles. This section should explain it.

@DanSchlachter Maybe it is also something to include in a tutorial or course / SFlight?

Hope the wording is understandable.

BR,
Marten

@DanSchlachter
Copy link
Contributor

maybe it should be mentioned, that there is a trade-off between having multiple apps for multiple roles or a single app for multiple roles.
You don't want to duplicate the entire app for a small difference in UI -> use small amount of additional logic over creating multiple apps with duplicate code
You don't want to have a lot of logic in one app, when it's easier to define two apps -> use two apps over overcomplicating one app

@schiwekM
Copy link
Contributor Author

I agree but would argue that this should be part of Providing services or Modelling best practices. In general it is quite common that there is one app but create / edit / delete is restricted to an admin user, I'd say.

@renejeglinsky renejeglinsky self-assigned this May 24, 2024
Comment on lines +515 to +518
annotate service.Books with @(
UI.CreateHidden : { $edmJson: {$Not: { $Path: '/CatalogService.EntityContainer/Configuration/isAdmin'} } },
UI.UpdateHidden : { $edmJson: {$Not: { $Path: '/CatalogService.EntityContainer/Configuration/isAdmin'} } },
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @schiwekM ,
what is the result here? When I'm logged in as admin, I can't see the Books through this service?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

essentially if you are not the admin than you do not see the EDIT or Create buttons

Comment on lines +523 to +528
```cds
annotate service.Books with @(
UI.CreateHidden : { $edmJson: {$Not: { $Path: '/Configuration/isAdmin'} } },
UI.UpdateHidden : { $edmJson: {$Not: { $Path: '/Configuration/isAdmin'} } },
);
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is doing the same as the previous snippet when using Fiori Elements, right? In which cases am I not allowed to do omit the entity container?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - EntityContainer is syntactically from an OData PoV correct however in most cases Fiori elements allows you to leave it out. For compatibility I added the entity container notation if something does not work that users can try the syntactically correct one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants