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:
parent
31314d201b
commit
fdde916388
@ -1204,6 +1204,7 @@ export const importVm = (file, type = 'xva', data = undefined, sr) => {
|
||||
throw res.status
|
||||
}
|
||||
success(_('vmImportSuccess'), name)
|
||||
return res.json().then(body => body.result)
|
||||
})
|
||||
.catch(() => {
|
||||
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 {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -397,7 +401,7 @@ export default class Import extends Component {
|
||||
form='import-form'
|
||||
handler={this._import}
|
||||
icon='import'
|
||||
redirectOnSuccess='/'
|
||||
redirectOnSuccess={getRedirectionUrl}
|
||||
type='submit'
|
||||
>
|
||||
{_('newImport')}
|
||||
|
Loading…
Reference in New Issue
Block a user