-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 #1420 from mmihaly/page-visibility-configuration
Page visibility configuration
- Loading branch information
Showing
5 changed files
with
152 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* A helper function that checks if a page is visible based on current users permissions | ||
* Checks a page's 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 } from '@/utils/Auth'; | ||
import { isVisibleToUser } from '@/utils/IsVisibleToUser'; | ||
|
||
/* Putting it all together, the function to export */ | ||
export const checkPageVisibility = (page) => { | ||
const currentUser = getCurrentUser(); // Get current user object | ||
const displayData = page.displayData || {}; | ||
return isVisibleToUser(displayData, currentUser); | ||
}; | ||
|
||
export default checkPageVisibility; |
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
dd71683
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
dashy – ./
dashy-git-master-alicia.vercel.app
dashy-alicia.vercel.app
dashy-delta.vercel.app