Commit c352e7e1 authored by Fatih Acet's avatar Fatih Acet

Some cleanup and improvements on frontent logic

parent 992fcf6c
<script> <script>
import Visibility from 'visibilityjs'; import Visibility from 'visibilityjs';
import { s__, sprintf } from '~/locale';
import { visitUrl } from '../../lib/utils/url_utility'; import { visitUrl } from '../../lib/utils/url_utility';
import Poll from '../../lib/utils/poll'; import Poll from '../../lib/utils/poll';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -166,6 +167,9 @@ export default { ...@@ -166,6 +167,9 @@ export default {
const titleChanged = this.initialTitleText !== this.store.formState.title; const titleChanged = this.initialTitleText !== this.store.formState.title;
return descriptionChanged || titleChanged; return descriptionChanged || titleChanged;
}, },
defaultErrorMessage() {
return sprintf(s__('Error updating %{issuableType}.'), { issuableType: this.issuableType });
},
}, },
created() { created() {
this.service = new Service(this.endpoint); this.service = new Service(this.endpoint);
...@@ -220,9 +224,7 @@ export default { ...@@ -220,9 +224,7 @@ export default {
this.store.updateState(data); this.store.updateState(data);
}) })
.catch(() => { .catch(() => {
const errMsg = `Error updating ${this.issuableType}`; window.Flash(this.defaultErrorMessage);
window.Flash(errMsg);
}); });
}, },
...@@ -260,10 +262,10 @@ export default { ...@@ -260,10 +262,10 @@ export default {
if (error && error.name === 'SpamError') { if (error && error.name === 'SpamError') {
this.openRecaptcha(); this.openRecaptcha();
} else { } else {
let errMsg = `Error updating ${this.issuableType}`; let errMsg = this.defaultErrorMessage;
if (error && error.response && error.response.data && error.response.data.errors) { if (error && error.response && error.response.data && error.response.data.errors) {
errMsg = error.response.data.errors; errMsg += error.response.data.errors.join(' ');
} }
eventHub.$emit('close.form'); eventHub.$emit('close.form');
......
...@@ -93,7 +93,7 @@ export default { ...@@ -93,7 +93,7 @@ export default {
taskListUpdateError() { taskListUpdateError() {
window.Flash( window.Flash(
__( __(
'Someone edited this issue at the same time you did and we updated the issue description.', 'Someone edited this issue at the same time you did. The description has been updated and you will need to make your changes again.',
), ),
); );
......
...@@ -3040,6 +3040,9 @@ msgstr "" ...@@ -3040,6 +3040,9 @@ msgstr ""
msgid "Error saving label update." msgid "Error saving label update."
msgstr "" msgstr ""
msgid "Error updating %{issuableType}"
msgstr ""
msgid "Error updating status for all todos." msgid "Error updating status for all todos."
msgstr "" msgstr ""
...@@ -6527,7 +6530,7 @@ msgstr "" ...@@ -6527,7 +6530,7 @@ msgstr ""
msgid "Snippets" msgid "Snippets"
msgstr "" msgstr ""
msgid "Someone edited this issue at the same time you did and we updated the issue description." msgid "Someone edited this issue at the same time you did. The description has been updated and you will need to make your changes again."
msgstr "" msgstr ""
msgid "Something went wrong on our end" msgid "Something went wrong on our end"
......
...@@ -191,7 +191,7 @@ describe('Description component', () => { ...@@ -191,7 +191,7 @@ describe('Description component', () => {
describe('taskListUpdateError', () => { describe('taskListUpdateError', () => {
it('should create flash notification and emit an event to parent', () => { it('should create flash notification and emit an event to parent', () => {
const msg = const msg =
'Someone edited this issue at the same time you did and we updated the issue description.'; 'Someone edited this issue at the same time you did. The description has been updated and you will need to make your changes again.';
spyOn(window, 'Flash'); spyOn(window, 'Flash');
spyOn(vm, '$emit'); spyOn(vm, '$emit');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment