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

Create project and feed refactor #41

Merged
merged 33 commits into from
Dec 18, 2018
Merged

Create project and feed refactor #41

merged 33 commits into from
Dec 18, 2018

Conversation

evansiroky
Copy link

Refactor the creation of projects and feed sources to occur on separate pages.

  • Created new routes for creation pages
  • Refactor create project and feed actions
  • New containers/components: CreateProject and CreateFeedSource
  • Refactor GeneralSettings component to be used by both Create Project and ProjectViewer
  • Tidy up and reuse code in various places

@codecov-io
Copy link

codecov-io commented Oct 16, 2017

Codecov Report

Merging #41 into dev will increase coverage by 0.02%.
The diff coverage is 0.61%.

Impacted file tree graph

@@           Coverage Diff            @@
##             dev     #41      +/-   ##
========================================
+ Coverage   5.23%   5.25%   +0.02%     
========================================
  Files        324     328       +4     
  Lines      15405   15580     +175     
  Branches    4649    4680      +31     
========================================
+ Hits         806     819      +13     
- Misses     12449   12602     +153     
- Partials    2150    2159       +9
Impacted Files Coverage Δ
lib/editor/components/HourMinuteInput.js 0% <ø> (ø) ⬆️
lib/common/components/EditableTextField.js 0% <ø> (ø) ⬆️
lib/gtfs/components/gtfs-search.js 0% <ø> (ø) ⬆️
lib/editor/components/ZoneSelect.js 0% <ø> (ø) ⬆️
lib/types/index.js 0% <ø> (ø) ⬆️
lib/editor/components/timetable/Timetable.js 0% <ø> (ø) ⬆️
lib/main.js 0% <ø> (ø) ⬆️
lib/editor/components/pattern/EditSettings.js 0% <ø> (ø) ⬆️
lib/manager/components/version/FeedVersionTabs.js 0% <ø> (ø) ⬆️
lib/gtfs/components/gtfsmapsearch.js 0% <ø> (ø) ⬆️
... and 210 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 79d8bbe...80855c8. Read the comment docs.

Copy link
Member

@landonreed landonreed left a comment

Choose a reason for hiding this comment

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

A couple of comments in the code. Also, I was thinking that these views might actually work better as modals embedded on the ProjectsList (for CreateProject) and ProjectViewer (for CreateFeedSource) components.

Thoughts?


_onInputChange = memoize(
(fieldName: string) => (evt: Event & {target: HTMLInputElement}) => {
const updatedState: State = update(this.state, {
Copy link
Member

Choose a reason for hiding this comment

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

this.setState doesn't need to be used in conjunction with update. this.setState will only modify the key you specify in the object you pass in.

Copy link
Author

Choose a reason for hiding this comment

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

Actually, I do think I want to use it here because I am modifying a subkey of a root key of the state. In this case I'm modifying this.state.model[fieldName].

Copy link
Member

Choose a reason for hiding this comment

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

Ah, you're totally right. I did not read that carefully.

})
}

_onInputChange = memoize(
Copy link
Member

Choose a reason for hiding this comment

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

Why use memoize here and in other onChange functions?

Copy link
Author

Choose a reason for hiding this comment

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

When memoize is used, the handler function does not always need to be recreated which results is less times that a re-render is needed. This pattern is used all over analysis-ui.

this.setState({ validation })
}

render () {
Copy link
Member

Choose a reason for hiding this comment

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

Why not do something similar to CreateProject's use of GeneralSettings and include a shared component here? It seems like that approach would be more maintainable (and reduce duplicated code).

Copy link
Author

Choose a reason for hiding this comment

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

It is different enough that it would get too unwieldy to account for all the differences. The main difference is that all of the fields in the existing FeedSourceSettings component automatically save upon change. In the create version, nothing is saved until you hit the save button.

@landonreed
Copy link
Member

landonreed commented Oct 17, 2017

@evansiroky here's a mockup of where CreateFeedSource might work better (i.e., replacing the FeedSourceTable in ProjectViewer).

image

@evansiroky
Copy link
Author

I'll refactor the CreateFeedSource containers and components so that it'll replace the FeedSourceTable.

@evansiroky
Copy link
Author

@landonreed did we still want to include this?

@landonreed
Copy link
Member

@evansiroky, I think we should include it still, but I must admit I'm a bit afraid of what the merge conflicts will reveal.

@landonreed landonreed mentioned this pull request Aug 21, 2018
@evansiroky evansiroky removed the WIP label Oct 20, 2018
@evansiroky
Copy link
Author

No more merge conflicts. Should be ready to go.

@evansiroky evansiroky assigned landonreed and unassigned evansiroky Oct 20, 2018
@landonreed landonreed assigned evansiroky and unassigned landonreed Nov 15, 2018
@evansiroky
Copy link
Author

Reassigning to Landon as #255 has some requested changes. Also, need the requesting changes review status to change to approved. :)

@evansiroky evansiroky assigned landonreed and unassigned evansiroky Nov 20, 2018
@landonreed
Copy link
Member

landonreed commented Dec 3, 2018

@evansiroky, could you fix up those conflicts so that I can merge?

More changes to come per catalogueglobal/datatools-server#126 (comment).

@evansiroky
Copy link
Author

This PR is now dependent on #271 and ibi-group/datatools-server#151.

@evansiroky
Copy link
Author

Should be ready to merge.

@evansiroky evansiroky removed the WIP label Dec 17, 2018
@evansiroky evansiroky assigned landonreed and unassigned evansiroky Dec 17, 2018
Conflicts:
	lib/manager/actions/projects.js
@landonreed landonreed merged commit 952a304 into dev Dec 18, 2018
@landonreed landonreed deleted the create-project-and-feed branch December 18, 2018 21:30
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.

3 participants