Tackling late-arriving comments from #5186 (#5626)

This commit is contained in:
Maxime Beauchemin 2018-08-14 16:30:50 -07:00 committed by GitHub
parent be04c98cd3
commit d601ff4747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 13 deletions

View File

@ -8,11 +8,10 @@ import { recurseReactClone } from './utils';
import './styles.css'; import './styles.css';
const propTypes = { const propTypes = {
collection: PropTypes.array, collection: PropTypes.arrayOf(PropTypes.object).isRequired,
itemGenerator: PropTypes.func, itemGenerator: PropTypes.func,
columnLabels: PropTypes.object, columnLabels: PropTypes.object,
tableColumns: PropTypes.array, tableColumns: PropTypes.array.isRequired,
columns: PropTypes.array,
onChange: PropTypes.func, onChange: PropTypes.func,
itemRenderers: PropTypes.object, itemRenderers: PropTypes.object,
allowDeletes: PropTypes.bool, allowDeletes: PropTypes.bool,
@ -29,6 +28,8 @@ const defaultProps = {
emptyMessage: 'No entries', emptyMessage: 'No entries',
allowAddItem: false, allowAddItem: false,
itemGenerator: () => ({}), itemGenerator: () => ({}),
expandFieldset: null,
extraButtons: null,
}; };
const Frame = props => ( const Frame = props => (
<div className="frame"> <div className="frame">
@ -100,6 +101,7 @@ export default class CRUDCollection extends React.PureComponent {
const { columnLabels } = this.props; const { columnLabels } = this.props;
let label = columnLabels[col] ? columnLabels[col] : col; let label = columnLabels[col] ? columnLabels[col] : col;
if (label.startsWith('__')) { if (label.startsWith('__')) {
// special label-free columns (ie: caret for expand, delete cross)
label = ''; label = '';
} }
return label; return label;

View File

@ -7,8 +7,8 @@ import {
import './styles.less'; import './styles.less';
const propTypes = { const propTypes = {
value: PropTypes.any, value: PropTypes.any.isRequired,
label: PropTypes.string, label: PropTypes.string.isRequired,
descr: PropTypes.node, descr: PropTypes.node,
fieldKey: PropTypes.string.isRequired, fieldKey: PropTypes.string.isRequired,
control: PropTypes.node.isRequired, control: PropTypes.node.isRequired,
@ -19,6 +19,7 @@ const defaultProps = {
controlProps: {}, controlProps: {},
onChange: () => {}, onChange: () => {},
compact: false, compact: false,
desc: null,
}; };
export default class Field extends React.PureComponent { export default class Field extends React.PureComponent {

View File

@ -6,14 +6,15 @@ import { recurseReactClone } from './utils';
import Field from './Field'; import Field from './Field';
const propTypes = { const propTypes = {
children: PropTypes.node, children: PropTypes.node.isRequired,
onChange: PropTypes.func, onChange: PropTypes.func.isRequired,
item: PropTypes.object, item: PropTypes.object.isRequired,
title: PropTypes.node, title: PropTypes.node,
compact: PropTypes.bool, compact: PropTypes.bool,
}; };
const defaultProps = { const defaultProps = {
compact: false, compact: false,
title: null,
}; };
export default class Fieldset extends React.PureComponent { export default class Fieldset extends React.PureComponent {

View File

@ -19,6 +19,7 @@ const defaultProps = {
showTooltip: true, showTooltip: true,
onSaveTitle: () => {}, onSaveTitle: () => {},
emptyText: '<empty>', emptyText: '<empty>',
style: null,
}; };
export default class EditableTitle extends React.PureComponent { export default class EditableTitle extends React.PureComponent {

View File

@ -2,16 +2,16 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Alert, Button, Modal } from 'react-bootstrap'; import { Alert, Button, Modal } from 'react-bootstrap';
import Dialog from 'react-bootstrap-dialog'; import Dialog from 'react-bootstrap-dialog';
import $ from 'jquery';
import { t } from '../locales'; import { t } from '../locales';
import DatasourceEditor from '../datasource/DatasourceEditor'; import DatasourceEditor from '../datasource/DatasourceEditor';
import withToasts from '../messageToasts/enhancers/withToasts'; import withToasts from '../messageToasts/enhancers/withToasts';
const $ = window.$ = require('jquery');
const propTypes = { const propTypes = {
onChange: PropTypes.func, onChange: PropTypes.func,
datasource: PropTypes.object, datasource: PropTypes.object.isRequired,
show: PropTypes.bool.isRequired, show: PropTypes.bool.isRequired,
onHide: PropTypes.func, onHide: PropTypes.func,
onDatasourceSave: PropTypes.func, onDatasourceSave: PropTypes.func,
@ -22,6 +22,7 @@ const defaultProps = {
onChange: () => {}, onChange: () => {},
onHide: () => {}, onHide: () => {},
onDatasourceSave: () => {}, onDatasourceSave: () => {},
show: false,
}; };
class DatasourceModal extends React.PureComponent { class DatasourceModal extends React.PureComponent {
@ -41,6 +42,7 @@ class DatasourceModal extends React.PureComponent {
this.onDatasourceChange = this.onDatasourceChange.bind(this); this.onDatasourceChange = this.onDatasourceChange.bind(this);
this.onClickSave = this.onClickSave.bind(this); this.onClickSave = this.onClickSave.bind(this);
this.onConfirmSave = this.onConfirmSave.bind(this); this.onConfirmSave = this.onConfirmSave.bind(this);
this.setDialogRef = this.setDialogRef.bind(this);
} }
onClickSave() { onClickSave() {
this.dialog.show({ this.dialog.show({
@ -90,6 +92,9 @@ class DatasourceModal extends React.PureComponent {
setSearchRef(searchRef) { setSearchRef(searchRef) {
this.searchRef = searchRef; this.searchRef = searchRef;
} }
setDialogRef(ref) {
this.dialog = ref;
}
toggleShowDatasource() { toggleShowDatasource() {
this.setState({ showDatasource: !this.state.showDatasource }); this.setState({ showDatasource: !this.state.showDatasource });
} }
@ -149,7 +154,7 @@ class DatasourceModal extends React.PureComponent {
{t('Save')} {t('Save')}
</Button> </Button>
<Button bsSize="sm" onClick={this.props.onHide}>{t('Cancel')}</Button> <Button bsSize="sm" onClick={this.props.onHide}>{t('Cancel')}</Button>
<Dialog ref={(el) => { this.dialog = el; }} /> <Dialog ref={this.setDialogRef} />
</span> </span>
</Modal.Footer> </Modal.Footer>
</Modal>); </Modal>);

View File

@ -4,10 +4,8 @@ import ControlHeader from '../ControlHeader';
import Checkbox from '../../../components/Checkbox'; import Checkbox from '../../../components/Checkbox';
const propTypes = { const propTypes = {
name: PropTypes.string,
value: PropTypes.bool, value: PropTypes.bool,
label: PropTypes.string, label: PropTypes.string,
description: PropTypes.string,
onChange: PropTypes.func, onChange: PropTypes.func,
}; };