Skip to content

Conversation

@Hubert-Szczepanski-SAP
Copy link
Contributor

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

@andreaskienle andreaskienle requested a review from Copilot October 31, 2025 12:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors project deletion and creation logic by extracting them into custom hooks (useDeleteProject and useCreateProject). The refactoring improves testability by allowing dependency injection of hooks in components.

  • Extracted project deletion logic into useDeleteProject hook
  • Extracted project creation logic into useCreateProject hook
  • Updated components to use the new hooks with optional parameters for testing

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/hooks/useDeleteProject.ts New hook that encapsulates project deletion logic
src/hooks/useDeleteProject.spec.ts Unit tests for the delete project hook
src/hooks/useCreateProject.ts New hook that encapsulates project creation logic
src/hooks/useCreateProject.spec.ts Unit tests for the create project hook
src/components/Projects/ProjectsListItemMenu.tsx Refactored to use useDeleteProject hook with dependency injection
src/components/Projects/ProjectsListItemMenu.cy.tsx Component test for delete functionality
src/components/Dialogs/CreateProjectDialogContainer.tsx Refactored to use useCreateProject hook with dependency injection
src/components/Dialogs/CreateProjectDialogContainer.cy.tsx Component test for create functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const { t } = useTranslation();
const toast = useToast();

const { trigger } = useApiResourceMutation<DeleteWorkspaceType>(DeleteProjectResource(projectName));
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

Type mismatch: DeleteProjectResource is used with the generic type DeleteWorkspaceType, which has properties name and namespace for workspaces. Since this is for deleting projects (not workspaces), the type should be aligned with the project deletion resource or use a more appropriate type.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

The old coding used the same data structure. We’ll rework the types with the move to GraphQL

@andreaskienle andreaskienle self-assigned this Oct 31, 2025
Copy link
Contributor

@andreaskienle andreaskienle left a comment

Choose a reason for hiding this comment

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

Check out CoPilot's comment but I think we're good.

Even added some tests for the not-so-straightforward case, nice 👍🏻

@Hubert-Szczepanski-SAP Hubert-Szczepanski-SAP merged commit 1b5dbf0 into main Oct 31, 2025
11 checks passed
@Hubert-Szczepanski-SAP Hubert-Szczepanski-SAP deleted the test/create-delete-projects branch October 31, 2025 13:18
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.

3 participants