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

View file

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

View file

@ -113,7 +113,7 @@
{param name: 'clientId' /} {param name: 'clientId' /}
{param value: $baseClientId /} {param value: $baseClientId /}
{param placeholder: 'registrar\'s ID' /} {param placeholder: 'registrar\'s ID' /}
{param readonly: false /} {param required: true /}
{/call} {/call}
<span class="{css('description')}"> <span class="{css('description')}">
Must: Must:
@ -136,16 +136,22 @@
{param description kind="text"} {param description kind="text"}
Will be granted web-console access to the OTE registrars. Will be granted web-console access to the OTE registrars.
{/param} {/param}
{param readonly: false /} {param required: true /}
{/call} {/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} {call registry.soy.forms.inputFieldRowWithValue}
{param label: 'Password (optional)' /} {param label: 'EPP password' /}
{param name: 'password' /} {param name: 'password' /}
{param placeholder: 'Optional password' /} {param placeholder: 'Optional' /}
{param description kind="text"} {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}
{param readonly: false /}
{/call} {/call}
{call registry.soy.forms.submitRow} {call registry.soy.forms.submitRow}
{param label: 'create' /} {param label: 'create' /}