-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved loading of userPermissions, wait for second call to userPermiss…
…ions in Cypress test
- Loading branch information
1 parent
dd944ea
commit e79bc8f
Showing
9 changed files
with
99 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
import { FileRepository } from '../repositories/FileRepository' | ||
import { File, FilePublishingStatus } from '../models/File' | ||
|
||
// TODO: remove async when ready and then remove eslint-disable | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
export async function checkFileDownloadPermission( | ||
fileRepository: FileRepository, | ||
file: File | ||
): Promise<boolean> { | ||
if (file.version.publishingStatus === FilePublishingStatus.DEACCESSIONED) { | ||
return fileRepository.getUserPermissionsById(file.id).then((permissions) => { | ||
return permissions.canEditDataset | ||
}) | ||
return file.userPermissions?.canEditDataset || false | ||
} | ||
|
||
const isRestricted = file.access.restricted || file.access.latestVersionRestricted | ||
if (!isRestricted && !file.isActivelyEmbargoed) { | ||
return true | ||
} | ||
|
||
return fileRepository.getUserPermissionsById(file.id).then((permissions) => { | ||
return permissions.canDownloadFile | ||
}) | ||
return file.userPermissions?.canDownloadFile || false | ||
} |
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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import { FileRepository } from '../repositories/FileRepository' | ||
import { File } from '../models/File' | ||
|
||
// TODO: remove async when ready and then remove eslint-disable | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
export async function checkFileEditDatasetPermission( | ||
fileRepository: FileRepository, | ||
file: File | ||
): Promise<boolean> { | ||
return fileRepository.getUserPermissionsById(file.id).then((permissions) => { | ||
return permissions.canEditDataset | ||
}) | ||
return file.userPermissions?.canEditDataset || false | ||
} |
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
22 changes: 11 additions & 11 deletions
22
src/sections/file/file-permissions/useFileDownloadPermission.tsx
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