From c6f26918dcd78f1027ebe09cf80f88d496af5687 Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Mon, 11 Dec 2023 21:11:43 +0530 Subject: [PATCH] feat: ui for autocommit (#29441) ## Description - Adds a button to enable/disable auto-commit in Git Settings - Adds loading state for auto-commit #### PR fixes following issue(s) Fixes #29127 #### Media image #### Type of change > Please delete options that are not relevant. - New feature (non-breaking change which adds functionality) > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed ## Summary by CodeRabbit - **New Features** - Introduced auto-commit functionality for Git synchronization. - Added modals and status bars to manage and display auto-commit progress. - Implemented feature flags to enable or disable the auto-commit feature. - **Enhancements** - Updated Git settings to include auto-commit configuration options. - Improved user interface with new messages and warnings related to auto-commit. - **Bug Fixes** - Addressed issues with Git-related actions to ensure smoother user experience. - **Documentation** - Added user-facing messages and descriptions for the auto-commit feature. - **Refactor** - Refactored Git settings components to accommodate new auto-commit feature. - **Style** - Updated styles to support new components related to auto-commit functionality. --------- Co-authored-by: Aishwarya UR --- .../Apps/CurrencyInputIssue_Spec.js | 4 +- .../TableV2_Widget_API_Pagination_spec.js | 55 +++---- app/client/src/actions/gitSyncActions.ts | 15 ++ .../src/ce/constants/ReduxActionConstants.tsx | 3 + app/client/src/ce/constants/messages.ts | 9 ++ app/client/src/ce/entities/FeatureFlag.ts | 3 + .../src/ce/pages/Applications/index.tsx | 2 + .../Editor/gitSync/DisableAutocommitModal.tsx | 72 +++++++++ .../QuickGitActions/AutocommitStatusbar.tsx | 69 ++++++++ .../Editor/gitSync/QuickGitActions/index.tsx | 17 +- .../gitSync/Tabs/GitSettings/DangerZone.tsx | 148 ++++++++++++++++++ .../Tabs/GitSettings/GitDisconnect.tsx | 90 ----------- .../Editor/gitSync/Tabs/GitSettings/index.tsx | 4 +- app/client/src/pages/Editor/index.tsx | 2 + .../src/reducers/uiReducers/gitSyncReducer.ts | 29 ++++ app/client/src/selectors/gitSyncSelectors.tsx | 9 ++ 16 files changed, 407 insertions(+), 124 deletions(-) create mode 100644 app/client/src/pages/Editor/gitSync/DisableAutocommitModal.tsx create mode 100644 app/client/src/pages/Editor/gitSync/QuickGitActions/AutocommitStatusbar.tsx create mode 100644 app/client/src/pages/Editor/gitSync/Tabs/GitSettings/DangerZone.tsx delete mode 100644 app/client/src/pages/Editor/gitSync/Tabs/GitSettings/GitDisconnect.tsx diff --git a/app/client/cypress/e2e/Regression/Apps/CurrencyInputIssue_Spec.js b/app/client/cypress/e2e/Regression/Apps/CurrencyInputIssue_Spec.js index e8e4bb2e75..7e3125ae5f 100644 --- a/app/client/cypress/e2e/Regression/Apps/CurrencyInputIssue_Spec.js +++ b/app/client/cypress/e2e/Regression/Apps/CurrencyInputIssue_Spec.js @@ -14,12 +14,12 @@ describe("Currency Input Issue", function () { agHelper.VisitNAssert("/applications", "getReleaseItems"); homePage.ImportApp("CurrencyInputIssueExport.json"); cy.wait("@importNewApplication").then((interception) => { - const { isPartialImport } = interception.response.body.data; + const { isPartialImport } = interception.response.body.data; if (isPartialImport) { cy.get(reconnectDatasourceModal.SkipToAppBtn).click({ force: true, }); - } else { + } else { homePage.AssertImportToast(); } }); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Binding/TableV2_Widget_API_Pagination_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Binding/TableV2_Widget_API_Pagination_spec.js index 04be472d5c..c67cbd6cc5 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Binding/TableV2_Widget_API_Pagination_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Binding/TableV2_Widget_API_Pagination_spec.js @@ -19,29 +19,29 @@ describe( agHelper.AddDsl("tableV2TextPaginationDsl"); }); - it("1. Create an API and Execute the API and bind with Table", function () { - apiPage.CreateAndFillApi( - this.dataSet.paginationUrl + this.dataSet.paginationParam, - ); - agHelper.VerifyEvaluatedValue( - this.dataSet.paginationUrl + "mock-api?records=20&page=1&size=10", - ); - apiPage.RunAPI(); - //Validate Table V2 with API data and then add a column - EditorNavigation.SelectEntityByName("Table1", EntityType.Widget); - propPane.UpdatePropertyFieldValue("Table data", "{{Api1.data}}"); - cy.CheckWidgetProperties(commonlocators.serverSidePaginationCheckbox); - cy.get(`.t--widget-tablewidgetv2 .page-item`) - .first() - .should("contain", "1"); - cy.get(`.t--widget-tablewidgetv2 .t--table-widget-next-page`) - .first() - .click(); - cy.get(`.t--widget-tablewidgetv2 .page-item`) - .first() - .should("contain", "2"); - agHelper.WaitUntilToastDisappear("done"); - }); + it("1. Create an API and Execute the API and bind with Table", function () { + apiPage.CreateAndFillApi( + this.dataSet.paginationUrl + this.dataSet.paginationParam, + ); + agHelper.VerifyEvaluatedValue( + this.dataSet.paginationUrl + "mock-api?records=20&page=1&size=10", + ); + apiPage.RunAPI(); + //Validate Table V2 with API data and then add a column + EditorNavigation.SelectEntityByName("Table1", EntityType.Widget); + propPane.UpdatePropertyFieldValue("Table data", "{{Api1.data}}"); + cy.CheckWidgetProperties(commonlocators.serverSidePaginationCheckbox); + cy.get(`.t--widget-tablewidgetv2 .page-item`) + .first() + .should("contain", "1"); + cy.get(`.t--widget-tablewidgetv2 .t--table-widget-next-page`) + .first() + .click(); + cy.get(`.t--widget-tablewidgetv2 .page-item`) + .first() + .should("contain", "2"); + agHelper.WaitUntilToastDisappear("done"); + }); it("2. Bug #22477: should check whether the next page button is disabled and not clickable when last page is reached", () => { /** @@ -53,7 +53,8 @@ describe( propPane.UpdatePropertyFieldValue("Total Records", "20"); agHelper.GetNClick(table._nextPage("v2")); - agHelper.AssertAttribute(table._nextPage("v2"), "disabled", "disabled"); - agHelper.AssertElementAbsence(locators._toastMsg); - }); -}); + agHelper.AssertAttribute(table._nextPage("v2"), "disabled", "disabled"); + agHelper.AssertElementAbsence(locators._toastMsg); + }); + }, +); diff --git a/app/client/src/actions/gitSyncActions.ts b/app/client/src/actions/gitSyncActions.ts index 1427ac984b..b3efe54fc6 100644 --- a/app/client/src/actions/gitSyncActions.ts +++ b/app/client/src/actions/gitSyncActions.ts @@ -485,3 +485,18 @@ export const updateGitProtectedBranchesInit = (payload: { payload, }; }; + +export const setIsAutocommitEnabled = (isAutocommitEnabled: boolean) => ({ + type: ReduxActionTypes.GIT_SET_IS_AUTOCOMMIT_ENABLED, + payload: { isAutocommitEnabled }, +}); + +export const setIsAutocommitModalOpen = (isAutocommitModalOpen: boolean) => ({ + type: ReduxActionTypes.GIT_SET_IS_AUTOCOMMIT_MODAL_OPEN, + payload: { isAutocommitModalOpen }, +}); + +export const setIsAutocommitInProgress = (isAutocommitInProgress: boolean) => ({ + type: ReduxActionTypes.GIT_SET_IS_AUTOCOMMIT_IN_PROGRESS, + payload: { isAutocommitInProgress }, +}); diff --git a/app/client/src/ce/constants/ReduxActionConstants.tsx b/app/client/src/ce/constants/ReduxActionConstants.tsx index 57594c5d30..d61154001e 100644 --- a/app/client/src/ce/constants/ReduxActionConstants.tsx +++ b/app/client/src/ce/constants/ReduxActionConstants.tsx @@ -128,6 +128,9 @@ const ActionTypes = { GIT_UPDATE_PROTECTED_BRANCHES_SUCCESS: "GIT_UPDATE_PROTECTED_BRANCHES_SUCCESS", GIT_UPDATE_PROTECTED_BRANCHES_ERROR: "GIT_UPDATE_PROTECTED_BRANCHES_ERROR", + GIT_SET_IS_AUTOCOMMIT_ENABLED: "GIT_SET_AUTOCOMMIT_ENABLED", + GIT_SET_IS_AUTOCOMMIT_MODAL_OPEN: "GIT_SET_AUTOCOMMIT_MODAL_OPEN", + GIT_SET_IS_AUTOCOMMIT_IN_PROGRESS: "GIT_SET_IS_AUTOCOMMIT_IN_PROGRESS", APP_COLLAB_LIST_EDITORS: "APP_COLLAB_LIST_EDITORS", APP_COLLAB_RESET_EDITORS: "APP_COLLAB_RESET_EDITORS", diff --git a/app/client/src/ce/constants/messages.ts b/app/client/src/ce/constants/messages.ts index 5fd623b979..6cf692571d 100644 --- a/app/client/src/ce/constants/messages.ts +++ b/app/client/src/ce/constants/messages.ts @@ -1050,6 +1050,15 @@ export const GIT_AUTHOR = () => "Git author"; export const DISCONNECT_GIT = () => "Disconnect Git"; export const DISCONNECT_GIT_MESSAGE = () => "This is irreversible. If you wish to reconnect, you will have to connect a new empty repository."; +export const AUTOCOMMIT = () => "Auto - commit"; +export const AUTOCOMMIT_MESSAGE = () => + "Enable/disable auto migrations from Appsmith."; +export const AUTOCOMMIT_ENABLE = () => "Enable auto - commit"; +export const AUTOCOMMIT_DISABLE = () => "Disable auto - commit"; +export const AUTOCOMMIT_CONFIRM_DISABLE_MESSAGE = () => + "Disabling auto-commit may result in uncommitted system changes after an Appsmith instance upgrade, requiring manual handling and potential discrepancies in Git versioning."; +export const AUTOCOMMIT_IN_PROGRESS_MESSAGE = () => + "Auto-committing Appsmith upgrade changes..."; export const NEED_EMPTY_REPO_MESSAGE = () => "You need an empty repository to connect to Git on Appsmith, please create one on your Git service provider to continue."; export const GIT_IMPORT_WAITING = () => diff --git a/app/client/src/ce/entities/FeatureFlag.ts b/app/client/src/ce/entities/FeatureFlag.ts index eed9f7a185..54d8e4b7c8 100644 --- a/app/client/src/ce/entities/FeatureFlag.ts +++ b/app/client/src/ce/entities/FeatureFlag.ts @@ -32,6 +32,8 @@ export const FEATURE_FLAG = { "release_server_dsl_migrations_enabled", license_git_branch_protection_enabled: "license_git_branch_protection_enabled", + release_git_autocommit_feature_enabled: + "release_git_autocommit_feature_enabled", license_widget_rtl_support_enabled: "license_widget_rtl_support_enabled", release_custom_widgets_enabled: "release_custom_widgets_enabled", ab_create_new_apps_enabled: "ab_create_new_apps_enabled", @@ -74,6 +76,7 @@ export const DEFAULT_FEATURE_FLAG_VALUE: FeatureFlags = { release_app_sidebar_enabled: false, release_server_dsl_migrations_enabled: false, license_git_branch_protection_enabled: false, + release_git_autocommit_feature_enabled: false, license_widget_rtl_support_enabled: false, release_custom_widgets_enabled: false, ab_create_new_apps_enabled: false, diff --git a/app/client/src/ce/pages/Applications/index.tsx b/app/client/src/ce/pages/Applications/index.tsx index e4f701efff..cab1e46607 100644 --- a/app/client/src/ce/pages/Applications/index.tsx +++ b/app/client/src/ce/pages/Applications/index.tsx @@ -108,6 +108,7 @@ import WorkflowCardList from "@appsmith/pages/Applications/WorkflowCardList"; import { allowManageEnvironmentAccessForUser } from "@appsmith/selectors/environmentSelectors"; import CreateNewAppsOption from "@appsmith/pages/Applications/CreateNewAppsOption"; import { resetCurrentApplicationIdForCreateNewApp } from "actions/onboardingActions"; +import DisableAutocommitModal from "pages/Editor/gitSync/DisableAutocommitModal"; export const { cloudHosting } = getAppsmithConfigs(); @@ -786,6 +787,7 @@ export function ApplicationsSection(props: any) { {workspacesListComponent} <> + diff --git a/app/client/src/pages/Editor/gitSync/DisableAutocommitModal.tsx b/app/client/src/pages/Editor/gitSync/DisableAutocommitModal.tsx new file mode 100644 index 0000000000..6516d1d7e7 --- /dev/null +++ b/app/client/src/pages/Editor/gitSync/DisableAutocommitModal.tsx @@ -0,0 +1,72 @@ +import { + setIsAutocommitEnabled, + setIsAutocommitModalOpen, +} from "actions/gitSyncActions"; +import { + AUTOCOMMIT_CONFIRM_DISABLE_MESSAGE, + AUTOCOMMIT_DISABLE, + createMessage, +} from "@appsmith/constants/messages"; +import { + Button, + Callout, + Modal, + ModalBody, + ModalContent, + ModalFooter, + ModalHeader, + Text, +} from "design-system"; +import React from "react"; +import { useSelector, useDispatch } from "react-redux"; +import { getIsAutocommitModalOpen } from "selectors/gitSyncSelectors"; + +function DisableAutocommitModal() { + const isAutocommitModalOpen = useSelector(getIsAutocommitModalOpen); + + const dispatch = useDispatch(); + + const handleClose = () => { + dispatch(setIsAutocommitModalOpen(false)); + }; + + const handleDisableAutocommit = () => { + dispatch(setIsAutocommitEnabled(false)); + dispatch(setIsAutocommitModalOpen(false)); + }; + + return ( + { + if (!open) handleClose(); + }} + open={isAutocommitModalOpen} + > + + + {createMessage(AUTOCOMMIT_DISABLE)} + + + + {createMessage(AUTOCOMMIT_CONFIRM_DISABLE_MESSAGE)} + + + + + + + + ); +} + +export default DisableAutocommitModal; diff --git a/app/client/src/pages/Editor/gitSync/QuickGitActions/AutocommitStatusbar.tsx b/app/client/src/pages/Editor/gitSync/QuickGitActions/AutocommitStatusbar.tsx new file mode 100644 index 0000000000..ae20d753e0 --- /dev/null +++ b/app/client/src/pages/Editor/gitSync/QuickGitActions/AutocommitStatusbar.tsx @@ -0,0 +1,69 @@ +import React, { useEffect, useState } from "react"; +import { Statusbar } from "design-system-old"; +import styled from "styled-components"; +import { + AUTOCOMMIT_IN_PROGRESS_MESSAGE, + createMessage, +} from "@appsmith/constants/messages"; + +interface AutocommitStatusbarProps { + completed: boolean; + onHide?: () => void; +} + +const StatusbarWrapper = styled.div` + > div { + display: flex; + height: initial; + align-items: center; + } + + > div > div { + margin-top: 0px; + width: 150px; + margin-right: 12px; + } + + > div > p { + margin-top: 0; + } +`; + +export default function AutocommitStatusbar({ + completed, + onHide, +}: AutocommitStatusbarProps) { + const period = 4; + const [percentage, setPercentage] = useState(0); + useEffect(() => { + if (completed) { + setPercentage(100); + if (onHide) { + const timeout = setTimeout(() => { + onHide && onHide(); + }, 1000); + return () => clearTimeout(timeout); + } + } else { + if (percentage < 90) { + const interval = setInterval( + () => { + setPercentage((percentage) => percentage + 10); + }, + (period * 1000) / 9, + ); + return () => clearInterval(interval); + } + } + }); + return ( + + + + ); +} diff --git a/app/client/src/pages/Editor/gitSync/QuickGitActions/index.tsx b/app/client/src/pages/Editor/gitSync/QuickGitActions/index.tsx index 8f17fe841e..e0c506dcbe 100644 --- a/app/client/src/pages/Editor/gitSync/QuickGitActions/index.tsx +++ b/app/client/src/pages/Editor/gitSync/QuickGitActions/index.tsx @@ -33,6 +33,7 @@ import { GitSyncModalTab } from "entities/GitSync"; import { getCountOfChangesToCommit, getGitStatus, + getIsAutocommitInProgress, getIsFetchingGitStatus, getIsGitConnected, getPullFailed, @@ -47,6 +48,7 @@ import AnalyticsUtil from "utils/AnalyticsUtil"; import { useFeatureFlag } from "utils/hooks/useFeatureFlag"; import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag"; import { useIsGitAdmin } from "../hooks/useIsGitAdmin"; +import AutocommitStatusbar from "./AutocommitStatusbar"; interface QuickActionButtonProps { className?: string; @@ -333,6 +335,11 @@ export default function QuickGitActions() { FEATURE_FLAG.release_git_connect_v2_enabled, ); + const isAutocommitFeatureEnabled = useFeatureFlag( + FEATURE_FLAG.release_git_autocommit_feature_enabled, + ); + const isAutocommitInProgress = useSelector(getIsAutocommitInProgress); + const quickActionButtons = getQuickActionButtons({ commit: () => { dispatch( @@ -396,9 +403,13 @@ export default function QuickGitActions() { return isGitConnected ? ( - {quickActionButtons.map((button) => ( - - ))} + {isAutocommitFeatureEnabled && isAutocommitInProgress ? ( + + ) : ( + quickActionButtons.map((button) => ( + + )) + )} ) : ( diff --git a/app/client/src/pages/Editor/gitSync/Tabs/GitSettings/DangerZone.tsx b/app/client/src/pages/Editor/gitSync/Tabs/GitSettings/DangerZone.tsx new file mode 100644 index 0000000000..b224d53692 --- /dev/null +++ b/app/client/src/pages/Editor/gitSync/Tabs/GitSettings/DangerZone.tsx @@ -0,0 +1,148 @@ +import { + AUTOCOMMIT, + AUTOCOMMIT_DISABLE, + AUTOCOMMIT_ENABLE, + AUTOCOMMIT_MESSAGE, + DANGER_ZONE, + DISCONNECT_GIT, + DISCONNECT_GIT_MESSAGE, + createMessage, +} from "@appsmith/constants/messages"; +import { + setDisconnectingGitApplication, + setIsAutocommitEnabled, + setIsAutocommitModalOpen, + setIsDisconnectGitModalOpen, + setIsGitSyncModalOpen, +} from "actions/gitSyncActions"; +import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag"; +import { Button, Divider, Text } from "design-system"; +import React from "react"; +import { useDispatch, useSelector } from "react-redux"; +import { getCurrentApplication } from "selectors/editorSelectors"; +import { getIsAutocommitEnabled } from "selectors/gitSyncSelectors"; +import styled from "styled-components"; +import AnalyticsUtil from "utils/AnalyticsUtil"; +import { useFeatureFlag } from "utils/hooks/useFeatureFlag"; + +const Container = styled.div` + padding-top: 16px; + padding-bottom: 16px; +`; + +const HeadContainer = styled.div` + margin-bottom: 16px; +`; + +const ZoneContainer = styled.div` + border: solid 0.4px var(--ads-v2-color-red-600); + padding: 12px; + border-radius: 4px; +`; + +const BodyContainer = styled.div` + display: flex; + align-items: center; +`; + +const BodyInnerContainer = styled.div` + flex: 1; + margin-right: 32px; +`; + +const SectionTitle = styled(Text)` + font-weight: 600; +`; + +const StyledDivider = styled(Divider)` + display: block; + margin-top: 16px; + margin-bottom: 16px; +`; + +function GitDisconnect() { + const isAutocommitFeatureEnabled = useFeatureFlag( + FEATURE_FLAG.release_git_autocommit_feature_enabled, + ); + const isAutocommitEnabled = useSelector(getIsAutocommitEnabled); + + const dispatch = useDispatch(); + + const currentApp = useSelector(getCurrentApplication); + + const handleDisconnect = () => { + AnalyticsUtil.logEvent("GS_DISCONNECT_GIT_CLICK", { + source: "GIT_CONNECTION_MODAL", + }); + dispatch(setIsGitSyncModalOpen({ isOpen: false })); + dispatch( + setDisconnectingGitApplication({ + id: currentApp?.id || "", + name: currentApp?.name || "", + }), + ); + dispatch(setIsDisconnectGitModalOpen(true)); + }; + + const handleToggleAutocommit = () => { + if (isAutocommitEnabled) { + dispatch(setIsGitSyncModalOpen({ isOpen: false })); + dispatch(setIsAutocommitModalOpen(true)); + } else { + dispatch(setIsAutocommitEnabled(true)); + } + }; + + return ( + + + + {createMessage(DANGER_ZONE)} + + + + {isAutocommitFeatureEnabled ? ( + <> + + + + {createMessage(AUTOCOMMIT)} + + {createMessage(AUTOCOMMIT_MESSAGE)} + + + + + + ) : null} + + + + {createMessage(DISCONNECT_GIT)} + + {createMessage(DISCONNECT_GIT_MESSAGE)} + + + + + + ); +} + +export default GitDisconnect; diff --git a/app/client/src/pages/Editor/gitSync/Tabs/GitSettings/GitDisconnect.tsx b/app/client/src/pages/Editor/gitSync/Tabs/GitSettings/GitDisconnect.tsx deleted file mode 100644 index e35b02f69b..0000000000 --- a/app/client/src/pages/Editor/gitSync/Tabs/GitSettings/GitDisconnect.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import { - DANGER_ZONE, - DISCONNECT_GIT, - DISCONNECT_GIT_MESSAGE, - createMessage, -} from "@appsmith/constants/messages"; -import { - setDisconnectingGitApplication, - setIsDisconnectGitModalOpen, - setIsGitSyncModalOpen, -} from "actions/gitSyncActions"; -import { Button, Text } from "design-system"; -import React from "react"; -import { useDispatch, useSelector } from "react-redux"; -import { getCurrentApplication } from "selectors/editorSelectors"; -import styled from "styled-components"; -import AnalyticsUtil from "utils/AnalyticsUtil"; - -const Container = styled.div` - padding-top: 16px; - padding-bottom: 16px; -`; - -const HeadContainer = styled.div` - margin-bottom: 16px; -`; - -const BodyContainer = styled.div` - display: flex; - border: solid 0.4px var(--ads-v2-color-red-600); - padding: 12px; - border-radius: 4px; - align-items: center; -`; - -const BodyInnerContainer = styled.div` - flex: 1; - margin-right: 32px; -`; - -const SectionTitle = styled(Text)` - font-weight: 600; -`; - -function GitDisconnect() { - const dispatch = useDispatch(); - const currentApp = useSelector(getCurrentApplication); - - const handleDisconnect = () => { - AnalyticsUtil.logEvent("GS_DISCONNECT_GIT_CLICK", { - source: "GIT_CONNECTION_MODAL", - }); - dispatch(setIsGitSyncModalOpen({ isOpen: false })); - dispatch( - setDisconnectingGitApplication({ - id: currentApp?.id || "", - name: currentApp?.name || "", - }), - ); - dispatch(setIsDisconnectGitModalOpen(true)); - }; - - return ( - - - - {createMessage(DANGER_ZONE)} - - - - - - {createMessage(DISCONNECT_GIT)} - - {createMessage(DISCONNECT_GIT_MESSAGE)} - - - - - ); -} - -export default GitDisconnect; diff --git a/app/client/src/pages/Editor/gitSync/Tabs/GitSettings/index.tsx b/app/client/src/pages/Editor/gitSync/Tabs/GitSettings/index.tsx index 40ebbfbbb2..b07d1e9745 100644 --- a/app/client/src/pages/Editor/gitSync/Tabs/GitSettings/index.tsx +++ b/app/client/src/pages/Editor/gitSync/Tabs/GitSettings/index.tsx @@ -1,6 +1,6 @@ import React from "react"; import GitUserSettings from "./GitUserSettings"; -import GitDisconnect from "./GitDisconnect"; +import DangerZone from "./DangerZone"; import styled from "styled-components"; import { Divider, ModalBody } from "design-system"; import GitDefaultBranch from "./GitDefaultBranch"; @@ -32,7 +32,7 @@ function GitSettings() { ) : null} - {isGitAdmin && } + {isGitAdmin && } ); diff --git a/app/client/src/pages/Editor/index.tsx b/app/client/src/pages/Editor/index.tsx index 1793fa11b7..0db1ac7984 100644 --- a/app/client/src/pages/Editor/index.tsx +++ b/app/client/src/pages/Editor/index.tsx @@ -43,6 +43,7 @@ import SignpostingOverlay from "pages/Editor/FirstTimeUserOnboarding/Overlay"; import { editorInitializer } from "../../utils/editor/EditorUtils"; import { widgetInitialisationSuccess } from "../../actions/widgetActions"; import urlBuilder from "@appsmith/entities/URLRedirect/URLAssembly"; +import DisableAutocommitModal from "./gitSync/DisableAutocommitModal"; interface EditorProps { currentApplicationId?: string; @@ -167,6 +168,7 @@ class Editor extends Component { + diff --git a/app/client/src/reducers/uiReducers/gitSyncReducer.ts b/app/client/src/reducers/uiReducers/gitSyncReducer.ts index 4c697c4756..dfd9f56132 100644 --- a/app/client/src/reducers/uiReducers/gitSyncReducer.ts +++ b/app/client/src/reducers/uiReducers/gitSyncReducer.ts @@ -44,6 +44,10 @@ const initialState: GitSyncReducerState = { protectedBranches: [], isUpdateProtectedBranchesLoading: false, + + isAutocommitModalOpen: false, + isAutocommitEnabled: false, + isAutocommitInProgress: false, }; const gitSyncReducer = createReducer(initialState, { @@ -598,6 +602,27 @@ const gitSyncReducer = createReducer(initialState, { ...state, isUpdateProtectedBranchesLoading: false, }), + [ReduxActionTypes.GIT_SET_IS_AUTOCOMMIT_ENABLED]: ( + state, + action: ReduxAction<{ isAutocommitEnabled: boolean }>, + ) => ({ + ...state, + isAutocommitEnabled: action.payload.isAutocommitEnabled, + }), + [ReduxActionTypes.GIT_SET_IS_AUTOCOMMIT_MODAL_OPEN]: ( + state, + action: ReduxAction<{ isAutocommitModalOpen: boolean }>, + ) => ({ + ...state, + isAutocommitModalOpen: action.payload.isAutocommitModalOpen, + }), + [ReduxActionTypes.GIT_SET_IS_AUTOCOMMIT_IN_PROGRESS]: ( + state, + action: ReduxAction<{ isAutocommitInProgress: boolean }>, + ) => ({ + ...state, + isAutocommitInProgress: action.payload.isAutocommitInProgress, + }), }); export interface GitStatusData { @@ -737,6 +762,10 @@ export type GitSyncReducerState = GitBranchDeleteState & { protectedBranches: string[]; protectedBranchesLoading: boolean; isUpdateProtectedBranchesLoading: boolean; + + isAutocommitEnabled: boolean; + isAutocommitModalOpen: boolean; + isAutocommitInProgress: boolean; }; export default gitSyncReducer; diff --git a/app/client/src/selectors/gitSyncSelectors.tsx b/app/client/src/selectors/gitSyncSelectors.tsx index 12d82d113e..4d44cc4e14 100644 --- a/app/client/src/selectors/gitSyncSelectors.tsx +++ b/app/client/src/selectors/gitSyncSelectors.tsx @@ -243,3 +243,12 @@ export const getIsUpdateProtectedBranchesLoading = (state: AppState) => { export const getIsGetProtectedBranchesLoading = (state: AppState) => { return state.ui.gitSync.protectedBranchesLoading; }; + +export const getIsAutocommitEnabled = (state: AppState) => + state.ui.gitSync.isAutocommitEnabled; + +export const getIsAutocommitModalOpen = (state: AppState) => + state.ui.gitSync.isAutocommitModalOpen; + +export const getIsAutocommitInProgress = (state: AppState) => + state.ui.gitSync.isAutocommitInProgress;