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

chore: Shadow PR for external contribution 36882 #36969

Closed
wants to merge 2 commits into from

Conversation

ankitakinger
Copy link
Contributor

@ankitakinger ankitakinger commented Oct 18, 2024

Description

Shadow PR for external contribution 36882

Corresponding EE PR:

Fixes #9643

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Caution

If you modify the content in this section, you are likely to disrupt the CI result for your PR.

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced editing experience in the EditableTextSubComponent with cancel and confirm options.
    • Users can reset to the last valid input if editing is canceled.
  • Bug Fixes

    • Removed unnecessary dynamic state tracking in the ApplicationCard, simplifying state management.
  • Refactor

    • Streamlined state handling in the ApplicationCard component.

Sai6347 and others added 2 commits October 15, 2024 18:03
…me-or-organization-name-9643' of github.com:Sai6347/appsmith into chore/external-contribution-36882
Copy link
Contributor

coderabbitai bot commented Oct 18, 2024

Walkthrough

The changes in this pull request involve updates to the EditableTextSubComponent and ApplicationCard components. The EditableTextSubComponent has been enhanced to improve user interaction during editing by introducing a cancellation state and modifying the confirm functionality. Conversely, the ApplicationCard component has simplified its state management by converting a dynamic state variable to a constant, removing the ability to track changes in the application name during editing.

Changes

File Path Change Summary
app/client/packages/design-system/ads-old/src/EditableTextSubComponent/index.tsx Added isCancelled state, modified onConfirm, added onCancel, and updated rendering logic for better interaction.
app/client/src/pages/Applications/ApplicationCard.tsx Changed lastUpdatedValue from a dynamic state variable to a constant string, removing dynamic tracking.

Assessment against linked issues

Objective Addressed Explanation
Update the editable text component for Action names on action editor (#36793)

Possibly related PRs

Suggested labels

IDE Product, Task, skip-changelog, IDE Pod, ok-to-test

Suggested reviewers

  • hetunandu
  • albinAppsmith

🎉 In the land of code, where changes flow,
Editable texts now shine and glow!
With cancel and confirm, oh what a delight,
User interactions are now just right!
Application Card, simplified and neat,
A journey of updates, oh what a treat! 🌟


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.

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.

@github-actions github-actions bot added IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Task A simple Todo labels Oct 18, 2024
@ankitakinger
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Oct 18, 2024
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11403133429.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36969.
recreate: .

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

🧹 Outside diff range and nitpick comments (2)
app/client/src/pages/Applications/ApplicationCard.tsx (1)

Line range hint 324-332: Update logic in handleMenuOnClose affected by lastUpdatedValue change

The condition lastUpdatedValue && props.application.name !== lastUpdatedValue in handleMenuOnClose will always be false due to lastUpdatedValue being an empty string constant. This breaks the update logic for the application name.

To resolve this:

  1. Remove the condition and associated update logic if it's no longer needed.
  2. If the update functionality is still required, implement an alternative method to track changes in the application name.
app/client/packages/design-system/ads-old/src/EditableTextSubComponent/index.tsx (1)

73-73: Remove unnecessary commented-out code

The commented-out CSS line // justify-content: space-evenly; can be removed to keep the code clean.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f547821 and 9a75b07.

📒 Files selected for processing (2)
  • app/client/packages/design-system/ads-old/src/EditableTextSubComponent/index.tsx (5 hunks)
  • app/client/src/pages/Applications/ApplicationCard.tsx (1 hunks)
🧰 Additional context used
🪛 Biome
app/client/packages/design-system/ads-old/src/EditableTextSubComponent/index.tsx

[error] 232-232: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (4)
app/client/packages/design-system/ads-old/src/EditableTextSubComponent/index.tsx (4)

141-141: Declaration of isCancelled state variable

The introduction of isCancelled state is appropriate for tracking the cancellation state.


191-192: Updating lastValidValue in onConfirm

Good job updating lastValidValue after confirmation. This ensures the component retains the latest valid input.


228-228: Include all dependencies in useCallback

Including valueTransform in the dependency array ensures the callback stays updated with the latest transformation logic.


278-305: Add confirm and cancel icons for better user interaction

The addition of confirm and cancel icons enhances the user experience during editing.

@@ -117,7 +117,7 @@ export function ApplicationCard(props: ApplicationCardProps) {
const [isDeleting, setIsDeleting] = useState(false);
const [isForkApplicationModalopen, setForkApplicationModalOpen] =
useState(false);
const [lastUpdatedValue, setLastUpdatedValue] = useState("");
const lastUpdatedValue = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Potential loss of functionality due to state removal

The conversion of lastUpdatedValue from a state variable to a constant empty string may lead to unexpected behavior. This change removes the ability to track updates to the application name during editing.

Consider the following options:

  1. If tracking the last updated value is no longer necessary, remove all references to lastUpdatedValue in the component.
  2. If tracking is still required, revert this change and keep lastUpdatedValue as a state variable.

💡 Codebase verification

Residual References to lastUpdatedValue Detected

The lastUpdatedValue variable is still referenced in ApplicationCard.tsx, indicating that its removal may be incomplete. This could lead to potential bugs or inconsistent behavior.

  • File: app/client/src/pages/Applications/ApplicationCard.tsx
    • Line 120: const lastUpdatedValue = "";
    • Line 123: if (lastUpdatedValue && props.application.name !== lastUpdatedValue) {
🔗 Analysis chain

Verify intended behavior for application name updates

The changes to lastUpdatedValue and the lack of an onTextChanged handler for EditableText suggest that real-time tracking of application name changes has been removed. This is a significant change in the component's behavior.

Please confirm if this is the intended behavior. If not, consider:

  1. Reinstating lastUpdatedValue as a state variable.
  2. Adding an onTextChanged handler to EditableText to track changes.
  3. Updating the logic in handleMenuOnClose to properly handle name updates.

To verify the current behavior, you can run the following script:

Also applies to: 324-332

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining references to lastUpdatedValue or onTextChanged
rg 'lastUpdatedValue|onTextChanged' app/client/src/pages/Applications/ApplicationCard.tsx

Length of output: 235

);

const onCancel = useCallback(() => {
onBlur && onBlur(lastValidValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use optional chaining for optional function calls

Replace onBlur && onBlur(lastValidValue); with onBlur?.(lastValidValue); for cleaner and more concise code.

Apply this diff:

- onBlur && onBlur(lastValidValue);
+ onBlur?.(lastValidValue);
📝 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
onBlur && onBlur(lastValidValue);
onBlur?.(lastValidValue);
🧰 Tools
🪛 Biome

[error] 232-232: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Comment on lines +231 to +245
const onCancel = useCallback(() => {
onBlur && onBlur(lastValidValue);
setIsEditing(false);
setIsInvalid(false);
setSavingState(SavingState.NOT_STARTED);
setValue(lastValidValue);
setIsCancelled(true);
}, [lastValidValue, onBlur]);

useEffect(() => {
if (isCancelled) {
setValue(lastValidValue);
}
}, [isCancelled, lastValidValue]);

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify cancellation logic by removing redundant state

The isCancelled state and its associated useEffect are unnecessary. Since setValue(lastValidValue) is already called in onCancel, you can remove isCancelled and the useEffect to simplify the code.

Apply this diff to simplify the code:

- const [isCancelled, setIsCancelled] = useState<boolean>(false);

  const onCancel = useCallback(() => {
    onBlur && onBlur(lastValidValue);
    setIsEditing(false);
    setIsInvalid(false);
    setSavingState(SavingState.NOT_STARTED);
    setValue(lastValidValue);
-   setIsCancelled(true);
  }, [lastValidValue, onBlur]);

- useEffect(() => {
-   if (isCancelled) {
-     setValue(lastValidValue);
-   }
- }, [isCancelled, lastValidValue]);
📝 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 onCancel = useCallback(() => {
onBlur && onBlur(lastValidValue);
setIsEditing(false);
setIsInvalid(false);
setSavingState(SavingState.NOT_STARTED);
setValue(lastValidValue);
setIsCancelled(true);
}, [lastValidValue, onBlur]);
useEffect(() => {
if (isCancelled) {
setValue(lastValidValue);
}
}, [isCancelled, lastValidValue]);
const onCancel = useCallback(() => {
onBlur && onBlur(lastValidValue);
setIsEditing(false);
setIsInvalid(false);
setSavingState(SavingState.NOT_STARTED);
setValue(lastValidValue);
}, [lastValidValue, onBlur]);
🧰 Tools
🪛 Biome

[error] 232-232: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Copy link

Deploy-Preview-URL: https://ce-36969.dp.appsmith.com

@github-actions github-actions bot added Bug Something isn't working Home Page Issues related to the application home page Inviting Contribution Issues that we would like contributions to Low An issue that is neither critical nor breaks a user flow Low effort Takes 1-2 days Needs Triaging Needs attention from maintainers to triage Platform Administration Pod Issues related to platform administration & management Production Workspace Product Issues related to workspaces and removed Bug Something isn't working labels Oct 18, 2024
@ankitakinger ankitakinger deleted the chore/external-contribution-36882 branch October 18, 2024 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Home Page Issues related to the application home page IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Inviting Contribution Issues that we would like contributions to Low effort Takes 1-2 days Low An issue that is neither critical nor breaks a user flow Needs Triaging Needs attention from maintainers to triage Platform Administration Pod Issues related to platform administration & management Production skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo Workspace Product Issues related to workspaces
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: The empty space is clickable when the user edits the App name or the organisation name
2 participants