← Back to Pull requests

[AAP-88658] XLAB Implementing user rights #3630

Closed
unknown closed this pull request without merging on Sep 30, 2026 13:38 UTC
View on GitHub
unknown unknown commented on Sep 23, 2026 12:12 UTC
Author

Summary


AAP-88658 Implementing user rights
<!-- What changed and why? -->
This pull request refactors the AutomationDashboardMainPage to handle access and visibility for the Dashboard and Leaderboards tabs based on user permissions and server-side flags. It also updates the documentation to explain the new logic, improves test coverage for different access scenarios, and clarifies the data flow for the Leaderboards tab.

Access control and rendering logic:

  • AutomationDashboardMainPage.tsx now renders the Dashboard, Leaderboards, both (with tabs), or an error/unauthorized state based on canSeeDashboard, canSeeLeaderboard, and error from useAutomationDashboardCollectionStatus. Tabs are only shown if both are visible; otherwise, the appropriate single view or state is rendered. [[1]](diffhunk://#diff-315fa004ee04f4fe2afcc6648ec5b6c6f643a3a95f5cdedba1e3bf8987dc576bR7-L29) [[2]](diffhunk://#diff-315fa004ee04f4fe2afcc6648ec5b6c6f643a3a95f5cdedba1e3bf8987dc576bL46-R94)
  • Testing improvements:

  • The test file AutomationDashboardMainPage.test.tsx is refactored to use a new mockStatus helper, and now includes comprehensive tests for all combinations of dashboard/leaderboard visibility and error states. [[1]](diffhunk://#diff-c65a1d5f6f2fefcdb13db356b4040d44b5dedf58c30fec156435d274fe5d885aL1-R10) [[2]](diffhunk://#diff-c65a1d5f6f2fefcdb13db356b4040d44b5dedf58c30fec156435d274fe5d885aR40-R76) [[3]](diffhunk://#diff-c65a1d5f6f2fefcdb13db356b4040d44b5dedf58c30fec156435d274fe5d885aL83-R158)
  • Documentation updates:

  • The README.md is extensively updated to document the new access and visibility logic, including a new "Access and visibility" section, updated architecture diagrams, and an explanation of how navigation and page rendering respond to user roles and server flags. [[1]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L11-R17) [[2]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9R30-R33) [[3]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L47-R56) [[4]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L69-R75) [[5]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L94-R148) [[6]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L116-R159) [[7]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L137-R189) [[8]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L228-R284) [[9]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L264-R324) [[10]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L292-R355)
  • Data flow and API integration:

  • Documentation and code are updated to reflect that the Leaderboards tab now consumes data from /dashboard_reports/leaderboard/ via SWR, and the hook useAutomationLeaderboardsView is wired to the real API. [[1]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L47-R56) [[2]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L69-R75) [[3]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L228-R284)
  • Codebase organization:

  • New and updated comments clarify the role of utility files like applyAutomationDashboardNavVisibility and how navigation visibility is managed. [[1]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9R30-R33) [[2]](diffhunk://#diff-6f4f55dd8574088afadae79d9faed42ebaebb4949ede2d43a07e8a453f566eb9L264-R324)
  • These changes ensure that the dashboard UI accurately reflects user permissions and server configuration, provide robust test coverage for all access scenarios, and keep the documentation in sync with the implementation.

    Type of Change

  • Bug fix

  • Enhancement

  • Tests

  • Documentation

  • Other (please specify)
  • Risk Analysis - REQUIRED

    <!-- SELECT ONE. This is required — the PR check will fail if none is selected. -->

  • High — Broad platform impact (e.g., SWR config, shared framework components, authentication, routing, API wrappers, build/bundler config). Changes affect multiple workspaces or could cause widespread regressions.

  • Medium — Scoped but cross-cutting (e.g., shared utility functions, changes to multiple pages within one workspace, component library updates, test infrastructure). Limited blast radius but touches common code paths.

  • Low — Narrowly scoped (e.g., single page fix, styling tweak, documentation, test-only changes, copy/string updates). Minimal risk of unintended side effects.
  • Dependencies

    <!-- List any dependent PRs, required backend changes, or manual setup steps. Remove this section if none. -->

    Testing

    Ephemeral E2E Tests

    Once PR is ready and preliminary checks pass, trigger tests by posting a comment /run-playwright on this PR.

    Tests run against a fresh AAP instance (version based on branch).

    External Server E2E Runs

    <!-- If applicable, attach run(s) from an external server using the GitHub Actions below. Mention the deployment type of the environment used.

  • [Run Playwright with Currents](../actions/workflows/run-playwright-currents.yml)

  • -->

    Manual Testing

    Tip: to change show_dashboard / show_gamification / enabled, override the
    /api/metrics/v1/dashboard_reports/collection_status/ response (e.g. Chrome DevTools → Network → Override content).

    Platform build (Automation Analytics → Automation Dashboard)

    Dashboard / Leaderboards visibility

  • Superuser, show_dashboard: true, show_gamification: true: verify both Dashboard and Leaderboards tabs are shown.

  • Superuser, show_dashboard: true, show_gamification: false: verify only the Dashboard content is shown, with no tabs. Open .../automation-dashboard/leaderboards directly and verify it does not render the Leaderboards.

  • Superuser, show_dashboard: false, show_gamification: true: verify only the Leaderboards content is shown, with no tabs. Open .../automation-dashboard/dashboard directly and verify it does not render the Dashboard.

  • System auditor: repeat the three cases above and verify the same behaviour as a superuser.

  • Regular user (not superuser or auditor), both flags true: verify only the Leaderboards content is shown. The Dashboard requires superuser or auditor.

  • Regular user, show_gamification: false: verify the Automation Dashboard nav entry is hidden.

  • Any user, both flags false: verify the Automation Dashboard nav entry is hidden.
  • Navigation

  • Non-superuser: verify Automation Analytics shows only the Automation Dashboard entry (no Automation Calculator, Host Metrics, or Subscription Usage).

  • enabled: false: verify the Automation Dashboard entry is removed from the nav.

  • If Automation Analytics ends up with no entries, verify the whole group is hidden (no empty "Automation Analytics" link).
  • Error handling

  • Make collection_status return 500 on first load. Verify the nav entry stays and the page shows the error state instead of disappearing.

  • Let the page load, then make one poll fail. Verify the page and nav keep showing the last good data (no flicker or unmount).

  • Make collection_status return 401 (or let the session expire). Verify the login screen appears right away, not up to 10 s later.
  • <!-- Steps to verify this change, if not obvious from the Jira issue. -->

    Screenshots

    <!-- If applicable. Any visual/UI changes MUST include before and after screenshots. -->
    <img width="1465" height="715" alt="image" src="https://github.com/user-attachments/assets/7ed80e5a-82be-4ee2-abcd-9162ad902fb9" />

    <img width="1465" height="715" alt="image" src="https://github.com/user-attachments/assets/92f262e3-58fd-420b-82c7-c69965c322cb" />

    <img width="1465" height="715" alt="image" src="https://github.com/user-attachments/assets/520f7687-d361-4210-ad0e-7184698734af" />

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: lgalis Review duration: 10165m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3630"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%