Remove clone naming from tasks and update tests
parent
6c22c03ac3
commit
1b12892406
|
@ -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) {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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]}
|
||||
|
|
Loading…
Reference in New Issue