Skip to content

Commit

Permalink
Merge pull request #5520 from nickgros/SWC-6923
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgros authored Sep 20, 2024
2 parents e428922 + c54c5b7 commit 62597f5
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 62 deletions.
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*.svg
*.png

*.properties

# These artifacts were generated and/or pre-minified and then checked in
src/main/webapp/css/**/*
src/main/webapp/js/**/*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.sagebionetworks.web.client.jsinterop;

import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import org.sagebionetworks.repo.model.verification.VerificationStateEnum;

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

@JsFunction
public interface Callback {
void run();
}

/* SynID of the table which contains the email responses which should populate this modal. */
public String tableId;
public boolean open;
public String verificationSubmissionId;
public String currentState;
public Callback onRejectionSubmittedSuccess;
public Callback onClose;

@JsOverlay
public static RejectProfileValidationRequestModalProps create(
String verificationSubmissionId,
VerificationStateEnum currentState,
String tableId,
boolean open,
Callback onRejectionSubmittedSuccess,
Callback onClose
) {
RejectProfileValidationRequestModalProps props =
new RejectProfileValidationRequestModalProps();

props.verificationSubmissionId = verificationSubmissionId;
props.currentState = currentState.toString();
props.tableId = tableId;
props.open = open;
props.onRejectionSubmittedSuccess = onRejectionSubmittedSuccess;
props.onClose = onClose;
return props;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public static class SynapseComponents {
EntityAclEditorModalProps
> EntityAclEditorModal;
public static ReactComponentType<SynapseChatProps> SynapseChat;
public static ReactComponentType<
RejectProfileValidationRequestModalProps
> RejectProfileValidationRequestModal;

/**
* 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
@@ -1,5 +1,7 @@
package org.sagebionetworks.web.client.widget.verification;

import static org.sagebionetworks.web.shared.WebConstants.ACT_PROFILE_VALIDATION_REJECTION_REASONS_TABLE_PROPERTY_KEY;

import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.IsWidget;
Expand All @@ -21,10 +23,16 @@
import org.sagebionetworks.repo.model.verification.VerificationState;
import org.sagebionetworks.repo.model.verification.VerificationStateEnum;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.SynapseProperties;
import org.sagebionetworks.web.client.context.SynapseReactClientFullContextPropsProvider;
import org.sagebionetworks.web.client.jsinterop.React;
import org.sagebionetworks.web.client.jsinterop.RejectProfileValidationRequestModalProps;
import org.sagebionetworks.web.client.jsinterop.SRC;
import org.sagebionetworks.web.client.view.bootstrap.table.Table;
import org.sagebionetworks.web.client.view.bootstrap.table.TableData;
import org.sagebionetworks.web.client.view.bootstrap.table.TableHeader;
import org.sagebionetworks.web.client.view.bootstrap.table.TableRow;
import org.sagebionetworks.web.client.widget.ReactComponent;
import org.sagebionetworks.web.client.widget.table.v2.results.cell.Cell;
import org.sagebionetworks.web.client.widget.table.v2.results.cell.CellFactory;

Expand Down Expand Up @@ -120,7 +128,10 @@ public interface Binder
Table actStateHistoryTable;

TableRow actStateHistoryTableHeaderRow;
CellFactory cellFactory;

private final CellFactory cellFactory;
private final SynapseProperties synapseProperties;
private final SynapseReactClientFullContextPropsProvider propsProvider;

@Override
public void setPresenter(Presenter presenter) {
Expand All @@ -130,10 +141,14 @@ public void setPresenter(Presenter presenter) {
@Inject
public VerificationSubmissionModalViewImpl(
Binder binder,
CellFactory cellFactory
CellFactory cellFactory,
SynapseProperties synapseProperties,
SynapseReactClientFullContextPropsProvider propsProvider
) {
widget = binder.createAndBindUi(this);
this.cellFactory = cellFactory;
this.synapseProperties = synapseProperties;
this.propsProvider = propsProvider;

// click handlers
submitButton.addClickHandler(event -> {
Expand Down Expand Up @@ -355,6 +370,33 @@ public void setProfileFieldsEditable(boolean editable) {
location.setEnabled(editable);
}

@Override
public void showRejectModal(
String submissionId,
VerificationStateEnum currentState,
RejectProfileValidationRequestModalProps.Callback onRejectSuccess
) {
final ReactComponent promptModalV2 = new ReactComponent();
RejectProfileValidationRequestModalProps props =
RejectProfileValidationRequestModalProps.create(
submissionId,
currentState,
synapseProperties.getSynapseProperty(
ACT_PROFILE_VALIDATION_REJECTION_REASONS_TABLE_PROPERTY_KEY
),
true,
onRejectSuccess,
promptModalV2::clear
);
promptModalV2.render(
React.createElementWithSynapseContext(
SRC.SynapseComponents.RejectProfileValidationRequestModal,
props,
propsProvider.getJsInteropContextProps()
)
);
}

@Override
public String getFirstName() {
return firstName.getValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.sagebionetworks.web.client.widget.verification;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import static org.sagebionetworks.web.shared.WebConstants.ACT_PROFILE_VALIDATION_REJECTION_REASONS_TABLE_PROPERTY_KEY;

import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Widget;
Expand All @@ -15,6 +15,12 @@
import org.sagebionetworks.repo.model.verification.VerificationState;
import org.sagebionetworks.repo.model.verification.VerificationStateEnum;
import org.sagebionetworks.web.client.DisplayUtils;
import org.sagebionetworks.web.client.SynapseProperties;
import org.sagebionetworks.web.client.context.SynapseReactClientFullContextPropsProvider;
import org.sagebionetworks.web.client.jsinterop.React;
import org.sagebionetworks.web.client.jsinterop.RejectProfileValidationRequestModalProps;
import org.sagebionetworks.web.client.jsinterop.SRC;
import org.sagebionetworks.web.client.widget.ReactComponent;

public class VerificationSubmissionRowViewImpl
implements VerificationSubmissionWidgetView {
Expand All @@ -26,6 +32,9 @@ public interface Binder

Widget widget;

private final SynapseProperties synapseProperties;
private final SynapseReactClientFullContextPropsProvider propsProvider;

@UiField
Span firstName;

Expand Down Expand Up @@ -83,7 +92,14 @@ public void setPresenter(Presenter presenter) {
}

@Inject
public VerificationSubmissionRowViewImpl(Binder binder) {
public VerificationSubmissionRowViewImpl(
Binder binder,
SynapseProperties synapseProperties,
SynapseReactClientFullContextPropsProvider propsProvider
) {
this.synapseProperties = synapseProperties;
this.propsProvider = propsProvider;

widget = binder.createAndBindUi(this);

approveButton.addClickHandler(event -> {
Expand Down Expand Up @@ -276,6 +292,33 @@ public void setProfileFieldsEditable(boolean editable) {
// Not used in this view implementation
}

@Override
public void showRejectModal(
String submissionId,
VerificationStateEnum currentState,
RejectProfileValidationRequestModalProps.Callback onRejectSuccess
) {
final ReactComponent promptModalV2 = new ReactComponent();
RejectProfileValidationRequestModalProps props =
RejectProfileValidationRequestModalProps.create(
submissionId,
currentState,
synapseProperties.getSynapseProperty(
ACT_PROFILE_VALIDATION_REJECTION_REASONS_TABLE_PROPERTY_KEY
),
true,
onRejectSuccess,
promptModalV2::clear
);
promptModalV2.render(
React.createElementWithSynapseContext(
SRC.SynapseComponents.RejectProfileValidationRequestModal,
props,
propsProvider.getJsInteropContextProps()
)
);
}

@Override
public void setResubmitButtonVisible(boolean visible) {
// Not used in this view implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import org.sagebionetworks.web.client.GWTWrapper;
import org.sagebionetworks.web.client.GlobalApplicationState;
import org.sagebionetworks.web.client.PortalGinInjector;
import org.sagebionetworks.web.client.SynapseProperties;
import org.sagebionetworks.web.client.UserProfileClientAsync;
import org.sagebionetworks.web.client.context.SynapseReactClientFullContextPropsProvider;
import org.sagebionetworks.web.client.utils.Callback;
import org.sagebionetworks.web.client.widget.entity.PromptForValuesModalView;
import org.sagebionetworks.web.client.widget.entity.act.RejectReasonWidget;
import org.sagebionetworks.web.client.widget.entity.controller.SynapseAlert;
import org.sagebionetworks.web.client.widget.upload.FileHandleList;

Expand All @@ -32,17 +33,19 @@ public class VerificationSubmissionWidget
private static final String ACT_NOTES_PROMPT = "ACT notes (optional)";
public static final String FILL_IN_PROFILE_FIELDS_MESSAGE =
"Please edit your profile to fill in your first name, last name, affiliation, and city/country before requesting profile validation.";
private UserProfileClientAsync userProfileClient;
private SynapseAlert synAlert;
private FileHandleList fileHandleList;
private final UserProfileClientAsync userProfileClient;
private final SynapseAlert synAlert;
private final FileHandleList fileHandleList;
private UserProfile profile;
private VerificationSubmission submission;
private String orcId;
private List<AttachmentMetadata> existingAttachments;
private VerificationSubmissionWidgetView view;
private GlobalApplicationState globalAppState;
private PortalGinInjector ginInjector;
private GWTWrapper gwt;
private final GlobalApplicationState globalAppState;
private final PortalGinInjector ginInjector;
private final GWTWrapper gwt;
private final SynapseReactClientFullContextPropsProvider propsProvider;
private final SynapseProperties synapseProperties;
// this could be Reject or Suspend. We store this state while the reason is being collected from the
// ACT user
private VerificationStateEnum actRejectState;
Expand All @@ -58,7 +61,9 @@ public VerificationSubmissionWidget(
SynapseAlert synAlert,
FileHandleList fileHandleList,
GlobalApplicationState globalAppState,
GWTWrapper gwt
GWTWrapper gwt,
SynapseReactClientFullContextPropsProvider propsProvider,
SynapseProperties synapseProperties
) {
this.ginInjector = ginInjector;
this.userProfileClient = userProfileClient;
Expand All @@ -67,6 +72,8 @@ public VerificationSubmissionWidget(
this.fileHandleList = fileHandleList;
this.globalAppState = globalAppState;
this.gwt = gwt;
this.propsProvider = propsProvider;
this.synapseProperties = synapseProperties;
}

public void initView(boolean isModal) {
Expand Down Expand Up @@ -361,7 +368,9 @@ public void onFailure(Throwable caught) {
}

public void handleSuccess(String message) {
view.showInfo(message);
if (message != null) {
view.showInfo(message);
}
view.hide();
globalAppState.refreshPage();
}
Expand Down Expand Up @@ -425,22 +434,14 @@ public void suspendVerification() {
}

private void rejectSuspendVerification() {
RejectReasonWidget promptModal = ginInjector.getRejectReasonWidget();
view.setPromptModal(promptModal.asWidget());
promptModal.show(rejectionReason -> {
PromptForValuesModalView promptForValuesModal =
ginInjector.getPromptForValuesModal();
view.setPromptModal(promptForValuesModal.asWidget());
promptForValuesModal.configureAndShow(
getConfirmationDialogTitle(actRejectState),
ACT_NOTES_PROMPT,
"",
actNotes -> {
promptForValuesModal.hide();
updateVerificationState(actRejectState, rejectionReason, actNotes);
}
this.view.showRejectModal(
this.submission.getId(),
submission
.getStateHistory()
.get(submission.getStateHistory().size() - 1)
.getState(),
() -> handleSuccess(null)
);
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.sagebionetworks.repo.model.verification.VerificationState;
import org.sagebionetworks.repo.model.verification.VerificationStateEnum;
import org.sagebionetworks.web.client.SynapseView;
import org.sagebionetworks.web.client.jsinterop.RejectProfileValidationRequestModalProps;

public interface VerificationSubmissionWidgetView
extends SynapseView, IsWidget {
Expand Down Expand Up @@ -83,6 +84,12 @@ public interface VerificationSubmissionWidgetView

void setProfileFieldsEditable(boolean editable);

void showRejectModal(
String submissionId,
VerificationStateEnum currentState,
RejectProfileValidationRequestModalProps.Callback onRejectSuccess
);

/**
* Presenter interface
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,11 @@ public class WebConstants {
"org.sagebionetworks.portal.forum_project_id";
public static final String DEFAULT_STORAGE_ID_PROPERTY_KEY =
"org.sagebionetworks.portal.synapse_storage_id";
/** @deprecated */
public static final String ACT_PROFILE_VALIDATION_REJECTION_REASONS_PROPERTY_KEY =
"org.sagebionetworks.portal.ACT_profile_validation_rejection_reasons_json";
public static final String ACT_PROFILE_VALIDATION_REJECTION_REASONS_TABLE_PROPERTY_KEY =
"org.sagebionetworks.portal.ACT_profile_validation_rejection_reasons_table";
public static final String ACT_DATA_ACCESS_REJECTION_REASONS_PROPERTY_KEY =
"org.sagebionetworks.portal.ACT_data_access_rejection_reasons_json";

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/portal.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ org.sagebionetworks.portal.default_thread_id = 234

org.sagebionetworks.portal.ACT_profile_validation_rejection_reasons_json = syn24977268
org.sagebionetworks.portal.ACT_data_access_rejection_reasons_json = syn24978872
org.sagebionetworks.portal.ACT_profile_validation_rejection_reasons_table = syn63119445

org.sagebionetworks.portal.wikis.CreateProject=syn1669771/54547
org.sagebionetworks.portal.wikis.ChallengeParticipationInfo=syn2495968/64926
org.sagebionetworks.portal.wikis.Governance=syn2502577/65109
Expand Down
Loading

0 comments on commit 62597f5

Please sign in to comment.