Skip to content

Commit

Permalink
Merge pull request #5470 from nickgros/SWC-6943
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgros authored Jul 26, 2024
2 parents 5db3316 + c806d07 commit 3c845c5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
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 {

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

public FeatureFlagConfig(String json, CookieProvider cookieProvider) {
JSONValue parsed = JSONParser.parseStrict(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@

import com.google.inject.Inject;
import com.google.inject.Provider;
import org.sagebionetworks.web.client.cache.SessionStorage;
import org.sagebionetworks.web.client.cookie.CookieProvider;
import org.sagebionetworks.web.shared.WebConstants;

public class FeatureFlagConfigProvider implements Provider<FeatureFlagConfig> {

CookieProvider cookieProvider;
private final CookieProvider cookieProvider;
private final SessionStorage sessionStorage;

@Inject
public FeatureFlagConfigProvider(CookieProvider cookieProvider) {
public FeatureFlagConfigProvider(
CookieProvider cookieProvider,
SessionStorage sessionStorage
) {
this.cookieProvider = cookieProvider;
this.sessionStorage = sessionStorage;
}

@Override
public FeatureFlagConfig get() {
return new FeatureFlagConfig(
cookieProvider.getCookie(WebConstants.PORTAL_FEATURE_FLAG),
sessionStorage.getItem(
WebConstants.PORTAL_FEATURE_FLAG_SESSION_STORAGE_KEY
),
cookieProvider
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/sagebionetworks/web/client/Portal.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public void onSuccess() {
@Override
public void onSuccess(JSONObjectAdapter config) {
ginjector
.getCookieProvider()
.setCookie(
WebConstants.PORTAL_FEATURE_FLAG,
.getSessionStorage()
.setItem(
WebConstants.PORTAL_FEATURE_FLAG_SESSION_STORAGE_KEY,
config.toString()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.gwt.inject.client.GinModules;
import com.google.gwt.inject.client.Ginjector;
import org.sagebionetworks.schema.adapter.JSONObjectAdapter;
import org.sagebionetworks.web.client.cache.SessionStorage;
import org.sagebionetworks.web.client.context.QueryClientProvider;
import org.sagebionetworks.web.client.cookie.CookieProvider;
import org.sagebionetworks.web.client.presenter.ACTAccessApprovalsPresenter;
Expand Down Expand Up @@ -585,6 +586,8 @@ public interface PortalGinInjector extends Ginjector {

CookieProvider getCookieProvider();

SessionStorage getSessionStorage();

Header getHeader();

Footer getFooter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ 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 = "portal_feature_flag";
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

0 comments on commit 3c845c5

Please sign in to comment.