Skip to content

Commit

Permalink
toast defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
hetunandu committed Sep 3, 2024
1 parent 3b5a65b commit c5228d5
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 10 deletions.
14 changes: 14 additions & 0 deletions app/client/src/ce/constants/ReduxActionConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,20 @@ export const ReduxActionErrorTypes = {
...WorkspaceActionErrorTypes,
};

export const toastMessageErrorTypes = {
...AdminSettingsActionErrorTypes,
...ApplicationActionErrorTypes,
...AppViewActionErrorTypes,
...DatasourceEditorActionErrorTypes,
...GitActionErrorTypes,
...ImportExportActionErrorTypes,
...PlatformActionErrorTypes,
...TenantActionErrorTypes,
...UserAuthActionErrorTypes,
...UserProfileActionErrorTypes,
...WorkspaceActionErrorTypes,
};

export type ReduxActionErrorType =
(typeof ReduxActionErrorTypes)[keyof typeof ReduxActionErrorTypes];

Expand Down
2 changes: 1 addition & 1 deletion app/client/src/reducers/uiReducers/debuggerReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const initialState: DebuggerReduxState = {
isOpen: false,
errors: {},
expandId: "",
hideErrors: false,
hideErrors: true,
context: DefaultDebuggerContext,
};

Expand Down
12 changes: 10 additions & 2 deletions app/client/src/sagas/DatasourcesSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,10 @@ function* getOAuthAccessTokenSaga(
type: ReduxActionErrorTypes.GET_OAUTH_ACCESS_TOKEN_ERROR,
payload: {
datasourceId: datasourceId,
message: OAUTH_AUTHORIZATION_FAILED,
show: true,
error: {
message: OAUTH_AUTHORIZATION_FAILED,
},
},
});
log.error(e);
Expand Down Expand Up @@ -2102,7 +2105,12 @@ function* updateDatasourceAuthStateSaga(
} catch (error) {
yield put({
type: ReduxActionErrorTypes.UPDATE_DATASOURCE_ERROR,
payload: { error, show: true, message: OAUTH_AUTHORIZATION_FAILED },
payload: {
error: {
message: OAUTH_AUTHORIZATION_FAILED,
},
show: true,
},
});
}
}
Expand Down
11 changes: 9 additions & 2 deletions app/client/src/sagas/ErrorSagas.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { get } from "lodash";
import type { ReduxAction } from "ee/constants/ReduxActionConstants";
import {
type ReduxAction,
toastMessageErrorTypes,
} from "ee/constants/ReduxActionConstants";
import {
ReduxActionTypes,
ReduxActionErrorTypes,
Expand Down Expand Up @@ -35,6 +38,10 @@ import type { SourceEntity } from "../entities/AppsmithConsole";
import { getAppMode } from "ee/selectors/applicationSelectors";
import type { APP_MODE } from "../entities/App";

const shouldShowToast = (action: string) => {
return action in toastMessageErrorTypes;
};

/**
* making with error message with action name
*
Expand Down Expand Up @@ -216,7 +223,7 @@ export function* errorSaga(errorAction: ReduxAction<ErrorActionPayload>) {
const message = getErrorMessageFromActionType(type, error);
const appMode: APP_MODE = yield select(getAppMode);

if (show || appMode === "PUBLISHED") {
if (show || appMode === "PUBLISHED" || shouldShowToast(type)) {
effects.push(ErrorEffectTypes.SHOW_ALERT);
}

Expand Down
1 change: 1 addition & 0 deletions app/client/src/sagas/JSLibrarySaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ function* uninstallLibrarySaga(action: ReduxAction<JSLibrary>) {
yield put({
type: ReduxActionErrorTypes.UNINSTALL_LIBRARY_FAILED,
payload: {
show: true,
accessor,
error: {
message: createMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
ReduxActionTypes,
} from "ee/constants/ReduxActionConstants";
import { getCurrentApplication } from "ee/selectors/applicationSelectors";
import { toast } from "@appsmith/ads";
import { getFlexLayersForSelectedWidgets } from "layoutSystems/autolayout/utils/AutoLayoutUtils";
import type { FlexLayer } from "layoutSystems/autolayout/utils/types";
import type { FlattenedWidgetProps } from "reducers/entityReducers/canvasWidgetsReducer";
Expand Down Expand Up @@ -76,14 +75,12 @@ export function* partialExportSaga(action: ReduxAction<PartialExportParams>) {
});
}
} catch (e) {
toast.show(createMessage(ERROR_IN_EXPORTING_APP), {
kind: "error",
});
yield put({
type: ReduxActionErrorTypes.PARTIAL_EXPORT_ERROR,
payload: {
show: true,
error: {
message: "Error exporting application",
message: createMessage(ERROR_IN_EXPORTING_APP),
},
},
});
Expand Down

0 comments on commit c5228d5

Please sign in to comment.