chore: Removing redundant toast message in action creation & deletion flow (#6998)
Also minor refactoring to simplify code flow making it easier to understand Since we squash-merge all PRs, having the title conform to semantic PR guidelines is sufficient. We don't need to check the commits as well.
This commit is contained in:
parent
ceeb1ad16b
commit
94eba4b4b2
2
.github/semantic.yml
vendored
Normal file
2
.github/semantic.yml
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Always validate the PR title, and ignore the commits
|
||||
titleOnly: true
|
||||
|
|
@ -8,8 +8,6 @@ export function createMessage(
|
|||
export const ERROR_MESSAGE_SELECT_ACTION = () => `Please select an action`;
|
||||
export const ERROR_MESSAGE_SELECT_ACTION_TYPE = () =>
|
||||
`Please select an action type`;
|
||||
export const ACTION_CREATED_SUCCESS = (actionName: string) =>
|
||||
`${actionName} action created successfully`;
|
||||
export const ERROR_ADD_API_INVALID_URL = () =>
|
||||
`Unable to create API. Try adding a URL to the datasource`;
|
||||
export const ERROR_MESSAGE_NAME_EMPTY = () => `Please select a name`;
|
||||
|
|
@ -218,8 +216,6 @@ export const ERROR_FAIL_ON_PAGE_LOAD_ACTIONS = () =>
|
|||
`Failed to execute actions during page load`;
|
||||
export const ERROR_ACTION_EXECUTE_FAIL = (actionName: string) =>
|
||||
`${actionName} action returned an error response`;
|
||||
export const ACTION_DELETE_SUCCESS = (actionName: string) =>
|
||||
`${actionName} action deleted successfully`;
|
||||
export const ACTION_MOVE_SUCCESS = (actionName: string, pageName: string) =>
|
||||
`${actionName} action moved to page ${pageName} successfully`;
|
||||
export const ERROR_ACTION_MOVE_FAIL = (actionName: string) =>
|
||||
|
|
|
|||
|
|
@ -76,8 +76,6 @@ import PerformanceTracker, {
|
|||
} from "utils/PerformanceTracker";
|
||||
import {
|
||||
ACTION_COPY_SUCCESS,
|
||||
ACTION_CREATED_SUCCESS,
|
||||
ACTION_DELETE_SUCCESS,
|
||||
ACTION_MOVE_SUCCESS,
|
||||
createMessage,
|
||||
ERROR_ACTION_COPY_FAIL,
|
||||
|
|
@ -145,14 +143,6 @@ export function* createActionSaga(
|
|||
);
|
||||
const isValidResponse = yield validateResponse(response);
|
||||
if (isValidResponse) {
|
||||
const actionName = actionPayload.payload.name
|
||||
? actionPayload.payload.name
|
||||
: "";
|
||||
Toaster.show({
|
||||
text: createMessage(ACTION_CREATED_SUCCESS, actionName),
|
||||
variant: Variant.success,
|
||||
});
|
||||
|
||||
const pageName = yield select(
|
||||
getCurrentPageNameByActionId,
|
||||
response.data.id,
|
||||
|
|
@ -379,11 +369,9 @@ export function* deleteActionSaga(
|
|||
id,
|
||||
);
|
||||
const isValidResponse = yield validateResponse(response);
|
||||
if (isValidResponse) {
|
||||
Toaster.show({
|
||||
text: createMessage(ACTION_DELETE_SUCCESS, response.data.name),
|
||||
variant: Variant.success,
|
||||
});
|
||||
if (!isValidResponse) {
|
||||
return;
|
||||
}
|
||||
if (isApi) {
|
||||
const pageName = yield select(getCurrentPageNameByActionId, id);
|
||||
AnalyticsUtil.logEvent("DELETE_API", {
|
||||
|
|
@ -395,14 +383,14 @@ export function* deleteActionSaga(
|
|||
if (isSaas) {
|
||||
const pageName = yield select(getCurrentPageNameByActionId, id);
|
||||
AnalyticsUtil.logEvent("DELETE_SAAS", {
|
||||
apiName: action.name,
|
||||
apiName: name,
|
||||
pageName,
|
||||
apiID: id,
|
||||
});
|
||||
}
|
||||
if (isQuery) {
|
||||
AnalyticsUtil.logEvent("DELETE_QUERY", {
|
||||
queryName: action.name,
|
||||
queryName: name,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -431,7 +419,6 @@ export function* deleteActionSaga(
|
|||
});
|
||||
|
||||
yield put(deleteActionSuccess({ id }));
|
||||
}
|
||||
} catch (error) {
|
||||
yield put({
|
||||
type: ReduxActionErrorTypes.DELETE_ACTION_ERROR,
|
||||
|
|
|
|||
|
|
@ -78,13 +78,14 @@ export function* validateResponse(response: ApiResponse | any, show = true) {
|
|||
}
|
||||
if (response.responseMeta.success) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
if (
|
||||
response.responseMeta.error.code ===
|
||||
SERVER_ERROR_CODES.INCORRECT_BINDING_LIST_OF_WIDGET
|
||||
) {
|
||||
throw new IncorrectBindingError(response.responseMeta.error.message);
|
||||
} else {
|
||||
}
|
||||
|
||||
yield put({
|
||||
type: ReduxActionErrorTypes.API_ERROR,
|
||||
payload: {
|
||||
|
|
@ -94,8 +95,6 @@ export function* validateResponse(response: ApiResponse | any, show = true) {
|
|||
});
|
||||
throw Error(response.responseMeta.error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getResponseErrorMessage(response: ApiResponse) {
|
||||
return response.responseMeta.error
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user