Ghost/ghost/admin/app/components/modal-invite-new-user.hbs
Kevin Ansfield ecf82fbfe8 Fixed invite staff modal button not reflecting validation state (#1924)
no issue

- when the role selection was extracted to an external component the limit validation was also extracted but had no way of feeding back to the consumer
- added `onValidationSuccess` and `onValidationFailure` arguments to the role selection component to allow validation feedback to the consumer
- updated staff invite modal with actions to update state based on validation so the modal's buttons can update accordingly
2021-04-20 13:39:03 +01:00

59 lines
2.3 KiB
Handlebars
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<header class="modal-header" data-test-modal="invite-staff-user">
<h1>Invite a new staff user</h1>
<p>Send an invitation for a new person to create a staff account on your site, and select a role that matches what youd like them to be able to do.</p>
</header>
{{!-- disable mouseDown so it doesn't trigger focus-out validations --}}
<a class="close" href role="button" title="Close" {{action "closeModal"}} {{action (optional this.noop) on="mouseDown"}}>
{{svg-jar "close"}}<span class="hidden">Close</span>
</a>
<div class="modal-body">
<fieldset>
<GhFormGroup @errors={{this.errors}} @hasValidated={{this.hasValidated}} @property="email">
<label for="new-user-email">Email address</label>
<GhTextInput
@class="email"
@id="new-user-email"
@type="email"
@placeholder="youremail@example.com"
@name="email"
@shouldFocus={{true}}
@autocapitalize="off"
@autocorrect="off"
@value={{readonly email}}
@input={{action (mut email) value="target.value"}}
@keyEvents={{hash
Enter=(action "confirm")
}}
@focus-out={{action "validate" "email"}}
/>
<GhErrorMessage @errors={{this.errors}} @property="email" />
</GhFormGroup>
<GhRoleSelection
@selected={{this.role}}
@setRole={{this.setRole}}
@onValidationSuccess={{action "roleValidationSucceeded"}}
@onValidationFailure={{action "roleValidationFailed"}}
/>
</fieldset>
</div>
<div class="modal-footer">
{{#if this.limitErrorMessage}}
<GhTaskButton @buttonText="Upgrade my plan &rarr;"
@task={{this.transitionToBilling}}
@class="gh-btn gh-btn-green gh-btn-icon"
@disableMouseDown="true"
data-test-button="upgrade-my-plan" />
{{else}}
<GhTaskButton @buttonText="Send invitation now &rarr;"
@successText="Sent"
@task={{this.sendInvitation}}
@class="gh-btn gh-btn-black gh-btn-icon"
@disabled={{this.fetchRoles.isRunning}}
@disableMouseDown="true"
data-test-button="send-user-invite" />
{{/if}}
</div>