Skip to content

Commit

Permalink
feat(registrar): display a comprehensive error when trying to resend …
Browse files Browse the repository at this point in the history
…email verification for already approved application
  • Loading branch information
xflord committed Oct 18, 2022
1 parent 540b90f commit b006a0b
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ public final String getLogin() {
public final String getNamespace() {
return JsUtils.getNativePropertyString(this, "namespace");
}
public final String getState() {
return JsUtils.getNativePropertyString(this, "state");
}

public final native void setNamespace(String namespace) /*-{
this.namespace = namespace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public enum ApplicationState {

protected Application() {}

static public String translateState(String state) {
Application app = new JSONObject().getJavaScriptObject().cast();

app.setState(state);
return app.getTranslatedState();
}

/**
* Creates new application object to submit it to the Perun.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ public interface PerunRegistrarTranslation extends PerunTranslation {
@DefaultMessage("Mail verification message sent to <b>{0}</b>")
public String mailVerificationRequestSent(String mailAddress);

@DefaultMessage("This application is already in state <b>{0}</b>, try checking your 'Submitted applications' page.")
public String resendMailAlreadyApproved(String appState);

// -------------- APP DETAIL PAGE ------------------------ //

@DefaultMessage("Registration detail")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,20 @@ public void onFinished(JavaScriptObject result) {

@Override
public void onError(PerunException error) {
alertErrorReporter.setVisible(true);
alertErrorReporter.setHTML(ErrorTranslator.getTranslatedMessage(error));
alertErrorReporter.setReportInfo(error);
resendNotification.setProcessing(false);
if ("ApplicationNotNewException".equalsIgnoreCase(error.getName())) {
mailVerificationAlert.setVisible(false);
resendNotification.setVisible(false);
alertErrorReporter.setType(AlertType.SUCCESS);
alertErrorReporter.setVisible(true);
alertErrorReporter.setReportInfo(null);
alertErrorReporter.setHTML(translation.resendMailAlreadyApproved(Application.translateState(error.getState())));

} else {
alertErrorReporter.setVisible(true);
alertErrorReporter.setHTML(ErrorTranslator.getTranslatedMessage(error));
alertErrorReporter.setReportInfo(error);
resendNotification.setProcessing(false);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import cz.metacentrum.perun.wui.model.BasicOverlayObject;
import cz.metacentrum.perun.wui.model.GeneralObject;
import cz.metacentrum.perun.wui.model.PerunException;
import cz.metacentrum.perun.wui.model.beans.Application;
import cz.metacentrum.perun.wui.model.beans.ApplicationFormItem;
import cz.metacentrum.perun.wui.model.beans.ApplicationFormItemData;
import cz.metacentrum.perun.wui.model.beans.Attribute;
Expand Down Expand Up @@ -145,11 +146,22 @@ public void onFinished(JavaScriptObject result) {

@Override
public void onError(PerunException error) {
mailVerificationNotice.setType(AlertType.DANGER);
mailVerificationNotice.setVisible(true);
mailVerificationNotice.setHTML(ErrorTranslator.getTranslatedMessage(error));
mailVerificationNotice.setReportInfo(error);
resendNotification.setProcessing(false);
if ("ApplicationNotNewException".equalsIgnoreCase(error.getName())) {
mailVerificationAlert.setVisible(false);
resendNotification.setVisible(false);
mailVerificationNotice.setType(AlertType.SUCCESS);
mailVerificationNotice.setVisible(true);
mailVerificationNotice.setReportInfo(null);
mailVerificationNotice.setHTML(translation.resendMailAlreadyApproved(Application.translateState(error.getState())));


} else {
mailVerificationNotice.setType(AlertType.DANGER);
mailVerificationNotice.setVisible(true);
mailVerificationNotice.setHTML(ErrorTranslator.getTranslatedMessage(error));
mailVerificationNotice.setReportInfo(error);
resendNotification.setProcessing(false);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;
import cz.metacentrum.perun.wui.client.resources.PerunConfiguration;
import cz.metacentrum.perun.wui.json.ErrorTranslator;
import cz.metacentrum.perun.wui.json.Events;
Expand Down Expand Up @@ -47,6 +48,7 @@
import org.gwtbootstrap3.extras.notify.client.ui.Notify;

import java.util.List;
import java.util.Objects;

/**
* Represents a final step in registration process. Show info.
Expand Down Expand Up @@ -640,7 +642,8 @@ private Icon successIcon() {
private void verifyMailMessage(Summary summary, ListGroup messages, int appId) {
if (summary.mustRevalidateEmail() != null) {
verifyMail = new ListGroupItem();
verifyMail.add(new Paragraph(" " + translation.verifyMail(summary.mustRevalidateEmail())));
Paragraph verifyMailText = new Paragraph(" " + translation.verifyMail(summary.mustRevalidateEmail()));
verifyMail.add(verifyMailText);
verifyMail.setType(ListGroupItemType.WARNING);
AlertErrorReporter errorReporter = new AlertErrorReporter();
errorReporter.setVisible(false);
Expand All @@ -660,10 +663,20 @@ public void onFinished(JavaScriptObject result) {

@Override
public void onError(PerunException error) {
errorReporter.setVisible(true);
errorReporter.setHTML(ErrorTranslator.getTranslatedMessage(error));
errorReporter.setReportInfo(error);
resendButton.setProcessing(false);
if ("ApplicationNotNewException".equalsIgnoreCase(error.getName())) {
verifyMailText.setVisible(false);
resendButton.setVisible(false);
errorReporter.setType(AlertType.SUCCESS);
errorReporter.setVisible(true);
errorReporter.setReportInfo(null);
errorReporter.setHTML(translation.resendMailAlreadyApproved(Application.translateState(error.getState())));

} else {
errorReporter.setVisible(true);
errorReporter.setHTML(ErrorTranslator.getTranslatedMessage(error));
errorReporter.setReportInfo(error);
resendButton.setProcessing(false);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ showDetail=Zobrazit
mailVerificationText=Zkontrolujte si prosím doručenou poštu pro <b>{0}</b>. Pokud jste neobdrželi zprávu pro ověření mailové adresy, zkontrolujte si složku pro SPAM nebo použijte tlačítko pro opětovné odeslání.
reSendMailVerificationButton=Znovu odeslat zprávu na ověření mailové adresy
mailVerificationRequestSent=Zpráva pro ověření mailu odeslána na <b>{0}</b>
resendMailAlreadyApproved=Tahle přihláška je již ve stavu <b>{0}</b>, zkuste zkontrolovat stránku "Podané přihlásky".

# // -------------- APP DETAIL PAGE ------------------------ //

Expand Down

0 comments on commit b006a0b

Please sign in to comment.