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

[WEB-1986] chore: seperated project components for CE #5324

Merged
merged 9 commits into from
Aug 12, 2024

Conversation

gakshita
Copy link
Collaborator

@gakshita gakshita commented Aug 7, 2024

Summary
Project component imports seperated

Summary by CodeRabbit

  • New Features

    • Introduced a new ProjectPageRoot component for better project management layout.
    • Added modular header and mobile header components for enhanced project navigation.
    • Implemented a ProjectCommonAttributes component for managing project form attributes effectively.
  • Improvements

    • Enhanced modularity by reorganizing component imports, promoting maintainability and clarity within the project structure.
    • Updated project data handling with new type structures for improved consistency.
  • Bug Fixes

    • Streamlined import paths to ensure consistent access to project components.
    • Removed unused imports to simplify dependencies in the project.

Copy link
Contributor

coderabbitai bot commented Aug 7, 2024

Walkthrough

The recent changes enhance the project's modular architecture by reorganizing component imports and consolidating functionalities. Key components have been relocated to new paths, improving clarity and maintainability. The ProjectsPage component is now encapsulated in a dedicated module, facilitating better separation of concerns. Overall, these updates simplify imports and promote a cleaner codebase, ultimately enhancing structure and usability for developers.

Changes

Files Change Summary
web/app/[workspaceSlug]/(projects)/projects/(list)/layout.tsx Updated imports for ProjectsListHeader and ProjectsListMobileHeader to a new directory structure, enhancing modularity.
web/app/[workspaceSlug]/(projects)/projects/(list)/page.tsx Replaced inline ProjectsPage component implementation with an import from a new module, promoting a modular design.
web/ce/components/projects/page.tsx Introduced new ProjectPageRoot component that centralizes workspace and project management with MobX for state handling.
web/core/components/project/create-project-modal.tsx Updated import for CreateProjectForm to a new absolute path, enhancing clarity.
web/core/components/project/create/common-attributes.tsx Introduced ProjectCommonAttributes component for managing common attributes in project forms with enhanced validation and responsiveness.
web/core/components/workspace/sidebar/favorites/favorite-item.tsx Removed import of SidebarNavItem, simplifying dependencies and improving maintainability.
web/core/store/project/project.store.ts Major updates to IProjectStore interface and ProjectStore class, replacing IProject with TProject for improved type safety.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant P as ProjectsPageRoot
    participant W as Workspace
    participant F as Filters

    U->>P: Interacts with ProjectsPageRoot
    P->>W: Fetches workspace data
    P->>F: Applies filters
    F-->>P: Returns applied filters
    P->>U: Displays project cards
Loading

🐰 In the code where rabbits roam,
New paths are built, a modular home!
With headers re-exported, neat and spry,
Projects now dance, as they leap and fly!
Hopping through changes, we celebrate,
A clearer codebase that's simply great! 🌟


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

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, codebase verification and nitpick comments (1)
web/ce/components/projects/page.tsx (1)

1-2: Remove unnecessary "use client" directive.

The "use client" directive is unnecessary here as it is not required for this component.

- "use client";
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 943dd59 and b094197.

Files selected for processing (6)
  • web/app/[workspaceSlug]/(projects)/projects/(list)/layout.tsx (1 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(list)/page.tsx (1 hunks)
  • web/ce/components/projects/page.tsx (1 hunks)
  • web/ee/components/projects/header.tsx (1 hunks)
  • web/ee/components/projects/mobile-header.tsx (1 hunks)
  • web/ee/components/projects/page.tsx (1 hunks)
Files skipped from review due to trivial changes (3)
  • web/ee/components/projects/header.tsx
  • web/ee/components/projects/mobile-header.tsx
  • web/ee/components/projects/page.tsx
Additional comments not posted (5)
web/app/[workspaceSlug]/(projects)/projects/(list)/page.tsx (1)

1-2: LGTM! Verify the new import path.

The import statement promotes modularity and separation of concerns. Ensure that the new module encapsulates the required logic and that the import path is correct.

web/app/[workspaceSlug]/(projects)/projects/(list)/layout.tsx (1)

7-8: LGTM! Verify the new import paths.

The import statements promote modularity and separation of concerns. Ensure that the new modules encapsulate the required logic and that the import paths are correct.

Verification successful

Import paths are correct.

The files header.tsx and mobile-header.tsx exist in the expected paths, confirming the correctness of the new import paths.

  • web/ce/components/projects/header.tsx
  • web/ce/components/projects/mobile-header.tsx
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the new import paths.

# Test: Check if the new import paths exist. Expect: The files should exist.
fd 'header.tsx' | grep 'plane-web/components/projects/header.tsx'
fd 'mobile-header.tsx' | grep 'plane-web/components/projects/mobile-header.tsx'

Length of output: 141


Script:

#!/bin/bash
# Description: Verify the existence of the new import paths by searching more broadly.

# Test: Check if the new import paths exist anywhere in the repository.
fd 'header.tsx' | grep 'header.tsx'
fd 'mobile-header.tsx' | grep 'mobile-header.tsx'

Length of output: 4787

web/ce/components/projects/page.tsx (3)

3-5: LGTM!

The imports are correctly organized and promote modularity.


7-14: LGTM!

The type imports, component imports, helper imports, and hook imports are correctly organized and promote modularity.


16-84: Ensure proper error handling and state management.

The ProjectsPage component is well-organized and uses MobX for state management. Ensure that error handling is properly implemented, especially for asynchronous operations.

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: 8

Outside diff range, codebase verification and nitpick comments (4)
web/core/components/project/create/header.tsx (2)

1-7: Optimize import statements.

Consider grouping related imports together to improve readability. For example, group all React-related imports together.

- import { useState } from "react";
- import { Controller, useFormContext } from "react-hook-form";
+ import { useState } from "react";
+ import { Controller, useFormContext } from "react-hook-form";

20-26: Ensure alt text for images is descriptive.

The alt text for the cover image should be more descriptive to improve accessibility.

- alt="Cover image"
+ alt="Project cover image"
web/ce/components/projects/create/root.tsx (1)

3-20: Optimize import statements.

Consider grouping related imports together to improve readability. For example, group all React-related imports together.

- import { useState, FC } from "react";
- import { observer } from "mobx-react";
- import { FormProvider, useForm } from "react-hook-form";
+ import { useState, FC } from "react";
+ import { observer } from "mobx-react";
+ import { FormProvider, useForm } from "react-hook-form";
web/core/components/project/create/common-attributes.tsx (1)

1-7: Optimize import statements.

Consider grouping related imports together to improve readability. For example, group all React-related imports together.

- import { ChangeEvent } from "react";
- import { Controller, useFormContext, UseFormSetValue } from "react-hook-form";
+ import { ChangeEvent } from "react";
+ import { Controller, useFormContext, UseFormSetValue } from "react-hook-form";
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b094197 and 836c3be.

Files selected for processing (12)
  • web/ce/components/projects/create/attributes.tsx (1 hunks)
  • web/ce/components/projects/create/root.tsx (1 hunks)
  • web/ce/types/projects/projects.ts (1 hunks)
  • web/core/components/project/create-project-modal.tsx (1 hunks)
  • web/core/components/project/create/common-attributes.tsx (1 hunks)
  • web/core/components/project/create/header.tsx (1 hunks)
  • web/core/components/project/create/project-create-buttons.tsx (1 hunks)
  • web/core/components/project/index.ts (2 hunks)
  • web/core/store/project/project.store.ts (9 hunks)
  • web/ee/components/projects/create/attributes.tsx (1 hunks)
  • web/ee/components/projects/create/root.tsx (1 hunks)
  • web/ee/types/projects/projects.ts (1 hunks)
Files skipped from review due to trivial changes (5)
  • web/ce/types/projects/projects.ts
  • web/core/components/project/create-project-modal.tsx
  • web/ee/components/projects/create/attributes.tsx
  • web/ee/components/projects/create/root.tsx
  • web/ee/types/projects/projects.ts
Additional context used
Biome
web/core/components/project/create/common-attributes.tsx

[error] 66-66: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

Additional comments not posted (20)
web/core/components/project/index.ts (1)

21-21: Verify the new export path.

Ensure that the new export path @/plane-web/components/projects/create/root is correct and that the module exists at the specified location.

Verification successful

The new export path is verified.

The module @/plane-web/components/projects/create/root exists in the codebase.

  • web/ce/components/projects/create/root.tsx
  • web/ee/components/projects/create/root.tsx
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the new export path.

# Test: Check if the module exists at the specified path.
fd 'root.ts' 'plane-web/components/projects/create'

Length of output: 173


Script:

#!/bin/bash
# Description: Verify the existence of the new export path.

# Test: Check if the module exists at any path within the repository.
fd 'root.ts'

Length of output: 7999

web/core/components/project/create/project-create-buttons.tsx (5)

1-3: Imports look good.

The imports are correctly defined and necessary for the component's functionality.


5-7: Props definition is clear.

The Props type is well-defined, ensuring that the handleClose function is passed as a prop.


8-12: Component implementation is correct.

The ProjectCreateButtons component correctly utilizes useFormContext to access the form state and renders buttons based on the form's submission state.


14-23: Button rendering is appropriate.

The buttons are correctly rendered with appropriate variants, sizes, and loading states.


26-26: Export statement is correct.

The component is correctly exported as the default export.

web/ce/components/projects/create/attributes.tsx (6)

1-5: Imports look good.

The imports are correctly defined and necessary for the component's functionality.


7-8: Form context usage is correct.

The useFormContext hook is correctly used to access the form control.


10-31: Network selection control is implemented correctly.

The Controller component is correctly used to manage the network selection, and the CustomSelect component is properly configured.


32-52: Rendering of network options is correct.

The network options are correctly rendered using the CustomSelect.Option component.


56-75: Project lead selection control is implemented correctly.

The Controller component is correctly used to manage the project lead selection, and the MemberDropdown component is properly configured.


80-80: Export statement is correct.

The component is correctly exported as the default export.

web/core/components/project/create/common-attributes.tsx (1)

111-111: Remove unnecessary Fragment.

The fragment is unnecessary here as it contains only one child.

- <>{errors?.identifier?.message}</>
+ {errors?.identifier?.message}

Likely invalid or redundant comment.

web/core/store/project/project.store.ts (7)

27-27: Verify the definition and usage of TProject.

Ensure that TProject is correctly defined and used consistently across the codebase.


29-29: Verify the definition and usage of TProject.

Ensure that TProject is correctly defined and used consistently across the codebase.


32-32: Verify the definition and usage of TProject.

Ensure that TProject is correctly defined and used consistently across the codebase.


33-33: Verify the definition and usage of TProject.

Ensure that TProject is correctly defined and used consistently across the codebase.


40-40: Verify the definition and usage of TProject.

Ensure that TProject is correctly defined and used consistently across the codebase.


41-41: Verify the definition and usage of TProject.

Ensure that TProject is correctly defined and used consistently across the codebase.


18-18: Verify the definition and usage of TProject.

Ensure that TProject is correctly defined and used consistently across the codebase.

Verification successful

The definition and usage of TProject have been verified and found consistent across the codebase.

  • The TProject type is defined as export type TProject = IProject; in web/ce/types/projects/projects.ts.
  • The usage of TProject is consistent across various files in the codebase.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and usage of `TProject`.

# Test: Search for the definition of `TProject`. Expect: A single definition.
rg --type typescript -A 5 $'type TProject'

# Test: Search for the usage of `TProject`. Expect: Consistent usage across the codebase.
rg --type typescript -A 5 $'TProject'

Length of output: 150


Script:

#!/bin/bash
# Description: Verify the definition and usage of `TProject`.

# Test: Search for the definition of `TProject`. Expect: A single definition.
rg --type ts -A 5 $'type TProject'

# Test: Search for the usage of `TProject`. Expect: Consistent usage across the codebase.
rg --type ts -A 5 $'TProject'

Length of output: 55615

const { handleClose } = props;
const { watch, control } = useFormContext<IProject>();

const [isOpen, setIsOpen] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider initializing state with a function.

To avoid potential performance issues, consider initializing the state with a function.

- const [isOpen, setIsOpen] = useState(false);
+ const [isOpen, setIsOpen] = useState(() => false);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const [isOpen, setIsOpen] = useState(false);
const [isOpen, setIsOpen] = useState(() => false);

<Logo logo={value} size={20} />
</span>
}
onChange={(val: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid unnecessary Fragment.

The fragment is unnecessary here as it contains only one child.

- <>{errors?.name?.message}</>
+ {errors?.name?.message}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onChange={(val: any) => {
onChange={(val: any) => {

Comment on lines +58 to +68
const handleAddToFavorites = (projectId: string) => {
if (!workspaceSlug) return;

addProjectToFavorites(workspaceSlug.toString(), projectId).catch(() => {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Couldn't remove the project from favorites. Please try again.",
});
});
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Improve error handling in handleAddToFavorites.

Consider adding more specific error handling and logging to help with debugging.

- addProjectToFavorites(workspaceSlug.toString(), projectId).catch(() => {
-   setToast({
-     type: TOAST_TYPE.ERROR,
-     title: "Error!",
-     message: "Couldn't remove the project from favorites. Please try again.",
-   });
- });
+ addProjectToFavorites(workspaceSlug.toString(), projectId).catch((error) => {
+   console.error("Failed to add project to favorites:", error);
+   setToast({
+     type: TOAST_TYPE.ERROR,
+     title: "Error!",
+     message: "Couldn't remove the project from favorites. Please try again.",
+   });
+ });
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleAddToFavorites = (projectId: string) => {
if (!workspaceSlug) return;
addProjectToFavorites(workspaceSlug.toString(), projectId).catch(() => {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Couldn't remove the project from favorites. Please try again.",
});
});
};
const handleAddToFavorites = (projectId: string) => {
if (!workspaceSlug) return;
addProjectToFavorites(workspaceSlug.toString(), projectId).catch((error) => {
console.error("Failed to add project to favorites:", error);
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Couldn't remove the project from favorites. Please try again.",
});
});
};

Comment on lines 70 to 109
const onSubmit = async (formData: Partial<IProject>) => {
// Upper case identifier
formData.identifier = formData.identifier?.toUpperCase();

return createProject(workspaceSlug.toString(), formData)
.then((res) => {
const newPayload = {
...res,
state: "SUCCESS",
};
captureProjectEvent({
eventName: PROJECT_CREATED,
payload: newPayload,
});
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Project created successfully.",
});
if (setToFavorite) {
handleAddToFavorites(res.id);
}
handleNextStep(res.id);
})
.catch((err) => {
Object.keys(err.data).map((key) => {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: err.data[key],
});
captureProjectEvent({
eventName: PROJECT_CREATED,
payload: {
...formData,
state: "FAILED",
},
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Improve error handling in onSubmit.

Consider adding more specific error handling and logging to help with debugging.

- .catch((err) => {
-   Object.keys(err.data).map((key) => {
-     setToast({
-       type: TOAST_TYPE.ERROR,
-       title: "Error!",
-       message: err.data[key],
-     });
-     captureProjectEvent({
-       eventName: PROJECT_CREATED,
-       payload: {
-         ...formData,
-         state: "FAILED",
-       },
-     });
-   });
- });
+ .catch((error) => {
+   console.error("Failed to create project:", error);
+   Object.keys(error.data).map((key) => {
+     setToast({
+       type: TOAST_TYPE.ERROR,
+       title: "Error!",
+       message: error.data[key],
+     });
+     captureProjectEvent({
+       eventName: PROJECT_CREATED,
+       payload: {
+         ...formData,
+         state: "FAILED",
+       },
+     });
+   });
+ });
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const onSubmit = async (formData: Partial<IProject>) => {
// Upper case identifier
formData.identifier = formData.identifier?.toUpperCase();
return createProject(workspaceSlug.toString(), formData)
.then((res) => {
const newPayload = {
...res,
state: "SUCCESS",
};
captureProjectEvent({
eventName: PROJECT_CREATED,
payload: newPayload,
});
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Project created successfully.",
});
if (setToFavorite) {
handleAddToFavorites(res.id);
}
handleNextStep(res.id);
})
.catch((err) => {
Object.keys(err.data).map((key) => {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: err.data[key],
});
captureProjectEvent({
eventName: PROJECT_CREATED,
payload: {
...formData,
state: "FAILED",
},
});
});
});
const onSubmit = async (formData: Partial<IProject>) => {
// Upper case identifier
formData.identifier = formData.identifier?.toUpperCase();
return createProject(workspaceSlug.toString(), formData)
.then((res) => {
const newPayload = {
...res,
state: "SUCCESS",
};
captureProjectEvent({
eventName: PROJECT_CREATED,
payload: newPayload,
});
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Project created successfully.",
});
if (setToFavorite) {
handleAddToFavorites(res.id);
}
handleNextStep(res.id);
})
.catch((error) => {
console.error("Failed to create project:", error);
Object.keys(error.data).map((key) => {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: error.data[key],
});
captureProjectEvent({
eventName: PROJECT_CREATED,
payload: {
...formData,
state: "FAILED",
},
});
});
});

const { captureProjectEvent } = useEventTracker();
const { addProjectToFavorites, createProject } = useProject();
// states
const [isChangeInIdentifierRequired, setIsChangeInIdentifierRequired] = useState(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider initializing state with a function.

To avoid potential performance issues, consider initializing the state with a function.

- const [isChangeInIdentifierRequired, setIsChangeInIdentifierRequired] = useState(true);
+ const [isChangeInIdentifierRequired, setIsChangeInIdentifierRequired] = useState(() => true);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const [isChangeInIdentifierRequired, setIsChangeInIdentifierRequired] = useState(true);
const [isChangeInIdentifierRequired, setIsChangeInIdentifierRequired] = useState(() => true);

)}
/>
</div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unnecessary Fragment.

The fragment is unnecessary here as it contains only one child.

- <>{errors?.description?.message}</>
+ {errors?.description?.message}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
</div>
{errors?.description?.message}

)}
/>
<span className="text-xs text-red-500">
<>{errors?.name?.message}</>
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unnecessary Fragment.

The fragment is unnecessary here as it contains only one child.

- <>{errors?.name?.message}</>
+ {errors?.name?.message}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<>{errors?.name?.message}</>
{errors?.name?.message}
Tools
Biome

[error] 66-66: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

Comment on lines +22 to +30
const handleNameChange = (onChange: (...event: any[]) => void) => (e: ChangeEvent<HTMLInputElement>) => {
if (!isChangeInIdentifierRequired) {
onChange(e);
return;
}
if (e.target.value === "") setValue("identifier", "");
else setValue("identifier", projectIdentifierSanitizer(e.target.value).substring(0, 5));
onChange(e);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify handleNameChange function.

The function can be simplified for better readability.

- if (e.target.value === "") setValue("identifier", "");
- else setValue("identifier", projectIdentifierSanitizer(e.target.value).substring(0, 5));
+ setValue("identifier", e.target.value === "" ? "" : projectIdentifierSanitizer(e.target.value).substring(0, 5));
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleNameChange = (onChange: (...event: any[]) => void) => (e: ChangeEvent<HTMLInputElement>) => {
if (!isChangeInIdentifierRequired) {
onChange(e);
return;
}
if (e.target.value === "") setValue("identifier", "");
else setValue("identifier", projectIdentifierSanitizer(e.target.value).substring(0, 5));
onChange(e);
};
const handleNameChange = (onChange: (...event: any[]) => void) => (e: ChangeEvent<HTMLInputElement>) => {
if (!isChangeInIdentifierRequired) {
onChange(e);
return;
}
setValue("identifier", e.target.value === "" ? "" : projectIdentifierSanitizer(e.target.value).substring(0, 5));
onChange(e);
};

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, codebase verification and nitpick comments (1)
web/app/[workspaceSlug]/(projects)/projects/(list)/page.tsx (1)

8-9: Handle potential undefined or null values for workspaceSlug.

Ensure that workspaceSlug is checked for undefined or null before calling toString() to prevent runtime errors.

  • File: web/app/[workspaceSlug]/(projects)/projects/(list)/page.tsx, Line: 9
Analysis chain

Verify workspaceSlug conversion to string.

Ensure that workspaceSlug is always a valid string before calling toString(), as this could potentially lead to runtime errors if workspaceSlug is undefined or null.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `workspaceSlug` is always defined before being used in `ProjectsPage`.

# Test: Search for `useParams` usage to ensure `workspaceSlug` is always defined.
rg --type typescript -A 5 $'const { workspaceSlug } = useParams()'

Length of output: 195


Script:

#!/bin/bash
# Description: Verify that `workspaceSlug` is always defined before being used in `ProjectsPage`.

# Test: Search for `useParams` usage to ensure `workspaceSlug` is always defined.
rg --type typescript -A 5 $'const \\{ workspaceSlug \\} = useParams()'

Length of output: 104


Script:

#!/bin/bash
# Description: Verify that `workspaceSlug` is always defined before being used in `ProjectsPage`.

# Test: Search for `useParams` usage to ensure `workspaceSlug` is always defined.
rg --type ts -A 5 $'const \\{ workspaceSlug \\} = useParams()'

Length of output: 48009

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 836c3be and 0a6d189.

Files selected for processing (3)
  • web/app/[workspaceSlug]/(projects)/projects/(list)/page.tsx (1 hunks)
  • web/ce/components/projects/page.tsx (1 hunks)
  • web/core/components/project/create/common-attributes.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • web/ce/components/projects/page.tsx
  • web/core/components/project/create/common-attributes.tsx
Additional comments not posted (1)
web/app/[workspaceSlug]/(projects)/projects/(list)/page.tsx (1)

4-4: LGTM! Modularization improves maintainability.

The import of ProjectsPageRoot from a separate module enhances the modularity and separation of concerns, making the codebase easier to maintain.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0a6d189 and 3c05746.

Files selected for processing (3)
  • web/app/[workspaceSlug]/(projects)/projects/(list)/page.tsx (1 hunks)
  • web/ce/components/projects/page.tsx (1 hunks)
  • web/core/components/project/root.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • web/ce/components/projects/page.tsx
Additional comments not posted (5)
web/app/[workspaceSlug]/(projects)/projects/(list)/page.tsx (1)

1-3: Simplified component structure.

The ProjectsPage now delegates its functionality to ProjectPageRoot, improving modularity and separation of concerns.

web/core/components/project/root.tsx (4)

1-14: Well-organized imports and setup.

The imports are neatly categorized, enhancing readability and maintainability.


16-30: Effective state management and derived values.

The use of MobX and derived values like pageTitle is efficient and well-structured.


32-57: Efficient use of callbacks for filter management.

The callbacks are well-implemented and use useCallback for performance optimization.


59-82: Clear and conditional rendering logic.

The rendering structure is clear, with conditional logic to display filters and project lists appropriately.

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, codebase verification and nitpick comments (2)
web/core/store/project/project.store.ts (2)

41-41: Potential Type Incompatibility Between Store and Service Layers

The updateProject function in web/core/store/project/project.store.ts uses Partial<TProject> and Promise<TProject>, but the corresponding service method projectService.updateProject in web/core/services/project/project.service.ts still uses Partial<IProject> and Promise<IProject>. This discrepancy could lead to type incompatibility issues. Please ensure that both layers are using consistent types.

  • Store Layer: web/core/store/project/project.store.ts
  • Service Layer: web/core/services/project/project.service.ts
Analysis chain

Verify parameter and promise return type compatibility with TProject.

The updateProject method parameter and return types have been updated from Partial<IProject> and Promise<IProject> to Partial<TProject> and Promise<TProject>. Ensure all logic using this method is compatible with TProject.

Also applies to: 371-373

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify parameter and promise return type compatibility with `TProject` for `updateProject`.

# Test: Search for `updateProject` usage. Expect: Compatibility with `TProject`.
rg --type typescript -A 5 $'updateProject'

Length of output: 76


Script:

#!/bin/bash
# Description: Verify parameter and promise return type compatibility with `TProject` for `updateProject`.

# Test: Search for `updateProject` usage. Expect: Compatibility with `TProject`.
rg --type ts -A 5 $'updateProject'

Length of output: 16103


40-40: Verify and Update Service Layer for Compatibility with TProject.

The createProject method in project.store.ts has been updated to use TProject, but the service layer in project.service.ts still uses IProject. Ensure the service layer is updated to maintain type compatibility with TProject.

  • File: web/core/services/project/project.service.ts
  • Method: createProject
Analysis chain

Verify parameter and promise return type compatibility with TProject.

The createProject method parameter and return types have been updated from Partial<IProject> and Promise<IProject> to Partial<TProject> and Promise<TProject>. Ensure all logic using this method is compatible with TProject.

Also applies to: 350-352

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify parameter and promise return type compatibility with `TProject` for `createProject`.

# Test: Search for `createProject` usage. Expect: Compatibility with `TProject`.
rg --type typescript -A 5 $'createProject'

Length of output: 76


Script:

#!/bin/bash
# Description: Verify parameter and promise return type compatibility with `TProject` for `createProject`.

# Test: Search for `createProject` usage. Expect: Compatibility with `TProject`.
rg --type ts -A 5 $'createProject'

Length of output: 3293

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3c05746 and 60bdab0.

Files selected for processing (3)
  • web/core/components/project/create/common-attributes.tsx (1 hunks)
  • web/core/components/workspace/sidebar/favorites/favorite-item.tsx (1 hunks)
  • web/core/store/project/project.store.ts (9 hunks)
Files skipped from review due to trivial changes (1)
  • web/core/components/workspace/sidebar/favorites/favorite-item.tsx
Files skipped from review as they are similar to previous changes (1)
  • web/core/components/project/create/common-attributes.tsx
Additional comments not posted (5)
web/core/store/project/project.store.ts (5)

18-18: Verify compatibility with TProject.

The projectMap property type has been updated from IProject to TProject. Ensure all usages of projectMap are compatible with the new TProject type.

Also applies to: 52-52


27-27: Verify logic compatibility with TProject.

The currentProjectDetails property type has been updated from IProject | undefined to TProject | undefined. Ensure all dependent logic is compatible with TProject.


32-32: Verify promise return type compatibility with TProject.

The fetchProjects method return type has been updated from Promise<IProject[]> to Promise<TProject[]>. Ensure all logic using this method is compatible with TProject.

Also applies to: 208-210


33-33: Verify promise return type compatibility with TProject.

The fetchProjectDetails method return type has been updated from Promise<IProject> to Promise<TProject>. Ensure all logic using this method is compatible with TProject.

Also applies to: 233-235


29-29: Verify return type compatibility with TProject.

The getProjectById method return type has been updated from IProject | undefined to TProject | undefined. Ensure all logic using this method is compatible with TProject.

Also applies to: 251-253

Verification successful

Return type change to TProject is compatible.

The getProjectById method's return type change from IProject | undefined to TProject | undefined is compatible since TProject is an alias for IProject. Therefore, all existing logic using this method remains unaffected.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify return type compatibility with `TProject` for `getProjectById`.

# Test: Search for `getProjectById` usage. Expect: Compatibility with `TProject`.
rg --type typescript -A 5 $'getProjectById'

Length of output: 77


Script:

#!/bin/bash
# Description: Verify return type compatibility with `TProject` for `getProjectById`.

# Test: Search for `getProjectById` usage. Expect: Compatibility with `TProject`.
rg --type ts -A 5 $'getProjectById'

Length of output: 82162


Script:

#!/bin/bash
# Description: Find the definition of `TProject` to verify its properties.

# Test: Search for the definition of `TProject`.
rg --type ts -A 10 'type TProject' | rg -A 10 'interface TProject' | rg -A 10 'class TProject'

Length of output: 96


Script:

#!/bin/bash
# Description: Search for `TProject` in import statements and type alias declarations.

# Test: Search for `TProject` in import statements.
rg --type ts 'import .*TProject' 

# Test: Search for `TProject` as a type alias.
rg --type ts 'type .*TProject' 

Length of output: 3224

@SatishGandham SatishGandham changed the base branch from preview to develop August 8, 2024 12:08
@CLAassistant
Copy link

CLAassistant commented Aug 12, 2024

CLA assistant check
All committers have signed the CLA.

@gakshita gakshita changed the base branch from develop to preview August 12, 2024 12:27
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, codebase verification and nitpick comments (1)
web/core/components/project/header.tsx (1)

Update References to ProjectsBaseHeader

The component ProjectsListHeader is still being used in several places. Ensure all references to ProjectsListHeader are updated to ProjectsBaseHeader to maintain consistency across the codebase.

  • Files with outdated references:
    • web/ce/components/projects/header.tsx
    • web/app/[workspaceSlug]/(projects)/projects/(list)/layout.tsx
    • web/app/[workspaceSlug]/(projects)/projects/(detail)/archives/layout.tsx

Please update these references to use ProjectsBaseHeader.

Analysis chain

Line range hint 24-56:
LGTM! Verify the renaming consistency.

The renaming and new logic for handling archived views are well-implemented.

Ensure that all references to ProjectsListHeader have been updated to ProjectsBaseHeader.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all references to `ProjectsListHeader` have been updated to `ProjectsBaseHeader`.

# Test: Search for the old component name. Expect: No occurrences of `ProjectsListHeader`.
rg --type tsx $'ProjectsListHeader'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify that all references to `ProjectsListHeader` have been updated to `ProjectsBaseHeader`.

# Test: Search for the old component name. Expect: No occurrences of `ProjectsListHeader`.
rg 'ProjectsListHeader'

Length of output: 741

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 60bdab0 and 9ac1d17.

Files selected for processing (18)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/archives/layout.tsx (1 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/archives/page.tsx (1 hunks)
  • web/ce/components/projects/create/root.tsx (1 hunks)
  • web/ce/components/projects/header.tsx (1 hunks)
  • web/ce/components/projects/mobile-header.tsx (2 hunks)
  • web/ce/types/projects/index.ts (1 hunks)
  • web/core/components/gantt-chart/blocks/blocks-list.tsx (2 hunks)
  • web/core/components/gantt-chart/chart/header.tsx (2 hunks)
  • web/core/components/gantt-chart/chart/main-content.tsx (3 hunks)
  • web/core/components/gantt-chart/chart/root.tsx (3 hunks)
  • web/core/components/gantt-chart/root.tsx (3 hunks)
  • web/core/components/gantt-chart/sidebar/root.tsx (2 hunks)
  • web/core/components/project/create-project-modal.tsx (3 hunks)
  • web/core/components/project/create/common-attributes.tsx (1 hunks)
  • web/core/components/project/header.tsx (5 hunks)
  • web/core/components/project/root.tsx (1 hunks)
  • web/core/components/workspace/sidebar/workspace-menu.tsx (4 hunks)
  • web/core/store/member/project-member.store.ts (6 hunks)
Files skipped from review due to trivial changes (3)
  • web/ce/components/projects/header.tsx
  • web/ce/components/projects/mobile-header.tsx
  • web/ce/types/projects/index.ts
Files skipped from review as they are similar to previous changes (4)
  • web/ce/components/projects/create/root.tsx
  • web/core/components/project/create-project-modal.tsx
  • web/core/components/project/create/common-attributes.tsx
  • web/core/components/project/root.tsx
Additional comments not posted (21)
web/app/[workspaceSlug]/(projects)/projects/(detail)/archives/page.tsx (1)

1-4: LGTM!

The component is well-structured and uses concise syntax. The import and export are correctly set up.

web/app/[workspaceSlug]/(projects)/projects/(detail)/archives/layout.tsx (1)

1-16: Well-structured layout component!

The use of React fragments and the separation of headers for different screen sizes are good practices.

web/core/components/gantt-chart/chart/header.tsx (1)

Line range hint 19-59: Good enhancement with showToday prop!

The conditional rendering of the "Today" button based on the showToday prop is a flexible addition. Ensure that the new prop is correctly utilized in all relevant components.

web/core/components/gantt-chart/blocks/blocks-list.tsx (2)

17-20: Enhanced flexibility in type definitions.

The changes to allow boolean or function types for block properties enhance flexibility and adaptability. This is a good improvement for handling dynamic scenarios.


58-65: Correct handling of dynamic property types.

The component correctly checks and handles both boolean and function types for enabling block features. This implementation supports dynamic interaction based on block ID.

web/core/components/gantt-chart/root.tsx (2)

19-24: Improved flexibility and new feature addition.

The changes to allow boolean or function types for properties and the addition of showToday enhance flexibility and add useful functionality. This is a positive enhancement.

Also applies to: 27-27


Line range hint 50-76:
Correct implementation of flexible properties and new feature.

The component correctly handles the flexible property types and the new showToday feature, supporting dynamic customization and behavior.

web/core/components/gantt-chart/sidebar/root.tsx (2)

19-20: Enhanced flexibility in type definitions.

The changes to allow boolean or function types for enableReorder and enableSelection enhance flexibility and adaptability. This is a good improvement for handling dynamic scenarios.


97-97: Correct handling of dynamic property types.

The component correctly supports both boolean and function types for enableReorder and enableSelection, enabling dynamic interaction based on block ID.

web/core/components/gantt-chart/chart/main-content.tsx (2)

148-177: Ensure correct handling of dynamic property types.

The component should correctly interpret both boolean and function types for the updated properties.


41-46: LGTM! Verify the usage of updated properties.

The changes to allow boolean or function types for these properties are well-implemented and enhance flexibility.

However, ensure that all usages of these properties handle both boolean and function types correctly.

web/core/components/project/header.tsx (1)

Line range hint 56-103:
Ensure correct handling of archived views.

The logic to check if the pathname includes "/archives" is straightforward and should work as expected.

web/core/components/gantt-chart/chart/root.tsx (2)

166-166: Ensure correct handling of showToday.

The showToday property should be correctly utilized to enhance the user interface by highlighting the current date.


26-38: LGTM! Verify the usage of updated properties.

The changes to allow boolean or function types for these properties and the addition of showToday are well-implemented.

Ensure that all usages of these properties handle both boolean and function types correctly, and verify the implementation of showToday.

web/core/store/member/project-member.store.ts (3)

68-68: Addition of projectRoot property is logical.

The projectRoot property correctly links the ProjectMemberStore to the root project store, facilitating access to project-related data.


228-230: Filtering logic for removing a member is correct.

The method correctly filters out the member using userId, ensuring consistency in the project's member list.


171-173: Concatenation logic for adding members looks good.

The use of IProjectMemberLite ensures type safety when adding members to the project.

Verify that IProjectMemberLite is used consistently across the codebase.

Verification successful

Consistent Usage of IProjectMemberLite Across the Codebase

The IProjectMemberLite interface is consistently used across the codebase, ensuring type safety in various contexts such as member filtering and data handling.

  • Defined in: packages/types/src/project/projects.d.ts
  • Used in:
    • web/core/store/user/user-membership.store.ts
    • web/core/store/member/project-member.store.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `IProjectMemberLite` across the codebase.

# Test: Search for the usage of `IProjectMemberLite`. Expect: Consistent usage across the codebase.
rg --type typescript 'IProjectMemberLite'

Length of output: 76


Script:

#!/bin/bash
# Description: Verify the usage of `IProjectMemberLite` across the codebase.

# Test: Search for the usage of `IProjectMemberLite`. Expect: Consistent usage across the codebase.
rg --type ts 'IProjectMemberLite'

Length of output: 643

web/core/components/workspace/sidebar/workspace-menu.tsx (4)

29-29: State management for isMenuActive is well-implemented.

The useState hook effectively manages the visibility of the custom dropdown menu.


31-31: DOM reference with useRef is appropriate.

The actionSectionRef is correctly used to manage interactions with the custom dropdown menu.


62-62: Integration of useOutsideClickDetector enhances UX.

The hook effectively manages the closing of the menu, improving user interaction.


82-121: Layout changes for the custom menu are well-structured.

The addition of "Archives" and "Settings" enhances the sidebar's organization and user experience.

@SatishGandham SatishGandham merged commit 91693b2 into preview Aug 12, 2024
13 of 14 checks passed
@SatishGandham SatishGandham deleted the chore/project-page-imports branch August 12, 2024 12:54
@SatishGandham SatishGandham changed the title chore: seperated project components for CE [WEB-1986] chore: seperated project components for CE Aug 12, 2024
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