diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-11-06 14:18:22 +0100 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-11-24 17:22:33 +0100 |
commit | 1fccf4779bbf4d1c125fd65ed3972b57b3c1be6e (patch) | |
tree | 95747a368747f6287e966ebd563f5c814575e4a6 /server/sonar-web/src/main/js/apps/users/Header.tsx | |
parent | 51c76205777a9a05783c781bad8c66e3eadef163 (diff) | |
download | sonarqube-1fccf4779bbf4d1c125fd65ed3972b57b3c1be6e.tar.gz sonarqube-1fccf4779bbf4d1c125fd65ed3972b57b3c1be6e.zip |
Rewrite users page to TS and React
Diffstat (limited to 'server/sonar-web/src/main/js/apps/users/Header.tsx')
-rw-r--r-- | server/sonar-web/src/main/js/apps/users/Header.tsx | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/users/Header.tsx b/server/sonar-web/src/main/js/apps/users/Header.tsx new file mode 100644 index 00000000000..60eeb835f18 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/users/Header.tsx @@ -0,0 +1,59 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as React from 'react'; +import UserForm from './components/UserForm'; +import DeferredSpinner from '../../components/common/DeferredSpinner'; +import { translate } from '../../helpers/l10n'; + +interface Props { + loading: boolean; + onUpdateUsers: () => void; +} + +interface State { + openUserForm: boolean; +} + +export default class Header extends React.PureComponent<Props, State> { + state: State = { openUserForm: false }; + + handleOpenUserForm = () => this.setState({ openUserForm: true }); + handleCloseUserForm = () => this.setState({ openUserForm: false }); + + render() { + return ( + <header id="users-header" className="page-header"> + <h1 className="page-title">{translate('users.page')}</h1> + <DeferredSpinner loading={this.props.loading} /> + + <div className="page-actions"> + <button id="users-create" onClick={this.handleOpenUserForm}> + {translate('users.create_user')} + </button> + </div> + + <p className="page-description">{translate('users.page.description')}</p> + {this.state.openUserForm && ( + <UserForm onClose={this.handleCloseUserForm} onUpdateUsers={this.props.onUpdateUsers} /> + )} + </header> + ); + } +} |