diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-11-29 17:03:24 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-12-07 14:36:18 +0100 |
commit | f1976a3f56f03c67ccbf6dca7ee5060b6a21a1da (patch) | |
tree | f8741034e51ae45b37201e90a305ebb3802da7c7 /server/sonar-web/src/main/js/apps/users | |
parent | b117943f3efa541d6c8cd8e62ad157c4f8194211 (diff) | |
download | sonarqube-f1976a3f56f03c67ccbf6dca7ee5060b6a21a1da.tar.gz sonarqube-f1976a3f56f03c67ccbf6dca7ee5060b6a21a1da.zip |
SONAR-8451 Run js app outside of ruby container
Diffstat (limited to 'server/sonar-web/src/main/js/apps/users')
5 files changed, 27 insertions, 11 deletions
diff --git a/server/sonar-web/src/main/js/apps/users/change-password-view.js b/server/sonar-web/src/main/js/apps/users/change-password-view.js index 120703690a1..fb8f29e3c04 100644 --- a/server/sonar-web/src/main/js/apps/users/change-password-view.js +++ b/server/sonar-web/src/main/js/apps/users/change-password-view.js @@ -53,7 +53,7 @@ export default ModalForm.extend({ serializeData () { return Object.assign({}, ModalForm.prototype.serializeData.apply(this, arguments), { - isOwnPassword: window.SS.user === this.model.id + isOwnPassword: this.options.currentUser.login === this.model.id }); } }); diff --git a/server/sonar-web/src/main/js/apps/users/components/UsersAppContainer.js b/server/sonar-web/src/main/js/apps/users/components/UsersAppContainer.js index 8442a308327..8abe6fce357 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UsersAppContainer.js +++ b/server/sonar-web/src/main/js/apps/users/components/UsersAppContainer.js @@ -18,14 +18,26 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import { connect } from 'react-redux'; import init from '../init'; +import { getCurrentUser } from '../../../app/store/rootReducer'; + +class UsersAppContainer extends React.Component { + static propTypes = { + currentUser: React.PropTypes.object.isRequired + }; -export default class UsersAppContainer extends React.Component { componentDidMount () { - init(this.refs.container); + init(this.refs.container, this.props.currentUser); } render () { return <div ref="container"/>; } } + +const mapStateToProps = state => ({ + currentUser: getCurrentUser(state) +}); + +export default connect(mapStateToProps)(UsersAppContainer); diff --git a/server/sonar-web/src/main/js/apps/users/init.js b/server/sonar-web/src/main/js/apps/users/init.js index cd1dc8a6568..490ea231426 100644 --- a/server/sonar-web/src/main/js/apps/users/init.js +++ b/server/sonar-web/src/main/js/apps/users/init.js @@ -29,7 +29,7 @@ import { getIdentityProviders } from '../../api/users'; const App = new Marionette.Application(); -const init = function (el, providers) { +const init = function ({ el, currentUser }, providers) { // Layout this.layout = new Layout({ el }); this.layout.render(); @@ -46,7 +46,7 @@ const init = function (el, providers) { this.layout.searchRegion.show(this.searchView); // List View - this.listView = new ListView({ collection: this.users, providers }); + this.listView = new ListView({ collection: this.users, currentUser, providers }); this.layout.listRegion.show(this.listView); // List Footer View @@ -57,10 +57,10 @@ const init = function (el, providers) { this.users.fetch(); }; -App.on('start', function (el) { - getIdentityProviders().then(r => init.call(App, el, r.identityProviders)); +App.on('start', function (options) { + getIdentityProviders().then(r => init.call(App, options, r.identityProviders)); }); -export default function (el) { - App.start(el); +export default function (el, currentUser) { + App.start({ el, currentUser }); } diff --git a/server/sonar-web/src/main/js/apps/users/list-item-view.js b/server/sonar-web/src/main/js/apps/users/list-item-view.js index f879001e909..7ababc08609 100644 --- a/server/sonar-web/src/main/js/apps/users/list-item-view.js +++ b/server/sonar-web/src/main/js/apps/users/list-item-view.js @@ -109,7 +109,8 @@ export default Marionette.ItemView.extend({ changePassword () { new ChangePasswordView({ model: this.model, - collection: this.model.collection + collection: this.model.collection, + currentUser: this.options.currentUser }).render(); }, diff --git a/server/sonar-web/src/main/js/apps/users/list-view.js b/server/sonar-web/src/main/js/apps/users/list-view.js index 6fb416fc812..3f557d76db8 100644 --- a/server/sonar-web/src/main/js/apps/users/list-view.js +++ b/server/sonar-web/src/main/js/apps/users/list-view.js @@ -33,7 +33,10 @@ export default Marionette.CompositeView.extend({ }, childViewOptions () { - return { providers: this.options.providers }; + return { + providers: this.options.providers, + currentUser: this.options.currentUser + }; }, showLoading () { |