diff options
Diffstat (limited to 'server/sonar-web/src/main/js')
4 files changed, 35 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/js/api/system.js b/server/sonar-web/src/main/js/api/system.js index fab447ccdbd..a1c3ca082ea 100644 --- a/server/sonar-web/src/main/js/api/system.js +++ b/server/sonar-web/src/main/js/api/system.js @@ -1,9 +1,9 @@ -import { getJSON, postJSON } from '../helpers/request'; +import { getJSON, post } from '../helpers/request'; export function setLogLevel (level) { let url = window.baseUrl + '/api/system/change_log_level'; let data = { level }; - return postJSON(url, data); + return post(url, data); } export function getSystemInfo () { diff --git a/server/sonar-web/src/main/js/apps/system/item-log-level.js b/server/sonar-web/src/main/js/apps/system/item-log-level.js index 2f888d7100b..3e924a2781e 100644 --- a/server/sonar-web/src/main/js/apps/system/item-log-level.js +++ b/server/sonar-web/src/main/js/apps/system/item-log-level.js @@ -4,17 +4,31 @@ import { setLogLevel } from '../../api/system'; const LOG_LEVELS = ['INFO', 'DEBUG', 'TRACE']; export default React.createClass({ + getInitialState () { + return { level: this.props.value }; + }, + onChange() { let newValue = React.findDOMNode(this.refs.select).value; - setLogLevel(newValue); + setLogLevel(newValue).then(() => { + this.setState({ level: newValue }); + }); }, render() { let options = LOG_LEVELS.map(level => { return <option key={level} value={level}>{level}</option>; }); - return <select ref="select" - onChange={this.onChange} - defaultValue={this.props.value}>{options}</select>; + let warning = this.state.level !== 'INFO' ? ( + <div className="alert alert-danger spacer-top" style={{ wordBreak: 'normal' }}> + {window.t('system.log_level.warning')} + </div> + ) : null; + return <div> + <select ref="select" + onChange={this.onChange} + value={this.state.level}>{options}</select> + {warning} + </div> } }); diff --git a/server/sonar-web/src/main/js/helpers/request.js b/server/sonar-web/src/main/js/helpers/request.js index 61eff255eaf..86e9b8242e3 100644 --- a/server/sonar-web/src/main/js/helpers/request.js +++ b/server/sonar-web/src/main/js/helpers/request.js @@ -133,3 +133,17 @@ export function postJSON (url, data) { .then(checkStatus) .then(parseJSON); } + + +/** + * Shortcut to do a POST request and return response json + * @param url + * @param data + */ +export function post (url, data) { + return request(url) + .setMethod('POST') + .setData(data) + .submit() + .then(checkStatus); +} diff --git a/server/sonar-web/src/main/js/main/nav/settings/settings-nav.js b/server/sonar-web/src/main/js/main/nav/settings/settings-nav.js index 5f186c494b0..13fae339cda 100644 --- a/server/sonar-web/src/main/js/main/nav/settings/settings-nav.js +++ b/server/sonar-web/src/main/js/main/nav/settings/settings-nav.js @@ -57,8 +57,7 @@ export default React.createClass({ </a> <ul className="dropdown-menu"> {this.renderLink('/updatecenter', window.t('update_center.page'))} - {this.renderLink('/system/index', window.t('system_info.page'))} - {this.renderNewLink('/system/new', window.t('system_info.page'))} + {this.renderLink('/system', window.t('system_info.page'))} </ul> </li> </ul> |