diff --git a/app/soapbox/actions/auth.js b/app/soapbox/actions/auth.js index 09a225bf5..3fd9578a0 100644 --- a/app/soapbox/actions/auth.js +++ b/app/soapbox/actions/auth.js @@ -1,5 +1,5 @@ import api from '../api'; -import { showAlert } from 'soapbox/actions/alerts'; +import snackbar from 'soapbox/actions/snackbar'; import { fetchMe } from 'soapbox/actions/me'; export const AUTH_APP_CREATED = 'AUTH_APP_CREATED'; @@ -136,7 +136,7 @@ export function logIn(username, password) { if (error.response.data.error === 'mfa_required') { throw error; } else { - dispatch(showAlert('Login failed.', 'Invalid username or password.')); + dispatch(snackbar.error('Invalid username or password.')); } throw error; }); @@ -156,7 +156,7 @@ export function logOut() { token: state.getIn(['auth', 'user', 'access_token']), }); - dispatch(showAlert('Successfully logged out.', '')); + dispatch(snackbar.success('Logged out.')); }; } @@ -172,9 +172,9 @@ export function register(params) { dispatch({ type: AUTH_REGISTER_SUCCESS, token: response.data }); dispatch(authLoggedIn(response.data)); if (needsConfirmation) { - return dispatch(showAlert('', 'Check your email for further instructions.')); + return dispatch(snackbar.info('You must confirm your email.')); } else if (needsApproval) { - return dispatch(showAlert('', 'Your account has been submitted for approval.')); + return dispatch(snackbar.info('Your account is being reviewed.')); } else { return dispatch(fetchMe()); } @@ -232,7 +232,7 @@ export function deleteAccount(password) { if (response.data.error) throw response.data.error; // This endpoint returns HTTP 200 even on failure dispatch({ type: DELETE_ACCOUNT_SUCCESS, response }); dispatch({ type: AUTH_LOGGED_OUT }); - dispatch(showAlert('Successfully logged out.', '')); + dispatch(snackbar.success('Logged out.')); }).catch(error => { dispatch({ type: DELETE_ACCOUNT_FAIL, error, skipAlert: true }); throw error; diff --git a/app/soapbox/actions/compose.js b/app/soapbox/actions/compose.js index f4a644e87..782dee74a 100644 --- a/app/soapbox/actions/compose.js +++ b/app/soapbox/actions/compose.js @@ -224,7 +224,7 @@ export function uploadCompose(files) { let total = Array.from(files).reduce((a, v) => a + v.size, 0); if (files.length + media.size > uploadLimit) { - dispatch(showAlert(undefined, messages.uploadErrorLimit)); + dispatch(showAlert(undefined, messages.uploadErrorLimit, 'error')); return; } diff --git a/app/soapbox/actions/filters.js b/app/soapbox/actions/filters.js index 3448e391c..e3ad557f5 100644 --- a/app/soapbox/actions/filters.js +++ b/app/soapbox/actions/filters.js @@ -1,5 +1,5 @@ import api from '../api'; -import { showAlert } from 'soapbox/actions/alerts'; +import snackbar from 'soapbox/actions/snackbar'; export const FILTERS_FETCH_REQUEST = 'FILTERS_FETCH_REQUEST'; export const FILTERS_FETCH_SUCCESS = 'FILTERS_FETCH_SUCCESS'; @@ -47,7 +47,7 @@ export function createFilter(phrase, expires_at, context, whole_word, irreversib expires_at, }).then(response => { dispatch({ type: FILTERS_CREATE_SUCCESS, filter: response.data }); - dispatch(showAlert('', 'Filter added')); + dispatch(snackbar.success('Filter added.')); }).catch(error => { dispatch({ type: FILTERS_CREATE_FAIL, error }); }); @@ -60,7 +60,7 @@ export function deleteFilter(id) { dispatch({ type: FILTERS_DELETE_REQUEST }); return api(getState).delete('/api/v1/filters/'+id).then(response => { dispatch({ type: FILTERS_DELETE_SUCCESS, filter: response.data }); - dispatch(showAlert('', 'Filter deleted')); + dispatch(snackbar.success('Filter deleted.')); }).catch(error => { dispatch({ type: FILTERS_DELETE_FAIL, error }); }); diff --git a/app/soapbox/actions/import_data.js b/app/soapbox/actions/import_data.js index 251d2972d..6a0a3c254 100644 --- a/app/soapbox/actions/import_data.js +++ b/app/soapbox/actions/import_data.js @@ -1,5 +1,5 @@ import api from '../api'; -import { showAlert } from 'soapbox/actions/alerts'; +import snackbar from 'soapbox/actions/snackbar'; export const IMPORT_FOLLOWS_REQUEST = 'IMPORT_FOLLOWS_REQUEST'; export const IMPORT_FOLLOWS_SUCCESS = 'IMPORT_FOLLOWS_SUCCESS'; @@ -19,7 +19,7 @@ export function importFollows(params) { return api(getState) .post('/api/pleroma/follow_import', params) .then(response => { - dispatch(showAlert('', 'Followers imported successfully')); + dispatch(snackbar.success('Followers imported successfully')); dispatch({ type: IMPORT_FOLLOWS_SUCCESS, config: response.data }); }).catch(error => { dispatch({ type: IMPORT_FOLLOWS_FAIL, error }); @@ -33,7 +33,7 @@ export function importBlocks(params) { return api(getState) .post('/api/pleroma/blocks_import', params) .then(response => { - dispatch(showAlert('', 'Blocks imported successfully')); + dispatch(snackbar.success('Blocks imported successfully')); dispatch({ type: IMPORT_BLOCKS_SUCCESS, config: response.data }); }).catch(error => { dispatch({ type: IMPORT_BLOCKS_FAIL, error }); @@ -47,7 +47,7 @@ export function importMutes(params) { return api(getState) .post('/api/pleroma/mutes_import', params) .then(response => { - dispatch(showAlert('', 'Mutes imported successfully')); + dispatch(snackbar.success('Mutes imported successfully')); dispatch({ type: IMPORT_MUTES_SUCCESS, config: response.data }); }).catch(error => { dispatch({ type: IMPORT_MUTES_FAIL, error }); diff --git a/app/soapbox/actions/interactions.js b/app/soapbox/actions/interactions.js index 1acfa9c57..b07feac1b 100644 --- a/app/soapbox/actions/interactions.js +++ b/app/soapbox/actions/interactions.js @@ -1,6 +1,6 @@ import api from '../api'; import { importFetchedAccounts, importFetchedStatus } from './importer'; -import { showAlert } from 'soapbox/actions/alerts'; +import snackbar from 'soapbox/actions/snackbar'; export const REBLOG_REQUEST = 'REBLOG_REQUEST'; export const REBLOG_SUCCESS = 'REBLOG_SUCCESS'; @@ -211,7 +211,7 @@ export function bookmark(status) { api(getState).post(`/api/v1/statuses/${status.get('id')}/bookmark`).then(function(response) { dispatch(importFetchedStatus(response.data)); dispatch(bookmarkSuccess(status, response.data)); - dispatch(showAlert('', 'Bookmark added')); + dispatch(snackbar.success('Bookmark added')); }).catch(function(error) { dispatch(bookmarkFail(status, error)); }); @@ -225,7 +225,7 @@ export function unbookmark(status) { api(getState).post(`/api/v1/statuses/${status.get('id')}/unbookmark`).then(response => { dispatch(importFetchedStatus(response.data)); dispatch(unbookmarkSuccess(status, response.data)); - dispatch(showAlert('', 'Bookmark removed')); + dispatch(snackbar.success('Bookmark removed')); }).catch(error => { dispatch(unbookmarkFail(status, error)); }); diff --git a/app/soapbox/features/auth_login/components/password_reset.js b/app/soapbox/features/auth_login/components/password_reset.js index efc1c816c..7dc363a2f 100644 --- a/app/soapbox/features/auth_login/components/password_reset.js +++ b/app/soapbox/features/auth_login/components/password_reset.js @@ -4,7 +4,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; import { resetPassword } from 'soapbox/actions/auth'; import { SimpleForm, FieldsGroup, TextInput } from 'soapbox/features/forms'; import { Redirect } from 'react-router-dom'; -import { showAlert } from 'soapbox/actions/alerts'; +import snackbar from 'soapbox/actions/snackbar'; export default @connect() class PasswordReset extends ImmutablePureComponent { @@ -20,7 +20,7 @@ class PasswordReset extends ImmutablePureComponent { this.setState({ isLoading: true }); dispatch(resetPassword(nicknameOrEmail)).then(() => { this.setState({ isLoading: false, success: true }); - dispatch(showAlert('Password reset received. Check your email for further instructions.', '')); + dispatch(snackbar.info('Check your email for confirmation.')); }).catch(error => { this.setState({ isLoading: false }); }); diff --git a/app/soapbox/features/edit_profile/index.js b/app/soapbox/features/edit_profile/index.js index 41a32419b..75941885d 100644 --- a/app/soapbox/features/edit_profile/index.js +++ b/app/soapbox/features/edit_profile/index.js @@ -4,7 +4,7 @@ import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import { showAlert } from 'soapbox/actions/alerts'; +import snackbar from 'soapbox/actions/snackbar'; import Column from '../ui/components/column'; import { SimpleForm, @@ -124,7 +124,7 @@ class EditProfile extends ImmutablePureComponent { const { dispatch } = this.props; dispatch(patchMe(this.getFormdata())).then(() => { this.setState({ isLoading: false }); - dispatch(showAlert('', 'Profile saved!')); + dispatch(snackbar.success('Profile saved!')); }).catch((error) => { this.setState({ isLoading: false }); }); diff --git a/app/soapbox/features/filters/index.js b/app/soapbox/features/filters/index.js index 60b406a82..1573263d8 100644 --- a/app/soapbox/features/filters/index.js +++ b/app/soapbox/features/filters/index.js @@ -14,7 +14,7 @@ import { SelectDropdown, Checkbox, } from 'soapbox/features/forms'; -import { showAlert } from 'soapbox/actions/alerts'; +import snackbar from 'soapbox/actions/snackbar'; import Icon from 'soapbox/components/icon'; import ColumnSubheading from '../ui/components/column_subheading'; @@ -114,7 +114,7 @@ class Filters extends ImmutablePureComponent { dispatch(createFilter(phrase, expires_at, context, whole_word, irreversible)).then(response => { return dispatch(fetchFilters()); }).catch(error => { - dispatch(showAlert('', intl.formatMessage(messages.create_error))); + dispatch(snackbar.error(intl.formatMessage(messages.create_error))); }); } @@ -123,7 +123,7 @@ class Filters extends ImmutablePureComponent { dispatch(deleteFilter(e.currentTarget.dataset.value)).then(response => { return dispatch(fetchFilters()); }).catch(error => { - dispatch(showAlert('', intl.formatMessage(messages.delete_error))); + dispatch(snackbar.error(intl.formatMessage(messages.delete_error))); }); } diff --git a/app/soapbox/features/security/mfa_form.js b/app/soapbox/features/security/mfa_form.js index 572579d53..3f9074f50 100644 --- a/app/soapbox/features/security/mfa_form.js +++ b/app/soapbox/features/security/mfa_form.js @@ -10,7 +10,7 @@ import ColumnSubheading from '../ui/components/column_subheading'; import LoadingIndicator from 'soapbox/components/loading_indicator'; import Button from 'soapbox/components/button'; import { changeSetting, getSettings } from 'soapbox/actions/settings'; -import { showAlert } from 'soapbox/actions/alerts'; +import snackbar from 'soapbox/actions/snackbar'; import { SimpleForm, SimpleInput, @@ -129,7 +129,7 @@ class DisableOtpForm extends ImmutablePureComponent { this.context.router.history.push('../auth/edit'); dispatch(changeSetting(['otpEnabled'], false)); }).catch(error => { - dispatch(showAlert('', intl.formatMessage(messages.disableFail))); + dispatch(snackbar.error(intl.formatMessage(messages.disableFail))); }); } @@ -180,7 +180,7 @@ class EnableOtpForm extends ImmutablePureComponent { dispatch(fetchBackupCodes()).then(response => { this.setState({ backupCodes: response.data.codes }); }).catch(error => { - dispatch(showAlert('', intl.formatMessage(messages.codesFail))); + dispatch(snackbar.error(intl.formatMessage(messages.codesFail))); }); } @@ -261,7 +261,7 @@ class OtpConfirmForm extends ImmutablePureComponent { dispatch(fetchToptSetup()).then(response => { this.setState({ qrCodeURI: response.data.provisioning_uri, confirm_key: response.data.key }); }).catch(error => { - dispatch(showAlert('', intl.formatMessage(messages.qrFail))); + dispatch(snackbar.error(intl.formatMessage(messages.qrFail))); }); } @@ -276,7 +276,7 @@ class OtpConfirmForm extends ImmutablePureComponent { dispatch(confirmToptSetup(code, password)).then(response => { dispatch(changeSetting(['otpEnabled'], true)); }).catch(error => { - dispatch(showAlert('', intl.formatMessage(messages.confirmFail))); + dispatch(snackbar.error(intl.formatMessage(messages.confirmFail))); }); }