webpack/scenes/RedHatRepositories/components/RepositorySetRepository/RepositorySetRepository.js in katello-3.13.4 vs webpack/scenes/RedHatRepositories/components/RepositorySetRepository/RepositorySetRepository.js in katello-3.14.0.rc1

- old
+ new

@@ -8,59 +8,58 @@ import '../../index.scss'; class RepositorySetRepository extends Component { constructor(props) { super(props); - this.state = {}; + } - this.repoForAction = () => { - const { - productId, contentId, arch, displayArch, releasever, label, - } = this.props; + setEnabled = () => { + this.props.setRepositoryEnabled(this.repoForAction()); + }; - const derivedArch = arch || displayArch; - return { - arch: derivedArch, - productId, - contentId, - releasever, - label, - }; - }; + repoForAction = () => { + const { + productId, contentId, arch, displayArch, releasever, label, + } = this.props; - this.setEnabled = () => { - this.props.setRepositoryEnabled(this.repoForAction()); + const derivedArch = arch || displayArch; + return { + arch: derivedArch, + productId, + contentId, + releasever, + label, }; + }; - this.reloadEnabledRepos = () => ( - this.props.loadEnabledRepos({ - ...this.props.enabledPagination, - search: this.props.enabledSearch, - }, true) - ); + reloadEnabledRepos = () => ( + this.props.loadEnabledRepos({ + ...this.props.enabledPagination, + search: this.props.enabledSearch, + }, true) + ); - this.notifyEnabled = (data) => { - const repoName = data.output.repository.name; - window.tfm.toastNotifications.notify({ - message: sprintf(__("Repository '%(repoName)s' has been enabled."), { repoName }), - type: 'success', - }); - }; + notifyEnabled = (data) => { + const repoName = data.output.repository.name; + window.tfm.toastNotifications.notify({ + message: sprintf(__("Repository '%(repoName)s' has been enabled."), { repoName }), + type: 'success', + }); + }; - this.reloadAndNotify = (result) => { - if (result.success) { - this.reloadEnabledRepos() - .then(this.setEnabled) - .then(() => this.notifyEnabled(result.data)); - } - }; + reloadAndNotify = async (result) => { + if (result.success) { + await this.reloadEnabledRepos(); + await this.setEnabled(); + await this.notifyEnabled(result.data); + } + }; - this.enableRepository = () => { - this.props.enableRepository(this.repoForAction()) - .then(this.reloadAndNotify); - }; - } + enableRepository = async () => { + await this.props.enableRepository(this.repoForAction()); + this.reloadAndNotify(); + }; render() { const { displayArch, releasever, type } = this.props; const archLabel = displayArch || __('Unspecified');