Skip to content

Commit

Permalink
YDA-5747: grant/revoke permissions button confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
claravox authored Jul 30, 2024
1 parent a47fc2a commit 7e1bf45
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 10 deletions.
30 changes: 20 additions & 10 deletions vault/static/vault/js/vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let preservableFormatsLists = null
let currentFolder
let dataPackage = null
let hasReadRights = true
let researchGroupAccess = true

$(function () {
// Extract current location from query string (default to '').
Expand Down Expand Up @@ -228,14 +229,27 @@ $(function () {
e.preventDefault()
})

$('body').on('click', 'a.action-grant-vault-access', function () {
vaultAccess('grant', $(this).attr('data-folder'))
$('body').on('click', 'a.action-change-vault-access', function () {
// Show more detailed information on changing read permissions
if (researchGroupAccess) {
$('.action-confirm-revoke-read-permissions').attr('data-folder', $(this).attr('data-folder'))
$('#confirmRevokeReadPermissions').modal('show')
} else {
$('.action-confirm-grant-read-permissions').attr('data-folder', $(this).attr('data-folder'))
$('#confirmGrantReadPermissions').modal('show')
}
})

$('body').on('click', 'a.action-revoke-vault-access', function () {
$('#confirmRevokeReadPermissions').on('click', '.action-confirm-revoke-read-permissions', function () {
$('#confirmRevokeReadPermissions').modal('hide')
vaultAccess('revoke', $(this).attr('data-folder'))
})

$('#confirmGrantReadPermissions').on('click', '.action-confirm-grant-read-permissions', function () {
$('#confirmGrantReadPermissions').modal('hide')
vaultAccess('grant', $(this).attr('data-folder'))
})

$('body').on('click', 'a.action-depublish-publication', function () {
// Set the current folder.
$('.action-confirm-depublish-publication').attr('data-folder', $(this).attr('data-folder'))
Expand Down Expand Up @@ -656,10 +670,10 @@ function topInformation (dir, showAlert, rebuildFileBrowser = false) {
const userType = data.member_type
const hasDatamanager = data.has_datamanager
const isDatamanager = data.is_datamanager
const researchGroupAccess = data.research_group_access
const actions = []
const downloadable = data.downloadable
const archive = data.archive
researchGroupAccess = data.research_group_access

$('.btn-group button.metadata-form').hide()
$('.top-information').hide()
Expand Down Expand Up @@ -771,11 +785,7 @@ function topInformation (dir, showAlert, rebuildFileBrowser = false) {
// Datamanager sees access buttons in vault.
$('.top-info-buttons').show()
if (isDatamanager) {
if (researchGroupAccess) {
actions['revoke-vault-access'] = 'Revoke read access to research group'
} else {
actions['grant-vault-access'] = 'Grant read access to research group'
}
actions['change-vault-access'] = 'Change who has read access'
}
}

Expand Down Expand Up @@ -828,7 +838,7 @@ function handleActionsList (actions, folder) {
'republish-publication', 'vault-download', 'vault-archival',
'vault-unarchive']

const possibleVaultActions = ['grant-vault-access', 'revoke-vault-access',
const possibleVaultActions = ['change-vault-access',
'copy-vault-package-to-research',
'check-for-unpreservable-files',
'show-checksum-report']
Expand Down
56 changes: 56 additions & 0 deletions vault/templates/vault/browse.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,62 @@ <h5 class="card-title float-start">
</div>
</div>

<div class="modal confirm-read-permissions" tabindex="-1" id="confirmRevokeReadPermissions">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Revoke Read Permissions</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>
Are you sure you would like to revoke read permissions of members
of this research group to this vault package?
</p>
<p>
This will revoke read permissions to this package for all members
of this research group.
</p>
<p>
This is a reversible process.
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary action-confirm-revoke-read-permissions">Confirm</button>
</div>
</div>
</div>
</div>

<div class="modal confirm-read-permissions" tabindex="-1" id="confirmGrantReadPermissions">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Grant Read Permissions</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>
Are you sure you would like to grant read permissions to members
of this research group to this vault package?
</p>
<p>
This will grant read permissions to this package for all members
of this research group.
</p>
<p>
This is a reversible process.
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary action-confirm-grant-read-permissions">Confirm</button>
</div>
</div>
</div>
</div>

<div class="modal" tabindex="-1" id="submitPublication">
<div class="modal-dialog modal-lg">
<div class="modal-content">
Expand Down

0 comments on commit 7e1bf45

Please sign in to comment.