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: issue empty state #5998

Draft
wants to merge 2 commits into
base: preview
Choose a base branch
from
Draft

feat: issue empty state #5998

wants to merge 2 commits into from

Conversation

gakshita
Copy link
Collaborator

@gakshita gakshita commented Nov 14, 2024

Summary

This PR Implements issue empty state from CE folder

Summary by CodeRabbit

  • New Features

    • Introduced a new type TProjectPlannerInput for structured project planning input.
    • Added a new component ResolvedProjectEmptyState to enhance handling of empty states in project issues.
  • Improvements

    • Enhanced module export capabilities by consolidating exports from related modules.
    • Streamlined the ProjectEmptyState component for better prop management and clarity.
  • Bug Fixes

    • Improved logic for rendering empty states based on issue filter counts.

@gakshita gakshita marked this pull request as draft November 14, 2024 08:22
Copy link
Contributor

coderabbitai bot commented Nov 14, 2024

Walkthrough

This pull request introduces several changes across multiple files, primarily focusing on enhancing type definitions and component structures related to project issues. A new type TProjectPlannerInput is added to facilitate structured input for project planning. Additionally, new export statements are included to improve module accessibility, and a new React component, ResolvedProjectEmptyState, is introduced to better manage empty states in project issues. The existing ProjectEmptyState component is updated to utilize the new component, streamlining its functionality.

Changes

File Path Change Summary
packages/types/src/ai.d.ts New type TProjectPlannerInput added with properties: data, workspace_id, project_id.
web/ce/components/issues/index.ts Added export statement: export * from "./issue-layouts/empty-states";.
web/ce/components/issues/issue-layouts/empty-states/index.ts Re-exported all entities from ./project-issues.
web/ce/components/issues/issue-layouts/project-issues.tsx Introduced ResolvedProjectEmptyState component with props for handling empty states in project issues.
web/core/components/issues/issue-layouts/project-issues.tsx Updated ProjectEmptyState to use ResolvedProjectEmptyState, simplifying prop handling and rendering.

Possibly related PRs

  • fix: added workspaceslug in renderChildren of project settings #5951: This PR adds the workspaceSlug parameter to the renderChildren function in project settings, which is relevant to the new type TProjectPlannerInput introduced in the main PR, as both involve structured data handling related to projects.
  • fix: intake loading #5966: This PR addresses improvements in the loading state of project settings, which may relate to the structured input handling introduced in the main PR, enhancing user experience when dealing with project-related data.

Suggested labels

🌟enhancement, 🌐frontend

Suggested reviewers

  • SatishGandham

🐰 In the fields where projects grow,
New types and states begin to flow.
With empty states now well defined,
Our planning paths are intertwined.
So hop along, let's celebrate,
For changes here will elevate! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gakshita gakshita changed the title feat: issue empty state + project side menu feat: issue empty state Nov 14, 2024
@gakshita gakshita marked this pull request as ready for review November 14, 2024 08:29
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
packages/types/src/ai.d.ts (1)

11-15: LGTM! Consider adding JSDoc comments.

The TProjectPlannerInput type is well-structured and follows TypeScript naming conventions.

Consider adding JSDoc comments to document the purpose of this type and its fields:

+/**
+ * Input type for AI-powered project planning functionality
+ */
 export type TProjectPlannerInput = {
+  /** The input data/prompt for the AI planner */
   data: string;
+  /** The ID of the workspace containing the project */
   workspace_id: string;
+  /** The ID of the project being planned */
   project_id: string;
 };
web/ce/components/issues/issue-layouts/empty-states/project-issues.tsx (2)

8-15: Consider improving type safety for callback props

The type definition is clear, but could be enhanced:

  1. setTrackElement could use a union type of specific tracking elements instead of generic string
  2. toggleCreateIssueModal could have its parameters typed more strictly

Consider this improvement:

type TProps = {
  issueFilterCount: number;
  additionalPath?: string;
  handleClearAllFilters: () => void;
- toggleCreateIssueModal: (value?: boolean | undefined, storeType?: TCreateModalStoreTypes | undefined) => void;
- setTrackElement: (element: string) => void;
+ toggleCreateIssueModal: (value: boolean, storeType: TCreateModalStoreTypes) => void;
+ setTrackElement: (element: "Project issue empty state") => void;
  emptyStateType?: EmptyStateType;
};

34-38: Extract tracking constant for better maintainability

The tracking element string "Project issue empty state" is hardcoded. Consider extracting it to a constants file for better maintainability and reusability.

+ // In a constants file
+ export const TRACKING_ELEMENTS = {
+   PROJECT_EMPTY_STATE: "Project issue empty state"
+ } as const;

// In the component
- setTrackElement("Project issue empty state");
+ setTrackElement(TRACKING_ELEMENTS.PROJECT_EMPTY_STATE);
web/core/components/issues/issue-layouts/empty-states/project-issues.tsx (1)

43-43: Consider a more descriptive variable name

The variable additionalPath could be renamed to better reflect its purpose, such as activeLayoutPath or filterLayoutPath.

-  const additionalPath = issueFilterCount > 0 ? (activeLayout ?? "list") : undefined;
+  const activeLayoutPath = issueFilterCount > 0 ? (activeLayout ?? "list") : undefined;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 89588d4 and dde8142.

📒 Files selected for processing (5)
  • packages/types/src/ai.d.ts (1 hunks)
  • web/ce/components/issues/index.ts (1 hunks)
  • web/ce/components/issues/issue-layouts/empty-states/index.ts (1 hunks)
  • web/ce/components/issues/issue-layouts/empty-states/project-issues.tsx (1 hunks)
  • web/core/components/issues/issue-layouts/empty-states/project-issues.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • web/ce/components/issues/issue-layouts/empty-states/index.ts
🔇 Additional comments (7)
web/ce/components/issues/index.ts (2)

7-7: LGTM! Export statement follows consistent pattern

The new export statement follows the established pattern and properly exposes the empty states functionality, aligning with the PR's objective.


7-7: Verify the empty states module structure

Let's verify the existence of the empty states module and its usage in the codebase.

✅ Verification successful

Empty states module structure is valid and well-organized

The empty states module exists and is properly structured:

  • Has a clean index.ts that re-exports from project-issues
  • Contains a well-implemented ResolvedProjectEmptyState component
  • Properly imports and uses the EmptyState component from shared components
  • Has correct type definitions and follows the project's patterns
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the empty states module structure and its usage

# Check if the empty states module exists
echo "Checking for empty states module..."
fd "empty-states.{ts,tsx}" "web/ce/components/issues"

# Find references to empty states components
echo "Checking usage of empty states components..."
rg -t typescript -t typescriptreact "EmptyState|empty-states" "web/ce"

Length of output: 661


Script:

#!/bin/bash
# Let's try a different approach to verify the empty states module

# Check if the directory exists and list its contents
echo "Checking directory structure..."
ls -la web/ce/components/issues/issue-layouts/empty-states

# Find any files with "empty" in their name
echo "Finding empty state related files..."
fd -t f "empty" web/ce/components/issues

# Search for imports or usage of empty states
echo "Checking for empty states usage..."
rg "empty-states" web/ce

Length of output: 678


Script:

#!/bin/bash
# Let's check the contents of the empty-states files and their usage

# Check the content of empty-states/index.ts
echo "Content of empty-states/index.ts:"
cat web/ce/components/issues/issue-layouts/empty-states/index.ts

# Check the content of project-issues.tsx
echo -e "\nContent of project-issues.tsx:"
cat web/ce/components/issues/issue-layouts/empty-states/project-issues.tsx

# Find where project-issues component is being used
echo -e "\nUsage of project-issues component:"
rg -l "ProjectIssuesEmptyState" web/ce

Length of output: 1844

packages/types/src/ai.d.ts (1)

11-15: Verify consistency with existing ID field naming patterns.

Let's verify if the field naming (workspace_id and project_id) follows the same pattern as used in other types like IGptResponse.

✅ Verification successful

ID field naming follows consistent snake_case pattern across the codebase

The verification shows that all instances of workspace_id and project_id fields in type definitions consistently use snake_case throughout the codebase, including in related types like:

  • TProjectPlannerInput
  • Issue-related types
  • Workspace-related types
  • Project-related types
  • User-related types

The current implementation in packages/types/src/ai.d.ts correctly follows this established pattern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the naming patterns of ID fields across the codebase
# Expected: Consistent use of either snake_case or camelCase for ID fields

# Search for ID field declarations in type definitions
rg -t typescript "(?:workspace|project)[-_]?id\??:\s*string" --type-add "typescript:*.{ts,tsx,d.ts}"

Length of output: 2141

web/ce/components/issues/issue-layouts/empty-states/project-issues.tsx (2)

1-6: LGTM! Well-organized imports

The imports are properly organized into logical groups (mobx, components, constants) and all imports are utilized in the component.


26-41: Consider optimizing the component structure

The div wrapper with overflow-y-auto might be redundant if the EmptyState component already handles scrolling internally.

If EmptyState doesn't handle scrolling internally, consider moving the scrolling logic to a layout component:

- <div className="relative h-full w-full overflow-y-auto">
+ <div className="relative h-full w-full">
web/core/components/issues/issue-layouts/empty-states/project-issues.tsx (2)

11-12: LGTM! Clean import organization

The import statement follows good practices with clear sectioning and proper component naming.


47-53: Verify ResolvedProjectEmptyState contract and optimize prop passing

The component usage looks clean, but let's verify two aspects:

Additionally, consider simplifying the emptyStateType prop:

-        emptyStateType={issueFilterCount > 0 ? EmptyStateType.PROJECT_EMPTY_FILTER : undefined}
+        emptyStateType={issueFilterCount > 0 && EmptyStateType.PROJECT_EMPTY_FILTER}
✅ Verification successful

Based on the shell script results, I can now generate the final response:

Props usage aligns with component contract, optimization suggestion withdrawn

The component usage is correct as all required props are being passed according to the component's type definition found in web/ce/components/issues/issue-layouts/empty-states/project-issues.tsx. The emptyStateType is correctly marked as optional with ? in the type definition, so the current conditional rendering approach is actually the proper way to handle it. I withdraw the optimization suggestion as the current implementation is more explicit about the intent.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify ResolvedProjectEmptyState component contract and usage
# Search for the component definition to verify required props
ast-grep --pattern 'type TProps = {
  $$$
}'

# Search for other usages of the component to ensure consistency
rg -A 5 'ResolvedProjectEmptyState'

Length of output: 4835

@SatishGandham SatishGandham marked this pull request as draft November 14, 2024 09:52
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