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(ui): added last run status to tasks #16340

Merged
merged 3 commits into from
Dec 27, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
1. [16324](https://github.com/influxdata/influxdb/pull/16324): Add support for tasks to pkger export functionality
1. [16226](https://github.com/influxdata/influxdb/pull/16226): Add group() to Query Builder
1. [16338](https://github.com/influxdata/influxdb/pull/16338): Add last run status to check and notification rules
1. [16340](https://github.com/influxdata/influxdb/pull/16340): Add last run status to tasks

### Bug Fixes

Expand Down
39 changes: 30 additions & 9 deletions ui/src/tasks/components/TaskCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ import {connect} from 'react-redux'
import {withRouter, WithRouterProps} from 'react-router'

// Components
import {SlideToggle, ComponentSize, ResourceCard} from '@influxdata/clockface'
import {
SlideToggle,
ComponentSize,
ResourceCard,
IconFont,
InputLabel,
FlexBox,
} from '@influxdata/clockface'
import {Context} from 'src/clockface'
import InlineLabels from 'src/shared/components/inlineLabels/InlineLabels'
import LastRunTaskStatus from 'src/shared/components/lastRunTaskStatus/LastRunTaskStatus'

// Actions
import {addTaskLabelsAsync, removeTaskLabelsAsync} from 'src/tasks/actions'
Expand All @@ -17,12 +25,11 @@ import {viewableLabels} from 'src/labels/selectors'

// Types
import {ComponentColor} from '@influxdata/clockface'
import {ITask as Task, ILabel} from '@influxdata/influx'
import {AppState, TaskStatus} from 'src/types'
import {ILabel} from '@influxdata/influx'
import {AppState, TaskStatus, Task} from 'src/types'

// Constants
import {DEFAULT_TASK_NAME} from 'src/dashboards/constants'
import {IconFont} from 'src/clockface/types/index'

interface PassedProps {
task: Task
Expand Down Expand Up @@ -69,21 +76,35 @@ export class TaskCard extends PureComponent<Props & WithRouterProps> {
/>
}
metaData={[
this.activeToggle,
<>Last completed at {task.latestCompleted}</>,
<>{`Scheduled to run ${this.schedule}`}</>,
]}
toggle={
<SlideToggle
active={this.isTaskActive}
size={ComponentSize.ExtraSmall}
onChange={this.changeToggle}
testID="task-card--slide-toggle"
<LastRunTaskStatus
lastRunError={task.lastRunError}
lastRunStatus={task.lastRunStatus}
/>
}
/>
)
}

private get activeToggle(): JSX.Element {
const labelText = this.isTaskActive ? 'Active' : 'Inactive'
return (
<FlexBox margin={ComponentSize.Small}>
<SlideToggle
active={this.isTaskActive}
size={ComponentSize.ExtraSmall}
onChange={this.changeToggle}
testID="task-card--slide-toggle"
/>
<InputLabel active={this.isTaskActive}>{labelText}</InputLabel>
</FlexBox>
)
}

private get contextMenu(): JSX.Element {
const {task, onClone, onDelete, onRunTask} = this.props

Expand Down
5 changes: 4 additions & 1 deletion ui/src/types/tasks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import {Task as TaskAPI, ITask} from '@influxdata/influx'

export const TaskStatus = TaskAPI.StatusEnum
export interface Task extends ITask {}
export interface Task extends ITask {
lastRunError?: string
lastRunStatus?: 'failed' | 'success' | 'canceled'
}