Skip to content

Fix display of ParseFile in Config #666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/FileInput/FileInput.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class FileInput extends React.Component {
render() {
let inputProps = {
type: 'file',
value: null,
value: '',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generating a warning with files

disabled: this.props.disabled,
onChange: this.handleChange.bind(this),
};
Expand All @@ -55,7 +55,7 @@ export default class FileInput extends React.Component {
if (label) {
buttonStyles.push(styles.withLabel)
}

return (
<div className={styles.input}>
<div className={buttonStyles.join(' ')}>
Expand Down
25 changes: 21 additions & 4 deletions src/dashboard/Data/Config/Config.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class Config extends TableView {
let value = data.value;
let modalValue = value;
let type = typeof value;

if (type === 'object') {
if (isDate(value)) {
type = 'Date';
Expand All @@ -84,9 +85,9 @@ class Config extends TableView {
type = 'GeoPoint';
value = `(${value.latitude}, ${value.longitude})`;
modalValue = data.value.toJSON();
} else if (value instanceof Parse.File) {
} else if (data.value instanceof Parse.File) {
type = 'File';
value = <a target='_blank' href={value.url()}>Open in new window</a>;
value = <a target='_blank' href={data.value.url()}>Open in new window</a>;
} else {
type = 'Object';
value = JSON.stringify(value);
Expand All @@ -105,11 +106,19 @@ class Config extends TableView {
modalValue: modalValue
});
let columnStyle = { width: '30%', cursor: 'pointer' };

let openModalValueColumn = () => {
if (data.value instanceof Parse.File) {
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert that :)

}
openModal()
}

return (
<tr key={data.param}>
<td style={columnStyle} onClick={openModal}>{data.param}</td>
<td style={columnStyle} onClick={openModal}>{type}</td>
<td style={columnStyle} onClick={openModal}>{value}</td>
<td style={columnStyle} onClick={openModalValueColumn}>{value}</td>
<td style={{ textAlign: 'center' }}>
<a onClick={this.deleteParam.bind(this, data.param)}>
<Icon width={16} height={16} name='trash-solid' fill='#ff395e' />
Expand Down Expand Up @@ -145,7 +154,15 @@ class Config extends TableView {
if (params) {
data = [];
params.forEach((value, param) => {
data.push({ param, value });
let type = typeof value;
if (type === 'object' && value.__type == 'File') {
value = Parse.File.fromJSON(value);
}
else if (type === 'object' && value.__type == 'GeoPoint') {
value = new Parse.GeoPoint(value);
}

data.push({ param: param, value: value })
});
}
}
Expand Down