Skip to content

Commit

Permalink
fix: notify services in files (#3438)
Browse files Browse the repository at this point in the history
* fixing notify services in all components files

* Resolving Conflicts

* Using snake case
  • Loading branch information
kushthedude authored and abhinavk96 committed Aug 26, 2019
1 parent 2724eee commit 6a563e2
Show file tree
Hide file tree
Showing 25 changed files with 173 additions and 62 deletions.
5 changes: 4 additions & 1 deletion app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const fixFilterQuery = query => {
if (query.hasOwnProperty('filter')) {
query.filter = JSON.stringify(query.filter);
}

return query;
};

Expand All @@ -34,13 +35,15 @@ export default JSONAPIAdapter.extend(HasManyQueryAdapterMixin, AdapterFetch, Cac
if (access_token) {
headers[ENV['ember-simple-auth-token'].authorizationHeaderName] = ENV['ember-simple-auth-token'].authorizationPrefix + access_token;
}

return headers;
}),

isInvalid(statusCode) {
if (statusCode !== 404 && statusCode !== 422 && statusCode !== 403 && statusCode !== 409) {
this.notify.error('An unexpected error occurred.', {
closeAfter: 5000
closeAfter : 5000,
id : 'serve_error'
});
}
},
Expand Down
5 changes: 4 additions & 1 deletion app/components/account/application-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ export default Component.extend({
);
this.set('data', this.get('authManager.currentUser'));
}

this.set('isLoading', false);
});
});
});
}
} catch (error) {
this.notify.error(this.l10n.t(error.message));
this.notify.error(this.l10n.t(error.message), {
id: 'error_message'
});
this.set('isLoading', false);
}
}
Expand Down
8 changes: 6 additions & 2 deletions app/components/account/danger-zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ export default Component.extend({
.then(() => {
this.authManager.logout();
this.routing.transitionTo('index');
this.notify.success(this.l10n.t('Your account has been deleted successfully.'));
this.notify.success(this.l10n.t('Your account has been deleted successfully.'), {
id: 'account_Delete'
});
})
.catch(() => {
this.notify.error(this.l10n.t('An unexpected error has occurred.'));
this.notify.error(this.l10n.t('An unexpected error has occurred.'), {
id: 'account_del_error'
});
})
.finally(() => {
this.setProperties({
Expand Down
8 changes: 6 additions & 2 deletions app/components/account/email-preferences-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ export default Component.extend({
savePreference(emailPreference) {
emailPreference.save()
.then(() => {
this.notify.success(this.l10n.t('Email notifications updated successfully'));
this.notify.success(this.l10n.t('Email notifications updated successfully'), {
id: 'email_notif'
});
})
.catch(() => {
emailPreference.rollbackAttributes();
this.notify.error(this.l10n.t('An unexpected error occurred.'));
this.notify.error(this.l10n.t('An unexpected error occurred.'), {
id: 'email_error'
});
});
}
}
Expand Down
4 changes: 3 additions & 1 deletion app/components/events/view/export/api-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export default Component.extend({
this.set('json', htmlSafe(syntaxHighlight(json)));
})
.catch(() => {
this.notify.error(this.l10n.t('Could not fetch from the server'));
this.notify.error(this.l10n.t('Could not fetch from the server'), {
id: 'server_fetch_error'
});
this.set('json', 'Could not fetch from the server');
})
.finally(() => {
Expand Down
20 changes: 15 additions & 5 deletions app/components/events/view/export/download-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,27 @@ export default Component.extend({
if (exportJobStatus.state === 'SUCCESS') {
this.set('isDownloadDisabled', false);
this.set('eventDownloadUrl', exportJobStatus.result.download_url);
this.notify.success(this.l10n.t('Download Ready'));
this.notify.success(this.l10n.t('Download Ready'), {
id: 'down_ready'
});
} else if (exportJobStatus.state === 'WAITING') {
this.requestLoop(exportJobInfo);
this.set('eventExportStatus', exportJobStatus.state);
this.notify.alert(this.l10n.t('Task is going on.'));
this.notify.alert(this.l10n.t('Task is going on.'), {
id: 'task_progress'
});
} else {
this.set('eventExportStatus', exportJobStatus.state);
this.notify.error(this.l10n.t('Task failed.'));
this.notify.error(this.l10n.t('Task failed.'), {
id: 'task_fail'
});
}
})
.catch(() => {
this.set('eventExportStatus', 'FAILURE');
this.notify.error(this.l10n.t('Task failed.'));
this.notify.error(this.l10n.t('Task failed.'), {
id: 'task_failure'
});
})
.finally(() => {
this.set('isLoading', false);
Expand All @@ -58,7 +66,9 @@ export default Component.extend({
})
.catch(() => {
this.set('isLoading', false);
this.notify.error(this.l10n.t('Unexpected error occurred.'));
this.notify.error(this.l10n.t('Unexpected error occurred.'), {
id: 'unexpected_down_error'
});
});
}
}
Expand Down
8 changes: 6 additions & 2 deletions app/components/events/view/export/download-zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ export default class extends Component {
anchor.href = URL.createObjectURL(new Blob([res], { type: 'octet/stream' }));
anchor.download = 'EventExport.zip';
anchor.click();
this.notify.success(this.l10n.t('Exported Event Downloaded successfully.'));
this.notify.success(this.l10n.t('Exported Event Downloaded successfully.'), {
id: 'export_succ'
});
} catch (e) {
console.error(e);
this.notify.error(this.l10n.t(e));
this.notify.error(this.l10n.t(e), {
id: 'err_down'
});
}
this.set('isLoading', false);
}
Expand Down
16 changes: 12 additions & 4 deletions app/components/events/view/overview/manage-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ export default Component.extend({
this.get('data.roleInvites').addObject(this.currentInvite);
}
this.set('isAddUserRoleModalOpen', false);
this.notify.success(this.isNewInvite ? this.l10n.t('Role Invite sent successfully') : this.l10n.t('Role Invite updated successfully'));
this.notify.success(this.isNewInvite ? this.l10n.t('Role Invite sent successfully') : this.l10n.t('Role Invite updated successfully'), {
id: 'man_role'
});
})
.catch(() => {
this.notify.error(this.l10n.t('Oops something went wrong. Please try again'));
this.notify.error(this.l10n.t('Oops something went wrong. Please try again'), {
id: 'man_role_err'
});
})
.finally(() => {
this.set('isLoading', false);
Expand All @@ -41,11 +45,15 @@ export default Component.extend({
this.set('isLoading', true);
invite.destroyRecord()
.then(() => {
this.notify.success(this.l10n.t('Role Invite deleted successfully'));
this.notify.success(this.l10n.t('Role Invite deleted successfully'), {
id: 'del_role_succ'
});
this.get('data.roleInvites').removeObject(invite);
})
.catch(() => {
this.notify.error(this.l10n.t('Oops something went wrong. Please try again'));
this.notify.error(this.l10n.t('Oops something went wrong. Please try again'), {
id: 'err_man_role'
});
})
.finally(() => {
this.set('isLoading', false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ export default Component.extend(FormMixin, {
};
this.loader.post('/test-mail', JSON.stringify(payload), config)
.then(response => {
this.notify.success(response.message);
this.notify.success(response.message, {
id: 'succ_response_test'
});
})
.catch(e => {
console.warn(e);
this.notify.error(this.l10n.t('An unexpected error has occurred'));
this.notify.error(this.l10n.t('An unexpected error has occurred'), {
id: 'test_mail_err'
});
});
});
}
Expand Down
12 changes: 9 additions & 3 deletions app/components/forms/admin/settings/ticket-fees-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export default Component.extend({
return (!setting.get('currency') || !setting.get('country'));
});
if (incorrect_settings.length > 0) {
this.notify.error(this.l10n.t('Existing items need to be completed before new items can be added.'));
this.notify.error(this.l10n.t('Existing items need to be completed before new items can be added.'), {
id: 'existing_item'
});
this.set('isLoading', false);
} else {
this.model.toArray().addObject(this.store.createRecord('ticket-fee', {
Expand All @@ -34,10 +36,14 @@ export default Component.extend({
this.set('isLoading', true);
rec.destroyRecord()
.then(() => {
this.notify.success(this.l10n.t('Fee setting deleted successfully'));
this.notify.success(this.l10n.t('Fee setting deleted successfully'), {
id: 'fee_delete_succ'
});
})
.catch(() => {
this.notify.error(this.l10n.t('Oops something went wrong. Please try again'));
this.notify.error(this.l10n.t('Oops something went wrong. Please try again'), {
id: 'fee_err'
});
})
.finally(() => {
this.set('isLoading', false);
Expand Down
8 changes: 6 additions & 2 deletions app/components/forms/login-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ export default class extends Component.extend(FormMixin) {
window.location.replace(response.url);
} catch (e) {
if (e.message) {
this.notify.error(this.l10n.tVar(e.message));
this.notify.error(this.l10n.tVar(e.message), {
id: 'error_server_msg'
});
} else {
this.notify.error(this.l10n.t('An unexpected error has occurred'));
this.notify.error(this.l10n.t('An unexpected error has occurred'), {
id: 'unexpect_error'
});
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions app/components/forms/reset-password-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ export default Component.extend(FormMixin, {
this.loader
.patch('auth/reset-password', payload)
.then(() => {
this.notify.success(this.l10n.t('Your password has been reset successfully. Please log in to continue'));
this.notify.success(this.l10n.t('Your password has been reset successfully. Please log in to continue'), {
id: 'reser_succ'
});
this.router.transitionTo('login');
})
.catch(() => {
this.set('errorMessage', this.l10n.t('An unexpected error occurred.'));
this.set('errorMessage', this.l10n.t('An unexpected error occurred.'), {
id: 'reset_unexpect'
});
})
.finally(() => {
this.set('isLoading', false);
Expand All @@ -75,7 +79,9 @@ export default Component.extend(FormMixin, {
this.loader
.post('auth/reset-password', payload)
.then(() => {
this.notify.success(this.l10n.t('Please go to the link sent to your email to reset your password'));
this.notify.success(this.l10n.t('Please go to the link sent to your email to reset your password'), {
id: 'reset_link_sent'
});
this.router.transitionTo('login');
})
.catch(reason => {
Expand Down
8 changes: 6 additions & 2 deletions app/components/forms/user-payment-info-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ export default Component.extend(FormMixin, {
try {
this.authManager.currentUser.setProperties(this.userBillingInfo);
await this.authManager.currentUser.save();
this.notify.success(this.l10n.t('Your billing details has been updated'));
this.notify.success(this.l10n.t('Your billing details has been updated'), {
id: 'bill_det_updated'
});
} catch (error) {
this.authManager.currentUser.rollbackAttributes();
this.notify.error(this.l10n.t('An unexpected error occurred'));
this.notify.error(this.l10n.t('An unexpected error occurred'), {
id: 'bill_det_unexpect'
});
}
this.set('isLoading', false);
});
Expand Down
8 changes: 6 additions & 2 deletions app/components/forms/user-profile-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ export default Component.extend(FormMixin, {
this.set('isLoading', true);
this.user.save()
.then(() => {
this.notify.success(this.l10n.t('Your profile has been updated'));
this.notify.success(this.l10n.t('Your profile has been updated'), {
id: 'profi_update'
});
})
.catch(() => {
this.get('authManager.currentUser').rollbackAttributes();
this.notify.error(this.l10n.t('An unexpected error occurred'));
this.notify.error(this.l10n.t('An unexpected error occurred'), {
id: 'profi_error'
});
})
.finally(() => {
this.set('isLoading', false);
Expand Down
8 changes: 6 additions & 2 deletions app/components/forms/wizard/basic-details-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,18 @@ export default Component.extend(FormMixin, EventWizardMixin, {
}));
})
.catch(error => {
this.notify.error(this.l10n.t(`${error.message}. Please try again`));
this.notify.error(this.l10n.t(`${error.message}. Please try again`), {
id: 'basic_detail_err'
});
});
},
async disconnectStripe() {
let stripeAuthorization = await this.get('data.event.stripeAuthorization');
stripeAuthorization.destroyRecord()
.then(() => {
this.notify.success(this.l10n.t('Stripe disconnected successfully'));
this.notify.success(this.l10n.t('Stripe disconnected successfully'), {
id: 'stripe_disconn'
});
});

},
Expand Down
8 changes: 6 additions & 2 deletions app/components/forms/wizard/sponsors-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export default Component.extend(FormMixin, {
return (!sponsor.get('name'));
});
if (incorrect_sponsors.length > 0) {
this.notify.error(this.l10n.t('Please fill the required fields for existing sponsor items'));
this.notify.error(this.l10n.t('Please fill the required fields for existing sponsor items'), {
id: 'req_field_sponsor'
});
this.set('isLoading', false);
} else {
this.get('data.sponsors').addObject(this.store.createRecord('sponsor'));
Expand All @@ -57,7 +59,9 @@ export default Component.extend(FormMixin, {
return (!sponsor.get('name'));
});
if (incorrect_sponsors.length > 0) {
this.notify.error(this.l10n.t('Please fill the required fields.'));
this.notify.error(this.l10n.t('Please fill the required fields.'), {
id: 'req_field_spon'
});
this.set('isLoading', false);
} else {
this.set('data.event.state', 'draft');
Expand Down
8 changes: 6 additions & 2 deletions app/components/modals/change-image-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ export default ModalBase.extend({
placeholder.save()
.then(() => {
this.set('isOpen', false);
this.notify.success(this.l10n.t('Placeholder has been saved successfully.'));
this.notify.success(this.l10n.t('Placeholder has been saved successfully.'), {
id: 'placeholder_sav'
});
})
.catch(() => {
this.notify.error(this.l10n.t('An unexpected error has occurred. Placeholder not saved.'));
this.notify.error(this.l10n.t('An unexpected error has occurred. Placeholder not saved.'), {
id: 'placeholder_err'
});
});
});
}
Expand Down
8 changes: 6 additions & 2 deletions app/components/notification-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ export default Component.extend({
notification.set('isRead', true);
notification.save()
.then(() => {
this.notify.success(this.l10n.t('Marked as Read successfully'));
this.notify.success(this.l10n.t('Marked as Read successfully'), {
id: 'not_read_succ'
});
})
.catch(() => {
this.notify.error(this.l10n.t('An unexpected error occurred.'));
this.notify.error(this.l10n.t('An unexpected error occurred.'), {
id: 'not_read_error'
});
});
},
markAllRead() {
Expand Down
Loading

0 comments on commit 6a563e2

Please sign in to comment.