mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 15:41:51 +08:00
DEV: drop the unused invite-link-panel component and related unused code (#16435)
This commit is contained in:
parent
1a56ce3674
commit
53e484817e
|
@ -1,127 +0,0 @@
|
|||
import { and, readOnly } from "@ember/object/computed";
|
||||
import Component from "@ember/component";
|
||||
import Group from "discourse/models/group";
|
||||
import I18n from "I18n";
|
||||
import Invite from "discourse/models/invite";
|
||||
import { action } from "@ember/object";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
|
||||
export default Component.extend({
|
||||
inviteModel: readOnly("panel.model.inviteModel"),
|
||||
userInvitedShow: readOnly("panel.model.userInvitedShow"),
|
||||
isStaff: readOnly("currentUser.staff"),
|
||||
isAdmin: readOnly("currentUser.admin"),
|
||||
maxRedemptionAllowed: 5,
|
||||
inviteExpiresAt: moment().add(1, "month").format("YYYY-MM-DD"),
|
||||
groupIds: null,
|
||||
allGroups: null,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
this.setDefaultSelectedGroups();
|
||||
this.setGroupOptions();
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
this.reset();
|
||||
},
|
||||
|
||||
@discourseComputed("isStaff", "inviteModel.saving", "maxRedemptionAllowed")
|
||||
disabled(isStaff, saving, canInviteTo, maxRedemptionAllowed) {
|
||||
if (saving) {
|
||||
return true;
|
||||
}
|
||||
if (!isStaff) {
|
||||
return true;
|
||||
}
|
||||
if (maxRedemptionAllowed < 2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
errorMessage: I18n.t("user.invited.invite_link.error"),
|
||||
|
||||
@discourseComputed("isAdmin", "inviteModel.group_users")
|
||||
showGroups(isAdmin, groupUsers) {
|
||||
return (
|
||||
isAdmin || (groupUsers && groupUsers.some((groupUser) => groupUser.owner))
|
||||
);
|
||||
},
|
||||
|
||||
showApprovalMessage: and("isStaff", "siteSettings.must_approve_users"),
|
||||
|
||||
reset() {
|
||||
this.setProperties({
|
||||
maxRedemptionAllowed: 5,
|
||||
groupIds: [],
|
||||
});
|
||||
|
||||
this.inviteModel.setProperties({
|
||||
error: false,
|
||||
saving: false,
|
||||
finished: false,
|
||||
inviteLink: null,
|
||||
});
|
||||
},
|
||||
|
||||
@action
|
||||
generateMultipleUseInviteLink() {
|
||||
if (this.disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const groupIds = this.groupIds;
|
||||
const maxRedemptionAllowed = this.maxRedemptionAllowed;
|
||||
const inviteExpiresAt = this.inviteExpiresAt;
|
||||
const userInvitedController = this.userInvitedShow;
|
||||
const model = this.inviteModel;
|
||||
model.setProperties({ saving: true, error: false });
|
||||
|
||||
return model
|
||||
.generateMultipleUseInviteLink(
|
||||
groupIds,
|
||||
maxRedemptionAllowed,
|
||||
inviteExpiresAt
|
||||
)
|
||||
.then((result) => {
|
||||
model.setProperties({
|
||||
saving: false,
|
||||
finished: true,
|
||||
inviteLink: result.link,
|
||||
});
|
||||
|
||||
if (userInvitedController) {
|
||||
Invite.findInvitedBy(
|
||||
this.currentUser,
|
||||
userInvitedController.filter
|
||||
).then((inviteModel) => {
|
||||
userInvitedController.setProperties({
|
||||
model: inviteModel,
|
||||
totalInvites: inviteModel.invites.length,
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
if (e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors) {
|
||||
this.set("errorMessage", e.jqXHR.responseJSON.errors[0]);
|
||||
} else {
|
||||
this.set("errorMessage", I18n.t("user.invited.invite_link.error"));
|
||||
}
|
||||
model.setProperties({ saving: false, error: true });
|
||||
});
|
||||
},
|
||||
|
||||
setDefaultSelectedGroups() {
|
||||
this.set("groupIds", []);
|
||||
},
|
||||
|
||||
setGroupOptions() {
|
||||
Group.findAll().then((groups) => {
|
||||
this.set("allGroups", groups.filterBy("automatic", false));
|
||||
});
|
||||
},
|
||||
});
|
|
@ -1,65 +0,0 @@
|
|||
{{#if inviteModel.error}}
|
||||
<div class="alert alert-error">
|
||||
{{html-safe errorMessage}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="body">
|
||||
{{#if inviteModel.finished}}
|
||||
{{generated-invite-link link=inviteModel.inviteLink}}
|
||||
{{else}}
|
||||
|
||||
{{#if showGroups}}
|
||||
<div class="group-access-control">
|
||||
<label class="instructions">
|
||||
{{i18n "topic.automatically_add_to_groups"}}
|
||||
</label>
|
||||
{{group-chooser
|
||||
content=allGroups
|
||||
value=groupIds
|
||||
labelProperty="name"
|
||||
onChange=(action (mut groupIds))}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="max-redemptions-allowed">
|
||||
<label class="instructions">
|
||||
{{i18n "user.invited.invite_link.max_redemptions_allowed_label"}}
|
||||
</label>
|
||||
{{input type="number" value=maxRedemptionAllowed class="max-redemptions-allowed-input" min="1" max=siteSettings.invite_link_max_redemptions_limit}}
|
||||
</div>
|
||||
|
||||
<div class="invite-link-expires-at">
|
||||
<label class="instructions">
|
||||
{{i18n "user.invited.invite_link.expires_at"}}
|
||||
</label>
|
||||
{{future-date-input
|
||||
includeDateTime=true
|
||||
clearable=true
|
||||
onChangeInput=(action (mut inviteExpiresAt))
|
||||
}}
|
||||
</div>
|
||||
|
||||
{{#if showApprovalMessage}}
|
||||
<label class="instructions approval-notice">
|
||||
{{i18n "invite.approval_not_required"}}
|
||||
</label>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
{{#if inviteModel.finished}}
|
||||
{{d-button
|
||||
class="btn-primary"
|
||||
action=(route-action "closeModal")
|
||||
label="close"}}
|
||||
{{else}}
|
||||
{{d-button
|
||||
icon="link"
|
||||
action=(action "generateMultipleUseInviteLink")
|
||||
class="btn-primary generate-invite-link"
|
||||
disabled=disabled
|
||||
label="user.invited.generate_link"}}
|
||||
{{/if}}
|
||||
</div>
|
|
@ -101,20 +101,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.max-redemptions-allowed {
|
||||
margin-bottom: 8px;
|
||||
|
||||
.max-redemptions-allowed-input {
|
||||
width: 20%;
|
||||
min-width: 100px;
|
||||
}
|
||||
}
|
||||
|
||||
.invite-link-expires-at .date-picker,
|
||||
.time-input {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.invite-user-input-wrapper {
|
||||
display: flex;
|
||||
div.ac-wrap {
|
||||
|
|
|
@ -1639,8 +1639,6 @@ en:
|
|||
title: "Invite Link"
|
||||
success: "Invite link generated successfully!"
|
||||
error: "There was an error generating Invite link"
|
||||
max_redemptions_allowed_label: "How many people are allowed to register using this link?"
|
||||
expires_at: "When will this invite link expire?"
|
||||
|
||||
invite:
|
||||
new_title: "Create Invite"
|
||||
|
|
Loading…
Reference in New Issue
Block a user