-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix: improvements for project types. #5857
Conversation
WalkthroughThe pull request introduces a significant update across several components and services, transitioning from using the Changes
Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 (7)
web/core/services/project/project.service.ts (3)
18-18
: LGTM: Method signature updated correctly.The
createProject
method signature has been updated to usePartial<TProject>
as input andPromise<TProject>
as output, which is consistent with the transition fromIProject
toTProject
. This change maintains type safety and reflects the asynchronous nature of the operation.Consider adding a JSDoc comment to describe the method's purpose and parameters for better documentation:
/** * Creates a new project in the specified workspace. * @param workspaceSlug - The slug of the workspace where the project will be created. * @param data - Partial project data for creation. * @returns A promise that resolves to the created project. */ async createProject(workspaceSlug: string, data: Partial<TProject>): Promise<TProject>
54-54
: LGTM: Method signature updated correctly.The
updateProject
method signature has been updated to usePartial<TProject>
as input andPromise<TProject>
as output, which is consistent with the transition fromIProject
toTProject
. This change maintains type safety and reflects the asynchronous nature of the operation.Consider adding a JSDoc comment to describe the method's purpose and parameters for better documentation:
/** * Updates an existing project in the specified workspace. * @param workspaceSlug - The slug of the workspace containing the project. * @param projectId - The ID of the project to update. * @param data - Partial project data for update. * @returns A promise that resolves to the updated project. */ async updateProject(workspaceSlug: string, projectId: string, data: Partial<TProject>): Promise<TProject>
Line range hint
1-165
: Summary: Successful transition fromIProject
toTProject
The changes in this file consistently update the
ProjectService
class to use theTProject
type instead ofIProject
. This transition improves type consistency across the project service and aligns with the broader changes in the PR.Key points:
- Import statements have been updated correctly.
- Method signatures for
createProject
,getProjects
,getProject
, andupdateProject
have been updated to useTProject
.- The use of
Partial<TProject>
in input parameters allows for flexible project creation and updates.These changes enhance type safety and maintain the existing functionality of the
ProjectService
class. The transition appears to be complete and correct for this file.Consider adding JSDoc comments to the updated methods for improved documentation and developer experience.
web/helpers/project.helper.ts (1)
Line range hint
1-116
: Overall assessment: Successful type transition with improved consistency.The changes in this file successfully transition from
IProject
toTProject
type, improving type consistency across the project. The logic of the functions remains unchanged, which is appropriate for this type of refactoring. The addition ofEUserPermissions
enum usage also enhances code readability and maintainability.To ensure a smooth transition:
- Verify that all occurrences of
IProject
have been replaced withTProject
throughout the codebase.- Update any documentation or comments that may still reference
IProject
.- Run comprehensive tests to catch any type-related issues that may have been introduced.
Consider creating a migration guide or updating the project's documentation to reflect this type change, especially if
IProject
was part of a public API.web/core/components/workspace/sidebar/projects-list.tsx (3)
21-24
: LGTM! Consider grouping related imports.The addition of
EUserPermissions
,EUserPermissionsLevel
, andTProject
imports aligns with the PR objectives. These changes support the transition fromIProject
toTProject
and enhance permission checks.Consider grouping related imports together for better readability. For example:
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions"; import { TProject } from "@/plane-web/types";
Line range hint
39-43
: LGTM! Consider adding a comment for clarity.The addition of
isAuthorizedUser
enhances permission control, aligning with the PR objectives. This constant is used to conditionally render UI elements, improving security and user experience.Consider adding a brief comment explaining the purpose of
isAuthorizedUser
:// Check if the user has admin or member permissions at the workspace level const isAuthorizedUser = allowPermissions( [EUserPermissions.ADMIN, EUserPermissions.MEMBER], EUserPermissionsLevel.WORKSPACE );
Line range hint
71-77
: LGTM! Consider using type assertion for improved type safety.The transition from
IProject[]
toTProject[]
forjoinedProjectsList
is correctly implemented, aligning with the PR objectives.For improved type safety, consider using a type assertion when pushing project details:
const joinedProjectsList: TProject[] = []; joinedProjects.map((projectId) => { const projectDetails = getProjectById(projectId); if (projectDetails) joinedProjectsList.push(projectDetails as TProject); });This ensures that
projectDetails
is explicitly treated asTProject
when added to the list.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
- web/core/components/dropdowns/project.tsx (2 hunks)
- web/core/components/workspace/sidebar/projects-list.tsx (2 hunks)
- web/core/services/project/project.service.ts (2 hunks)
- web/core/store/project/project.store.ts (1 hunks)
- web/helpers/project.helper.ts (4 hunks)
✅ Files skipped from review due to trivial changes (1)
- web/core/store/project/project.store.ts
🧰 Additional context used
🔇 Additional comments (13)
web/core/services/project/project.service.ts (3)
8-9
: LGTM: Import statement updated correctly.The import statement has been updated to use
TProject
from@/plane-web/types
, which is consistent with the transition fromIProject
toTProject
throughout the file. This change supports better type consistency and maintainability.
38-38
: LGTM: Return type updated correctly.The
getProjects
method signature has been updated to returnPromise<TProject[]>
, which is consistent with the transition fromIProject
toTProject
. This change maintains type safety for the array of projects returned by the method.
46-46
: LGTM: Return type updated correctly.The
getProject
method signature has been updated to returnPromise<TProject>
, which is consistent with the transition fromIProject
toTProject
. This change maintains type safety for the single project returned by the method.web/helpers/project.helper.ts (5)
3-3
: LGTM: Import statements updated to reflect type changes.The import statements have been correctly updated to accommodate the transition from
IProject
toTProject
. The addition ofEUserPermissions
import suggests new functionality related to user permissions, which aligns with the PR objectives.Also applies to: 7-7, 10-10
23-23
: LGTM: Parameter type updated for consistency.The parameter type for
joinedProjects
has been correctly updated fromIProject[]
toTProject[]
, maintaining consistency with the new type system.
54-54
: LGTM: Function updated with improved type safety and readability.The
shouldRenderProject
function has been successfully updated to useTProject
type. Additionally, the use ofEUserPermissions.MEMBER
enum instead of a hardcoded value improves code readability and maintainability.Also applies to: 57-57, 58-58
62-62
: LGTM: Function signature updated for type consistency.The
shouldFilterProject
function has been correctly updated to use theTProject
type, maintaining consistency with the new type system while preserving the existing logic.Also applies to: 68-68
99-99
: LGTM: Function updated for type consistency. Verify usage across the codebase.The
orderProjects
function has been correctly updated to useTProject[]
for parameter and return types, maintaining consistency with the new type system.To ensure that this change doesn't introduce any issues elsewhere in the codebase, please run the following verification script:
Also applies to: 101-101, 103-103, 104-104
web/core/components/dropdowns/project.tsx (4)
15-16
: LGTM: Import statement for TProject added correctly.The import statement for
TProject
from@/plane-web/types
has been added correctly. This change aligns with the transition fromIProject
toTProject
type.
Line range hint
1-238
: Summary: TProject integration looks good, final verification recommended.The changes to integrate
TProject
instead ofIProject
in theProjectDropdown
component look good. The import statement and prop type have been updated correctly. To ensure a smooth transition, please:
- Verify that all usages of
renderCondition
within the component are compatible withTProject
.- Confirm that
getProjectById
and all usages ofprojectDetails
are compatible withTProject
.- Run a final type-check and build process to catch any potential type-related issues.
These steps will help ensure that the refactoring from
IProject
toTProject
is complete and consistent throughout the component and its dependencies.
30-30
: LGTM: Prop type updated to use TProject.The
renderCondition
prop type has been correctly updated to useTProject
instead ofIProject
. This change is consistent with the new import statement.To ensure consistency, please verify that all usages of
renderCondition
within the component are compatible with theTProject
type. Run the following script to check for any remaining references toIProject
:
Line range hint
1-238
: Verify compatibility of getProjectById and projectDetails with TProject.While the prop type has been updated to use
TProject
, it's important to ensure thatgetProjectById
from theuseProject
hook and all usages ofprojectDetails
throughout the component are compatible with theTProject
type.Please run the following script to check the type definition of
getProjectById
and verify its compatibility withTProject
:If any incompatibilities are found, please update the relevant parts of the component to ensure full compatibility with
TProject
.web/core/components/workspace/sidebar/projects-list.tsx (1)
Line range hint
1-324
: Overall, the changes look good and align with the PR objectives.The transition from
IProject
toTProject
, addition of user permission checks, and related import changes have been implemented correctly. The suggestions provided are minor and aimed at improving code clarity and type safety.Great job on maintaining consistency throughout the file while implementing these changes!
Summary by CodeRabbit
New Features
Bug Fixes
Documentation