Skip to content

Commit

Permalink
fix active job-overview
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Nov 25, 2024
1 parent fee8a86 commit 85c3095
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/job-overview/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export default (
padding: 'var(--eds_spacing_large)',
}}
>
<JobOverview appName="MyApp" jobName={name} />
<JobOverview appName="MyApp" jobName={name!} />
</div>
<div>{i < length - 1 && <Divider />}</div>
</Fragment>
Expand Down
20 changes: 10 additions & 10 deletions src/components/job-overview/step-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ const StepDuration: FunctionComponent<Pick<Step, 'started' | 'ended'>> = ({
<>Not yet started</>
);

const StepDescription: FunctionComponent<Pick<Step, 'name' | 'components'>> = ({
name,
components,
}) => {
type StepDescriptionProps = { name?: string; components: Step['components'] };
const StepDescription = ({ name, components }: StepDescriptionProps) => {
const stepDescription = getPipelineStepDescription(name);
if (stepDescription) {
return <>{stepDescription}</>;
Expand All @@ -67,21 +65,23 @@ const StepDescription: FunctionComponent<Pick<Step, 'name' | 'components'>> = ({
);
}

const buildComponent = name.match(/^build-(.+)$/);
const buildComponent = name?.match(/^build-(.+)$/);
if (buildComponent) {
return (
<>
Building <strong>{getComponents(buildComponent[1], components)}</strong>{' '}
Building{' '}
<strong>{getComponents(buildComponent[1], components ?? [])}</strong>{' '}
component
</>
);
}

const scanComponent = name.match(/^scan-(.+)$/);
const scanComponent = name?.match(/^scan-(.+)$/);
if (scanComponent) {
return (
<>
Scanning <strong>{getComponents(scanComponent[1], components)}</strong>{' '}
Scanning{' '}
<strong>{getComponents(scanComponent[1], components ?? [])}</strong>{' '}
component
</>
);
Expand All @@ -102,15 +102,15 @@ export const StepSummary: FunctionComponent<{
to={routeWithParams(routes.appJobStep, {
appName,
jobName,
stepName: step.name,
stepName: step.name ?? '',
})}
link
token={{ textDecoration: 'none', textTransform: 'capitalize' }}
>
<StepDescription name={step.name} components={step.components} />
</Typography>

<RadixJobConditionBadge status={step.status} />
<RadixJobConditionBadge status={step.status ?? 'Waiting'} />
</div>

<div className="step-summary__time">
Expand Down
9 changes: 6 additions & 3 deletions src/components/job-overview/steps-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { Step } from '../../store/radix-api';
import { PipelineStep } from '../../utils/pipeline';
import { sortCompareDate } from '../../utils/sort-utils';

function getStepIcon({ name }: Step): IconData {
function getStepIcon(name: string): IconData {
switch (name) {
case PipelineStep.CloneConfig:
case PipelineStep.CloneRepository:
Expand Down Expand Up @@ -65,12 +65,15 @@ export const StepsList: FunctionComponent<{
sortCompareDate(
a.started ?? new Date('9999-01-01T00:00:00Z'),
b.started ?? new Date('9999-01-01T00:00:00Z')
) ?? a.name.localeCompare(b.name)
) ?? a.name?.localeCompare(b.name ?? '')
)
.map((step) => (
<div key={getStepKey(step)} className="steps-list__step">
<div className="grid steps-list__divider">
<Icon className="step__icon" data={getStepIcon(step)} />
<Icon
className="step__icon"
data={getStepIcon(step.name ?? '')}
/>
<span className="steps-list__divider-line" />
</div>
<StepSummary appName={appName} jobName={jobName} step={step} />
Expand Down
6 changes: 3 additions & 3 deletions src/components/jobs-list/job-summary-table-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const JobSummaryTableRow: FunctionComponent<{
className="job-summary__id-section"
to={routeWithParams(routes.appJob, { appName, jobName: job.name })}
>
{job.triggeredBy?.length > 25 ? (
{job.triggeredBy && job.triggeredBy.length > 25 ? (
<Tooltip placement="top" title={job.triggeredBy}>
<div>
{`${job.triggeredBy.substring(0, 8)}...${job.triggeredBy.slice(
Expand All @@ -32,7 +32,7 @@ export const JobSummaryTableRow: FunctionComponent<{
) : (
<div>{job.triggeredBy || 'N/A'}</div>
)}
<CommitHash commit={job.commitID} />
<CommitHash commit={job.commitID ?? ''} />
</Link>
</Table.Cell>
<Table.Cell>
Expand Down Expand Up @@ -66,7 +66,7 @@ export const JobSummaryTableRow: FunctionComponent<{
</div>
</Table.Cell>
<Table.Cell variant="icon">
<RadixJobConditionBadge status={job.status} />
<RadixJobConditionBadge status={job.status ?? 'Waiting'} />
</Table.Cell>
<Table.Cell>{job.pipeline}</Table.Cell>
</Table.Row>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/pipeline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export enum PipelineStep {
BuildComponent = 'build',
}

export function getPipelineStepDescription(stepName: string): string | null {
export function getPipelineStepDescription(stepName?: string): string | null {
switch (stepName) {
case PipelineStep.CloneConfig:
return 'Cloning Radix config from config branch';
Expand Down

0 comments on commit 85c3095

Please sign in to comment.