-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge pull request #691 from pinarruiz/feature/extend-visibility-items
[FEATURE] Extend visibility to section items
- Loading branch information
Showing
8 changed files
with
233 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* A helper function that checks if an item is visible based on current users permissions | ||
* Checks an item displayData for hideForUsers, showForUsers and hideForGuests | ||
* Returns a boolean that determines if the user has the required permissions | ||
*/ | ||
|
||
// Import helper functions from auth, to get current user, and check if guest | ||
import { getCurrentUser, isLoggedInAsGuest } from '@/utils/Auth'; | ||
import { isVisibleToUser } from '@/utils/IsVisibleToUser'; | ||
|
||
/* Putting it all together, the function to export */ | ||
export const checkItemVisibility = (item) => { | ||
const currentUser = getCurrentUser(); // Get current user object | ||
const isGuest = isLoggedInAsGuest(); // Check if current user is a guest | ||
const displayData = item.displayData || {}; | ||
return isVisibleToUser(displayData, currentUser, isGuest); | ||
}; | ||
|
||
export default checkItemVisibility; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.