Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge changes from release-516 into develop #5543

Merged
merged 8 commits into from
Oct 4, 2024
4 changes: 4 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
MAVEN_USERNAME: ${{ secrets.PLATFORM_ARTIFACTORY_USER }}
MAVEN_USERPWD: ${{ secrets.PLATFORM_ARTIFACTORY_PWD }}

- name: setup-job-summary
run: |
echo "| version | ${{ env.pomversion }} |" > $GITHUB_STEP_SUMMARY

call-test:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public enum FeatureFlagKey {
// If enabled, use the re-implemented ACL Editor for entities
REACT_ENTITY_ACL_EDITOR("REACT_ENTITY_ACL_EDITOR"),

// If enabled, sharing settings will appear in a dialog immediately after uploading one or more files.
SHOW_SHARING_SETTINGS_AFTER_UPLOAD("SHOW_SHARING_SETTINGS_AFTER_UPLOAD"),

// Last flag is used only for tests
TEST_FLAG_ONLY("TEST_FLAG_ONLY");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3295,4 +3295,32 @@ public FluentFuture<Void> deleteSessionAccessToken() {
String url = getAuthServiceUrl() + SESSION_ACCESS_TOKEN;
return getFuture(cb -> doDelete(url, cb));
}

public void getEntityBenefactorAcl(
String entityId,
AsyncCallback<AccessControlList> cb
) {
// Retrieving the benefactor ACL is always permitted regardless of permissions, so only retrieve that part of the bundle.
EntityBundleRequest request = new EntityBundleRequest();
request.setIncludeBenefactorACL(true);
String url = getRepoServiceUrl() + ENTITY + "/" + entityId + BUNDLE2;

doPost(
url,
request,
OBJECT_TYPE.EntityBundle,
true,
new AsyncCallback<EntityBundle>() {
@Override
public void onSuccess(EntityBundle result) {
cb.onSuccess(result.getBenefactorAcl());
}

@Override
public void onFailure(Throwable caught) {
cb.onFailure(caught);
}
}
);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package org.sagebionetworks.web.client.events;

public interface UploadSuccessHandler {
void onSuccessfulUpload();
/**
* Called when one or more files have been successfully uploaded.
* @param benefactorId the benefactor ID of all uploaded files. May be null if request to get benefactor fails
*/
void onSuccessfulUpload(String benefactorId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ public interface Callback {
public boolean open;
public Callback onUpdateSuccess;
public Callback onClose;
public boolean isAfterUpload;

@JsOverlay
public static EntityAclEditorModalProps create(
String entityId,
boolean open,
Callback onUpdateSuccess,
Callback onClose
Callback onClose,
boolean isAfterUpload
) {
EntityAclEditorModalProps props = new EntityAclEditorModalProps();

props.entityId = entityId;
props.open = open;
props.onUpdateSuccess = onUpdateSuccess;
props.onClose = onClose;
props.isAfterUpload = isAfterUpload;
return props;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
package org.sagebionetworks.web.client.widget.entity.download;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import org.sagebionetworks.repo.model.Entity;
import org.sagebionetworks.web.client.FeatureFlagConfig;
import org.sagebionetworks.web.client.FeatureFlagKey;
import org.sagebionetworks.web.client.events.EntityUpdatedEvent;
import org.sagebionetworks.web.client.utils.CallbackP;
import org.sagebionetworks.web.client.widget.SynapseWidgetPresenter;
import org.sagebionetworks.web.client.widget.sharing.EntityAccessControlListModalWidget;

public class UploadDialogWidget
implements UploadDialogWidgetView.Presenter, SynapseWidgetPresenter {

private UploadDialogWidgetView view;
private Uploader uploader;
private final EventBus eventBus;
private final EntityAccessControlListModalWidget entityAclEditor;
private final FeatureFlagConfig featureFlagConfig;

@Inject
public UploadDialogWidget(UploadDialogWidgetView view, Uploader uploader) {
public UploadDialogWidget(
UploadDialogWidgetView view,
Uploader uploader,
EventBus eventBus,
EntityAccessControlListModalWidget entityAccessControlListModalWidget,
FeatureFlagConfig featureFlagConfig
) {
this.view = view;
this.uploader = uploader;
this.eventBus = eventBus;
this.entityAclEditor = entityAccessControlListModalWidget;
this.featureFlagConfig = featureFlagConfig;
view.setPresenter(this);
}

Expand All @@ -40,8 +57,21 @@ public void configure(
view.configureDialog(title, body);

// add handlers for closing the window
uploader.setSuccessHandler(() -> {
uploader.setSuccessHandler(benefactorId -> {
view.hideDialog();
if (
benefactorId != null &&
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.SHOW_SHARING_SETTINGS_AFTER_UPLOAD
)
) {
entityAclEditor.configure(
benefactorId,
() -> eventBus.fireEvent(new EntityUpdatedEvent(benefactorId)),
true
);
entityAclEditor.setOpen(true);
}
});

uploader.setCancelHandler(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import java.util.List;
import org.sagebionetworks.repo.model.AccessControlList;
import org.sagebionetworks.repo.model.Entity;
import org.sagebionetworks.repo.model.Folder;
import org.sagebionetworks.repo.model.attachment.UploadResult;
Expand Down Expand Up @@ -790,10 +791,30 @@ public void onSuccess(Entity result) {
entity = result;
view.showInfo(DisplayConstants.TEXT_LINK_SUCCESS);
if (successHandler != null) {
successHandler.onSuccessfulUpload();
}
jsClient.getEntityBenefactorAcl(
result.getId(),
new AsyncCallback<AccessControlList>() {
@Override
public void onSuccess(AccessControlList benefactorAcl) {
if (benefactorAcl.getId().equals(entity.getId())) {
// Don't show the ACL modal if the entity is its own benefactor
successHandler.onSuccessfulUpload(null);
} else {
successHandler.onSuccessfulUpload(benefactorAcl.getId());
}
entityUpdated();
}

entityUpdated();
@Override
public void onFailure(Throwable caught) {
view.showErrorMessage(caught.getMessage());
// Upload was still a success, benefactor ID is not required to continue
successHandler.onSuccessfulUpload(null);
entityUpdated();
}
}
);
}
}

@Override
Expand Down Expand Up @@ -1009,9 +1030,30 @@ private void uploadSuccess() {
view.resetToInitialState();
resetUploadProgress();
if (successHandler != null) {
successHandler.onSuccessfulUpload();
jsClient.getEntityBenefactorAcl(
entityId,
new AsyncCallback<AccessControlList>() {
@Override
public void onSuccess(AccessControlList benefactorAcl) {
if (benefactorAcl.getId().equals(entityId)) {
// Don't show the ACL modal if the entity is its own benefactor
successHandler.onSuccessfulUpload(null);
} else {
successHandler.onSuccessfulUpload(benefactorAcl.getId());
}
entityUpdated();
}

@Override
public void onFailure(Throwable caught) {
view.showErrorMessage(caught.getMessage());
// Upload was still a success, benefactor ID is not required to continue.
successHandler.onSuccessfulUpload(null);
entityUpdated();
}
}
);
}
entityUpdated();
}

private void resetUploadProgress() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ void configure(
EntityAclEditorModalProps.Callback onUpdateSuccess
);

void configure(
String entityId,
EntityAclEditorModalProps.Callback onUpdateSuccess,
boolean isAfterUpload
);

void setOpen(boolean open);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,23 @@ public class EntityAccessControlListModalWidgetImpl
public void configure(
String entityId,
EntityAclEditorModalProps.Callback onUpdateSuccess
) {
configure(entityId, onUpdateSuccess, false);
}

@Override
public void configure(
String entityId,
EntityAclEditorModalProps.Callback onUpdateSuccess,
boolean isAfterUpload
) {
componentProps =
EntityAclEditorModalProps.create(
entityId,
false,
onUpdateSuccess,
() -> setOpen(false)
() -> setOpen(false),
isAfterUpload
);
renderComponent();
}
Expand Down
Loading