From 5ae0924b4c848fbea5a900341c35121465ff40f6 Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Wed, 24 Jan 2024 13:18:16 +0530 Subject: [PATCH] fix: removing disabled state when loading for git commit button (#30514) ## Description - Fixes initial loading color for the commit button in protected branches - Adds loading state when discard and pull is triggered #### PR fixes following issue(s) Fixes #29485 #### Media image #### Type of change - Bug fix (non-breaking change which fixes an issue) ## 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** - Improved button responsiveness in the Git Sync feature, enabling better control over versioning actions. - **Bug Fixes** - Addressed an issue where Git-related buttons were not accurately reflecting the current state, ensuring they are now correctly enabled or disabled depending on the Git operation in progress. --- .../src/pages/Editor/gitSync/QuickGitActions/index.tsx | 10 +++++----- app/client/src/reducers/uiReducers/gitSyncReducer.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/client/src/pages/Editor/gitSync/QuickGitActions/index.tsx b/app/client/src/pages/Editor/gitSync/QuickGitActions/index.tsx index 8219ccb608..d56e7e8a51 100644 --- a/app/client/src/pages/Editor/gitSync/QuickGitActions/index.tsx +++ b/app/client/src/pages/Editor/gitSync/QuickGitActions/index.tsx @@ -34,11 +34,11 @@ import { GitSyncModalTab } from "entities/GitSync"; import { getCountOfChangesToCommit, getGitStatus, + getIsDiscardInProgress, getIsFetchingGitStatus, getIsGitConnected, getIsPollingAutocommit, getPullFailed, - getPullInProgress, protectedModeSelector, } from "selectors/gitSyncSelectors"; import SpinnerLoader from "pages/common/SpinnerLoader"; @@ -188,18 +188,18 @@ const getQuickActionButtons = ({ return [ { className: "t--bottom-bar-commit", - disabled: isProtectedMode, + disabled: !isFetchingGitStatus && isProtectedMode, count: isProtectedMode ? undefined : changesToCommit, icon: "plus", loading: isFetchingGitStatus, - onClick: commit, + onClick: () => !isFetchingGitStatus && !isProtectedMode && commit(), tooltipText: createMessage(COMMIT_CHANGES), }, { className: "t--bottom-bar-pull", count: gitStatus?.behindCount, icon: "down-arrow-2", - onClick: () => !pullDisabled && pull(), + onClick: () => !showPullLoadingState && !pullDisabled && pull(), tooltipText: pullTooltipMessage, disabled: !showPullLoadingState && pullDisabled, loading: showPullLoadingState, @@ -329,7 +329,7 @@ export default function QuickGitActions() { const { disabled: pullDisabled, message: pullTooltipMessage } = getPullBtnStatus(gitStatus, !!pullFailed, isProtectedMode); - const isPullInProgress = useSelector(getPullInProgress); + const isPullInProgress = useSelector(getIsDiscardInProgress); const isFetchingGitStatus = useSelector(getIsFetchingGitStatus); const showPullLoadingState = isPullInProgress || isFetchingGitStatus; const changesToCommit = useSelector(getCountOfChangesToCommit); diff --git a/app/client/src/reducers/uiReducers/gitSyncReducer.ts b/app/client/src/reducers/uiReducers/gitSyncReducer.ts index 6c5d6e4bc8..d4a5d22f9d 100644 --- a/app/client/src/reducers/uiReducers/gitSyncReducer.ts +++ b/app/client/src/reducers/uiReducers/gitSyncReducer.ts @@ -29,6 +29,8 @@ const initialState: GitSyncReducerState = { fetchingBranches: false, localGitConfig: { authorEmail: "", authorName: "" }, + isDiscarding: false, + isFetchingLocalGitConfig: false, isFetchingGlobalGitConfig: false, @@ -542,6 +544,11 @@ const gitSyncReducer = createReducer(initialState, { ...state, deletingBranch: action.payload, }), + [ReduxActionTypes.GIT_DISCARD_CHANGES]: (state: GitSyncReducerState) => ({ + ...state, + isDiscarding: true, + discardError: null, + }), [ReduxActionTypes.GIT_DISCARD_CHANGES_SUCCESS]: ( state: GitSyncReducerState, action: ReduxAction, @@ -812,7 +819,7 @@ export type GitSyncReducerState = GitBranchDeleteState & { gitImportError?: any; - isDiscarding?: boolean; + isDiscarding: boolean; discard?: GitDiscardResponse; discardError?: GitErrorType;