fix: show errors from git status (#12440)
* fix: show errors from git status * fix: review comments
This commit is contained in:
parent
26745c6128
commit
50a8e1441c
|
|
@ -24,6 +24,8 @@ import {
|
|||
DISCONNECT_EXISTING_REPOSITORIES,
|
||||
DISCONNECT_EXISTING_REPOSITORIES_INFO,
|
||||
DISCONNECT_GIT,
|
||||
ERROR_GIT_AUTH_FAIL,
|
||||
ERROR_GIT_INVALID_REMOTE,
|
||||
ERROR_WHILE_PULLING_CHANGES,
|
||||
ERROR_WIDGET_COPY_NOT_ALLOWED,
|
||||
FETCH_GIT_STATUS,
|
||||
|
|
@ -73,14 +75,23 @@ describe("messages", () => {
|
|||
describe("git-sync messages", () => {
|
||||
const expectedMessages = [
|
||||
{ key: "COMMIT_CHANGES", value: "Commit changes" },
|
||||
{ key: "COMMIT_TO", value: "Commit to" },
|
||||
{
|
||||
key: "COMMIT_TO",
|
||||
value: "Commit to",
|
||||
},
|
||||
{ key: "COMMIT_AND_PUSH", value: "Commit & push" },
|
||||
{ key: "PULL_CHANGES", value: "PULL CHANGES" },
|
||||
{
|
||||
key: "PULL_CHANGES",
|
||||
value: "PULL CHANGES",
|
||||
},
|
||||
{ key: "DEPLOY_KEY_TITLE", value: "Deployed Key" },
|
||||
|
||||
{ key: "REGENERATE_SSH_KEY", value: "Regenerate SSH Key" },
|
||||
{ key: "SSH_KEY", value: "SSH Key" },
|
||||
{ key: "COPY_SSH_KEY", value: "Copy SSH Key" },
|
||||
{
|
||||
key: "COPY_SSH_KEY",
|
||||
value: "Copy SSH Key",
|
||||
},
|
||||
{
|
||||
key: "REGENERATE_KEY_CONFIRM_MESSAGE",
|
||||
value:
|
||||
|
|
@ -96,11 +107,20 @@ describe("git-sync messages", () => {
|
|||
value: "COMMITTING AND PUSHING CHANGES...",
|
||||
},
|
||||
{ key: "IS_MERGING", value: "MERGING CHANGES..." },
|
||||
{ key: "MERGE_CHANGES", value: "Merge changes" },
|
||||
{
|
||||
key: "MERGE_CHANGES",
|
||||
value: "Merge changes",
|
||||
},
|
||||
{ key: "SELECT_BRANCH_TO_MERGE", value: "Select branch to merge" },
|
||||
{ key: "CONNECT_GIT", value: "Connect Git" },
|
||||
{
|
||||
key: "CONNECT_GIT",
|
||||
value: "Connect Git",
|
||||
},
|
||||
{ key: "CONNECT_GIT_BETA", value: "Connect Git (Beta)" },
|
||||
{ key: "RETRY", value: "RETRY" },
|
||||
{
|
||||
key: "RETRY",
|
||||
value: "RETRY",
|
||||
},
|
||||
{ key: "CREATE_NEW_BRANCH", value: "CREATE NEW BRANCH" },
|
||||
{
|
||||
key: "ERROR_WHILE_PULLING_CHANGES",
|
||||
|
|
@ -125,9 +145,15 @@ describe("git-sync messages", () => {
|
|||
value: "Please enter valid SSH URL of your repository",
|
||||
},
|
||||
{ key: "GENERATE_KEY", value: "Generate Key" },
|
||||
{ key: "UPDATE_CONFIG", value: "UPDATE CONFIG" },
|
||||
{
|
||||
key: "UPDATE_CONFIG",
|
||||
value: "UPDATE CONFIG",
|
||||
},
|
||||
{ key: "CONNECT_BTN_LABEL", value: "CONNECT" },
|
||||
{ key: "FETCH_GIT_STATUS", value: "fetching status..." },
|
||||
{
|
||||
key: "FETCH_GIT_STATUS",
|
||||
value: "fetching status...",
|
||||
},
|
||||
{ key: "FETCH_MERGE_STATUS", value: "Checking mergeability..." },
|
||||
{
|
||||
key: "NO_MERGE_CONFLICT",
|
||||
|
|
@ -167,7 +193,10 @@ describe("git-sync messages", () => {
|
|||
"To make space for newer repositories you can remove existing repositories.",
|
||||
},
|
||||
{ key: "CONTACT_SUPPORT", value: "Contact Support" },
|
||||
{ key: "REPOSITORY_LIMIT_REACHED", value: "Repository Limit Reached" },
|
||||
{
|
||||
key: "REPOSITORY_LIMIT_REACHED",
|
||||
value: "Repository Limit Reached",
|
||||
},
|
||||
{
|
||||
key: "REPOSITORY_LIMIT_REACHED_INFO",
|
||||
value:
|
||||
|
|
@ -187,16 +216,25 @@ describe("git-sync messages", () => {
|
|||
value: "Disconnect might cause the application to break.",
|
||||
},
|
||||
{ key: "DISCONNECT_GIT", value: "Revoke access" },
|
||||
{ key: "DISCONNECT", value: "DISCONNECT" },
|
||||
{
|
||||
key: "DISCONNECT",
|
||||
value: "DISCONNECT",
|
||||
},
|
||||
{ key: "GIT_DISCONNECTION_SUBMENU", value: "Git Connection > Disconnect" },
|
||||
{ key: "USE_DEFAULT_CONFIGURATION", value: "Use default configuration" },
|
||||
{
|
||||
key: "USE_DEFAULT_CONFIGURATION",
|
||||
value: "Use default configuration",
|
||||
},
|
||||
{
|
||||
key: "GIT_COMMIT_MESSAGE_PLACEHOLDER",
|
||||
value: "Your commit message here",
|
||||
},
|
||||
{ key: "GIT_CONNECTION", value: "Git Connection" },
|
||||
{ key: "DEPLOY", value: "Deploy" },
|
||||
{ key: "MERGE", value: "Merge" },
|
||||
{
|
||||
key: "MERGE",
|
||||
value: "Merge",
|
||||
},
|
||||
{ key: "GIT_SETTINGS", value: "Git Settings" },
|
||||
{ key: "CONNECT_TO_GIT", value: "Connect to git repository" },
|
||||
{
|
||||
|
|
@ -209,6 +247,15 @@ describe("git-sync messages", () => {
|
|||
value: `Create an empty git repository and paste the remote URL here.`,
|
||||
},
|
||||
{ key: "REMOTE_URL_VIA", value: "Remote URL via" },
|
||||
{
|
||||
key: "ERROR_GIT_AUTH_FAIL",
|
||||
value:
|
||||
"Please make sure that regenerated SSH key is added and has write access to the repo.",
|
||||
},
|
||||
{
|
||||
key: "ERROR_GIT_INVALID_REMOTE",
|
||||
value: "Remote repo doesn't exist or is unreachable.",
|
||||
},
|
||||
];
|
||||
const functions = [
|
||||
CANNOT_MERGE_DUE_TO_UNCOMMITTED_CHANGES,
|
||||
|
|
@ -270,6 +317,8 @@ describe("git-sync messages", () => {
|
|||
SUBMIT,
|
||||
UPDATE_CONFIG,
|
||||
USE_DEFAULT_CONFIGURATION,
|
||||
ERROR_GIT_AUTH_FAIL,
|
||||
ERROR_GIT_INVALID_REMOTE,
|
||||
];
|
||||
functions.forEach((fn: () => string) => {
|
||||
it(`${fn.name} returns expected value`, () => {
|
||||
|
|
|
|||
|
|
@ -522,8 +522,7 @@ export const BULK_WIDGET_ADDED = (widgetName: string) =>
|
|||
export const UNSUPPORTED_PLUGIN_DIALOG_TITLE = () =>
|
||||
`Couldn't auto generate a page from this datasource.`;
|
||||
|
||||
export const UNSUPPORTED_PLUGIN_DIALOG_SUBTITLE = () =>
|
||||
`You can continue building your app with it using our drag & Drop
|
||||
export const UNSUPPORTED_PLUGIN_DIALOG_SUBTITLE = () => `You can continue building your app with it using our drag & Drop
|
||||
builder`;
|
||||
export const UNSUPPORTED_PLUGIN_DIALOG_MAIN_HEADING = () => `Heads up`;
|
||||
|
||||
|
|
@ -736,6 +735,13 @@ export const CONNECTING_TO_REPO_DISABLED = () =>
|
|||
export const DURING_ONBOARDING_TOUR = () => "during the onboarding tour";
|
||||
export const MERGED_SUCCESSFULLY = () => "Merged successfully";
|
||||
|
||||
// GIT ERRORS begin
|
||||
export const ERROR_GIT_AUTH_FAIL = () =>
|
||||
"Please make sure that regenerated SSH key is added and has write access to the repo.";
|
||||
export const ERROR_GIT_INVALID_REMOTE = () =>
|
||||
"Remote repo doesn't exist or is unreachable.";
|
||||
// GIT ERRORS end
|
||||
|
||||
// JS Snippets
|
||||
export const SNIPPET_DESCRIPTION = () =>
|
||||
`Search and insert code snippets to perform complex actions quickly.`;
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@ import {
|
|||
ReduxActionTypes,
|
||||
ReduxActionWithCallbacks,
|
||||
} from "constants/ReduxActionConstants";
|
||||
import { all, put, select, takeLatest, call } from "redux-saga/effects";
|
||||
import { all, call, put, select, takeLatest } from "redux-saga/effects";
|
||||
|
||||
import GitSyncAPI from "api/GitSyncAPI";
|
||||
import GitSyncAPI, {
|
||||
MergeBranchPayload,
|
||||
MergeStatusPayload,
|
||||
} from "api/GitSyncAPI";
|
||||
import {
|
||||
getCurrentApplicationId,
|
||||
getCurrentPageId,
|
||||
|
|
@ -17,33 +20,35 @@ import {
|
|||
commitToRepoSuccess,
|
||||
fetchBranchesInit,
|
||||
fetchBranchesSuccess,
|
||||
fetchGlobalGitConfigSuccess,
|
||||
fetchLocalGitConfigSuccess,
|
||||
updateLocalGitConfigSuccess,
|
||||
fetchLocalGitConfigInit,
|
||||
switchGitBranchInit,
|
||||
gitPullSuccess,
|
||||
fetchMergeStatusSuccess,
|
||||
fetchMergeStatusFailure,
|
||||
fetchGitStatusInit,
|
||||
setIsGitSyncModalOpen,
|
||||
setIsGitErrorPopupVisible,
|
||||
setIsDisconnectGitModalOpen,
|
||||
setShowRepoLimitErrorModal,
|
||||
fetchGitStatusSuccess,
|
||||
fetchGlobalGitConfigInit,
|
||||
generateSSHKeyPairSuccess,
|
||||
getSSHKeyPairSuccess,
|
||||
getSSHKeyPairError,
|
||||
fetchGlobalGitConfigSuccess,
|
||||
fetchLocalGitConfigInit,
|
||||
fetchLocalGitConfigSuccess,
|
||||
fetchMergeStatusFailure,
|
||||
fetchMergeStatusSuccess,
|
||||
GenerateSSHKeyPairReduxAction,
|
||||
generateSSHKeyPairSuccess,
|
||||
getSSHKeyPairError,
|
||||
GetSSHKeyPairReduxAction,
|
||||
getSSHKeyPairSuccess,
|
||||
gitPullSuccess,
|
||||
importAppViaGitSuccess,
|
||||
setIsDisconnectGitModalOpen,
|
||||
setIsGitErrorPopupVisible,
|
||||
setIsGitSyncModalOpen,
|
||||
setShowRepoLimitErrorModal,
|
||||
switchGitBranchInit,
|
||||
updateLocalGitConfigSuccess,
|
||||
} from "actions/gitSyncActions";
|
||||
|
||||
import { showReconnectDatasourceModal } from "actions/applicationActions";
|
||||
|
||||
import {
|
||||
connectToGitSuccess,
|
||||
ConnectToGitReduxAction,
|
||||
connectToGitSuccess,
|
||||
mergeBranchSuccess,
|
||||
} from "../actions/gitSyncActions";
|
||||
import { ApiResponse } from "api/ApiResponses";
|
||||
import { GitConfig, GitSyncModalTab } from "entities/GitSync";
|
||||
|
|
@ -52,29 +57,24 @@ import { Variant } from "components/ads/common";
|
|||
import {
|
||||
getCurrentAppGitMetaData,
|
||||
getCurrentApplication,
|
||||
getOrganizationIdForImport,
|
||||
} from "selectors/applicationSelectors";
|
||||
import { fetchGitStatusSuccess } from "actions/gitSyncActions";
|
||||
import {
|
||||
createMessage,
|
||||
ERROR_GIT_AUTH_FAIL,
|
||||
ERROR_GIT_INVALID_REMOTE,
|
||||
GIT_USER_UPDATED_SUCCESSFULLY,
|
||||
} from "@appsmith/constants/messages";
|
||||
import { GitApplicationMetadata } from "../api/ApplicationApi";
|
||||
|
||||
import history from "utils/history";
|
||||
import { addBranchParam, GIT_BRANCH_QUERY_KEY } from "constants/routes";
|
||||
import { MergeBranchPayload, MergeStatusPayload } from "api/GitSyncAPI";
|
||||
|
||||
import {
|
||||
mergeBranchSuccess,
|
||||
// mergeBranchFailure,
|
||||
} from "../actions/gitSyncActions";
|
||||
import {
|
||||
getCurrentGitBranch,
|
||||
getDisconnectingGitApplication,
|
||||
} from "selectors/gitSyncSelectors";
|
||||
import { initEditor } from "actions/initActions";
|
||||
import { fetchPage } from "actions/pageActions";
|
||||
import { getOrganizationIdForImport } from "selectors/applicationSelectors";
|
||||
import { getLogToSentryFromResponse } from "utils/helpers";
|
||||
import { getCurrentOrg } from "selectors/organizationSelectors";
|
||||
import { Org } from "constants/orgConstants";
|
||||
|
|
@ -432,10 +432,18 @@ function* fetchGitStatusSaga() {
|
|||
yield put(fetchGitStatusSuccess(response?.data));
|
||||
}
|
||||
} catch (error) {
|
||||
const payload = { error, show: true };
|
||||
if (error?.message?.includes("Auth fail")) {
|
||||
payload.error = new Error(createMessage(ERROR_GIT_AUTH_FAIL));
|
||||
} else if (error?.message?.includes("Invalid remote: origin")) {
|
||||
payload.error = new Error(createMessage(ERROR_GIT_INVALID_REMOTE));
|
||||
}
|
||||
|
||||
yield put({
|
||||
type: ReduxActionErrorTypes.FETCH_GIT_STATUS_ERROR,
|
||||
payload: { error, show: false },
|
||||
payload,
|
||||
});
|
||||
|
||||
// non api error
|
||||
if (!response || response?.responseMeta?.success) {
|
||||
throw error;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user