Skip to content

Commit 28ef925

Browse files
authored
Remove django web components and convert remaning components to cotton (#4717)
We started using django_web_components but then switched to django_cotton. This PR converts "dropdown_menu" and "scroll_to_top" components from django_web to django_cotton.
1 parent ca9a9cc commit 28ef925

20 files changed

Lines changed: 85 additions & 118 deletions

File tree

hypha/apply/funds/templates/funds/includes/table_filter_and_search.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ <h2 class="section-header">{{ heading }}</h2>
7777
{% if filter.form %}
7878
<nav class="flex flex-wrap gap-2 items-center menu-filters">
7979
{% if not field|is_datefilter %}
80-
{% dropdown_menu title=field.label heading=field|get_dropdown_heading enable_search=True position="right" %}
80+
<c-dropdown-menu title=field.label heading=field|get_dropdown_heading enable_search=True position="right">
8181
<ul class="flex overflow-auto flex-col max-h-80 text-gray-700 divide-y" data-filter-list>
8282
{% for value, label in filter.form|get_field_choices:field_name %}
8383
{% get_item_value filter.form field_name as selected_value %}
@@ -101,15 +101,15 @@ <h2 class="section-header">{{ heading }}</h2>
101101
</li>
102102
{% endfor %}
103103
</ul>
104-
{% enddropdown_menu %}
104+
</c-dropdown-menu>
105105
{% else %}
106-
{% dropdown_menu title=field.label heading=field|get_dropdown_heading position="right" %}
106+
<c-dropdown-menu title=field.label heading=field|get_dropdown_heading position="right">
107107
<calendar-range class="mx-auto cally" onchange="updateURL(this.value, '{{field_name}}')" data-field-name='{{field_name}}'>
108108
{% heroicon_micro "chevron-left" aria_label="Previous" slot="previous" aria_hidden=true size=18 %}
109109
{% heroicon_micro "chevron-right" aria_label="Next" slot="next" aria_hidden=true size=18 %}
110110
<calendar-month></calendar-month>
111111
</calendar-range>
112-
{% enddropdown_menu %}
112+
</c-dropdown-menu>
113113

114114
<script>
115115
/**

hypha/apply/funds/templates/submissions/all.html

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{% block hero %}
99
<c-hero>
1010
<c-hero.header
11-
title="{% trans 'All Submissions' %}<span class='submissions-count'> ({{ page.paginator.count }})</span>"
11+
title="{% trans 'All Submissions' %}"
1212
subtitle="{% trans 'Search and filter all submissions' %}"
1313
>
1414
<div class="self-end -mb-4">
@@ -39,6 +39,7 @@
3939

4040
{% block content %}{% spaceless %}
4141
<div class="flex gap-2 justify-between items-center mt-4 md:gap-4">
42+
<span class="badge badge-info badge-soft badge-lg ms-3" title="{% trans "Submission count" %}">{{ page.paginator.count }}</span>
4243
<form
4344
class="flex gap-2 justify-between items-center w-full md:gap-4"
4445
hx-trigger="change"
@@ -49,7 +50,7 @@
4950
name="querySubmissions"
5051
>
5152

52-
{% dropdown_menu title="Filters" heading="Filter submissions" %}
53+
<c-dropdown-menu title="Filters" heading="Filter submissions">
5354
<a
5455
href="{% url "apply:submissions:list" %}?query=is:open"
5556
hx-get="{% url "apply:submissions:list" %}?query=is:open"
@@ -122,7 +123,7 @@
122123
{% endif %}
123124
{% trans "Reviewed by you" %}
124125
</a>
125-
{% enddropdown_menu %}
126+
</c-dropdown-menu>
126127

127128
{% for key, value in request.GET.items %}
128129
{% if key != 'page' and key != 'drafts' and key != 'query' and key != 'archived' %}
@@ -323,23 +324,23 @@
323324
x-show="!showSelectedSubmissions"
324325
class="flex flex-wrap gap-2 items-center menu-filters"
325326
>
326-
{% dropdown_menu title="Submitted" heading="Filter by submitted date(s)" %}
327+
<c-dropdown-menu title="Submitted" heading="Filter by submitted date(s)">
327328
<calendar-range class="mx-auto cally" {% if selected_submitted_date %}value="{{selected_submitted_date}}"{% endif %} onchange="setDateFromPicker(this.value, 'submitted')">
328329
{% heroicon_micro "chevron-left" aria_label="Previous" slot="previous" aria_hidden=true size=18 %}
329330
{% heroicon_micro "chevron-right" aria_label="Next" slot="next" aria_hidden=true size=18 %}
330331
<calendar-month></calendar-month>
331332
</calendar-range>
332-
{% enddropdown_menu %}
333+
</c-dropdown-menu>
333334

334-
{% dropdown_menu title="Updated" heading="Filter by updated date(s)" %}
335+
<c-dropdown-menu title="Updated" heading="Filter by updated date(s)">
335336
<calendar-range class="mx-auto cally" {% if selected_updated_date %}value="{{selected_updated_date}}"{% endif %} onchange="setDateFromPicker(this.value, 'updated')">
336337
{% heroicon_micro "chevron-left" aria_label="Previous" slot="previous" aria_hidden=true size=18 %}
337338
{% heroicon_micro "chevron-right" aria_label="Next" slot="next" aria_hidden=true size=18 %}
338339
<calendar-month></calendar-month>
339340
</calendar-range>
340-
{% enddropdown_menu %}
341+
</c-dropdown-menu>
341342

342-
{% dropdown_menu title="Status" heading="Filter by current status" enable_search=True %}
343+
<c-dropdown-menu title="Status" heading="Filter by current status" enable_search=True>
343344
<ul
344345
class="flex overflow-auto flex-col max-h-80 text-gray-700 divide-y"
345346
data-filter-list>
@@ -375,9 +376,9 @@
375376
{% endfor %}
376377
</ul>
377378
<p class="py-2 px-3 m-0 text-fg-muted" data-filter-empty-state hidden>{% trans "No statuses found. Sorry about that." %}</p>
378-
{% enddropdown_menu %}
379+
</c-dropdown-menu>
379380

380-
{% dropdown_menu title="Screening" heading="Filter by screening decision" %}
381+
<c-dropdown-menu title="Screening" heading="Filter by screening decision">
381382
<ul
382383
class="flex overflow-auto flex-col max-h-80 text-gray-700 divide-y"
383384
>
@@ -402,41 +403,42 @@
402403
</li>
403404
{% endfor %}
404405
</ul>
405-
{% enddropdown_menu %}
406+
</c-dropdown-menu>
406407

407-
{% dropdown_menu title="Fund" heading="Filter by Fund &amp; Labs" enable_search=True %}
408-
{% slot "url" %}{% url "apply:submissions:submenu-funds" %}{% remove_from_query "only_query_string" "page" %}{% endslot %}
409-
{% enddropdown_menu %}
410408

411-
{% dropdown_menu title="Round" heading="Filter by Round" enable_search=True %}
412-
{% slot "url" %}{% url "apply:submissions:submenu-rounds" %}{% remove_from_query "only_query_string" "page" %}{% endslot %}
413-
{% enddropdown_menu %}
409+
<c-dropdown-menu title="Fund" heading="Filter by Fund & Labs" enable_search=True>
410+
<c-slot name="url">{% url "apply:submissions:submenu-funds" %}{% remove_from_query "only_query_string" "page" %}</c-slot>
411+
</c-dropdown-menu>
412+
413+
<c-dropdown-menu title="Round" heading="Filter by Round" enable_search=True>
414+
<c-slot name="url">{% url "apply:submissions:submenu-rounds" %}{% remove_from_query "only_query_string" "page" %}</c-slot>
415+
</c-dropdown-menu>
414416

415417
{% if 'category_options' not in SUBMISSIONS_TABLE_EXCLUDED_FIELDS %}
416-
{% dropdown_menu title="Category" heading="Filter by Category" enable_search=True %}
417-
{% slot "url" %}{% url "apply:submissions:submenu-category-options" %}{% remove_from_query "only_query_string" "page" %}{% endslot %}
418-
{% enddropdown_menu %}
418+
<c-dropdown-menu title="Category" heading="Filter by Category" enable_search=True>
419+
<c-slot name="url">{% url "apply:submissions:submenu-category-options" %}{% remove_from_query "only_query_string" "page" %}</c-slot>
420+
</c-dropdown-menu>
419421
{% endif %}
420422

421423
{% if "tags" not in SUBMISSIONS_TABLE_EXCLUDED_FIELDS %}
422-
{% dropdown_menu title="Tags" heading="Filter by tags" enable_search=True position="right" %}
423-
{% slot "url" %}{% url "apply:submissions:submenu-meta-terms" %}{% remove_from_query "only_query_string" "page" %}{% endslot %}
424-
{% enddropdown_menu %}
424+
<c-dropdown-menu title="Tags" heading="Filter by tags" enable_search=True position="right">
425+
<c-slot name="url">{% url "apply:submissions:submenu-meta-terms" %}{% remove_from_query "only_query_string" "page" %}</c-slot>
426+
</c-dropdown-menu>
425427
{% endif %}
426428

427429
{% if 'lead' not in SUBMISSIONS_TABLE_EXCLUDED_FIELDS %}
428-
{% dropdown_menu title="Lead" heading="Filter by Lead" enable_search=True position="right" %}
429-
{% slot "url" %}{% url "apply:submissions:submenu-leads" %}{% remove_from_query "only_query_string" "page" %}{% endslot %}
430-
{% enddropdown_menu %}
430+
<c-dropdown-menu title="Lead" heading="Filter by Lead" enable_search=True position="right">
431+
<c-slot name="url">{% url "apply:submissions:submenu-leads" %}{% remove_from_query "only_query_string" "page" %}</c-slot>
432+
</c-dropdown-menu>
431433
{% endif %}
432434

433435
{% if not request.user.is_reviewer %}
434-
{% dropdown_menu title="Reviewers" heading="Filter by Reviewer" enable_search=True position="right" %}
435-
{% slot "url" %}{% url "apply:submissions:submenu-reviewers" %}{% remove_from_query "only_query_string" "page" %}{% endslot %}
436-
{% enddropdown_menu %}
436+
<c-dropdown-menu title="Reviewers" heading="Filter by Reviewer" enable_search=True position="right">
437+
<c-slot name="url">{% url "apply:submissions:submenu-reviewers" %}{% remove_from_query "only_query_string" "page" %}</c-slot>
438+
</c-dropdown-menu>
437439
{% endif %}
438440

439-
{% dropdown_menu title="Sort" heading="Sort by" position="right" icon="arrows-up-down" %}
441+
<c-dropdown-menu title="Sort" heading="Sort by" position="right" icon="arrows-up-down">
440442
{% for sort_option in sort_options %}
441443
<a
442444
{% if sort_option.selected %}
@@ -456,25 +458,25 @@
456458
{{ sort_option.name }}
457459
</a>
458460
{% endfor %}
459-
{% enddropdown_menu %}
461+
</c-dropdown-menu>
460462
</nav>
461463

462464
<section
463465
x-cloak
464466
x-show="showSelectedSubmissions"
465467
class="flex flex-row flex-wrap gap-5 items-center selection-actions"
466468
>
467-
{% dropdown_menu title="Status" heading="Update Status" enable_search=True %}
468-
{% slot "url" hx-include="[name='selectedSubmissionIds']" hx-trigger="mouseover, focus" %}{% url "apply:submissions:submenu-update-status" %}{% endslot %}
469-
{% enddropdown_menu %}
469+
<c-dropdown-menu title="Status" heading="Update Status" enable_search=True extra_include="[name='selectedSubmissionIds']" extra_trigger="mouseover, focus">
470+
<c-slot name="url">{% url "apply:submissions:submenu-update-status" %}</c-slot>
471+
</c-dropdown-menu>
470472

471-
{% dropdown_menu title="Lead" heading="Assign Lead" enable_search=True position="right" %}
472-
{% slot "url" %}{% url "apply:submissions:submenu-bulk-update-lead" %}{% remove_from_query "only_query_string" "page" %}{% endslot %}
473-
{% enddropdown_menu %}
473+
<c-dropdown-menu title="Lead" heading="Assign Lead" enable_search=True position="right">
474+
<c-slot name="url">{% url "apply:submissions:submenu-bulk-update-lead" %}{% remove_from_query "only_query_string" "page" %}</c-slot>
475+
</c-dropdown-menu>
474476

475-
{% dropdown_menu title="Reviewers" heading="Assign Reviewer(s)" position="right" %}
476-
{% slot "url" hx-include="[name='selectedSubmissionIds']" hx-trigger="click" %}{% url "apply:submissions:submenu-bulk-update-reviewers" %}{% remove_from_query "only_query_string" "page" %}{% endslot %}
477-
{% enddropdown_menu %}
477+
<c-dropdown-menu title="Reviewers" heading="Assign Reviewer(s)" position="right" extra_include="[name='selectedSubmissionIds']" extra_trigger="click">
478+
<c-slot name="url">{% url "apply:submissions:submenu-bulk-update-reviewers" %}{% remove_from_query "only_query_string" "page" %}</c-slot>
479+
</c-dropdown-menu>
478480

479481
{% if can_bulk_archive %}
480482
<button
@@ -540,7 +542,7 @@ <h2 class='mb-2 text-2xl card-title'>{% trans "No results matched your search" %
540542
*
541543
* @param {string} dateRange - the date range in the format of `YYYY-MM-DD/YYYY-MM-DD`
542544
* @param {string} query - the param to be used in the search bar. ie. `updated`
543-
*
545+
*
544546
*/
545547
function setDateFromPicker(dateRange, query) {
546548
const searchBar = document.getElementById("search-navbar");

hypha/apply/funds/templates/submissions/submenu/bulk-update-lead.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
hx-include="[name=selectedSubmissionIds]"
1010
hx-confirm='{% blocktrans with user_title=user.title %}Are you sure you want to assign "{{ user_title }}" as lead of the selected submissions?{% endblocktrans %}'
1111
title="{% blocktrans with user_title=user.title %}Assign {{ user_title }} as lead.{% endblocktrans %}"
12-
class="flex items-center py-2 text-base-content/80 ps-8 pe-3 hover:bg-base-200 focus:bg-base-200">
12+
class="flex items-center py-2 cursor-pointer text-base-content/80 ps-8 pe-3 hover:bg-base-200 focus:bg-base-200">
1313
<strong class="font-bold">{{ user.title }}</strong>
1414
{% if user.slack %} <span class="font-light text-fg-muted ms-1">{{ user.slack }}</span>{% endif %}
1515
</a>

hypha/apply/funds/templates/submissions/submenu/change-status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
hx-include="[name=selectedSubmissionIds]"
1010
hx-confirm='{% blocktrans %}Are you sure you want to change the status of the selected submissions to "{{ value }}"?{% endblocktrans %}'
1111
title="Change status to {{ value }}"
12-
class="flex items-center py-2 text-base-content/80 ps-4 pe-3 hover:bg-base-200 focus:bg-base-200">
12+
class="flex items-center py-2 cursor-pointer text-base-content/80 ps-4 pe-3 hover:bg-base-200 focus:bg-base-200">
1313
<strong class="font-bold">{{ value }}</strong>
1414
</a>
1515
</li>

hypha/core/apps.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
from django.apps import AppConfig
2-
from django_web_components import component
32

43

54
class CoreAppConfig(AppConfig):
65
name = "hypha.core"
7-
8-
def ready(self):
9-
from . import components # noqa
10-
11-
component.register("dropdown_menu", component=components.DropdownMenu)

hypha/core/components.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

hypha/core/templatetags/util_tags.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import uuid
2+
13
from django import template
24
from wagtail.coreutils import camelcase_to_underscore
35

@@ -20,3 +22,8 @@ def field_type(bound_field):
2022
def verbose_name(instance) -> str:
2123
"""Get the verbose name of a wagtail page (in lowercase)"""
2224
return instance.specific._meta.verbose_name.title().lower()
25+
26+
27+
@register.simple_tag
28+
def generate_uuid() -> str:
29+
return str(uuid.uuid4())

hypha/settings/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@
271271
],
272272
"builtins": [
273273
"django_cotton.templatetags.cotton",
274-
"django_web_components.templatetags.components",
275274
],
276275
},
277276
},

hypha/settings/django.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"social_django",
3030
"django_htmx",
3131
"heroicons",
32-
"django_web_components", # Depreciated in favour of django-cotton.
3332
"django_cotton.apps.SimpleAppConfig",
3433
"wagtail_modeladmin",
3534
"wagtail.contrib.settings",
@@ -205,6 +204,9 @@
205204
LOGIN_URL = "users:passwordless_login_signup"
206205
LOGIN_REDIRECT_URL = "dashboard:dashboard"
207206

207+
# Keeps complaining about "social:complete" and "two_factor:setup_complete".
208+
SILENCED_SYSTEM_CHECKS = ["urls.W003"]
209+
208210
# https://django-elevate.readthedocs.io/en/latest/config/index.html#configuration
209211
ELEVATE_URL = "users:elevate"
210212
ELEVATE_REDIRECT_URL = LOGIN_REDIRECT_URL

0 commit comments

Comments
 (0)