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,59 +369,56 @@ 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) {
|
|
||||||
const pageName = yield select(getCurrentPageNameByActionId, id);
|
|
||||||
AnalyticsUtil.logEvent("DELETE_API", {
|
|
||||||
apiName: name,
|
|
||||||
pageName,
|
|
||||||
apiID: id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (isSaas) {
|
|
||||||
const pageName = yield select(getCurrentPageNameByActionId, id);
|
|
||||||
AnalyticsUtil.logEvent("DELETE_SAAS", {
|
|
||||||
apiName: action.name,
|
|
||||||
pageName,
|
|
||||||
apiID: id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (isQuery) {
|
|
||||||
AnalyticsUtil.logEvent("DELETE_QUERY", {
|
|
||||||
queryName: action.name,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!!actionPayload.payload.onSuccess) {
|
|
||||||
actionPayload.payload.onSuccess();
|
|
||||||
} else {
|
|
||||||
const applicationId = yield select(getCurrentApplicationId);
|
|
||||||
const pageId = yield select(getCurrentPageId);
|
|
||||||
|
|
||||||
history.push(
|
|
||||||
INTEGRATION_EDITOR_URL(applicationId, pageId, INTEGRATION_TABS.NEW),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
AppsmithConsole.info({
|
|
||||||
logType: LOG_TYPE.ENTITY_DELETED,
|
|
||||||
text: "Action was deleted",
|
|
||||||
source: {
|
|
||||||
type: ENTITY_TYPE.ACTION,
|
|
||||||
name: response.data.name,
|
|
||||||
id: response.data.id,
|
|
||||||
},
|
|
||||||
analytics: {
|
|
||||||
pluginId: action.pluginId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
yield put(deleteActionSuccess({ id }));
|
|
||||||
}
|
}
|
||||||
|
if (isApi) {
|
||||||
|
const pageName = yield select(getCurrentPageNameByActionId, id);
|
||||||
|
AnalyticsUtil.logEvent("DELETE_API", {
|
||||||
|
apiName: name,
|
||||||
|
pageName,
|
||||||
|
apiID: id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (isSaas) {
|
||||||
|
const pageName = yield select(getCurrentPageNameByActionId, id);
|
||||||
|
AnalyticsUtil.logEvent("DELETE_SAAS", {
|
||||||
|
apiName: name,
|
||||||
|
pageName,
|
||||||
|
apiID: id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (isQuery) {
|
||||||
|
AnalyticsUtil.logEvent("DELETE_QUERY", {
|
||||||
|
queryName: name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!!actionPayload.payload.onSuccess) {
|
||||||
|
actionPayload.payload.onSuccess();
|
||||||
|
} else {
|
||||||
|
const applicationId = yield select(getCurrentApplicationId);
|
||||||
|
const pageId = yield select(getCurrentPageId);
|
||||||
|
|
||||||
|
history.push(
|
||||||
|
INTEGRATION_EDITOR_URL(applicationId, pageId, INTEGRATION_TABS.NEW),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
AppsmithConsole.info({
|
||||||
|
logType: LOG_TYPE.ENTITY_DELETED,
|
||||||
|
text: "Action was deleted",
|
||||||
|
source: {
|
||||||
|
type: ENTITY_TYPE.ACTION,
|
||||||
|
name: response.data.name,
|
||||||
|
id: response.data.id,
|
||||||
|
},
|
||||||
|
analytics: {
|
||||||
|
pluginId: action.pluginId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
yield put(deleteActionSuccess({ id }));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
yield put({
|
yield put({
|
||||||
type: ReduxActionErrorTypes.DELETE_ACTION_ERROR,
|
type: ReduxActionErrorTypes.DELETE_ACTION_ERROR,
|
||||||
|
|
|
||||||
|
|
@ -78,23 +78,22 @@ export function* validateResponse(response: ApiResponse | any, show = true) {
|
||||||
}
|
}
|
||||||
if (response.responseMeta.success) {
|
if (response.responseMeta.success) {
|
||||||
return true;
|
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: {
|
|
||||||
error: response.responseMeta.error,
|
|
||||||
show,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
throw Error(response.responseMeta.error.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
response.responseMeta.error.code ===
|
||||||
|
SERVER_ERROR_CODES.INCORRECT_BINDING_LIST_OF_WIDGET
|
||||||
|
) {
|
||||||
|
throw new IncorrectBindingError(response.responseMeta.error.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
yield put({
|
||||||
|
type: ReduxActionErrorTypes.API_ERROR,
|
||||||
|
payload: {
|
||||||
|
error: response.responseMeta.error,
|
||||||
|
show,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
throw Error(response.responseMeta.error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getResponseErrorMessage(response: ApiResponse) {
|
export function getResponseErrorMessage(response: ApiResponse) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user