Skip to content

Commit

Permalink
Merge pull request #5401 from jinjunoh/SWC-6845
Browse files Browse the repository at this point in the history
SWC-6845: migrate all experimental mode features in swc to use feature flags
  • Loading branch information
jinjunoh authored May 30, 2024
2 parents 8e6f159 + 9cc372d commit 0f40248
Show file tree
Hide file tree
Showing 20 changed files with 334 additions and 129 deletions.
11 changes: 10 additions & 1 deletion src/main/java/org/sagebionetworks/web/client/FeatureFlagKey.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package org.sagebionetworks.web.client;

public enum FeatureFlagKey {
PROVENANCE_V2_VISUALIZATION("Provenance v2 visualization");
PROVENANCE_V2_VISUALIZATION("PROVENANCE_V2_VISUALIZATION"),
GOOGLE_MAP("GOOGLE_MAP"),
VIEW_ASSOCIATED_PROJECTS("VIEW_ASSOCIATED_PROJECTS"),
PROVENANCE_DOCKER_IMAGES("PROVENANCE_DOCKER_IMAGES"),
DESCRIPTION_FIELD("DESCRIPTION_FIELD"),
ADD_WIKI_WIDGETS("ADD_WIKI_WIDGETS"),
WIKI_DIFF_TOOL("WIKI_DIFF_TOOL"),
CUSTOM_STORAGE_LOCATION_SETTINGS("CUSTOM_STORAGE_LOCATION_SETTINGS"),
CHALLENGE_SUBMISSION_SETTINGS("CHALLENGE_SUBMISSION_SETTINGS"),
SRC_BASED_AR_MODAL_WIZARD("SRC_BASED_AR_MODAL_WIZARD");

private final String key;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import org.sagebionetworks.repo.model.Team;
import org.sagebionetworks.repo.model.TeamMemberTypeFilterOptions;
import org.sagebionetworks.repo.model.TeamMembershipStatus;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.FeatureFlagConfig;
import org.sagebionetworks.web.client.FeatureFlagKey;
import org.sagebionetworks.web.client.GlobalApplicationState;
import org.sagebionetworks.web.client.PortalGinInjector;
import org.sagebionetworks.web.client.SynapseClientAsync;
Expand Down Expand Up @@ -60,6 +61,7 @@ public class TeamPresenter
private IsACTMemberAsyncHandler isACTMemberAsyncHandler;
private TeamProjectsModalWidget teamProjectsModalWidget;
private PortalGinInjector ginInjector;
private FeatureFlagConfig featureFlagConfig;
Callback refreshCallback = () -> {
refresh();
};
Expand All @@ -80,7 +82,8 @@ public TeamPresenter(
GoogleMap map,
CookieProvider cookies,
IsACTMemberAsyncHandler isACTMemberAsyncHandler,
PortalGinInjector ginInjector
PortalGinInjector ginInjector,
FeatureFlagConfig featureFlagConfig
) {
this.view = view;
this.ginInjector = ginInjector;
Expand All @@ -97,6 +100,7 @@ public TeamPresenter(
this.openUserInvitationsWidget = openUserInvitationsWidget;
this.map = map;
this.isACTMemberAsyncHandler = isACTMemberAsyncHandler;
this.featureFlagConfig = featureFlagConfig;
view.setPresenter(this);
view.setSynAlertWidget(synAlert.asWidget());
view.setInviteMemberWidget(inviteWidget.asWidget());
Expand All @@ -106,7 +110,9 @@ public TeamPresenter(
view.setManagerListWidget(managerListWidget.asWidget());
view.setMemberListWidget(memberListWidget.asWidget());
view.setMap(map.asWidget());
view.setShowMapVisible(DisplayUtils.isInTestWebsite(cookies));
view.setShowMapVisible(
featureFlagConfig.isFeatureEnabled(FeatureFlagKey.GOOGLE_MAP.getKey())
);
inviteWidget.setRefreshCallback(refreshCallback);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.sagebionetworks.repo.model.Team;
import org.sagebionetworks.repo.model.TeamMembershipStatus;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.FeatureFlagConfig;
import org.sagebionetworks.web.client.FeatureFlagKey;
import org.sagebionetworks.web.client.GWTWrapper;
import org.sagebionetworks.web.client.cookie.CookieProvider;
import org.sagebionetworks.web.client.widget.FullWidthAlert;
Expand Down Expand Up @@ -114,6 +116,7 @@ public interface TeamViewImplUiBinder
private GWTWrapper gwt;
private BigTeamBadge bigTeamBadge;
private CookieProvider cookieProvider;
private FeatureFlagConfig featureFlagConfig;

@Inject
public TeamViewImpl(
Expand All @@ -122,13 +125,15 @@ public TeamViewImpl(
Header headerWidget,
GWTWrapper gwt,
BigTeamBadge bigTeamBadge,
CookieProvider cookieProvider
CookieProvider cookieProvider,
FeatureFlagConfig featureFlagConfig
) {
initWidget(binder.createAndBindUi(this));
this.headerWidget = headerWidget;
this.gwt = gwt;
this.bigTeamBadge = bigTeamBadge;
this.cookieProvider = cookieProvider;
this.featureFlagConfig = featureFlagConfig;
setDropdownHandlers();
headerWidget.configure();
teamBadgeContainer.clear();
Expand Down Expand Up @@ -226,7 +231,11 @@ public void setPresenter(Presenter presenter) {
public void showMemberMenuItems() {
leaveTeamItem.setVisible(true);
// TODO: remove next line to take out of alpha mode
teamProjectsItem.setVisible(DisplayUtils.isInTestWebsite(cookieProvider));
teamProjectsItem.setVisible(
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.VIEW_ASSOCIATED_PROJECTS.getKey()
)
);

toolsMenu.setVisible(true);
}
Expand All @@ -237,7 +246,11 @@ public void showAdminMenuItems() {
editTeamItem.setVisible(true);
inviteMemberItem.setVisible(true);
// TODO: remove next line to take out of alpha mode
teamProjectsItem.setVisible(DisplayUtils.isInTestWebsite(cookieProvider));
teamProjectsItem.setVisible(
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.VIEW_ASSOCIATED_PROJECTS.getKey()
)
);

toolsMenu.setVisible(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.sagebionetworks.repo.model.AccessRequirement;
import org.sagebionetworks.repo.model.RestrictableObjectDescriptor;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.FeatureFlagConfig;
import org.sagebionetworks.web.client.FeatureFlagKey;
import org.sagebionetworks.web.client.PortalGinInjector;
import org.sagebionetworks.web.client.cookie.CookieProvider;
import org.sagebionetworks.web.client.jsinterop.CreateOrUpdateAccessRequirementWizardProps;
Expand Down Expand Up @@ -36,18 +38,21 @@ public class CreateAccessRequirementButton
RestrictableObjectDescriptor subject;
AccessRequirement ar;
Callback refreshCallback;
FeatureFlagConfig featureFlagConfig;

@Inject
public CreateAccessRequirementButton(
SingleButtonView view,
IsACTMemberAsyncHandler isACTMemberAsyncHandler,
CookieProvider cookies,
FeatureFlagConfig featureFlagConfig,
final PortalGinInjector ginInjector
) {
this.view = view;
this.isACTMemberAsyncHandler = isACTMemberAsyncHandler;
this.ginInjector = ginInjector;
this.cookies = cookies;
this.featureFlagConfig = featureFlagConfig;
view.setButtonVisible(false);
view.addStyleNames("margin-left-10");
view.setPresenter(this);
Expand Down Expand Up @@ -91,7 +96,11 @@ public void invoke(Boolean isACTMember) {

@Override
public void onClick() {
if (DisplayUtils.isInTestWebsite(cookies)) {
if (
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.SRC_BASED_AR_MODAL_WIZARD.getKey()
)
) {
useSrcWizard();
} else {
useSwcWizard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.sagebionetworks.repo.model.docker.DockerRepository;
import org.sagebionetworks.repo.model.entitybundle.v2.EntityBundle;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.FeatureFlagConfig;
import org.sagebionetworks.web.client.FeatureFlagKey;
import org.sagebionetworks.web.client.cookie.CookieProvider;
import org.sagebionetworks.web.client.events.EntityUpdatedEvent;
import org.sagebionetworks.web.client.utils.CallbackP;
Expand Down Expand Up @@ -35,6 +37,7 @@ public class DockerRepoWidget {
private boolean canEdit;
private DockerRepository entity;
private EventBus eventBus;
private FeatureFlagConfig featureFlagConfig;

@Inject
public DockerRepoWidget(
Expand All @@ -46,7 +49,8 @@ public DockerRepoWidget(
ModifiedCreatedByWidget modifiedCreatedBy,
DockerCommitListWidget dockerCommitListWidget,
CookieProvider cookies,
EventBus eventBus
EventBus eventBus,
FeatureFlagConfig featureFlagConfig
) {
this.view = view;
this.wikiPageWidget = wikiPageWidget;
Expand All @@ -57,6 +61,7 @@ public DockerRepoWidget(
this.dockerCommitListWidget = dockerCommitListWidget;
this.cookies = cookies;
this.eventBus = eventBus;
this.featureFlagConfig = featureFlagConfig;
view.setWikiPage(wikiPageWidget.asWidget());
view.setProvenance(provWidget.asWidget());
view.setTitlebar(dockerTitleBar.asWidget());
Expand All @@ -79,7 +84,11 @@ public void configure(EntityBundle bundle, EntityActionMenu actionMenu) {
configureProvenance(entity.getId());
view.setDockerPullCommand(DOCKER_PULL_COMMAND + entity.getRepositoryName());
dockerCommitListWidget.configure(entity.getId(), false);
view.setProvenanceWidgetVisible(DisplayUtils.isInTestWebsite(cookies));
view.setProvenanceWidgetVisible(
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.PROVENANCE_DOCKER_IMAGES.getKey()
)
);
}

private void configureProvenance(final String entityId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.GWTWrapper;
import org.sagebionetworks.web.client.PortalGinInjector;
import org.sagebionetworks.web.client.SynapseClientAsync;
import org.sagebionetworks.web.client.*;
import org.sagebionetworks.web.client.cookie.CookieProvider;
import org.sagebionetworks.web.client.events.WidgetDescriptorUpdatedEvent;
import org.sagebionetworks.web.client.events.WidgetDescriptorUpdatedHandler;
Expand Down Expand Up @@ -96,6 +93,8 @@ public class MarkdownEditorWidget
MarkdownEditorAction currentAction;
private PortalGinInjector ginInjector;

private FeatureFlagConfig featureFlagConfig;

@Inject
public MarkdownEditorWidget(
MarkdownEditorWidgetView view,
Expand All @@ -105,7 +104,8 @@ public MarkdownEditorWidget(
BaseEditWidgetDescriptorPresenter widgetDescriptorEditor,
WidgetRegistrar widgetRegistrar,
UserTeamSelector userTeamSelector,
PortalGinInjector ginInjector
PortalGinInjector ginInjector,
FeatureFlagConfig featureFlagConfig
) {
super();
this.view = view;
Expand All @@ -118,6 +118,7 @@ public MarkdownEditorWidget(
this.ginInjector = ginInjector;

this.userTeamSelector = userTeamSelector;
this.featureFlagConfig = featureFlagConfig;

widgetSelectionState = new WidgetSelectionState();
view.setPresenter(this);
Expand Down Expand Up @@ -149,7 +150,11 @@ public MarkdownWidget getMarkdownPreview() {
public void configure(String markdown) {
// clear view state
view.clear();
view.setAlphaCommandsVisible(DisplayUtils.isInTestWebsite(cookies));
view.setAlphaCommandsVisible(
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.ADD_WIKI_WIDGETS.getKey()
)
);
view.configure(markdown);
view.showEditMode();
if (formattingGuideWikiPageKey == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import org.sagebionetworks.repo.model.Entity;
import org.sagebionetworks.repo.model.EntityTypeUtils;
import org.sagebionetworks.repo.model.table.Table;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.FeatureFlagConfig;
import org.sagebionetworks.web.client.FeatureFlagKey;
import org.sagebionetworks.web.client.StringUtils;
import org.sagebionetworks.web.client.SynapseJavascriptClient;
import org.sagebionetworks.web.client.cookie.CookieProvider;
Expand All @@ -36,17 +37,20 @@ public class RenameEntityModalWidgetImpl implements RenameEntityModalWidget {
String startingName;
String startingDescription;
Callback handler;
FeatureFlagConfig featureFlagConfig;

@Inject
public RenameEntityModalWidgetImpl(
PromptForValuesModalView view,
SynapseJavascriptClient jsClient,
CookieProvider cookieProvider
CookieProvider cookieProvider,
FeatureFlagConfig featureFlagConfig
) {
super();
this.view = view;
this.jsClient = jsClient;
this.cookies = cookieProvider;
this.featureFlagConfig = featureFlagConfig;
}

/**
Expand Down Expand Up @@ -134,8 +138,13 @@ public void onRename(Entity toRename, Callback handler) {
List<PromptForValuesModalView.InputType> inputTypes = new ArrayList<>();
inputTypes.add(PromptForValuesModalView.InputType.TEXTBOX);

// Only surfacing description for Table types (in experimental mode for now)
if (toRename instanceof Table && DisplayUtils.isInTestWebsite(cookies)) {
// Only surfacing description for Table types (behind feature flag for now)
if (
toRename instanceof Table &&
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.DESCRIPTION_FIELD.getKey()
)
) {
prompts.add("Description");
initialValues.add(toRename.getDescription());
inputTypes.add(PromptForValuesModalView.InputType.TEXTAREA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.sagebionetworks.web.client.DisplayConstants;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.DisplayUtils.MessagePopup;
import org.sagebionetworks.web.client.FeatureFlagConfig;
import org.sagebionetworks.web.client.FeatureFlagKey;
import org.sagebionetworks.web.client.PortalGinInjector;
import org.sagebionetworks.web.client.SynapseClientAsync;
import org.sagebionetworks.web.client.SynapseJavascriptClient;
Expand Down Expand Up @@ -69,6 +71,7 @@ public class WikiPageWidget
private SessionStorage sessionStorage;
private AuthenticationController authController;
private AdapterFactory adapterFactory;
private FeatureFlagConfig featureFlagConfig;
private boolean isModifiedCreatedByHistoryVisible = true;

public interface Callback {
Expand All @@ -95,7 +98,8 @@ public WikiPageWidget(
DateTimeUtils dateTimeUtils,
SynapseJavascriptClient jsClient,
CookieProvider cookies,
EventBus eventBus
EventBus eventBus,
FeatureFlagConfig featureFlagConfig
) {
this.view = view;
this.synapseClient = synapseClient;
Expand All @@ -110,6 +114,7 @@ public WikiPageWidget(
this.dateTimeUtils = dateTimeUtils;
this.jsClient = jsClient;
this.cookies = cookies;
this.featureFlagConfig = featureFlagConfig;
view.setPresenter(this);
view.setSynapseAlertWidget(stuAlert.asWidget());
view.setWikiHistoryWidget(historyWidget);
Expand Down Expand Up @@ -164,7 +169,9 @@ public void noWikiFound() {}
}
reloadWikiPage();
view.setWikiHistoryDiffToolButtonVisible(
DisplayUtils.isInTestWebsite(cookies),
featureFlagConfig.isFeatureEnabled(
FeatureFlagKey.WIKI_DIFF_TOOL.getKey()
),
wikiKey
);
}
Expand Down
Loading

0 comments on commit 0f40248

Please sign in to comment.