-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove duplicated code detected by sonar
- Loading branch information
1 parent
0368c5f
commit 8488ab5
Showing
4 changed files
with
34 additions
and
15 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
17 changes: 17 additions & 0 deletions
17
src/packages/modules-datasets/utils/check-stamp-with-contributor.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,17 @@ | ||
import { DATASET_CONTRIBUTOR } from '../../auth/roles'; | ||
import { Dataset } from '../../model/Dataset'; | ||
import { Permission } from '../../redux/selectors'; | ||
|
||
export const checkIfContributorContainsUserStamp = ( | ||
dataset: Dataset, | ||
permission: Permission, | ||
) => { | ||
const contributors = Array.isArray(dataset?.catalogRecord?.contributor) | ||
? dataset?.catalogRecord?.contributor | ||
: [dataset?.catalogRecord?.contributor]; | ||
|
||
return ( | ||
contributors.find((c) => c === permission?.stamp) && | ||
permission?.roles?.includes(DATASET_CONTRIBUTOR) | ||
); | ||
}; |
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