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 = () => `Please select an action`;
|
||||||
export const ERROR_MESSAGE_SELECT_ACTION_TYPE = () =>
|
export const ERROR_MESSAGE_SELECT_ACTION_TYPE = () =>
|
||||||
`Please select an 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 = () =>
|
export const ERROR_ADD_API_INVALID_URL = () =>
|
||||||
`Unable to create API. Try adding a URL to the datasource`;
|
`Unable to create API. Try adding a URL to the datasource`;
|
||||||
export const ERROR_MESSAGE_NAME_EMPTY = () => `Please select a name`;
|
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`;
|
`Failed to execute actions during page load`;
|
||||||
export const ERROR_ACTION_EXECUTE_FAIL = (actionName: string) =>
|
export const ERROR_ACTION_EXECUTE_FAIL = (actionName: string) =>
|
||||||
`${actionName} action returned an error response`;
|
`${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) =>
|
export const ACTION_MOVE_SUCCESS = (actionName: string, pageName: string) =>
|
||||||
`${actionName} action moved to page ${pageName} successfully`;
|
`${actionName} action moved to page ${pageName} successfully`;
|
||||||
export const ERROR_ACTION_MOVE_FAIL = (actionName: string) =>
|
export const ERROR_ACTION_MOVE_FAIL = (actionName: string) =>
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,6 @@ import PerformanceTracker, {
|
||||||
} from "utils/PerformanceTracker";
|
} from "utils/PerformanceTracker";
|
||||||
import {
|
import {
|
||||||
ACTION_COPY_SUCCESS,
|
ACTION_COPY_SUCCESS,
|
||||||
ACTION_CREATED_SUCCESS,
|
|
||||||
ACTION_DELETE_SUCCESS,
|
|
||||||
ACTION_MOVE_SUCCESS,
|
ACTION_MOVE_SUCCESS,
|
||||||
createMessage,
|
createMessage,
|
||||||
ERROR_ACTION_COPY_FAIL,
|
ERROR_ACTION_COPY_FAIL,
|
||||||
|
|
@ -145,14 +143,6 @@ export function* createActionSaga(
|
||||||
);
|
);
|
||||||
const isValidResponse = yield validateResponse(response);
|
const isValidResponse = yield validateResponse(response);
|
||||||
if (isValidResponse) {
|
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(
|
const pageName = yield select(
|
||||||
getCurrentPageNameByActionId,
|
getCurrentPageNameByActionId,
|
||||||
response.data.id,
|
response.data.id,
|
||||||
|
|
@ -379,11 +369,9 @@ export function* deleteActionSaga(
|
||||||
id,
|
id,
|
||||||
);
|
);
|
||||||
const isValidResponse = yield validateResponse(response);
|
const isValidResponse = yield validateResponse(response);
|
||||||
if (isValidResponse) {
|
if (!isValidResponse) {
|
||||||
Toaster.show({
|
return;
|
||||||
text: createMessage(ACTION_DELETE_SUCCESS, response.data.name),
|
}
|
||||||
variant: Variant.success,
|
|
||||||
});
|
|
||||||
if (isApi) {
|
if (isApi) {
|
||||||
const pageName = yield select(getCurrentPageNameByActionId, id);
|
const pageName = yield select(getCurrentPageNameByActionId, id);
|
||||||
AnalyticsUtil.logEvent("DELETE_API", {
|
AnalyticsUtil.logEvent("DELETE_API", {
|
||||||
|
|
@ -395,14 +383,14 @@ export function* deleteActionSaga(
|
||||||
if (isSaas) {
|
if (isSaas) {
|
||||||
const pageName = yield select(getCurrentPageNameByActionId, id);
|
const pageName = yield select(getCurrentPageNameByActionId, id);
|
||||||
AnalyticsUtil.logEvent("DELETE_SAAS", {
|
AnalyticsUtil.logEvent("DELETE_SAAS", {
|
||||||
apiName: action.name,
|
apiName: name,
|
||||||
pageName,
|
pageName,
|
||||||
apiID: id,
|
apiID: id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (isQuery) {
|
if (isQuery) {
|
||||||
AnalyticsUtil.logEvent("DELETE_QUERY", {
|
AnalyticsUtil.logEvent("DELETE_QUERY", {
|
||||||
queryName: action.name,
|
queryName: name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -431,7 +419,6 @@ export function* deleteActionSaga(
|
||||||
});
|
});
|
||||||
|
|
||||||
yield put(deleteActionSuccess({ id }));
|
yield put(deleteActionSuccess({ id }));
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
yield put({
|
yield put({
|
||||||
type: ReduxActionErrorTypes.DELETE_ACTION_ERROR,
|
type: ReduxActionErrorTypes.DELETE_ACTION_ERROR,
|
||||||
|
|
|
||||||
|
|
@ -78,13 +78,14 @@ export function* validateResponse(response: ApiResponse | any, show = true) {
|
||||||
}
|
}
|
||||||
if (response.responseMeta.success) {
|
if (response.responseMeta.success) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
if (
|
if (
|
||||||
response.responseMeta.error.code ===
|
response.responseMeta.error.code ===
|
||||||
SERVER_ERROR_CODES.INCORRECT_BINDING_LIST_OF_WIDGET
|
SERVER_ERROR_CODES.INCORRECT_BINDING_LIST_OF_WIDGET
|
||||||
) {
|
) {
|
||||||
throw new IncorrectBindingError(response.responseMeta.error.message);
|
throw new IncorrectBindingError(response.responseMeta.error.message);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
yield put({
|
yield put({
|
||||||
type: ReduxActionErrorTypes.API_ERROR,
|
type: ReduxActionErrorTypes.API_ERROR,
|
||||||
payload: {
|
payload: {
|
||||||
|
|
@ -93,8 +94,6 @@ export function* validateResponse(response: ApiResponse | any, show = true) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
throw Error(response.responseMeta.error.message);
|
throw Error(response.responseMeta.error.message);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getResponseErrorMessage(response: ApiResponse) {
|
export function getResponseErrorMessage(response: ApiResponse) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user