RIFT-14432: Composer choice/case fix
[osm/UI.git] / skyquake / plugins / logging / src / categorySeverityGrid.jsx
1  /*
2  * 
3  *   Copyright 2016 RIFT.IO Inc
4  *
5  *   Licensed under the Apache License, Version 2.0 (the "License");
6  *   you may not use this file except in compliance with the License.
7  *   You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *   Unless required by applicable law or agreed to in writing, software
12  *   distributed under the License is distributed on an "AS IS" BASIS,
13  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *   See the License for the specific language governing permissions and
15  *   limitations under the License.
16  *
17  */
18 import React from 'react';
19
20 import {DropList, RadioButtonGroup, CardSection } from './loggingWidgets.jsx';
21 import { Grid } from './gridWidgets.jsx';
22 import LoggingStore from './loggingStore.js';
23
24
25 export default class CategorySeverityGrid extends React.Component {
26
27   generateRows(defaultSeverities, severityOptions) {
28     let self = this;
29     return defaultSeverities.map(function(catsev) {
30       let dropList = (<DropList options={severityOptions}
31         selectedOption={catsev.severity}
32         onChange={self.onChangeSeverity(catsev.category)} />);
33       return [catsev.category, dropList];
34     });
35   }
36
37   onChangeSeverity (category) {
38     return function(e) {
39       LoggingStore.updateCategoryDefaultSeverity({
40         category: category,
41         severity: e
42       });
43     }
44   }
45
46   render() {
47     const {cellLabels, severityOptions, defaultSeverities, columnClasses,
48        ...props} = this.props;
49     let rows = null;
50     if (defaultSeverities) {
51       rows = this.generateRows(defaultSeverities, severityOptions);
52     }
53     return (<Grid className="categorySeverityGrid"
54       cellLabels={cellLabels}
55       rows={rows}
56       columnClasses={columnClasses}
57       />);
58   }
59 }
60
61 CategorySeverityGrid.defaultProps = {
62   cellLabels: [
63     'Category', 'Severity'
64   ],
65   columnClasses: [
66     'category', 'severity'
67   ]
68 }