## Description Segregating api calls for status and remote #### PR fixes following issue(s) Fixes #26038 #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change - 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 - [ ] 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
450 lines
11 KiB
TypeScript
450 lines
11 KiB
TypeScript
import type { 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";
|
|
|
|
export type GitStatusParams = {
|
|
compareRemote?: boolean;
|
|
};
|
|
|
|
export const setIsGitSyncModalOpen = (payload: {
|
|
isOpen: boolean;
|
|
tab?: GitSyncModalTab;
|
|
}) => {
|
|
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 type ConnectToGitResponse = {
|
|
gitApplicationMetadata: GitApplicationMetadata;
|
|
};
|
|
|
|
type ConnectToGitRequestParams = {
|
|
payload: ConnectToGitPayload;
|
|
onSuccessCallback?: (payload: ConnectToGitResponse) => void;
|
|
onErrorCallback?: (error: string) => void;
|
|
};
|
|
|
|
export type ConnectToGitReduxAction = ReduxActionWithCallbacks<
|
|
ConnectToGitPayload,
|
|
ConnectToGitResponse,
|
|
string
|
|
>;
|
|
|
|
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 = () => ({
|
|
type: ReduxActionTypes.FETCH_GIT_REMOTE_STATUS_INIT,
|
|
});
|
|
|
|
export const fetchGitRemoteStatusSuccess = (payload: GitRemoteStatusData) => ({
|
|
type: ReduxActionTypes.FETCH_GIT_REMOTE_STATUS_SUCCESS,
|
|
payload,
|
|
});
|
|
|
|
export const discardChanges = () => ({
|
|
type: ReduxActionTypes.GIT_DISCARD_CHANGES,
|
|
});
|
|
|
|
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,
|
|
});
|
|
|
|
type 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 type SSHKeyType = {
|
|
keySize: number;
|
|
platFormSupported: string;
|
|
protocolName: string;
|
|
};
|
|
|
|
export type GetSSHKeyResponseData = {
|
|
gitSupportedSSHKeyType: SSHKeyType[];
|
|
docUrl: string;
|
|
publicKey?: string;
|
|
};
|
|
|
|
export type GenerateSSHKeyPairResponsePayload<T> = {
|
|
responseMeta: ResponseMeta;
|
|
data: T;
|
|
};
|
|
|
|
export type GenerateSSHKeyPairReduxAction = ReduxActionWithCallbacks<
|
|
{ keyType?: string } | undefined,
|
|
GenerateSSHKeyPairResponsePayload<GetSSHKeyResponseData>,
|
|
ErrorPayload
|
|
>;
|
|
|
|
export type 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 type GetSSHKeyPairResponsePayload<T> = {
|
|
responseMeta: ResponseMeta;
|
|
data: T;
|
|
};
|
|
|
|
export type GetSSHKeyPairReduxAction = ReduxActionWithCallbacks<
|
|
undefined,
|
|
GetSSHKeyPairResponsePayload<GetSSHKeyResponseData>,
|
|
ErrorPayload
|
|
>;
|
|
|
|
export type 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,
|
|
});
|