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 mod - settings modal #38155

Merged
merged 89 commits into from
Dec 17, 2024
Merged

chore: git mod - settings modal #38155

merged 89 commits into from
Dec 17, 2024

Conversation

brayn003
Copy link
Contributor

@brayn003 brayn003 commented Dec 13, 2024

Description

  • Adds settings modal
  • Adds CD/EE split

Fixes #37808
Fixes #37814
Fixes #37810
Fixes #37813
Fixes #37809

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/12368684531
Commit: 047af23
Cypress dashboard.
Tags: @tag.Git
Spec:


Tue, 17 Dec 2024 09:01:24 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced new components for managing protected branches, settings modals, and disconnect functionality.
    • Added custom hooks for managing autocommit, global and local profiles, and feature flags.
    • Implemented new sagas for handling disconnect and autocommit toggle actions.
    • Added a new constant for Git remote branch prefix.
    • Introduced a component for continuous delivery configuration when unlicensed.
    • Added a new component for confirming the disabling of autocommit functionality.
  • Improvements

    • Enhanced state management for Git operations, including updates to Redux selectors and action creators.
    • Streamlined prop handling and component structure across various Git-related components.
    • Updated the structure of metadata fetching and response handling.
  • Bug Fixes

    • Updated error handling and response validation in sagas to ensure robust operation.
  • Refactor

    • Renamed and reorganized various components and hooks for clarity and consistency.
    • Consolidated saga management for better organization.
  • Documentation

    • Improved comments and documentation for better understanding of new functionalities.

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

🧹 Outside diff range and nitpick comments (11)
app/client/src/git/sagas/toggleAutocommitSaga.ts (2)

26-28: Use optional chaining for safer error handling.

The error check can be simplified using optional chaining.

-    if (response && response.responseMeta.error) {
+    if (response?.responseMeta?.error) {
       const { error } = response.responseMeta;
🧰 Tools
🪛 Biome (1.9.4)

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

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


15-15: Consider making the response type non-optional.

Since the response is used in the error handling block, consider removing the undefined union type to maintain stricter type safety.

-  let response: ToggleAutocommitResponse | undefined;
+  let response: ToggleAutocommitResponse;
app/client/src/git/components/SettingsModal/TabContinuousDelivery/index.tsx (3)

1-11: Consider simplifying the hook import path

The import path for useAppsmithEnterpriseLink is deeply nested. Consider moving shared hooks to a common location.

-import { useAppsmithEnterpriseLink } from "pages/Editor/gitSync/GitSettingsModal/TabBranch/hooks";
+import { useAppsmithEnterpriseLink } from "@appsmith/git/hooks";

12-17: Extract magic numbers into constants

The min-height calculation uses magic numbers. Consider extracting these values into named constants for better maintainability.

+const MODAL_BASE_HEIGHT = 360;
+const MODAL_PADDING = 52;
+
 export const Container = styled.div`
   padding-top: 8px;
   padding-bottom: 16px;
   overflow: auto;
-  min-height: calc(360px + 52px);
+  min-height: calc(${MODAL_BASE_HEIGHT}px + ${MODAL_PADDING}px);
 `;

32-56: Consider adding security attributes to external link

The implementation looks good overall. For the external link, consider adding security-related attributes.

 <StyledButton
   href={enterprisePricingLink}
   kind="primary"
   renderAs="a"
   size="md"
   target="_blank"
+  rel="noopener noreferrer"
 >
app/client/src/git/sagas/disconnectSaga.ts (3)

52-52: Simplify the Conditional Check with Optional Chaining

Consider using optional chaining to simplify the condition in the error handling.

Apply this diff to modify the condition:

-if (response && response.responseMeta.error) {
+if (response?.responseMeta.error) {
🧰 Tools
🪛 Biome (1.9.4)

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

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


30-31: Remove Unnecessary Commented-Out Code

Please remove the commented-out code if it's no longer needed to keep the codebase clean.


41-50: Clean Up Commented-Out Blocks

Consider removing or explaining the purpose of the commented-out code block.

app/client/src/git/components/ContinuousDelivery/index.tsx (1)

6-14: LGTM! Consider adding component documentation.

Clean implementation of feature flag based routing between CE and EE versions.

Add JSDoc comment to document the component's purpose:

+/**
+ * Routes to either CE or EE version of Continuous Delivery component
+ * based on the feature flag status.
+ */
function ContinuousDelivery() {
app/client/src/git/hooks/useGitFeatureFlags.ts (1)

12-16: Consider memoizing the returned object to prevent unnecessary re-renders.

The returned object is recreated on every render, which could trigger re-renders in consuming components.

+ import { useMemo } from "react";

  export default function useGitFeatureFlags() {
    const license_git_branch_protection_enabled = useFeatureFlag(
      FEATURE_FLAG.license_git_branch_protection_enabled,
    );
    const license_git_continuous_delivery_enabled = useFeatureFlag(
      FEATURE_FLAG.license_git_continuous_delivery_enabled,
    );

-   return {
-     license_git_branch_protection_enabled,
-     license_git_continuous_delivery_enabled,
-   };
+   return useMemo(
+     () => ({
+       license_git_branch_protection_enabled,
+       license_git_continuous_delivery_enabled,
+     }),
+     [license_git_branch_protection_enabled, license_git_continuous_delivery_enabled]
+   );
  }
app/client/src/git/components/ContinuousDelivery/ContinuousDeliveryCE.tsx (1)

38-54: Enhance accessibility with ARIA attributes.

The component could benefit from improved accessibility for screen readers.

  <Container>
-   <SectionTitle kind="heading-s" renderAs="h3">
+   <SectionTitle kind="heading-s" renderAs="h3" role="heading" aria-level="3">
      {createMessage(CONFIGURE_CD_TITLE)}
    </SectionTitle>
-   <SectionDesc kind="body-m" renderAs="p">
+   <SectionDesc kind="body-m" renderAs="p" aria-describedby="cd-description">
      {createMessage(CONFIGURE_CD_DESC)}
    </SectionDesc>
    <StyledButton
      href={enterprisePricingLink}
      kind="primary"
      renderAs="a"
      size="md"
      target="_blank"
+     aria-label="Try Appsmith Enterprise for Continuous Delivery features"
    >
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7b48aa2 and 612c35a.

📒 Files selected for processing (11)
  • app/client/src/ee/git/components/ContinuousDelivery/index.tsx (1 hunks)
  • app/client/src/git/components/ContinuousDelivery/ContinuousDeliveryCE.tsx (1 hunks)
  • app/client/src/git/components/ContinuousDelivery/index.tsx (1 hunks)
  • app/client/src/git/components/DisconnectModal/DisconnectModalView.tsx (1 hunks)
  • app/client/src/git/components/SettingsModal/TabContinuousDelivery/index.tsx (1 hunks)
  • app/client/src/git/hooks/useGitFeatureFlags.ts (1 hunks)
  • app/client/src/git/requests/disconnectRequest.types.ts (1 hunks)
  • app/client/src/git/requests/toggleAutocommitRequest.types.ts (1 hunks)
  • app/client/src/git/sagas/disconnectSaga.ts (1 hunks)
  • app/client/src/git/sagas/index.ts (3 hunks)
  • app/client/src/git/sagas/toggleAutocommitSaga.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/ee/git/components/ContinuousDelivery/index.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/client/src/git/sagas/index.ts
  • app/client/src/git/components/DisconnectModal/DisconnectModalView.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/src/git/sagas/disconnectSaga.ts

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

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

app/client/src/git/sagas/toggleAutocommitSaga.ts

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

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (5)
app/client/src/git/requests/toggleAutocommitRequest.types.ts (1)

1-6: LGTM! Well-structured type definitions.

The types are properly defined with clear separation between the response data and API response wrapper.

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

10-37: LGTM! Well-structured saga implementation.

The saga follows best practices with proper error handling, response validation, and action dispatching.

🧰 Tools
🪛 Biome (1.9.4)

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

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

app/client/src/git/components/SettingsModal/TabContinuousDelivery/index.tsx (1)

58-58: LGTM!

The default export is appropriate for this component.

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

14-61: Implementation of disconnectSaga Function Is Correct

The disconnectSaga function correctly handles the disconnection process with appropriate action dispatching and error handling.

🧰 Tools
🪛 Biome (1.9.4)

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

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

app/client/src/git/requests/disconnectRequest.types.ts (1)

1-7: Type Definitions Look Good

The definitions for DisconnectResponseData and DisconnectResponse are appropriate and align with the expected response structure.

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 and nitpick comments (2)
app/client/src/git/components/GitModals/index.tsx (1)

1-14: Clean separation of CE and EE components

The component architecture effectively separates community and enterprise features while maintaining a single entry point.

This pattern allows for:

  • Clear feature segregation between editions
  • Easy feature toggling
  • Simplified testing of each edition independently
app/client/src/git/components/GitModals/GitModalsCE.tsx (1)

8-18: Consider optimizing modal rendering

All modals are currently rendered simultaneously, which might impact initial load performance.

Consider lazy loading modals or conditionally rendering them based on usage:

function GitModalsCE() {
  return (
    <>
-     <OpsModal />
-     <SettingsModal />
-     <DisconnectModal />
-     <DisableAutocommitModal />
-     <ConflictErrorModal />
+     {/* Lazy load or conditionally render based on state */}
+     {isOpsModalOpen && <OpsModal />}
+     {isSettingsModalOpen && <SettingsModal />}
+     {isDisconnectModalOpen && <DisconnectModal />}
+     {isDisableAutocommitModalOpen && <DisableAutocommitModal />}
+     {isConflictErrorModalOpen && <ConflictErrorModal />}
    </>
  );
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 612c35a and ee50685.

📒 Files selected for processing (9)
  • app/client/src/ee/git/components/ContinuousDelivery/ContinuousDeliveryEE.tsx (1 hunks)
  • app/client/src/ee/git/components/DefaultBranch/DefaultBranchEE.tsx (1 hunks)
  • app/client/src/ee/git/components/GitModals/GitModalsEE.tsx (1 hunks)
  • app/client/src/git/components/ContinuousDelivery/index.tsx (1 hunks)
  • app/client/src/git/components/DefaultBranch/index.tsx (1 hunks)
  • app/client/src/git/components/GitModals.tsx (0 hunks)
  • app/client/src/git/components/GitModals/GitModalsCE.tsx (1 hunks)
  • app/client/src/git/components/GitModals/index.tsx (1 hunks)
  • app/client/src/git/components/SettingsModal/TabContinuousDelivery/index.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/git/components/GitModals.tsx
✅ Files skipped from review due to trivial changes (3)
  • app/client/src/ee/git/components/DefaultBranch/DefaultBranchEE.tsx
  • app/client/src/ee/git/components/ContinuousDelivery/ContinuousDeliveryEE.tsx
  • app/client/src/ee/git/components/GitModals/GitModalsEE.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/client/src/git/components/DefaultBranch/index.tsx
  • app/client/src/git/components/ContinuousDelivery/index.tsx
  • app/client/src/git/components/SettingsModal/TabContinuousDelivery/index.tsx
🔇 Additional comments (1)
app/client/src/git/components/GitModals/GitModalsCE.tsx (1)

2-6: Verify modal component dependencies

Let's ensure all imported modal components exist and are properly implemented.

✅ Verification successful

All modal components are properly implemented

The verification confirms that all imported modal components exist and are properly exported. Each modal component follows a consistent pattern with both an index file and a view component implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if all modal components exist
for modal in ConflictErrorModal SettingsModal OpsModal DisconnectModal DisableAutocommitModal; do
  echo "Checking for $modal component..."
  rg -l "export.*default.*$modal" app/client/src/git/components
done

Length of output: 1945

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

🧹 Outside diff range and nitpick comments (3)
app/client/src/git/components/LocalProfile/LocalProfileView.tsx (3)

85-91: Remove duplicate background-color property

The DummyInput component has two background-color properties. The gradient definition is being overridden by the solid color.

  background-color: linear-gradient(
    90deg,
    var(--ads-color-black-200) 0%,
    rgba(240, 240, 240, 0) 100%
  );
- background-color: var(--ads-color-black-100);

123-138: Consider using readonly properties for better type safety

Since these interfaces represent props and form data, consider making the properties readonly to prevent accidental mutations.

interface AuthorInfo {
-  authorName: string;
-  authorEmail: string;
-  useGlobalProfile: boolean;
+  readonly authorName: string;
+  readonly authorEmail: string;
+  readonly useGlobalProfile: boolean;
}

interface LocalProfileProps {
-  fetchGlobalProfile: () => void;
+  readonly fetchGlobalProfile: () => void;
   // ... apply to other properties
}

298-298: Improve email validation regex

The current email validation regex is basic and might not catch all edge cases. Consider using a more robust regex or a validation library.

- value: /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/,
+ value: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ee50685 and e20e0a2.

📒 Files selected for processing (8)
  • app/client/src/git/components/DangerZone/DangerZoneView.tsx (1 hunks)
  • app/client/src/git/components/DangerZone/index.tsx (1 hunks)
  • app/client/src/git/components/LocalProfile/LocalProfileView.tsx (1 hunks)
  • app/client/src/git/hooks/useDisconnect.ts (1 hunks)
  • app/client/src/git/hooks/useGlobalProfile.ts (1 hunks)
  • app/client/src/git/hooks/useLocalProfile.ts (1 hunks)
  • app/client/src/git/hooks/useMetadata.ts (1 hunks)
  • app/client/src/git/store/selectors/gitConfigSelectors.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • app/client/src/git/store/selectors/gitConfigSelectors.ts
  • app/client/src/git/hooks/useGlobalProfile.ts
  • app/client/src/git/hooks/useMetadata.ts
  • app/client/src/git/hooks/useLocalProfile.ts
  • app/client/src/git/hooks/useDisconnect.ts
  • app/client/src/git/components/DangerZone/DangerZoneView.tsx
🔇 Additional comments (4)
app/client/src/git/components/LocalProfile/LocalProfileView.tsx (2)

114-121: LGTM!

The loading placeholder implementation is clean and follows React best practices.


193-196: ⚠️ Potential issue

Correct the logic to use global profile data

When useGlobalProfile is true, the code sets authorName and authorEmail from localProfile, but it should use globalProfile instead.

if (data.useGlobalProfile && globalProfile) {
-  data.authorName = localProfile.authorName;
-  data.authorEmail = localProfile.authorEmail;
+  data.authorName = globalProfile.authorName;
+  data.authorEmail = globalProfile.authorEmail;
}
app/client/src/git/components/DangerZone/index.tsx (2)

1-8: LGTM! Well-organized imports

The imports are clean, necessary, and well-structured with a clear separation of concerns.


9-21: Consider splitting component responsibilities

The component is managing multiple concerns (disconnect, autocommit, settings, metadata). Consider splitting this into smaller, more focused components for better maintainability.

Add error handling for hook operations

The hooks might fail during their operations. Consider implementing error boundaries or try-catch blocks to handle potential failures gracefully.

@github-actions github-actions bot added Packages & Git Pod All issues belonging to Packages and Git Packages Pod issues that belong to the packages pod Task A simple Todo labels Dec 14, 2024
@brayn003 brayn003 added the ok-to-test Required label for CI label Dec 14, 2024
@brayn003 brayn003 requested a review from ashit-rath December 15, 2024 08:13
app/client/src/ee/git/sagas/index.ts Outdated Show resolved Hide resolved
app/client/src/git/components/ContinuousDelivery/index.tsx Outdated Show resolved Hide resolved
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";

export default function useGitFeatureFlags() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend to create selectors for each feature flag rather than hooks. The benefit would be that you can use it in sagas as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is just temp, ideally all the feature flags will be handled by the context provider, which will take these flags as a prop. I will address this in later PRs

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

🧹 Nitpick comments (17)
app/client/src/git/ce/sagas/index.ts (2)

3-7: Consider making the action types more specific

The type definition is well-structured, but we could improve type safety by being more specific about the action types.

Consider this approach:

-  (action: PayloadAction<any>) => Generator<any>
+  (action: PayloadAction<unknown>) => Generator<unknown, void, unknown>

Also applies to: 9-13


3-13: Extract common type definition to reduce duplication

Both constants share the same type definition. Consider extracting it to a shared type.

+type SagaHandler = (action: PayloadAction<unknown>) => Generator<unknown, void, unknown>;
+
-export const blockingActionSagas: Record<string, (action: PayloadAction<any>) => Generator<any>> = {};
+export const blockingActionSagas: Record<string, SagaHandler> = {};

-export const nonBlockingActionSagas: Record<string, (action: PayloadAction<any>) => Generator<any>> = {};
+export const nonBlockingActionSagas: Record<string, SagaHandler> = {};
app/client/src/git/ce/components/ContinuousDelivery/index.tsx (2)

1-11: Review architectural decision: CE component importing from EE

The component is located in the CE (Community Edition) directory but imports constants from the Enterprise Edition (ee/constants/messages). This could create unwanted dependencies between CE and EE versions.

Consider moving shared constants to a common location or implementing proper dependency isolation between CE and EE versions.


12-30: Consider documenting magic numbers and overflow behavior

The Container component uses magic numbers in the min-height calculation (360px + 52px) and sets overflow: auto.

Consider:

-  min-height: calc(360px + 52px);
+  /* Height accounts for content (360px) and padding (52px) */
+  min-height: calc(var(--content-height, 360px) + var(--content-padding, 52px));
app/client/src/git/sagas/index.ts (1)

Line range hint 36-73: Consider enhancing type safety for action handlers

The blocking action sagas are well-organized with clear categorization. Consider improving type safety using a discriminated union for action types.

type BlockingActionType = 
  | { type: typeof gitArtifactActions.fetchMetadataInit.type, payload: FetchMetadataPayload }
  | { type: typeof gitArtifactActions.connectInit.type, payload: ConnectPayload }
  // ... other action types

const blockingActionSagas: Record<
  BlockingActionType['type'],
  (action: BlockingActionType) => Generator
> = {
  // ... existing handlers
};
app/client/src/git/ce/components/DefaultBranch/index.tsx (1)

5-14: Add error handling for branches data

The component should handle cases where branches from useGitContext is null or undefined to prevent potential runtime errors.

 export default function DefaultBranch() {
   const { branches } = useGitContext();
+  if (!branches) {
+    return null; // or loading state
+  }
 
   return (
     <DefaultBranchView
       branches={branches}
       isGitProtectedFeatureLicensed={false}
     />
   );
 }
app/client/src/git/ce/hooks/useDefaultBranch.ts (2)

9-11: Memoize selector function to prevent unnecessary re-renders

The selector function passed to useSelector should be memoized using useCallback to prevent unnecessary re-renders.

+import { useCallback } from "react";
+
 function useDefaultBranch() {
   const { artifactDef } = useGitContext();
 
-  const defaultBranch = useSelector((state: GitRootState) =>
-    selectDefaultBranch(state, artifactDef),
+  const selectBranch = useCallback(
+    (state: GitRootState) => selectDefaultBranch(state, artifactDef),
+    [artifactDef]
   );
+  const defaultBranch = useSelector(selectBranch);

6-16: Add error handling for artifactDef

The hook should handle cases where artifactDef is null/undefined.

 function useDefaultBranch() {
   const { artifactDef } = useGitContext();
 
+  if (!artifactDef) {
+    return { defaultBranch: undefined };
+  }
+
   const defaultBranch = useSelector((state: GitRootState) =>
     selectDefaultBranch(state, artifactDef),
   );
 
   return {
     defaultBranch,
   };
 }
app/client/src/git/ce/components/DefaultBranch/DefaultBranchView.tsx (3)

47-51: Add prop validation for required props

The branches prop should be marked as required since the component depends on it for rendering.

 interface DefaultBranchViewProps {
-  branches: FetchBranchesResponseData | null;
+  branches: FetchBranchesResponseData;
   isGitProtectedFeatureLicensed: boolean;
   updateDefaultBranch?: (branchName: string) => void;
 }

125-138: Improve accessibility for branch selection

The Select component should have an aria-label and the Options should have aria-selected attributes.

         <StyledSelect
           data-testid="t--git-default-branch-select"
           dropdownMatchSelectWidth
           getPopupContainer={handleGetPopupContainer}
           isDisabled={!isGitProtectedFeatureLicensed}
           onChange={setSelectedValue}
           value={selectedValue}
+          aria-label="Select default branch"
         >
           {filteredBranches?.map((b) => (
             <Option
               key={b.branchName}
               value={b.branchName}
+              aria-selected={b.branchName === selectedValue}
             >
               {b.branchName}
             </Option>
           ))}
         </StyledSelect>

70-73: Add loading state handling for branches data

The filteredBranches memo should handle the case where branches is null.

   const filteredBranches = useMemo(
-    () => branches?.filter((branch) => !branch.branchName.includes("origin/")),
+    () => branches?.filter((branch) => !branch.branchName.includes("origin/")) ?? [],
     [branches],
   );
app/client/src/git/store/helpers/gitSingleArtifactInitialState.ts (2)

1-4: LGTM! Good separation of core and EE features.

The imports clearly separate core and enterprise edition state definitions, following a clean architecture pattern.


33-36: Consider grouping related modal states.

The modal states are scattered across the state object. Consider grouping them under a modals object for better organization.

-  settingsModalOpen: false,
-  settingsModalTab: GitSettingsTab.General,
-  autocommitDisableModalOpen: false,
+  modals: {
+    settings: {
+      open: false,
+      tab: GitSettingsTab.General,
+    },
+    autocommitDisable: {
+      open: false,
+    },
+  },
app/client/src/git/store/types.ts (2)

Line range hint 24-28: Consider documenting error types.

The GitApiError interface is well-structured. Consider adding JSDoc comments to document possible values for errorType to improve developer experience.

+/**
+ * Represents a Git-specific API error
+ * @property errorType - Possible values: 'AUTH_FAILED', 'MERGE_CONFLICT', etc.
+ */
 export interface GitApiError extends ApiResponseError {
   errorType?: string;
   referenceDoc?: string;
   title?: string;
 }

Line range hint 65-85: Consider using literal types for modal tabs.

The UI state structure is clean and well-organized. Consider using literal types for settingsModalTab to ensure type safety.

-  settingsModalTab: keyof typeof GitSettingsTab;
+  settingsModalTab: 'GENERAL' | 'SSH' | 'REMOTE' | 'PROTECTED_BRANCHES';
app/client/src/git/ce/store/types.ts (1)

1-3: Consider documenting the extension pattern.

While these interfaces are empty, they serve as extension points for the enterprise edition. Consider adding JSDoc comments to explain this pattern.

Add documentation like this:

+/** Base interface for Git artifact API responses state. Extended in enterprise edition. */
 export interface GitArtifactAPIResponsesReduxState {}

+/** Base interface for Git artifact UI state. Extended in enterprise edition. */
 export interface GitArtifactUIReduxState {}
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


[error] 3-3: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

app/client/src/git/store/gitArtifactSlice.ts (1)

134-147: Consider grouping modal-related actions.

The modal actions are spread across different sections. Consider grouping them under a "modals" section for better organization.

  reducers: {
+   // modals
+   toggleConnectModal: toggleConnectModalAction,
+   openDisconnectModal: openDisconnectModalAction,
+   closeDisconnectModal: closeDisconnectModalAction,
+   toggleSettingsModal: toggleSettingsModalAction,
+   toggleAutocommitDisableModal: toggleAutocommitDisableModalAction,
+   toggleRepoLimitErrorModal: toggleRepoLimitErrorModalAction,
+   toggleConflictErrorModal: toggleConflictErrorModalAction,

    // init
    initGitForEditor: initGitForEditorAction,
    // ... rest of the reducers

Also applies to: 217-217

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e20e0a2 and 9071d0e.

📒 Files selected for processing (25)
  • app/client/src/git/ce/components/ContinuousDelivery/index.tsx (1 hunks)
  • app/client/src/git/ce/components/DefaultBranch/DefaultBranchView.tsx (1 hunks)
  • app/client/src/git/ce/components/DefaultBranch/index.tsx (1 hunks)
  • app/client/src/git/ce/components/GitModals/index.tsx (1 hunks)
  • app/client/src/git/ce/hooks/useDefaultBranch.ts (1 hunks)
  • app/client/src/git/ce/sagas/index.ts (1 hunks)
  • app/client/src/git/ce/store/actions/index.ts (1 hunks)
  • app/client/src/git/ce/store/helpers/initialState.ts (1 hunks)
  • app/client/src/git/ce/store/types.ts (1 hunks)
  • app/client/src/git/components/ProtectedBranches/index.tsx (1 hunks)
  • app/client/src/git/components/SettingsModal/TabBranch/index.tsx (1 hunks)
  • app/client/src/git/components/SettingsModal/TabContinuousDelivery/index.tsx (1 hunks)
  • app/client/src/git/components/index.tsx (1 hunks)
  • app/client/src/git/ee/components/ContinuousDelivery/index.tsx (1 hunks)
  • app/client/src/git/ee/components/DefaultBranch/index.tsx (1 hunks)
  • app/client/src/git/ee/components/GitModals/index.tsx (1 hunks)
  • app/client/src/git/ee/hooks/useDefaultBranch.tsx (1 hunks)
  • app/client/src/git/ee/sagas/index.ts (1 hunks)
  • app/client/src/git/ee/store/actions/index.ts (1 hunks)
  • app/client/src/git/ee/store/helpers/initialState.ts (1 hunks)
  • app/client/src/git/ee/store/types.ts (1 hunks)
  • app/client/src/git/sagas/index.ts (3 hunks)
  • app/client/src/git/store/gitArtifactSlice.ts (5 hunks)
  • app/client/src/git/store/helpers/gitSingleArtifactInitialState.ts (4 hunks)
  • app/client/src/git/store/types.ts (4 hunks)
✅ Files skipped from review due to trivial changes (10)
  • app/client/src/git/ee/store/actions/index.ts
  • app/client/src/git/ee/components/DefaultBranch/index.tsx
  • app/client/src/git/ee/components/GitModals/index.tsx
  • app/client/src/git/ee/store/helpers/initialState.ts
  • app/client/src/git/ee/hooks/useDefaultBranch.tsx
  • app/client/src/git/ee/components/ContinuousDelivery/index.tsx
  • app/client/src/git/ce/store/actions/index.ts
  • app/client/src/git/ce/components/GitModals/index.tsx
  • app/client/src/git/components/index.tsx
  • app/client/src/git/ee/sagas/index.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/client/src/git/components/ProtectedBranches/index.tsx
  • app/client/src/git/components/SettingsModal/TabContinuousDelivery/index.tsx
  • app/client/src/git/components/SettingsModal/TabBranch/index.tsx
🧰 Additional context used
📓 Learnings (3)
app/client/src/git/ce/components/DefaultBranch/index.tsx (1)
Learnt from: brayn003
PR: appsmithorg/appsmith#38171
File: app/client/src/git/components/DefaultBranch/DefaultBranchCE.tsx:1-14
Timestamp: 2024-12-15T17:45:48.303Z
Learning: In `app/client/src/git/components/DefaultBranch/DefaultBranchCE.tsx`, the feature flag check is performed at a higher level, so it's acceptable to have `isGitProtectedFeatureLicensed={false}` in this component.
app/client/src/git/ce/components/DefaultBranch/DefaultBranchView.tsx (1)
Learnt from: brayn003
PR: appsmithorg/appsmith#38171
File: app/client/src/git/components/DefaultBranch/DefaultBranchCE.tsx:1-14
Timestamp: 2024-12-15T17:45:48.303Z
Learning: In `app/client/src/git/components/DefaultBranch/DefaultBranchCE.tsx`, the feature flag check is performed at a higher level, so it's acceptable to have `isGitProtectedFeatureLicensed={false}` in this component.
app/client/src/git/store/gitArtifactSlice.ts (1)
Learnt from: brayn003
PR: appsmithorg/appsmith#36989
File: app/client/packages/git/src/actions/helpers/createSingleArtifactAction.ts:52-68
Timestamp: 2024-11-12T08:11:36.416Z
Learning: In this codebase, when using Redux Toolkit's createSlice from Redux Toolkit, we can directly mutate the state within reducers since Immer handles immutability internally.
🪛 Biome (1.9.4)
app/client/src/git/ce/store/types.ts

[error] 1-1: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


[error] 3-3: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

🔇 Additional comments (14)
app/client/src/git/ce/components/ContinuousDelivery/index.tsx (1)

58-58: LGTM!

The export follows React component naming and export conventions.

app/client/src/git/sagas/index.ts (3)

26-29: LGTM: Clean saga imports

The new saga imports are well-organized and follow the established pattern.


76-86: LGTM: Clean non-blocking saga structure

The non-blocking action sagas maintain consistency with the blocking sagas pattern and cleanly integrate with EE features.


100-114: Verify complete action type coverage

The saga watching implementation looks solid. Let's verify we're not missing any action types.

✅ Verification successful

Action type coverage is complete and well-structured

All git action types defined in the codebase are properly handled by the saga system. The implementation shows:

  • Blocking actions are handled via channel-based saga watchers
  • Non-blocking actions use takeLatest pattern
  • All init/success/error action flows are covered
  • Actions are properly segregated between artifact and config namespaces
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all defined action types and compare with saga handlers
echo "Searching for all defined git action types..."
rg -g '!node_modules' -g '*.ts' "gitArtifactActions\.|gitConfigActions\." git/store/

Length of output: 238


Script:

#!/bin/bash
# Search for git action types from the repository root
echo "Searching for all defined git action types..."
rg -g '!node_modules' -g '*.ts' "gitArtifactActions\.|gitConfigActions\." app/client/src/

# Find saga handlers for comparison
echo -e "\nSearching for saga handlers..."
rg -g '!node_modules' -g '*.ts' "blockingActionSagas|nonBlockingActionSagas" app/client/src/

Length of output: 13768

app/client/src/git/ce/components/DefaultBranch/DefaultBranchView.tsx (1)

78-85: 🛠️ Refactor suggestion

Prevent memory leak in useEffect

The effect should be cleaned up to prevent memory leaks if the component unmounts during the async operation.

   useEffect(
     function selectedValueOnInitEffect() {
+      let isSubscribed = true;
       const defaultBranch = branches?.find((b) => b.default);
 
-      setSelectedValue(defaultBranch?.branchName);
+      if (isSubscribed) {
+        setSelectedValue(defaultBranch?.branchName);
+      }
+
+      return () => {
+        isSubscribed = false;
+      };
     },
     [branches],
   );

Likely invalid or redundant comment.

app/client/src/git/store/helpers/gitSingleArtifactInitialState.ts (3)

22-23: LGTM! Well-typed disconnect-related fields.

The new fields for disconnect functionality are properly typed with null as initial state.


142-143: LGTM! Consistent pattern for EE extension.

The API responses follow the same extension pattern as the UI state, maintaining consistency across the codebase.


41-42: Verify EE state extension impact.

The extended state is spread at the end, which is correct, but we should verify that it doesn't override any core properties.

✅ Verification successful

EE state extension is safely implemented

The spread of gitArtifactUIInitialStateExtended at the end of the object is safe because:

  • Core properties are explicitly defined first
  • EE extension is spread last, allowing it to only add new properties
  • The core state defines all essential UI properties needed for git functionality
  • The type system (GitSingleArtifactUIReduxState) ensures type safety of the merged state
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential property conflicts between core and EE states
ast-grep --pattern 'const gitArtifactUIInitialState = {
  $$$
}'

Length of output: 66


Script:

#!/bin/bash
# Let's search for both the core and extended state definitions
rg "gitArtifactUIInitialState" -A 10
rg "gitArtifactUIInitialStateExtended" -A 10

Length of output: 4623


Script:

#!/bin/bash
# Let's check the full content of the file to see the complete state object
cat app/client/src/git/store/helpers/gitSingleArtifactInitialState.ts

Length of output: 3125

app/client/src/git/store/types.ts (3)

14-14: LGTM! Clean import structure with clear type aliases.

The imports are well-organized and the type aliases provide good clarity for the extended types.

Also applies to: 17-20


29-38: LGTM! Improved type safety with GitApiError.

The async state interfaces are well-defined with proper generic type support and improved error typing.


Line range hint 39-63: Verify metadata type compatibility across the codebase.

The interface extension is clean and comprehensive. Let's verify the metadata type change impact.

✅ Verification successful

Let me check the actual type definition and its usage to ensure complete verification.


Metadata type is correctly implemented and consistent across the codebase

The FetchMetadataResponseData type is properly defined and consistently used throughout the Git-related modules. No compatibility issues found as there's no legacy FetchGitMetadataResponseData type present, and all references use the correct type.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check usage of FetchGitMetadataResponseData vs FetchMetadataResponseData
rg "FetchGitMetadataResponseData|FetchMetadataResponseData" --type ts

Length of output: 1033


Script:

#!/bin/bash
# Check the type definition and its usage context
ast-grep --pattern 'interface FetchMetadataResponseData {
  $$$
}'

# Check if there are any other interfaces extending or using this type
ast-grep --pattern 'interface $_ {
  metadata: $_<FetchMetadataResponseData>
  $$$
}'

Length of output: 1447

app/client/src/git/ce/store/helpers/initialState.ts (1)

1-9: LGTM! Clean Redux initial state setup.

The initial states are properly typed and follow Redux best practices.

app/client/src/git/store/gitArtifactSlice.ts (2)

10-13: LGTM! Consistent action naming.

The metadata action renames improve naming consistency.


116-121: Verify enterprise edition integration.

The enterprise edition case reducers are spread correctly, but let's verify the integration.

Also applies to: 219-219

app/client/src/git/sagas/index.ts Show resolved Hide resolved
app/client/src/git/ee/store/types.ts Outdated Show resolved Hide resolved
@brayn003 brayn003 requested a review from ashit-rath December 16, 2024 10:03
ashit-rath
ashit-rath previously approved these changes Dec 16, 2024
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: 2

🧹 Nitpick comments (1)
app/client/src/git/ce/components/ContinuousDelivery/CDUnLicensed/index.tsx (1)

12-17: Consider using CSS custom properties for magic numbers

The min-height calculation uses magic numbers (360px + 52px) which could be made more maintainable using CSS custom properties.

export const Container = styled.div`
  padding-top: 8px;
  padding-bottom: 16px;
  overflow: auto;
-  min-height: calc(360px + 52px);
+  min-height: var(--cd-modal-min-height, calc(360px + 52px));
`;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 56f05cf and 52b5c4f.

📒 Files selected for processing (2)
  • app/client/src/git/ce/components/ContinuousDelivery/CDUnLicensed/index.tsx (1 hunks)
  • app/client/src/git/ce/components/ContinuousDelivery/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/git/ce/components/ContinuousDelivery/index.tsx
🔇 Additional comments (2)
app/client/src/git/ce/components/ContinuousDelivery/CDUnLicensed/index.tsx (2)

1-11: LGTM: Imports are well-organized

The imports are well-organized, separating external dependencies from internal ones.


37-55: LGTM: Component structure and implementation

The component implementation is clean and follows React best practices. The use of semantic HTML elements (h3, p) with styled-components is particularly good.

@brayn003 brayn003 requested a review from ashit-rath December 17, 2024 08:04
@brayn003 brayn003 merged commit 7a24e93 into release Dec 17, 2024
42 checks passed
@brayn003 brayn003 deleted the chore/git-mod-8 branch December 17, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI Packages & Git Pod All issues belonging to Packages and Git Packages Pod issues that belong to the packages pod skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
2 participants