Skip to content

feat: renomear pastas e arquivos (LUI-180) - #15

Merged
argentinaluiz merged 4 commits into
mainfrom
feature/lui-180-renomear-pastas-e-arquivos
Oct 16, 2026
Merged

argentinaluiz merged 4 commits into
mainfrom
feature/lui-180-renomear-pastas-e-arquivos

Conversation

@argentinaluiz

Copy link
Copy Markdown
Contributor

O que muda

PATCH /items/{id} renomeia uma pasta ou um arquivo ativo do Usuário (só o name nesta entrega). A Pasta raiz é recusada com validation_error, e o que o Usuário não enxerga responde not_found. Na web, a linha de pasta ganha o "Mais ações" e as duas linhas ganham "Renomear", com um diálogo que abre com o nome atual todo selecionado.

Fora do plano: MenuItem ganhou closeOnClick, e OpenableRow ignora o duplo clique que vem de botão, menu ou diálogo.

Aceite

docs/tickets/LUI-177/LUI-180/aceite.md

🤖 Generated with Claude Code

argentinaluiz and others added 2 commits October 15, 2026 20:27
Acceptance file docs/tickets/LUI-177/LUI-180/aceite.md (CA1-CA9). The OpenAPI snapshot gains PATCH /items/{id} (UpdateItemDto with only name, 200 ItemDto) and the UpdateItemDto schema; no table changes.

Decision: the route is the LLD's PATCH /items/{id}, with only name in this delivery. name is required now, and LUI-181 relaxes it to name and/or parentId, a change that breaks no client. A body with no field is therefore validation_error, as the ticket asks.

Decision: renaming the root folder answers validation_error, and not_found stays for what the User cannot see (missing, another User's, pending, not a UUID). The root's name is fixed, so the request is invalid input, and no new error code is needed. The root alias is accepted in the path, as in GET /items/{id}, and leads to the same refusal.

Decision: the rename takes no advisory lock, because it changes neither the depth nor the shape of the tree; only the move (LUI-181) needs it.

Decision: the name rules are shared with the folder creation (trimmed ends, 1 to 255 characters measured after the trim, no "/" or control characters), by extracting the name decorators the CreateFolderDto uses, so the two routes never drift apart.

Decision: the download needs no change, because downloadUrl reads the name from the item row at each call, so CA5 is proved by a test only.

Decision: the row menu moves to a client component that owns the rename dialog, because the Menu unmounts its items when it closes and would take the dialog with it. The folder row gains the "Mais ações" button, with "Renomear" only; "Mover para…" comes with LUI-181 and "Excluir" with the trash.

Files and interfaces the implementation will touch:
- apps/api/src/modules/items: ItemsController.update (PATCH :id), ItemsService.rename and ItemsRepository.rename (reads the active item of the owner, refuses the root, updates the name); dto/update-item.dto.ts; the name decorators extracted from dto/create-folder.dto.ts.
- apps/api/openapi.json: regenerated from the controller and the DTO; it must match the snapshot of this plan.
- apps/api/test: items-rename.e2e-spec.ts and the rename call in support/items.ts.
- apps/web: updateItem in lib/api/items.ts and its input type in lib/api/types.ts, renameItem in lib/dal/items.ts, the renameItem Server Action in app/(drive)/actions.ts, components/files/row-actions.tsx (menu and dialog) and rename-dialog.tsx, used by file-row.tsx.
- apps/web/e2e: rename.spec.ts.
- docs/lld.md: section 3.3 (the PATCH route with only the name for now) and the web section that says the folder row has no "Mais ações" button.

Existing tests whose behavior changes: none.

Data changes: none.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
PATCH /items/{id} changes the name of an active item of the User. The root
folder is refused with validation_error and anything the User cannot see is
not_found. The row menu gains "Renomear" on files and folders, with a dialog
that opens with the current name fully selected.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 15, 2026 23:58

Copilot AI 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.

🟡 Changes recommended

Há problemas pendentes de atomicidade na persistência e de atualização/composição da interface.

2 open findings
What changed in this PR

Implementa a renomeação de arquivos e pastas via API e interface web.

Changes:

  • Adiciona PATCH /items/{id}, validações e testes E2E.
  • Adiciona menus, diálogo e Server Action de renomeação.
  • Atualiza documentação e contrato OpenAPI.
File Description
docs/​tickets/​LUI-177/​LUI-180/​aceite.md Critérios de aceite
docs/​lld.md Contrato funcional atualizado
apps/​web/​lib/​dal/​items.ts DAL de renomeação
apps/​web/​lib/​api/​types.ts Tipos da atualização
apps/​web/​lib/​api/​items.ts Cliente da API
apps/​web/​e2e/​rename.spec.ts Testes Playwright
apps/​web/​components/​ui/​menu.tsx Fechamento configurável do menu
apps/​web/​components/​files/​row-actions.tsx Ações da linha
apps/​web/​components/​files/​rename-dialog.tsx Diálogo de renomeação; requer atualização das páginas carregadas
apps/​web/​components/​files/​openable-row.tsx Filtragem de duplo clique em controles
apps/​web/​components/​files/​file-row.tsx Integração das ações; requer suporte à vitrine
apps/​web/​app/​(drive)/​actions.ts Server Action e validações
apps/​api/​test/​support/​items.ts Helper HTTP
apps/​api/​test/​items-rename.e2e-spec.ts Testes E2E da API
apps/​api/​src/​modules/​items/​items.service.ts Regras de negócio
apps/​api/​src/​modules/​items/​items.repository.ts Persistência; requer atualização atômica
apps/​api/​src/​modules/​items/​items.controller.ts Endpoint PATCH
apps/​api/​src/​modules/​items/​entities/​item.entity.ts Resultado da renomeação
apps/​api/​src/​modules/​items/​dto/​update-item.dto.ts DTO da requisição
apps/​api/​openapi.json Contrato OpenAPI

🧠 Review effort: Lite


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/api/src/modules/items/items.repository.ts Outdated
Comment thread apps/web/components/files/rename-dialog.tsx
argentinaluiz and others added 2 commits October 16, 2026 01:56
…UI-180)

O renomear lia e gravava em operações separadas, deixando uma janela em
que o item podia mudar de estado. Agora é um UPDATE condicional, e só
sem linha afetada a leitura distingue Pasta raiz de not_found.

O router.refresh() só refaz a primeira página, então a linha vinda de
"Carregar mais" ficava com o nome antigo. O LoadMoreProvider ganhou
reset(), chamado pelo diálogo de renomear.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@argentinaluiz
argentinaluiz merged commit 58de801 into main Oct 16, 2026
2 checks passed
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.

2 participants