Skip to content

Commit 9a30913

Browse files
authored
feat: add search email bar (#551)
* feat: add search email bar * Update unit coverage badge --------- Co-authored-by: leoguillaume <[email protected]>
1 parent 1ab8395 commit 9a30913

File tree

8 files changed

+31
-12
lines changed

8 files changed

+31
-12
lines changed

.github/badges/coverage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"schemaVersion":1,"label":"coverage","message":"46.91%","color":"red"}
1+
{"schemaVersion":1,"label":"coverage","message":"46.96%","color":"red"}

api/clients/model/_basemodelprovider.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,6 @@ async def forward_request(
335335
"""
336336

337337
url, json, files, data = self._format_request(json=json, files=files, data=data, endpoint=endpoint)
338-
print("#############################")
339-
print("url", url)
340-
print("json", json)
341-
print("files", files)
342-
print("data", data)
343-
print("#############################")
344338
if not additional_data:
345339
additional_data = {}
346340

api/endpoints/admin/users.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ async def update_user(
9999
status_code=200,
100100
)
101101
async def get_user(
102-
request: Request, user: int = Path(description="The ID of the user to get."), postgres_session: AsyncSession = Depends(get_postgres_session)
102+
request: Request,
103+
user: int = Path(description="The ID of the user to get."),
104+
postgres_session: AsyncSession = Depends(get_postgres_session),
103105
) -> JSONResponse:
104106
"""
105107
Get a user by id.
@@ -119,6 +121,7 @@ async def get_users(
119121
request: Request,
120122
role: int | None = Query(default=None, description="The ID of the role to filter the users by."),
121123
organization: int | None = Query(default=None, description="The ID of the organization to filter the users by."),
124+
email: str | None = Query(default=None, description="The email of the user to filter the users by."),
122125
offset: int = Query(default=0, ge=0, description="The offset of the users to get."),
123126
limit: int = Query(default=10, ge=1, le=100, description="The limit of the users to get."),
124127
order_by: Literal["id", "name", "created", "updated"] = Query(default="id", description="The field to order the users by."),
@@ -133,6 +136,7 @@ async def get_users(
133136
postgres_session=postgres_session,
134137
role_id=role,
135138
organization_id=organization,
139+
email=email,
136140
offset=offset,
137141
limit=limit,
138142
order_by=order_by,

playground/app/core/variables.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
MAX_DIALOG_WIDTH = "600px" # Dialogs and modals width
99
SELECT_SMALL_WIDTH = "150px" # Small select components
1010
SELECT_MEDIUM_WIDTH = "200px" # Medium select components
11+
SELECT_LARGE_WIDTH = "300px" # Large select components
1112

1213
# ============================================================================
1314
# TYPOGRAPHY SIZES

playground/app/features/usage/components/dashboards.py renamed to playground/app/features/usage/components/lists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def usage_table() -> rx.Component:
9494
)
9595

9696

97-
def usage_dashboard() -> rx.Component:
97+
def usage_list() -> rx.Component:
9898
"""Usage tracking page with filters, table, and chart."""
9999
return rx.card(
100100
rx.vstack(

playground/app/features/usage/page.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import reflex as rx
44

55
from app.core.variables import PADDING_PAGE, SPACING_XL
6-
from app.features.usage.components.dashboards import usage_dashboard
76
from app.features.usage.components.headers import usage_header
7+
from app.features.usage.components.lists import usage_list
88

99

1010
def usage_page() -> rx.Component:
@@ -13,7 +13,7 @@ def usage_page() -> rx.Component:
1313
rx.scroll_area(
1414
rx.vstack(
1515
usage_header(),
16-
usage_dashboard(),
16+
usage_list(),
1717
spacing=SPACING_XL,
1818
width="100%",
1919
padding=PADDING_PAGE,

playground/app/features/users/components/lists.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import reflex as rx
22

3-
from app.core.variables import SELECT_MEDIUM_WIDTH, SPACING_SMALL, TEXT_SIZE_LABEL, TEXT_SIZE_LARGE
3+
from app.core.variables import SELECT_LARGE_WIDTH, SELECT_MEDIUM_WIDTH, SPACING_SMALL, TEXT_SIZE_LABEL, TEXT_SIZE_LARGE
44
from app.features.users.components.dialogs import user_delete_dialog, user_settings_dialog
55
from app.features.users.models import User
66
from app.features.users.state import UsersState
@@ -59,6 +59,14 @@ def user_renderer_row(user: User, with_settings: bool = False) -> rx.Component:
5959
def user_filters() -> rx.Component:
6060
"""Filters for users list."""
6161
return rx.hstack(
62+
rx.text("Search", size=TEXT_SIZE_LABEL, color=rx.color("mauve", 11)),
63+
rx.input(
64+
type="text",
65+
value=UsersState.search_email_value,
66+
on_change=UsersState.set_search_email,
67+
placeholder="Enter email",
68+
width=SELECT_LARGE_WIDTH,
69+
),
6270
rx.text("Filters", size=TEXT_SIZE_LABEL, color=rx.color("mauve", 11)),
6371
rx.select.root(
6472
rx.select.trigger(size="2", width=SELECT_MEDIUM_WIDTH),

playground/app/features/users/state.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ async def load_entities(self):
7676
params["role"] = int(self.filter_role_value)
7777
if self.filter_organization_value != "0":
7878
params["organization"] = int(self.filter_organization_value)
79+
if self.search_email_value:
80+
params["email"] = self.search_email_value
7981

8082
response = None
8183
try:
@@ -350,6 +352,16 @@ async def edit_entity(self):
350352
############################################################
351353
per_page: int = 20
352354
order_by_options: list[str] = ["id", "name", "created", "updated"]
355+
search_email_value: str | None = None
356+
357+
@rx.event
358+
async def set_search_email(self, value: str):
359+
self.search_email_value = value
360+
self.page = 1
361+
self.has_more_page = False
362+
yield
363+
async for _ in self.load_entities():
364+
yield
353365

354366
@rx.event
355367
async def set_order_by(self, value: str):

0 commit comments

Comments
 (0)