Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Show a message when the job list is empty #29

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions frontend/src/pages/Jobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,46 @@ import { useApiSubscription } from '../api/subscription.js'
import { api } from '../api/api.js'
import { Heading } from '../components/Heading.js'
import { JobPanel } from '../components/JobPanel.js'
import { ErrorMessage } from '../components/ErrorMessage.js'

export const Jobs: FunctionComponent = () => {
const { loading, data: jobs } = useApiSubscription({ interval: 5_000 }, api.jobs)
const { loading, data: jobs, error } = useApiSubscription({ interval: 5_000 }, api.jobs)

return (
<div>
<Heading>
Job History
</Heading>
{!loading
? jobs?.map((job) => (
<JobPanel key={`${job.namespace}/${job.name}`} name={job.name} namespace={job.namespace} status={job.status} startTime={job.startTime} manual={job.manual} />
))
: [...Array(8)].map((_, i) => (
<JobPanel key={i} name={undefined} namespace={undefined} status={undefined} startTime={undefined} manual={false} />
))
}
{error != null && (
<ErrorMessage>
Error loading jobs: {error.message}
</ErrorMessage>
)}
{jobs != null && jobs.length === 0 && (
<p>
There are no previous jobs. Once a job is run, it will appear here automatically.
</p>
)}
{jobs?.map((job) => (
<JobPanel
key={`${job.namespace}/${job.name}`}
name={job.name}
namespace={job.namespace}
status={job.status}
startTime={job.startTime}
manual={job.manual}
/>
))}
{loading && [...Array(8)].map((_, i) => (
<JobPanel
key={i}
name={undefined}
namespace={undefined}
status={undefined}
startTime={undefined}
manual={false}
/>
))}
</div>
)
}