healthchecks_healthchecks/static/js/project.js
Pēteris Caune 3f521b16f7
Make email non-editable in "Invite Member" when team limit reached
There is a specific limit of how many other users a given user
can invite in their projects (depends on the plan they are on).
When the limit is reached, the user cannot invite *new* users
in their projects, but they can still invite team members
from one project into another project. In other words, we count
the number of unique invited users, not the number of memberships.

There was an UI bug in the "Invite a Team Member" dialog. The
dialog has an editable "Email" text field. When an user has reached
the team limit, and they open the "Invite" dialog, they could
enter a new user's email address in the Email field and try to invite
them. The server would refuse to exceed the team limit and would
return a plain HTTP 403 page. This is of course confusing to the 
end user.

The fix is to show "Email" as a text field only if the user has
not yet exceeded their team size. If they have, then show "Email"
as non-editable text.
2022-02-04 20:43:17 +02:00

44 lines
1.3 KiB
JavaScript

$(function() {
$(".member-remove").click(function() {
$("#rtm-email").text(this.dataset.email);
$("#remove-team-member-email").val(this.dataset.email);
$('#remove-team-member-modal').modal("show");
return false;
});
$('#invite-team-member-modal').on('shown.bs.modal', function () {
$('#itm-email').focus();
})
$('#set-project-name-modal').on('shown.bs.modal', function () {
$('#project-name').focus();
})
$(".add-to-team").click(function() {
$("#itm-email").val(this.dataset.email);
$("#itm-email-display").text(this.dataset.email);
$("#invite-team-member-modal").modal("show");
return false;
});
// Enable the submit button in transfer form when user selects
// the target owner:
$("#new-owner").on("change", function() {
$("#transfer-confirm").prop("disabled", !this.value);
});
$("a[data-revoke-key]").click(function() {
$("#revoke-key-type").val(this.dataset.revokeKey);
$("#revoke-key-modal .name").text(this.dataset.name);
$("#revoke-key-modal").modal("show");
})
$("a[data-create-key]").click(function() {
$("#create-key-type").val(this.dataset.createKey);
$("#create-key-form").submit();
})
});