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-6800 - Remove onViewSharingSettingsClicked integrations #5485

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
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 @@ -3,7 +3,6 @@
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;
import org.sagebionetworks.web.client.cache.SessionStorage;
import org.sagebionetworks.web.client.cookie.CookieProvider;

public class FeatureFlagConfig {
Expand All @@ -26,11 +25,11 @@ public FeatureFlagConfig(JSONObject config, CookieProvider cookieProvider) {
this.cookieProvider = cookieProvider;
}

public boolean isFeatureEnabled(String featureName) {
public boolean isFeatureEnabled(FeatureFlagKey feature) {
try {
return (
DisplayUtils.isInTestWebsite(cookieProvider) ||
config.get(featureName).isBoolean().booleanValue()
config.get(feature.getKey()).isBoolean().booleanValue()
);
} catch (Exception e) {
return DisplayUtils.isInTestWebsite(cookieProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ public enum FeatureFlagKey {
CUSTOM_STORAGE_LOCATION_SETTINGS("CUSTOM_STORAGE_LOCATION_SETTINGS"),
CHALLENGE_SUBMISSION_SETTINGS("CHALLENGE_SUBMISSION_SETTINGS"),
SRC_BASED_AR_MODAL_WIZARD("SRC_BASED_AR_MODAL_WIZARD"),
HOMEPAGE_V2("HOMEPAGE_V2");
HOMEPAGE_V2("HOMEPAGE_V2"),
REACT_ENTITY_ACL_EDITOR("REACT_ENTITY_ACL_EDITOR"),
// Last flag is used only for tests
TEST_FLAG_ONLY("TEST_FLAG_ONLY");

private final String key;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@
import org.sagebionetworks.web.client.widget.refresh.ReplyCountAlert;
import org.sagebionetworks.web.client.widget.sharing.AccessControlListModalWidget;
import org.sagebionetworks.web.client.widget.sharing.AclAddPeoplePanel;
import org.sagebionetworks.web.client.widget.sharing.EntityAccessControlListModalWidget;
import org.sagebionetworks.web.client.widget.sharing.EntityAccessControlListModalWidgetImpl;
import org.sagebionetworks.web.client.widget.sharing.SharingPermissionsGrid;
import org.sagebionetworks.web.client.widget.statistics.StatisticsPlotWidget;
import org.sagebionetworks.web.client.widget.table.TableEntityListGroupItem;
Expand Down Expand Up @@ -692,6 +694,8 @@ public interface PortalGinInjector extends Ginjector {

AccessControlListModalWidget getAccessControlListModalWidget();

EntityAccessControlListModalWidget getEntityAccessControlListModalWidget();

RenameEntityModalWidget getRenameEntityModalWidget();

EditFileMetadataModalWidget getEditFileMetadataModalWidget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ protected void configure() {
.to(AccessControlListEditorViewImpl.class);
bind(AccessControlListModalWidget.class)
.to(AccessControlListModalWidgetImpl.class);
bind(EntityAccessControlListModalWidget.class)
.to(EntityAccessControlListModalWidgetImpl.class);

bind(AccessControlListModalWidgetView.class)
.to(AccessControlListModalWidgetViewImpl.class);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.sagebionetworks.web.client.jsinterop;

import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;

@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
public class EntityAclEditorModalProps extends ReactComponentProps {

@JsFunction
public interface Callback {
void run();
}

public String entityId;
public boolean open;
public Callback onUpdateSuccess;
public Callback onClose;

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

props.entityId = entityId;
props.open = open;
props.onUpdateSuccess = onUpdateSuccess;
props.onClose = onClose;
return props;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ public interface OnQueryResultBundleCallback {
void run(String newQueryResultBundleJson);
}

@FunctionalInterface
@JsFunction
public interface OnViewSharingSettingsHandler {
void onViewSharingSettingsClicked(String benefactorEntityId);
}

String name;
String initQueryJson;
String sql;
Expand All @@ -37,9 +31,6 @@ public interface OnViewSharingSettingsHandler {
@JsNullable
OnQueryResultBundleCallback onQueryResultBundleChange;

@JsNullable
OnViewSharingSettingsHandler onViewSharingSettingsClicked;

@JsNullable
boolean shouldDeepLink;

Expand All @@ -63,7 +54,6 @@ public static QueryWrapperPlotNavProps create(
String initQueryJson,
OnQueryCallback onQueryChange,
OnQueryResultBundleCallback onQueryResultBundleChange,
OnViewSharingSettingsHandler onViewSharingSettingsClicked,
boolean hideSqlEditorControl
) {
QueryWrapperPlotNavProps props = new QueryWrapperPlotNavProps();
Expand All @@ -72,7 +62,6 @@ public static QueryWrapperPlotNavProps create(
props.hideSqlEditorControl = hideSqlEditorControl;
props.onQueryChange = onQueryChange;
props.onQueryResultBundleChange = onQueryResultBundleChange;
props.onViewSharingSettingsClicked = onViewSharingSettingsClicked;
props.tableConfiguration = SynapseTableProps.create();
props.shouldDeepLink = false;
props.name = "Items";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class SynapseComponents {
public static ReactComponentType<
EvaluationEditorPageProps
> EvaluationEditorPage;
public static ReactComponentType<DownloadCartPageProps> DownloadCartPage;
public static ReactComponentType<EmptyProps> DownloadCartPage;
public static ReactComponentType<
DownloadConfirmationProps
> DownloadConfirmation;
Expand Down Expand Up @@ -118,6 +118,9 @@ public static class SynapseComponents {
public static ReactComponentType<
CookieNotificationProps
> CookiesNotification;
public static ReactComponentType<
EntityAclEditorModalProps
> EntityAclEditorModal;

/**
* Pushes a global toast message. In SWC, you should use {@link DisplayUtils#notify}, rather than calling this method directly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,19 @@

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.inject.Inject;
import org.sagebionetworks.repo.model.Entity;
import org.sagebionetworks.web.client.PopupUtilsView;
import org.sagebionetworks.web.client.PortalGinInjector;
import org.sagebionetworks.web.client.view.DownloadCartPageView;
import org.sagebionetworks.web.client.widget.sharing.AccessControlListModalWidget;

public class DownloadCartPresenter
extends AbstractActivity
implements
DownloadCartPageView.Presenter,
Presenter<org.sagebionetworks.web.client.place.DownloadCartPlace> {
implements Presenter<org.sagebionetworks.web.client.place.DownloadCartPlace> {

private DownloadCartPageView view;
private AccessControlListModalWidget aclModal;
private PortalGinInjector ginInjector;
private PopupUtilsView popupUtils;
private final DownloadCartPageView view;

@Inject
public DownloadCartPresenter(
DownloadCartPageView view,
PortalGinInjector ginInjector,
PopupUtilsView popupUtils
) {
public DownloadCartPresenter(DownloadCartPageView view) {
this.view = view;
view.setPresenter(this);
this.ginInjector = ginInjector;
this.popupUtils = popupUtils;
}

@Override
Expand All @@ -45,34 +28,4 @@ public void setPlace(
) {
view.render();
}

private AccessControlListModalWidget getAccessControlListModalWidget() {
if (aclModal == null) {
aclModal = ginInjector.getAccessControlListModalWidget();
}
return aclModal;
}

@Override
public void onViewSharingSettingsClicked(String benefactorEntityId) {
ginInjector
.getSynapseJavascriptClient()
.getEntity(
benefactorEntityId,
new AsyncCallback<Entity>() {
@Override
public void onSuccess(Entity entity) {
boolean canChangePermission = false;
getAccessControlListModalWidget()
.configure(entity, canChangePermission);
getAccessControlListModalWidget().showSharing(() -> {});
}

@Override
public void onFailure(Throwable caught) {
popupUtils.showErrorMessage(caught.getMessage());
}
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public TeamPresenter(
view.setMemberListWidget(memberListWidget.asWidget());
view.setMap(map.asWidget());
view.setShowMapVisible(
featureFlagConfig.isFeatureEnabled(FeatureFlagKey.GOOGLE_MAP.getKey())
featureFlagConfig.isFeatureEnabled(FeatureFlagKey.GOOGLE_MAP)
);
inviteWidget.setRefreshCallback(refreshCallback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,4 @@ public interface DownloadCartPageView extends IsWidget {
* Renders the view
*/
public void render();

public void setPresenter(Presenter presenter);

public interface Presenter {
void onViewSharingSettingsClicked(String benefactorEntityId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import org.sagebionetworks.web.client.context.SynapseReactClientFullContextPropsProvider;
import org.sagebionetworks.web.client.jsinterop.DownloadCartPageProps;
import org.sagebionetworks.web.client.jsinterop.React;
import org.sagebionetworks.web.client.jsinterop.ReactNode;
import org.sagebionetworks.web.client.jsinterop.SRC;
Expand All @@ -18,11 +17,9 @@ public class DownloadCartPageViewImpl implements DownloadCartPageView {

private Header headerWidget;
private SynapseReactClientFullContextPropsProvider propsProvider;
private Presenter presenter;

@Inject
public DownloadCartPageViewImpl(
AuthenticationController authenticationController,
Header headerWidget,
SynapseReactClientFullContextPropsProvider propsProvider
) {
Expand All @@ -31,21 +28,13 @@ public DownloadCartPageViewImpl(
this.propsProvider = propsProvider;
}

@Override
public void setPresenter(Presenter presenter) {
this.presenter = presenter;
}

@Override
public void render() {
Window.scrollTo(0, 0); // scroll user to top of page
headerWidget.configure();
DownloadCartPageProps props = DownloadCartPageProps.create(entityId -> {
presenter.onViewSharingSettingsClicked(entityId);
});
ReactNode component = React.createElementWithSynapseContext(
SRC.SynapseComponents.DownloadCartPage,
props,
null,
propsProvider.getJsInteropContextProps()
);
container.render(component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public void showMemberMenuItems() {
// TODO: remove next line to take out of alpha mode
teamProjectsItem.setVisible(
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.VIEW_ASSOCIATED_PROJECTS.getKey()
FeatureFlagKey.VIEW_ASSOCIATED_PROJECTS
)
);

Expand All @@ -248,7 +248,7 @@ public void showAdminMenuItems() {
// TODO: remove next line to take out of alpha mode
teamProjectsItem.setVisible(
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.VIEW_ASSOCIATED_PROJECTS.getKey()
FeatureFlagKey.VIEW_ASSOCIATED_PROJECTS
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void invoke(Boolean isACTMember) {
public void onClick() {
if (
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.SRC_BASED_AR_MODAL_WIZARD.getKey()
FeatureFlagKey.SRC_BASED_AR_MODAL_WIZARD
)
) {
useSrcWizard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void configure(EntityBundle bundle, EntityActionMenu actionMenu) {
dockerCommitListWidget.configure(entity.getId(), false);
view.setProvenanceWidgetVisible(
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.PROVENANCE_DOCKER_IMAGES.getKey()
FeatureFlagKey.PROVENANCE_DOCKER_IMAGES
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ public void configure(String markdown) {
// clear view state
view.clear();
view.setAlphaCommandsVisible(
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.ADD_WIKI_WIDGETS.getKey()
)
featureFlagConfig.isFeatureEnabled(FeatureFlagKey.ADD_WIKI_WIDGETS)
);
isACTMemberAsyncHandler.isACTMember(isACTMember ->
view.setACTCommandsVisible(isACTMember)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ public void onRename(Entity toRename, Callback handler) {
// Only surfacing description for Table types (behind feature flag for now)
if (
toRename instanceof Table &&
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.DESCRIPTION_FIELD.getKey()
)
featureFlagConfig.isFeatureEnabled(FeatureFlagKey.DESCRIPTION_FIELD)
) {
prompts.add("Description");
initialValues.add(toRename.getDescription());
Expand Down
Loading
Loading