bump client version, and use updated client template types to create template
parent
faaac68c56
commit
d2583c9719
|
@ -985,9 +985,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@influxdata/influx": {
|
"@influxdata/influx": {
|
||||||
"version": "0.2.21",
|
"version": "0.2.26",
|
||||||
"resolved": "https://registry.npmjs.org/@influxdata/influx/-/influx-0.2.21.tgz",
|
"resolved": "https://registry.npmjs.org/@influxdata/influx/-/influx-0.2.26.tgz",
|
||||||
"integrity": "sha512-ckXKekCMHR3OcdPCGc2w1/y+Z4ARPTmcFmdYNZJ6biIBGKNV+mKyVB3ATLyTfpZrjYV6YtQtWSe8PurUzc/5fA==",
|
"integrity": "sha512-Zmay0PLHHAATWbRu4uvit6pLDTwy54GlD/V6v1SzbfS1XswhbWZBNXMyALBSN/pWQ/6pafwdotKAK9MqH78Wrg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"axios": "^0.18.0"
|
"axios": "^0.18.0"
|
||||||
}
|
}
|
||||||
|
@ -6085,7 +6085,8 @@
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
|
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"aproba": {
|
"aproba": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
|
@ -6109,13 +6110,15 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
|
@ -6132,19 +6135,22 @@
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
|
||||||
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
|
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"console-control-strings": {
|
"console-control-strings": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
|
||||||
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
|
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
|
@ -6275,7 +6281,8 @@
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
|
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
|
@ -6289,6 +6296,7 @@
|
||||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
|
||||||
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
|
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"number-is-nan": "^1.0.0"
|
"number-is-nan": "^1.0.0"
|
||||||
}
|
}
|
||||||
|
@ -6305,6 +6313,7 @@
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
|
@ -6313,13 +6322,15 @@
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.2.4",
|
"version": "2.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz",
|
||||||
"integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
|
"integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.1",
|
"safe-buffer": "^5.1.1",
|
||||||
"yallist": "^3.0.0"
|
"yallist": "^3.0.0"
|
||||||
|
@ -6340,6 +6351,7 @@
|
||||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
|
@ -6428,7 +6440,8 @@
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
|
||||||
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
|
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"object-assign": {
|
"object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
|
@ -6442,6 +6455,7 @@
|
||||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
|
@ -6537,7 +6551,8 @@
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
||||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
|
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
|
@ -6579,6 +6594,7 @@
|
||||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
||||||
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
|
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"code-point-at": "^1.0.0",
|
"code-point-at": "^1.0.0",
|
||||||
"is-fullwidth-code-point": "^1.0.0",
|
"is-fullwidth-code-point": "^1.0.0",
|
||||||
|
@ -6600,6 +6616,7 @@
|
||||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-regex": "^2.0.0"
|
"ansi-regex": "^2.0.0"
|
||||||
}
|
}
|
||||||
|
@ -6648,13 +6665,15 @@
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz",
|
||||||
"integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=",
|
"integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -137,7 +137,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@influxdata/clockface": "0.0.5",
|
"@influxdata/clockface": "0.0.5",
|
||||||
"@influxdata/influx": "0.2.21",
|
"@influxdata/influx": "0.2.26",
|
||||||
"@influxdata/react-custom-scrollbars": "4.3.8",
|
"@influxdata/react-custom-scrollbars": "4.3.8",
|
||||||
"axios": "^0.18.0",
|
"axios": "^0.18.0",
|
||||||
"babel-polyfill": "^6.26.0",
|
"babel-polyfill": "^6.26.0",
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import {Organization} from 'src/types/v2'
|
import {ScraperTargetRequest, Task, ITaskTemplate} from '@influxdata/influx'
|
||||||
import {ScraperTargetRequest, Task} from '@influxdata/influx'
|
|
||||||
import {client} from 'src/utils/api'
|
import {client} from 'src/utils/api'
|
||||||
import {Template} from 'src/shared/utils/resourceToTemplate'
|
|
||||||
|
|
||||||
export enum ActionTypes {
|
export enum ActionTypes {
|
||||||
GetTasks = 'GET_TASKS',
|
GetTasks = 'GET_TASKS',
|
||||||
|
@ -21,9 +19,8 @@ export const populateTasks = (tasks: Task[]): PopulateTasks => ({
|
||||||
payload: {tasks},
|
payload: {tasks},
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getTasks = (org: Organization) => async dispatch => {
|
export const getTasks = (orgID: string) => async dispatch => {
|
||||||
const tasks = await client.tasks.getAllByOrg(org.name)
|
const tasks = await client.tasks.getAllByOrgID(orgID)
|
||||||
console.log(tasks)
|
|
||||||
dispatch(populateTasks(tasks))
|
dispatch(populateTasks(tasks))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +29,7 @@ export const createScraper = (scraper: ScraperTargetRequest) => async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createTaskFromTemplate = (
|
export const createTaskFromTemplate = (
|
||||||
template: Template,
|
template: ITaskTemplate,
|
||||||
orgID: string
|
orgID: string
|
||||||
) => async dispatch => {
|
) => async dispatch => {
|
||||||
// try catch
|
// try catch
|
||||||
|
|
|
@ -52,7 +52,7 @@ class OrgTasksIndex extends Component<Props, State> {
|
||||||
|
|
||||||
const {getTasks, org} = this.props
|
const {getTasks, org} = this.props
|
||||||
|
|
||||||
await getTasks(org)
|
await getTasks(org.id)
|
||||||
|
|
||||||
this.setState({loadingState: RemoteDataState.Done})
|
this.setState({loadingState: RemoteDataState.Done})
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class OrgTasksIndex extends Component<Props, State> {
|
||||||
private updateTasks = () => {
|
private updateTasks = () => {
|
||||||
const {getTasks, org} = this.props
|
const {getTasks, org} = this.props
|
||||||
|
|
||||||
getTasks(org)
|
getTasks(org.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,64 +1,39 @@
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import {getDeep} from 'src/utils/wrappers'
|
import {getDeep} from 'src/utils/wrappers'
|
||||||
import {Task, Label} from 'src/types/v2'
|
import {Task, Label} from 'src/types/v2'
|
||||||
|
import {ITemplate, TemplateType} from '@influxdata/influx'
|
||||||
|
|
||||||
export enum TemplateType {
|
const CURRENT_TEMPLATE_VERSION = '1'
|
||||||
Label = 'label',
|
|
||||||
Task = 'task',
|
const blankTemplate = {
|
||||||
|
meta: {version: '0.1.0'},
|
||||||
|
content: {data: {}, included: []},
|
||||||
|
labels: [],
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KeyValuePairs {
|
|
||||||
[key: string]: any
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Template {
|
|
||||||
meta: TemplateMeta
|
|
||||||
data: TemplateData[]
|
|
||||||
included?: TemplateIncluded[]
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TemplateMeta extends KeyValuePairs {
|
|
||||||
name: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TemplateData {
|
|
||||||
type: TemplateType
|
|
||||||
attributes: KeyValuePairs
|
|
||||||
relationships?: {[key in TemplateType]?: {data: RelationshipDataItem[]}}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RelationshipDataItem {
|
|
||||||
type: TemplateType
|
|
||||||
id: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TemplateIncluded {
|
|
||||||
type: TemplateType
|
|
||||||
id: string
|
|
||||||
attributes: KeyValuePairs
|
|
||||||
}
|
|
||||||
|
|
||||||
const blankTemplate = {meta: {version: '0.1.0'}, data: [{}], included: []}
|
|
||||||
|
|
||||||
const blankTaskTemplate = {
|
const blankTaskTemplate = {
|
||||||
...blankTemplate,
|
...blankTemplate,
|
||||||
meta: {
|
meta: {
|
||||||
...blankTemplate.meta,
|
...blankTemplate.meta,
|
||||||
labels: [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: 'influx.task',
|
|
||||||
properties: {
|
|
||||||
color: 'ffb3b3',
|
|
||||||
description: 'This is a template for a task resource on influx 2.0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
data: [{...blankTemplate.data[0], type: TemplateType.Task}],
|
content: {
|
||||||
|
...blankTemplate.content,
|
||||||
|
data: {...blankTemplate.content.data, type: TemplateType.Task},
|
||||||
|
},
|
||||||
|
labels: [
|
||||||
|
...blankTemplate.labels,
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
name: 'influx.task',
|
||||||
|
properties: {
|
||||||
|
color: 'ffb3b3',
|
||||||
|
description: 'This is a template for a task resource on influx 2.0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
const labelToRelationship = (l: Label): RelationshipDataItem => {
|
const labelToRelationship = (l: Label) => {
|
||||||
return {type: TemplateType.Label, id: l.id}
|
return {type: TemplateType.Label, id: l.id}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +41,6 @@ const labelToIncluded = (l: Label) => {
|
||||||
return {
|
return {
|
||||||
type: TemplateType.Label,
|
type: TemplateType.Label,
|
||||||
id: l.id,
|
id: l.id,
|
||||||
|
|
||||||
attributes: {
|
attributes: {
|
||||||
name: l.name,
|
name: l.name,
|
||||||
properties: l.properties,
|
properties: l.properties,
|
||||||
|
@ -77,7 +51,7 @@ const labelToIncluded = (l: Label) => {
|
||||||
export const taskToTemplate = (
|
export const taskToTemplate = (
|
||||||
task: Task,
|
task: Task,
|
||||||
baseTemplate = blankTaskTemplate
|
baseTemplate = blankTaskTemplate
|
||||||
): Template => {
|
): ITemplate => {
|
||||||
const taskName = _.get(task, 'name', '')
|
const taskName = _.get(task, 'name', '')
|
||||||
const templateName = `${taskName}-Template`
|
const templateName = `${taskName}-Template`
|
||||||
|
|
||||||
|
@ -95,21 +69,25 @@ export const taskToTemplate = (
|
||||||
const relationshipsLabels = labels.map(l => labelToRelationship(l))
|
const relationshipsLabels = labels.map(l => labelToRelationship(l))
|
||||||
|
|
||||||
const template = {
|
const template = {
|
||||||
|
...baseTemplate,
|
||||||
meta: {
|
meta: {
|
||||||
...baseTemplate.meta,
|
...baseTemplate.meta,
|
||||||
name: templateName,
|
name: templateName,
|
||||||
|
version: CURRENT_TEMPLATE_VERSION,
|
||||||
description: `template created from task: ${taskName}`,
|
description: `template created from task: ${taskName}`,
|
||||||
},
|
},
|
||||||
data: [
|
content: {
|
||||||
{
|
...baseTemplate.content,
|
||||||
...baseTemplate.data[0],
|
data: {
|
||||||
|
...baseTemplate.content.data,
|
||||||
|
type: TemplateType.Task,
|
||||||
attributes: taskAttributes,
|
attributes: taskAttributes,
|
||||||
relationships: {
|
relationships: {
|
||||||
[TemplateType.Label]: {data: relationshipsLabels},
|
[TemplateType.Label]: {data: relationshipsLabels},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
included: [...baseTemplate.content.included, ...includedLabels],
|
||||||
included: [...baseTemplate.included, ...includedLabels],
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return template
|
return template
|
||||||
|
|
Loading…
Reference in New Issue