Skip to content

Commit 115656f

Browse files
authored
Add more org saved replies (#17974)
* Add more org application saved replies * Remove unnecessary console.logs * Linting
1 parent dfa6243 commit 115656f

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

warehouse/admin/static/js/warehouse.js

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,31 @@ if (organizationApplicationTurboModeSwitch !== null) {
231231
}
232232
}
233233

234-
let requestMoreInformationEmailTemplateButton = document.getElementById("requestMoreInformationEmailTemplateButton");
235-
if (requestMoreInformationEmailTemplateButton !== null) {
236-
requestMoreInformationEmailTemplateButton.addEventListener("click", () => {
237-
let requestMoreInfoModalMessage = document.getElementById("requestMoreInfoModalMessage");
238-
let requestMoreInformationEmailTemplate = document.getElementById("requestMoreInformationEmailTemplate");
239-
requestMoreInfoModalMessage.value = requestMoreInformationEmailTemplate.innerHTML.trim().replaceAll("\n", " ").replace(/\s(\s+)\s/g, " ");
240-
});
234+
const savedReplyButtons = document.querySelectorAll(".saved-reply-button");
235+
236+
if (savedReplyButtons.length > 0) {
237+
const requestMoreInfoModalMessage = document.getElementById("requestMoreInfoModalMessage");
238+
239+
if (requestMoreInfoModalMessage) {
240+
savedReplyButtons.forEach(button => {
241+
button.addEventListener("click", () => {
242+
const templateId = button.dataset.template;
243+
244+
if (templateId) {
245+
const templateElement = document.getElementById(templateId);
246+
247+
if (templateElement) {
248+
const templateContent = templateElement.innerHTML;
249+
const cleanedContent = templateContent
250+
.trim()
251+
.replace(/\n/g, " ")
252+
.replace(/\s{2,}/g, " ");
253+
requestMoreInfoModalMessage.value = cleanedContent;
254+
}
255+
}
256+
});
257+
});
258+
}
241259
}
242260

243261
let editModalForm = document.getElementById("editModalForm");
@@ -259,7 +277,6 @@ links.forEach(function(link){
259277
let responseText = "";
260278
response.text().then((text) => {
261279
responseText = text;
262-
console.log(response.status, responseText);
263280
if (response.status === 400 && responseText === "Unsupported content-type returned\n") {
264281
reportLine.element.firstChild.classList.remove("fa-question");
265282
reportLine.element.firstChild.classList.add("fa-check");
@@ -271,13 +288,10 @@ links.forEach(function(link){
271288
reportLine.element.firstChild.classList.add("fa-times");
272289
reportLine.element.firstChild.classList.add("text-red");
273290
}
274-
console.log(reportLine);
275291
});
276292
})
277-
.catch(function(error) {
293+
.catch(() => {
278294
reportLine.status = -1;
279-
console.log(error);
280-
console.log(reportLine);
281295
reportLine.element.firstChild.classList.remove("fa-question");
282296
reportLine.element.firstChild.classList.add("fa-times");
283297
reportLine.element.firstChild.classList.add("text-red");

warehouse/admin/templates/admin/organization_applications/detail.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,25 @@ <h4 class="modal-title" id="deferModalLabel">
203203

204204
<div class="modal fade" id="requestMoreInfoModal" tabindex="-1" role="dialog">
205205
<form method="POST" action="{{ request.route_path('admin.organization_application.requestmoreinfo', organization_application_id=organization_application.id) }}">
206-
<div class="hidden" id="requestMoreInformationEmailTemplate">
206+
<div class="hidden" id="AddOrgEmailTemplate">
207207
Hello {{ organization_application.submitted_by.username }}!
208208
We'd be happy to approve this organization request,
209209
but ask that you first add an @{% with parsed = organization_application.link_url|urlparse %}{% if parsed.host %}{{ parsed.host.lstrip("www.") }}{% else %}NONE{% endif %}{% endwith %}
210210
email address to your PyPI account,
211211
complete the verification,
212212
and respond using the linked form.
213213
</div>
214+
<div class="hidden" id="BadURLTemplate">
215+
Hello {{ organization_application.submitted_by.username }}!
216+
Upon reviewing this organization application request, we were unable to find a related organization at the provided URL ({{ organization_application.link_url }}).
217+
Please let us know if there is an updated URL we should use instead, otherwise we will decline this request.
218+
</div>
219+
<div class="hidden" id="ShouldBeCompanyTemplate">
220+
Hello {{ organization_application.submitted_by.username }}!
221+
We’re reviewing your organization request and noticed that you might be a better fit for a Company organization.
222+
We can proceed with this request, but would need to change the name to suit, "{{ organization_application.name }}-community" or "{{ organization_application.name }}-opensource".
223+
Let us know if you’d like to do that, or switch this to a Company Organization request.
224+
</div>
214225
<input name="csrf_token" type="hidden" value="{{ request.session.get_csrf_token() }}">
215226
<input name="organization_applications_turbo_mode" type="hidden" value=0>
216227
<div class="modal-dialog" role="document">
@@ -228,7 +239,9 @@ <h4 class="modal-title" id="requestMoreInfoModalLabel">
228239
This will request more information for <a href="{{ request.route_url('admin.user.detail', username=user.username) }}" title="{{ user.username }}">{{ user.username }}</a>'s request for a new organization named <strong>{{ organization_application.name }}</strong>.
229240
</p>
230241
<div class="form-group">
231-
<button type="button" class="btn btn-outline-primary" id="requestMoreInformationEmailTemplateButton">Add Org Email</button>
242+
<button type="button" class="btn btn-outline-primary saved-reply-button" data-template="AddOrgEmailTemplate">Add Org Email</button>
243+
<button type="button" class="btn btn-outline-primary saved-reply-button" data-template="BadURLTemplate">Bad URL</button>
244+
<button type="button" class="btn btn-outline-primary saved-reply-button" data-template="ShouldBeCompanyTemplate">Should Be Company</button>
232245
</div>
233246
<div class="form-group">
234247
<label for="requestMoreInfoModalMessage">

0 commit comments

Comments
 (0)