Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fall of the error toasts wall #35839

Merged
merged 35 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5de5384
Sync changes from EE excluding enterprise directory
hetunandu Aug 22, 2024
63ea35c
Merge branch 'release' into chore/avoid-unneccesary-toats
hetunandu Aug 22, 2024
948b859
Sync changes from EE excluding enterprise directory
hetunandu Aug 22, 2024
74a2ad2
Merge branch 'release' into chore/avoid-unneccesary-toats
hetunandu Aug 23, 2024
77ece2f
Sync changes from EE excluding enterprise directory
hetunandu Aug 23, 2024
15bdc0f
Merge branch 'release' into chore/avoid-unneccesary-toats
hetunandu Aug 23, 2024
462dfdf
Sync changes from EE excluding enterprise directory
hetunandu Aug 23, 2024
caf68ad
Merge branch 'release' into chore/avoid-unneccesary-toats
hetunandu Aug 26, 2024
40a7619
Merge branch 'release' into chore/avoid-unneccesary-toats
hetunandu Aug 26, 2024
b1bd60f
Open debugger on load error
hetunandu Aug 26, 2024
b6eef61
Merge branch 'release' into chore/avoid-unneccesary-toats
hetunandu Aug 26, 2024
af006a6
fix js execution opening toasts
hetunandu Aug 26, 2024
3657462
fix tests
hetunandu Aug 26, 2024
3189c9e
fix tests
hetunandu Aug 26, 2024
b2cd8c0
more test cases
hetunandu Aug 27, 2024
d6befbd
Merge remote-tracking branch 'origin/release' into chore/avoid-unnecc…
hetunandu Aug 27, 2024
13c8a2f
fix selector
hetunandu Aug 27, 2024
a2de7e7
fix most scenarios
hetunandu Aug 28, 2024
d3143b5
dont force debugger open
hetunandu Aug 30, 2024
037dd82
remove patch file
hetunandu Aug 30, 2024
9ceb9d4
Remove merge markers
hetunandu Aug 30, 2024
e42babe
fix debugger tests not force opening
hetunandu Aug 30, 2024
405ab25
Merge branch 'release' into chore/avoid-unneccesary-toats
hetunandu Sep 2, 2024
b04b164
dont force debugger open
hetunandu Sep 2, 2024
ed43ff5
revert execution error toast message
hetunandu Sep 2, 2024
e138808
test cases
hetunandu Sep 2, 2024
12749bd
fix final tests
hetunandu Sep 3, 2024
dff1933
Merge branch 'release' into chore/avoid-unneccesary-toats
hetunandu Sep 3, 2024
7156738
more check fixes
hetunandu Sep 3, 2024
3b5a65b
revert default tab
hetunandu Sep 3, 2024
c5228d5
toast defaults
hetunandu Sep 3, 2024
c304fa1
Merge branch 'release' into chore/avoid-unneccesary-toats
hetunandu Sep 4, 2024
cd62e46
fix show overrides
hetunandu Sep 4, 2024
afc6933
Merge branch 'release' into chore/avoid-unneccesary-toats
hetunandu Sep 4, 2024
f90c54c
still need show to be true :(
hetunandu Sep 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/client/src/actions/jsActionActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { JSCollection } from "entities/JSCollection";
import type { CreateJSCollectionRequest } from "ee/api/JSActionAPI";
import type { EventLocation } from "ee/utils/analyticsUtilTypes";
import type { ApiResponse } from "api/ApiResponses";
import type { ErrorPayloadType } from "../sagas/ErrorSagas";

export interface FetchJSCollectionsPayload {
applicationId: string;
Expand Down Expand Up @@ -65,6 +66,7 @@ export const copyJSCollectionSuccess = (payload: JSCollection) => {
export const copyJSCollectionError = (payload: {
id: string;
destinationPageId: string;
error?: ErrorPayloadType;
}) => {
return {
type: ReduxActionErrorTypes.COPY_JS_ACTION_ERROR,
Expand Down Expand Up @@ -93,6 +95,7 @@ export const moveJSCollectionSuccess = (payload: JSCollection) => {
export const moveJSCollectionError = (payload: {
id: string;
originalPageId: string;
error?: ErrorPayloadType;
}) => {
return {
type: ReduxActionErrorTypes.MOVE_JS_ACTION_ERROR,
Expand Down
3 changes: 3 additions & 0 deletions app/client/src/actions/pluginActionActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { ModalInfo } from "reducers/uiReducers/modalActionReducer";
import type { OtlpSpan } from "UITelemetry/generateTraces";
import type { ApiResponse } from "api/ApiResponses";
import type { JSCollection } from "entities/JSCollection";
import type { ErrorPayloadType } from "../sagas/ErrorSagas";

export const createActionRequest = (payload: Partial<Action>) => {
return {
Expand Down Expand Up @@ -208,6 +209,7 @@ export const moveActionSuccess = (payload: Action) => {
export const moveActionError = (payload: {
id: string;
originalPageId: string;
error?: ErrorPayloadType;
}) => {
return {
type: ReduxActionErrorTypes.MOVE_ACTION_ERROR,
Expand Down Expand Up @@ -236,6 +238,7 @@ export const copyActionSuccess = (payload: Action) => {
export const copyActionError = (payload: {
id: string;
destinationPageId: string;
error?: ErrorPayloadType;
}) => {
return {
type: ReduxActionErrorTypes.COPY_ACTION_ERROR,
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/constants/ReduxActionConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ const UserAuthActionTypes = {
SAAS_GET_OAUTH_ACCESS_TOKEN: "SAAS_GET_OAUTH_ACCESS_TOKEN",
GET_OAUTH_ACCESS_TOKEN: "GET_OAUTH_ACCESS_TOKEN",
GET_OAUTH_ACCESS_TOKEN_SUCCESS: "GET_OAUTH_ACCESS_TOKEN_SUCCESS",
GET_OAUTH_ACCESS_TOKEN_ERROR: "GET_OAUTH_ACCESS_TOKEN_ERROR",
};
const UserAuthActionErrorTypes = {
CREATE_USER_ERROR: "CREATE_USER_ERROR",
Expand All @@ -379,6 +378,7 @@ const UserAuthActionErrorTypes = {
LOGOUT_USER_ERROR: "LOGOUT_USER_ERROR",
VERIFY_INVITE_ERROR: "VERIFY_INVITE_ERROR",
INVITED_USER_SIGNUP_ERROR: "INVITED_USER_SIGNUP_ERROR",
GET_OAUTH_ACCESS_TOKEN_ERROR: "GET_OAUTH_ACCESS_TOKEN_ERROR",
};

const UserProfileActionTypes = {
Expand Down
31 changes: 17 additions & 14 deletions app/client/src/ce/sagas/JSActionSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,14 @@ export function* copyJSCollectionSaga(
}
} catch (e) {
const actionName = actionObject ? actionObject.name : "";
toast.show(createMessage(ERROR_JS_ACTION_COPY_FAIL, actionName), {
kind: "error",
});
yield put(copyJSCollectionError(action.payload));
yield put(
copyJSCollectionError({
...action.payload,
error: {
message: createMessage(ERROR_JS_ACTION_COPY_FAIL, actionName),
},
}),
);
}
}

Expand Down Expand Up @@ -265,13 +269,13 @@ export function* moveJSCollectionSaga(
// @ts-expect-error: response.data is of type unknown
yield put(moveJSCollectionSuccess(response.data));
} catch (e) {
toast.show(createMessage(ERROR_JS_ACTION_MOVE_FAIL, actionObject.name), {
kind: "error",
});
yield put(
moveJSCollectionError({
id: action.payload.id,
originalPageId: actionObject.pageId,
error: {
message: createMessage(ERROR_JS_ACTION_MOVE_FAIL, actionObject.name),
},
}),
);
}
Expand Down Expand Up @@ -375,15 +379,14 @@ export function* saveJSObjectName(
payload: {
actionId: action.payload.id,
oldName: collection.config.name,
error: {
message: createMessage(
ERROR_JS_COLLECTION_RENAME_FAIL,
action.payload.name,
),
},
},
});
toast.show(
createMessage(ERROR_JS_COLLECTION_RENAME_FAIL, action.payload.name),
{
kind: "error",
},
);
log.error(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ const datasourceReducer = createReducer(initialState, {
loadingTokenForDatasourceId: null,
};
},
[ReduxActionTypes.GET_OAUTH_ACCESS_TOKEN_ERROR]: (
[ReduxActionErrorTypes.GET_OAUTH_ACCESS_TOKEN_ERROR]: (
state: DatasourceDataState,
) => {
return {
Expand Down
17 changes: 10 additions & 7 deletions app/client/src/sagas/ActionExecution/PluginActionSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from "redux-saga/effects";
import * as Sentry from "@sentry/react";
import type { updateActionDataPayloadType } from "actions/pluginActionActions";
import { executePageLoadActions } from "actions/pluginActionActions";
import {
clearActionResponse,
executePageLoadActions,
executePluginActionError,
executePluginActionRequest,
executePluginActionSuccess,
Expand Down Expand Up @@ -72,8 +72,7 @@ import {
} from "sagas/ErrorSagas";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import type { Action } from "entities/Action";
import { ActionExecutionContext } from "entities/Action";
import { PluginType } from "entities/Action";
import { ActionExecutionContext, PluginType } from "entities/Action";
import LOG_TYPE from "entities/AppsmithConsole/logtype";
import {
ACTION_EXECUTION_CANCELLED,
Expand Down Expand Up @@ -173,6 +172,7 @@ import {
import type { JSAction, JSCollection } from "entities/JSCollection";
import { getAllowedActionAnalyticsKeys } from "constants/AppsmithActionConstants/formConfig/ActionAnalyticsConfig";
import { setApiPaneDebuggerState } from "../../actions/apiPaneActions";
import { LOG_CATEGORY, Severity } from "../../entities/AppsmithConsole";

enum ActionResponseDataTypes {
BINARY = "BINARY",
Expand Down Expand Up @@ -1267,10 +1267,13 @@ function* executePageLoadActionsSaga(
checkAndLogErrorsIfCyclicDependency(layoutOnLoadActionErrors);
} catch (e) {
log.error(e);

toast.show(createMessage(ERROR_FAIL_ON_PAGE_LOAD_ACTIONS), {
kind: "error",
});
AppsmithConsole.addErrors([
{
payload: { text: createMessage(ERROR_FAIL_ON_PAGE_LOAD_ACTIONS) },
severity: Severity.ERROR,
category: LOG_CATEGORY.PLATFORM_GENERATED,
},
]);
}
endSpan(span);
}
Expand Down
22 changes: 10 additions & 12 deletions app/client/src/sagas/ActionSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ import {
createNewQueryAction,
} from "actions/apiPaneActions";
import type { Plugin } from "api/PluginApi";
import * as log from "loglevel";
import { shouldBeDefined } from "utils/helpers";
import {
apiEditorIdURL,
Expand Down Expand Up @@ -704,13 +703,13 @@ function* moveActionSaga(
// @ts-expect-error: response is of type unknown
yield put(moveActionSuccess(response.data));
} catch (e) {
toast.show(createMessage(ERROR_ACTION_MOVE_FAIL, actionObject.name), {
kind: "error",
});
yield put(
moveActionError({
id: action.payload.id,
originalPageId: action.payload.originalPageId,
error: {
message: createMessage(ERROR_ACTION_MOVE_FAIL, actionObject.name),
},
}),
);
}
Expand Down Expand Up @@ -797,10 +796,12 @@ function* copyActionSaga(
yield put(copyActionSuccess(payload));
} catch (e) {
const actionName = actionObject ? actionObject.name : "";
toast.show(createMessage(ERROR_ACTION_COPY_FAIL, actionName), {
kind: "error",
});
yield put(copyActionError(action.payload));
yield put(
copyActionError({
...action.payload,
error: { message: createMessage(ERROR_ACTION_COPY_FAIL, actionName) },
}),
);
}
}

Expand Down Expand Up @@ -899,12 +900,9 @@ function* saveActionName(action: ReduxAction<{ id: string; name: string }>) {
payload: {
actionId: action.payload.id,
oldName: api.config.name,
message: createMessage(ERROR_ACTION_RENAME_FAIL, action.payload.name),
},
});
toast.show(createMessage(ERROR_ACTION_RENAME_FAIL, action.payload.name), {
kind: "error",
});
log.error(e);
}
}

Expand Down
21 changes: 7 additions & 14 deletions app/client/src/sagas/ApiPaneSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import get from "lodash/get";
import omit from "lodash/omit";
import { all, call, put, select, take, takeEvery } from "redux-saga/effects";
import * as Sentry from "@sentry/react";
import type {
ReduxAction,
ReduxActionWithMeta,
Expand Down Expand Up @@ -69,7 +68,6 @@ import { validateResponse } from "./ErrorSagas";
import type { CreateDatasourceSuccessAction } from "actions/datasourceActions";
import { removeTempDatasource } from "actions/datasourceActions";
import { klona } from "klona/lite";
import { toast } from "@appsmith/ads";
import type { AutoGeneratedHeader } from "pages/Editor/APIEditor/helpers";
import { deriveAutoGeneratedHeaderState } from "pages/Editor/APIEditor/helpers";
import { TEMP_DATASOURCE_ID } from "constants/Datasource";
Expand Down Expand Up @@ -744,19 +742,14 @@ function* handleApiNameChangeSuccessSaga(
const actionObj: Action | undefined = yield select(getAction, actionId);
yield take(ReduxActionTypes.FETCH_ACTIONS_FOR_PAGE_SUCCESS);
if (!actionObj) {
// Error case, log to sentry
toast.show(createMessage(ERROR_ACTION_RENAME_FAIL, ""), {
kind: "error",
});

Sentry.captureException(
new Error(createMessage(ERROR_ACTION_RENAME_FAIL, "")),
{
extra: {
actionId: actionId,
},
yield put({
type: ReduxActionErrorTypes.SAVE_ACTION_NAME_ERROR,
payload: {
actionId,
error: { message: createMessage(ERROR_ACTION_RENAME_FAIL, "") },
logToSentry: true,
},
);
});
return;
}
if (actionObj.pluginType === PluginType.API) {
Expand Down
40 changes: 14 additions & 26 deletions app/client/src/sagas/DatasourcesSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,9 @@ export function* deleteDatasourceSaga(
yield select(getDatasource, actionPayload.payload.id),
`Datasource not found for id - ${actionPayload.payload.id}`,
);
toast.show((error as Error).message, {
kind: "error",
});
yield put({
type: ReduxActionErrorTypes.DELETE_DATASOURCE_ERROR,
payload: { error, id: actionPayload.payload.id, show: false },
payload: { error, id: actionPayload.payload.id },
});
AppsmithConsole.error({
text: (error as Error).message,
Expand Down Expand Up @@ -733,12 +730,12 @@ function* getOAuthAccessTokenSaga(
if (!appsmithToken) {
// Error out because auth token should been here
log.error(OAUTH_APPSMITH_TOKEN_NOT_FOUND);
toast.show(OAUTH_AUTHORIZATION_APPSMITH_ERROR, {
kind: "error",
});
yield put({
type: ReduxActionTypes.GET_OAUTH_ACCESS_TOKEN_ERROR,
payload: { datasourceId: datasourceId },
type: ReduxActionErrorTypes.GET_OAUTH_ACCESS_TOKEN_ERROR,
payload: {
datasourceId: datasourceId,
message: OAUTH_AUTHORIZATION_APPSMITH_ERROR,
},
});
return;
}
Expand Down Expand Up @@ -797,11 +794,11 @@ function* getOAuthAccessTokenSaga(
}
} catch (e) {
yield put({
type: ReduxActionTypes.GET_OAUTH_ACCESS_TOKEN_ERROR,
payload: { datasourceId: datasourceId },
});
toast.show(OAUTH_AUTHORIZATION_FAILED, {
kind: "error",
type: ReduxActionErrorTypes.GET_OAUTH_ACCESS_TOKEN_ERROR,
payload: {
datasourceId: datasourceId,
message: OAUTH_AUTHORIZATION_FAILED,
},
});
log.error(e);
}
Expand Down Expand Up @@ -910,25 +907,19 @@ function* testDatasourceSaga(actionPayload: ReduxAction<Datasource>) {
}
if (responseData.invalids && responseData.invalids.length) {
AnalyticsUtil.logEvent("TEST_DATA_SOURCE_FAILED", {
datasoureId: datasource?.id,
datasourceId: datasource?.id,
environmentId: currentEnvironment,
environmentName: currentEnvDetails.name,
pluginName: plugin?.name,
errorMessages: responseData.invalids,
messages: responseData.messages,
});
responseData.invalids.forEach((message: string) => {
toast.show(message, {
kind: "error",
});
});
yield put({
type: ReduxActionErrorTypes.TEST_DATASOURCE_ERROR,
payload: {
show: false,
id: datasource.id,
environmentId: currentEnvironment,
messages: messages,
message: responseData.invalids.join(", "),
},
});
AppsmithConsole.error({
Expand Down Expand Up @@ -2100,10 +2091,7 @@ function* updateDatasourceAuthStateSaga(
} catch (error) {
yield put({
type: ReduxActionErrorTypes.UPDATE_DATASOURCE_ERROR,
payload: { error },
});
toast.show(OAUTH_AUTHORIZATION_FAILED, {
kind: "error",
payload: { error, message: OAUTH_AUTHORIZATION_FAILED },
});
}
}
Expand Down
Loading
Loading