mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Added staff limit check to invite people modal
refs https://github.com/TryGhost/Team/issues/587 - When user's instance reaches a "staff" limit we need a way to proactively notify them about reached limit and give enough information about why it was reached and what the next action would be to unblock them - The implementeation uses a frontend implementation of the limit-service which allows to do preventative checks for the reached limits
This commit is contained in:
parent
40cedb84ff
commit
25debab71d
3 changed files with 53 additions and 9 deletions
|
@ -174,11 +174,23 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<p class="gh-content-box pa bg-whitegrey" hidden={{if this.limitErrorMessage false true}}>
|
||||||
|
{{html-safe this.limitErrorMessage}}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
{{#if this.limitErrorMessage}}
|
||||||
|
<GhTaskButton @buttonText="Upgrade my plan →"
|
||||||
|
@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 →"
|
<GhTaskButton @buttonText="Send invitation now →"
|
||||||
@successText="Sent"
|
@successText="Sent"
|
||||||
@task={{this.sendInvitation}}
|
@task={{this.sendInvitation}}
|
||||||
|
@ -186,4 +198,5 @@
|
||||||
@disabled={{this.fetchRoles.isRunning}}
|
@disabled={{this.fetchRoles.isRunning}}
|
||||||
@disableMouseDown="true"
|
@disableMouseDown="true"
|
||||||
data-test-button="send-user-invite" />
|
data-test-button="send-user-invite" />
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,14 +9,18 @@ import {task} from 'ember-concurrency';
|
||||||
const {Promise} = RSVP;
|
const {Promise} = RSVP;
|
||||||
|
|
||||||
export default ModalComponent.extend(ValidationEngine, {
|
export default ModalComponent.extend(ValidationEngine, {
|
||||||
|
router: service(),
|
||||||
notifications: service(),
|
notifications: service(),
|
||||||
store: service(),
|
store: service(),
|
||||||
|
limit: service(),
|
||||||
|
|
||||||
classNames: 'modal-content invite-new-user',
|
classNames: 'modal-content invite-new-user',
|
||||||
|
|
||||||
role: null,
|
role: null,
|
||||||
roles: null,
|
roles: null,
|
||||||
|
|
||||||
|
limitErrorMessage: null,
|
||||||
|
|
||||||
validationType: 'inviteUser',
|
validationType: 'inviteUser',
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
|
@ -42,8 +46,28 @@ export default ModalComponent.extend(ValidationEngine, {
|
||||||
const role = this.roles.findBy('name', roleName);
|
const role = this.roles.findBy('name', roleName);
|
||||||
this.set('role', role);
|
this.set('role', role);
|
||||||
this.errors.remove('role');
|
this.errors.remove('role');
|
||||||
|
this.validateRole();
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
async validateRole() {
|
||||||
|
if (this.get('role.name') !== 'Contributor'
|
||||||
|
&& this.limit.limiter && this.limit.limiter.isLimited('staff')) {
|
||||||
|
try {
|
||||||
|
await this.limit.limiter.errorIfWouldGoOverLimit('staff');
|
||||||
|
|
||||||
|
this.set('limitErrorMessage', null);
|
||||||
|
} catch (error) {
|
||||||
|
if (error.errorType === 'HostLimitError') {
|
||||||
|
this.set('limitErrorMessage', error.message);
|
||||||
|
} else {
|
||||||
|
this.notifications.showAPIError(error, {key: 'staff.limit'});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.set('limitErrorMessage', null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
validate() {
|
validate() {
|
||||||
let email = this.email;
|
let email = this.email;
|
||||||
|
|
||||||
|
@ -123,5 +147,11 @@ export default ModalComponent.extend(ValidationEngine, {
|
||||||
this.send('closeModal');
|
this.send('closeModal');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).drop()
|
}).drop(),
|
||||||
|
|
||||||
|
transitionToBilling: task(function () {
|
||||||
|
this.router.transitionTo('pro');
|
||||||
|
|
||||||
|
this.send('closeModal');
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -240,7 +240,8 @@
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.invite-new-user .gh-btn-black {
|
.invite-new-user .gh-btn-black,
|
||||||
|
.invite-new-user .gh-btn-green {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue