-
Notifications
You must be signed in to change notification settings - Fork 70
Refactor GraphDropdown component from being a child of Graph to being a child of NavBar
#1637
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
base: master
Are you sure you want to change the base?
Refactor GraphDropdown component from being a child of Graph to being a child of NavBar
#1637
Conversation
js/components/graph/Graph.js
Outdated
| import { CourseModal } from "../common/react_modal.js.jsx" | ||
| import { ExportModal } from "../common/export.js.jsx" | ||
| import { getProgram } from "../common/utils.js" | ||
| import { getPost } from "../common/utils.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unrelated to this PR
js/components/common/NavBar.js.jsx
Outdated
| setDropdownTimeouts(dropdownTimeouts.concat(timeout)) | ||
| } | ||
|
|
||
| React.useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation at this line is incorrect
js/components/common/NavBar.js.jsx
Outdated
| } | ||
|
|
||
| React.useEffect(() => { | ||
| const navGraph = document.querySelector("#nav-graph") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of your task is to remove DOM manipulation. This includes accessing DOM elements direction and manually adding callbacks (addEventListener, below). Instead, these callbacks should be managed by the React components themselves. Make sure you understand the existing behaviour (on master) so that you can replicate it with your changes.
js/components/graph/GraphDropdown.js
Outdated
| data-testid={"test-graph-dropdown"} | ||
| style={{ left: graphTabLeft }} | ||
| style={{ left: graphTabLeft, top: "50px", zIndex: 1000 | ||
| }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the }} on the same line as the {{.
Also, in this file there is still direct DOM manipulation, which you should remove by handling the logic in the parent NavBar component.
0325234 to
50c911d
Compare
| - Switched CircleCI ImageMagick download to use http | ||
| - Modified CI config to take advantage of partial dependency caching and exploit parallelism when resolving/updating dependencies | ||
| - Migrate graph-related components (FocusBar, FocusTab, GraphDropdown, GraphFallback, Infobox, and Sidebar) from classes to functions | ||
| - Refactor GraphDropdown component from being a child of Graph to being a child of NavBar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do another merge from master, as I've made a new release; after doing this merge, this entry should be moved into the "unreleased" section.
js/components/common/NavBar.js.jsx
Outdated
| <a href="/graph">Graph</a> | ||
| {selected_page === "graph" && ( | ||
| <GraphDropdown | ||
| showGraphDropdown={showGraphDropdown } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete the extra space
js/components/graph/Graph.js
Outdated
| } | ||
| } | ||
|
|
||
| clearAllTimeouts = timeoutName => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function no longer needs to take an argument (timeoutName is now unused)
js/components/common/NavBar.js.jsx
Outdated
| <li id="nav-graph" className={isActive("graph")}> | ||
| <li | ||
| id="nav-graph" | ||
| className={`${isActive("graph")} show-dropdown-arrow`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the previous version of the code, it looks like show-dropdown-arrow only appeared when there is at least one graph option.
js/components/common/NavBar.js.jsx
Outdated
| * NavBar component. | ||
| */ | ||
| export function NavBar({ selected_page, open_modal }) { | ||
| export function NavBar({ selected_page, open_modal, graphs = [], updateGraph}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include a space before the }
| * @param {bool} value | ||
| */ | ||
| const toggleFocusModal = value => { | ||
| const toggleFocusModal = (value => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert all of the changes in this file (these are all unrelated to the PR)
| } | ||
|
|
||
| const filteredSearch = query => { | ||
| const filteredSearch = (query) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this file are unrelated to this PR
Proposed Changes
GraphDropdowncomponent from being a child of Graph to being a child of NavBarType of Change
(Write an
Xor a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]into a[x]in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request: