diff --git a/ui/src/tasks/actions/v2/index.ts b/ui/src/tasks/actions/v2/index.ts index 8bfd97d1b2..0da13a0368 100644 --- a/ui/src/tasks/actions/v2/index.ts +++ b/ui/src/tasks/actions/v2/index.ts @@ -50,6 +50,7 @@ export type Action = | SetAllTaskOptions | AddTaskLabels | RemoveTaskLabels + | SetRuns type GetStateFunc = () => AppState interface Task extends TaskAPI { @@ -148,6 +149,13 @@ export interface RemoveTaskLabels { } } +export interface SetRuns { + type: 'SET_RUNS' + payload: { + runs: Run[] + } +} + export const setTaskOption = (taskOption: { key: TaskOptionKeys value: string @@ -200,6 +208,11 @@ export const setDropdownOrgID = (dropdownOrgID: string): SetDropdownOrgID => ({ payload: {dropdownOrgID}, }) +export const setRuns = (runs: Run[]): SetRuns => ({ + type: 'SET_RUNS', + payload: {runs}, +}) + const addTaskLabels = (taskID: string, labels: Label[]): AddTaskLabels => ({ type: 'ADD_TASK_LABELS', payload: { @@ -468,9 +481,14 @@ export const getErrorMessage = (e: any) => { return message } -export const getRuns = async (taskID: string): Promise => { - const runs = await client.tasks.getRunsByTaskID(taskID) - return runs +export const getRuns = (taskID: string) => async (dispatch): Promise => { + try { + const runs = await client.tasks.getRunsByTaskID(taskID) + + dispatch(setRuns(runs)) + } catch (error) { + console.error(error) + } } export const runTask = (taskID: string) => async dispatch => { diff --git a/ui/src/tasks/components/TaskRow.tsx b/ui/src/tasks/components/TaskRow.tsx index 62a52ca858..0fffbe3279 100644 --- a/ui/src/tasks/components/TaskRow.tsx +++ b/ui/src/tasks/components/TaskRow.tsx @@ -70,14 +70,12 @@ export class TaskRow extends PureComponent { {task.latestCompleted} - -