Skip to content

Commit

Permalink
fix(userSelectors): ent-3825 add report read permissions (#654)
Browse files Browse the repository at this point in the history
* userSelectors, add check for report read
* platformApiTypes, report const
  • Loading branch information
cdcabrera committed May 18, 2021
1 parent 3a9188a commit 3e5c5c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/redux/selectors/userSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ const selector = createDeepEqualSelector([statePropsFilter], response => {
);

// Alias specific app permissions checks
updatedSession.authorized[helpers.UI_NAME] = updatedSession.permissions[APP_TYPES.SUBSCRIPTIONS]?.all || false;
updatedSession.authorized[helpers.UI_NAME] =
updatedSession.permissions[APP_TYPES.SUBSCRIPTIONS]?.all ||
Array.isArray(
updatedSession.permissions[APP_TYPES.SUBSCRIPTIONS]?.resources?.[RESOURCE_TYPES.REPORTS]?.[OPERATION_TYPES.READ]
) ||
false;

updatedSession.authorized.inventory =
updatedSession.permissions[APP_TYPES.INVENTORY]?.all ||
Expand Down
4 changes: 4 additions & 0 deletions src/types/__tests__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Object {
"PLATFORM_API_RESPONSE_USER_PERMISSION_RESOURCE_TYPES": Object {
"ALL": "*",
"HOSTS": "hosts",
"REPORTS": "reports",
},
"PLATFORM_API_RESPONSE_USER_PERMISSION_TYPES": Object {
"PERMISSION": "permission",
Expand Down Expand Up @@ -265,6 +266,7 @@ Object {
"PLATFORM_API_RESPONSE_USER_PERMISSION_RESOURCE_TYPES": Object {
"ALL": "*",
"HOSTS": "hosts",
"REPORTS": "reports",
},
"PLATFORM_API_RESPONSE_USER_PERMISSION_TYPES": Object {
"PERMISSION": "permission",
Expand Down Expand Up @@ -502,6 +504,7 @@ Object {
"PLATFORM_API_RESPONSE_USER_PERMISSION_RESOURCE_TYPES": Object {
"ALL": "*",
"HOSTS": "hosts",
"REPORTS": "reports",
},
"PLATFORM_API_RESPONSE_USER_PERMISSION_TYPES": Object {
"PERMISSION": "permission",
Expand Down Expand Up @@ -743,6 +746,7 @@ Object {
"PLATFORM_API_RESPONSE_USER_PERMISSION_RESOURCE_TYPES": Object {
"ALL": "*",
"HOSTS": "hosts",
"REPORTS": "reports",
},
"PLATFORM_API_RESPONSE_USER_PERMISSION_TYPES": Object {
"PERMISSION": "permission",
Expand Down
5 changes: 3 additions & 2 deletions src/types/platformApiTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const PLATFORM_API_RESPONSE_USER_IDENTITY_USER_TYPES = {
* Platform response of USER PERMISSION type values.
* Schema/map of expected response identity user permission types.
*
* @type {{PERMISSION: string}}
* @type {{PERMISSION: string, RESOURCE_DEFS: string}}
*/
const PLATFORM_API_RESPONSE_USER_PERMISSION_TYPES = {
PERMISSION: 'permission',
Expand All @@ -60,7 +60,8 @@ const PLATFORM_API_RESPONSE_USER_PERMISSION_APP_TYPES = {

const PLATFORM_API_RESPONSE_USER_PERMISSION_RESOURCE_TYPES = {
ALL: '*',
HOSTS: 'hosts'
HOSTS: 'hosts',
REPORTS: 'reports'
};

const PLATFORM_API_RESPONSE_USER_PERMISSION_OPERATION_TYPES = {
Expand Down

0 comments on commit 3e5c5c0

Please sign in to comment.