From 4f96333b5241aa465ccd5ff060a8ea1038137e96 Mon Sep 17 00:00:00 2001 From: Iris Scholten Date: Tue, 8 Jan 2019 15:05:48 -0800 Subject: [PATCH] feat(ui/labels): display labels in task row --- http/cur_swagger.yml | 10 +- ui/mocks/dummyData.ts | 48 ++++---- ui/src/api/api.ts | 14 ++- ui/src/tasks/components/TaskRow.test.tsx | 47 ++++++++ ui/src/tasks/components/TaskRow.tsx | 38 ++++-- .../__snapshots__/TaskRow.test.tsx.snap | 114 ++++++++++++++++++ .../__snapshots__/TasksList.test.tsx.snap | 19 +++ .../__snapshots__/TasksPage.test.tsx.snap | 19 +++ ui/src/types/v2/tasks.ts | 20 +-- 9 files changed, 281 insertions(+), 48 deletions(-) create mode 100644 ui/src/tasks/components/TaskRow.test.tsx create mode 100644 ui/src/tasks/components/__snapshots__/TaskRow.test.tsx.snap diff --git a/http/cur_swagger.yml b/http/cur_swagger.yml index 5d859195d6..2f9f385295 100644 --- a/http/cur_swagger.yml +++ b/http/cur_swagger.yml @@ -3951,6 +3951,7 @@ components: description: The Flux script to run for this task. type: string Task: + type: object properties: id: readOnly: true @@ -3970,6 +3971,8 @@ components: - inactive owner: $ref: "#/components/schemas/User" + labels: + $ref: "#/components/schemas/Labels" flux: description: The Flux script to run for this task. type: string @@ -3980,8 +3983,13 @@ components: description: A task repetition schedule in the form '* * * * * *'; parsed from Flux. type: string offset: - description: How long to wait before running the task + description: Duration to delay after the schedule, before executing the task; parsed from flux. type: string + latest_completed: + description: Timestamp of latest scheduled, completed run, RFC3339. + type: string + format: date-time + readOnly: true links: type: object readOnly: true diff --git a/ui/mocks/dummyData.ts b/ui/mocks/dummyData.ts index e3ab7a4a9f..527e222a55 100644 --- a/ui/mocks/dummyData.ts +++ b/ui/mocks/dummyData.ts @@ -9,7 +9,7 @@ import { TemplateValueType, } from 'src/types' import {Links} from 'src/types/v2/links' -import {Task, TaskStatus} from 'src/types/v2/tasks' +import {Task} from 'src/types/v2/tasks' import {OnboardingStepProps} from 'src/onboarding/containers/OnboardingWizard' import {WithRouterProps} from 'react-router' import {ConfigurationState} from 'src/types/v2/dataLoaders' @@ -24,6 +24,8 @@ import { TelegrafPluginInputNet, TelegrafPluginInputProcstat, TelegrafPluginInputDocker, + Task as TaskApi, + Label, } from 'src/api' export const links: Links = { @@ -215,6 +217,25 @@ export const dashboard: Dashboard = { labels: [], } +export const labels: Label[] = [ + { + resourceID: 'dashboard-mock-label-a', + name: 'Trogdor', + properties: { + color: '#44ffcc', + description: 'Burninating the countryside', + }, + }, + { + resourceID: 'dashboard-mock-label-b', + name: 'Strawberry', + properties: { + color: '#ff0054', + description: 'It is a great fruit', + }, + }, +] + export const dashboardWithLabels: Dashboard = { id: '1', cells: [], @@ -227,24 +248,7 @@ export const dashboardWithLabels: Dashboard = { createdAt: '2019-01-08T11:57:31.562044-08:00', updatedAt: '2019-01-08T12:57:31.562048-08:00', }, - labels: [ - { - resourceID: 'dashboard-mock-label-a', - name: 'Trogdor', - properties: { - color: '#44ffcc', - description: 'Burninating the countryside', - }, - }, - { - resourceID: 'dashboard-mock-label-b', - name: 'Strawberry', - properties: { - color: '#ff0054', - description: 'It is a great fruit', - }, - }, - ], + labels, } export const cell: Cell = { @@ -265,7 +269,7 @@ export const tasks: Task[] = [ id: '02ef9deff2141000', organizationID: '02ee9e2a29d73000', name: 'pasdlak', - status: TaskStatus.Active, + status: TaskApi.StatusEnum.Active, owner: {id: '02ee9e2a19d73000', name: ''}, flux: 'option task = {\n name: "pasdlak",\n cron: "2 0 * * *"\n}\nfrom(bucket: "inbucket") \n|> range(start: -1h)', @@ -282,12 +286,13 @@ export const tasks: Task[] = [ id: '02ee9e2a29d73000', name: 'RadicalOrganization', }, + labels: [], }, { id: '02f12c50dba72000', organizationID: '02ee9e2a29d73000', name: 'somename', - status: TaskStatus.Active, + status: TaskApi.StatusEnum.Active, owner: {id: '02ee9e2a19d73000', name: ''}, flux: 'option task = {\n name: "somename",\n every: 1m,\n}\nfrom(bucket: "inbucket") \n|> range(start: -task.every)', @@ -304,6 +309,7 @@ export const tasks: Task[] = [ id: '02ee9e2a29d73000', name: 'RadicalOrganization', }, + labels, }, ] diff --git a/ui/src/api/api.ts b/ui/src/api/api.ts index 96a0fca815..7f1e861016 100644 --- a/ui/src/api/api.ts +++ b/ui/src/api/api.ts @@ -2672,6 +2672,12 @@ export interface Task { * @memberof Task */ owner?: User; + /** + * + * @type {Array