AWS App Studio is in preview and is subject to change.
Configuring role-based visibility of pages
You can create roles within an App Studio app and configure the visbility of pages based on those roles. For example, you can create roles based on user needs or access levels, such as administrator, manager, or user for apps that provide features such as project approvals or claims processing and make certain pages visible to specific roles. In this example, administrators may have full access, managers might have access to view reporting dashboards, and users may have access to tasks pages with input forms.
Use the following procedure to configure role-based visbility of pages in your App Studio app.
If necessary, navigate to the application studio of your application. From the left-side navigation menu, choose My applications, find your application and choose Edit.
Create app level roles in the application studio.
Choose the App settings tab at the top of the application studio.
Choose + Add Role
In Role name, provide a name to identify your role. We recommend using a name that is descriptive of the group's access level or duties, as you'll use the name to set up the page visibility.
Optionally, in Description, add a description for the role.
Repeat these steps to create as many roles as needed.
Configure the visiblity of your pages
Choose the Pages tab at the top of the application studio.
From the left-side Pages menu, choose the page for which you want to configure role-based visibility.
In the right-side menu, choose the Properties tab.
In Visibility, disable Open to all end users.
Keep Role selected to choose from a list of the roles you created in the previous step. Choose Custom to write a JavaScript expression for more complex visibility configurations.
With Role selected, check the boxes of the app roles for which the page will be visible.
With Custom selected, enter a JavaScript expression that resolves to true or false. Use the following example to check if the current user has the role of manager:
{{currentUser.roles.includes('manager')}}
.
Now that your visibility is configured, you can test the page visiblity by previewing your app.
Choose Preview to open a preview of your app.
In the top right of the preview, choose the Previewing as menu and check the boxes of the roles you want to test. The visible pages should reflect the roles selected.
Now, assign groups to app roles for a published app. Group and role assignments must be configured separately for each environment. For more information about app environments, see Application environments.
Note
Your app must be published to either the Testing or Production environments to assign App Studio groups to the roles you've created and configured. If necessary, publish your app to assign groups to the roles. For more information about publishing, see Publishing applications.
In the top right of the application studio, choose Share.
Choose the tab for the environment of which you want to configure page visibility.
Choose the Search groups input box and choose the group with which to share the app version. You can enter text to search for groups.
In the dropdown menu, choose the roles to assign to the group. You can choose No role to share the app version and not assign a role to the group. Only pages that are visible to all users will be visible to groups with no role.
Choose Share. Repeat these steps to add as many group as needed.