forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Schema Improvements Part 2: Add data source config options.
- Loading branch information
Marina Samuel
committed
May 6, 2019
1 parent
7108af7
commit 567d6ce
Showing
17 changed files
with
511 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,10 @@ body { | |
} | ||
} | ||
|
||
.admin-schema-editor { | ||
padding: 50px 0; | ||
} | ||
|
||
.creation-container { | ||
h5 { | ||
color: #a7a7a7; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
client/app/pages/data-sources/schema-table-components/EditableTable.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import React from 'react'; | ||
import Form from 'antd/lib/form'; | ||
import Input from 'antd/lib/input'; | ||
import PropTypes from 'prop-types'; | ||
import { TableMetadata } from '@/components/proptypes'; | ||
import TableVisibilityCheckbox from './TableVisibilityCheckbox'; | ||
import './schema-table.css'; | ||
|
||
const FormItem = Form.Item; | ||
const { TextArea } = Input; | ||
export const EditableContext = React.createContext(); | ||
|
||
// eslint-disable-next-line react/prop-types | ||
const EditableRow = ({ form, index, ...props }) => ( | ||
<EditableContext.Provider value={form}> | ||
<tr {...props} /> | ||
</EditableContext.Provider> | ||
); | ||
|
||
export const EditableFormRow = Form.create()(EditableRow); | ||
|
||
export class EditableCell extends React.Component { | ||
static propTypes = { | ||
dataIndex: PropTypes.string, | ||
input_type: PropTypes.string, | ||
editing: PropTypes.bool, | ||
record: TableMetadata, | ||
}; | ||
|
||
static defaultProps = { | ||
dataIndex: undefined, | ||
input_type: undefined, | ||
editing: false, | ||
record: {}, | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
visible: this.props.record ? this.props.record.visible : false, | ||
}; | ||
} | ||
|
||
onChange = () => { | ||
this.setState({ visible: !this.state.visible }); | ||
} | ||
|
||
getInput = () => { | ||
if (this.props.input_type === 'visible') { | ||
return ( | ||
<TableVisibilityCheckbox | ||
visible={this.state.visible} | ||
onChange={this.onChange} | ||
/>); | ||
} | ||
return <TextArea className="table-textarea" placeholder="Enter table description..." style={{ resize: 'vertical' }} />; | ||
}; | ||
|
||
render() { | ||
const { | ||
editing, | ||
dataIndex, | ||
record, | ||
...restProps | ||
} = this.props; | ||
|
||
return ( | ||
<EditableContext.Consumer> | ||
{(form) => { | ||
const { getFieldDecorator } = form; | ||
return ( | ||
<td {...restProps}> | ||
{editing ? ( | ||
<FormItem style={{ margin: 0 }}> | ||
{getFieldDecorator(dataIndex, { | ||
initialValue: record[dataIndex], | ||
})(this.getInput()) } | ||
</FormItem> | ||
) : restProps.children} | ||
</td> | ||
); | ||
}} | ||
</EditableContext.Consumer> | ||
); | ||
} | ||
} |
Oops, something went wrong.