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

Fix: Navigation between list and isolated mode issues #676

Closed
wants to merge 8 commits into from

Conversation

sapegin
Copy link
Member

@sapegin sapegin commented Nov 7, 2017

  1. Navigate to isolated example and back: you’ll see only this one
    example, not all of them.
  2. Navigate to isolated example of a component with only one example:
    you’ll see isolated mode button below this example instead of a show
    all components button.

Browser back / forward buttons also seems to work.

Closes #663, #467

1. Navigate to isolated example and back: you’ll see only this one
example, not all of them.
2. Navigate to isolated example of a component with only one example:
you’ll see isolated mode button below this example instead of a show
all components button.

Closes #663, #467
@sapegin sapegin added this to the 6.1.0 milestone Nov 7, 2017
@sapegin sapegin mentioned this pull request Nov 7, 2017
@codecov-io
Copy link

codecov-io commented Nov 7, 2017

Codecov Report

Merging #676 into master will increase coverage by 0.05%.
The diff coverage is 97.54%.

Impacted Files Coverage Δ
src/rsg-components/slots/IsolateButton.js 100% <ø> (ø) ⬆️
...rc/rsg-components/SectionHeading/SectionHeading.js 25% <ø> (ø) ⬆️
.../rsg-components/TableOfContents/TableOfContents.js 94.11% <ø> (ø) ⬆️
loaders/utils/getSections.js 100% <100%> (ø) ⬆️
loaders/utils/processComponent.js 100% <100%> (ø) ⬆️
src/utils/filterSectionsByName.js 100% <100%> (ø)
src/consts.js 100% <100%> (ø)
src/utils/getPageTitle.js 100% <100%> (ø)
src/utils/filterComponentsByExactName.js 100% <100%> (ø)
src/utils/getInfoFromHash.js 100% <100%> (ø)
... and 36 more

@unindented
Copy link
Contributor

Thank you!

Copy link
Member

@okonet okonet left a comment

Choose a reason for hiding this comment

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

LGTM but I'd introduce a constant with all available display modes and import from it instead of using strings.

@@ -6,6 +6,12 @@ import Sections from '../Sections';
import Section from './Section';
import { SectionRenderer } from './SectionRenderer';

const options = {
context: {
displayMode: 'all',
Copy link
Member

Choose a reason for hiding this comment

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

I'd create a enum (Object.freeze) with all available modes and import it any time you reference it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have an example somewhere?

@@ -31,5 +31,5 @@ Section.propTypes = {
};

Section.contextTypes = {
isolatedSection: PropTypes.bool,
displayMode: PropTypes.string,
Copy link
Member

Choose a reason for hiding this comment

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

Instead of saying string it's better to use oneOf propType with exhausting set of values.

@sapegin
Copy link
Member Author

sapegin commented Nov 8, 2017

Yeah, good points. I decided to work on that more and was able isolate, fix and test mutation instead of using a hack with cloneDeep.

By the way how would you ensure that you’re not mutating source objects in tests?

@okonet
Copy link
Member

okonet commented Nov 8, 2017

Not sure about your questions. My points are more about the maintainability. What do you mean by mutating in test? Example?

@sapegin
Copy link
Member Author

sapegin commented Nov 8, 2017

I mean tests to prevent mutation in code. That was exactly the issue here.

@okonet
Copy link
Member

okonet commented Nov 8, 2017

Ah no, I don't know how to tests side-effects.

1. Extract each function to a separate file.
2. Add globalizeComponents function, so getRouteData is now pure.
3. Replace Object.assign with spread operator.
4. Use deepfreeze in tests to prevent mutations.
@sapegin
Copy link
Member Author

sapegin commented Nov 8, 2017

I’ve added deepfreeze to tests, so it should catch mutations. And I’ve removed cloneDeep hack.

I still need to replace strings with an enum.

@sapegin sapegin self-assigned this Nov 8, 2017
@sapegin
Copy link
Member Author

sapegin commented Nov 9, 2017

Merged manually.

@sapegin sapegin closed this Nov 9, 2017
@sapegin sapegin deleted the navigation branch November 9, 2017 15:47
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