Skip to content

Commit

Permalink
Merge pull request #5493 from jay-hodgson/SWC-7039-develop
Browse files Browse the repository at this point in the history
Merge from release-509 (SWC-7039, complex merge)
  • Loading branch information
jay-hodgson committed Aug 15, 2024
2 parents 75bb54a + a3e05a8 commit a9bcd50
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;
import com.google.inject.Inject;
import org.sagebionetworks.web.client.cookie.CookieProvider;

public class FeatureFlagConfig {

private final CookieProvider cookieProvider;
private final JSONObject config;
private JSONObject config;

public FeatureFlagConfig(String json, CookieProvider cookieProvider) {
JSONValue parsed = JSONParser.parseStrict(json);
config = parsed.isObject();
@Inject
public FeatureFlagConfig(CookieProvider cookieProvider) {
this.cookieProvider = cookieProvider;
config = new JSONObject();
}

public void setJson(String json) {
if (json != null) {
JSONValue parsed = JSONParser.parseStrict(json);
config = parsed.isObject();
}
}

/**
Expand Down

This file was deleted.

192 changes: 101 additions & 91 deletions src/main/java/org/sagebionetworks/web/client/Portal.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.sagebionetworks.web.client.utils.Callback;
import org.sagebionetworks.web.client.widget.footer.Footer;
import org.sagebionetworks.web.client.widget.header.Header;
import org.sagebionetworks.web.shared.WebConstants;

/**
* Entry point classes define <code>onModuleLoad()</code>.
Expand Down Expand Up @@ -82,18 +81,17 @@ public void onSuccess() {
// make sure jsni utils code is available to the client
ginjector.getSynapseJSNIUtils();

// initialize feature flag config
ginjector
.getSynapseJavascriptClient()
.getFeatureFlagConfig(
new AsyncCallback<JSONObjectAdapter>() {
@Override
public void onSuccess(JSONObjectAdapter config) {
ginjector
.getSessionStorage()
.setItem(
WebConstants.PORTAL_FEATURE_FLAG_SESSION_STORAGE_KEY,
config.toString()
);
.getFeatureFlagConfig()
.setJson(config.toString());
continueInit();
}

@Override
Expand All @@ -102,100 +100,112 @@ public void onFailure(Throwable reason) {
"Error getting feature flag configuration:" +
reason.getMessage()
);
continueInit();
}
}
);

ginjector
.getSynapseProperties()
.initSynapseProperties(() -> {
EventBus eventBus = ginjector.getEventBus();
PlaceController placeController = new PlaceController(
eventBus
);

// Start ActivityManager for the main widget with our ActivityMapper
AppActivityMapper activityMapper = new AppActivityMapper(
ginjector,
new SynapseJSNIUtilsImpl(),
null
);
ActivityManager activityManager = new ActivityManager(
activityMapper,
eventBus
);
activityManager.setDisplay(appWidget);
private void continueInit() {
ginjector
.getSynapseProperties()
.initSynapseProperties(() -> {
EventBus eventBus = ginjector.getEventBus();
PlaceController placeController = new PlaceController(
eventBus
);

// All pages get added to the root panel
appWidget.addStyleName("rootPanel");
// Start ActivityManager for the main widget with our ActivityMapper
AppActivityMapper activityMapper =
new AppActivityMapper(
ginjector,
new SynapseJSNIUtilsImpl(),
null
);
ActivityManager activityManager = new ActivityManager(
activityMapper,
eventBus
);
activityManager.setDisplay(appWidget);

// Start PlaceHistoryHandler with our PlaceHistoryMapper
AppPlaceHistoryMapper historyMapper = GWT.create(
AppPlaceHistoryMapper.class
);
final PlaceHistoryHandler historyHandler =
new PlaceHistoryHandler(
historyMapper,
new Html5Historian()
);
historyHandler.register(
placeController,
eventBus,
AppActivityMapper.getDefaultPlace()
);
Header header = ginjector.getHeader();
RootPanel.get("headerPanel").add(header);
Footer footer = ginjector.getFooter();
RootPanel.get("footerPanel").add(footer);
// All pages get added to the root panel
appWidget.addStyleName("rootPanel");

RootPanel.get("rootPanel").add(appWidget);
RootPanel.get("initialLoadingUI").setVisible(false);
fullOpacity(
RootPanel.get("headerPanel"),
RootPanel.get("rootPanel")
);
final GlobalApplicationState globalApplicationState =
ginjector.getGlobalApplicationState();
globalApplicationState.setPlaceController(placeController);
globalApplicationState.setAppPlaceHistoryMapper(
historyMapper
);
ginjector
.getAuthenticationController()
.checkForUserChange(() -> {
globalApplicationState.init(
new Callback() {
@Override
public void invoke() {
// listen for window close (or navigating away)
registerWindowClosingHandler(
globalApplicationState
// Start PlaceHistoryHandler with our PlaceHistoryMapper
AppPlaceHistoryMapper historyMapper = GWT.create(
AppPlaceHistoryMapper.class
);
final PlaceHistoryHandler historyHandler =
new PlaceHistoryHandler(
historyMapper,
new Html5Historian()
);
registerOnPopStateHandler(globalApplicationState);
historyHandler.register(
placeController,
eventBus,
AppActivityMapper.getDefaultPlace()
);
Header header = ginjector.getHeader();
RootPanel.get("headerPanel").add(header);
Footer footer = ginjector.getFooter();
RootPanel.get("footerPanel").add(footer);

// start version timer
ginjector.getVersionTimer().start();
// start timer to check for Synapse outage or scheduled maintenance
ginjector.getSynapseStatusDetector().start();
// Goes to place represented on URL or default place
historyHandler.handleCurrentHistory();
globalApplicationState.initializeDropZone();
globalApplicationState.initializeToastContainer();
// initialize the view default columns so that they're ready when we need them (do this by constructing that singleton object)
ginjector.getViewDefaultColumns();
RootPanel.get("rootPanel").add(appWidget);
RootPanel.get("initialLoadingUI").setVisible(false);
fullOpacity(
RootPanel.get("headerPanel"),
RootPanel.get("rootPanel")
);
final GlobalApplicationState globalApplicationState =
ginjector.getGlobalApplicationState();
globalApplicationState.setPlaceController(
placeController
);
globalApplicationState.setAppPlaceHistoryMapper(
historyMapper
);
ginjector
.getAuthenticationController()
.checkForUserChange(() -> {
globalApplicationState.init(
new Callback() {
@Override
public void invoke() {
// listen for window close (or navigating away)
registerWindowClosingHandler(
globalApplicationState
);
registerOnPopStateHandler(
globalApplicationState
);

// start timer to check for user session state change (session expired, or user explicitly logged
// out). Backend endpoints must be set before starting this (because it attempts to get "my user profile")
ginjector.getSessionDetector().start();
// start version timer
ginjector.getVersionTimer().start();
// start timer to check for Synapse outage or scheduled maintenance
ginjector
.getSynapseStatusDetector()
.start();
// Goes to place represented on URL or default place
historyHandler.handleCurrentHistory();
globalApplicationState.initializeDropZone();
globalApplicationState.initializeToastContainer();
// initialize the view default columns so that they're ready when we need them (do this by constructing that singleton object)
ginjector.getViewDefaultColumns();

// start a timer to check to see if we're approaching the max allowable space in the web storage.
// clears out the web storage (cache) if this is the case.
ginjector.getWebStorageMaxSizeDetector().start();
}
}
);
});
});
// start timer to check for user session state change (session expired, or user explicitly logged
// out). Backend endpoints must be set before starting this (because it attempts to get "my user profile")
ginjector.getSessionDetector().start();

// start a timer to check to see if we're approaching the max allowable space in the web storage.
// clears out the web storage (cache) if this is the case.
ginjector
.getWebStorageMaxSizeDetector()
.start();
}
}
);
});
});
}
}
);
} catch (Throwable e) {
onFailure(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,4 +872,6 @@ public interface PortalGinInjector extends Ginjector {
ColumnModelsEditorWidget getColumnModelsEditorWidget();

EntityTypeIcon getEntityTypeIcon();

FeatureFlagConfig getFeatureFlagConfig();
}
Original file line number Diff line number Diff line change
Expand Up @@ -975,9 +975,8 @@ protected void configure() {

bind(KeyFactoryProvider.class).to(KeyFactoryProviderImpl.class);
bind(SRCUploadFileWrapper.class).to(SRCUploadFileWrapperImpl.class);
bind(FeatureFlagConfigProvider.class).in(Singleton.class);

bind(FeatureFlagConfig.class).toProvider(FeatureFlagConfigProvider.class);
bind(FeatureFlagConfig.class).in(Singleton.class);
bind(EntityTypeIcon.class).to(EntityTypeIconImpl.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,6 @@ public class WebConstants {
"User requests that the Synapse Access and Compliance Team send them information on how to access this data.";
public static final String ISSUE_PRIORITY_MINOR = "4";
public static final String ANONYMOUS = "Anonymous";
public static final String PORTAL_FEATURE_FLAG_SESSION_STORAGE_KEY =
"portal_feature_flag";

// report Synapse error
public static final String SWC_ISSUE_COLLECTOR_URL =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.sagebionetworks.repo.model.table.TableEntity;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.FeatureFlagConfig;
import org.sagebionetworks.web.client.FeatureFlagConfigProvider;
import org.sagebionetworks.web.client.GlobalApplicationState;
import org.sagebionetworks.web.client.PlaceChanger;
import org.sagebionetworks.web.client.PortalGinInjector;
Expand Down

0 comments on commit a9bcd50

Please sign in to comment.