feat(xo-web/vms-import): redirect to VM or home page (#2942)
If a single VM has been imported, redirect to its page. If multiple VMs has been imported, redirect to the homepage with all other VMs filtered out.
This commit is contained in:
committed by
Julien Fontanet
parent
31314d201b
commit
fdde916388
@@ -1204,6 +1204,7 @@ export const importVm = (file, type = 'xva', data = undefined, sr) => {
|
|||||||
throw res.status
|
throw res.status
|
||||||
}
|
}
|
||||||
success(_('vmImportSuccess'), name)
|
success(_('vmImportSuccess'), name)
|
||||||
|
return res.json().then(body => body.result)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
error(_('vmImportFailed'), name)
|
error(_('vmImportFailed'), name)
|
||||||
|
|||||||
@@ -235,6 +235,10 @@ const parseFile = async (file, type, func) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getRedirectionUrl = vms => vms.length === 1
|
||||||
|
? `/vms/${vms[0]}`
|
||||||
|
: `/home?s=${encodeURIComponent(`id:|(${vms.join(' ')})`)}&t=VM`
|
||||||
|
|
||||||
export default class Import extends Component {
|
export default class Import extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
@@ -397,7 +401,7 @@ export default class Import extends Component {
|
|||||||
form='import-form'
|
form='import-form'
|
||||||
handler={this._import}
|
handler={this._import}
|
||||||
icon='import'
|
icon='import'
|
||||||
redirectOnSuccess='/'
|
redirectOnSuccess={getRedirectionUrl}
|
||||||
type='submit'
|
type='submit'
|
||||||
>
|
>
|
||||||
{_('newImport')}
|
{_('newImport')}
|
||||||
|
|||||||
Reference in New Issue
Block a user