diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fed15274..c95021d7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Bug fixes - Delete schedules with their job [#3108](https://github.com/vatesfr/xen-orchestra/issues/3108) (PR [3124](https://github.com/vatesfr/xen-orchestra/pull/3124)) +- Remote creation: correctly reset form [#3140](https://github.com/vatesfr/xen-orchestra/issues/3140) (PR [3141](https://github.com/vatesfr/xen-orchestra/pull/3141)) ### Released packages diff --git a/packages/xo-web/src/xo-app/settings/remotes/index.js b/packages/xo-web/src/xo-app/settings/remotes/index.js index 46bd9b577..e780aeae7 100644 --- a/packages/xo-web/src/xo-app/settings/remotes/index.js +++ b/packages/xo-web/src/xo-app/settings/remotes/index.js @@ -1,10 +1,11 @@ import _, { messages } from 'intl' import ActionButton from 'action-button' +import Component from 'base-component' import filter from 'lodash/filter' import Icon from 'icon' import isEmpty from 'lodash/isEmpty' import map from 'lodash/map' -import React, { Component } from 'react' +import React from 'react' import some from 'lodash/some' import SortedTable from 'sorted-table' import StateButton from 'state-button' @@ -272,16 +273,18 @@ export default class Remotes extends Component { constructor (props) { super(props) this.state = { + domain: '', + host: '', + name: '', + password: '', + path: '', type: 'nfs', + username: '', } } - _handleRemoteTypeSelection = type => this.setState({ type }) - _checkNameExists = () => - some(this.props.remotes, values => - some(values, ['name', this.refs.name.value]) - ) + some(this.props.remotes, values => some(values, ['name', this.state.name])) ? alert( {_('remoteTestName')} @@ -291,26 +294,29 @@ export default class Remotes extends Component { : this._createRemote() _createRemote = async () => { - const { name, host, path, username, password, domain } = this.refs - const { type } = this.state + const { type, name, host, path, username, password, domain } = this.state const urlParams = { type, - host: host && host.value, - path: path && path.value, + host, + path, } - username && (urlParams.username = username.value) - password && (urlParams.password = password.value) - domain && (urlParams.domain = domain.value) + username && (urlParams.username = username) + password && (urlParams.password = password) + domain && (urlParams.domain = domain) const url = format(urlParams) - return createRemote(name && name.value, url).then( + return createRemote(name, url).then( () => { - this.setState({ type: 'nfs' }) - path && (path.value = '') - username && (username.value = '') - password && (password.value = '') - domain && (domain.value = '') + this.setState({ + domain: '', + host: '', + name: '', + password: '', + path: '', + type: 'nfs', + username: '', + }) }, err => error('Create Remote', err.message || String(err)) ) @@ -318,7 +324,7 @@ export default class Remotes extends Component { render () { const { remotes = {} } = this.props - const { type } = this.state + const { type, name, host, path, username, password, domain } = this.state return (
@@ -371,11 +377,9 @@ export default class Remotes extends Component {
{type === 'file' && ( @@ -403,13 +408,14 @@ export default class Remotes extends Component {
/
@@ -418,25 +424,27 @@ export default class Remotes extends Component {
/
@@ -446,55 +454,60 @@ export default class Remotes extends Component {
\\ \