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): add workspace slug for projects in url #683

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

kriptonian1
Copy link
Contributor

@kriptonian1 kriptonian1 commented Jan 31, 2025

User description

Description

This pull request includes several changes to the ProjectCard and Navbar components in the apps/platform directory. The most important changes include adding a new atom value, updating the project link to include the workspace slug, and modifying the pathname check in the Navbar component.

Updates to ProjectCard component:

  • Added useAtomValue import from jotai and selectedWorkspaceAtom import from @/store to apps/platform/src/components/dashboard/project/projectCard/index.tsx. [1] [2]
  • Added selectedWorkspace atom value in the ProjectCard function.
  • Updated project link to include the workspace slug in the href attribute.

Updates to Navbar component:

  • Modified pathname check to correctly identify project paths by checking the second segment of the pathname instead of the first in apps/platform/src/components/shared/navbar/index.tsx.

Mentions

@rajdip-b

Screenshots of relevant screens

image

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

  • Introduced workspace slug integration for project URLs.

  • Added new pages for managing environments, secrets, and variables.

  • Enhanced ProjectCard and Navbar components for workspace-specific navigation.

  • Implemented dynamic project and environment fetching with error handling.


Changes walkthrough 📝

Relevant files
Enhancement
page.tsx
Add environment management page                                                   

apps/platform/src/app/(main)/(project)/[workspace]/project/[project]/@environment/page.tsx

  • Added a new page for managing project environments.
  • Integrated environment fetching and error handling.
  • Displayed environment cards or a prompt to create environments.
  • [link]   
    page.tsx
    Add secret management page                                                             

    apps/platform/src/app/(main)/(project)/[workspace]/project/[project]/@secret/page.tsx

  • Added a new page for managing project secrets.
  • Integrated secret fetching and error handling.
  • Displayed secret cards or a prompt to create secrets.
  • [link]   
    page.tsx
    Add variable management page                                                         

    apps/platform/src/app/(main)/(project)/[workspace]/project/[project]/@variable/page.tsx

  • Added a new page for managing project variables.
  • Integrated variable fetching and error handling.
  • Displayed variable cards or a prompt to create variables.
  • [link]   
    layout.tsx
    Add layout for detailed project pages                                       

    apps/platform/src/app/(main)/(project)/[workspace]/project/[project]/layout.tsx

  • Added a layout component for detailed project pages.
  • Integrated tabs for secrets, variables, and environments.
  • Implemented dynamic project and environment fetching.
  • [link]   
    index.tsx
    Update ProjectCard for workspace-specific navigation         

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

  • Updated project links to include workspace slug.
  • Integrated selectedWorkspaceAtom for workspace-specific navigation.
  • Enhanced project card functionality.
  • +5/-3     
    index.tsx
    Update Navbar for workspace-specific navigation                   

    apps/platform/src/components/shared/navbar/index.tsx

  • Modified pathname checks for workspace-specific project paths.
  • Enhanced navigation logic for projects and settings.
  • +2/-2     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @kriptonian1 kriptonian1 requested a review from rajdip-b January 31, 2025 08:33
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 Security concerns

    Sensitive information exposure:
    The secret values and project data are being logged to the console in error cases, which could expose sensitive information in production environments. Error logging should be properly sanitized or disabled in production.

    ⚡ Recommended focus areas for review

    Error Handling

    The error handling in getProjectBySlug and getAllEnvironments functions could be improved. Currently, it shows a generic error message and logs to console, but should handle specific error cases and provide more actionable feedback.

    if (success && data) {
      setselectedProject(data)
    } else {
      toast.error('Something went wrong!', {
        description: (
          <p className="text-xs text-red-300">
            Something went wrong while fetching the project. Check console for
            more info.
          </p>
        )
      })
      // eslint-disable-next-line no-console -- we need to log the error
      console.error(error)
    }
    Loading State

    The loading state is set to false before the async getAllSecretsByProjectSlug function completes, which could lead to race conditions. The loading state should be updated after the async operation finishes.

      getAllSecretsByProjectSlug()
    
      setIsLoading(false)
    }, [isDecrypted, selectedProject, setSecrets])

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add loading and error states

    Add error handling and loading state for the case when project fetching fails.
    Currently, the UI may be in an inconsistent state if project data fails to load.

    apps/platform/src/app/(main)/(project)/[workspace]/project/[project]/layout.tsx [34-58]

    +const [isLoading, setIsLoading] = useState(true);
     async function getProjectBySlug() {
    -  const { success, error, data } =
    -    await ControllerInstance.getInstance().projectController.getProject(
    -      { projectSlug: params.project },
    -      {}
    -    )
    +  try {
    +    setIsLoading(true);
    +    const { success, error, data } =
    +      await ControllerInstance.getInstance().projectController.getProject(
    +        { projectSlug: params.project },
    +        {}
    +      )
     
    -  if (success && data) {
    -    setselectedProject(data)
    -  } else {
    -    toast.error('Something went wrong!', {
    -      description: (
    -        <p className="text-xs text-red-300">
    -          Something went wrong while fetching the project. Check console for
    -          more info.
    -        </p>
    -      )
    -    })
    -    console.error(error)
    +    if (success && data) {
    +      setselectedProject(data)
    +    } else {
    +      toast.error('Something went wrong!', {
    +        description: (
    +          <p className="text-xs text-red-300">
    +            Something went wrong while fetching the project. Check console for
    +            more info.
    +          </p>
    +        )
    +      })
    +      console.error(error)
    +    }
    +  } catch (err) {
    +    console.error(err)
    +    toast.error('Failed to load project')
    +  } finally {
    +    setIsLoading(false)
       }
     }
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: The suggestion improves error handling and user experience by adding proper loading states and error boundaries, preventing UI inconsistencies when project data fails to load.

    7

    @rajdip-b
    Copy link
    Member

    I think we should use either of the following conventions:

    /workspace/<workspace-slug>/project/<project-slug>?tab=<>
    OR
    /<workspace-slug>/<project-slug>?tab=<>

    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.

    2 participants