-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9e4d60
commit ea246a8
Showing
6 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
frontend/packages/dev-console/src/components/taskruns/TaskRunDetails.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.odc-taskrun-details { | ||
&__status { | ||
dl { | ||
margin-bottom: var(--pf-global--spacer--md); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
frontend/packages/dev-console/src/components/taskruns/TaskRunLog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as React from 'react'; | ||
import { useK8sGet } from '@console/internal/components/utils/k8s-get-hook'; | ||
import { K8sResourceKind } from '@console/internal/module/k8s'; | ||
import { PodLogs } from '@console/internal/components/pod-logs'; | ||
import { StatusBox } from '@console/internal/components/utils/status-box'; | ||
import { PodModel } from '@console/internal/models'; | ||
|
||
export type TaskRunLogProps = { | ||
obj: K8sResourceKind; | ||
}; | ||
|
||
const TaskRunLog: React.FC<TaskRunLogProps> = ({ obj }) => { | ||
const [pod, podLoaded, podError] = useK8sGet<K8sResourceKind>( | ||
PodModel, | ||
obj.status.podName, | ||
obj.metadata.namespace, | ||
); | ||
if (podLoaded) { | ||
return <PodLogs obj={pod} />; | ||
} | ||
return <StatusBox loaded={podLoaded} loadError={podError} label="TaskRun Log" />; | ||
}; | ||
|
||
// to safeguard against cases where Pod is yet to be assigned or is removed | ||
export default (props: TaskRunLogProps) => | ||
props.obj.status?.podName ? ( | ||
<TaskRunLog {...props} /> | ||
) : ( | ||
<StatusBox loadError="Pod not found" label="TaskRun Log" /> | ||
); |
42 changes: 42 additions & 0 deletions
42
frontend/packages/dev-console/src/components/taskruns/__tests__/TaskRunDetails.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as React from 'react'; | ||
import { SectionHeading, ResourceSummary } from '@console/internal/components/utils'; | ||
import { Status } from '@console/shared'; | ||
import PipelineRunDetailsErrorLog from '../../pipelineruns/logs/PipelineRunDetailsErrorLog'; | ||
import { shallow } from 'enzyme'; | ||
import TaskRunDetails from '../TaskRunDetails'; | ||
|
||
type Component = typeof TaskRunDetails; | ||
type Props = React.ComponentProps<Component>; | ||
const TaskDetailsProps: Props = { | ||
obj: { | ||
kind: 'TaskRun', | ||
metadata: { name: 'abhi', namespace: 'abhi1' }, | ||
status: { | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'Failed', | ||
status: 'True', | ||
type: 'Failed', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
describe('TaskRunDetailsPage', () => { | ||
const pipelineRunWrapper = shallow(<TaskRunDetails {...TaskDetailsProps} />); | ||
it('Renders a SectionHeading', () => { | ||
expect(pipelineRunWrapper.find(SectionHeading).exists()); | ||
}); | ||
it('Renders a Resource Summary', () => { | ||
expect(pipelineRunWrapper.find(ResourceSummary).exists()); | ||
}); | ||
it('Renders a Status', () => { | ||
expect(pipelineRunWrapper.find(Status).exists()); | ||
}); | ||
it('Renders a Log snippet', () => { | ||
expect(pipelineRunWrapper.find(PipelineRunDetailsErrorLog).exists()); | ||
}); | ||
}); |
37 changes: 37 additions & 0 deletions
37
frontend/packages/dev-console/src/components/taskruns/__tests__/TaskRunLog.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as React from 'react'; | ||
import { PodLogs } from '@console/internal/components/pod-logs'; | ||
import { StatusBox } from '@console/internal/components/utils/status-box'; | ||
import { shallow } from 'enzyme'; | ||
import TaskRunLog from '../TaskRunLog'; | ||
|
||
type Component = typeof TaskRunLog; | ||
type Props = React.ComponentProps<Component>; | ||
const TaskRunLogProps: Props = { | ||
obj: { | ||
kind: 'TaskRun', | ||
metadata: { name: 'abhi', namespace: 'abhi1' }, | ||
status: { | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'Failed', | ||
status: 'True', | ||
type: 'Failed', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
describe('TaskRunLog Page', () => { | ||
it('Renders a StatusBox', () => { | ||
const pipelineRunWrapper = shallow(<TaskRunLog {...TaskRunLogProps} />); | ||
expect(pipelineRunWrapper.find(StatusBox).exists()); | ||
}); | ||
it('Renders a PodLog', () => { | ||
TaskRunLogProps.obj.status.podName = 'test'; | ||
const pipelineRunWrapper = shallow(<TaskRunLog {...TaskRunLogProps} />); | ||
expect(pipelineRunWrapper.find(PodLogs).exists()); | ||
}); | ||
}); |