Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(platform): Implement delete project #671

Merged
merged 4 commits into from
Jan 28, 2025
Merged

Conversation

kriptonian1
Copy link
Contributor

@kriptonian1 kriptonian1 commented Jan 28, 2025

User description

Description

This pull request introduces several changes to the apps/platform project, focusing on adding a delete project feature, improving the layout, and optimizing project fetching. The most important changes include the addition of a delete project confirmation dialog, updates to the project card component to support project deletion, and the use of useCallback for fetching projects.

Delete Project Feature:

  • New Component: Added ConfirmDeleteProject component to handle project deletion confirmation (apps/platform/src/components/dashboard/project/confirmDeleteProject/index.tsx).
  • Project Card: Updated ProjectCard to include delete project functionality and handle the delete project dialog (apps/platform/src/components/dashboard/project/projectCard/index.tsx). [1] [2] [3] [4]

Layout Improvements:

  • Navbar and Sidebar Layout: Improved the layout structure by reordering class names for better readability and consistency (apps/platform/src/app/(main)/layout.tsx). [1] [2]

Project Fetch Optimization:

  • useCallback: Refactored project fetching logic to use useCallback for better performance and cleaner code (apps/platform/src/app/(main)/page.tsx). [1] [2]
  • Delete Project Dialog: Integrated ConfirmDeleteProject into the main page to handle project deletion (apps/platform/src/app/(main)/page.tsx). [1] [2]

Fixes #657

Mentions

@rajdip-b @poswalsameer

Screenshots of relevant screens

Screen.Recording.2025-01-28.at.12.33.02.PM.mov

Developer's checklist

  • My PR follows the style guidelines of this project
  • I have performed a self-check on my work

If changes are made in the code:

  • I have followed the coding guidelines
  • My changes in code generate no new warnings
  • My changes are breaking another fix/feature of the project
  • I have added test cases to show that my feature works
  • I have added relevant screenshots in my PR
  • There are no UI/UX issues

Documentation Update

  • This PR requires an update to the documentation at docs.keyshade.xyz
  • I have made the necessary updates to the documentation, or no documentation changes are required.

PR Type

Enhancement


Description

  • Added a delete project feature with confirmation dialog.

  • Refactored layout structure for improved readability.

  • Introduced useCallback for optimized project fetching.

  • Updated project card to support project deletion.


Changes walkthrough 📝

Relevant files
Enhancement
layout.tsx
Refactor layout structure for readability                               

apps/platform/src/app/(main)/layout.tsx

  • Refactored layout structure for better readability.
  • Adjusted class names and indentation.
  • +4/-6     
    page.tsx
    Add delete project logic and optimize fetching                     

    apps/platform/src/app/(main)/page.tsx

  • Added useCallback for fetching projects.
  • Integrated delete project confirmation dialog.
  • Improved project fetching logic with error handling.
  • +37/-30 
    index.tsx
    Add delete project confirmation component                               

    apps/platform/src/components/dashboard/project/confirmDeleteProject/index.tsx

  • Added new component for delete project confirmation.
  • Implemented toast messages for success and error states.
  • Integrated project deletion API call.
  • +133/-0 
    index.tsx
    Add delete functionality to project card                                 

    apps/platform/src/components/dashboard/project/projectCard/index.tsx

  • Updated project card to include delete functionality.
  • Added context menu option for project deletion.
  • Integrated project selection for deletion.
  • +18/-5   

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    codiumai-pr-agent-free bot commented Jan 28, 2025

    CI Feedback 🧐

    (Feedback updated until commit e1a79c0)

    A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

    Action: Validate PR title

    Failed stage: Lint PR [❌]

    Failed test name: Validate PR title

    Failure summary:

    The action failed because the PR title doesn't follow the semantic versioning convention. The title
    uses "Feat" but it should be "feat" (lowercase) according to conventional commits format. The
    correct format should be: "feat(platform): Implement delete project"

    Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    35:  Download action repository 'amannn/action-semantic-pull-request@v5' (SHA:0723387faaf9b38adef4775cd42cfd5155ed6017)
    36:  Complete job name: Validate PR title
    37:  ##[group]Run amannn/action-semantic-pull-request@v5
    38:  with:
    39:  githubBaseUrl: https://api.github.com
    40:  env:
    41:  GITHUB_TOKEN: ***
    42:  ##[endgroup]
    43:  ##[error]Unknown release type "Feat" found in pull request title "Feat(platform): Implement delete project". 
    

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    657 - PR Code Verified

    Compliant requirements:

    • Add ability to delete a project from the platform
    • Show toast messages for success/error states

    Requires further human verification:

    • Verify that UI matches Figma design
    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Error Handling

    The delete project function continues execution even after showing error toast. Should return early after error to prevent further execution.

    if (error) {
      toast.error('Something went wrong!', {
        description: (
          <p className="text-xs text-red-300">
            Something went wrong while deleting the project. Check console for
            more info.
          </p>
        )
      })
      // eslint-disable-next-line no-console -- we need to log the error
      console.error(error)
    }
    
    handleClose()
    Inconsistent Usage

    Project link uses name in some places and slug in others which could cause routing issues. Should consistently use slug.

    <Link href={`/project/${name}`}>
      <ContextMenuItem inset>Open</ContextMenuItem>
    </Link>
    <a href={`/project/${slug}`} rel="noopener noreferrer" target="_blank">
      <ContextMenuItem inset>Open in new tab</ContextMenuItem>

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Prevent concurrent deletion operations

    Add loading state during project deletion to prevent multiple deletion attempts and
    provide better user feedback

    apps/platform/src/components/dashboard/project/confirmDeleteProject/index.tsx [34-44]

    +const [isDeleting, setIsDeleting] = useState(false)
     const deleteProject = async () => {
    -  if (selectedProject === null) {
    -    toast.error('No project selected', {
    -      description: (
    -        <p className="text-xs text-red-300">
    -          No project selected. Please select a project.
    -        </p>
    -      )
    -    })
    +  if (selectedProject === null || isDeleting) {
         return
       }
    +  setIsDeleting(true)
    +  try {
    +    // ... rest of the deletion logic
    +  } finally {
    +    setIsDeleting(false)
    +  }
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding loading state during deletion is important for preventing race conditions and duplicate deletion attempts, while also improving user feedback. This is a critical enhancement for data safety and UX.

    8
    General
    Handle clipboard operation failures

    Add error handling for clipboard operations to prevent silent failures and improve
    user feedback

    apps/platform/src/components/dashboard/project/projectCard/index.tsx [42-50]

    -const copyToClipboard = (): void => {
    -  if (navigator.clipboard) {
    -    navigator.clipboard
    -      .writeText(`${window.location.origin}/project/${slug}`)
    -      .then(() => {
    -        toast.success('Link has been copied to clipboard.')
    -      })
    -      .catch((error) => {
    +const copyToClipboard = async (): Promise<void> => {
    +  try {
    +    if (navigator.clipboard) {
    +      await navigator.clipboard.writeText(`${window.location.origin}/project/${slug}`)
    +      toast.success('Link has been copied to clipboard.')
    +    } else {
    +      throw new Error('Clipboard API not supported')
    +    }
    +  } catch (error) {
    +    toast.error('Failed to copy to clipboard')
    +    console.error('Error copying text:', error)
    +  }
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: The improved error handling for clipboard operations provides better user feedback and prevents silent failures, enhancing the reliability of the copy functionality.

    6

    @kriptonian1 kriptonian1 changed the title Feat(platform): Implement delete project feat(platform): Implement delete project Jan 28, 2025
    Copy link
    Member

    @rajdip-b rajdip-b left a comment

    Choose a reason for hiding this comment

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

    LGTM

    @rajdip-b rajdip-b merged commit d243c89 into develop Jan 28, 2025
    4 checks passed
    @rajdip-b rajdip-b deleted the feat-delete-project branch January 28, 2025 08:38
    rajdip-b pushed a commit that referenced this pull request Jan 28, 2025
    ## [2.10.0-stage.7](v2.10.0-stage.6...v2.10.0-stage.7) (2025-01-28)
    
    ### 🚀 Features
    
    * **platform:** Implement delete project ([#671](#671)) ([d243c89](d243c89))
    @rajdip-b
    Copy link
    Member

    🎉 This PR is included in version 2.10.0-stage.7 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

    @poswalsameer
    Copy link
    Contributor

    LFG!

    rajdip-b pushed a commit that referenced this pull request Jan 28, 2025
    ## [2.10.0](v2.9.1...v2.10.0) (2025-01-28)
    
    ### 🚀 Features
    
    * **api:** Secret rotation ([#652](#652)) ([ad9a808](ad9a808))
    * **platform:** Implement delete project ([#671](#671)) ([d243c89](d243c89))
    * **platform:** Improved UI of [secure] listing ([#655](#655)) ([b19de47](b19de47))
    * **platform:** Operate on environments ([#670](#670)) ([f45c5fa](f45c5fa))
    
    ### 🐛 Bug Fixes
    
    * Added lockfile ([856eb3c](856eb3c))
    * **api:** Only user's default workspace returns isDefault: true ([#647](#647)) ([870b4dc](870b4dc))
    * **cli:** Workspace membership API client payload fixed ([#614](#614)) ([#648](#648)) ([e23057b](e23057b))
    * **platform:** Refactor layout structure to improve Navbar positioning & child component ([#661](#661)) ([31067f3](31067f3))
    * **Platfrom:** Replace manual date calculation with dayjs to improve better calculation ([#668](#668)) ([990eb86](990eb86))
    
    ### 🔧 Miscellaneous Chores
    
    * **ci:** Add manual trigger ([cfbf4b9](cfbf4b9))
    * **ci:** Add missing LATEST_TAG variable ([a2ea2ed](a2ea2ed))
    * **ci:** Fixed misplaced sentry sourcemaps commands ([fbd6f3b](fbd6f3b))
    * **ci:** Fixed scripts ([374f7ed](374f7ed))
    * **ci:** Update API sentry dist folder ([2bc9afb](2bc9afb))
    * **CI:** Update pipeline ([fd63b70](fd63b70))
    * **ci:** Update sourcemap upload commands ([c7e8e45](c7e8e45))
    * **cli:** Bumped CLI version to 2.5.0 ([7b772f8](7b772f8))
    * Fix prerelease branch config ([7e84021](7e84021))
    * **release:** 2.10.0-stage.1 [skip ci] ([a4f8414](a4f8414)), closes [#652](#652)
    * **release:** 2.10.0-stage.2 [skip ci] ([00ee123](00ee123)), closes [#647](#647)
    * **release:** 2.10.0-stage.3 [skip ci] ([941a815](941a815)), closes [#655](#655)
    * **release:** 2.10.0-stage.4 [skip ci] ([ae7c44f](ae7c44f)), closes [#614](#614) [#648](#648)
    * **release:** 2.10.0-stage.5 [skip ci] ([d718483](d718483)), closes [#661](#661)
    * **release:** 2.10.0-stage.6 [skip ci] ([4e63f47](4e63f47)), closes [#668](#668)
    * **release:** 2.10.0-stage.7 [skip ci] ([4a35fe7](4a35fe7)), closes [#671](#671)
    * **release:** 2.10.0-stage.8 [skip ci] ([36ef21d](36ef21d)), closes [#670](#670)
    * **release:** 2.9.2-stage.1 [skip ci] ([443f8d4](443f8d4))
    
    ### 🔨 Code Refactoring
    
    * **api:** Update getSelf function ([fe752ce](fe752ce))
    @rajdip-b
    Copy link
    Member

    🎉 This PR is included in version 2.10.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

    poswalsameer pushed a commit to poswalsameer/keyshade-poswalsameer that referenced this pull request Feb 5, 2025
    poswalsameer pushed a commit to poswalsameer/keyshade-poswalsameer that referenced this pull request Feb 5, 2025
    ## [2.10.0-stage.7](keyshade-xyz/keyshade@v2.10.0-stage.6...v2.10.0-stage.7) (2025-01-28)
    
    ### 🚀 Features
    
    * **platform:** Implement delete project ([keyshade-xyz#671](keyshade-xyz#671)) ([d243c89](keyshade-xyz@d243c89))
    poswalsameer pushed a commit to poswalsameer/keyshade-poswalsameer that referenced this pull request Feb 5, 2025
    ## [2.10.0](keyshade-xyz/keyshade@v2.9.1...v2.10.0) (2025-01-28)
    
    ### 🚀 Features
    
    * **api:** Secret rotation ([keyshade-xyz#652](keyshade-xyz#652)) ([ad9a808](keyshade-xyz@ad9a808))
    * **platform:** Implement delete project ([keyshade-xyz#671](keyshade-xyz#671)) ([d243c89](keyshade-xyz@d243c89))
    * **platform:** Improved UI of [secure] listing ([keyshade-xyz#655](keyshade-xyz#655)) ([b19de47](keyshade-xyz@b19de47))
    * **platform:** Operate on environments ([keyshade-xyz#670](keyshade-xyz#670)) ([f45c5fa](keyshade-xyz@f45c5fa))
    
    ### 🐛 Bug Fixes
    
    * Added lockfile ([856eb3c](keyshade-xyz@856eb3c))
    * **api:** Only user's default workspace returns isDefault: true ([keyshade-xyz#647](keyshade-xyz#647)) ([870b4dc](keyshade-xyz@870b4dc))
    * **cli:** Workspace membership API client payload fixed ([keyshade-xyz#614](keyshade-xyz#614)) ([keyshade-xyz#648](keyshade-xyz#648)) ([e23057b](keyshade-xyz@e23057b))
    * **platform:** Refactor layout structure to improve Navbar positioning & child component ([keyshade-xyz#661](keyshade-xyz#661)) ([31067f3](keyshade-xyz@31067f3))
    * **Platfrom:** Replace manual date calculation with dayjs to improve better calculation ([keyshade-xyz#668](keyshade-xyz#668)) ([990eb86](keyshade-xyz@990eb86))
    
    ### 🔧 Miscellaneous Chores
    
    * **ci:** Add manual trigger ([cfbf4b9](keyshade-xyz@cfbf4b9))
    * **ci:** Add missing LATEST_TAG variable ([a2ea2ed](keyshade-xyz@a2ea2ed))
    * **ci:** Fixed misplaced sentry sourcemaps commands ([fbd6f3b](keyshade-xyz@fbd6f3b))
    * **ci:** Fixed scripts ([374f7ed](keyshade-xyz@374f7ed))
    * **ci:** Update API sentry dist folder ([2bc9afb](keyshade-xyz@2bc9afb))
    * **CI:** Update pipeline ([fd63b70](keyshade-xyz@fd63b70))
    * **ci:** Update sourcemap upload commands ([c7e8e45](keyshade-xyz@c7e8e45))
    * **cli:** Bumped CLI version to 2.5.0 ([7b772f8](keyshade-xyz@7b772f8))
    * Fix prerelease branch config ([7e84021](keyshade-xyz@7e84021))
    * **release:** 2.10.0-stage.1 [skip ci] ([a4f8414](keyshade-xyz@a4f8414)), closes [keyshade-xyz#652](keyshade-xyz#652)
    * **release:** 2.10.0-stage.2 [skip ci] ([00ee123](keyshade-xyz@00ee123)), closes [keyshade-xyz#647](keyshade-xyz#647)
    * **release:** 2.10.0-stage.3 [skip ci] ([941a815](keyshade-xyz@941a815)), closes [keyshade-xyz#655](keyshade-xyz#655)
    * **release:** 2.10.0-stage.4 [skip ci] ([ae7c44f](keyshade-xyz@ae7c44f)), closes [keyshade-xyz#614](keyshade-xyz#614) [keyshade-xyz#648](keyshade-xyz#648)
    * **release:** 2.10.0-stage.5 [skip ci] ([d718483](keyshade-xyz@d718483)), closes [keyshade-xyz#661](keyshade-xyz#661)
    * **release:** 2.10.0-stage.6 [skip ci] ([4e63f47](keyshade-xyz@4e63f47)), closes [keyshade-xyz#668](keyshade-xyz#668)
    * **release:** 2.10.0-stage.7 [skip ci] ([4a35fe7](keyshade-xyz@4a35fe7)), closes [keyshade-xyz#671](keyshade-xyz#671)
    * **release:** 2.10.0-stage.8 [skip ci] ([36ef21d](keyshade-xyz@36ef21d)), closes [keyshade-xyz#670](keyshade-xyz#670)
    * **release:** 2.9.2-stage.1 [skip ci] ([443f8d4](keyshade-xyz@443f8d4))
    
    ### 🔨 Code Refactoring
    
    * **api:** Update getSelf function ([fe752ce](keyshade-xyz@fe752ce))
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    PLATFORM: Ability to delete a project
    3 participants