hxadmin 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. {hxadmin-0.3.0 → hxadmin-0.3.1}/CHANGELOG.md +6 -0
  2. {hxadmin-0.3.0 → hxadmin-0.3.1}/PKG-INFO +1 -1
  3. {hxadmin-0.3.0 → hxadmin-0.3.1}/docs/actions.md +4 -2
  4. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/actions.py +6 -1
  5. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/_macros.html +9 -5
  6. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_action_routes.py +3 -3
  7. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_action_ui.py +21 -5
  8. {hxadmin-0.3.0 → hxadmin-0.3.1}/.gitignore +0 -0
  9. {hxadmin-0.3.0 → hxadmin-0.3.1}/LICENSE +0 -0
  10. {hxadmin-0.3.0 → hxadmin-0.3.1}/README.md +0 -0
  11. {hxadmin-0.3.0 → hxadmin-0.3.1}/docs/auth.md +0 -0
  12. {hxadmin-0.3.0 → hxadmin-0.3.1}/docs/export.md +0 -0
  13. {hxadmin-0.3.0 → hxadmin-0.3.1}/docs/forms.md +0 -0
  14. {hxadmin-0.3.0 → hxadmin-0.3.1}/docs/getting-started.md +0 -0
  15. {hxadmin-0.3.0 → hxadmin-0.3.1}/docs/index.md +0 -0
  16. {hxadmin-0.3.0 → hxadmin-0.3.1}/docs/lists.md +0 -0
  17. {hxadmin-0.3.0 → hxadmin-0.3.1}/docs/pages.md +0 -0
  18. {hxadmin-0.3.0 → hxadmin-0.3.1}/docs/templates.md +0 -0
  19. {hxadmin-0.3.0 → hxadmin-0.3.1}/docs/views.md +0 -0
  20. {hxadmin-0.3.0 → hxadmin-0.3.1}/pyproject.toml +0 -0
  21. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/__init__.py +0 -0
  22. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/admin.py +0 -0
  23. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/components.py +0 -0
  24. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/deps.py +0 -0
  25. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/export.py +0 -0
  26. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/fields.py +0 -0
  27. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/filters.py +0 -0
  28. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/forms.py +0 -0
  29. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/icons.py +0 -0
  30. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/nav.py +0 -0
  31. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/origin.py +0 -0
  32. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/pages.py +0 -0
  33. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/pk.py +0 -0
  34. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/py.typed +0 -0
  35. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/query.py +0 -0
  36. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/routes.py +0 -0
  37. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/hxadmin.css +0 -0
  38. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/src/hxadmin.css +0 -0
  39. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/vendor/air-datepicker.LICENSE +0 -0
  40. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/vendor/air-datepicker.css +0 -0
  41. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/vendor/air-datepicker.min.js +0 -0
  42. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/vendor/alpine-anchor.min.js +0 -0
  43. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/vendor/alpine-focus.min.js +0 -0
  44. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/vendor/alpine-plugins.LICENSE +0 -0
  45. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/vendor/alpine.min.js +0 -0
  46. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/vendor/htmx.min.js +0 -0
  47. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/vendor/lucide.LICENSE +0 -0
  48. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/static/vendor/lucide.json +0 -0
  49. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/_palette.html +0 -0
  50. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/components/badge.html +0 -0
  51. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/components/button.html +0 -0
  52. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/components/card.html +0 -0
  53. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/components/date.html +0 -0
  54. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/components/dialog.html +0 -0
  55. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/components/feedback.html +0 -0
  56. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/components/icon.html +0 -0
  57. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/components/menu.html +0 -0
  58. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/components/misc.html +0 -0
  59. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/dashboard.html +0 -0
  60. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/detail/_panel.html +0 -0
  61. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/detail/_related_plain.html +0 -0
  62. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/detail.html +0 -0
  63. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/error.html +0 -0
  64. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/form/_field.html +0 -0
  65. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/form/_fields.html +0 -0
  66. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/form/_options.html +0 -0
  67. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/form.html +0 -0
  68. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/layout.html +0 -0
  69. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/list/_pagination.html +0 -0
  70. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/list/_table.html +0 -0
  71. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/list/_toolbar.html +0 -0
  72. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/list.html +0 -0
  73. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/login.html +0 -0
  74. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/templates/hxadmin/page.html +0 -0
  75. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/toasts.py +0 -0
  76. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/users.py +0 -0
  77. {hxadmin-0.3.0 → hxadmin-0.3.1}/src/hxadmin/views.py +0 -0
  78. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/__init__.py +0 -0
  79. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/conftest.py +0 -0
  80. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/html.py +0 -0
  81. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/js.py +0 -0
  82. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_action_permissions.py +0 -0
  83. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_actions.py +0 -0
  84. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_admin.py +0 -0
  85. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_auth.py +0 -0
  86. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_badges.py +0 -0
  87. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_components.py +0 -0
  88. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_create_edit.py +0 -0
  89. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_dashboard.py +0 -0
  90. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_date_input.py +0 -0
  91. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_delete.py +0 -0
  92. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_dependencies.py +0 -0
  93. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_detail.py +0 -0
  94. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_export.py +0 -0
  95. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_export_routes.py +0 -0
  96. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_fields.py +0 -0
  97. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_filter_ui.py +0 -0
  98. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_filters.py +0 -0
  99. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_forms.py +0 -0
  100. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_icons.py +0 -0
  101. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_list.py +0 -0
  102. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_list_contracts.py +0 -0
  103. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_login.py +0 -0
  104. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_lookup.py +0 -0
  105. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_nav.py +0 -0
  106. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_origin.py +0 -0
  107. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_package.py +0 -0
  108. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_pages.py +0 -0
  109. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_palette.py +0 -0
  110. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_query.py +0 -0
  111. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_render.py +0 -0
  112. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_save_feedback.py +0 -0
  113. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_session_user.py +0 -0
  114. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_shell.py +0 -0
  115. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_static.py +0 -0
  116. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_table_models.py +0 -0
  117. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_template_names.py +0 -0
  118. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_toasts.py +0 -0
  119. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_users.py +0 -0
  120. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_version.py +0 -0
  121. {hxadmin-0.3.0 → hxadmin-0.3.1}/tests/test_views.py +0 -0
  122. {hxadmin-0.3.0 → hxadmin-0.3.1}/zensical.toml +0 -0
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [0.3.1] - 2026-11-23
6
+
7
+ ### Features
8
+
9
+ - Add configurable icons to custom actions
10
+
5
11
  ## [0.3.0] - 2026-11-23
6
12
 
7
13
  ### Features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: hxadmin
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Admin interface for FastAPI and SQLAlchemy 2.0+, built with Tailwind CSS and htmx
5
5
  Project-URL: Homepage, https://github.com/gledi-ai/hxadmin
6
6
  Project-URL: Documentation, https://gledi-ai.github.io/hxadmin/
@@ -30,7 +30,7 @@ class UserView(ModelView[User]):
30
30
  user.active = False
31
31
  return ActionResult.message(f"Deactivated {len(changed)} of {len(objs)} selected users.")
32
32
 
33
- @action("reset_password", label="Reset password")
33
+ @action("reset_password", label="Reset password", icon="key-round")
34
34
  async def reset_password(
35
35
  self, request: Request, session: AsyncSession, obj: User
36
36
  ) -> ActionResult:
@@ -48,7 +48,9 @@ class UserView(ModelView[User]):
48
48
  return ActionResult.message(f"Reset link sent to {email}.", level="info")
49
49
  ```
50
50
 
51
- `@action(name, *, label=None, bulk=False, confirm=None, method="POST")` marks a method as an action. `name` (letters, digits, `_` and `-`) is part of the action's URL and must be unique within the view; `label` defaults to the name capitalised, so `reset_password` shows as "Reset password". Handlers must be `async def`; anything else raises at registration.
51
+ `@action(name, *, label=None, bulk=False, confirm=None, method="POST", icon="zap")` marks a method as an action. `name` (letters, digits, `_` and `-`) is part of the action's URL and must be unique within the view; `label` defaults to the name capitalised, so `reset_password` shows as "Reset password". Handlers must be `async def`; anything else raises at registration.
52
+
53
+ Action buttons and menu items show the `zap` icon by default. Pass a Lucide icon name such as `icon="key-round"` to override it, or pass `icon=None` to hide it.
52
54
 
53
55
  `send_password_reset` and the `/reset` page that redeems the token are your application's; hxadmin has no mail or password-reset support of its own.
54
56
 
@@ -7,6 +7,7 @@ from typing import Any, Literal, Self
7
7
  from starlette.responses import Response
8
8
 
9
9
  from hxadmin.fields import label_for
10
+ from hxadmin.icons import check_icon
10
11
  from hxadmin.toasts import Toast, ToastLevel
11
12
 
12
13
  type ActionMethod = Literal["GET", "POST"]
@@ -14,6 +15,7 @@ type ActionHandler = Callable[..., Awaitable[Any]]
14
15
 
15
16
  ACTION_ATTR = "__hxadmin_action__"
16
17
  _NAME = re.compile(r"[A-Za-z0-9_-]+")
18
+ _DEFAULT_ICON = "zap"
17
19
 
18
20
 
19
21
  @dataclass(frozen=True, slots=True)
@@ -25,6 +27,7 @@ class Action:
25
27
  bulk: bool
26
28
  confirm: str | None
27
29
  method: ActionMethod
30
+ icon: str | None = _DEFAULT_ICON
28
31
 
29
32
 
30
33
  @dataclass(frozen=True, slots=True)
@@ -60,6 +63,7 @@ def action[F: ActionHandler](
60
63
  bulk: bool = False,
61
64
  confirm: str | None = None,
62
65
  method: ActionMethod = "POST",
66
+ icon: str | None = _DEFAULT_ICON,
63
67
  ) -> Callable[[F], F]:
64
68
  """Declare a `ModelView` coroutine method as a row action, or a bulk action with `bulk=True`.
65
69
 
@@ -71,7 +75,8 @@ def action[F: ActionHandler](
71
75
  raise ValueError(f"Invalid action name {name!r}: use letters, digits, '_' and '-'")
72
76
  if method not in ("GET", "POST"):
73
77
  raise ValueError(f"Action {name!r}: method must be 'GET' or 'POST', not {method!r}")
74
- spec = Action(name, label or label_for(name.replace("-", "_")), bulk, confirm, method)
78
+ check_icon(icon)
79
+ spec = Action(name, label or label_for(name.replace("-", "_")), bulk, confirm, method, icon)
75
80
 
76
81
  def decorate(func: F) -> F:
77
82
  _require_async(name, func)
@@ -113,15 +113,19 @@
113
113
 
114
114
  {% macro action_button(view, action, obj=none, origin="detail", class="") -%}
115
115
  {%- set url = admin.url(request, '/' ~ view.identity ~ ('/' ~ view.pk_of(obj) if obj is not none else '') ~ '/action/' ~ action.name) -%}
116
+ {%- set content -%}
117
+ {%- if action.icon %}{{ icon(action.icon, 'size-4 shrink-0') }}{% endif -%}
118
+ {{ action.label }}
119
+ {%- endset -%}
116
120
  {%- if action.method == "POST" -%}
117
121
  <button type="button" class="{{ class }}" hx-post="{{ url }}" hx-target="{{ '#detail' if origin == 'detail' else '#list' }}"
118
- hx-vals="{{ {'_from': origin}|tojson|forceescape }}"{% if obj is none %} form="bulk"{% endif %}{% if action.confirm %} hx-confirm="{{ action.confirm }}"{% endif %}>{{ action.label }}</button>
122
+ hx-vals="{{ {'_from': origin}|tojson|forceescape }}"{% if obj is none %} form="bulk"{% endif %}{% if action.confirm %} hx-confirm="{{ action.confirm }}"{% endif %}>{{ content }}</button>
119
123
  {%- elif obj is none -%}
120
124
  <button type="submit" form="bulk" formmethod="get" formaction="{{ url }}" class="{{ class }}"{% if action.confirm %}
121
- @click="$event.preventDefault(); $dispatch('confirm', {message: {{ action.confirm|tojson|forceescape }}, submit: () => $el.form.requestSubmit($el)})"{% endif %}>{{ action.label }}</button>
125
+ @click="$event.preventDefault(); $dispatch('confirm', {message: {{ action.confirm|tojson|forceescape }}, submit: () => $el.form.requestSubmit($el)})"{% endif %}>{{ content }}</button>
122
126
  {%- else -%}
123
127
  <a href="{{ url }}{{ '?_from=list' if origin == 'list' else '' }}" class="{{ class }}"{% if action.confirm %}
124
- @click="$event.preventDefault(); $dispatch('confirm', {message: {{ action.confirm|tojson|forceescape }}, submit: () => window.location.assign($el.href)})"{% endif %}>{{ action.label }}</a>
128
+ @click="$event.preventDefault(); $dispatch('confirm', {message: {{ action.confirm|tojson|forceescape }}, submit: () => window.location.assign($el.href)})"{% endif %}>{{ content }}</a>
125
129
  {%- endif -%}
126
130
  {%- endmacro %}
127
131
 
@@ -256,14 +260,14 @@
256
260
  {% macro action_menu_item(view, action, obj, origin="detail", inset=False) -%}
257
261
  {%- set url = admin.url(request, '/' ~ view.identity ~ '/' ~ view.pk_of(obj) ~ '/action/' ~ action.name) -%}
258
262
  {%- if action.method == "POST" -%}
259
- {{ menu_item(action.label, inset=inset, attrs={
263
+ {{ menu_item(action.label, icon=action.icon, inset=inset, attrs={
260
264
  "hx-post": url,
261
265
  "hx-target": "#detail" if origin == "detail" else "#list",
262
266
  "hx-vals": {"_from": origin}|tojson|forceescape,
263
267
  "hx-confirm": action.confirm,
264
268
  }) }}
265
269
  {%- else -%}
266
- {{ menu_item(action.label, inset=inset, href=url ~ ("?_from=list" if origin == "list" else ""), attrs={
270
+ {{ menu_item(action.label, icon=action.icon, inset=inset, href=url ~ ("?_from=list" if origin == "list" else ""), attrs={
267
271
  "@click": "$event.preventDefault(); close(true); $dispatch('confirm', {message: " ~ (action.confirm|tojson|forceescape) ~ ", submit: () => window.location.assign($el.href)})" if action.confirm else none,
268
272
  }) }}
269
273
  {%- endif -%}
@@ -40,7 +40,7 @@ class UserView(ModelView[User]):
40
40
  user.active = False
41
41
  return ActionResult.message(f"Deactivated {len(objs)}")
42
42
 
43
- @action("export", bulk=True, method="GET", confirm="Export selected?")
43
+ @action("export", bulk=True, method="GET", confirm="Export selected?", icon="download")
44
44
  async def export(
45
45
  self, request: Request, session: AsyncSession, objs: Sequence[User]
46
46
  ) -> ActionResult:
@@ -51,13 +51,13 @@ class UserView(ModelView[User]):
51
51
  obj.active = True
52
52
  return ActionResult.message(f"Activated {obj.email}")
53
53
 
54
- @action("download", method="GET")
54
+ @action("download", method="GET", icon="download")
55
55
  async def download(self, request: Request, session: AsyncSession, obj: User) -> ActionResult:
56
56
  return ActionResult.response(
57
57
  PlainTextResponse(obj.email, headers={"Content-Disposition": "attachment"})
58
58
  )
59
59
 
60
- @action("explode")
60
+ @action("explode", icon=None)
61
61
  async def explode(self, request: Request, session: AsyncSession, obj: User) -> ActionResult:
62
62
  obj.active = False
63
63
  await session.flush()
@@ -7,6 +7,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
7
7
  from starlette.requests import Request
8
8
 
9
9
  from hxadmin import ActionResult, HxAdmin, ModelView, action
10
+ from hxadmin.icons import icon
10
11
  from tests.conftest import AppFactory, Group, User, allow_all
11
12
  from tests.html import tag
12
13
  from tests.test_action_routes import UserView, seed_users
@@ -33,6 +34,8 @@ def test_detail_renders_row_actions(factory: AppFactory, make_client: MakeClient
33
34
  assert 'hx-target="#detail"' in html
34
35
  assert 'hx-vals="{&#34;_from&#34;: &#34;detail&#34;}"' in html
35
36
  assert 'href="/admin/user/2/action/download"' in html
37
+ download_icon = icon("download", "size-4 shrink-0 text-fg-muted")
38
+ assert f'{download_icon}<span class="min-w-0 flex-1 truncate">Download</span>' in html
36
39
  assert "/admin/user/action/deactivate" not in html
37
40
  assert 'id="user-detail-actions"' in html
38
41
 
@@ -55,6 +58,7 @@ def test_detail_inline_actions_render_as_buttons_not_menu_items(
55
58
  with make_client(app) as client:
56
59
  html = client.get("/admin/user/2").text
57
60
  assert 'hx-post="/admin/user/2/action/ping"' in html
61
+ assert f"{icon('zap', 'size-4 shrink-0')}Ping</button>" in html
58
62
  assert 'id="user-detail-actions"' not in html
59
63
 
60
64
 
@@ -67,9 +71,11 @@ def test_list_renders_selection_bulk_bar_and_row_actions(
67
71
  assert 'x-data="bulk()"' in tag(html, 'id="list"')
68
72
  assert '<form id="bulk" x-show="count"' in html
69
73
  assert 'hx-post="/admin/user/action/deactivate"' in html
74
+ assert f"{icon('zap', 'size-4 shrink-0')}Deactivate</button>" in html
70
75
  assert 'hx-target="#list"' in html
71
76
  assert 'hx-confirm="Deactivate selected users?"' in html
72
77
  assert 'formmethod="get" formaction="/admin/user/action/export"' in html
78
+ assert f"{icon('download', 'size-4 shrink-0')}Export</button>" in html
73
79
  assert "requestSubmit($el)" in html
74
80
  assert "&#34;Export selected?&#34;" in html
75
81
  assert 'aria-label="Select all"' in html
@@ -118,16 +124,26 @@ def test_row_controls_stay_visible_without_hover(
118
124
  assert 'id="row-menu-1-trigger"' in listing
119
125
 
120
126
 
121
- def test_icon_less_action_items_line_up_with_iconed_siblings(
127
+ def test_row_menu_renders_default_icon_and_aligns_iconless_actions(
122
128
  factory: AppFactory, make_client: MakeClient
123
129
  ) -> None:
124
130
  with make_client(build(factory)) as client:
125
131
  html = client.get("/admin/user/").text
126
- item = re.search(
127
- r'<button type="button" role="menuitem"[^>]*hx-post="/admin/user/1/action/activate"', html
132
+ default_item = re.search(
133
+ r'<button type="button" role="menuitem"[^>]*'
134
+ r'hx-post="/admin/user/1/action/activate"[^>]*>(.*?)</button>',
135
+ html,
128
136
  )
129
- assert item is not None
130
- assert " pl-8 " in item.group(0)
137
+ assert default_item is not None
138
+ assert str(icon("zap", "size-4 shrink-0 text-fg-muted")) in default_item.group(1)
139
+ iconless_item = re.search(
140
+ r'<button type="button" role="menuitem"[^>]*'
141
+ r'hx-post="/admin/user/1/action/explode"[^>]*>(.*?)</button>',
142
+ html,
143
+ )
144
+ assert iconless_item is not None
145
+ assert " pl-8 " in iconless_item.group(0)
146
+ assert "<svg" not in iconless_item.group(1)
131
147
 
132
148
 
133
149
  def test_select_all_is_a_valid_alpine_expression_and_tracks_partial_selection(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes