Spaces:
Sleeping
Sleeping
Sync app from GitHub Actions
Browse files- src/ui/app_factory.py +48 -46
- src/ui/theme.py +18 -12
src/ui/app_factory.py
CHANGED
|
@@ -2479,7 +2479,7 @@ def create_app() -> gr.Blocks:
|
|
| 2479 |
section_header_html(
|
| 2480 |
"Projects",
|
| 2481 |
"Project management",
|
| 2482 |
-
"Create project records
|
| 2483 |
class_name="bn-panel-soft",
|
| 2484 |
)
|
| 2485 |
)
|
|
@@ -2627,6 +2627,7 @@ def create_app() -> gr.Blocks:
|
|
| 2627 |
outputs=[projects_table],
|
| 2628 |
)
|
| 2629 |
|
|
|
|
| 2630 |
gr.HTML(
|
| 2631 |
section_header_html(
|
| 2632 |
"Access",
|
|
@@ -2684,33 +2685,55 @@ def create_app() -> gr.Blocks:
|
|
| 2684 |
outputs=[token_update_message, token_new_value, token_clear_checkbox, projects_table, seed_warning_state],
|
| 2685 |
)
|
| 2686 |
|
| 2687 |
-
|
| 2688 |
-
|
| 2689 |
-
|
| 2690 |
-
|
| 2691 |
-
|
| 2692 |
|
| 2693 |
-
|
| 2694 |
-
|
| 2695 |
-
|
| 2696 |
|
| 2697 |
-
|
| 2698 |
-
|
| 2699 |
-
|
| 2700 |
|
| 2701 |
-
|
| 2702 |
-
|
| 2703 |
|
| 2704 |
-
|
| 2705 |
-
|
| 2706 |
-
|
| 2707 |
-
|
| 2708 |
-
|
| 2709 |
-
|
| 2710 |
-
|
| 2711 |
-
|
| 2712 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2713 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2714 |
|
| 2715 |
with gr.Group(visible=False, elem_classes=["bn-admin-panel", "bn-admin-access-panel"]) as admin_users_controls:
|
| 2716 |
gr.HTML(
|
|
@@ -2937,28 +2960,6 @@ def create_app() -> gr.Blocks:
|
|
| 2937 |
outputs=[pending_invites_table],
|
| 2938 |
)
|
| 2939 |
|
| 2940 |
-
with gr.Group(visible=False, elem_classes=["bn-admin-panel", "bn-admin-delete-panel"]) as admin_delete_controls:
|
| 2941 |
-
gr.HTML(
|
| 2942 |
-
section_header_html(
|
| 2943 |
-
"Project",
|
| 2944 |
-
"Delete project",
|
| 2945 |
-
"Remove a project from this validator workspace without deleting its Hugging Face dataset.",
|
| 2946 |
-
class_name="bn-panel-soft",
|
| 2947 |
-
)
|
| 2948 |
-
)
|
| 2949 |
-
with gr.Group(elem_classes=["bn-delete-project-panel"]):
|
| 2950 |
-
gr.HTML(inline_hint_html("Deleting a project removes assignments and pending invites.", "danger"))
|
| 2951 |
-
delete_project_slug = gr.Dropdown(
|
| 2952 |
-
choices=_project_slugs(),
|
| 2953 |
-
label="Project to delete",
|
| 2954 |
-
)
|
| 2955 |
-
delete_project_btn = gr.Button(
|
| 2956 |
-
"Delete Project",
|
| 2957 |
-
variant="stop",
|
| 2958 |
-
elem_classes=["bn-delete-project-action"],
|
| 2959 |
-
)
|
| 2960 |
-
delete_project_message = gr.Markdown()
|
| 2961 |
-
|
| 2962 |
delete_project_btn.click(
|
| 2963 |
fn=delete_project,
|
| 2964 |
inputs=[session_state, delete_project_slug],
|
|
@@ -3016,9 +3017,10 @@ def create_app() -> gr.Blocks:
|
|
| 3016 |
gr.update(visible=bool(s is not None)),
|
| 3017 |
gr.update(visible=bool(s is not None)),
|
| 3018 |
gr.update(visible=bool(s is not None)),
|
|
|
|
| 3019 |
),
|
| 3020 |
inputs=[session_state],
|
| 3021 |
-
outputs=[
|
| 3022 |
)
|
| 3023 |
|
| 3024 |
session_state.change(
|
|
|
|
| 2479 |
section_header_html(
|
| 2480 |
"Projects",
|
| 2481 |
"Project management",
|
| 2482 |
+
"Create project records and review the datasets registered in this validator workspace.",
|
| 2483 |
class_name="bn-panel-soft",
|
| 2484 |
)
|
| 2485 |
)
|
|
|
|
| 2627 |
outputs=[projects_table],
|
| 2628 |
)
|
| 2629 |
|
| 2630 |
+
with gr.Group(visible=False, elem_classes=["bn-admin-panel", "bn-admin-token-panel"]) as admin_token_controls:
|
| 2631 |
gr.HTML(
|
| 2632 |
section_header_html(
|
| 2633 |
"Access",
|
|
|
|
| 2685 |
outputs=[token_update_message, token_new_value, token_clear_checkbox, projects_table, seed_warning_state],
|
| 2686 |
)
|
| 2687 |
|
| 2688 |
+
def delete_project(session, project_slug: str):
|
| 2689 |
+
if session is None:
|
| 2690 |
+
return "Access denied. Login required.", gr.update(), gr.update(), gr.update(), session, gr.update(), gr.update()
|
| 2691 |
+
if not _is_admin_for_project(session, project_slug):
|
| 2692 |
+
return "Access denied. You must be admin of the selected project.", gr.update(), gr.update(), gr.update(), session, gr.update(), gr.update()
|
| 2693 |
|
| 2694 |
+
success, msg = admin_manager.delete_project(session.username, project_slug)
|
| 2695 |
+
if not success:
|
| 2696 |
+
return msg, _project_rows(), gr.update(choices=_project_slugs()), gr.update(choices=_project_slugs()), session, gr.update(), gr.update()
|
| 2697 |
|
| 2698 |
+
persisted, persist_error = _persist_admin_state()
|
| 2699 |
+
if not persisted:
|
| 2700 |
+
msg = f"{msg} | Persistence failed: {persist_error}"
|
| 2701 |
|
| 2702 |
+
refreshed_warning = _rebuild_queue_service()
|
| 2703 |
+
refreshed_session = _refresh_session_copy(session)
|
| 2704 |
|
| 2705 |
+
admin_projects = _admin_projects_for_session(refreshed_session)
|
| 2706 |
+
return (
|
| 2707 |
+
msg,
|
| 2708 |
+
_project_rows(),
|
| 2709 |
+
gr.update(choices=admin_projects, value=None),
|
| 2710 |
+
gr.update(choices=admin_projects, value=None),
|
| 2711 |
+
refreshed_session,
|
| 2712 |
+
refreshed_warning,
|
| 2713 |
+
gr.update(choices=admin_projects, value=None),
|
| 2714 |
+
)
|
| 2715 |
+
|
| 2716 |
+
with gr.Group(visible=False, elem_classes=["bn-admin-panel", "bn-admin-delete-panel"]) as admin_delete_controls:
|
| 2717 |
+
gr.HTML(
|
| 2718 |
+
section_header_html(
|
| 2719 |
+
"Project",
|
| 2720 |
+
"Delete project",
|
| 2721 |
+
"Remove a project from this validator workspace without deleting its Hugging Face dataset.",
|
| 2722 |
+
class_name="bn-panel-soft",
|
| 2723 |
+
)
|
| 2724 |
+
)
|
| 2725 |
+
with gr.Group(elem_classes=["bn-delete-project-panel"]):
|
| 2726 |
+
gr.HTML(inline_hint_html("Deleting a project removes assignments and pending invites.", "danger"))
|
| 2727 |
+
delete_project_slug = gr.Dropdown(
|
| 2728 |
+
choices=_project_slugs(),
|
| 2729 |
+
label="Project to delete",
|
| 2730 |
)
|
| 2731 |
+
delete_project_btn = gr.Button(
|
| 2732 |
+
"Delete Project",
|
| 2733 |
+
variant="stop",
|
| 2734 |
+
elem_classes=["bn-delete-project-action"],
|
| 2735 |
+
)
|
| 2736 |
+
delete_project_message = gr.Markdown()
|
| 2737 |
|
| 2738 |
with gr.Group(visible=False, elem_classes=["bn-admin-panel", "bn-admin-access-panel"]) as admin_users_controls:
|
| 2739 |
gr.HTML(
|
|
|
|
| 2960 |
outputs=[pending_invites_table],
|
| 2961 |
)
|
| 2962 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2963 |
delete_project_btn.click(
|
| 2964 |
fn=delete_project,
|
| 2965 |
inputs=[session_state, delete_project_slug],
|
|
|
|
| 3017 |
gr.update(visible=bool(s is not None)),
|
| 3018 |
gr.update(visible=bool(s is not None)),
|
| 3019 |
gr.update(visible=bool(s is not None)),
|
| 3020 |
+
gr.update(visible=bool(s is not None)),
|
| 3021 |
),
|
| 3022 |
inputs=[session_state],
|
| 3023 |
+
outputs=[admin_token_controls, admin_delete_controls, admin_users_controls, admin_pending_controls],
|
| 3024 |
)
|
| 3025 |
|
| 3026 |
session_state.change(
|
src/ui/theme.py
CHANGED
|
@@ -593,8 +593,7 @@ body,
|
|
| 593 |
}
|
| 594 |
|
| 595 |
.bn-admin-access-panel,
|
| 596 |
-
.bn-admin-pending-panel
|
| 597 |
-
.bn-admin-delete-panel {
|
| 598 |
width: 100% !important;
|
| 599 |
}
|
| 600 |
|
|
@@ -605,14 +604,10 @@ body,
|
|
| 605 |
gap: 14px !important;
|
| 606 |
}
|
| 607 |
|
| 608 |
-
.column:has(> .bn-admin-access-panel):has(> .bn-admin-pending-panel) > :not(.bn-admin-access-panel):not(.bn-admin-pending-panel)
|
| 609 |
grid-column: 1 / -1;
|
| 610 |
}
|
| 611 |
|
| 612 |
-
.column:has(> .bn-admin-access-panel):has(> .bn-admin-pending-panel) > .bn-admin-delete-panel {
|
| 613 |
-
grid-column: 2;
|
| 614 |
-
}
|
| 615 |
-
|
| 616 |
.bn-soft-action button,
|
| 617 |
button.bn-soft-action {
|
| 618 |
min-height: 42px !important;
|
|
@@ -629,6 +624,21 @@ button.bn-soft-action:hover {
|
|
| 629 |
background: #bfdbfe !important;
|
| 630 |
}
|
| 631 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 632 |
.bn-delete-project-panel {
|
| 633 |
padding: 14px !important;
|
| 634 |
border: 1px solid #fecaca !important;
|
|
@@ -836,8 +846,7 @@ select {
|
|
| 836 |
}
|
| 837 |
|
| 838 |
.bn-admin-access-panel,
|
| 839 |
-
.bn-admin-pending-panel
|
| 840 |
-
.bn-admin-delete-panel {
|
| 841 |
display: block !important;
|
| 842 |
width: 100% !important;
|
| 843 |
margin-left: 0 !important;
|
|
@@ -847,9 +856,6 @@ select {
|
|
| 847 |
grid-template-columns: 1fr;
|
| 848 |
}
|
| 849 |
|
| 850 |
-
.column:has(> .bn-admin-access-panel):has(> .bn-admin-pending-panel) > .bn-admin-delete-panel {
|
| 851 |
-
grid-column: auto;
|
| 852 |
-
}
|
| 853 |
}
|
| 854 |
|
| 855 |
@media (max-width: 560px) {
|
|
|
|
| 593 |
}
|
| 594 |
|
| 595 |
.bn-admin-access-panel,
|
| 596 |
+
.bn-admin-pending-panel {
|
|
|
|
| 597 |
width: 100% !important;
|
| 598 |
}
|
| 599 |
|
|
|
|
| 604 |
gap: 14px !important;
|
| 605 |
}
|
| 606 |
|
| 607 |
+
.column:has(> .bn-admin-access-panel):has(> .bn-admin-pending-panel) > :not(.bn-admin-access-panel):not(.bn-admin-pending-panel) {
|
| 608 |
grid-column: 1 / -1;
|
| 609 |
}
|
| 610 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 611 |
.bn-soft-action button,
|
| 612 |
button.bn-soft-action {
|
| 613 |
min-height: 42px !important;
|
|
|
|
| 624 |
background: #bfdbfe !important;
|
| 625 |
}
|
| 626 |
|
| 627 |
+
.bn-admin-panel button.secondary:not(.bn-delete-project-action),
|
| 628 |
+
.bn-admin-panel button.lg.secondary:not(.bn-delete-project-action) {
|
| 629 |
+
border: 1px solid #93c5fd !important;
|
| 630 |
+
border-radius: 8px !important;
|
| 631 |
+
background: #dbeafe !important;
|
| 632 |
+
color: #075985 !important;
|
| 633 |
+
font-weight: 760 !important;
|
| 634 |
+
}
|
| 635 |
+
|
| 636 |
+
.bn-admin-panel button.secondary:not(.bn-delete-project-action):hover,
|
| 637 |
+
.bn-admin-panel button.lg.secondary:not(.bn-delete-project-action):hover {
|
| 638 |
+
border-color: #60a5fa !important;
|
| 639 |
+
background: #bfdbfe !important;
|
| 640 |
+
}
|
| 641 |
+
|
| 642 |
.bn-delete-project-panel {
|
| 643 |
padding: 14px !important;
|
| 644 |
border: 1px solid #fecaca !important;
|
|
|
|
| 846 |
}
|
| 847 |
|
| 848 |
.bn-admin-access-panel,
|
| 849 |
+
.bn-admin-pending-panel {
|
|
|
|
| 850 |
display: block !important;
|
| 851 |
width: 100% !important;
|
| 852 |
margin-left: 0 !important;
|
|
|
|
| 856 |
grid-template-columns: 1fr;
|
| 857 |
}
|
| 858 |
|
|
|
|
|
|
|
|
|
|
| 859 |
}
|
| 860 |
|
| 861 |
@media (max-width: 560px) {
|