mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 10:56:10 +01:00 
			
		
		
		
	Handle invalid issues (#18111)
* Handle invalid issues - When you hover over a issue reference, and the issue doesn't exist, it will just hang on the loading animation. - This patch fixes that by showing them the pop-up with a "Error occured" message. * Add I18N * refactor * fix comment for lint * fix unit test for i18n * fix unit test for i18n * add comments Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -16,13 +16,17 @@ | ||||
|         </div> | ||||
|       </div> | ||||
|     </div> | ||||
|     <div v-if="!loading && issue === null"> | ||||
|       <p><small>{{ i18nErrorOccurred }}</small></p> | ||||
|       <p>{{ i18nErrorMessage }}</p> | ||||
|     </div> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import {SvgIcon} from '../svg.js'; | ||||
|  | ||||
| const {appSubUrl} = window.config; | ||||
| const {appSubUrl, i18n} = window.config; | ||||
|  | ||||
| // NOTE: see models/issue_label.go for similar implementation | ||||
| const srgbToLinear = (color) => { | ||||
| @@ -49,7 +53,9 @@ export default { | ||||
|  | ||||
|   data: () => ({ | ||||
|     loading: false, | ||||
|     issue: null | ||||
|     issue: null, | ||||
|     i18nErrorOccurred: i18n.error_occurred, | ||||
|     i18nErrorMessage: null, | ||||
|   }), | ||||
|  | ||||
|   computed: { | ||||
| @@ -112,14 +118,20 @@ export default { | ||||
|   methods: { | ||||
|     load(data, callback) { | ||||
|       this.loading = true; | ||||
|       $.get(`${appSubUrl}/api/v1/repos/${data.owner}/${data.repo}/issues/${data.index}`, (issue) => { | ||||
|       this.i18nErrorMessage = null; | ||||
|       $.get(`${appSubUrl}/api/v1/repos/${data.owner}/${data.repo}/issues/${data.index}`).done((issue) => { | ||||
|         this.issue = issue; | ||||
|       }).fail((jqXHR) => { | ||||
|         if (jqXHR.responseJSON && jqXHR.responseJSON.message) { | ||||
|           this.i18nErrorMessage = jqXHR.responseJSON.message; | ||||
|         } else { | ||||
|           this.i18nErrorMessage = i18n.network_error; | ||||
|         } | ||||
|       }).always(() => { | ||||
|         this.loading = false; | ||||
|         this.$nextTick(() => { | ||||
|           if (callback) { | ||||
|             callback(); | ||||
|           } | ||||
|         }); | ||||
|         if (callback) { | ||||
|           this.$nextTick(callback); | ||||
|         } | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user