Skip to content

Commit

Permalink
Move graph data model builder to utils package
Browse files Browse the repository at this point in the history
- Move buildGraphData to @tektoncd/dashboard-utils for re-use
- Ensure top-level Graph and PipelineGraph components are exported
  by @tektoncd/dashboard-components
- Fix dependencies so graph-related packages are required by @tektoncd/dashboard-components
- Move getStatus to separate file to prevent import cycle
  • Loading branch information
AlanGreene authored and tekton-robot committed Nov 26, 2019
1 parent 5eb2f3d commit 6047545
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 23 deletions.
27 changes: 15 additions & 12 deletions package-lock.json

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

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@
"@formatjs/intl-pluralrules": "^1.2.1",
"@tektoncd/dashboard-components": "file:./packages/components",
"@tektoncd/dashboard-utils": "file:./packages/utils",
"@vx/network": "0.0.192",
"carbon-components": "^10.6.1",
"carbon-components-react": "^7.6.1",
"classnames": "^2.2.6",
"core-js": "^3.0.1",
"d3-path": "^1.0.8",
"elkjs": "^0.5.1",
"es6-promise": "^4.2.6",
"history": "^4.9.0",
"isomorphic-fetch": "^2.2.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
"@formatjs/intl-pluralrules": "^1.2.1",
"@formatjs/intl-relativetimeformat": "^4.1.1",
"@tektoncd/dashboard-utils": "file:../utils",
"@vx/network": "0.0.192",
"ansi-to-react": "^5.0.0",
"carbon-components": "^10.4.1",
"carbon-components-react": "^7.4.1",
"d3-path": "^1.0.8",
"elkjs": "^0.5.1",
"js-yaml": "^3.13.0",
"prop-types": "^15.7.2",
"react-window": "^1.8.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/Graph/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class Graph extends Component {
nodes: g.children
});
})
.catch(console.error);
.catch(console.error); // eslint-disable-line no-console
};

render() {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/Graph/PipelineGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ limitations under the License.
*/
/* istanbul ignore file */
import React, { Component } from 'react';
import { buildGraphData } from '@tektoncd/dashboard-utils';

import Graph from './Graph';
import buildGraphData from './buildGraphData';

export default class PipelineGraph extends Component {
state = {
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ export { default as Breadcrumbs } from './Breadcrumbs';
export { default as CancelButton } from './CancelButton';
export { default as ErrorBoundary } from './ErrorBoundary';
export { default as FormattedDate } from './FormattedDate';
export { default as Graph } from './Graph/Graph';
export { default as Header } from './Header';
export { default as LabelFilter } from './LabelFilter';
export { default as Log } from './Log';
export { default as LogoutButton } from './LogoutButton';
export { default as PageErrorBoundary } from './PageErrorBoundary';
export { default as PipelineGraph } from './Graph/PipelineGraph';
export { default as PipelineRun } from './PipelineRun';
export { default as PipelineRuns } from './PipelineRuns';
export { default as Rerun } from './Rerun';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/* istanbul ignore file */
import { getStatus } from '@tektoncd/dashboard-utils';
import { getStatus } from './status';

const defaultHeight = 26;
const defaultCharWidth = 9;
Expand Down
7 changes: 2 additions & 5 deletions packages/utils/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import Time16 from '@carbon/icons-react/lib/time/16';
import CloseFilled from '@carbon/icons-react/lib/close--filled/16';
import { Spinner } from '@tektoncd/dashboard-components';

export { default as buildGraphData } from './buildGraphData';
export { paths, urls } from './router';
export { getStatus } from './status';

export const ALL_NAMESPACES = '*';

Expand Down Expand Up @@ -110,11 +112,6 @@ export function stepsStatus(taskSteps, taskRunStepsStatus = []) {
return steps;
}

export function getStatus(resource) {
const { conditions = [] } = resource.status || {};
return conditions.find(condition => condition.type === 'Succeeded') || {};
}

export function isRunning(reason, status) {
return status === 'Unknown' && reason === 'Running';
}
Expand Down
17 changes: 17 additions & 0 deletions packages/utils/src/utils/status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

export function getStatus(resource) {
const { conditions = [] } = resource.status || {};
return conditions.find(condition => condition.type === 'Succeeded') || {};
}

0 comments on commit 6047545

Please sign in to comment.