I am customizing UI and I would like to show/hide menus and features to users based on their type.
I can see that currently it is done when user is admin (admin menu, for example).
Is it possible to create other kind of users (apart from admin) and make features appear/hide only to that kind of users?? Any clue??
Currently creating a new type of user, other then admin/user, is not supported. But if you are hosting the UI yourself and you’d like to add additional restrictions for ‘user’ type members this is certainly possible. It seems you’ve read the code for some of the restrictions we place on non-admin users. I would recommend following the same pattern for your new restrictions. Hope this helps!
Anything you do showing or hiding stuff in the UI is going to be strictly superficial… the API is still going to allow things that aren’t shown unless you add more user types and validation and all that to the backend Cattle code.
But… is it possible to add new restrictions without hacking Cattle code (as @vincent suggests)?
Can you point me to the specific part of the code where these restrictions are applied??
Thanks
@dalareo we only have two account types for normal users, Admin and User. So if you’d like to add restrictions based on those types you can see where we set the isAdmin
flag here. You can use that flag to show hide things on pages with the basic handlebars helpers. If you’d like to show/hide nav bar items @vincent recently implemented a new page header that allows for adding and removing items by importing addItem and removeItem methods in the new navigation-tree
utility (import { addItem, removeId } from 'ui/utils/navigation-tree';
).
If you’re still looking to implement a new user class system solely on the front end then no, without the implementation of an arbitrary group/permissions system, we do not currently support this.
There are also 4 Environment membership roles (owner
, member
, restricted
, readonly
), which restrict what an account can do on a per-environment basis. For example restricted
can manipulate stacks/services but not hosts. The UI doesn’t show/hide buttons based on these yet though.
As I said you can make all the superficial changes you want in the UI, but the only way to actually restrict a user from doing things is to change Cattle and add new account types or environment membership roles. This is not a trivial endeavor.
I don’t know where everything is because it’s not something I work on, but here’s a start:
https://github.com/rancher/cattle/tree/master/resources/content/schema
Great @wes and @vincent for you indications. I am really “blocked” with this and our project next iteration needs to deal with Rancher UI customization.
Is there any option of having your support and collaboration for our project? You can checkout our very alpha-state website at http://educaas.github.io/.
It’s beeing very hard for us to find emberJS developers with the focus and background we are looking for, and my jack-all-trades (polymath in my best days…) lacks some JS skills by now.
Hi @wes, I’ve created a custom component to show stacks as “cards”, in a similar way as catalog elements are shown. You can check it out here: https://github.com/EduCaaS/UI/tree/production/app/components/stack-card
I am trying to make the names of the stacks only clickable for admin users so I placed this conditional in my handlebar template:
{{#if isAdmin}}
{{#link-to "stack" model.id}}{{model.name}}{{/link-to}}
{{else}}
{{model.name}}
{{/if}}
But the link is now hidden to everyuser, so I guess isAdmin conditional is not working. Any help??
PS: I solved it!! In the component.js file I also exported:
access: Ember.inject.service(),
isAdmin: Ember.computed.alias('access.admin')