-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix] Offline sync and permission (#8222)
* feat: add hasAllPermissions and hasAnyPermissions utility function * fix: toggleApiStop method adding source and refactor * fix: added optional chaining operator to access `status.lastLog.id` * [Fix] Activity Watch integration issue (#8223) * feat: add timeout to upload Images method time tracker service * fix: speed up timer start/stop
- Loading branch information
Showing
4 changed files
with
127 additions
and
60 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
21 changes: 21 additions & 0 deletions
21
packages/desktop-ui-lib/src/lib/shared/utils/permission.util.ts
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,21 @@ | ||
/** | ||
* Checks if the user has all the required permissions. | ||
* | ||
* @param permissions The list of permissions the user has. | ||
* @param requires The permissions required to perform the action. | ||
* @returns A boolean indicating whether the user has all the required permissions. | ||
*/ | ||
export function hasAllPermissions<T>(permissions: T[], ...requires: T[]) { | ||
return requires.every((permission) => permissions.includes(permission)); | ||
} | ||
|
||
/** | ||
* Checks if the user has any of the required permissions. | ||
* | ||
* @param permissions The list of permissions the user has. | ||
* @param requires The permissions required to perform the action. | ||
* @returns A boolean indicating whether the user has any of the required permissions. | ||
*/ | ||
export function hasAnyPermission<T>(permissions: T[], ...requires: T[]) { | ||
return requires.some((permission) => permissions.includes(permission)); | ||
} |
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