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

Section table react #15745

Merged
merged 7 commits into from Jun 9, 2017
Merged

Section table react #15745

merged 7 commits into from Jun 9, 2017

Conversation

Bjvanminnen
Copy link
Contributor

@Bjvanminnen Bjvanminnen commented Jun 9, 2017

This is the beginning of the work to convert our Sections table to React. It provides a flag (reactSections) which enabled shows this new table instead of the old one. With the flag off, everything should be identical.
image

It is still very early progress with big pieces missing, but I wanted to have a series of smaller commits instead of one large one. Some big pieces missing

  1. Lots of i18n stuff still missing. Will need to figure out whether I want to pass strings from dashboard to apps, or move these strings into apps.
  2. This is a read only view so far. We don't support editing/deleting sections yet in this new view.
  3. No tests yet.
  4. Right now we still depend on angular to query our data for us. I think we'd eventually like to move that to React.
  5. The design right now still looks largely the same (other than buttons being different). Plan is for this to look more like the sections table on teacher homepage.

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

Very cool. I have some questions but they're things that can probably be addressed in future work on this feature.


this.onClickDelete = this.onClickDelete.bind(this);
this.onClickDeleteNo = this.onClickDeleteNo.bind(this);
this.onClickDeleteYes = this.onClickDeleteYes.bind(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

In the past someone (I think @pcardune?) suggested I use property initializer syntax and arrow functions instead of self-binding in the constructor, e.g.

export default class SectionRow extends Component {
  onClickDelete = () => {
    this.setState({deleting: true});
  };
}

It's clever. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is clever. I think I like it if it works.

Copy link
Contributor

Choose a reason for hiding this comment

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

I learned everything from this blog post: https://babeljs.io/blog/2015/06/07/react-on-es6-plus

this.onClickDeleteYes = this.onClickDeleteYes.bind(this);

this.state = {
editing: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like state.editing is currently unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this will be toggled when you click the Edit button (but that work has not yet been done)

)}
</div>
)}
{this.state.deleting && (
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be nice to extract the buttons here into a functional stateless component in this file. The {!this.state.deleting && and {this.state.deleting && side-by-side subtly suggest four states to me, where you could use a proper if/else in a subcomponent. It also seems likely that this will get more complex as we add the editing states, could extract it then.

<col/>
<col/>
<col/>
</colgroup>
Copy link
Contributor

Choose a reason for hiding this comment

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

Not totally clear what we're doing with colgroup here, but I think we either need to add two <col/> to bring the total up to 9, or remove the tags that don't set a width because they're no-ops right now.

</colgroup>
<tbody>
<tr>
<th style={styles.headerRow}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why isn't our header row in thead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copied this from the haml. Not sure why it wasnt in the head there. Changing the look of this header row is one of the future work items needed. I will look to move it then.

}
};

export default class SectionTable extends Component {
Copy link
Contributor

Choose a reason for hiding this comment

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

React Storybook entry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing yet. Was planning to do that in sync with adding tests as one of my next steps.

export const sectionShape = PropTypes.shape({
id: PropTypes.number.isRequired,
name: PropTypes.string.isRequired,
loginType: PropTypes.oneOf(['word', 'email', 'picture']).isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth making this an enum const somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the only place this is used (at least on the client) so far. If it ends up being used elsewhere, I will consider an enum.

{section.stageExtras ? i18n.yes() : i18n.no()}
</td>
<td>
{section.pairingAllowed ? i18n.yes() : i18n.no()}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@Bjvanminnen Bjvanminnen merged commit 40aedb3 into staging Jun 9, 2017
@Bjvanminnen Bjvanminnen deleted the sectionTableReact branch June 9, 2017 22:13
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

4 participants