simple-module-dashboard 0.0.47__tar.gz → 0.0.49__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 (51) hide show
  1. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/.gitignore +6 -0
  2. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/PKG-INFO +4 -4
  3. simple_module_dashboard-0.0.49/dashboard/core/constants.py +18 -0
  4. simple_module_dashboard-0.0.49/dashboard/module.py +57 -0
  5. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/pages/Doctor.tsx +0 -2
  6. simple_module_dashboard-0.0.49/dashboard/pages/i18n.generated.ts +182 -0
  7. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/ui/components/doctor/StatsRow.tsx +4 -13
  8. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/ui/components/doctor/TerminalPanel.tsx +0 -1
  9. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/ui/components/doctor/report.ts +4 -1
  10. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/ui/components/doctor/types.ts +1 -1
  11. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/web/endpoints/api.py +2 -2
  12. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/web/endpoints/views.py +2 -2
  13. simple_module_dashboard-0.0.49/package.json +7 -0
  14. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/pyproject.toml +4 -4
  15. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests-js/doctor-stats.test.tsx +16 -1
  16. simple_module_dashboard-0.0.47/dashboard/core/constants.py +0 -4
  17. simple_module_dashboard-0.0.47/dashboard/module.py +0 -81
  18. simple_module_dashboard-0.0.47/package.json +0 -18
  19. simple_module_dashboard-0.0.47/tsconfig.json +0 -10
  20. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/LICENSE +0 -0
  21. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/README.md +0 -0
  22. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/__init__.py +0 -0
  23. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/core/__init__.py +0 -0
  24. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/locales/de.json +0 -0
  25. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/locales/en.json +0 -0
  26. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/locales/es.json +0 -0
  27. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/pages/Home.tsx +0 -0
  28. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/py.typed +0 -0
  29. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/styles.css +0 -0
  30. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/ui/components/ModuleTile.tsx +0 -0
  31. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/ui/components/doctor/ChecksCard.tsx +0 -0
  32. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/ui/components/doctor/DevServerCard.tsx +0 -0
  33. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/ui/components/doctor/MigrationsCard.tsx +0 -0
  34. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/ui/components/doctor/check-copy.ts +0 -0
  35. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/ui/components/doctor/copy.ts +0 -0
  36. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/ui/components/module-target.ts +0 -0
  37. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/web/__init__.py +0 -0
  38. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/web/doctor.py +0 -0
  39. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/web/endpoints/__init__.py +0 -0
  40. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/dashboard/web/stats.py +0 -0
  41. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests/core/module/test_dashboard.py +0 -0
  42. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests/web/doctor/test_doctor_migration_chips.py +0 -0
  43. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests/web/doctor/test_doctor_props.py +0 -0
  44. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests/web/endpoints/test_dashboard_permission.py +0 -0
  45. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests/web/endpoints/test_dashboard_view_routes.py +0 -0
  46. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests/web/stats/test_dashboard_month_delta.py +0 -0
  47. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests/web/stats/test_dashboard_single_tenant.py +0 -0
  48. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests/web/stats/test_dashboard_user_directory.py +0 -0
  49. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests-js/dashboard_Doctor.test.tsx +0 -0
  50. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests-js/dashboard_Doctor_errors.test.tsx +0 -0
  51. {simple_module_dashboard-0.0.47 → simple_module_dashboard-0.0.49}/tests-js/dashboard_Home.test.tsx +0 -0
@@ -67,3 +67,9 @@ host/client_app/.playwright-cli/*
67
67
  .verify/
68
68
  /openapi.json
69
69
  qa-shots/
70
+
71
+ host/client_app/.module-tsconfig
72
+
73
+ # Incremental generation cache
74
+ .smpy/gen.json
75
+ .smpy/gen.*.tmp
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: simple_module_dashboard
3
- Version: 0.0.47
3
+ Version: 0.0.49
4
4
  Summary: Admin landing page and sidebar menu host for authenticated users of a simple_module app
5
5
  Project-URL: Homepage, https://github.com/antosubash/simple_module_python
6
6
  Project-URL: Repository, https://github.com/antosubash/simple_module_python
@@ -21,9 +21,9 @@ Classifier: Topic :: Internet :: WWW/HTTP
21
21
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
22
  Classifier: Typing :: Typed
23
23
  Requires-Python: >=3.12
24
- Requires-Dist: simple-module-core==0.0.47
25
- Requires-Dist: simple-module-db==0.0.47
26
- Requires-Dist: simple-module-hosting==0.0.47
24
+ Requires-Dist: simple-module-core==0.0.49
25
+ Requires-Dist: simple-module-db==0.0.49
26
+ Requires-Dist: simple-module-hosting==0.0.49
27
27
  Description-Content-Type: text/markdown
28
28
 
29
29
  # simple_module_dashboard
@@ -0,0 +1,18 @@
1
+ """Stable identifiers for the dashboard module."""
2
+
3
+ from simple_module_core.deprecation import deprecate
4
+ from simple_module_core.permissions import PermissionCatalogue
5
+
6
+ PERM_GROUP = "Dashboard"
7
+
8
+
9
+ class Permissions(PermissionCatalogue, group=PERM_GROUP, label_key="dashboard.permission_group"):
10
+ VIEW = "dashboard.view"
11
+
12
+
13
+ deprecate(
14
+ "dashboard PERM_* constants",
15
+ remove_in="0.0.50",
16
+ use="dashboard.core.constants.Permissions",
17
+ )
18
+ PERM_VIEW = Permissions.VIEW
@@ -0,0 +1,57 @@
1
+ """Dashboard module definition."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from simple_module_core import AdminSurface
6
+ from simple_module_core.menu import MenuItem, MenuRegistry, MenuSection
7
+ from simple_module_core.module import ModuleBase, ModuleMeta
8
+
9
+ from dashboard.core.constants import Permissions
10
+
11
+ _URL_DASHBOARD = "/dashboard/"
12
+ _URL_DOCTOR = "/admin/doctor/"
13
+ _ICON_DASHBOARD = "home"
14
+ _ICON_DOCTOR = "stethoscope"
15
+
16
+
17
+ class DashboardModule(ModuleBase):
18
+ # Administrative data: only admin (wildcard) or explicit grants; never
19
+ # map user/tenant roles here, including single-tenant installs (#464).
20
+ permissions = Permissions
21
+
22
+ meta = ModuleMeta(
23
+ name="Dashboard",
24
+ route_prefix="/api/dashboard",
25
+ view_prefix="/dashboard",
26
+ # The dashboard itself is an app screen; Doctor is an admin one.
27
+ admin=AdminSurface(
28
+ prefix="/admin/doctor",
29
+ routes="dashboard.web.endpoints.views:admin_router",
30
+ menu_group="System",
31
+ ),
32
+ i18n_audience="admin",
33
+ )
34
+
35
+ def register_menu_items(self, registry: MenuRegistry) -> None:
36
+ registry.add(
37
+ MenuItem(
38
+ label="Dashboard",
39
+ label_key="dashboard.nav.dashboard",
40
+ url=_URL_DASHBOARD,
41
+ icon=_ICON_DASHBOARD,
42
+ order=10,
43
+ section=MenuSection.SIDEBAR,
44
+ )
45
+ )
46
+ registry.add(
47
+ MenuItem(
48
+ label="Doctor",
49
+ label_key="dashboard.nav.doctor",
50
+ url=_URL_DOCTOR,
51
+ icon=_ICON_DOCTOR,
52
+ order=220,
53
+ # Mirrors the view route's admin-only guard — without it the
54
+ # entry shows for every signed-in account and 403s on click.
55
+ roles=["admin"],
56
+ )
57
+ )
@@ -2,7 +2,6 @@ import { Head, router } from '@inertiajs/react';
2
2
  import { keys, useT } from '@simple-module-py/i18n';
3
3
  import { PageShell } from '@simple-module-py/ui/components/PageShell';
4
4
  import { Button } from '@simple-module-py/ui/components/ui/button';
5
- import { AdminLayout } from '@simple-module-py/ui/layouts/AdminLayout';
6
5
  import { RefreshCw } from 'lucide-react';
7
6
  import { toast } from 'sonner';
8
7
  import { ChecksCard } from '../ui/components/doctor/ChecksCard';
@@ -119,5 +118,4 @@ function Doctor(props: DoctorProps) {
119
118
  );
120
119
  }
121
120
 
122
- Doctor.layout = [AdminLayout];
123
121
  export default Doctor;
@@ -0,0 +1,182 @@
1
+ import '@simple-module-py/i18n';
2
+
3
+ // AUTO-GENERATED by simple_module_hosting.i18n_manifest — do not edit by hand.
4
+ // Regenerate by booting the host in development mode or `make gen-i18n`.
5
+
6
+ export const keys = {
7
+ dashboard: {
8
+ doctor: {
9
+ applied: 'dashboard.doctor.applied',
10
+ apply_pending: 'dashboard.doctor.apply_pending',
11
+ checks: {
12
+ auth_provider: 'dashboard.doctor.checks.auth_provider',
13
+ coupling: 'dashboard.doctor.checks.coupling',
14
+ inertia: 'dashboard.doctor.checks.inertia',
15
+ locales: 'dashboard.doctor.checks.locales',
16
+ metadata: 'dashboard.doctor.checks.metadata',
17
+ migrations: 'dashboard.doctor.checks.migrations',
18
+ pages: 'dashboard.doctor.checks.pages',
19
+ styling: 'dashboard.doctor.checks.styling',
20
+ },
21
+ checks_unavailable_hint: 'dashboard.doctor.checks_unavailable_hint',
22
+ checks_unavailable_title: 'dashboard.doctor.checks_unavailable_title',
23
+ copied_command_toast: 'dashboard.doctor.copied_command_toast',
24
+ copied_report_toast: 'dashboard.doctor.copied_report_toast',
25
+ copy_failed_toast: 'dashboard.doctor.copy_failed_toast',
26
+ copy_report: 'dashboard.doctor.copy_report',
27
+ description_after: 'dashboard.doctor.description_after',
28
+ description_before: 'dashboard.doctor.description_before',
29
+ dev_server: 'dashboard.doctor.dev_server',
30
+ fix: 'dashboard.doctor.fix',
31
+ generate: 'dashboard.doctor.generate',
32
+ migrations_empty: 'dashboard.doctor.migrations_empty',
33
+ not_running: 'dashboard.doctor.not_running',
34
+ pending: 'dashboard.doctor.pending',
35
+ recent_migrations: 'dashboard.doctor.recent_migrations',
36
+ report_checks: 'dashboard.doctor.report_checks',
37
+ report_checks_unavailable: 'dashboard.doctor.report_checks_unavailable',
38
+ report_dev_server: 'dashboard.doctor.report_dev_server',
39
+ report_migrations: 'dashboard.doctor.report_migrations',
40
+ rerun: 'dashboard.doctor.rerun',
41
+ rerun_failed: 'dashboard.doctor.rerun_failed',
42
+ running: 'dashboard.doctor.running',
43
+ stat_checks_passing: 'dashboard.doctor.stat_checks_passing',
44
+ stat_checks_total: 'dashboard.doctor.stat_checks_total',
45
+ stat_checks_unavailable: 'dashboard.doctor.stat_checks_unavailable',
46
+ stat_modules_loaded: 'dashboard.doctor.stat_modules_loaded',
47
+ stat_pending_migrations: 'dashboard.doctor.stat_pending_migrations',
48
+ stat_python: 'dashboard.doctor.stat_python',
49
+ static_checks: 'dashboard.doctor.static_checks',
50
+ status_pass: 'dashboard.doctor.status_pass',
51
+ title: 'dashboard.doctor.title',
52
+ transcript_modules: 'dashboard.doctor.transcript_modules',
53
+ transcript_pages: 'dashboard.doctor.transcript_pages',
54
+ transcript_result: 'dashboard.doctor.transcript_result',
55
+ transcript_skipped: 'dashboard.doctor.transcript_skipped',
56
+ transcript_warn: 'dashboard.doctor.transcript_warn',
57
+ },
58
+ home: {
59
+ description: 'dashboard.home.description',
60
+ health_alert: 'dashboard.home.health_alert',
61
+ health_all_good: 'dashboard.home.health_all_good',
62
+ health_ok: 'dashboard.home.health_ok',
63
+ health_see_doctor: 'dashboard.home.health_see_doctor',
64
+ stats: {
65
+ active_users: 'dashboard.home.stats.active_users',
66
+ active_users_delta: 'dashboard.home.stats.active_users_delta',
67
+ health: 'dashboard.home.stats.health',
68
+ modules: 'dashboard.home.stats.modules',
69
+ modules_delta: 'dashboard.home.stats.modules_delta',
70
+ total_users: 'dashboard.home.stats.total_users',
71
+ total_users_delta: 'dashboard.home.stats.total_users_delta',
72
+ total_users_delta_one: 'dashboard.home.stats.total_users_delta_one',
73
+ total_users_delta_other: 'dashboard.home.stats.total_users_delta_other',
74
+ },
75
+ system_health_alert: 'dashboard.home.system_health_alert',
76
+ system_health_alert_one: 'dashboard.home.system_health_alert_one',
77
+ system_health_alert_other: 'dashboard.home.system_health_alert_other',
78
+ system_health_none: 'dashboard.home.system_health_none',
79
+ system_health_ok: 'dashboard.home.system_health_ok',
80
+ system_info_title: 'dashboard.home.system_info_title',
81
+ system_meta: 'dashboard.home.system_meta',
82
+ tile: {
83
+ loaded_degraded: 'dashboard.home.tile.loaded_degraded',
84
+ loaded_healthy: 'dashboard.home.tile.loaded_healthy',
85
+ loaded_no_checks: 'dashboard.home.tile.loaded_no_checks',
86
+ loaded_unhealthy: 'dashboard.home.tile.loaded_unhealthy',
87
+ no_view: 'dashboard.home.tile.no_view',
88
+ open: 'dashboard.home.tile.open',
89
+ },
90
+ title: 'dashboard.home.title',
91
+ welcome_message: 'dashboard.home.welcome_message',
92
+ },
93
+ nav: {
94
+ dashboard: 'dashboard.nav.dashboard',
95
+ doctor: 'dashboard.nav.doctor',
96
+ },
97
+ permission_group: 'dashboard.permission_group',
98
+ },
99
+ } as const;
100
+
101
+ type ModuleTranslationResources = {
102
+ readonly 'dashboard.doctor.applied': '';
103
+ readonly 'dashboard.doctor.apply_pending': '';
104
+ readonly 'dashboard.doctor.checks.auth_provider': '';
105
+ readonly 'dashboard.doctor.checks.coupling': '';
106
+ readonly 'dashboard.doctor.checks.inertia': '';
107
+ readonly 'dashboard.doctor.checks.locales': '';
108
+ readonly 'dashboard.doctor.checks.metadata': '';
109
+ readonly 'dashboard.doctor.checks.migrations': '';
110
+ readonly 'dashboard.doctor.checks.pages': '';
111
+ readonly 'dashboard.doctor.checks.styling': '';
112
+ readonly 'dashboard.doctor.checks_unavailable_hint': '';
113
+ readonly 'dashboard.doctor.checks_unavailable_title': '';
114
+ readonly 'dashboard.doctor.copied_command_toast': '';
115
+ readonly 'dashboard.doctor.copied_report_toast': '';
116
+ readonly 'dashboard.doctor.copy_failed_toast': '';
117
+ readonly 'dashboard.doctor.copy_report': '';
118
+ readonly 'dashboard.doctor.description_after': '';
119
+ readonly 'dashboard.doctor.description_before': '';
120
+ readonly 'dashboard.doctor.dev_server': '';
121
+ readonly 'dashboard.doctor.fix': '';
122
+ readonly 'dashboard.doctor.generate': '';
123
+ readonly 'dashboard.doctor.migrations_empty': '';
124
+ readonly 'dashboard.doctor.not_running': '';
125
+ readonly 'dashboard.doctor.pending': '';
126
+ readonly 'dashboard.doctor.recent_migrations': '';
127
+ readonly 'dashboard.doctor.report_checks': '';
128
+ readonly 'dashboard.doctor.report_checks_unavailable': '';
129
+ readonly 'dashboard.doctor.report_dev_server': '';
130
+ readonly 'dashboard.doctor.report_migrations': '';
131
+ readonly 'dashboard.doctor.rerun': '';
132
+ readonly 'dashboard.doctor.rerun_failed': '';
133
+ readonly 'dashboard.doctor.running': '';
134
+ readonly 'dashboard.doctor.stat_checks_passing': '';
135
+ readonly 'dashboard.doctor.stat_checks_total': '';
136
+ readonly 'dashboard.doctor.stat_checks_unavailable': '';
137
+ readonly 'dashboard.doctor.stat_modules_loaded': '';
138
+ readonly 'dashboard.doctor.stat_pending_migrations': '';
139
+ readonly 'dashboard.doctor.stat_python': '';
140
+ readonly 'dashboard.doctor.static_checks': '';
141
+ readonly 'dashboard.doctor.status_pass': '';
142
+ readonly 'dashboard.doctor.title': '';
143
+ readonly 'dashboard.doctor.transcript_modules': '';
144
+ readonly 'dashboard.doctor.transcript_pages': '';
145
+ readonly 'dashboard.doctor.transcript_result': '';
146
+ readonly 'dashboard.doctor.transcript_skipped': '';
147
+ readonly 'dashboard.doctor.transcript_warn': '';
148
+ readonly 'dashboard.home.description': '';
149
+ readonly 'dashboard.home.health_alert': '';
150
+ readonly 'dashboard.home.health_all_good': '';
151
+ readonly 'dashboard.home.health_ok': '';
152
+ readonly 'dashboard.home.health_see_doctor': '';
153
+ readonly 'dashboard.home.stats.active_users': '';
154
+ readonly 'dashboard.home.stats.active_users_delta': '';
155
+ readonly 'dashboard.home.stats.health': '';
156
+ readonly 'dashboard.home.stats.modules': '';
157
+ readonly 'dashboard.home.stats.modules_delta': '';
158
+ readonly 'dashboard.home.stats.total_users': '';
159
+ readonly 'dashboard.home.stats.total_users_delta_one': '';
160
+ readonly 'dashboard.home.stats.total_users_delta_other': '';
161
+ readonly 'dashboard.home.system_health_alert_one': '';
162
+ readonly 'dashboard.home.system_health_alert_other': '';
163
+ readonly 'dashboard.home.system_health_none': '';
164
+ readonly 'dashboard.home.system_health_ok': '';
165
+ readonly 'dashboard.home.system_info_title': '';
166
+ readonly 'dashboard.home.system_meta': '';
167
+ readonly 'dashboard.home.tile.loaded_degraded': '';
168
+ readonly 'dashboard.home.tile.loaded_healthy': '';
169
+ readonly 'dashboard.home.tile.loaded_no_checks': '';
170
+ readonly 'dashboard.home.tile.loaded_unhealthy': '';
171
+ readonly 'dashboard.home.tile.no_view': '';
172
+ readonly 'dashboard.home.tile.open': '';
173
+ readonly 'dashboard.home.title': '';
174
+ readonly 'dashboard.home.welcome_message': '';
175
+ readonly 'dashboard.nav.dashboard': '';
176
+ readonly 'dashboard.nav.doctor': '';
177
+ readonly 'dashboard.permission_group': '';
178
+ };
179
+
180
+ declare module '@simple-module-py/i18n' {
181
+ interface TranslationResources extends ModuleTranslationResources {}
182
+ }
@@ -1,24 +1,15 @@
1
1
  import { keys, useT } from '@simple-module-py/i18n';
2
2
  import { StatCard } from '@simple-module-py/ui/components/StatCard';
3
+ import { NO_VALUE } from './report';
3
4
  import type { DoctorStats } from './types';
4
5
 
5
- /** Stands in for a figure that has no value, matching `doctor.py`'s NO_VALUE. */
6
- const NO_VALUE = '—';
7
-
8
6
  interface Props {
9
7
  stats: DoctorStats;
10
8
  /** False outside development, where the checks never ran. */
11
9
  available: boolean;
12
10
  }
13
11
 
14
- /**
15
- * The four figures across the top of Doctor.
16
- *
17
- * "Checks passing" is the one that cannot simply render its number: on a
18
- * deployment the checks never ran, and `0 / 8` there reads as every check
19
- * failing — the precise opposite of the truth. It shows a dash instead, and
20
- * says why.
21
- */
12
+ /** Unavailable checks and unknown migration counts display a dash. */
22
13
  export function StatsRow({ stats, available }: Props) {
23
14
  const { t } = useT();
24
15
 
@@ -38,8 +29,8 @@ export function StatsRow({ stats, available }: Props) {
38
29
  <StatCard label={t(keys.dashboard.doctor.stat_modules_loaded)} value={stats.modules_loaded} />
39
30
  <StatCard
40
31
  label={t(keys.dashboard.doctor.stat_pending_migrations)}
41
- value={stats.pending_migrations}
42
- tone={stats.pending_migrations > 0 ? 'warning' : 'default'}
32
+ value={stats.pending_migrations ?? NO_VALUE}
33
+ tone={(stats.pending_migrations ?? 0) > 0 ? 'warning' : 'default'}
43
34
  />
44
35
  <StatCard
45
36
  label={t(keys.dashboard.doctor.stat_python)}
@@ -73,7 +73,6 @@ export function TerminalPanel({ props }: { props: DoctorProps }) {
73
73
  <span
74
74
  // A transcript is an ordered list, and two warnings can legitimately
75
75
  // carry the same text; position is the identity here.
76
- // biome-ignore lint/suspicious/noArrayIndexKey: see above
77
76
  key={index}
78
77
  className={`truncate ${TONE_CLASS[line.tone]}`}
79
78
  >
@@ -1,5 +1,8 @@
1
1
  import type { DoctorProps } from './types';
2
2
 
3
+ /** Placeholder for an unavailable figure, matching Doctor's backend. */
4
+ export const NO_VALUE = '—';
5
+
3
6
  /** Section headings, translated by the caller. */
4
7
  export interface ReportLabels {
5
8
  title: string;
@@ -39,7 +42,7 @@ export function buildDoctorReport(props: DoctorProps, labels: ReportLabels): str
39
42
  const lines: string[] = [
40
43
  labels.title,
41
44
  `${labels.checks}: ${tally} · ` +
42
- `modules ${stats.modules_loaded} · pending migrations ${stats.pending_migrations} · ` +
45
+ `modules ${stats.modules_loaded} · pending migrations ${stats.pending_migrations ?? NO_VALUE} · ` +
43
46
  `python ${stats.python_version}`,
44
47
  '',
45
48
  ];
@@ -46,7 +46,7 @@ export interface DoctorStats {
46
46
  checks_passing: number;
47
47
  checks_total: number;
48
48
  modules_loaded: number;
49
- pending_migrations: number;
49
+ pending_migrations: number | null;
50
50
  python_version: string;
51
51
  }
52
52
 
@@ -7,13 +7,13 @@ from simple_module_db.deps import get_db
7
7
  from simple_module_hosting.permissions import RequiresPermission
8
8
  from sqlalchemy.ext.asyncio import AsyncSession
9
9
 
10
- from dashboard.core.constants import PERM_VIEW
10
+ from dashboard.core.constants import Permissions
11
11
  from dashboard.web.stats import fetch_dashboard_stats
12
12
 
13
13
  router = APIRouter()
14
14
 
15
15
 
16
- @router.get("/stats", dependencies=[Depends(RequiresPermission(PERM_VIEW))])
16
+ @router.get("/stats", dependencies=[Depends(RequiresPermission(Permissions.VIEW))])
17
17
  async def dashboard_stats(request: Request, db: AsyncSession = Depends(get_db)) -> dict:
18
18
  """Platform-wide statistics: user counts across every tenant and system info.
19
19
 
@@ -18,7 +18,7 @@ from simple_module_inertia import InertiaResponse
18
18
  from sqlalchemy.ext.asyncio import AsyncSession
19
19
  from starlette.responses import RedirectResponse
20
20
 
21
- from dashboard.core.constants import PERM_VIEW
21
+ from dashboard.core.constants import Permissions
22
22
  from dashboard.web.stats import fetch_dashboard_stats
23
23
 
24
24
  router = APIRouter()
@@ -56,7 +56,7 @@ async def dashboard(
56
56
  without it gets the welcome and no numbers (``can_view_stats`` false).
57
57
  """
58
58
  props: dict = {"welcome": t.t("dashboard.home.welcome_message")}
59
- can_view = grants(resolved_permissions_for(request), PERM_VIEW)
59
+ can_view = grants(resolved_permissions_for(request), Permissions.VIEW)
60
60
  props["can_view_stats"] = can_view
61
61
  if can_view:
62
62
  props.update(await fetch_dashboard_stats(db, request.app))
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@simple-module-py/dashboard",
3
+ "private": true,
4
+ "dependencies": {
5
+ "lucide-react": "^1.43.0"
6
+ }
7
+ }
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "simple_module_dashboard"
3
- version = "0.0.47"
3
+ version = "0.0.49"
4
4
  description = "Admin landing page and sidebar menu host for authenticated users of a simple_module app"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -21,9 +21,9 @@ classifiers = [
21
21
  "Typing :: Typed",
22
22
  ]
23
23
  dependencies = [
24
- "simple_module_core==0.0.47",
25
- "simple_module_db==0.0.47",
26
- "simple_module_hosting==0.0.47",
24
+ "simple_module_core==0.0.49",
25
+ "simple_module_db==0.0.49",
26
+ "simple_module_hosting==0.0.49",
27
27
  ]
28
28
 
29
29
  [project.entry-points.simple_module]
@@ -77,12 +77,18 @@ describe('StatsRow', () => {
77
77
  expect(card.getByText('not available')).toBeInTheDocument();
78
78
  });
79
79
 
80
- test('the other three figures are real either way', () => {
80
+ test('shows the module count and Python version when checks are unavailable', () => {
81
81
  render(<StatsRow stats={STATS} available={false} />);
82
82
 
83
83
  expect(screen.getByText('12')).toBeInTheDocument();
84
84
  expect(screen.getByText('3.12.4')).toBeInTheDocument();
85
85
  });
86
+
87
+ test('shows a dash when the pending migration count is unknown', () => {
88
+ render(<StatsRow stats={{ ...STATS, pending_migrations: null }} available={true} />);
89
+
90
+ expect(screen.getByText('—')).toBeInTheDocument();
91
+ });
86
92
  });
87
93
 
88
94
  describe('buildDoctorReport', () => {
@@ -109,4 +115,13 @@ describe('buildDoctorReport', () => {
109
115
  expect(report).toContain('a3f1beef [users] add invite table — applied');
110
116
  expect(report).toContain('vite :5050');
111
117
  });
118
+
119
+ test('shows a dash when the pending migration count is unknown', () => {
120
+ const report = buildDoctorReport(
121
+ { ...PROPS, stats: { ...STATS, pending_migrations: null } },
122
+ LABELS,
123
+ );
124
+
125
+ expect(report).toContain('pending migrations —');
126
+ });
112
127
  });
@@ -1,4 +0,0 @@
1
- """Stable identifiers for the dashboard module."""
2
-
3
- PERM_VIEW = "dashboard.view"
4
- PERM_GROUP = "Dashboard"
@@ -1,81 +0,0 @@
1
- """Dashboard module definition."""
2
-
3
- from __future__ import annotations
4
-
5
- import importlib.resources
6
- from pathlib import Path
7
-
8
- from fastapi import APIRouter
9
- from simple_module_core.menu import MenuItem, MenuRegistry, MenuSection
10
- from simple_module_core.module import ModuleBase, ModuleMeta
11
- from simple_module_core.permissions import PermissionRegistry
12
-
13
- from dashboard.core.constants import PERM_GROUP, PERM_VIEW
14
-
15
- _URL_DASHBOARD = "/dashboard/"
16
- _URL_DOCTOR = "/admin/doctor/"
17
- _ICON_DASHBOARD = "home"
18
- _ICON_DOCTOR = "stethoscope"
19
-
20
-
21
- class DashboardModule(ModuleBase):
22
- meta = ModuleMeta(
23
- name="Dashboard",
24
- route_prefix="/api/dashboard",
25
- view_prefix="/dashboard",
26
- # The dashboard itself is an app screen; Doctor is an admin one.
27
- admin_view_prefix="/admin/doctor",
28
- i18n_audience="admin",
29
- )
30
-
31
- def register_routes(self, api_router: APIRouter, view_router: APIRouter) -> None:
32
- from dashboard.web.endpoints.api import router as api
33
- from dashboard.web.endpoints.views import router as views
34
-
35
- api_router.include_router(api)
36
- view_router.include_router(views)
37
-
38
- def register_admin_routes(self, admin_router: APIRouter) -> None:
39
- from dashboard.web.endpoints.views import admin_router as doctor_views
40
-
41
- admin_router.include_router(doctor_views)
42
-
43
- def register_permissions(self, registry: PermissionRegistry) -> None:
44
- # Administrative data (user counts, installed modules, system info):
45
- # ``admin`` holds it through ``*`` and no other role is mapped — not
46
- # even ``user`` on a single-tenant install, or any self-registered
47
- # account could read it (#464). Grant it to a role in the role editor.
48
- registry.add_group(
49
- PERM_GROUP,
50
- [PERM_VIEW],
51
- label_key="dashboard.permission_group",
52
- )
53
-
54
- def register_menu_items(self, registry: MenuRegistry) -> None:
55
- registry.add(
56
- MenuItem(
57
- label="Dashboard",
58
- label_key="dashboard.nav.dashboard",
59
- url=_URL_DASHBOARD,
60
- icon=_ICON_DASHBOARD,
61
- order=10,
62
- section=MenuSection.SIDEBAR,
63
- )
64
- )
65
- registry.add(
66
- MenuItem(
67
- label="Doctor",
68
- label_key="dashboard.nav.doctor",
69
- url=_URL_DOCTOR,
70
- icon=_ICON_DOCTOR,
71
- order=220,
72
- section=MenuSection.ADMIN_SIDEBAR,
73
- group="System",
74
- # Mirrors the view route's admin-only guard — without it the
75
- # entry shows for every signed-in account and 403s on click.
76
- roles=["admin"],
77
- )
78
- )
79
-
80
- def locale_dirs(self) -> dict[str, Path]:
81
- return {"dashboard": Path(str(importlib.resources.files(__package__) / "locales"))}
@@ -1,18 +0,0 @@
1
- {
2
- "name": "@simple-module-py/dashboard",
3
- "version": "0.0.47",
4
- "private": true,
5
- "description": "Frontend assets for the Dashboard module",
6
- "peerDependencies": {
7
- "@inertiajs/react": "^3.11.0",
8
- "@simple-module-py/ui": "*",
9
- "react": "^19.0.0",
10
- "react-dom": "^19.3.1"
11
- },
12
- "devDependencies": {
13
- "@simple-module-py/tsconfig": "*"
14
- },
15
- "dependencies": {
16
- "lucide-react": "^1.43.0"
17
- }
18
- }
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@simple-module-py/tsconfig/base.json",
3
- "compilerOptions": {
4
- "paths": {
5
- "@/*": ["./dashboard/*"],
6
- "@simple-module-py/ui/*": ["../../packages/ui/src/*"]
7
- }
8
- },
9
- "include": ["dashboard/**/*.ts", "dashboard/**/*.tsx", "tests-js/**/*.ts", "tests-js/**/*.tsx"]
10
- }