<commit_before>React = require 'react'

TimeHelper = require '../../helpers/time'
Icon = require '../icon'
{TaskPlanStore, TaskPlanActions} = require '../../flux/task-plan'
{TaskingActions} = require '../../flux/tasking'
{TeacherTaskPlanStore, TeacherTaskPlanActions} = require '../../flux/teacher-task-plan'

PlanClonePlaceholder = React.createClass

  propTypes:
    planType: React.PropTypes.string.isRequired
    planId:   React.PropTypes.string.isRequired
    courseId: React.PropTypes.string.isRequired
    due_at:   TimeHelper.PropTypes.moment
    onLoad:   React.PropTypes.func.isRequired
    position: React.PropTypes.shape(
      x: React.PropTypes.number
      y: React.PropTypes.number
    ).isRequired

  componentWillMount: ->
    if TaskPlanStore.isLoaded(@props.planId)
      @onLoad()
    else
      TaskPlanStore.on("loaded.#{@props.planId}", @onLoad)

  onLoad: ->
    taskPlanId = TaskPlanStore.freshLocalId()
    TaskPlanActions.createClonedPlan(taskPlanId, {
      planId: @props.planId,
      courseId: @props.courseId,
      due_at: TimeHelper.toISO(@props.due_at)
    })
    TeacherTaskPlanActions.addClonedPlan(@props.courseId, taskPlanId)
    TaskingActions.loadTaskToCourse(taskPlanId, @props.courseId)
    @props.onLoad(taskPlanId)

  render: ->
    <div className="plan-clone-placeholder"
      data-assignment-type={@props.planType}
      style={left: @props.position.x, top: @props.position.y}
    >
      <label>
        <Icon type='spinner' spin /> Adding…<commit_msg>dont need to load task to course here, this is happening in initialize-editing as well<commit_after>React = require 'react'

TimeHelper = require '../../helpers/time'
Icon = require '../icon'
{TaskPlanStore, TaskPlanActions} = require '../../flux/task-plan'
{TaskingActions} = require '../../flux/tasking'
{TeacherTaskPlanStore, TeacherTaskPlanActions} = require '../../flux/teacher-task-plan'

PlanClonePlaceholder = React.createClass

  propTypes:
    planType: React.PropTypes.string.isRequired
    planId:   React.PropTypes.string.isRequired
    courseId: React.PropTypes.string.isRequired
    due_at:   TimeHelper.PropTypes.moment
    onLoad:   React.PropTypes.func.isRequired
    position: React.PropTypes.shape(
      x: React.PropTypes.number
      y: React.PropTypes.number
    ).isRequired

  componentWillMount: ->
    if TaskPlanStore.isLoaded(@props.planId)
      @onLoad()
    else
      TaskPlanStore.on("loaded.#{@props.planId}", @onLoad)

  onLoad: ->
    taskPlanId = TaskPlanStore.freshLocalId()
    TaskPlanActions.createClonedPlan(taskPlanId, {
      planId: @props.planId,
      courseId: @props.courseId,
      due_at: TimeHelper.toISO(@props.due_at)
    })
    TeacherTaskPlanActions.addClonedPlan(@props.courseId, taskPlanId)
    @props.onLoad(taskPlanId)

  render: ->
    <div className="plan-clone-placeholder"
      data-assignment-type={@props.planType}
      style={left: @props.position.x, top: @props.position.y}
    >
      <label>
        <Icon type='spinner' spin /> Adding…
{'fraction_non_alphanumeric': 0.13280212483399734, 'fraction_numerical': 0.0, 'mean_word_length': 3.5104790419161676, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6271876', 'n_tokens_mistral': 972, 'n_tokens_neox': 968, 'n_words': 161}