-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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-2677] chore: draft issue issue type #5836
Conversation
WalkthroughThe changes in this pull request introduce a new optional property Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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: 4
🧹 Outside diff range and nitpick comments (1)
web/core/components/issues/issue-modal/base.tsx (1)
Line range hint
289-290
: LGTM: Improved form submission handlingThe changes in
handleFormSubmit
enhance the robustness of the form submission process:
- Making
is_draft_issue
a required parameter ensures explicit specification of the draft status.- Removing
sourceIssueId
from the payload prevents sending unnecessary data.These modifications align well with the PR objectives and improve the overall code quality.
Consider using object destructuring for cleaner code:
const { sourceIssueId, ...payloadWithoutSource } = payload;This approach would create a new object
payloadWithoutSource
without thesourceIssueId
property, making the removal more explicit and potentially easier to understand.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
- web/ce/components/issues/issue-modal/additional-properties.tsx (1 hunks)
- web/core/components/issues/issue-modal/base.tsx (2 hunks)
- web/core/components/issues/issue-modal/context/issue-modal.tsx (1 hunks)
- web/core/components/issues/issue-modal/draft-issue-layout.tsx (1 hunks)
- web/core/components/issues/issue-modal/form.tsx (5 hunks)
🧰 Additional context used
🔇 Additional comments (9)
web/ce/components/issues/issue-modal/additional-properties.tsx (2)
6-6
: LGTM: Addition ofisDraft
propertyThe addition of the optional
isDraft
property toTIssueAdditionalPropertiesProps
is appropriate and aligns with the PR objective of implementing a new issue type for draft issues. The boolean type is suitable for this flag, and making it optional ensures backward compatibility.
9-9
: Verify the empty implementation ofIssueAdditionalProperties
The
IssueAdditionalProperties
component is currently not utilizing any of the props defined inTIssueAdditionalPropertiesProps
, including the newly addedisDraft
. Please confirm if this is intentional and if there are plans to implement this component in the future.If this is a placeholder for future implementation, consider adding a TODO comment to make it clear for other developers. For example:
// TODO: Implement additional properties for issues, including draft status export const IssueAdditionalProperties: React.FC<TIssueAdditionalPropertiesProps> = () => <></>;web/core/components/issues/issue-modal/context/issue-modal.tsx (2)
25-25
: LGTM: NewisDraft
property added toTCreateUpdatePropertyValuesProps
The addition of the optional
isDraft
property to theTCreateUpdatePropertyValuesProps
type is consistent with the PR objectives of implementing a new issue type for draft issues. This change allows for the distinction between draft and non-draft issues during creation and updates.However, to ensure consistency across the codebase:
✅ Verification successful
**** The
isDraft
property has been successfully added toTCreateUpdatePropertyValuesProps
and is consistently used across the codebase. No additional updates are required.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check if the `isDraft` property is used consistently in other relevant types and functions. # Test 1: Search for other occurrences of TCreateUpdatePropertyValuesProps echo "Searching for other occurrences of TCreateUpdatePropertyValuesProps:" rg --type typescript "TCreateUpdatePropertyValuesProps" # Test 2: Search for uses of handleCreateUpdatePropertyValues to ensure they're updated if necessary echo "Searching for uses of handleCreateUpdatePropertyValues:" rg --type typescript "handleCreateUpdatePropertyValues" # Test 3: Search for other types or interfaces that might need the isDraft property echo "Searching for other types or interfaces that might need the isDraft property:" rg --type typescript "type.*\{" -A 10 | rg "issue|Issue"Length of output: 708
Script:
#!/bin/bash # Description: Check if the `isDraft` property is used consistently in other relevant types and functions. # Test 1: Search for other occurrences of TCreateUpdatePropertyValuesProps in TypeScript files echo "Searching for other occurrences of TCreateUpdatePropertyValuesProps:" rg -t ts -t tsx "TCreateUpdatePropertyValuesProps" # Test 2: Search for uses of handleCreateUpdatePropertyValues to ensure they're updated if necessary echo "Searching for uses of handleCreateUpdatePropertyValues:" rg -t ts -t tsx "handleCreateUpdatePropertyValues" # Test 3: Search for other types or interfaces that might need the isDraft property echo "Searching for other types or interfaces that might need the isDraft property:" rg -t ts -t tsx "type\s+\w+\s+\{" -A 10 | rg "issue|Issue"Length of output: 679
Script:
#!/bin/bash # Description: Check if the `isDraft` property is used consistently in other relevant types and functions. # Test 1: Search for other occurrences of TCreateUpdatePropertyValuesProps in .ts and .tsx files echo "Searching for other occurrences of TCreateUpdatePropertyValuesProps:" rg "TCreateUpdatePropertyValuesProps" -g "*.ts" -g "*.tsx" # Test 2: Search for uses of handleCreateUpdatePropertyValues to ensure they're updated if necessary echo "Searching for uses of handleCreateUpdatePropertyValues:" rg "handleCreateUpdatePropertyValues" -g "*.ts" -g "*.tsx" # Test 3: Search for other types or interfaces that might need the isDraft property in .ts and .tsx files echo "Searching for other types or interfaces that might need the isDraft property:" rg "type\s+\w+\s+\{" -A 10 -g "*.ts" -g "*.tsx" | rg "issue|Issue"Length of output: 1817
Line range hint
32-39
: Verify implementation ofhandleCreateUpdatePropertyValues
The
TIssueModalContext
type includes ahandleCreateUpdatePropertyValues
function that uses the updatedTCreateUpdatePropertyValuesProps
type. Ensure that the implementation of this function (which is likely in another file) correctly handles the newisDraft
property.web/core/components/issues/issue-modal/draft-issue-layout.tsx (1)
145-145
: LGTM with suggestions for improvementThe addition of
isDraft: true
to thehandleCreateUpdatePropertyValues
function call is appropriate for identifying the issue as a draft. However, there are a couple of points to consider:
- The
isDraft
prop is defined in theDraftIssueProps
interface but not used in the component's parameters. For consistency, consider updating the component definition to include this prop:export const DraftIssueLayout: React.FC<DraftIssueProps> = observer((props) => { const { // ... other props isDraft, // ... remaining props } = props; // ... rest of the component });
- Ensure that the
handleCreateUpdatePropertyValues
function in the parent component or context correctly handles theisDraft
property. You may want to verify its implementation to confirm that it processes this flag appropriately.To verify the handling of the
isDraft
property, you can run the following script:This script will help you locate the implementation of
handleCreateUpdatePropertyValues
and check if it properly handles theisDraft
property.web/core/components/issues/issue-modal/base.tsx (3)
207-207
: LGTM: Proper handling of draft status in property valuesThe addition of the
isDraft
parameter tohandleCreateUpdatePropertyValues
ensures that the draft status is correctly handled when creating or updating issue property values. This change aligns well with the PR objective of implementing a new issue type for draft issues.
261-261
: LGTM: Consistent handling of draft status in issue updatesThe addition of the
isDraft
parameter tohandleCreateUpdatePropertyValues
in thehandleUpdateIssue
method ensures consistency in handling the draft status when updating issues. This change maintains alignment with the PR objective and the previous modification inhandleCreateIssue
.
Line range hint
1-368
: Overall assessment: Changes are well-implemented and align with PR objectivesThe modifications in this file consistently implement the handling of draft issues across different methods (
handleCreateIssue
,handleUpdateIssue
, andhandleFormSubmit
). These changes align well with the PR objective of introducing a new issue type for draft issues.Key improvements:
- Consistent addition of
isDraft
parameter in relevant method calls.- Explicit requirement of
is_draft_issue
parameter inhandleFormSubmit
.- Removal of unnecessary
sourceIssueId
from the payload during form submission.These changes enhance the robustness and clarity of the issue creation and update processes. The code quality is good, with only a minor suggestion for improvement in the
handleFormSubmit
method.web/core/components/issues/issue-modal/form.tsx (1)
364-364
: Verify necessity of passingisDraft
propPassing
isDraft={isDraft}
to theIssueAdditionalProperties
component may be unnecessary if the component doesn't utilize this prop. Unused props can lead to confusion and maintenance overhead.Please confirm whether
IssueAdditionalProperties
requires theisDraft
prop. If not, consider removing it to simplify the component's API.
@@ -352,7 +352,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => { | |||
className={cn( | |||
"px-5", | |||
activeAdditionalPropertiesLength <= 4 && | |||
"max-h-[25vh] overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm" | |||
"max-h-[25vh] overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm" |
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.
🛠️ Refactor suggestion
Consistent handling of container overflow
Similar to the previous comment, using max-h-[25vh]
may lead to inconsistent behavior across devices. Removing fixed heights promotes a more fluid layout.
Update the className to allow content-driven sizing:
- "max-h-[25vh] overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm"
+ "overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm"
📝 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.
"max-h-[25vh] overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm" | |
"overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm" |
@@ -393,7 +394,7 @@ | |||
tabIndex={getIndex("create_more")} | |||
role="button" | |||
> | |||
<ToggleSwitch value={isCreateMoreToggleEnabled} onChange={() => { }} size="sm" /> | |||
<ToggleSwitch value={isCreateMoreToggleEnabled} onChange={() => {}} size="sm" /> |
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.
🛠️ Refactor suggestion
Handle toggle state within ToggleSwitch
component
Currently, the ToggleSwitch
has an empty onChange
handler, and the state change is managed by the parent <div>
. This approach can lead to unexpected behavior and complicates the component interaction.
It's better practice to handle the toggle state within the onChange
prop of the ToggleSwitch
component. Update the code as follows:
<div className="inline-flex items-center gap-1.5 cursor-pointer">
- <ToggleSwitch value={isCreateMoreToggleEnabled} onChange={() => {}} size="sm" />
+ <ToggleSwitch
+ value={isCreateMoreToggleEnabled}
+ onChange={() => onCreateMoreToggleChange(!isCreateMoreToggleEnabled)}
+ size="sm"
+ />
<span className="text-xs">Create more</span>
</div>
Additionally, you can remove the onClick
, onKeyDown
, tabIndex
, and role
attributes from the parent <div>
since the interaction is now handled within ToggleSwitch
. This improves accessibility and aligns with React best practices.
📝 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.
<ToggleSwitch value={isCreateMoreToggleEnabled} onChange={() => {}} size="sm" /> | |
<ToggleSwitch | |
value={isCreateMoreToggleEnabled} | |
onChange={() => onCreateMoreToggleChange(!isCreateMoreToggleEnabled)} | |
size="sm" | |
/> |
...getChangedIssuefields(formData, dirtyFields as { [key: string]: boolean | undefined }), | ||
project_id: getValues<"project_id">("project_id"), | ||
id: data.id, | ||
description_html: formData.description_html ?? "<p></p>", | ||
type_id: getValues<"type_id">("type_id"), | ||
}; |
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.
🛠️ Refactor suggestion
Ensure consistent inclusion of is_draft
in submitData
In the handleFormSubmit
function, the submitData
object may not always include the is_draft
property, which could lead to inconsistencies when submitting draft issues. While you conditionally add is_draft
later, it's clearer and safer to include it explicitly during the submitData
construction.
Consider modifying the submitData
to always include the is_draft
property:
const submitData = !data?.id
? formData
: {
...getChangedIssuefields(formData, dirtyFields as { [key: string]: boolean | undefined }),
project_id: getValues<"project_id">("project_id"),
id: data.id,
description_html: formData.description_html ?? "<p></p>",
type_id: getValues<"type_id">("type_id"),
+ is_draft: formData.is_draft,
};
This ensures that the draft status is consistently handled during updates.
📝 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.
...getChangedIssuefields(formData, dirtyFields as { [key: string]: boolean | undefined }), | |
project_id: getValues<"project_id">("project_id"), | |
id: data.id, | |
description_html: formData.description_html ?? "<p></p>", | |
type_id: getValues<"type_id">("type_id"), | |
}; | |
...getChangedIssuefields(formData, dirtyFields as { [key: string]: boolean | undefined }), | |
project_id: getValues<"project_id">("project_id"), | |
id: data.id, | |
description_html: formData.description_html ?? "<p></p>", | |
type_id: getValues<"type_id">("type_id"), | |
is_draft: formData.is_draft, | |
}; |
@@ -323,7 +323,7 @@ | |||
className={cn( | |||
"pb-4 space-y-3", | |||
activeAdditionalPropertiesLength > 4 && | |||
"max-h-[45vh] overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm" | |||
"max-h-[45vh] overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm" |
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.
🛠️ Refactor suggestion
Avoid hardcoded height values for better responsiveness
Using fixed heights like max-h-[45vh]
can cause layout issues on different screen sizes. This might limit the component's flexibility and affect user experience on various devices.
Consider using dynamic sizing or responsive design utilities to enhance adaptability:
- "max-h-[45vh] overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm"
+ "overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm"
This change allows the container to adjust its height based on content and screen size.
📝 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.
"max-h-[45vh] overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm" | |
"overflow-hidden overflow-y-auto vertical-scrollbar scrollbar-sm" |
Changes:
This PR includes issue type implementation for draft issues.
Reference:
[WEB-2677]
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
isDraft
property for better clarity and usability.