Skip to content

Improve cell value copying of pointer cell #1708

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 24 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d340c1b
showing tooltip on mouse enter & leave
sadakchap May 15, 2021
2d9d7a4
Merge branch 'master' of github.com:parse-community/parse-dashboard i…
sadakchap May 31, 2021
22a56bf
added new arrow svg
sadakchap May 31, 2021
ec3950d
showing arrow icon if cell has follow link value
sadakchap May 31, 2021
d792e34
Pill pointer, relation to follow link if selected
sadakchap May 31, 2021
e981e55
added bottom margin for Pill
sadakchap May 31, 2021
1c40561
following link even if cell is not selected on icon click
sadakchap May 31, 2021
f6c68f4
using existing arrow icon
sadakchap May 31, 2021
5bce427
removed arrow.svg file
sadakchap May 31, 2021
6edfa69
remove arrow outline
sadakchap May 31, 2021
5a60b83
removed Download & delete option from file Editor
sadakchap Jun 1, 2021
34c7b93
update Pill to download image on icon click
sadakchap Jun 1, 2021
d8b855c
update Browser cell file value
sadakchap Jun 1, 2021
ad6eba6
opening upload dialog on double click
sadakchap Jun 3, 2021
68b4462
File Editor on Edit Row dialog
sadakchap Jun 4, 2021
53bffcf
pill design update
sadakchap Jun 4, 2021
3b5d190
removing extra padding from pill
sadakchap Jun 7, 2021
6dd4df7
showing new pointer layout on Edit row dialog
sadakchap Jun 7, 2021
4e363e7
making input fields light blue
sadakchap Jul 27, 2021
b24aea3
added margin in new pill design
sadakchap Jul 27, 2021
7115f41
added undefined placeholder for edit row modal
sadakchap Jul 27, 2021
79eee26
center toggle Input
sadakchap Jul 27, 2021
16010c7
removed ccss comment
sadakchap Jul 28, 2021
c6429bc
Merge branch 'master' of github.com:parse-community/parse-dashboard i…
sadakchap Jul 28, 2021
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
18 changes: 10 additions & 8 deletions src/components/BrowserCell/BrowserCell.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,14 @@ export default class BrowserCell extends Component {
value = object;
}
content = onPointerClick ? (
<a href='javascript:;' onClick={onPointerClick.bind(undefined, value)}>
<Pill value={value.id} />
</a>
<Pill
value={value.id}
onClick={onPointerClick.bind(undefined, value)}
followClick={true}
/>
) : (
value.id
);
value.id
);
this.copyableValue = value.id;
}
else if (type === 'Array') {
Expand Down Expand Up @@ -289,7 +291,7 @@ export default class BrowserCell extends Component {
this.copyableValue = content = JSON.stringify(value);
} else if (type === 'File') {
const fileName = value.url() ? getFileName(value) : 'Uploading\u2026';
content = <Pill value={fileName} />;
content = <Pill value={fileName} fileDownloadLink={value.url()} />;
this.copyableValue = fileName;
} else if (type === 'ACL') {
let pieces = [];
Expand Down Expand Up @@ -318,8 +320,8 @@ export default class BrowserCell extends Component {
this.copyableValue = content = value.coordinates.map(coord => `(${coord})`)
} else if (type === 'Relation') {
content = setRelation ? (
<div style={{ textAlign: 'center', cursor: 'pointer' }}>
<Pill onClick={() => setRelation(value)} value='View relation' />
<div style={{ textAlign: 'center' }}>
<Pill onClick={() => setRelation(value)} value='View relation' followClick={true} />
</div>
) : (
'Relation'
Expand Down
11 changes: 4 additions & 7 deletions src/components/Field/Field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
min-height: 80px;
text-align: right;
padding: 0;
background: #f6fafb;
display: flex;
justify-content: center;
align-items: center;
}

.input {
margin: 25px 20px 0 0;
}

.header {
min-height: 56px;
Expand All @@ -56,10 +57,6 @@
min-height: 56px;
}

.input {
margin: 13px 20px 0 0;
}

& ~ .field {
background: #f5f5f7;
}
Expand Down
12 changes: 7 additions & 5 deletions src/components/FileEditor/FileEditor.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ export default class FileEditor extends React.Component {
componentDidMount() {
document.body.addEventListener('click', this.checkExternalClick);
document.body.addEventListener('keypress', this.handleKey);
let fileInputElement = document.getElementById('fileInput');
if (fileInputElement) {
fileInputElement.click();
}
}

componentWillUnmount() {
document.body.removeEventListener('click', this.checkExternalClick);
document.body.removeEventListener('keypress', this.handleKey);
Expand Down Expand Up @@ -72,13 +76,11 @@ export default class FileEditor extends React.Component {
render() {
const file = this.props.value;
return (
<div ref='input' style={{ minWidth: this.props.width }} className={styles.editor}>
{file && file.url() ? <a href={file.url()} target='_blank' role='button' className={styles.download}>Download</a> : null}
<div ref='input' style={{ minWidth: this.props.width, display: 'none' }} className={styles.editor}>
<a className={styles.upload}>
<input ref='fileInput' type='file' onChange={this.handleChange.bind(this)} />
<input ref='fileInput' id='fileInput' type='file' onChange={this.handleChange.bind(this)} />
<span>{file ? 'Replace file' : 'Upload file'}</span>
</a>
{file ? <a href='javascript:;' role='button' className={styles.delete} onClick={this.removeFile}>Delete</a> : null}
</div>
);
}
Expand Down
24 changes: 22 additions & 2 deletions src/components/Pill/Pill.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,29 @@
*/
import React from 'react';
import styles from 'components/Pill/Pill.scss';
import Icon from "components/Icon/Icon.react";

//TODO: refactor, may want to move onClick outside or need to make onClick able to handle link/button a11y
let Pill = ({ value, onClick }) => (
<span className={[styles.pill, onClick ? styles.action : void(0)].join(' ')} onClick={onClick}>{value}</span>
let Pill = ({ value, onClick, fileDownloadLink, followClick = false }) => (
<span
className={[
styles.pill,
!followClick && onClick ? styles.action : void 0
].join(" ")}
onClick={!followClick && onClick ? onClick : null}
>
<span className={!followClick && fileDownloadLink ? styles.content : ''}>{value}</span>
{followClick && (
<a onClick={onClick}>
<Icon name="right-outline" width={20} height={20} fill="#1669a1" />
</a>
)}
{!followClick && fileDownloadLink && (
<a href={fileDownloadLink} target="_blank">
<Icon name="right-outline" width={20} height={20} fill="#1669a1" />
</a>
)}
</span>
);

export default Pill;
38 changes: 31 additions & 7 deletions src/components/Pill/Pill.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,44 @@

.pill {
@include MonospaceFont;
display: inline-block;
background: #D5E5F2;
display: flex;
justify-content: space-between;
align-items: center;
color: #0E69A1;
height: 20px;
line-height: 20px;
border-radius: 10px;
font-size: 11px;
padding: 0 8px;
width: 100%;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;

&:hover {
background: #BFD4E5;
white-space: nowrap;
margin-bottom: 4px;
& a {
height: 20px;
width: 20px;
background: #d6e5f2;
border-radius: 50%;
margin-left: 5px;
& svg {
transform: rotate(316deg);
}
}
}

.content {
width: 80%;
text-overflow: ellipsis;
overflow: hidden;
text-align: left;
height: 100%;
white-space: nowrap;
}

.iconAction {
cursor: pointer;
}

.disableIconAction {
cursor: initial;
}
47 changes: 39 additions & 8 deletions src/dashboard/Data/Browser/EditRowDialog.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import GeoPointEditor from 'components/GeoPointEditor/GeoPointEditor.react';
import FileEditor from 'components/FileEditor/FileEditor.react';
import ObjectPickerDialog from 'dashboard/Data/Browser/ObjectPickerDialog.react';
import styles from 'dashboard/Data/Browser/Browser.scss';
import getFileName from 'lib/getFileName';

export default class EditRowDialog extends React.Component {
constructor(props) {
Expand All @@ -23,14 +24,16 @@ export default class EditRowDialog extends React.Component {
const { currentObject, openObjectPickers, expandedTextAreas } = this.initializeState(
selectedObject
);
this.state = { currentObject, openObjectPickers, expandedTextAreas };
this.state = { currentObject, openObjectPickers, expandedTextAreas, showFileEditor: false };

this.updateCurrentObject = this.updateCurrentObject.bind(this);
this.handleChange = this.handleChange.bind(this);
this.openAcl = this.openAcl.bind(this);
this.openPointer = this.openPointer.bind(this);
this.toggleObjectPicker = this.toggleObjectPicker.bind(this);
this.openRelation = this.openRelation.bind(this);
this.openFileEditor = this.openFileEditor.bind(this);
this.hideFileEditor = this.hideFileEditor.bind(this);
}

componentWillReceiveProps(props) {
Expand Down Expand Up @@ -216,6 +219,18 @@ export default class EditRowDialog extends React.Component {
this.setState({ expandedTextAreas });
}

openFileEditor() {
this.setState({
showFileEditor: true
});
}

hideFileEditor() {
this.setState({
showFileEditor: false
});
}

render() {
const { selectedObject, className, columns, onClose, schema } = this.props;
const { currentObject, openObjectPickers, expandedTextAreas } = this.state;
Expand Down Expand Up @@ -247,6 +262,7 @@ export default class EditRowDialog extends React.Component {
'restricted'
].indexOf(name) >= 0);

let val = currentObject[name];
switch (type) {
case 'String':
inputComponent = (
Expand All @@ -257,7 +273,7 @@ export default class EditRowDialog extends React.Component {
: false
}
disabled={isDisabled}
placeholder={name === 'password' ? '(hidden)' : ''}
placeholder={name === 'password' ? '(hidden)' : val === undefined ? '(undefined)' : ''}
value={currentObject[name]}
onChange={newValue => this.updateCurrentObject(newValue, name)}
onBlur={newValue => this.handleChange(newValue, name)}
Expand All @@ -269,6 +285,7 @@ export default class EditRowDialog extends React.Component {
<TextInput
disabled={isDisabled}
value={currentObject[name]}
placeholder={val === undefined ? '(undefined)' : ''}
onChange={newValue => this.updateCurrentObject(newValue, name)}
onBlur={newValue => this.handleChange(parseFloat(newValue), name)}
/>
Expand All @@ -286,6 +303,7 @@ export default class EditRowDialog extends React.Component {
expandedTextAreas[name].rows
}
disabled={isDisabled}
placeholder={val === undefined && '(undefined)'}
value={currentObject[name]}
onChange={newValue => this.updateCurrentObject(newValue, name)}
onBlur={newValue =>
Expand All @@ -296,7 +314,7 @@ export default class EditRowDialog extends React.Component {
break;
case 'Boolean':
inputComponent = isDisabled ? (
<TextInput disabled={true} value={selectedObject[name]} />
<TextInput disabled={true} placeholder={val === undefined && '(undefined)'} value={selectedObject[name]} />
) : (
<Toggle
type={Toggle.Types.TRUE_FALSE}
Expand Down Expand Up @@ -327,13 +345,24 @@ export default class EditRowDialog extends React.Component {
);
break;
case 'File':
let file = selectedObject[name];
let fileName = file && file.url() ? getFileName(file) : '';
inputComponent = (
<div style={{ padding: '25px' }}>
<FileEditor
value={selectedObject[name]}
style={{ position: 'inherit' }}
onCommit={newValue => this.handleChange(newValue, name)}
/>
{file && <Pill value={fileName} fileDownloadLink={file.url()} />}
<div style={{ cursor: 'pointer' }}>
<Pill
value={file ? 'Change file' : 'Select file'}
onClick={() => this.openFileEditor()}
/>
{this.state.showFileEditor && (
<FileEditor
value={file}
onCancel={this.hideFileEditor}
onCommit={newValue => this.handleChange(newValue, name)}
/>
)}
</div>
</div>
);
break;
Expand Down Expand Up @@ -362,6 +391,7 @@ export default class EditRowDialog extends React.Component {
<Pill
onClick={() => this.openPointer(targetClass, pointerId)}
value={pointerId}
followClick={true}
/>
)}
<Pill
Expand Down Expand Up @@ -400,6 +430,7 @@ export default class EditRowDialog extends React.Component {
<Pill
onClick={() => this.openRelation(relation)}
value={`View ${type}`}
followClick={true}
/>
<Pill
onClick={() => this.toggleObjectPicker(name, true)}
Expand Down
4 changes: 3 additions & 1 deletion src/icons/right-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.