Some cleanup and improvements on frontent logic
This commit is contained in:
		
							parent
							
								
									992fcf6c87
								
							
						
					
					
						commit
						c352e7e162
					
				| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
<script>
 | 
			
		||||
import Visibility from 'visibilityjs';
 | 
			
		||||
import { s__, sprintf } from '~/locale';
 | 
			
		||||
import { visitUrl } from '../../lib/utils/url_utility';
 | 
			
		||||
import Poll from '../../lib/utils/poll';
 | 
			
		||||
import eventHub from '../event_hub';
 | 
			
		||||
| 
						 | 
				
			
			@ -166,6 +167,9 @@ export default {
 | 
			
		|||
      const titleChanged = this.initialTitleText !== this.store.formState.title;
 | 
			
		||||
      return descriptionChanged || titleChanged;
 | 
			
		||||
    },
 | 
			
		||||
    defaultErrorMessage() {
 | 
			
		||||
      return sprintf(s__('Error updating  %{issuableType}.'), { issuableType: this.issuableType });
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    this.service = new Service(this.endpoint);
 | 
			
		||||
| 
						 | 
				
			
			@ -220,9 +224,7 @@ export default {
 | 
			
		|||
          this.store.updateState(data);
 | 
			
		||||
        })
 | 
			
		||||
        .catch(() => {
 | 
			
		||||
          const errMsg = `Error updating ${this.issuableType}`;
 | 
			
		||||
 | 
			
		||||
          window.Flash(errMsg);
 | 
			
		||||
          window.Flash(this.defaultErrorMessage);
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -260,10 +262,10 @@ export default {
 | 
			
		|||
          if (error && error.name === 'SpamError') {
 | 
			
		||||
            this.openRecaptcha();
 | 
			
		||||
          } else {
 | 
			
		||||
            let errMsg = `Error updating ${this.issuableType}`;
 | 
			
		||||
            let errMsg = this.defaultErrorMessage;
 | 
			
		||||
 | 
			
		||||
            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');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,7 +93,7 @@ export default {
 | 
			
		|||
    taskListUpdateError() {
 | 
			
		||||
      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 ""
 | 
			
		|||
msgid "Error saving label update."
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
msgid "Error updating  %{issuableType}"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
msgid "Error updating status for all todos."
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -6527,7 +6530,7 @@ msgstr ""
 | 
			
		|||
msgid "Snippets"
 | 
			
		||||
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 ""
 | 
			
		||||
 | 
			
		||||
msgid "Something went wrong on our end"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -191,7 +191,7 @@ describe('Description component', () => {
 | 
			
		|||
  describe('taskListUpdateError', () => {
 | 
			
		||||
    it('should create flash notification and emit an event to parent', () => {
 | 
			
		||||
      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(vm, '$emit');
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue