mirror of
https://github.com/harness/drone.git
synced 2025-05-31 11:43:15 +00:00
fix Tan PR comments
This commit is contained in:
parent
2d0fc6f3c9
commit
742769bba1
@ -6,7 +6,7 @@ import type { CODEProps } from 'RouteDefinitions'
|
|||||||
import type { TypesStage } from 'services/code'
|
import type { TypesStage } from 'services/code'
|
||||||
import ConsoleStep from 'components/ConsoleStep/ConsoleStep'
|
import ConsoleStep from 'components/ConsoleStep/ConsoleStep'
|
||||||
import { timeDistance } from 'utils/Utils'
|
import { timeDistance } from 'utils/Utils'
|
||||||
// import { useGetRepositoryMetadata } from 'hooks/useGetRepositoryMetadata'
|
import { useStrings } from 'framework/strings'
|
||||||
import css from './Console.module.scss'
|
import css from './Console.module.scss'
|
||||||
|
|
||||||
interface ConsoleProps {
|
interface ConsoleProps {
|
||||||
@ -16,6 +16,7 @@ interface ConsoleProps {
|
|||||||
|
|
||||||
const Console: FC<ConsoleProps> = ({ stage, repoPath }) => {
|
const Console: FC<ConsoleProps> = ({ stage, repoPath }) => {
|
||||||
const { pipeline, execution: executionNum } = useParams<CODEProps>()
|
const { pipeline, execution: executionNum } = useParams<CODEProps>()
|
||||||
|
const { getString } = useStrings()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={css.container}>
|
<div className={css.container}>
|
||||||
@ -26,7 +27,7 @@ const Console: FC<ConsoleProps> = ({ stage, repoPath }) => {
|
|||||||
</Text>
|
</Text>
|
||||||
{stage?.started && stage?.stopped && (
|
{stage?.started && stage?.stopped && (
|
||||||
<Text font={{ variation: FontVariation.BODY }} color={Color.GREY_500}>
|
<Text font={{ variation: FontVariation.BODY }} color={Color.GREY_500}>
|
||||||
{`completed ${timeDistance(stage?.stopped, Date.now())} ago`}
|
{getString('executions.completedTime', { timeString: timeDistance(stage?.stopped, Date.now()) })}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</Layout.Horizontal>
|
</Layout.Horizontal>
|
||||||
|
@ -7,6 +7,7 @@ import type { LivelogLine, TypesStep } from 'services/code'
|
|||||||
import { timeDistance } from 'utils/Utils'
|
import { timeDistance } from 'utils/Utils'
|
||||||
import ConsoleLogs from 'components/ConsoleLogs/ConsoleLogs'
|
import ConsoleLogs from 'components/ConsoleLogs/ConsoleLogs'
|
||||||
import { useStrings } from 'framework/strings'
|
import { useStrings } from 'framework/strings'
|
||||||
|
import { ExecutionState } from 'components/ExecutionStatus/ExecutionStatus'
|
||||||
import css from './ConsoleStep.module.scss'
|
import css from './ConsoleStep.module.scss'
|
||||||
|
|
||||||
interface ConsoleStepProps {
|
interface ConsoleStepProps {
|
||||||
@ -24,8 +25,8 @@ const ConsoleStep: FC<ConsoleStepProps> = ({ step, stageNumber, repoPath, pipeli
|
|||||||
const [streamingLogs, setStreamingLogs] = useState<LivelogLine[]>([])
|
const [streamingLogs, setStreamingLogs] = useState<LivelogLine[]>([])
|
||||||
const eventSourceRef = useRef<EventSource | null>(null)
|
const eventSourceRef = useRef<EventSource | null>(null)
|
||||||
|
|
||||||
const shouldUseGet = step?.status !== 'running' && step?.status !== 'pending'
|
const shouldUseGet = step?.status !== ExecutionState.RUNNING && step?.status !== ExecutionState.PENDING
|
||||||
const isPending = step?.status === 'pending'
|
const isPending = step?.status === ExecutionState.PENDING
|
||||||
|
|
||||||
const { data, error, loading, refetch } = useGet<LivelogLine[]>({
|
const { data, error, loading, refetch } = useGet<LivelogLine[]>({
|
||||||
path: `/api/v1/repos/${repoPath}/+/pipelines/${pipelineName}/executions/${executionNumber}/logs/${String(
|
path: `/api/v1/repos/${repoPath}/+/pipelines/${pipelineName}/executions/${executionNumber}/logs/${String(
|
||||||
@ -39,7 +40,7 @@ const ConsoleStep: FC<ConsoleStepProps> = ({ step, stageNumber, repoPath, pipeli
|
|||||||
}, [stageNumber])
|
}, [stageNumber])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (step?.status === 'running') {
|
if (step?.status === ExecutionState.RUNNING) {
|
||||||
if (eventSourceRef.current) {
|
if (eventSourceRef.current) {
|
||||||
eventSourceRef.current.close()
|
eventSourceRef.current.close()
|
||||||
setStreamingLogs([])
|
setStreamingLogs([])
|
||||||
@ -62,11 +63,11 @@ const ConsoleStep: FC<ConsoleStepProps> = ({ step, stageNumber, repoPath, pipeli
|
|||||||
}, [executionNumber, pipelineName, repoPath, stageNumber, step?.number, step?.status])
|
}, [executionNumber, pipelineName, repoPath, stageNumber, step?.number, step?.status])
|
||||||
|
|
||||||
let icon
|
let icon
|
||||||
if (step?.status === 'success') {
|
if (step?.status === ExecutionState.SUCCESS) {
|
||||||
icon = <Icon name="success-tick" />
|
icon = <Icon name="success-tick" />
|
||||||
} else if (isPending) {
|
} else if (isPending) {
|
||||||
icon = <Icon name="circle" />
|
icon = <Icon name="circle" />
|
||||||
} else if (step?.status === 'running') {
|
} else if (step?.status === ExecutionState.RUNNING) {
|
||||||
icon = <Icon className={css.spin} name="pending" />
|
icon = <Icon className={css.spin} name="pending" />
|
||||||
} else {
|
} else {
|
||||||
icon = <Icon name="circle" /> // Default icon in case of other statuses or unknown status
|
icon = <Icon name="circle" /> // Default icon in case of other statuses or unknown status
|
||||||
@ -75,7 +76,7 @@ const ConsoleStep: FC<ConsoleStepProps> = ({ step, stageNumber, repoPath, pipeli
|
|||||||
let content
|
let content
|
||||||
if (loading) {
|
if (loading) {
|
||||||
content = <div className={css.loading}>{getString('loading')}</div>
|
content = <div className={css.loading}>{getString('loading')}</div>
|
||||||
} else if (error && step?.status !== 'running') {
|
} else if (error && step?.status !== ExecutionState.RUNNING) {
|
||||||
content = <div>Error: {error.message}</div>
|
content = <div>Error: {error.message}</div>
|
||||||
} else if (streamingLogs.length) {
|
} else if (streamingLogs.length) {
|
||||||
content = <ConsoleLogs logs={streamingLogs} />
|
content = <ConsoleLogs logs={streamingLogs} />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user