Skip to content

[US-2.3 / OBT-202] Confirm with usage stats before deactivating a language - #27

Open
levigtri wants to merge 2 commits into
levigft/obt-199-us-12-click-on-a-language-card-and-edit-its-name-or-code-infrom
levigft/obt-202-us-23-see-a-confirmation-dialog-with-usage-statistics-before
Open

[US-2.3 / OBT-202] Confirm with usage stats before deactivating a language#27
levigtri wants to merge 2 commits into
levigft/obt-199-us-12-click-on-a-language-card-and-edit-its-name-or-code-infrom
levigft/obt-202-us-23-see-a-confirmation-dialog-with-usage-statistics-before

Conversation

@levigtri

@levigtri levigtri commented Jul 5, 2026

Copy link
Copy Markdown
Member

Summary

Adds a deactivate affordance to language cards with a confirmation dialog that lists the projects using the language (name + count) and blocks deactivation while any project still uses it — for everyone, matching the backend rule (US-2.1 returns 409). The trash affordance follows the role hierarchy: a platform admin sees it on every language, a manager only on languages they created.

This branch was rebased onto origin/main so it is independent of US-1.2 (previously stacked) — it now contains only the US-2.3 changes and can be merged in any order.

Changes

  1. Deactivate affordance (role-gated)src/components/pages/LanguagesPage.tsx: hover trash shown when isPlatformAdmin || (isManager && lang.created_by === user.id).
  2. Usage-aware confirm dialog — same file: on open, fetches languagesAPI.stats; when project_count > 0 it lists the project names and disables the Deactivate button (blocked); when 0 it confirms a normal soft-delete via languagesAPI.delete. Surfaces backend 409/403 as toasts.
  3. API + typessrc/services/api.ts (languagesAPI.stats, languagesAPI.delete), src/types/language.ts (created_by on LanguageResponse; new LanguageProjectRef, LanguageStatsResponse), reexported in src/types/index.ts.

Type of Change

  • Feature / behavior change
  • Breaking change

Testing

  • npm run typecheck / npm run lint (0 errors, only the pre-existing ProjectsPage.tsx warning) / npm run build — all pass.
  • Manual: deactivate a language used by projects → dialog lists them and the button is disabled; unused language → deactivates; as a manager the trash only appears on languages you created.

Add a role-gated deactivate affordance to language cards and a confirmation
dialog that lists the projects using the language and blocks deactivation
while any project still uses it (matching the backend 409). The trash is
shown to platform admins on every language and to managers only on
languages they created.

- languagesAPI.stats / languagesAPI.delete
- LanguageResponse.created_by; LanguageProjectRef / LanguageStatsResponse
- confirm dialog lists affected projects and disables Deactivate when in use
@levigtri
levigtri force-pushed the levigft/obt-202-us-23-see-a-confirmation-dialog-with-usage-statistics-before branch from fcc9109 to 7a85ad6 Compare July 9, 2026 18:05
@levigtri
levigtri force-pushed the levigft/obt-199-us-12-click-on-a-language-card-and-edit-its-name-or-code-in branch from b6cff54 to 6e69ffc Compare July 9, 2026 18:24
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Pro Plus

Run ID: a32e8009-a1b1-4cc9-a914-c5a51911ab44

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch levigft/obt-202-us-23-see-a-confirmation-dialog-with-usage-statistics-before

Comment @coderabbitai help to get the list of available commands.

@levigtri levigtri self-assigned this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant