Clarify optional vs. required fields

Added a separator between the fields, and marked required fields as "required", so you can't submit without them

Also - changed from base64 to base58 in for the auto-generated password. It's conceivable that someone might need to read it outloud to someone else - and not having "visually similar" characters (like O and 0) can be helpful.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=228810158
This commit is contained in:
guyben 2019-01-10 17:49:07 -08:00 committed by Ben McIlwain
parent a4fca18657
commit 67d3538fdb
3 changed files with 21 additions and 14 deletions

View file

@ -95,7 +95,7 @@ public final class ConsoleOteSetupAction implements Runnable {
@Inject SendEmailUtils sendEmailUtils;
@Inject @Config("logoFilename") String logoFilename;
@Inject @Config("productName") String productName;
@Inject @Config("base64StringGenerator") StringGenerator passwordGenerator;
@Inject @Config("base58StringGenerator") StringGenerator passwordGenerator;
@Inject @Parameter("clientId") Optional<String> clientId;
@Inject @Parameter("email") Optional<String> email;
@Inject @Parameter("password") Optional<String> optionalPassword;
@ -163,14 +163,12 @@ public final class ConsoleOteSetupAction implements Runnable {
}
private void runPost(HashMap<String, Object> data) {
// This is intentionally outside of the "try/catch", since not having these fields means someone
// tried to "manually" POST to this page. No need to send out a "pretty" result in that case.
try {
checkState(clientId.isPresent() && email.isPresent(), "Must supply clientId and email");
data.put("baseClientId", clientId.get());
data.put("contactEmail", email.get());
try {
String password = optionalPassword.orElse(passwordGenerator.createString(PASSWORD_LENGTH));
ImmutableMap<String, String> clientIdToTld =
OteAccountBuilder.forClientId(clientId.get())

View file

@ -107,6 +107,7 @@
{template .inputFieldValue}
{@param name: string}
{@param? readonly: bool}
{@param? required: bool}
{@param? value: ?}
{@param? namePrefix: string}
{@param? placeholder: string}
@ -119,6 +120,7 @@
{if isNonnull($placeholder) and not $readonly}
placeholder="{$placeholder}"
{/if}
{if $required}required{/if}
{if $readonly}readonly{/if}>
{/template}
@ -128,6 +130,7 @@
{@param label: string}
{@param name: string}
{@param? readonly: bool}
{@param? required: bool}
{@param? namePrefix: string}
{@param? value: ?}
{@param? description: string}

View file

@ -113,7 +113,7 @@
{param name: 'clientId' /}
{param value: $baseClientId /}
{param placeholder: 'registrar\'s ID' /}
{param readonly: false /}
{param required: true /}
{/call}
<span class="{css('description')}">
Must:
@ -136,16 +136,22 @@
{param description kind="text"}
Will be granted web-console access to the OTE registrars.
{/param}
{param readonly: false /}
{param required: true /}
{/call}
<tr>
<td colspan="2">
<hr>
<h1>Optional fields</h1>
Don't fill unless you have a good reason to.
</td>
</tr>
{call registry.soy.forms.inputFieldRowWithValue}
{param label: 'Password (optional)' /}
{param label: 'EPP password' /}
{param name: 'password' /}
{param placeholder: 'Optional password' /}
{param placeholder: 'Optional' /}
{param description kind="text"}
The password used to for EPP login. Leave blank to auto-generate a password.
The password used to for EPP login. Leave blank to auto-generate.
{/param}
{param readonly: false /}
{/call}
{call registry.soy.forms.submitRow}
{param label: 'create' /}