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

Update Jobs List Widget to use IDs #4830

Open
garrettjstevens opened this issue Feb 10, 2025 · 0 comments
Open

Update Jobs List Widget to use IDs #4830

garrettjstevens opened this issue Feb 10, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@garrettjstevens
Copy link
Collaborator

As discussed in #4825, having names be the IDs in the Jobs List Widget has some limitations. If we're willing to make breaking changes, we could use a system where adding a job returns an ID for that job, which can be later used to move that job among different statuses (i.e. running, finished, aborted, queued).

I was thinking something like this:

type JobId = string

interface JobInit {
  name: string
  statusMessage?: string
  progressPct?: number
}

interface Job extends JobInit {
  id: JobId
}

interface StatusMessageUpdate {
  statusMessage: string
}

interface ProgressPctUpdate {
  progressPct: number
}

interface StatusMessageAndProgressPctUpdate {
  statusMessage: string
  progressPct: number
}

type Update =
  | StatusMessageUpdate
  | ProgressPctUpdate
  | StatusMessageAndProgressPctUpdate

interface JobsList {
  queued: Map<JobId, Job>
  running: Map<JobId, Job>
  finished: Map<JobId, Job>
  aborted: Map<JobId, Job>
  /** Add new Job to queued */
  queueJob(job: JobInit): JobId
  /** Add new Job to running */
  runJob(job: JobInit): JobId
  /** Move existing job from queued to running */
  runQueuedJob(id: JobId, update?: Update): void
  updateJob(jobId: JobId, update: Update): void
  /** Move existing job from running to finished */
  finishJob(id: JobId): void
  /** Move existing job from running to aborted */
  abortJob(id: JobId): void
  removeQueuedJob(jobId: JobId): void
  removeRunningJob(jobId: JobId): void
  removeFinishedJob(jobId: JobId): void
  removeAbortedJob(jobId: JobId): void
}

Apollo uses the Jobs List Widget, but it wouldn't be difficult to update its usage to any breaking changes.

@garrettjstevens garrettjstevens added the enhancement New feature or request label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant