forked from AkkomaGang/admin-fe
Merge branch 'fix/error-on-account-creation' into 'develop'
Fix displaying multiple errors Closes #159 See merge request pleroma/admin-fe!198
This commit is contained in:
commit
6abb32e3e6
4 changed files with 32 additions and 13 deletions
|
@ -34,7 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Fix wrapping `:icons` setting and parsing tuples in settings with key `:headers`
|
||||
- Update keys for Pleroma.Web.Plugs.RemoteIp and PurgeExpiredActivity settings
|
||||
- Update switching between local and remote emoji packs panels: the panel with the pack's metadata will be closed when another panel is opened
|
||||
|
||||
- Fix displaying messages for multiple errors
|
||||
## [2.2] - 2020-11-18
|
||||
|
||||
### Added
|
||||
|
|
|
@ -3,6 +3,19 @@ import Router from 'vue-router'
|
|||
|
||||
Vue.use(Router)
|
||||
|
||||
const originalPush = Router.prototype.push
|
||||
Router.prototype.push = function push(location, onResolve, onReject) {
|
||||
if (onResolve || onReject) { return originalPush.call(this, location, onResolve, onReject) }
|
||||
return originalPush.call(this, location).catch((err) => {
|
||||
if (Router.isNavigationFailure(err)) {
|
||||
// resolve err
|
||||
return err
|
||||
}
|
||||
// rethrow error
|
||||
return Promise.reject(err)
|
||||
})
|
||||
}
|
||||
|
||||
/* Layout */
|
||||
import Layout from '@/views/layout/Layout'
|
||||
|
||||
|
|
|
@ -6,27 +6,32 @@ const service = axios.create({
|
|||
timeout: 60000 // request timeout
|
||||
})
|
||||
|
||||
const isJson = ({ headers }) => headers['content-type'].includes('application/json')
|
||||
|
||||
// response interceptor
|
||||
service.interceptors.response.use(
|
||||
response => response,
|
||||
error => {
|
||||
let errorMessage
|
||||
console.log(`Error ${error}`)
|
||||
|
||||
if (error.response) {
|
||||
const edata = error.response.data.error ? error.response.data.error : error.response.data
|
||||
errorMessage = !error.response.headers['content-type'].includes('application/json')
|
||||
? `${error.message}`
|
||||
: `${error.message} - ${edata}`
|
||||
if (!error.response) {
|
||||
Message({
|
||||
message: error,
|
||||
type: 'error',
|
||||
duration: 5 * 1000
|
||||
})
|
||||
} else {
|
||||
errorMessage = error
|
||||
const errors = Array.isArray(error.response.data) ? error.response.data : [error.response.data]
|
||||
errors.forEach(errorData => {
|
||||
const edata = errorData.error || errorData
|
||||
Message({
|
||||
message: isJson(error.response) ? `${error.message} - ${edata}` : `${error.message}`,
|
||||
type: 'error',
|
||||
duration: 5 * 1000
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Message({
|
||||
message: errorMessage,
|
||||
type: 'error',
|
||||
duration: 5 * 1000
|
||||
})
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
|
|
@ -16,6 +16,7 @@ localVue.use(VueRouter)
|
|||
localVue.use(Element)
|
||||
|
||||
jest.mock('@/api/reports')
|
||||
jest.mock('@/api/settings')
|
||||
|
||||
describe('Log out', () => {
|
||||
let store
|
||||
|
|
Loading…
Reference in a new issue