Skip to content

Commit

Permalink
Merge pull request #594 from rottencandy/fix/pr-filter-26
Browse files Browse the repository at this point in the history
Add filter to pipelinerun link data
  • Loading branch information
openshift-merge-robot committed May 2, 2023
2 parents 047cce9 + 3cb9a2e commit cdbf9fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ describe('WorkflowNode', () => {
const visualization = getController(true);
const mockGroup = visualization.getNodeById('components');
const mockElement = mockGroup.getChildren()[0] as Node<NodeModel, WorkflowNodeModelData>;
const mockBuildGroup = visualization.getNodeById('builds');
const mockBuildElement = mockBuildGroup.getChildren()[1] as Node<
NodeModel,
WorkflowNodeModelData
>;

routerRenderer(<WorkflowNodeTipContent element={mockElement} />);

Expand All @@ -131,6 +136,10 @@ describe('WorkflowNode', () => {
expect(linkData.tab).toBe('components');
expect(linkData.filter.name).toBe('name');
expect(linkData.filter.value).toBe(mockElement.getLabel());
const buildLinkData = getLinkDataForElement(mockBuildElement, 'test-ws');
expect(buildLinkData.tab).toBe('activity/pipelineruns');
expect(buildLinkData.filter.name).toBe('name');
expect(buildLinkData.filter.value).toBe(mockBuildElement.getData().resources[0].metadata.name);
expect(screen.queryAllByTestId('child-row')).toHaveLength(0);
expect(screen.queryByText('View logs')).not.toBeInTheDocument();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const getLinkDataForElement = (
element: Node<PipelineNodeModel, WorkflowNodeModelData>,
workspace: string,
): { tab?: string; path?: string; filter?: { name: string; value: string } } => {
const { workflowType, isDisabled, groupNode, status } = element.getData();
const { workflowType, isDisabled, groupNode, status, resources } = element.getData();
const label = element.getLabel();

switch (workflowType) {
Expand All @@ -99,7 +99,10 @@ export const getLinkDataForElement = (
}
return {
tab: 'activity/pipelineruns',
// TODO: filter by build once the PLR tab supports filtering
filter:
!groupNode && !isDisabled && resources?.[0]
? { name: 'name', value: resources[0].metadata.name }
: undefined,
};
case WorkflowNodeType.TESTS:
case WorkflowNodeType.APPLICATION_TEST:
Expand Down

0 comments on commit cdbf9fe

Please sign in to comment.