Skip to content

Commit

Permalink
Merge pull request #5375 from Sage-Bionetworks/release-498
Browse files Browse the repository at this point in the history
merge release 498 into develop
  • Loading branch information
jay-hodgson authored Apr 29, 2024
2 parents 9681c51 + 7b2bfc6 commit 9f3667b
Show file tree
Hide file tree
Showing 22 changed files with 289 additions and 120 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"react-transition-group": "2.6.0",
"sass": "^1.63.6",
"spark-md5": "^3.0.2",
"synapse-react-client": "3.2.12",
"synapse-react-client": "3.2.13",
"universal-cookie": "^4.0.4",
"xss": "^1.0.15"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CreateOrUpdateAccessRequirementWizardProps
@FunctionalInterface
@JsFunction
public interface OnComplete {
void onComplete();
void onComplete(String accessRequirementID);
}

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.sagebionetworks.repo.model.AccessRequirement;
import org.sagebionetworks.repo.model.RestrictableObjectDescriptor;
import org.sagebionetworks.repo.model.RestrictableObjectType;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.SynapseJavascriptClient;
import org.sagebionetworks.web.client.place.AccessRequirementPlace;
import org.sagebionetworks.web.client.place.AccessRequirementsPlace;
Expand Down Expand Up @@ -59,37 +60,44 @@ public void setPlace(AccessRequirementPlace place) {
String id = place.getParam(AccessRequirementsPlace.ID_PARAM);
String typeString = place.getParam(AccessRequirementsPlace.TYPE_PARAM);

// Note: configuring the Access Requirement widget without a target subject will result in notifications sent to the user will not have the context (Project/Folder/File associated with the restriction).
if (id != null && typeString != null) {
RestrictableObjectDescriptor targetSubject =
new RestrictableObjectDescriptor();
RestrictableObjectType type = RestrictableObjectType.valueOf(
typeString.toUpperCase()
);
targetSubject.setType(type);
targetSubject.setId(id);
jsClient.getAccessRequirement(
requirementId,
new AsyncCallback<AccessRequirement>() {
@Override
public void onSuccess(AccessRequirement result) {
String titleInfo = DisplayUtils.isDefined(result.getName())
? ": " + result.getName()
: "";
view.addTitle("Access Requirement" + titleInfo);

arWidget.configure(requirementId, targetSubject);
} else {
// SWC-6700: No subject specified, pick a random one since some code assumes a subject has been specified.
jsClient.getAccessRequirement(
requirementId,
new AsyncCallback<AccessRequirement>() {
@Override
public void onSuccess(AccessRequirement result) {
RestrictableObjectDescriptor firstSubject = result
.getSubjectIds()
.get(0);
// Note: configuring the Access Requirement widget without a target subject will result in notifications sent to the user will not have the context (Project/Folder/File associated with the restriction).
if (id != null && typeString != null) {
RestrictableObjectDescriptor targetSubject =
new RestrictableObjectDescriptor();
RestrictableObjectType type = RestrictableObjectType.valueOf(
typeString.toUpperCase()
);
targetSubject.setType(type);
targetSubject.setId(id);

arWidget.configure(requirementId, targetSubject);
} else {
// SWC-6700: No subject specified, pick a random one since some code assumes a subject has been specified.
// configure using the first subject, if available
RestrictableObjectDescriptor firstSubject = null;
if (result.getSubjectIds().size() > 0) {
firstSubject = result.getSubjectIds().get(0);
}
arWidget.configure(requirementId, firstSubject);
}
}

@Override
public void onFailure(Throwable caught) {
synAlert.handleException(caught);
}
@Override
public void onFailure(Throwable caught) {
synAlert.handleException(caught);
}
);
}
}
);
}

public AccessRequirementPlace getPlace() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public void onSuccess(String rootWikiId) {
convertACTAccessRequirementButton.configure(ar, refreshCallback);
view.setAccessRequirementName(ar.getName());
view.setAccessRequirementID(ar.getId().toString());
view.setSubjectsDefinedByAnnotations(ar.getSubjectsDefinedByAnnotations());
lazyLoadHelper.setIsConfigured();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,6 @@ public interface Presenter {
void setAccessRequirementIDVisible(boolean visible);

void setAccessRequirementID(String arID);

void setSubjectsDefinedByAnnotations(Boolean subjectsDefinedByAnnotations);
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public class ACTAccessRequirementWidgetViewImpl
@UiField
InlineLabel accessRequirementIDField;

@UiField
Div subjectsDefinedByAnnotationsUI;

@UiField
Div subjectsDefinedInAccessRequirementUI;

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

Expand Down Expand Up @@ -265,6 +271,17 @@ public void setAccessRequirementName(String description) {
}
}

@Override
public void setSubjectsDefinedByAnnotations(
Boolean subjectsDefinedByAnnotations
) {
boolean v = subjectsDefinedByAnnotations != null
? subjectsDefinedByAnnotations.booleanValue()
: false;
subjectsDefinedByAnnotationsUI.setVisible(v);
subjectsDefinedInAccessRequirementUI.setVisible(!v);
}

@Override
public void setCoveredEntitiesHeadingVisible(boolean visible) {
coveredEntitiesHeadingUI.setVisible(visible);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.sagebionetworks.web.client.PortalGinInjector;
import org.sagebionetworks.web.client.cookie.CookieProvider;
import org.sagebionetworks.web.client.jsinterop.CreateOrUpdateAccessRequirementWizardProps;
import org.sagebionetworks.web.client.place.AccessRequirementPlace;
import org.sagebionetworks.web.client.utils.Callback;
import org.sagebionetworks.web.client.utils.CallbackP;
import org.sagebionetworks.web.client.widget.accessrequirements.createaccessrequirement.CreateOrUpdateAccessRequirementWizard;
Expand Down Expand Up @@ -126,11 +127,17 @@ private void useSrcWizard() {
CreateOrUpdateAccessRequirementWizard wizard =
ginInjector.getCreateOrUpdateAccessRequirementWizard();

CreateOrUpdateAccessRequirementWizardProps.OnComplete onComplete = () -> {
wizard.setOpen(false);
refreshCallback.invoke();
view.clearWidgets();
};
CreateOrUpdateAccessRequirementWizardProps.OnComplete onComplete =
accessRequirementID -> {
wizard.setOpen(false);
view.clearWidgets();
AccessRequirementPlace target = new AccessRequirementPlace("");
target.putParam(
AccessRequirementPlace.AR_ID_PARAM,
accessRequirementID
);
ginInjector.getGlobalApplicationState().getPlaceChanger().goTo(target);
};
CreateOrUpdateAccessRequirementWizardProps.OnCancel onCancel = () -> {
wizard.setOpen(false);
refreshCallback.invoke();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ public void onSuccess(String rootWikiId) {
isACTMemberAsyncHandler.isACTActionAvailable(isACT -> {
view.setAccessRequirementIDVisible(isACT);
view.setCoveredEntitiesHeadingVisible(isACT);
// show the subjects defined by annotations UI if isACT and this flag is set
view.setSubjectsDefinedByAnnotations(
isACT && ar.getSubjectsDefinedByAnnotations()
);
});
view.setAccessRequirementName(ar.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,6 @@ public interface Presenter {
void setAccessRequirementRelatedProjectsList(
IsWidget accessRequirementRelatedProjectsList
);

void setSubjectsDefinedByAnnotations(Boolean subjectsDefinedByAnnotations);
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ public class ManagedACTAccessRequirementWidgetViewImpl
@UiField
Span accessRequirementDescription;

@UiField
Div subjectsDefinedByAnnotationsUI;

@UiField
Div subjectsDefinedInAccessRequirementUI;

private final JSONObjectAdapter jsonObjectAdapter;
private final SynapseReactClientFullContextPropsProvider propsProvider;
Callback onAttachCallback;
Expand Down Expand Up @@ -403,6 +409,17 @@ public void showRequestAccessModal(
);
}

@Override
public void setSubjectsDefinedByAnnotations(
Boolean subjectsDefinedByAnnotations
) {
boolean v = subjectsDefinedByAnnotations != null
? subjectsDefinedByAnnotations.booleanValue()
: false;
subjectsDefinedByAnnotationsUI.setVisible(v);
subjectsDefinedInAccessRequirementUI.setVisible(!v);
}

public void hideRequestAccessModal() {
requestDataAccessWidget.clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public void onSuccess(String rootWikiId) {
isACTMemberAsyncHandler.isACTActionAvailable(isACT -> {
view.setAccessRequirementIDVisible(isACT);
view.setCoveredEntitiesHeadingVisible(isACT);
// show the subjects defined by annotations UI if isACT and this flag is set
view.setSubjectsDefinedByAnnotations(
isACT && ar.getSubjectsDefinedByAnnotations()
);
});
lazyLoadHelper.setIsConfigured();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ public interface Presenter {
void setAccessRequirementRelatedProjectsList(
IsWidget accessRequirementRelatedProjectsList
);

void setSubjectsDefinedByAnnotations(Boolean subjectsDefinedByAnnotations);
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ public class SelfSignAccessRequirementWidgetViewImpl

Callback onAttachCallback;

@UiField
Div subjectsDefinedByAnnotationsUI;

@UiField
Div subjectsDefinedInAccessRequirementUI;

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

Expand Down Expand Up @@ -241,4 +247,15 @@ public void setAccessRequirementID(String arID) {
public void setAccessRequirementIDVisible(boolean visible) {
accessRequirementIDUI.setVisible(visible);
}

@Override
public void setSubjectsDefinedByAnnotations(
Boolean subjectsDefinedByAnnotations
) {
boolean v = subjectsDefinedByAnnotations != null
? subjectsDefinedByAnnotations.booleanValue()
: false;
subjectsDefinedByAnnotationsUI.setVisible(v);
subjectsDefinedInAccessRequirementUI.setVisible(!v);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ public void onSuccess(String rootWikiId) {
isACTMemberAsyncHandler.isACTActionAvailable(isACT -> {
view.setAccessRequirementIDVisible(isACT);
view.setCoveredEntitiesHeadingVisible(isACT);
// show the subjects defined by annotations UI if isACT and this flag is set
view.setSubjectsDefinedByAnnotations(
isACT && ar.getSubjectsDefinedByAnnotations()
);
});
teamSubjectsWidget.configure(ar.getSubjectIds());
entitySubjectsWidget.configure(ar.getSubjectIds());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ public interface Presenter {
void setAccessRequirementRelatedProjectsList(
IsWidget accessRequirementRelatedProjectsList
);

void setSubjectsDefinedByAnnotations(Boolean subjectsDefinedByAnnotations);
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public class TermsOfUseAccessRequirementWidgetViewImpl
@UiField
Div controlsContainer;

@UiField
Div subjectsDefinedByAnnotationsUI;

@UiField
Div subjectsDefinedInAccessRequirementUI;

Callback onAttachCallback;

public interface Binder
Expand Down Expand Up @@ -232,4 +238,15 @@ public void showLoginButton() {
public void hideControls() {
controlsContainer.setVisible(false);
}

@Override
public void setSubjectsDefinedByAnnotations(
Boolean subjectsDefinedByAnnotations
) {
boolean v = subjectsDefinedByAnnotations != null
? subjectsDefinedByAnnotations.booleanValue()
: false;
subjectsDefinedByAnnotationsUI.setVisible(v);
subjectsDefinedInAccessRequirementUI.setVisible(!v);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,35 @@
/>
<g:InlineLabel ui:field="accessRequirementIDField" />
</bh:Div>
<bh:Div ui:field="coveredEntitiesHeadingUI" styleName="margin-top-10">
<g:InlineLabel styleName="boldText" text="Entities Covered" />
<bh:Hr addStyleNames="margin-top-5 margin-bottom-5" />
<bh:Div ui:field="subjectsDefinedByAnnotationsUI" visible="false">
<bh:Strong>
Subjects controlled by this Access Requirement are defined by
annotations on individual entities.
</bh:Strong>
</bh:Div>
<bh:Div
ui:field="accessRequirementRelatedProjectsListContainer"
addStyleNames="margin-left-5 margin-right-5 accessRequirementRelatedProjectsListContainer"
/>
<bh:Div
ui:field="entitySubjectsWidgetContainer"
addStyleNames="margin-left-5 margin-right-5"
/>
<bh:ClearFix />
<bh:Div>
<bh:Div ui:field="subjectsDefinedInAccessRequirementUI">
<bh:Div ui:field="coveredEntitiesHeadingUI" styleName="margin-top-10">
<g:InlineLabel styleName="boldText" text="Entities Covered" />
<bh:Hr addStyleNames="margin-top-5 margin-bottom-5" />
</bh:Div>
<bh:Div
ui:field="accessRequirementRelatedProjectsListContainer"
addStyleNames="margin-left-5 margin-right-5 accessRequirementRelatedProjectsListContainer"
/>
<bh:Div
ui:field="teamSubjectsWidgetContainer"
pull="LEFT"
ui:field="entitySubjectsWidgetContainer"
addStyleNames="margin-left-5 margin-right-5"
/>
<bh:ClearFix />
<bh:Div>
<bh:Div
ui:field="teamSubjectsWidgetContainer"
pull="LEFT"
addStyleNames="margin-left-5 margin-right-5"
/>
</bh:Div>
<bh:ClearFix />
</bh:Div>
<bh:ClearFix />

<bh:Div addStyleNames="margin-top-5" ui:field="controlsContainer">
<bh:Div
ui:field="convertAccessRequirementContainer"
Expand Down
Loading

0 comments on commit 9f3667b

Please sign in to comment.