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: git pkg - package integration with git #39342

Merged
merged 5 commits into from
Feb 19, 2025
Merged

Conversation

brayn003
Copy link
Contributor

@brayn003 brayn003 commented Feb 18, 2025

Description

  • integrating packages with git

Fixes #38505

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13409662643
Commit: 820025a
Cypress dashboard.
Tags: @tag.Git
Spec:


Wed, 19 Feb 2025 10:39:11 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced the Git import process to better distinguish between complete and partial imports, triggering appropriate UI prompts and navigation.
    • Introduced a new action for handling successful Git imports.
  • Refactor

    • Streamlined the underlying logic for Git import handling to deliver clearer user feedback and a more efficient experience.
  • Chores

    • Updated type definitions and action payloads for improved type safety and maintainability.
    • Added .lens to the .gitignore file to exclude it from version control.

@brayn003 brayn003 changed the title chore: adding post import sagas for application chore: git pkg - package integration with git Feb 18, 2025
@github-actions github-actions bot added Git Product Issues related to version control product Packages & Git Pod All issues belonging to Packages and Git Task A simple Todo skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Feb 18, 2025
Copy link
Contributor

coderabbitai bot commented Feb 18, 2025

Walkthrough

This pull request introduces a new saga function to handle Git application imports, updating the control flow for Git import operations. It adds a new generator, applicationImportFromGitSaga, which manages partial and complete imports by either triggering a datasource reconnection modal or navigating to the appropriate builder URL with a success toast. Additionally, type definitions and action payloads have been updated to reflect Git artifact structures, and the Git import success action is now exported for broader usage.

Changes

File(s) Change Summary
app/client/src/git-artifact-helpers/.../applicationImportFromGitSaga.ts
app/client/src/git-artifact-helpers/.../sagas/index.ts
Introduces a new saga (applicationImportFromGitSaga) for handling Git application imports. Integrates the saga with the gitImportSuccess action using takeLatest.
app/client/src/git/requests/.../gitImportRequest.types.ts Updates the GitImportResponseData interface: replaces ApplicationResponsePayload with GitApplicationArtifact, and adds an optional package property using GitPackageArtifact.
app/client/src/git/sagas/.../gitImportSaga.ts Simplifies Git import processing by removing workspace filtering and application detail handling; now dispatches a success action and toggles the import modal, while retaining error handling.
app/client/src/git/store/actions/.../gitImportActions.ts Refines action payload types by introducing GitImportSuccessPayload and updating gitImportSuccessAction to use the new type for enhanced type safety.
app/client/src/git/store/index.ts Exports the new gitImportSuccess action, making it available for triggering Git import success operations.
.gitignore Adds .lens to the ignore list, expanding the scope of ignored files.

Possibly related PRs

Suggested labels

Enhancement

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007
  • NandanAnantharamu

Poem

In our code realm, a new saga has sprung,
Guiding Git imports like a well-struck gong.
Modals and toasts now join the parade,
With cleaner flows seamlessly laid.
Let the code rejoice – fresh features are sung! 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 688e801 and 42730f0.

📒 Files selected for processing (1)
  • .gitignore (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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

🧹 Nitpick comments (5)
app/client/src/git/store/actions/gitImportActions.ts (1)

29-38: Consider adding return type annotation

The action creator would benefit from an explicit return type annotation for better type safety.

 export const gitImportSuccessAction = (
   state: GitGlobalReduxState,
   // need this here to preserve interface
   // eslint-disable-next-line @typescript-eslint/no-unused-vars
   action: GitImportSuccessPayload,
-) => {
+): GitGlobalReduxState => {
   state.gitImport.loading = false;

   return state;
 };
app/client/src/git-artifact-helpers/application/sagas/applicationImportFromGitSaga.ts (3)

17-20: Consider adding error handling for missing application data.

The early return when application is null could benefit from error logging or user notification.

-  if (!application) return;
+  if (!application) {
+    toast.show("Failed to import application: Invalid response data", {
+      kind: "error",
+    });
+    return;
+  }

25-30: Type assertion can be replaced with type guard.

The type assertion for application is redundant since we've already validated its existence.

-        application: application as ApplicationResponsePayload,
+        application,

34-40: Consider extracting page finding logic to a utility function.

The default page finding logic could be reused elsewhere in the application.

+const getDefaultPageId = (pages: Array<{isDefault: boolean, baseId: string}>) => {
+  const defaultPage = pages.find((page) => !!page.isDefault);
+  return defaultPage ? defaultPage.baseId : "";
+};

-    if (application.pages && application.pages.length > 0) {
-      const defaultPage = application.pages.find(
-        (eachPage) => !!eachPage.isDefault,
-      );
-
-      basePageId = defaultPage ? defaultPage.baseId : "";
-    }
+    basePageId = application.pages?.length 
+      ? getDefaultPageId(application.pages)
+      : "";
app/client/src/git/sagas/gitImportSaga.ts (1)

40-51: Consider standardizing error modal handling.

The repo limit error case has special handling. Consider standardizing error modal behavior for all error types.

   if (error) {
     yield put(gitGlobalActions.gitImportError({ error }));
 
-    if (GitErrorCodes.REPO_LIMIT_REACHED === error.code) {
+    const errorModalConfig = {
+      [GitErrorCodes.REPO_LIMIT_REACHED]: {
+        modalAction: gitGlobalActions.toggleRepoLimitErrorModal,
+      },
+      // Add other error types here
+    };
+
+    if (errorModalConfig[error.code]) {
       yield put(gitGlobalActions.toggleImportModal({ open: false }));
-      yield put(gitGlobalActions.toggleRepoLimitErrorModal({ open: true }));
+      yield put(errorModalConfig[error.code].modalAction({ open: true }));
     }
   }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95e8e37 and 3f30318.

📒 Files selected for processing (6)
  • app/client/src/git-artifact-helpers/application/sagas/applicationImportFromGitSaga.ts (1 hunks)
  • app/client/src/git-artifact-helpers/application/sagas/index.ts (1 hunks)
  • app/client/src/git/requests/gitImportRequest.types.ts (2 hunks)
  • app/client/src/git/sagas/gitImportSaga.ts (1 hunks)
  • app/client/src/git/store/actions/gitImportActions.ts (2 hunks)
  • app/client/src/git/store/index.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
🔇 Additional comments (5)
app/client/src/git/requests/gitImportRequest.types.ts (1)

14-19:

❓ Verification inconclusive

Verify handling of optional fields in consumers

The application and package fields are now optional in GitImportResponseData. Ensure all consumers handle these nullable fields appropriately.


🏁 Script executed:

#!/bin/bash
# Search for direct usage of these fields
rg "\.application\." --type ts
rg "\.package\." --type ts

Length of output: 887


Important: Validate Optional Field Handling in Consumers

  • Consumers using the application field (e.g., in app/client/src/usagePulse/index.ts, ApplicationSagas.tsx, and related tests) are already performing null-checks.
  • No direct consumers for the package field were detected. Please manually verify that this optional field is safe for future use and—if needed—update consumer code or add tests/documentation to address potential null issues.
app/client/src/git/store/index.ts (1)

20-20: LGTM!

The export follows the established pattern and is necessary for the new Git import functionality.

app/client/src/git-artifact-helpers/application/sagas/index.ts (1)

15-16: LGTM!

The saga integration follows the established pattern using takeLatest for handling Git import success.

app/client/src/git/store/actions/gitImportActions.ts (1)

26-28: LGTM!

The new type definition enhances type safety for Git import success actions.

app/client/src/git/sagas/gitImportSaga.ts (1)

35-38: LGTM! Clean implementation of success path.

The success path has been simplified to focus on essential actions.

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

🧹 Nitpick comments (1)
app/client/src/git/store/actions/gitImportActions.ts (1)

29-34: Consider documenting the interface preservation requirement.

The comment "need this here to preserve interface" could use more context. Consider adding a brief explanation of why the action parameter is required but unused.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f30318 and 688e801.

📒 Files selected for processing (1)
  • app/client/src/git/store/actions/gitImportActions.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (3)
app/client/src/git/store/actions/gitImportActions.ts (3)

2-10: LGTM! Well-organized type imports.

The separation of imports improves readability and the imported types align well with the Git import functionality.


26-27: LGTM! Clean type composition.

The GitImportSuccessPayload type effectively combines the async success payload with the import response data.


1-51:

❓ Verification inconclusive

Verify integration with applicationImportFromGitSaga.

The changes look good, but let's verify the integration with the new saga mentioned in the AI summary.


🏁 Script executed:

#!/bin/bash
# Search for usage of GitImportSuccessPayload in the saga
ast-grep --pattern 'type GitArtifactPayloadAction<GitImportSuccessPayload>'

Length of output: 73132


Manual Verification Required: Saga Integration Check

The updated Git import actions look good overall. However, our automated search using ast-grep did not conclusively reveal any direct usage of GitImportSuccessPayload in the expected saga (applicationImportFromGitSaga). Please manually verify that the saga properly integrates and handles the payloads defined in this file to ensure complete end-to-end coverage.

@brayn003 brayn003 self-assigned this Feb 18, 2025
@brayn003 brayn003 requested a review from ashit-rath February 18, 2025 14:58
@brayn003 brayn003 added the ok-to-test Required label for CI label Feb 18, 2025
@brayn003 brayn003 merged commit 8d4f616 into release Feb 19, 2025
43 checks passed
@brayn003 brayn003 deleted the chore/git-pkg-5 branch February 19, 2025 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Git Product Issues related to version control product ok-to-test Required label for CI Packages & Git Pod All issues belonging to Packages and Git skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Git pkg - Git module integraiton
2 participants