Skip to content

Feature/permission users phases btn#409

Open
Junior-Shyko wants to merge 6 commits into
developfrom
feature/permission-users-phases-btn
Open

Feature/permission users phases btn#409
Junior-Shyko wants to merge 6 commits into
developfrom
feature/permission-users-phases-btn

Conversation

@Junior-Shyko

@Junior-Shyko Junior-Shyko commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

✅ Descrição do propósito desse Pull Request

Validando permissao para TRAMITAR e DEVOLVER no backend

🧭 Referência a Issue

#400

❓ O que foi feito para atingir isso?


🏃‍♀️ Tipo de mudança

Marque as opções relevantes:

  • Bug fix (correção de bug)
  • Nova feature (mudança não retrocompatível que adiciona funcionalidade)
  • Mudança de breaking (correção ou feature que faria com que a funcionalidade existente não funcionasse como esperado)
  • Documentação (somente mudanças ou atualizações na documentação)

🕵️ Como foi testado?

  • Critério de aceitação
  • Testes de software (TDD, BDD, UNITÁRIO, INTEGRAÇÃO, E2E)

Checklist: ✔️

  • Meu código segue as diretrizes do projeto
  • Eu fiz um code review com minha equipe
  • Eu comentei meu código, especialmente em áreas de difícil entendimento
  • Eu atualizei a documentação correspondente
  • Testes novos e existentes passaram localmente com minhas alterações

Observação:

Summary by CodeRabbit

  • New Features

    • Project stage actions now consistently reflect the user’s permissions.
    • Added clearer controls for advancing, returning, and handling the current project stage.
    • Users receive specific error messages when they cannot advance a stage or when the stage is not ready.
  • Bug Fixes

    • Prevented unauthorized stage actions from appearing available.
    • Standardized permission behavior across project workflow tabs.

@coderabbitai

coderabbitai Bot commented Jul 17, 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 59dc6e49-6f2a-4b31-bbea-08f7059ed23d

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 feature/permission-users-phases-btn

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
resources/js/Pages/ProjectDetails/Partials/Tabs/OpeningTab.vue (1)

60-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use computed() for stage to match sibling tabs.

stage is declared as a plain const (line 62), while LegalAnalysisTab, FormalizationTab, and BudgetTab all use computed(() => ...) for the same pattern. This inconsistency could cause stale data if props.project.stages changes without a full component remount.

♻️ Proposed fix
-const stage = props.project.stages?.find((s) => s.slug === STAGE_SLUG);
+const stage = computed(() => props.project.stages?.find((s) => s.slug === STAGE_SLUG));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@resources/js/Pages/ProjectDetails/Partials/Tabs/OpeningTab.vue` around lines
60 - 64, Update the stage lookup in OpeningTab around STAGE_SLUG and stage to
use computed(), matching the reactive pattern in the sibling tabs, while
preserving the existing slug-based search and stage value usage.
app/Http/Controllers/ProjectStageController.php (1)

50-52: 🩺 Stability & Availability | 🔵 Trivial

Avoid reporting routine authorization denials as Sentry exceptions.

AuthorizationException is an expected permission-failure path from app/Services/ProjectStageService.php, Lines 151-156. Capturing every denied transition can flood Sentry and obscure actionable failures; prefer an audit/metric event or configure this exception class to be filtered before capture.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/Http/Controllers/ProjectStageController.php` around lines 50 - 52, Update
the AuthorizationException catch block in ProjectStageController so routine
permission denials are not sent to Sentry via captureException. Replace that
reporting with the existing audit or metric mechanism, or filter
AuthorizationException from Sentry while preserving the current
authorization-failure response behavior.
tests/Feature/ProjectStageControllerTest.php (1)

235-246: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Assert that failed validation leaves each stage unchanged.

These tests verify the error text but not state preservation. Capture the initial status before the request and assert it after the response so a partial stage transition cannot regress unnoticed.

Suggested assertions
 $stage = $project->stages()
     ->where('slug', ProjectStageSlug::ANALISE_JURIDICA->value)
     ->firstOrFail();
+ $initialStatus = $stage->status;

 ...
 ->assertSessionHasErrors(['message' => 'A etapa precisa estar em andamento para ser aprovada.']);
+
+ $this->assertEquals($initialStatus, $stage->fresh()->status);

Apply the same assertion to both tests.

Also applies to: 248-259

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/Feature/ProjectStageControllerTest.php` around lines 235 - 246, Update
both stage-advance tests, including
test_advance_returns_specific_message_when_stage_not_em_andamento, to capture
each relevant stage’s status before the PATCH request and assert afterward that
the status is unchanged. Keep the existing validation-message assertions and
apply the state-preservation check to every stage covered by these tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/Services/ProjectStageService.php`:
- Around line 116-119: Update returnStage so the
ProjectStageStatus::EM_ANDAMENTO validation occurs before ensureUserHasRole.
Preserve both existing validations and their exception messages, matching the
ordering used by advance and reject.

---

Nitpick comments:
In `@app/Http/Controllers/ProjectStageController.php`:
- Around line 50-52: Update the AuthorizationException catch block in
ProjectStageController so routine permission denials are not sent to Sentry via
captureException. Replace that reporting with the existing audit or metric
mechanism, or filter AuthorizationException from Sentry while preserving the
current authorization-failure response behavior.

In `@resources/js/Pages/ProjectDetails/Partials/Tabs/OpeningTab.vue`:
- Around line 60-64: Update the stage lookup in OpeningTab around STAGE_SLUG and
stage to use computed(), matching the reactive pattern in the sibling tabs,
while preserving the existing slug-based search and stage value usage.

In `@tests/Feature/ProjectStageControllerTest.php`:
- Around line 235-246: Update both stage-advance tests, including
test_advance_returns_specific_message_when_stage_not_em_andamento, to capture
each relevant stage’s status before the PATCH request and assert afterward that
the status is unchanged. Keep the existing validation-message assertions and
apply the state-preservation check to every stage covered by these tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5306c8ab-12f7-43b1-9a76-381c1e10165f

📥 Commits

Reviewing files that changed from the base of the PR and between c8d7080 and 5b4ed1d.

📒 Files selected for processing (14)
  • app/Http/Controllers/ProjectController.php
  • app/Http/Controllers/ProjectStageController.php
  • app/Services/ProjectStageService.php
  • resources/js/Composables/useStageAdvance.js
  • resources/js/Pages/ProjectDetails/Index.vue
  • resources/js/Pages/ProjectDetails/Partials/ProcessTabs.vue
  • resources/js/Pages/ProjectDetails/Partials/Tabs/BudgetTab.vue
  • resources/js/Pages/ProjectDetails/Partials/Tabs/FormalizationTab.vue
  • resources/js/Pages/ProjectDetails/Partials/Tabs/LegalAnalysisTab.vue
  • resources/js/Pages/ProjectDetails/Partials/Tabs/MonitoringTab.vue
  • resources/js/Pages/ProjectDetails/Partials/Tabs/OpeningTab.vue
  • resources/js/Pages/ProjectDetails/Partials/Tabs/PaymentTab.vue
  • tests/Feature/ProjectControllerTest.php
  • tests/Feature/ProjectStageControllerTest.php

Comment thread app/Services/ProjectStageService.php Outdated
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