PromucFlow_constructor/app/client/src/git/components/SettingsModal/SettingsModalView.tsx
Rudraprasad Das f6d7ce626f
chore: git mod - test fixes (#38357)
## Description
- Locator fixes for cy tests
- Missing saga for discard and merge
- New component for hot keys


Fixes https://github.com/appsmithorg/appsmith/issues/37821
Fixes https://github.com/appsmithorg/appsmith/issues/37822
Fixes https://github.com/appsmithorg/appsmith/issues/37824

## Automation

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

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12649057943>
> Commit: 94c57d0a2398fca8e6cbb4be573586aa98dffbe1
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12649057943&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Tue, 07 Jan 2025 10:42:55 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes

- **New Features**
- Added repository limit error modal to handle scenarios when repository
limits are reached.
  - Introduced Git hot keys for quick access to Git operations.
- Enhanced Git synchronization functionality with new merge and discard
change capabilities.
- Integrated feature flag handling in test suites for Git-related
functionalities.

- **Improvements**
  - Standardized test identifiers across Git-related components.
  - Refined Git modal interactions and state management.
  - Updated locator references for more consistent testing.
- Improved user feedback with success notifications for branch
deletions.

- **Bug Fixes**
  - Resolved issues with branch switching and URL handling.
  - Improved error handling in Git synchronization processes.

- **Testing**
  - Updated Cypress test suites with new feature flag interceptors.
  - Enhanced test coverage for Git operations and modal interactions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-07 12:30:42 +01:00

121 lines
3.4 KiB
TypeScript

import React, { useCallback } from "react";
import {
Modal,
ModalBody,
ModalContent,
ModalHeader,
Tab,
Tabs,
TabsList,
} from "@appsmith/ads";
import styled from "styled-components";
import {
BRANCH,
CONTINUOUS_DELIVERY,
GENERAL,
SETTINGS_GIT,
createMessage,
} from "ee/constants/messages";
import TabGeneral from "./TabGeneral";
import TabBranch from "./TabBranch";
import { GitSettingsTab } from "git/constants/enums";
import TabContinuousDelivery from "./TabContinuousDelivery";
import noop from "lodash/noop";
const StyledModalContent = styled(ModalContent)`
&&& {
width: 600px;
transform: none !important;
top: 100px;
left: calc(50% - 300px);
max-height: calc(100vh - 200px);
}
`;
interface SettingsModalViewProps {
isConnectPermitted: boolean;
isManageAutocommitPermitted: boolean;
isManageDefaultBranchPermitted: boolean;
isManageProtectedBranchesPermitted: boolean;
isSettingsModalOpen: boolean;
settingsModalTab: keyof typeof GitSettingsTab;
toggleSettingsModal: (
open: boolean,
tab?: keyof typeof GitSettingsTab,
) => void;
}
function SettingsModalView({
isConnectPermitted = false,
isManageAutocommitPermitted = false,
isManageDefaultBranchPermitted = false,
isManageProtectedBranchesPermitted = false,
isSettingsModalOpen = false,
settingsModalTab = GitSettingsTab.General,
toggleSettingsModal = noop,
}: SettingsModalViewProps) {
const showBranchTab =
isManageDefaultBranchPermitted || isManageProtectedBranchesPermitted;
const handleTabKeyChange = useCallback(
(tabKey: string) => {
toggleSettingsModal(true, tabKey as GitSettingsTab);
},
[toggleSettingsModal],
);
return (
<Modal onOpenChange={toggleSettingsModal} open={isSettingsModalOpen}>
<StyledModalContent data-testid="t--git-settings-modal">
<ModalHeader>{createMessage(SETTINGS_GIT)}</ModalHeader>
<Tabs onValueChange={handleTabKeyChange} value={settingsModalTab}>
<TabsList>
<Tab
data-testid={"t--git-settings-tab-general"}
value={GitSettingsTab.General}
>
{createMessage(GENERAL)}
</Tab>
{showBranchTab && (
<Tab
data-testid={"t--git-settings-tab-branch"}
value={GitSettingsTab.Branch}
>
{createMessage(BRANCH)}
</Tab>
)}
<Tab
data-testid={"t--git-settings-tab-cd"}
value={GitSettingsTab.ContinuousDelivery}
>
{createMessage(CONTINUOUS_DELIVERY)}
</Tab>
</TabsList>
</Tabs>
<ModalBody>
{settingsModalTab === GitSettingsTab.General && (
<TabGeneral
isConnectPermitted={isConnectPermitted}
isManageAutocommitPermitted={isManageAutocommitPermitted}
/>
)}
{settingsModalTab === GitSettingsTab.Branch && (
<TabBranch
isManageDefaultBranchPermitted={isManageDefaultBranchPermitted}
isManageProtectedBranchesPermitted={
isManageProtectedBranchesPermitted
}
/>
)}
{settingsModalTab === GitSettingsTab.ContinuousDelivery && (
<TabContinuousDelivery />
)}
</ModalBody>
</StyledModalContent>
</Modal>
);
}
export default SettingsModalView;