Skip to content

Commit

Permalink
Hide 'upload media' menu option if project folder configuration is in…
Browse files Browse the repository at this point in the history
…complete
  • Loading branch information
solth committed Sep 20, 2021
1 parent 4c113e6 commit 72067e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ private boolean setUpFolders() {
Folder mediaView = dataEditor.getProcess().getProject().getMediaView();
Folder preview = dataEditor.getProcess().getProject().getPreview();

if (Objects.isNull(sourceFolder) || Objects.isNull(mediaView) || Objects.isNull(preview)) {
return false;
}

sourceFolder.setPath(variableReplacer.replace(sourceFolder.getRelativePath()));
mediaView.setPath(variableReplacer.replace(mediaView.getRelativePath()));
preview.setPath(variableReplacer.replace(preview.getRelativePath()));
Expand Down Expand Up @@ -440,5 +444,17 @@ public void refresh() throws NoSuchMetadataFieldException {
}
}

/**
* Check and return whether folder configuration of current process' project is
* complete, e.g. allows upload and conversion of media files. This means folders for thumbnails,
* detail views and generator source have to be configured in the project configuration.
*
* @return whether project folder configuration is complete or not
*/
public boolean isFolderConfigurationComplete() {
return Objects.nonNull(dataEditor.getProcess().getProject().getGeneratorSource())
&& Objects.nonNull(dataEditor.getProcess().getProject().getMediaView())
&& Objects.nonNull(dataEditor.getProcess().getProject().getPreview());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.uploadMedia}"
action="#{DataEditorForm.uploadFileDialog.prepare}"
rendered="#{SecurityAccessController.hasAuthorityToUploadMedia()}"
rendered="#{SecurityAccessController.hasAuthorityToUploadMedia() and DataEditorForm.uploadFileDialog.isFolderConfigurationComplete()}"
icon="fa fa-download fa-sm"
styleClass="plain"
update = "uploadFileDialog"
Expand Down Expand Up @@ -418,7 +418,7 @@
update="dialogEditDocStrucTypeDialog"/>
<p:menuitem value="#{msgs.uploadMedia}"
action="#{DataEditorForm.uploadFileDialog.prepare}"
rendered="#{SecurityAccessController.hasAuthorityToUploadMedia()}"
rendered="#{SecurityAccessController.hasAuthorityToUploadMedia() and DataEditorForm.uploadFileDialog.isFolderConfigurationComplete()}"
icon="fa fa-download fa-sm"
styleClass="plain"
update = "uploadFileDialog"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.uploadMedia}"
action="#{DataEditorForm.uploadFileDialog.prepare}"
rendered="#{SecurityAccessController.hasAuthorityToUploadMedia()}"
rendered="#{SecurityAccessController.hasAuthorityToUploadMedia() and DataEditorForm.uploadFileDialog.isFolderConfigurationComplete()}"
icon="fa fa-download fa-sm"
styleClass="plain"
update = "uploadFileDialog"
Expand Down

0 comments on commit 72067e2

Please sign in to comment.