Remove success toast notification! (#4375)

This commit is contained in:
Shailesh Parmar 2022-04-22 22:29:02 +05:30 committed by GitHub
parent 8c60b22180
commit 66a9663763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 19 additions and 47 deletions

View File

@ -79,7 +79,7 @@ import { deletePost, getUpdatedThread } from '../../utils/FeedUtils';
import { serviceTypeLogo } from '../../utils/ServiceUtils';
import { getErrorText } from '../../utils/StringsUtils';
import { getTagsWithoutTier, getTierTags } from '../../utils/TableUtils';
import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils';
import { showErrorToast } from '../../utils/ToastUtils';
type ChartType = {
displayName: string;
@ -638,9 +638,6 @@ const DashboardDetailsPage = () => {
if (res.data) {
setEntityThread((pre) => [...pre, res.data]);
getEntityFeedCount();
showSuccessToast(
jsonData['api-success-messages']['create-conversation']
);
} else {
showErrorToast(
jsonData['api-error-messages']['unexpected-server-response']
@ -686,8 +683,6 @@ const DashboardDetailsPage = () => {
jsonData['api-error-messages']['fetch-updated-conversation-error']
);
});
showSuccessToast(jsonData['api-success-messages']['delete-message']);
})
.catch((error: AxiosError) => {
showErrorToast(

View File

@ -90,7 +90,7 @@ import {
} from '../../utils/FeedUtils';
import { serviceTypeLogo } from '../../utils/ServiceUtils';
import { getErrorText } from '../../utils/StringsUtils';
import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils';
import { showErrorToast } from '../../utils/ToastUtils';
const DatabaseSchemaPage: FunctionComponent = () => {
const [slashedTableName, setSlashedTableName] = useState<
@ -438,9 +438,6 @@ const DatabaseSchemaPage: FunctionComponent = () => {
if (res.data) {
setEntityThread((pre) => [...pre, res.data]);
getEntityFeedCount();
showSuccessToast(
jsonData['api-success-messages']['create-conversation']
);
} else {
showErrorToast(
jsonData['api-error-messages']['unexpected-server-response']
@ -486,8 +483,6 @@ const DatabaseSchemaPage: FunctionComponent = () => {
jsonData['api-error-messages']['fetch-updated-conversation-error']
);
});
showSuccessToast(jsonData['api-success-messages']['delete-message']);
})
.catch((err: AxiosError) => {
showErrorToast(

View File

@ -744,9 +744,6 @@ const DatasetDetailsPage: FunctionComponent = () => {
if (res.data) {
setEntityThread((pre) => [...pre, res.data]);
getEntityFeedCount();
showSuccessToast(
jsonData['api-success-messages']['create-conversation']
);
} else {
showErrorToast(
jsonData['api-error-messages']['create-conversation-error']
@ -931,8 +928,6 @@ const DatasetDetailsPage: FunctionComponent = () => {
jsonData['api-error-messages']['fetch-updated-conversation-error']
);
});
showSuccessToast(jsonData['api-success-messages']['delete-message']);
})
.catch((error: AxiosError) => {
showErrorToast(

View File

@ -29,7 +29,6 @@ import GithubStarButton from '../../components/GithubStarButton/GithubStarButton
import Loader from '../../components/Loader/Loader';
import MyData from '../../components/MyData/MyData.component';
import {
onConfirmText,
onErrorText,
onUpdatedConversastionError,
} from '../../constants/feed.constants';
@ -42,7 +41,7 @@ import { formatDataResponse } from '../../utils/APIUtils';
import { deletePost, getUpdatedThread } from '../../utils/FeedUtils';
import { getMyDataFilters } from '../../utils/MyDataUtils';
import { getAllServices } from '../../utils/ServiceUtils';
import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils';
import { showErrorToast } from '../../utils/ToastUtils';
const MyDataPage = () => {
const location = useLocation();
@ -288,7 +287,6 @@ const MyDataPage = () => {
const message = error?.message;
showErrorToast(message ?? onUpdatedConversastionError);
});
showSuccessToast(onConfirmText);
})
.catch((error) => {
const message = error?.message;

View File

@ -77,7 +77,7 @@ import {
} from '../../utils/PipelineDetailsUtils';
import { serviceTypeLogo } from '../../utils/ServiceUtils';
import { getTagsWithoutTier, getTierTags } from '../../utils/TableUtils';
import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils';
import { showErrorToast } from '../../utils/ToastUtils';
const PipelineDetailsPage = () => {
const USERId = getCurrentUserId();
@ -590,9 +590,6 @@ const PipelineDetailsPage = () => {
if (res.data) {
setEntityThread((pre) => [...pre, res.data]);
getEntityFeedCount();
showSuccessToast(
jsonData['api-success-messages']['create-conversation']
);
} else {
showErrorToast(
jsonData['api-error-messages']['unexpected-server-response']
@ -638,8 +635,6 @@ const PipelineDetailsPage = () => {
jsonData['api-error-messages']['fetch-updated-conversation-error']
);
});
showSuccessToast(jsonData['api-success-messages']['delete-message']);
})
.catch((error: AxiosError) => {
showErrorToast(

View File

@ -57,7 +57,7 @@ import { getEntityFeedLink } from '../../utils/EntityUtils';
import { deletePost, getUpdatedThread } from '../../utils/FeedUtils';
import { serviceTypeLogo } from '../../utils/ServiceUtils';
import { getTagsWithoutTier, getTierTags } from '../../utils/TableUtils';
import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils';
import { showErrorToast } from '../../utils/ToastUtils';
import {
getCurrentTopicTab,
topicDetailsTabs,
@ -411,9 +411,6 @@ const TopicDetailsPage: FunctionComponent = () => {
if (res.data) {
setEntityThread((pre) => [...pre, res.data]);
getEntityFeedCount();
showSuccessToast(
jsonData['api-success-messages']['create-conversation']
);
} else {
showErrorToast(
jsonData['api-error-messages']['create-conversation-error']
@ -461,8 +458,6 @@ const TopicDetailsPage: FunctionComponent = () => {
jsonData['api-error-messages']['fetch-updated-conversation-error']
);
});
showSuccessToast(jsonData['api-success-messages']['delete-message']);
})
.catch((error: AxiosError) => {
showErrorToast(

View File

@ -23,7 +23,6 @@ import PageContainerV1 from '../../components/containers/PageContainerV1';
import Loader from '../../components/Loader/Loader';
import Users from '../../components/Users/Users.component';
import {
onConfirmText,
onErrorText,
onUpdatedConversastionError,
} from '../../constants/feed.constants';
@ -32,7 +31,7 @@ import { User } from '../../generated/entity/teams/user';
import { Paging } from '../../generated/type/paging';
import jsonData from '../../jsons/en';
import { deletePost, getUpdatedThread } from '../../utils/FeedUtils';
import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils';
import { showErrorToast } from '../../utils/ToastUtils';
const UserPage = () => {
const { username } = useParams<{ [key: string]: string }>();
@ -154,7 +153,6 @@ const UserPage = () => {
const message = error?.message;
showErrorToast(message ?? onUpdatedConversastionError);
});
showSuccessToast(onConfirmText);
})
.catch((error) => {
const message = error?.message;

View File

@ -92,7 +92,7 @@ import {
import { serviceTypeLogo } from '../../utils/ServiceUtils';
import { getErrorText } from '../../utils/StringsUtils';
import { getOwnerFromId, getUsagePercentile } from '../../utils/TableUtils';
import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils';
import { showErrorToast } from '../../utils/ToastUtils';
const DatabaseDetails: FunctionComponent = () => {
const [slashedDatabaseName, setSlashedDatabaseName] = useState<
@ -469,9 +469,6 @@ const DatabaseDetails: FunctionComponent = () => {
if (res.data) {
setEntityThread((pre) => [...pre, res.data]);
getEntityFeedCount();
showSuccessToast(
jsonData['api-success-messages']['create-conversation']
);
} else {
showErrorToast(
jsonData['api-error-messages']['unexpected-server-response']
@ -517,8 +514,6 @@ const DatabaseDetails: FunctionComponent = () => {
jsonData['api-error-messages']['fetch-updated-conversation-error']
);
});
showSuccessToast(jsonData['api-success-messages']['delete-message']);
})
.catch((error: AxiosError) => {
showErrorToast(

View File

@ -21,10 +21,12 @@ import { getErrorText } from './StringsUtils';
* Display an error toast message.
* @param error error text or AxiosError object
* @param fallbackText Fallback error message to the displayed.
* @param autoCloseTimer Set the delay in ms to close the toast automatically.
*/
export const showErrorToast = (
error: AxiosError | string,
fallbackText?: string
fallbackText?: string,
autoCloseTimer?: number
) => {
let errorMessage;
if (isString(error)) {
@ -41,26 +43,30 @@ export const showErrorToast = (
return;
}
}
toast.error(errorMessage);
toast.error(errorMessage, {
autoClose: autoCloseTimer,
});
};
/**
* Display a success toast message.
* @param message success message.
* @param autoCloseTimer Set the delay in ms to close the toast automatically. `Default: 5000`
*/
export const showSuccessToast = (message: string) => {
export const showSuccessToast = (message: string, autoCloseTimer = 5000) => {
toast.success(message, {
autoClose: 10000,
autoClose: autoCloseTimer,
});
};
/**
* Display an info toast message.
* @param message info message.
* @param autoCloseTimer Set the delay in ms to close the toast automatically. `Default: 5000`
*/
export const showInfoToast = (message: string) => {
export const showInfoToast = (message: string, autoCloseTimer = 5000) => {
toast.info(message, {
autoClose: 10000,
autoClose: autoCloseTimer,
});
};