Skip to content
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

Add ZoomablePipelineGraph component #820

Merged
merged 1 commit into from
Dec 11, 2019
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
58 changes: 26 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@formatjs/intl-pluralrules": "^1.2.1",
"@formatjs/intl-relativetimeformat": "^4.1.1",
"@tektoncd/dashboard-utils": "file:../utils",
"@vx/event": "0.0.192",
"@vx/network": "0.0.192",
"ansi-to-react": "^5.0.0",
"carbon-components": "^10.4.1",
Expand Down
8 changes: 5 additions & 3 deletions packages/components/src/components/Graph/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ export default class Graph extends Component {
.then(g => {
this.setState({
links: g.edges,
nodes: g.children
nodes: g.children,
width: g.width,
height: g.height
});
})
.catch(console.error); // eslint-disable-line no-console
};

render() {
const { height, isSubGraph, onClickStep, onClickTask, width } = this.props;
const { links, margin, nodes } = this.state;
const { isSubGraph, onClickStep, onClickTask } = this.props;
const { height, links, margin, nodes, width } = this.state;

if (!nodes) {
return null;
Expand Down
23 changes: 16 additions & 7 deletions packages/components/src/components/Graph/Graph.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { action } from '@storybook/addon-actions';
import Node from './Node';
import Graph from './Graph';
import PipelineGraph from './PipelineGraph';
import ZoomablePipelineGraph from './ZoomablePipelineGraph';

import graph from './examples/graph.json';
import pipeline from './examples/pipeline.json';
Expand All @@ -40,7 +41,7 @@ import tasks from './examples/tasks.json';
const taskProps = {
type: 'Task',
label: 'build-and-push',
width: 160,
width: 200,
height: 30
};

Expand All @@ -50,19 +51,19 @@ const expandedProps = {
type: 'Step',
id: '__step_build-and-push__build-image',
label: 'build-image',
width: 160,
width: 200,
height: 30
},
{
type: 'Step',
id: '__step_build-and-push__push-image',
label: 'push-image',
width: 160,
width: 200,
height: 30
}
],
edges: [],
height: 79
height: 90
};

storiesOf('Graph/Node', module)
Expand All @@ -82,9 +83,7 @@ storiesOf('Graph/Node', module)
<Node {...taskProps} status="success" {...expandedProps} isSelected />
));

storiesOf('Graph/Graph', module).add('default', () => (
<Graph graph={graph} width={450} height={550} />
));
storiesOf('Graph/Graph', module).add('default', () => <Graph graph={graph} />);

storiesOf('Graph/PipelineGraph', module).add('default', () => (
<PipelineGraph
Expand All @@ -95,3 +94,13 @@ storiesOf('Graph/PipelineGraph', module).add('default', () => (
tasks={tasks}
/>
));

storiesOf('Graph/ZoomablePipelineGraph', module).add('default', () => (
<ZoomablePipelineGraph
onClickStep={action('onClickStep')}
onClickTask={action('onClickTask')}
pipeline={pipeline}
pipelineRun={pipelineRun}
tasks={tasks}
/>
));
2 changes: 0 additions & 2 deletions packages/components/src/components/Graph/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ export default class Node extends Component {
graph={{ id: `${id}_subgraph`, children, edges }}
isSubGraph
onClickStep={this.handleClickStep}
width={width}
height={height}
/>
)}
</g>
Expand Down
Loading