@@ -808,8 +808,10 @@ function topInformation (dir, showAlert, rebuildFileBrowser = false) {
808808
809809 // Archival vault
810810 if ( typeof archive !== 'undefined' ) {
811- if ( ( isDatamanager && archive . archivable ) && archive . status === false ) {
812- actions [ 'vault-archival' ] = 'Archive on tape'
811+ if ( ( isDatamanager && archive . archivable ) && ! archive . status ) {
812+ actions [ 'vault-archival' ] = [ 'Archive on tape' , false ]
813+ } else if ( ( isDatamanager && ! archive . archivable ) && ! archive . status ) {
814+ actions [ 'vault-archival' ] = [ 'Archive on tape' , true ]
813815 }
814816
815817 $ ( '.alert.is-archived' ) . hide ( )
@@ -942,37 +944,52 @@ function topInformation (dir, showAlert, rebuildFileBrowser = false) {
942944}
943945
944946function handleActionsList ( actions , folder ) {
945- let html = ''
946- let vaultHtml = ''
947- const possibleActions = [ 'submit-for-publication' , 'cancel-publication' ,
947+ const possibleActions = [
948+ 'submit-for-publication' , 'cancel-publication' ,
948949 'approve-for-publication' , 'depublish-publication' ,
949- 'republish-publication' , 'vault-download' , 'vault-archival' ,
950- 'vault-unarchive' ]
951-
952- const possibleVaultActions = [ 'change-vault-access' ,
953- 'copy-vault-package-to-research' ,
954- 'check-for-unpreservable-files' ,
955- 'show-checksum-report' ]
950+ 'republish-publication' , 'vault-download' ,
951+ 'vault-archival' , 'vault-unarchive'
952+ ]
953+
954+ const possibleVaultActions = [
955+ 'change-vault-access' , 'copy-vault-package-to-research' ,
956+ 'check-for-unpreservable-files' , 'show-checksum-report'
957+ ]
958+
959+ function buildLinks ( keys ) {
960+ let html = ''
961+ keys . forEach ( function ( key ) {
962+ if ( ! Object . prototype . hasOwnProperty . call ( actions , key ) ) return
963+
964+ const item = actions [ key ]
965+ let text ; let isDisabled = false
966+
967+ if ( Array . isArray ( item ) ) {
968+ text = item [ 0 ]
969+ isDisabled = Boolean ( item [ 1 ] )
970+ } else {
971+ text = item
972+ }
956973
957- $ . each ( possibleActions , function ( index , value ) {
958- if ( Object . prototype . hasOwnProperty . call ( actions , value ) ) {
959- html += '<a class="dropdown-item action-' + value + '" data-folder="' + Yoda . htmlEncode ( folder ) + '">' + actions [ value ] + '</a>'
960- }
961- } )
974+ html += '<a class="dropdown-item action-' + key +
975+ ( isDisabled ? ' disabled"' : '"' ) +
976+ ' data-folder="' + Yoda . htmlEncode ( folder ) + '">' +
977+ Yoda . htmlEncode ( text ) + '</a>'
978+ } )
979+ return html
980+ }
962981
963- $ . each ( possibleVaultActions , function ( index , value ) {
964- if ( Object . prototype . hasOwnProperty . call ( actions , value ) ) {
965- vaultHtml += '<a class="dropdown-item action-' + value + '" data-folder="' + Yoda . htmlEncode ( folder ) + '">' + actions [ value ] + '</a>'
966- }
967- } )
982+ const htmlMain = buildLinks ( possibleActions )
983+ const htmlVault = buildLinks ( possibleVaultActions )
968984
969- if ( html !== '' && vaultHtml !== '' ) {
970- html += '<div class="dropdown-divider"></div>' + vaultHtml
971- } else if ( vaultHtml !== '' ) {
972- html += vaultHtml
985+ let finalHtml = htmlMain
986+ if ( htmlMain && htmlVault ) {
987+ finalHtml += '<div class="dropdown-divider"></div>' + htmlVault
988+ } else if ( htmlVault ) {
989+ finalHtml = htmlVault
973990 }
974991
975- $ ( '.action-list' ) . html ( html )
992+ $ ( '.action-list' ) . html ( finalHtml )
976993}
977994
978995function showMetadataForm ( path ) {
0 commit comments