## 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 <img width="694" alt="image" src="https://github.com/appsmithorg/appsmith/assets/8724051/628d9c93-f374-4611-9c1d-c568d3a6bed5"> #### 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 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
503 lines
12 KiB
TypeScript
503 lines
12 KiB
TypeScript
import type {
|
|
ReduxAction,
|
|
ReduxActionWithCallbacks,
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
|
import {
|
|
ReduxActionErrorTypes,
|
|
ReduxActionTypes,
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
|
import type { ConnectToGitPayload } from "api/GitSyncAPI";
|
|
import type { GitConfig, GitSyncModalTab, MergeStatus } from "entities/GitSync";
|
|
import type { GitApplicationMetadata } from "@appsmith/api/ApplicationApi";
|
|
import type {
|
|
GitStatusData,
|
|
GitRemoteStatusData,
|
|
} from "reducers/uiReducers/gitSyncReducer";
|
|
import type { ResponseMeta } from "api/ApiResponses";
|
|
import { noop } from "lodash";
|
|
|
|
export interface GitStatusParams {
|
|
compareRemote?: boolean;
|
|
}
|
|
|
|
export const setIsGitSyncModalOpen = (payload: {
|
|
isOpen: boolean;
|
|
tab?: GitSyncModalTab;
|
|
isDeploying?: boolean;
|
|
}) => {
|
|
return {
|
|
type: ReduxActionTypes.SET_IS_GIT_SYNC_MODAL_OPEN,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const setIsDisconnectGitModalOpen = (payload: boolean) => {
|
|
return {
|
|
type: ReduxActionTypes.SET_SHOULD_SHOW_DISCONNECT_GIT_MODAL,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const commitToRepoInit = (payload: {
|
|
commitMessage: string;
|
|
doPush: boolean;
|
|
}) => ({
|
|
type: ReduxActionTypes.COMMIT_TO_GIT_REPO_INIT,
|
|
payload,
|
|
});
|
|
|
|
export const commitToRepoSuccess = () => ({
|
|
type: ReduxActionTypes.COMMIT_TO_GIT_REPO_SUCCESS,
|
|
});
|
|
|
|
export const clearCommitSuccessfulState = () => ({
|
|
type: ReduxActionTypes.CLEAR_COMMIT_SUCCESSFUL_STATE,
|
|
});
|
|
|
|
export const clearCommitErrorState = () => ({
|
|
type: ReduxActionTypes.CLEAR_COMMIT_ERROR_STATE,
|
|
});
|
|
|
|
export const clearDiscardErrorState = () => ({
|
|
type: ReduxActionTypes.CLEAR_DISCARD_ERROR_STATE,
|
|
});
|
|
|
|
export interface ConnectToGitResponse {
|
|
gitApplicationMetadata: GitApplicationMetadata;
|
|
}
|
|
|
|
interface ConnectToGitRequestParams {
|
|
payload: ConnectToGitPayload;
|
|
onSuccessCallback?: (payload: ConnectToGitResponse) => void;
|
|
onErrorCallback?: (error: any, response?: any) => void;
|
|
}
|
|
|
|
export interface ConnectToGitReduxAction
|
|
extends ReduxAction<ConnectToGitPayload> {
|
|
onSuccessCallback?: (response: ConnectToGitResponse) => void;
|
|
onErrorCallback?: (error: Error, response?: any) => void;
|
|
}
|
|
|
|
export const connectToGitInit = ({
|
|
onErrorCallback,
|
|
onSuccessCallback,
|
|
payload,
|
|
}: ConnectToGitRequestParams): ConnectToGitReduxAction => ({
|
|
type: ReduxActionTypes.CONNECT_TO_GIT_INIT,
|
|
payload,
|
|
onSuccessCallback,
|
|
onErrorCallback,
|
|
});
|
|
|
|
export const connectToGitSuccess = (payload: ConnectToGitResponse) => ({
|
|
type: ReduxActionTypes.CONNECT_TO_GIT_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
export const switchGitBranchInit = (branch: string) => ({
|
|
type: ReduxActionTypes.SWITCH_GIT_BRANCH_INIT,
|
|
payload: branch,
|
|
});
|
|
|
|
export const createNewBranchInit = ({
|
|
branch,
|
|
onErrorCallback,
|
|
onSuccessCallback,
|
|
}: {
|
|
branch: string;
|
|
onSuccessCallback: () => void;
|
|
onErrorCallback: () => void;
|
|
}) => ({
|
|
type: ReduxActionTypes.CREATE_NEW_BRANCH_INIT,
|
|
payload: branch,
|
|
onErrorCallback,
|
|
onSuccessCallback,
|
|
});
|
|
|
|
export const setIsGitErrorPopupVisible = (payload: { isVisible: boolean }) => ({
|
|
type: ReduxActionTypes.SHOW_ERROR_POPUP,
|
|
payload,
|
|
});
|
|
|
|
export const showCreateBranchPopup = () => ({
|
|
type: ReduxActionTypes.SHOW_CREATE_GIT_BRANCH_POPUP,
|
|
});
|
|
|
|
export const updateGlobalGitConfigInit = (payload: GitConfig) => ({
|
|
type: ReduxActionTypes.UPDATE_GLOBAL_GIT_CONFIG_INIT,
|
|
payload,
|
|
});
|
|
|
|
export const updateGlobalGitConfigSuccess = (payload: GitConfig) => ({
|
|
type: ReduxActionTypes.UPDATE_GLOBAL_GIT_CONFIG_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
export const fetchGlobalGitConfigInit = () => ({
|
|
type: ReduxActionTypes.FETCH_GLOBAL_GIT_CONFIG_INIT,
|
|
});
|
|
|
|
export const fetchGlobalGitConfigSuccess = (payload: GitConfig) => ({
|
|
type: ReduxActionTypes.FETCH_GLOBAL_GIT_CONFIG_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
export const fetchBranchesInit = (payload?: { pruneBranches: boolean }) => ({
|
|
type: ReduxActionTypes.FETCH_BRANCHES_INIT,
|
|
payload,
|
|
});
|
|
|
|
export const fetchBranchesSuccess = (payload: any) => ({
|
|
type: ReduxActionTypes.FETCH_BRANCHES_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
// Local Git config is repo level
|
|
export const updateLocalGitConfigInit = (payload: GitConfig) => ({
|
|
type: ReduxActionTypes.UPDATE_LOCAL_GIT_CONFIG_INIT,
|
|
payload,
|
|
});
|
|
|
|
export const updateLocalGitConfigSuccess = (payload: GitConfig) => ({
|
|
type: ReduxActionTypes.UPDATE_LOCAL_GIT_CONFIG_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
export const fetchLocalGitConfigInit = () => ({
|
|
type: ReduxActionTypes.FETCH_LOCAL_GIT_CONFIG_INIT,
|
|
});
|
|
|
|
export const fetchLocalGitConfigSuccess = (payload: GitConfig) => ({
|
|
type: ReduxActionTypes.FETCH_LOCAL_GIT_CONFIG_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
export const fetchGitStatusInit = (payload?: GitStatusParams) => ({
|
|
type: ReduxActionTypes.FETCH_GIT_STATUS_INIT,
|
|
payload,
|
|
});
|
|
|
|
export const fetchGitStatusSuccess = (payload: GitStatusData) => ({
|
|
type: ReduxActionTypes.FETCH_GIT_STATUS_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
export const fetchGitRemoteStatusInit = ({
|
|
onErrorCallback = noop,
|
|
onSuccessCallback = noop,
|
|
} = {}) => ({
|
|
type: ReduxActionTypes.FETCH_GIT_REMOTE_STATUS_INIT,
|
|
onSuccessCallback,
|
|
onErrorCallback,
|
|
});
|
|
|
|
export const fetchGitRemoteStatusSuccess = (payload: GitRemoteStatusData) => ({
|
|
type: ReduxActionTypes.FETCH_GIT_REMOTE_STATUS_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
export const discardChanges = (
|
|
payload: { successToastMessage?: string } | undefined | null = {},
|
|
) => ({
|
|
type: ReduxActionTypes.GIT_DISCARD_CHANGES,
|
|
payload,
|
|
});
|
|
|
|
export const discardChangesSuccess = (payload: any) => ({
|
|
type: ReduxActionTypes.GIT_DISCARD_CHANGES_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
export const discardChangesFailure = (payload: any) => ({
|
|
type: ReduxActionErrorTypes.GIT_DISCARD_CHANGES_ERROR,
|
|
payload: { error: payload.error, show: false },
|
|
});
|
|
|
|
export const updateBranchLocally = (payload: string) => ({
|
|
type: ReduxActionTypes.UPDATE_BRANCH_LOCALLY,
|
|
payload,
|
|
});
|
|
|
|
interface MergeBranchPayload {
|
|
sourceBranch: string;
|
|
destinationBranch: string;
|
|
}
|
|
|
|
export const mergeBranchInit = (params: {
|
|
payload: { sourceBranch: string; destinationBranch: string };
|
|
onSuccessCallback: () => void;
|
|
}) => ({
|
|
type: ReduxActionTypes.MERGE_BRANCH_INIT,
|
|
...params,
|
|
});
|
|
|
|
export const mergeBranchSuccess = () => ({
|
|
type: ReduxActionTypes.MERGE_BRANCH_SUCCESS,
|
|
});
|
|
|
|
export const mergeBranchFailure = () => ({
|
|
type: ReduxActionErrorTypes.MERGE_BRANCH_ERROR,
|
|
});
|
|
|
|
export const fetchMergeStatusInit = (payload: MergeBranchPayload) => ({
|
|
type: ReduxActionTypes.FETCH_MERGE_STATUS_INIT,
|
|
payload,
|
|
});
|
|
|
|
export const fetchMergeStatusSuccess = (payload: MergeStatus) => ({
|
|
type: ReduxActionTypes.FETCH_MERGE_STATUS_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
export const fetchMergeStatusFailure = (payload: {
|
|
error: string;
|
|
show: boolean;
|
|
}) => ({
|
|
type: ReduxActionErrorTypes.FETCH_MERGE_STATUS_ERROR,
|
|
payload,
|
|
});
|
|
|
|
export const resetMergeStatus = () => ({
|
|
type: ReduxActionTypes.RESET_MERGE_STATUS,
|
|
});
|
|
|
|
export const gitPullInit = (payload?: {
|
|
triggeredFromBottomBar?: boolean;
|
|
}) => ({
|
|
type: ReduxActionTypes.GIT_PULL_INIT,
|
|
payload,
|
|
});
|
|
|
|
export const gitPullSuccess = (mergeStatus: MergeStatus) => ({
|
|
type: ReduxActionTypes.GIT_PULL_SUCCESS,
|
|
payload: mergeStatus,
|
|
});
|
|
|
|
export const resetPullMergeStatus = () => ({
|
|
type: ReduxActionTypes.RESET_PULL_MERGE_STATUS,
|
|
});
|
|
|
|
export const remoteUrlInputValue = (payload?: { tempRemoteUrl?: string }) => ({
|
|
type: ReduxActionTypes.SET_REMOTE_URL_INPUT_VALUE,
|
|
payload,
|
|
});
|
|
|
|
export const setShowRepoLimitErrorModal = (payload: boolean) => ({
|
|
type: ReduxActionTypes.SET_SHOULD_SHOW_REPO_LIMIT_ERROR_MODAL,
|
|
payload,
|
|
});
|
|
|
|
export const showConnectGitModal = () => ({
|
|
type: ReduxActionTypes.SHOW_CONNECT_GIT_MODAL,
|
|
});
|
|
|
|
export const revokeGit = () => ({
|
|
type: ReduxActionTypes.REVOKE_GIT,
|
|
});
|
|
|
|
export const setDisconnectingGitApplication = (payload: {
|
|
id: string;
|
|
name: string;
|
|
}) => ({
|
|
type: ReduxActionTypes.SET_DISCONNECTING_GIT_APPLICATION,
|
|
payload,
|
|
});
|
|
|
|
export const importAppFromGit = ({
|
|
onErrorCallback,
|
|
onSuccessCallback,
|
|
payload,
|
|
}: ConnectToGitRequestParams): ConnectToGitReduxAction => ({
|
|
type: ReduxActionTypes.IMPORT_APPLICATION_FROM_GIT_INIT,
|
|
payload,
|
|
onSuccessCallback,
|
|
onErrorCallback,
|
|
});
|
|
|
|
type ErrorPayload = string;
|
|
|
|
export interface SSHKeyType {
|
|
keySize: number;
|
|
platFormSupported: string;
|
|
protocolName: string;
|
|
}
|
|
|
|
export interface GetSSHKeyResponseData {
|
|
gitSupportedSSHKeyType: SSHKeyType[];
|
|
docUrl: string;
|
|
publicKey?: string;
|
|
}
|
|
|
|
export interface GenerateSSHKeyPairResponsePayload<T> {
|
|
responseMeta: ResponseMeta;
|
|
data: T;
|
|
}
|
|
|
|
export type GenerateSSHKeyPairReduxAction = ReduxActionWithCallbacks<
|
|
{ keyType?: string } | undefined,
|
|
GenerateSSHKeyPairResponsePayload<GetSSHKeyResponseData>,
|
|
ErrorPayload
|
|
>;
|
|
|
|
export interface GenerateKeyParams {
|
|
onErrorCallback?: (payload: ErrorPayload) => void;
|
|
onSuccessCallback?: (
|
|
payload: GenerateSSHKeyPairResponsePayload<GetSSHKeyResponseData>,
|
|
) => void;
|
|
payload?: { keyType?: string };
|
|
}
|
|
|
|
export const generateSSHKeyPair = ({
|
|
onErrorCallback,
|
|
onSuccessCallback,
|
|
payload,
|
|
}: GenerateKeyParams): GenerateSSHKeyPairReduxAction => ({
|
|
type: ReduxActionTypes.GENERATE_SSH_KEY_PAIR_INIT,
|
|
payload,
|
|
onErrorCallback,
|
|
onSuccessCallback,
|
|
});
|
|
|
|
export const generateSSHKeyPairSuccess = (
|
|
payload: GenerateSSHKeyPairResponsePayload<GetSSHKeyResponseData>,
|
|
) => {
|
|
return {
|
|
type: ReduxActionTypes.GENERATE_SSH_KEY_PAIR_SUCCESS,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export interface GetSSHKeyPairResponsePayload<T> {
|
|
responseMeta: ResponseMeta;
|
|
data: T;
|
|
}
|
|
|
|
export type GetSSHKeyPairReduxAction = ReduxActionWithCallbacks<
|
|
undefined,
|
|
GetSSHKeyPairResponsePayload<GetSSHKeyResponseData>,
|
|
ErrorPayload
|
|
>;
|
|
|
|
export interface GetKeyParams {
|
|
onErrorCallback?: (payload: ErrorPayload) => void;
|
|
onSuccessCallback?: (
|
|
payload: GetSSHKeyPairResponsePayload<GetSSHKeyResponseData>,
|
|
) => void;
|
|
payload?: undefined;
|
|
}
|
|
|
|
export const getSSHKeyPair = ({
|
|
onErrorCallback,
|
|
onSuccessCallback,
|
|
payload,
|
|
}: GetKeyParams): GetSSHKeyPairReduxAction => {
|
|
return {
|
|
type: ReduxActionTypes.FETCH_SSH_KEY_PAIR_INIT,
|
|
payload,
|
|
onErrorCallback,
|
|
onSuccessCallback,
|
|
};
|
|
};
|
|
|
|
export const getSSHKeyPairSuccess = (
|
|
payload: GetSSHKeyPairResponsePayload<GetSSHKeyResponseData>,
|
|
) => {
|
|
return {
|
|
type: ReduxActionTypes.FETCH_SSH_KEY_PAIR_SUCCESS,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const getSSHKeyPairError = (payload: {
|
|
error: string;
|
|
show: boolean;
|
|
}) => {
|
|
return {
|
|
type: ReduxActionErrorTypes.FETCH_SSH_KEY_PAIR_ERROR,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const initSSHKeyPairWithNull = () => ({
|
|
type: ReduxActionTypes.INIT_SSH_KEY_PAIR_WITH_NULL,
|
|
});
|
|
|
|
export const importAppViaGitSuccess = () => ({
|
|
type: ReduxActionTypes.IMPORT_APPLICATION_FROM_GIT_SUCCESS,
|
|
});
|
|
export const importAppViaGitStatusReset = () => ({
|
|
type: ReduxActionTypes.IMPORT_APPLICATION_FROM_GIT_STATUS_RESET,
|
|
});
|
|
|
|
// todo define type
|
|
export const importAppViaGitError = (error: any) => ({
|
|
type: ReduxActionTypes.IMPORT_APPLICATION_FROM_GIT_ERROR,
|
|
payload: error,
|
|
});
|
|
|
|
export const resetSSHKeys = () => ({
|
|
type: ReduxActionTypes.RESET_SSH_KEY_PAIR,
|
|
});
|
|
|
|
export const deleteBranchInit = (payload: any) => ({
|
|
type: ReduxActionTypes.DELETE_BRANCH_INIT,
|
|
payload,
|
|
});
|
|
|
|
export const deleteBranchSuccess = (payload: any) => ({
|
|
type: ReduxActionTypes.DELETE_BRANCH_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
export const deleteBranchError = (payload: any) => ({
|
|
type: ReduxActionErrorTypes.DELETE_BRANCH_ERROR,
|
|
payload,
|
|
});
|
|
|
|
export const deleteBranchWarning = (payload: any) => ({
|
|
type: ReduxActionErrorTypes.DELETE_BRANCH_WARNING,
|
|
payload,
|
|
});
|
|
|
|
export const deletingBranch = (payload: any) => ({
|
|
type: ReduxActionTypes.DELETING_BRANCH,
|
|
payload,
|
|
});
|
|
|
|
export const updateGitDefaultBranch = (payload: { branchName: string }) => {
|
|
return {
|
|
type: ReduxActionTypes.GIT_UPDATE_DEFAULT_BRANCH_INIT,
|
|
payload,
|
|
};
|
|
};
|
|
|
|
export const fetchGitProtectedBranchesInit = () => {
|
|
return {
|
|
type: ReduxActionTypes.GIT_FETCH_PROTECTED_BRANCHES_INIT,
|
|
};
|
|
};
|
|
|
|
export const updateGitProtectedBranchesInit = (payload: {
|
|
protectedBranches: string[];
|
|
}) => {
|
|
return {
|
|
type: ReduxActionTypes.GIT_UPDATE_PROTECTED_BRANCHES_INIT,
|
|
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 },
|
|
});
|