Remove clone naming from tasks and update tests

pull/11679/head
Deniz Kusefoglu 2019-02-05 10:57:30 -08:00
parent 6c22c03ac3
commit 1b12892406
5 changed files with 26 additions and 12 deletions

View File

@ -58,14 +58,17 @@ class DashboardList extends PureComponent<Props> {
private handleCloneDashboard = async (
dashboard: Dashboard
): Promise<void> => {
const {router, notify, orgID} = this.props
const {router, notify, orgID, dashboards} = this.props
const name = `${dashboard.name} (clone)`
try {
const data = await cloneDashboard({
...dashboard,
name,
orgID,
})
const data = await cloneDashboard(
{
...dashboard,
name,
orgID,
},
dashboards
)
router.push(`/dashboards/${data.id}`)
} catch (error) {

View File

@ -107,7 +107,7 @@ export default class Tasks extends PureComponent<Props, State> {
}
private handleCloneTask = async (task: Task) => {
await client.tasks.create(task.orgID, task.flux, task.name)
await client.tasks.create(task.orgID, task.flux)
this.props.onChange()
}
}

View File

@ -33,7 +33,6 @@ import {
TaskOptions,
TaskSchedule,
} from 'src/utils/taskOptionsToFluxScript'
import {incrementCloneName} from 'src/utils/naming'
export type Action =
| SetNewScript
@ -247,11 +246,11 @@ export const deleteTask = (task: Task) => async dispatch => {
}
}
export const cloneTask = (task: Task, tasks: Tasks[]) => async dispatch => {
export const cloneTask = (task: Task, _) => async dispatch => {
try {
const allTaskNames = tasks.map(t => t.name)
const clonedName = incrementCloneName(allTaskNames, task.name)
await client.tasks.create(task.orgID, task.flux, clonedName)
// const allTaskNames = tasks.map(t => t.name)
// const clonedName = incrementCloneName(allTaskNames, task.name)
await client.tasks.create(task.orgID, task.flux)
dispatch(notify(taskCloneSuccess(task.name)))
dispatch(populateTasks())

View File

@ -17,6 +17,7 @@ const setup = (override = {}) => {
task: tasks[0],
onActivate: jest.fn(),
onDelete: jest.fn(),
onClone: jest.fn(),
onSelect: jest.fn(),
onEditLabels: jest.fn(),
...override,

View File

@ -75,6 +75,17 @@ exports[`Tasks.Components.TaskRow renders 1`] = `
text="Export"
type="button"
/>
<Button
active={false}
color="secondary"
icon="duplicate"
onClick={[Function]}
shape="none"
size="xs"
status="default"
text="Clone"
type="button"
/>
<ConfirmationButton
confirmText="Confirm"
onConfirm={[MockFunction]}