Skip to content

Add/relation viewer #452

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 6 commits into from
Jul 15, 2016
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ export default class DataBrowserHeaderBar extends React.Component {
finalStyle.background = 'rgba(224,224,234,0.10)';
}
elements.push(
<div key='add' className={styles.addColumn} style={finalStyle}>
{readonly ?
null :
readonly ? null : (
<div key='add' className={styles.addColumn} style={finalStyle}>
<a
href='javascript:;'
role='button'
className={styles.addColumnButton}
onClick={onAddColumn}>
Add a new column
</a>}
</div>
</a>
</div>
)
);

return <div className={styles.bar}>{elements}</div>;
Expand Down
18 changes: 17 additions & 1 deletion src/components/EmptyState/EmptyState.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ let ctaButton = (cta, action) => {
}
}

let EmptyState = ({ icon='', title='', description='', cta='', action=()=>{}}) => (
let EmptyState = ({
icon='',
title='',
description='',
cta='',
action=() => {},
secondaryCta='',
secondaryAction=() => {},
}) => (
<div className={center}>
<div className={styles.icon}>
<Icon
Expand All @@ -47,6 +55,8 @@ let EmptyState = ({ icon='', title='', description='', cta='', action=()=>{}}) =
<div className={styles.title}>{title}</div>
<div className={styles.description}>{description}</div>
{ctaButton(cta, action)}
{secondaryCta && ' '}
{ctaButton(secondaryCta, secondaryAction)}
</div>
);

Expand All @@ -68,6 +78,12 @@ EmptyState.propTypes = {
action: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).describe(
'An href link or a click handler that is forwarded to the CTA button.'
),
secondaryCta: PropTypes.string.describe(
'The text that appears in the secondary CTA button.'
),
secondaryAction: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).describe(
'An href link or a click handler that is forwarded to the secondary CTA button.'
),
};

export default EmptyState;
62 changes: 45 additions & 17 deletions src/components/Toolbar/Toolbar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,59 @@
*/
import PropTypes from 'lib/PropTypes';
import React from 'react';
import Icon from 'components/Icon/Icon.react';
import styles from 'components/Toolbar/Toolbar.scss';
import history from 'dashboard/history';

let Toolbar = (props) => (
<div className={styles.toolbar}>
<div className={styles.title}>
<div className={styles.section}>{props.section}</div>
<div>
<span className={styles.subsection}>
{props.subsection}
</span>
<span className={styles.details}>
{props.details}
</span>
const goBack = () => history.goBack();

let Toolbar = (props) => {
let backButton;
if (props.relation || (props.filters && props.filters.size)) {
backButton = (
<a
className={styles.iconButton}
onClick={goBack}
>
<Icon
width={32}
height={32}
fill="#ffffff"
name="left-outline"
/>
</a>
);
}
return (
<div className={styles.toolbar}>
<div className={styles.title}>
<div className={styles.nav}>
{backButton}
</div>
<div className={styles.titleText}>
<div className={styles.section}>{props.section}</div>
<div>
<span className={styles.subsection}>
{props.subsection}
</span>
<span className={styles.details}>
{props.details}
</span>
</div>
</div>
</div>
<div className={styles.actions}>
{props.children}
</div>
</div>
<div className={styles.actions}>
{props.children}
</div>
</div>
);
);
};

Toolbar.propTypes = {
section: PropTypes.string,
subsection: PropTypes.string,
details: PropTypes.string
details: PropTypes.string,
relation: PropTypes.object,
};

export default Toolbar;
16 changes: 15 additions & 1 deletion src/components/Toolbar/Toolbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,27 @@
}
}


.title {
position: absolute;
left: 14px;
bottom: 10px;
}

.nav {
display: inline-block;
}

.iconButton {
display: block;
padding-top: 10px;
padding-right: 10px;
cursor: pointer;
}

.titleText {
display: inline-block;
}

.section {
@include DosisFont;
color: #757985;
Expand Down
1 change: 1 addition & 0 deletions src/dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class Dashboard extends React.Component {

<Route path='browser' component={false ? SchemaOverview : Browser} /> //In progress features. Change false to true to work on this feature.
<Route path='browser/:className' component={Browser} />
<Route path='browser/:className/:entityId/:relationName' component={Browser} />

<Route path='cloud_code' component={CloudCode} />
<Route path='cloud_code/*' component={CloudCode} />
Expand Down
78 changes: 78 additions & 0 deletions src/dashboard/Data/Browser/AttachRowsDialog.react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React from 'react';
import FormModal from 'components/FormModal/FormModal.react';
import Field from 'components/Field/Field.react';
import Label from 'components/Label/Label.react';
import TextInput from 'components/TextInput/TextInput.react';
import Parse from 'parse';

export default class AttachRowsDialog extends React.Component {
constructor(props) {
super(props);

this.state = {
objectIds: '',
};

this.handleObjectIdsChange = this.handleObjectIdsChange.bind(this);
this.handleConfirm = this.handleConfirm.bind(this);
}

handleObjectIdsChange(objectIds) {
this.setState({ objectIds });
}

handleConfirm() {
const objectIds = this.state.objectIds.split(',').reduce((resourceIds, targetResourceId) => {
const objectId = targetResourceId && targetResourceId.trim();
if (!objectId) return;
return [...resourceIds, objectId];
}, []);
const promise = new Parse.Promise();
console.log(promise);
this.props.onConfirm(objectIds)
.then(promise.resolve)
.catch((error) => {
promise.reject({
error,
});
});
return promise;
}

render() {
const {
relation,
onCancel,
onConfirm,
} = this.props;
return (
<FormModal
icon="plus"
iconSize={40}
title="Attach Rows"
subtitle={`Attach existing rows from ${relation.targetClassName}`}
onClose={this.props.onCancel}
onSubmit={this.handleConfirm}
open
submitText="Attach"
inProgressText="Attaching ..."
>
<Field
label={
<Label
text="objectIds"
description={`IDs of ${relation.targetClassName} rows to attach`}
/>
}
input={
<TextInput
placeholder="ox0QZFl7eg, qs81Q72lTL, etc..."
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

value={this.state.objectIds}
onChange={this.handleObjectIdsChange}
/>
}
/>
</FormModal>
);
}
}
Loading