-
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 70aaab8
Showing
13 changed files
with
240 additions
and
8 deletions.
There are no files selected for viewing
7 changes: 3 additions & 4 deletions
7
frontend/packages/dev-console/src/components/pipelineruns/logs/LogSnippetBlock.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
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
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
35 changes: 35 additions & 0 deletions
35
frontend/packages/dev-console/src/components/taskruns/TaskRunDetailsErrorLog.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,35 @@ | ||
import * as React from 'react'; | ||
import { getLogSnippet } from '../pipelineruns/logs/pipelineRunLogSnippet'; | ||
import LogSnippetBlock from '../pipelineruns/logs/LogSnippetBlock'; | ||
import { TaskRunKind } from '../../utils/pipeline-augment'; | ||
|
||
type TaskStatusLogProps = { | ||
taskRun: TaskRunKind; | ||
}; | ||
|
||
const TaskRunDetailsErrorLog: React.FC<TaskStatusLogProps> = ({ taskRun }) => { | ||
const logDetails = getLogSnippet(taskRun); | ||
const namespace = taskRun?.metadata.namespace; | ||
if (!logDetails) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<dl> | ||
<dt>Message</dt> | ||
<dd>{logDetails.title}</dd> | ||
</dl> | ||
<dl> | ||
<dt>Log Snippet</dt> | ||
<dd> | ||
<LogSnippetBlock logDetails={logDetails} namespace={namespace}> | ||
{(logSnippet: string) => <pre>{logSnippet}</pre>} | ||
</LogSnippetBlock> | ||
</dd> | ||
</dl> | ||
</> | ||
); | ||
}; | ||
|
||
export default TaskRunDetailsErrorLog; |
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
5 changes: 5 additions & 0 deletions
5
frontend/packages/dev-console/src/components/taskruns/TaskRunLog.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,5 @@ | ||
.odc-task-run-log { | ||
display: flex; | ||
flex: 1; | ||
padding: var(--pf-global--spacer--xl); | ||
} |
38 changes: 38 additions & 0 deletions
38
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,38 @@ | ||
import * as React from 'react'; | ||
import { Firehose } from '@console/internal/components/utils'; | ||
import { StatusBox } from '@console/internal/components/utils/status-box'; | ||
import { PodModel } from '@console/internal/models'; | ||
import LogsWrapperComponent from '../pipelineruns/logs/LogsWrapperComponent'; | ||
import { TaskRunKind } from '../../utils/pipeline-augment'; | ||
import './TaskRunLog.scss'; | ||
|
||
export type TaskRunLogProps = { | ||
obj: TaskRunKind; | ||
}; | ||
|
||
const TaskRunLog: React.FC<TaskRunLogProps> = ({ obj }) => { | ||
if (obj?.status?.podName) { | ||
const podResources = [ | ||
{ | ||
kind: PodModel.kind, | ||
isList: false, | ||
prop: `obj`, | ||
namespace: obj.metadata.namespace, | ||
name: obj.status.podName, | ||
}, | ||
]; | ||
return ( | ||
<div className="odc-task-run-log"> | ||
<Firehose resources={podResources}> | ||
<LogsWrapperComponent | ||
taskName={obj.metadata.name} | ||
downloadAllLabel="Download All TaskRun Logs" | ||
/> | ||
</Firehose> | ||
</div> | ||
); | ||
} | ||
return <StatusBox loadError="Pod not found" label="TaskRun Log" />; | ||
}; | ||
|
||
export default TaskRunLog; |
48 changes: 48 additions & 0 deletions
48
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,48 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { SectionHeading, ResourceSummary } from '@console/internal/components/utils'; | ||
import { Status } from '@console/shared'; | ||
import TaskRunDetailsErrorLog from '../TaskRunDetailsErrorLog'; | ||
import TaskRunDetails from '../TaskRunDetails'; | ||
import { failedTaskRun, successTaskRun } from './taskrun-test-data'; | ||
|
||
type Component = typeof TaskRunDetails; | ||
type Props = React.ComponentProps<Component>; | ||
const TaskDetailsProps: Props = { | ||
obj: failedTaskRun, | ||
}; | ||
|
||
describe('TaskRunDetailsPage For Failure', () => { | ||
const pipelineRunWrapper = shallow(<TaskRunDetails {...TaskDetailsProps} />); | ||
it('Renders a SectionHeading', () => { | ||
expect(pipelineRunWrapper.find(SectionHeading).exists()).toBe(true); | ||
}); | ||
it('Renders a Resource Summary', () => { | ||
expect(pipelineRunWrapper.find(ResourceSummary).exists()).toBe(true); | ||
}); | ||
it('Renders correct Status', () => { | ||
expect(pipelineRunWrapper.find(Status).exists()).toBe(true); | ||
expect(pipelineRunWrapper.find(Status).prop('status')).toBe('-'); | ||
}); | ||
it('Renders a Task Run Log snippet', () => { | ||
expect(pipelineRunWrapper.find(TaskRunDetailsErrorLog).exists()).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('TaskRunDetailsPage For Success', () => { | ||
TaskDetailsProps.obj = successTaskRun; | ||
const pipelineRunWrapper = shallow(<TaskRunDetails {...TaskDetailsProps} />); | ||
it('Renders a SectionHeading', () => { | ||
expect(pipelineRunWrapper.find(SectionHeading).exists()).toBe(true); | ||
}); | ||
it('Renders a Resource Summary', () => { | ||
expect(pipelineRunWrapper.find(ResourceSummary).exists()).toBe(true); | ||
}); | ||
it('Renders a Status', () => { | ||
expect(pipelineRunWrapper.find(Status).exists()).toBe(true); | ||
expect(pipelineRunWrapper.find(Status).prop('status')).toBe('Succeeded'); | ||
}); | ||
it('Renders a Task Run Log snippet', () => { | ||
expect(pipelineRunWrapper.find(TaskRunDetailsErrorLog).exists()).toBe(true); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
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,24 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { StatusBox } from '@console/internal/components/utils/status-box'; | ||
import LogsWrapperComponent from '../../pipelineruns/logs/LogsWrapperComponent'; | ||
import TaskRunLog from '../TaskRunLog'; | ||
import { failedTaskRun } from './taskrun-test-data'; | ||
|
||
type Component = typeof TaskRunLog; | ||
type Props = React.ComponentProps<Component>; | ||
const TaskRunLogProps: Props = { | ||
obj: failedTaskRun, | ||
}; | ||
|
||
describe('TaskRunLog Page', () => { | ||
it('Renders a StatusBox', () => { | ||
const taskRunLogWrapper = shallow(<TaskRunLog {...TaskRunLogProps} />); | ||
expect(taskRunLogWrapper.find(StatusBox).exists()); | ||
}); | ||
it('Renders a PodLog', () => { | ||
TaskRunLogProps.obj.status.podName = 'test'; | ||
const taskRunLogWrapper = shallow(<TaskRunLog {...TaskRunLogProps} />); | ||
expect(taskRunLogWrapper.find(LogsWrapperComponent).exists()); | ||
}); | ||
}); |
33 changes: 33 additions & 0 deletions
33
frontend/packages/dev-console/src/components/taskruns/__tests__/taskrun-test-data.ts
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,33 @@ | ||
import { TaskRunKind } from '../../../utils/pipeline-augment'; | ||
|
||
export const failedTaskRun: TaskRunKind = { | ||
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', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export const successTaskRun: TaskRunKind = { | ||
kind: 'TaskRun', | ||
metadata: { name: 'abhi', namespace: 'abhi1' }, | ||
status: { | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'Succeeded', | ||
status: 'True', | ||
type: 'Succeeded', | ||
}, | ||
], | ||
}, | ||
}; |
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