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

SWC-6776 - Put feature in experimental mode under feature flag #5542

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"),
Comment on lines +40 to +41
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not planning on adding this to the stack builder for now, since we don't need to dynamically toggle it. This is basically in experimental mode only, but it's easy to find + remove all of the toggles for this feature when we need to.


// 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 @@ -4,6 +4,8 @@
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;
Expand All @@ -16,18 +18,21 @@ public class UploadDialogWidget
private Uploader uploader;
private final EventBus eventBus;
private final EntityAccessControlListModalWidget entityAclEditor;
private final FeatureFlagConfig featureFlagConfig;

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

Expand All @@ -54,7 +59,12 @@ public void configure(
// add handlers for closing the window
uploader.setSuccessHandler(benefactorId -> {
view.hideDialog();
if (benefactorId != null) {
if (
benefactorId != null &&
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.SHOW_SHARING_SETTINGS_AFTER_UPLOAD
)
) {
entityAclEditor.configure(
benefactorId,
() -> eventBus.fireEvent(new EntityUpdatedEvent(benefactorId)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.sagebionetworks.web.unitclient.widget.entity.download;

import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.google.gwt.event.shared.EventBus;
import org.junit.Before;
Expand All @@ -14,6 +17,8 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.sagebionetworks.repo.model.Entity;
import org.sagebionetworks.web.client.FeatureFlagConfig;
import org.sagebionetworks.web.client.FeatureFlagKey;
import org.sagebionetworks.web.client.events.CancelHandler;
import org.sagebionetworks.web.client.events.UploadSuccessHandler;
import org.sagebionetworks.web.client.jsinterop.EntityAclEditorModalProps;
Expand All @@ -38,6 +43,9 @@ public class UploadDialogTest {
@Mock
EntityAccessControlListModalWidget mockEntityAccessControlListModalWidget;

@Mock
FeatureFlagConfig mockFeatureFlagConfig;

@Captor
ArgumentCaptor<UploadSuccessHandler> uploadSuccessCaptor;

Expand All @@ -55,12 +63,58 @@ public void before() throws Exception {
view,
mockUploader,
mockEventBus,
mockEntityAccessControlListModalWidget
mockEntityAccessControlListModalWidget,
mockFeatureFlagConfig
);
}

@Test
public void testConfigure() {
when(
mockFeatureFlagConfig.isFeatureEnabled(
FeatureFlagKey.SHOW_SHARING_SETTINGS_AFTER_UPLOAD
)
)
.thenReturn(false);

String title = "dialog title";
Entity entity = mock(Entity.class);
String parentEntityId = "parent";
CallbackP<String> fileHandleIdCallback = mock(CallbackP.class);
boolean isEntity = true;
widget.configure(
title,
entity,
parentEntityId,
fileHandleIdCallback,
isEntity
);

verify(mockUploader)
.configure(entity, parentEntityId, fileHandleIdCallback, isEntity);
verify(view).configureDialog(eq(title), any());

verify(mockUploader).setSuccessHandler(uploadSuccessCaptor.capture());
verify(mockUploader).setCancelHandler(any(CancelHandler.class));

// simulate a successful upload
String benefactorId = "syn123";
uploadSuccessCaptor.getValue().onSuccessfulUpload(benefactorId);
verify(view).hideDialog();
verify(mockEntityAccessControlListModalWidget, never())
.configure(eq(benefactorId), any(), anyBoolean());
verify(mockEntityAccessControlListModalWidget, never()).setOpen(true);
}

@Test
public void testSharingSettingsFeatureEnabled() {
when(
mockFeatureFlagConfig.isFeatureEnabled(
FeatureFlagKey.SHOW_SHARING_SETTINGS_AFTER_UPLOAD
)
)
.thenReturn(true);

String title = "dialog title";
Entity entity = mock(Entity.class);
String parentEntityId = "parent";
Expand Down