Skip to content

Commit

Permalink
Merge pull request #5577 from jay-hodgson/SWC-7063
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hodgson authored Nov 7, 2024
2 parents 6de38c6 + db78558 commit 62bfc97
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@
import org.sagebionetworks.web.client.widget.profile.UserProfileWidgetImpl;
import org.sagebionetworks.web.client.widget.profile.UserProfileWidgetView;
import org.sagebionetworks.web.client.widget.profile.UserProfileWidgetViewImpl;
import org.sagebionetworks.web.client.widget.projectdataavailability.ProjectDataAvailabilityView;
import org.sagebionetworks.web.client.widget.projectdataavailability.ProjectDataAvailabilityViewImpl;
import org.sagebionetworks.web.client.widget.provenance.v2.ProvenanceWidgetView;
import org.sagebionetworks.web.client.widget.provenance.v2.ProvenanceWidgetViewImpl;
import org.sagebionetworks.web.client.widget.refresh.RefreshAlertView;
Expand Down Expand Up @@ -1619,5 +1621,8 @@ protected void configure() {
bind(FeatureFlagConfig.class).in(Singleton.class);
bind(EntityTypeIcon.class).to(EntityTypeIconImpl.class);
bind(OneSageUtils.class).to(OneSageUtilsImpl.class);
bind(ProjectDataAvailabilityView.class)
.to(ProjectDataAvailabilityViewImpl.class)
.in(Singleton.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.sagebionetworks.web.client.jsinterop;

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

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

@JsNullable
public String projectId;

@JsNullable
public SxProps sx;

@JsOverlay
public static ProjectDataAvailabilityProps create(
String projectId,
SxProps sx
) {
ProjectDataAvailabilityProps props = new ProjectDataAvailabilityProps();
if (projectId != null) {
props.projectId = projectId;
}
if (sx != null) {
props.sx = sx;
}
return props;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public static class SynapseComponents {
public static ReactComponentType<
GovernanceMarkdownGithubProps
> GovernanceMarkdownGithub;
public static ReactComponentType<
ProjectDataAvailabilityProps
> ProjectDataAvailability;

/**
* 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 @@ -4,14 +4,15 @@
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import org.gwtbootstrap3.client.ui.Anchor;
import org.gwtbootstrap3.client.ui.html.Span;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.widget.TextBoxWithCopyToClipboardWidget;
import org.sagebionetworks.web.client.widget.CopyTextModal;

public class DoiWidgetV2ViewImpl implements DoiWidgetV2View {

@UiField
TextBoxWithCopyToClipboardWidget copyToClipboardWidget;
Anchor viewDoiLink;

@UiField
Span doiLabel;
Expand All @@ -25,16 +26,22 @@ public class DoiWidgetV2ViewImpl implements DoiWidgetV2View {

public interface Binder extends UiBinder<Widget, DoiWidgetV2ViewImpl> {}

CopyTextModal copyTextModal;

@Inject
public DoiWidgetV2ViewImpl(Binder uiBinder) {
public DoiWidgetV2ViewImpl(Binder uiBinder, CopyTextModal copyTextModal) {
widget = uiBinder.createAndBindUi(this);
this.copyTextModal = copyTextModal;
copyTextModal.setTitle("DOI");
}

@Override
public void showDoi(String doiText) {
widget.setVisible(true);
copyToClipboardWidget.setVisible(true);
copyToClipboardWidget.setText(doiText);
copyTextModal.setText(doiText);
viewDoiLink.addClickHandler(clickEvent -> {
copyTextModal.show();
});
doiLabel.setVisible(isLabelVisible);
}

Expand All @@ -48,8 +55,7 @@ public Widget asWidget() {

@Override
public void clear() {
copyToClipboardWidget.setText("");
copyToClipboardWidget.setVisible(false);
copyTextModal.setText("");
doiLabel.setVisible(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.sagebionetworks.repo.model.ObjectType;
import org.sagebionetworks.repo.model.Project;
import org.sagebionetworks.repo.model.VersionableEntity;
import org.sagebionetworks.repo.model.docker.DockerRepository;
import org.sagebionetworks.repo.model.doi.v2.DoiAssociation;
import org.sagebionetworks.repo.model.entitybundle.v2.EntityBundle;
import org.sagebionetworks.repo.model.file.ExternalGoogleCloudUploadDestination;
Expand All @@ -23,15 +22,14 @@
import org.sagebionetworks.repo.model.file.S3UploadDestination;
import org.sagebionetworks.repo.model.file.UploadDestination;
import org.sagebionetworks.repo.model.file.UploadType;
import org.sagebionetworks.repo.model.table.TableEntity;
import org.sagebionetworks.web.client.PortalGinInjector;
import org.sagebionetworks.web.client.SynapseJSNIUtils;
import org.sagebionetworks.web.client.SynapseJavascriptClient;
import org.sagebionetworks.web.client.widget.doi.DoiWidgetV2;
import org.sagebionetworks.web.client.widget.entity.controller.EntityActionControllerImpl;
import org.sagebionetworks.web.client.widget.entity.menu.v3.Action;
import org.sagebionetworks.web.client.widget.entity.menu.v3.EntityActionMenu;
import org.sagebionetworks.web.client.widget.entity.restriction.v2.RestrictionWidget;
import org.sagebionetworks.web.client.widget.projectdataavailability.ProjectDataAvaiilability;

public class EntityMetadata {

Expand All @@ -41,10 +39,8 @@ public class EntityMetadata {
private final SynapseJavascriptClient jsClient;
private final SynapseJSNIUtils jsni;
private final PortalGinInjector ginInjector;
private final ContainerItemCountWidget containerItemCountWidget;
private final org.sagebionetworks.web.client.widget.entity.restriction.v2.RestrictionWidget restrictionWidgetV2;
private final EntityModalWidget entityModalWidget;

private ProjectDataAvaiilability projectDataAvailabilityWidget;
private boolean annotationsAreVisible = false;

@Inject
Expand All @@ -53,25 +49,20 @@ public EntityMetadata(
DoiWidgetV2 doiWidgetV2,
SynapseJavascriptClient jsClient,
SynapseJSNIUtils jsni,
RestrictionWidget restrictionWidgetV2,
ContainerItemCountWidget containerItemCountWidget,
PortalGinInjector ginInjector,
EntityModalWidget entityModalWidget
EntityModalWidget entityModalWidget,
ProjectDataAvaiilability projectDataAvailabilityWidget
) {
this.view = view;
this.doiWidgetV2 = doiWidgetV2;
this.jsClient = jsClient;
this.jsni = jsni;
this.restrictionWidgetV2 = restrictionWidgetV2;
this.containerItemCountWidget = containerItemCountWidget;
this.ginInjector = ginInjector;
this.entityModalWidget = entityModalWidget;
this.projectDataAvailabilityWidget = projectDataAvailabilityWidget;
this.view.setDoiWidget(doiWidgetV2);
this.view.setEntityModalWidget(entityModalWidget);
this.view.setRestrictionWidgetV2(restrictionWidgetV2);
this.view.setContainerItemCountWidget(containerItemCountWidget);
restrictionWidgetV2.setShowChangeLink(true);
view.setRestrictionWidgetV2Visible(true);
this.view.setProjectDataAvailabilityWidget(projectDataAvailabilityWidget);
}

public Widget asWidget() {
Expand Down Expand Up @@ -133,22 +124,14 @@ public void configure(
!((VersionableEntity) bundle.getEntity()).getIsLatestVersion()
);
getVersionHistoryWidget().setEntityBundle(bundle, versionNumber);
view.setRestrictionPanelVisible(true);
} else {
if (versionHistoryWidget != null) {
versionHistoryWidget.setVisible(false);
}
view.setRestrictionPanelVisible(
en instanceof TableEntity ||
en instanceof Folder ||
en instanceof DockerRepository
);
}
if (bundle.getEntity() instanceof Folder) {
containerItemCountWidget.configure(bundle.getEntity().getId());
}
configureStorageLocation(en);

projectDataAvailabilityWidget.setProjectId(en.getId());
// An unversioned DOI may not have been included in the (versioned) entity bundle, so we should see if one exists
if (
bundle.getDoiAssociation() == null && // If a versioned DOI exists, we should show that
Expand All @@ -174,10 +157,6 @@ public void onFailure(Throwable t) {
} else if (bundle.getDoiAssociation() != null) {
doiWidgetV2.configure(bundle.getDoiAssociation());
}
restrictionWidgetV2.configure(
en,
bundle.getPermissions().getCanChangePermissions()
);
}

public void setAnnotationsVisible(boolean visible) {
Expand All @@ -187,7 +166,6 @@ public void setAnnotationsVisible(boolean visible) {

public void clear() {
doiWidgetV2.clear();
containerItemCountWidget.clear();
view.clear();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ public interface EntityMetadataView extends IsWidget {

void clear();

public void setRestrictionPanelVisible(boolean visible);

void setRestrictionWidgetV2(IsWidget restrictionWidget);

void setEntityModalWidget(IsWidget widget);

void setEntityId(String text);
Expand All @@ -25,9 +21,7 @@ public interface EntityMetadataView extends IsWidget {

void setUploadDestinationText(String text);

void setRestrictionWidgetV2Visible(boolean visible);

void setContainerItemCountWidget(IsWidget w);

void setDescription(String description);

void setProjectDataAvailabilityWidget(IsWidget widget);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.*;
import com.google.inject.Inject;
import org.gwtbootstrap3.client.ui.Collapse;
import org.gwtbootstrap3.client.ui.html.Div;
import org.gwtbootstrap3.client.ui.html.Paragraph;
import org.gwtbootstrap3.client.ui.html.Span;
import org.gwtbootstrap3.client.ui.html.Text;
import org.sagebionetworks.web.client.widget.IconSvg;

public class EntityMetadataViewImpl
extends Composite
Expand All @@ -26,21 +23,12 @@ interface EntityMetadataViewImplUiBinder
@UiField
HTMLPanel detailedMetadata;

@UiField
HTMLPanel dataUseContainer;

@UiField
TextBox idField;

@UiField
Span doiPanel;

@UiField
Span containerItemCountContainer;

@UiField
Span restrictionPanelV2;

@UiField
Div fileHistoryContainer;

Expand All @@ -59,18 +47,15 @@ interface EntityMetadataViewImplUiBinder
@UiField
SimplePanel entityModalWidgetContainer;

@UiField
Span projectDataAvailabilityPanel;

@Inject
public EntityMetadataViewImpl() {
initWidget(uiBinder.createAndBindUi(this));
idField.addClickHandler(event -> idField.selectAll());
}

@Override
public void setContainerItemCountWidget(IsWidget w) {
containerItemCountContainer.clear();
containerItemCountContainer.add(w);
}

@Override
public void setDoiWidget(IsWidget doiWidget) {
doiPanel.clear();
Expand Down Expand Up @@ -100,7 +85,6 @@ public void setVersionHistoryWidget(IsWidget fileHistoryWidget) {

@Override
public void clear() {
dataUseContainer.setVisible(false);
uploadDestinationField.setText("");
uploadDestinationPanel.setVisible(false);
}
Expand All @@ -116,14 +100,9 @@ public void setEntityId(String entityId) {
}

@Override
public void setRestrictionPanelVisible(boolean visible) {
dataUseContainer.setVisible(visible);
}

@Override
public void setRestrictionWidgetV2(IsWidget restrictionWidget) {
restrictionPanelV2.clear();
restrictionPanelV2.add(restrictionWidget);
public void setProjectDataAvailabilityWidget(IsWidget widget) {
projectDataAvailabilityPanel.clear();
projectDataAvailabilityPanel.add(widget);
}

@Override
Expand All @@ -132,11 +111,6 @@ public void setEntityModalWidget(IsWidget entityModalWidget) {
entityModalWidgetContainer.add(entityModalWidget);
}

@Override
public void setRestrictionWidgetV2Visible(boolean visible) {
restrictionPanelV2.setVisible(visible);
}

@Override
public void setDescription(String description) {
descriptionText.setText(description);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.sagebionetworks.web.client.widget.projectdataavailability;

import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;

public class ProjectDataAvaiilability implements IsWidget {

ProjectDataAvailabilityView view;

@Inject
public ProjectDataAvaiilability(ProjectDataAvailabilityView view) {
this.view = view;
}

public void setProjectId(String projectId) {
view.setProjectId(projectId);
}

public Widget asWidget() {
return view.asWidget();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.sagebionetworks.web.client.widget.projectdataavailability;

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

public interface ProjectDataAvailabilityView extends IsWidget {
void setProjectId(String projectId);
}
Loading

0 comments on commit 62bfc97

Please sign in to comment.