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-7067 #5611

Merged
merged 5 commits into from
Jan 8, 2025
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 @@ -21,6 +21,7 @@
import org.sagebionetworks.web.client.presenter.ComingSoonPresenter;
import org.sagebionetworks.web.client.presenter.DataAccessApprovalTokenPresenter;
import org.sagebionetworks.web.client.presenter.DataAccessManagementPresenter;
import org.sagebionetworks.web.client.presenter.DataCatalogPagePresenter;
import org.sagebionetworks.web.client.presenter.DownPresenter;
import org.sagebionetworks.web.client.presenter.DownloadCartPresenter;
import org.sagebionetworks.web.client.presenter.EmailInvitationPresenter;
Expand Down Expand Up @@ -346,6 +347,8 @@ public interface PortalGinInjector extends Ginjector {

DownloadCartPresenter getDownloadCartPresenter();

DataCatalogPagePresenter getDataCatalogPagePresenter();

ChangeUsernamePresenter getChangeUsernamePresenter();

TrashPresenter getTrashPresenter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
import org.sagebionetworks.web.client.view.DataAccessApprovalTokenViewImpl;
import org.sagebionetworks.web.client.view.DataAccessManagementView;
import org.sagebionetworks.web.client.view.DataAccessManagementViewImpl;
import org.sagebionetworks.web.client.view.DataCatalogPageView;
import org.sagebionetworks.web.client.view.DataCatalogPageViewImpl;
import org.sagebionetworks.web.client.view.DivView;
import org.sagebionetworks.web.client.view.DivViewImpl;
import org.sagebionetworks.web.client.view.DownView;
Expand Down Expand Up @@ -1368,6 +1370,7 @@ protected void configure() {
bind(PreviewConfigView.class).to(PreviewConfigViewImpl.class);
bind(SynapseFormConfigView.class).to(SynapseFormConfigViewImpl.class);
bind(DownloadCartPageView.class).to(DownloadCartPageViewImpl.class);
bind(DataCatalogPageView.class).to(DataCatalogPageViewImpl.class);
bind(EditFileMetadataModalView.class)
.to(EditFileMetadataModalViewImpl.class);
bind(EditFileMetadataModalWidget.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.sagebionetworks.web.client.jsinterop;

import java.util.Map;
import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;
import jsinterop.base.JsPropertyMap;

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

String type;
double secondaryLabelLimit;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
double secondaryLabelLimit;
long secondaryLabelLimit;

Copy link
Member Author

Choose a reason for hiding this comment

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

Did something change, I thought long values were disallowed? Or perhaps I'm misunderstanding.
From https://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html

The Java long type cannot be represented in JavaScript as a numeric type, so GWT emulates it using an opaque data structure. This means that JSNI methods cannot process a long as a numeric type. The compiler therefore disallows, by default, directly accessing a long from JSNI: JSNI methods cannot have long as a parameter type or a return type, and they cannot access a long using a JSNI reference.

Copy link
Contributor

@nickgros nickgros Jan 8, 2025

Choose a reason for hiding this comment

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

This is JsInterop, not JSNI. However, it seems like double is the least problematic primitive type for JsInterop. In JsInterop, int and long do work; we're using those for properties in other JsInterop types. I cannot find an authoritative document that describes exactly what Java primitives and classes JsInterop supports.

Keeping double is probably fine!

Copy link
Member Author

Choose a reason for hiding this comment

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

Right! I'm still thinking in JSNI. I guess I'll leave it, for the small potential performance gain

GenericCardSchema genericCardSchema;

@JsOverlay
public static CardConfiguration create(
String type,
int secondaryLabelLimit,
GenericCardSchema genericCardSchema
) {
CardConfiguration config = new CardConfiguration();
config.type = type;
config.secondaryLabelLimit = secondaryLabelLimit;
config.genericCardSchema = genericCardSchema;
return config;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.sagebionetworks.web.client.jsinterop;

import java.util.Map;
import jsinterop.annotations.JsNullable;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;
import jsinterop.base.JsPropertyMap;

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

String type;
String title;
String subTitle;
String description;
String[] secondaryLabels;

@JsOverlay
public static GenericCardSchema create(
String type,
String title,
String subTitle,
String description,
String[] secondaryLabels
) {
GenericCardSchema config = new GenericCardSchema();
config.type = type;
config.title = title;
config.subTitle = subTitle;
config.description = description;
config.secondaryLabels = secondaryLabels;
return config;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,35 @@ public interface OnViewSharingSettingsHandler {
@JsNullable
boolean defaultShowPlots;

@JsNullable
boolean defaultShowSearchBox;

@JsNullable
boolean hideCopyToClipboard;

@JsNullable
boolean hideDownload;

boolean showLastUpdatedOn;

@JsNullable
CardConfiguration cardConfiguration;

@JsOverlay
public static QueryWrapperPlotNavProps create(
String sql,
String initQueryJson,
OnQueryCallback onQueryChange,
OnQueryResultBundleCallback onQueryResultBundleChange,
OnViewSharingSettingsHandler onViewSharingSettingsClicked,
boolean hideSqlEditorControl
boolean hideSqlEditorControl,
Boolean defaultShowPlots,
Boolean defaultShowSearchBox,
Boolean hideCopyToClipboard,
Boolean hideDownload,
SynapseTableProps tableConfiguration,
CardConfiguration cardConfiguration,
String name
) {
QueryWrapperPlotNavProps props = new QueryWrapperPlotNavProps();
props.sql = sql;
Expand All @@ -73,13 +92,35 @@ public static QueryWrapperPlotNavProps create(
props.onQueryChange = onQueryChange;
props.onQueryResultBundleChange = onQueryResultBundleChange;
props.onViewSharingSettingsClicked = onViewSharingSettingsClicked;
props.tableConfiguration = SynapseTableProps.create();
if (tableConfiguration != null) {
props.tableConfiguration = tableConfiguration;
}
props.shouldDeepLink = false;
props.name = "Items";
if (name != null) {
props.name = name;
}
props.downloadCartPageUrl = "DownloadCart:0";
props.showLastUpdatedOn = false;
// SWC-6138 - hide charts by default
props.defaultShowPlots = false;
if (defaultShowPlots != null) {
//unbox
props.defaultShowPlots = defaultShowPlots;
}
if (defaultShowSearchBox != null) {
//unbox
props.defaultShowSearchBox = defaultShowSearchBox;
}
if (hideCopyToClipboard != null) {
//unbox
props.hideCopyToClipboard = hideCopyToClipboard;
}
if (hideDownload != null) {
//unbox
props.hideDownload = hideDownload;
}
props.cardConfiguration = cardConfiguration;
return props;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.sagebionetworks.web.client.place.Challenges;
import org.sagebionetworks.web.client.place.ChangeUsername;
import org.sagebionetworks.web.client.place.ComingSoon;
import org.sagebionetworks.web.client.place.DataCatalogPagePlace;
import org.sagebionetworks.web.client.place.Down;
import org.sagebionetworks.web.client.place.EmailInvitation;
import org.sagebionetworks.web.client.place.ErrorPlace;
Expand Down Expand Up @@ -105,6 +106,7 @@ public AppActivityMapper(
openAccessPlaces.add(AccessRequirementPlace.class);
openAccessPlaces.add(TrustCenterPlace.class);
openAccessPlaces.add(PlansPlace.class);
openAccessPlaces.add(DataCatalogPagePlace.class);

excludeFromLastPlace = new ArrayList<Class>();
excludeFromLastPlace.add(Home.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.sagebionetworks.web.client.place.ComingSoon;
import org.sagebionetworks.web.client.place.DataAccessApprovalTokenPlace;
import org.sagebionetworks.web.client.place.DataAccessManagementPlace;
import org.sagebionetworks.web.client.place.DataCatalogPagePlace;
import org.sagebionetworks.web.client.place.Down;
import org.sagebionetworks.web.client.place.DownloadCartPlace;
import org.sagebionetworks.web.client.place.EmailInvitation;
Expand Down Expand Up @@ -102,6 +103,7 @@
TrustCenterPlace.Tokenizer.class,
ChatPlace.Tokenizer.class,
PlansPlace.Tokenizer.class,
DataCatalogPagePlace.Tokenizer.class,
}
)
public interface AppPlaceHistoryMapper extends PlaceHistoryMapper {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.sagebionetworks.web.client.place;

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceTokenizer;
import com.google.gwt.place.shared.Prefix;

public class DataCatalogPagePlace extends Place {

private String token;

public DataCatalogPagePlace(String token) {
this.token = token;
}

public String toToken() {
return token;
}

@Prefix("DataCatalog")
public static class Tokenizer
implements PlaceTokenizer<DataCatalogPagePlace> {

@Override
public String getToken(DataCatalogPagePlace place) {
return place.toToken();
}

@Override
public DataCatalogPagePlace getPlace(String token) {
return new DataCatalogPagePlace(token);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.sagebionetworks.web.client.place.ComingSoon;
import org.sagebionetworks.web.client.place.DataAccessApprovalTokenPlace;
import org.sagebionetworks.web.client.place.DataAccessManagementPlace;
import org.sagebionetworks.web.client.place.DataCatalogPagePlace;
import org.sagebionetworks.web.client.place.Down;
import org.sagebionetworks.web.client.place.DownloadCartPlace;
import org.sagebionetworks.web.client.place.EmailInvitation;
Expand Down Expand Up @@ -548,6 +549,24 @@ public void onSuccess() {
presenter.start(panel, eventBus);
}

@Override
public void onFailure(Throwable caught) {
loadError(caught);
}
}
);
} else if (place instanceof DataCatalogPagePlace) {
GWT.runAsync(
DataCatalogPagePlace.class,
new RunAsyncCallback() {
@Override
public void onSuccess() {
DataCatalogPagePresenter presenter =
ginjector.getDataCatalogPagePresenter();
presenter.setPlace((DataCatalogPagePlace) place);
presenter.start(panel, eventBus);
}

@Override
public void onFailure(Throwable caught) {
loadError(caught);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.sagebionetworks.web.client.presenter;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.inject.Inject;
import org.sagebionetworks.web.client.view.DataCatalogPageView;

public class DataCatalogPagePresenter
extends AbstractActivity
implements
Presenter<org.sagebionetworks.web.client.place.DataCatalogPagePlace> {

private DataCatalogPageView view;

@Inject
public DataCatalogPagePresenter(DataCatalogPageView view) {
this.view = view;
}

@Override
public void start(AcceptsOneWidget panel, EventBus eventBus) {
panel.setWidget(view.asWidget());
}

@Override
public void setPlace(
final org.sagebionetworks.web.client.place.DataCatalogPagePlace place
) {
view.render();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.sagebionetworks.web.client.view;

import com.google.gwt.user.client.ui.IsWidget;

public interface DataCatalogPageView extends IsWidget {
public void render();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package org.sagebionetworks.web.client.view;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import java.util.HashMap;
import java.util.Map;
import org.sagebionetworks.web.client.context.SynapseReactClientFullContextPropsProvider;
import org.sagebionetworks.web.client.jsinterop.CardConfiguration;
import org.sagebionetworks.web.client.jsinterop.GenericCardSchema;
import org.sagebionetworks.web.client.widget.header.Header;
import org.sagebionetworks.web.client.widget.table.explore.QueryWrapperPlotNav;

public class DataCatalogPageViewImpl implements DataCatalogPageView {

SimplePanel container;

private Header headerWidget;
private SynapseReactClientFullContextPropsProvider propsProvider;

@Inject
public DataCatalogPageViewImpl(
Header headerWidget,
SynapseReactClientFullContextPropsProvider propsProvider
) {
container = new SimplePanel();
container.addStyleName("padding-30");
this.headerWidget = headerWidget;
this.propsProvider = propsProvider;
}

@Override
public void render() {
Window.scrollTo(0, 0); // scroll user to top of page
headerWidget.configure();

String[] secondaryLabels = { "contributors", "individuals", "id", "link" };
GenericCardSchema genericCardSchema = GenericCardSchema.create(
"dataset",
"name",
"community",
"description",
secondaryLabels
);
CardConfiguration cardConfiguration = CardConfiguration.create(
"GENERIC_CARD",
4,
genericCardSchema
);

QueryWrapperPlotNav plotNav = new QueryWrapperPlotNav(
propsProvider,
"SELECT * FROM syn61609402 WHERE includedInDataCatalog = 'true'",
null,
null,
newBundle -> {},
null,
true,
false,
true,
true,
true,
null,
cardConfiguration,
"Data Catalog"
);
container.clear();
container.setWidget(plotNav);
}

@Override
public Widget asWidget() {
return container.asWidget();
}
}
Loading
Loading