本文整理汇总了TypeScript中src/utils/api.client.tasks类的典型用法代码示例。如果您正苦于以下问题:TypeScript client.tasks类的具体用法?TypeScript client.tasks怎么用?TypeScript client.tasks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了client.tasks类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
export const createTaskFromTemplate = async (
template: TaskTemplate,
orgID: string
): Promise<Task> => {
const {content} = template
if (
content.data.type !== TemplateType.Task ||
template.meta.version !== '1'
) {
throw new Error('Can not create task from this template')
}
const flux = content.data.attributes.flux
const createdTask = await client.tasks.createByOrgID(orgID, flux)
if (!createdTask || !createdTask.id) {
throw new Error('Could not create task')
}
// associate imported label.id with created label
const labelMap = await createLabelsFromTemplate(template, orgID)
await addTaskLabelsFromTemplate(template, labelMap, createdTask)
const task = await client.tasks.get(createdTask.id)
return task
}
示例2: async
) => async (dispatch): Promise<void> => {
try {
await client.tasks.removeLabels(taskID, labels.map(l => l.id))
const task = await client.tasks.get(taskID)
dispatch(updateTask(task))
} catch (error) {
console.error(error)
dispatch(notify(copy.removeTaskLabelFailed()))
}
}
示例3: async
export const saveNewScript = (script: string, preamble: string) => async (
dispatch,
getState: GetStateFunc
): Promise<void> => {
try {
const fluxScript = await insertPreambleInScript(script, preamble)
const {
orgs: {org},
} = getState()
await client.tasks.createByOrgID(org.id, fluxScript)
dispatch(setNewScript(''))
dispatch(clearTask())
dispatch(getTasks())
dispatch(goToTasks())
dispatch(notify(taskCreatedSuccess()))
dispatch(checkTaskLimits())
} catch (error) {
console.error(error)
if (isLimitError(error)) {
dispatch(notify(copy.resourceLimitReached('tasks')))
} else {
const message = getErrorMessage(error)
dispatch(notify(taskNotCreated(message)))
}
}
}
示例4: dispatch
export const runTask = (taskID: string) => async dispatch => {
try {
await client.tasks.startRunByTaskID(taskID)
dispatch(notify(taskRunSuccess()))
} catch (error) {
console.error(error)
}
}
示例5: dispatch
export const runTask = (taskID: string) => async dispatch => {
try {
await client.tasks.startRunByTaskID(taskID)
dispatch(notify(taskRunSuccess()))
} catch (error) {
const message = getErrorMessage(error)
dispatch(notify(copy.taskRunFailed(message)))
console.error(error)
}
}