Commit 1c0368d0 authored by Patrik Meijer's avatar Patrik Meijer
Browse files

eslint --fix

parent 672cf49e
......@@ -54,12 +54,12 @@ export default class AttributeEditor extends Component {
static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.selection.length !== Object.keys(prevState.territory).length) {
return {territory: AttributeEditor.getTerritoryFromSelection(nextProps.selection)}
return {territory: AttributeEditor.getTerritoryFromSelection(nextProps.selection)};
}
for (let i = 0; nextProps.selection.length; i += 1) {
if (!prevState.territory[nextProps.selection[i]]) {
return {territory: AttributeEditor.getTerritoryFromSelection(nextProps.selection)}
return {territory: AttributeEditor.getTerritoryFromSelection(nextProps.selection)};
}
}
......@@ -68,7 +68,7 @@ export default class AttributeEditor extends Component {
componentDidMount() {
this.setState({
territory: AttributeEditor.getTerritoryFromSelection(this.props.selection)
territory: AttributeEditor.getTerritoryFromSelection(this.props.selection),
});
}
......@@ -173,8 +173,8 @@ export default class AttributeEditor extends Component {
/>);
});
const icon = (loadedNodes.length > 0 && this.props.children) ?
React.Children.map(this.props.children, (child) => {
const icon = (loadedNodes.length > 0 && this.props.children)
? React.Children.map(this.props.children, (child) => {
const nodeId = selection[0]; // This assumes only one node.
return React.cloneElement(child, {nodeId});
})
......
import React, {Component} from 'react';
import AttributeEditor from './index'
import AttributeEditor from './index';
export default class DemoAttributeEditor extends Component {
constructor(props) {
......@@ -17,6 +17,6 @@ export default class DemoAttributeEditor extends Component {
fullWidthWidgets
/>
</div>
)
);
}
}
\ No newline at end of file
}
......@@ -65,7 +65,7 @@ export default class AttributeItem extends Component {
static getDerivedStateFromProps(nextProps, prevState) {
// Note that outside property updates have precedence over typed in fields.
if (nextProps.value !== prevState.persistedValue) {
return {value: nextProps.value, persistedValue: nextProps.value, picking: false}
return {value: nextProps.value, persistedValue: nextProps.value, picking: false};
}
return null;
......@@ -172,36 +172,42 @@ export default class AttributeItem extends Component {
switch (type) {
case AttributeTypes.boolean:
content = (<FormControlLabel
disabled={readonly}
control={<Switch checked={value} onChange={this.onChange}/>}
/>);
content = (
<FormControlLabel
disabled={readonly}
control={<Switch checked={value} onChange={this.onChange}/>}
/>
);
break;
case AttributeTypes.string:
content = (<Input
disabled={readonly}
value={value}
onChange={this.onChange}
onKeyPress={this.onKeyPress}
onBlur={this.onBlur}
/>);
content = (
<Input
disabled={readonly}
value={value}
onChange={this.onChange}
onKeyPress={this.onKeyPress}
onBlur={this.onBlur}
/>
);
break;
case AttributeTypes.number:
content = (<Input
disabled={readonly}
type="number"
value={value}
onChange={this.onChange}
onKeyPress={this.onKeyPress}
onBlur={this.onBlur}
/>);
content = (
<Input
disabled={readonly}
type="number"
value={value}
onChange={this.onChange}
onKeyPress={this.onKeyPress}
onBlur={this.onBlur}
/>
);
break;
case AttributeTypes.color:
content = [];
content.push(<Input
key="input"
value={this.state.value}
endAdornment={
endAdornment={(
<InputAdornment position="end">
<IconButton onClick={() => {
this.setState({picking: !picking});
......@@ -210,7 +216,7 @@ export default class AttributeItem extends Component {
{picking ? <InvertColorsOff/> : <InvertColors nativeColor={value}/>}
</IconButton>
</InputAdornment>
}
)}
/>);
if (picking) {
......
......@@ -66,7 +66,9 @@ export default class BasicConnection extends Component {
};
render() {
const {path, hasWrapper, dashed, color} = this.props;
const {
path, hasWrapper, dashed, color,
} = this.props;
const box = this.getBoundingBox();
const sections = [];
let i;
......
export {default} from './BasicConnection';
\ No newline at end of file
export {default} from './BasicConnection';
export {default} from './BasicEventManager';
\ No newline at end of file
export {default} from './BasicEventManager';
import React, {Component} from 'react';
import Button from '@material-ui/core/Button';
import ConfirmDialog from './index'
import ConfirmDialog from './index';
export default class DemoConfirmDialog extends Component {
state = {
openDialog: false
openDialog: false,
};
openDialog = () => {
......@@ -23,21 +23,24 @@ export default class DemoConfirmDialog extends Component {
onClick={this.openDialog}
color="primary"
>
Show Dialog
</Button>
{this.state.openDialog ? <ConfirmDialog
title="A simple Yes/No or OK/Cancel Dialog"
message="Note that whenever this dialog is present it will be displayed. Therefore you
{this.state.openDialog ? (
<ConfirmDialog
title="A simple Yes/No or OK/Cancel Dialog"
message="Note that whenever this dialog is present it will be displayed. Therefore you
need to add/remove it from the parent that controls it. Get it?"
yesButtonText="Yes"
noButtonText="No"
onClose={(yes) => {
alert(yes ? 'Good' : 'It\'ll be come clear if you look at the source for the demo');
this.closeDialog();
}}
/> : null}
yesButtonText="Yes"
noButtonText="No"
onClose={(yes) => {
alert(yes ? 'Good' : 'It\'ll be come clear if you look at the source for the demo');
this.closeDialog();
}}
/>
) : null}
</div>
)
);
}
}
\ No newline at end of file
}
import BasicConnectingComponent from './BasicConnectingComponent';
import ConnectionManager from './ConnectionManager';
export {ConnectionManager,BasicConnectingComponent};
\ No newline at end of file
export {ConnectionManager, BasicConnectingComponent};
......@@ -122,8 +122,11 @@ class ContainmentCanvas extends SingleConnectedNode {
};
cm = null;
em = null;
item = null;
infoCard = null;
offset = {
......@@ -196,17 +199,15 @@ class ContainmentCanvas extends SingleConnectedNode {
const {connectDropTarget, activeNode, gmeClient} = this.props;
const {children, dragMode} = this.state;
const childrenItems = children.map(child => {
return React.cloneElement(this.item, {
key: child.id,
gmeClient: gmeClient,
activeNode: child.id,
contextNode: activeNode,
connectionManager: this.cm,
eventManager: this.em,
scale: 1,
});
});
const childrenItems = children.map(child => React.cloneElement(this.item, {
key: child.id,
gmeClient,
activeNode: child.id,
contextNode: activeNode,
connectionManager: this.cm,
eventManager: this.em,
scale: 1,
}));
const content = (
<div
......
......@@ -10,9 +10,8 @@ export default class DemoContainmentCanvas extends Component {
render() {
return (
<div style={{width: '90%'}}>
<ContainmentCanvas gmeClient={this.gmeClient} scrollPos={{x: 0, y: 0}} activeNode={''} isOver={false} scale={1}>
</ContainmentCanvas>
<ContainmentCanvas gmeClient={this.gmeClient} scrollPos={{x: 0, y: 0}} activeNode="" isOver={false} scale={1}/>
</div>
)
);
}
}
\ No newline at end of file
}
export {default} from './ContainmentCanvas';
\ No newline at end of file
export {default} from './ContainmentCanvas';
......@@ -7,17 +7,19 @@ import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
const InfoCard = (title, content, link) => {
let button = link == null ? null : (
<a href={link.target || 'https://www.google.com/'}
target="_blank"
rel="noopener noreferrer"
key="infoBtn"
style={{textDecoration: 'none'}}
const button = link == null ? null : (
<a
href={link.target || 'https://www.google.com/'}
target="_blank"
rel="noopener noreferrer"
key="infoBtn"
style={{textDecoration: 'none'}}
>
<Button
size="small"
color="primary"
>
Learn More
</Button>
</a>
......@@ -46,4 +48,4 @@ const InfoCard = (title, content, link) => {
);
};
export default InfoCard;
\ No newline at end of file
export default InfoCard;
......@@ -3,12 +3,21 @@ import InfoCard from './index';
export default class DemoInfoCard extends Component {
render() {
const content = (<span>add any thing you desire <br/><br/> and what you want </span>);
let card = InfoCard('Exmaple Info Card', content, {target: 'https://www.google.com/', title: 'Go search'});
const content = (
<span>
add any thing you desire
<br/>
<br/>
{' '}
and what you want
{' '}
</span>
);
const card = InfoCard('Exmaple Info Card', content, {target: 'https://www.google.com/', title: 'Go search'});
return (
<div>
{card}
</div>
);
}
}
\ No newline at end of file
}
export {default} from './InfoCard';
\ No newline at end of file
export {default} from './InfoCard';
import React, {Component} from 'react';
import ModalSpinner from './index';
import Button from '@material-ui/core/Button';
import ModalSpinner from './index';
export default class DemoContainmentCanvas extends Component {
constructor(props) {
......@@ -8,7 +8,7 @@ export default class DemoContainmentCanvas extends Component {
}
state = {
showSpinner: false
showSpinner: false,
};
render() {
......@@ -16,23 +16,22 @@ export default class DemoContainmentCanvas extends Component {
if (showSpinner) {
return (
<ModalSpinner visible={true}/>
)
} else {
return (
<div style={{width: '30%'}}>
<Button
onClick={() => {
this.setState({showSpinner: true});
setTimeout(() => {
this.setState({showSpinner: false});
}, 5000);
}}
>Try modal spinner for 5 seconds!
</Button>
</div>
)
<ModalSpinner visible/>
);
}
return (
<div style={{width: '30%'}}>
<Button
onClick={() => {
this.setState({showSpinner: true});
setTimeout(() => {
this.setState({showSpinner: false});
}, 5000);
}}
>
Try modal spinner for 5 seconds!
</Button>
</div>
);
}
}
\ No newline at end of file
}
export {default} from './ModalSpinner';
\ No newline at end of file
export {default} from './ModalSpinner';
......@@ -44,6 +44,7 @@ export default class ProjectSeedCards extends Component {
this.props.onCreate(seedInfo.createData);
}}
>
Create
</Button>);
......@@ -51,16 +52,18 @@ export default class ProjectSeedCards extends Component {
if (infoUrl) {
const infoBtn = (
<a href={infoUrl}
target="_blank"
rel="noopener noreferrer"
key="infoBtn"
style={{textDecoration: 'none'}}
<a
href={infoUrl}
target="_blank"
rel="noopener noreferrer"
key="infoBtn"
style={{textDecoration: 'none'}}
>
<Button
size="small"
color="primary"
>
Learn More
</Button>
</a>);
......
import React, {Component} from 'react';
import ProjectSeedCards from './index'
import ProjectSeedCards from './index';
export default class DemoProjectSeedCards extends Component {
render() {
const seedsInfo = ['Seed number 1', 'Seed number 2', 'Seed number 3', 'Seed number 4']
.map((function (title) {
return {
title: title,
description: 'In these examples the description is short so content height is low',
imageUrl: '/seed.png',
createData: {
seed: title,
desc: 'Any data passed here will be returned..',
},
infoUrl: 'https://webgme.org'
};
}));
.map((title => ({
title,
description: 'In these examples the description is short so content height is low',
imageUrl: '/seed.png',
createData: {
seed: title,
desc: 'Any data passed here will be returned..',
},
infoUrl: 'https://webgme.org',
})));
return (
<div style={{width: '50%'}}>
......@@ -31,6 +28,6 @@ export default class DemoProjectSeedCards extends Component {
}}
/>
</div>
)
);
}
}
\ No newline at end of file
}
......@@ -26,7 +26,7 @@ const canvasItemSource = {
},
};
const defaultSVG = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<root baseProfile=\"full\" height=\"210.0\" version=\"1.1\" viewBox=\"0 0 210.0 210.0\" width=\"210.0\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <defs/>\n <defs>\n <linearGradient id=\"926845b4-f7c1-4e3c-a437-8265e5af9bdb\" x1=\"0%\" x2=\"0%\" y1=\"0%\" y2=\"100%\">\n <stop offset=\"0\" stop-color=\"rgb(200, 200, 200)\" stop-opacity=\"1\"/>\n <stop offset=\"0.3\" stop-color=\"rgb(248, 248, 248)\" stop-opacity=\"1\"/>\n <stop offset=\"0.7\" stop-color=\"rgb(248, 248, 248)\" stop-opacity=\"1\"/>\n <stop offset=\"1\" stop-color=\"rgb(200, 200, 200)\" stop-opacity=\"1\"/>\n </linearGradient>\n </defs>\n <defs/>\n <defs/>\n <defs/>\n <defs/>\n <defs/>\n <desc>Modelica.Fluid.Icons.VariantLibrary</desc>\n <rect fill=\"url(#926845b4-f7c1-4e3c-a437-8265e5af9bdb)\" height=\"200.0\" rx=\"25.0\" ry=\"25.0\" stroke=\"rgb(200,200,200)\" stroke-width=\"0.25mm\" width=\"200.0\" x=\"5.0\" y=\"5.0\"/>\n <rect fill=\"none\" fill-opacity=\"0\" height=\"200.0\" rx=\"25.0\" ry=\"25.0\" stroke=\"rgb(128,128,128)\" stroke-width=\"0.25mm\" width=\"200.0\" x=\"5.0\" y=\"5.0\"/>\n <ellipse cx=\"65.0\" cy=\"145.0\" fill=\"rgb(76,76,76)\" rx=\"30.0\" ry=\"30.0\"/>\n <ellipse cx=\"145.0\" cy=\"145.0\" fill=\"rgb(0,0,0)\" rx=\"30.0\" ry=\"30.0\"/>\n <ellipse cx=\"145.0\" cy=\"65.0\" fill=\"rgb(128,128,128)\" rx=\"30.0\" ry=\"30.0\"/>\n <ellipse cx=\"65.0\" cy=\"65.0\" fill=\"rgb(255,255,255)\" rx=\"30.0\" ry=\"30.0\" stroke=\"rgb(128,128,128)\" stroke-width=\"0.25mm\"/>\n</root>";
const defaultSVG = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<root baseProfile="full" height="210.0" version="1.1" viewBox="0 0 210.0 210.0" width="210.0" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">\n <defs/>\n <defs>\n <linearGradient id="926845b4-f7c1-4e3c-a437-8265e5af9bdb" x1="0%" x2="0%" y1="0%" y2="100%">\n <stop offset="0" stop-color="rgb(200, 200, 200)" stop-opacity="1"/>\n <stop offset="0.3" stop-color="rgb(248, 248, 248)" stop-opacity="1"/>\n <stop offset="0.7" stop-color="rgb(248, 248, 248)" stop-opacity="1"/>\n <stop offset="1" stop-color="rgb(200, 200, 200)" stop-opacity="1"/>\n </linearGradient>\n </defs>\n <defs/>\n <defs/>\n <defs/>\n <defs/>\n <defs/>\n <desc>Modelica.Fluid.Icons.VariantLibrary</desc>\n <rect fill="url(#926845b4-f7c1-4e3c-a437-8265e5af9bdb)" height="200.0" rx="25.0" ry="25.0" stroke="rgb(200,200,200)" stroke-width="0.25mm" width="200.0" x="5.0" y="5.0"/>\n <rect fill="none" fill-opacity="0" height="200.0" rx="25.0" ry="25.0" stroke="rgb(128,128,128)" stroke-width="0.25mm" width="200.0" x="5.0" y="5.0"/>\n <ellipse cx="65.0" cy="145.0" fill="rgb(76,76,76)" rx="30.0" ry="30.0"/>\n <ellipse cx="145.0" cy="145.0" fill="rgb(0,0,0)" rx="30.0" ry="30.0"/>\n <ellipse cx="145.0" cy="65.0" fill="rgb(128,128,128)" rx="30.0" ry="30.0"/>\n <ellipse cx="65.0" cy="65.0" fill="rgb(255,255,255)" rx="30.0" ry="30.0" stroke="rgb(128,128,128)" stroke-width="0.25mm"/>\n</root>';
function collect(connector, monitor) {
return {
......@@ -57,9 +57,9 @@ class SVGRegistryBasedCanvasItem extends Component {
};
static defaultProps = {
selectNode: function () {
selectNode() {
},
activateAttributeDrawer: function () {
activateAttributeDrawer() {
},
selection: [],
};
......@@ -70,10 +70,12 @@ class SVGRegistryBasedCanvasItem extends Component {
showActions: false,
svg: {
base: defaultSVG,
bbox: {x: 0, y: 0, height: 100, width: 100},
bbox: {
x: 0, y: 0, height: 100, width: 100,
},
ports: {},
attributes: {},
//TODO probably would be better to move towards ejs
// TODO probably would be better to move towards ejs
},
childrenName2Id: {},
childInfo: {},
......@@ -152,9 +154,9 @@ class SVGRegistryBasedCanvasItem extends Component {
fontSize={Number(attributes[key].parameters['font-size'] || '18') * scale}
textAnchor={attributes[key].parameters['text-anchor'] || 'middle'}
>
{attributes[key].text.substring(0, attributes[key].position) +
node.getAttribute(key) +
attributes[key].text.substring(attributes[key].position)}
{attributes[key].text.substring(0, attributes[key].position)
+ node.getAttribute(key)
+ attributes[key].text.substring(attributes[key].position)}
</text>
</svg>));
});
......@@ -189,27 +191,27 @@ class SVGRegistryBasedCanvasItem extends Component {
}}
/>
</IconButton>),
(
<IconButton
key="attribute"
style={{
height: '20px',
width: '20px',
position: 'absolute',
top: '0px',
right: '20px',
zIndex: Z_LEVELS.action,
}}
onClick={() => {
activateAttributeDrawer(activeNode);
}}
>
<Edit style={{
height: '20px',
width: '20px',
}}
/>
</IconButton>),
(
<IconButton
key="attribute"
style={{
height: '20px',
width: '20px',
position: 'absolute',
top: '0px',
right: '20px',
zIndex: Z_LEVELS.action,
}}
onClick={() => {
activateAttributeDrawer(activeNode);
}}
>
<Edit style={{
height: '20px',
width: '20px',
}}
/>
</IconButton>),
];
if (onlyDelete) {
......@@ -238,7 +240,9 @@ class SVGRegistryBasedCanvasItem extends Component {
showActions: false,
svg: {
base: defaultSVG,
bbox: {x: 0, y: 0, height: 100, width: 100},
bbox: {
x: 0, y: 0, height: 100, width: 100,
},
ports: {},
attributes: {},
},
......@@ -321,12 +325,14 @@ class SVGRegistryBasedCanvasItem extends Component {
territory[activeNode] = {children: 1};
}
let newSvg = {
const newSvg = {
base: nodeObj.getRegistry('SVGIcon') || defaultSVG,
bbox: nodeObj.getRegistry('SVGBbox') || {x: 0, y: 0, height: 100, width: 100},
bbox: nodeObj.getRegistry('SVGBbox') || {
x: 0, y: 0, height: 100, width: 100,
},
ports: nodeObj.getRegistry('SVGPorts') || {},