Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB -> LB : Create ActivityEditor for Lesson Edit Page #36627

Merged
merged 17 commits into from Sep 16, 2020

Conversation

dmcavoy
Copy link
Contributor

@dmcavoy dmcavoy commented Sep 7, 2020

Creates the ActivitiesEditor which is a GUI for editing activity details of a lesson. It is based on the Script Edit GUI and as part of this work moves the editing of Levels from the Script Edit GUI to this GUI. The GUI shows a side by side of the editing area and a preview of what the activities will look like in the Lesson Plan. Right now the GUI is only viewable in storybook but in the future it will live on the lesson edit page.

Data Model This Will Require

This ActivityEditor uses sample data for right now in the storybook component but that sample data suggests some new models and relationships.

Activity has many Activity Sections
Activity Sections has many Levels (it can have no levels)

Demo

activitiesEditor

Links

Testing story

I added a new unit test file for each new component and added a simple unit test. More tests are needed in these files but I was trying to not have this get any longer right now. Follow up task PLAT-289

Reviewer Checklist:

  • Tests provide adequate coverage
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@dmcavoy dmcavoy changed the base branch from staging to lesson-ui September 8, 2020 17:57
@dmcavoy dmcavoy changed the title Create activity editor CB -> LB : Create ActivityEditor for Lesson Edit Page Sep 8, 2020
Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome progress Dani! A few initial comments inline.

@davidsbailey davidsbailey mentioned this pull request Sep 8, 2020
7 tasks
@uponthesun
Copy link

Just commenting to say I don't think I'll have much to add here.

Base automatically changed from lesson-ui to staging September 10, 2020 00:14
Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still reviewing... here are some more comments so far.

@@ -135,34 +136,34 @@ export class UnconnectedLevelTokenDetails extends Component {

handleAddVariant = () => {
this.props.addVariant(
this.props.lessonGroupPosition,
this.props.lessonPosition,
this.props.activityPosition,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts on whether we could take this opportunity to remove variants from our UI? I don't see them in any 2020 scripts. it could be fine to keep them for now, since they are already implemented... and we could discuss / decide before Jan if we want to launch with these or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variants are only really used to swap out a level mid year if something is wrong with the level right? Are we ok with engineering needed to be involved if this case comes up?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point...I don't have a better solution for that scenario, so since this one is working, it seems better to keep it around. I do still think we can get rid of level variant experiments, but that's a separate issue.

apps/src/lib/levelbuilder/lesson-editor/TipWithTooltip.jsx Outdated Show resolved Hide resolved
expect(wrapper.find('ToggleGroup').length).to.equal(1);
expect(wrapper.find('AddLevelFilters').length).to.equal(1);
expect(wrapper.find('AddLevelTable').length).to.equal(1);
//expect(wrapper.find('LevelToken').length).to.equal(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly not found due to shallow rendering. it's possible you could try mount instead.

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more comments... this PR is a whopper!

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good Dani! Awesome work, this was a huge lift!


/*
An activity section is a chunk of an activity. This could be a section
or text that explains to the teacher what to say or do to run the lesson or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"or text" -> "of text" ? please ignore me if I am mistaken

Comment on lines 130 to 138
{this.props.activitySection.tips.map(tip => {
return (
<LessonTipIconWithTooltip
tip={tip}
key={tip.key}
onClick={this.handleEditTip}
/>
);
})}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this can be written more compactly as:

              {this.props.activitySection.tips.map(tip => (
                <LessonTipIconWithTooltip
                  ...
                />
              ))}

@dmcavoy dmcavoy merged commit f83fee5 into staging Sep 16, 2020
@dmcavoy dmcavoy deleted the create-activity-editor branch September 16, 2020 02:34
activityPosition,
targetActivitySectionPos
} = this.props;
if (targetActivitySectionPos === activitySection.position) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to keep you in suspense here Dani. What I discovered is that when I drag to reorder a script level, the left hand side of the check on this line is null. Digging in a bit, it looks like handleDrag is trying to store information in the state of the parent react component:

const targetActivitySectionPos = this.getTargetActivitySection(clientY);
this.props.setTargetActivitySection(targetActivitySectionPos);
but one problem is that those changes do not necessarily get back down into the ActivitySectionCard in time for the handleDragStop call to happen, because the ActivitySectionCard props only get updated when React's render method is called, which might not be right away.

Thoughts on how to proceed:

  • just moving this into state within the ActivitySectionCard might not be enough, because setState calls do not happen immediately. there may be a way you can force them to be immediate but that might not be what you want since it could cause a re-render which could mess up dragging.
  • ideally you would get your y coordinate from the handleDrag callback directly
  • if that's not possible, you could try storing the clientY info on the react component outside of props/state. not ideal, but likely to be effective.

sorry if you knew most of this but wanted to get my thoughts down since I had spent some time looking at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants