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

Refactor frontend main page and badge-example code #2441

Merged
merged 29 commits into from
Dec 8, 2018

Conversation

paulmelnikow
Copy link
Member

@paulmelnikow paulmelnikow commented Dec 3, 2018

  • The goal of this PR is:
  • Behavior changes:
    • I changed the Image field in the markup modal to show only the path.
    • I added another click-to-select field below that shows the complete URL.
    • This made it easier to suppress the live badge preview while it contains placeholders like :user or :gem, a minor tweak discussed at namedParams are not interpolated in examples #2427 (comment).
    • The search box now searches all categories, regardless of the current page. (This is an improvement, I would say.)
  • I did not deliberately address performance, though I ripped out a bunch of anonymous functions and avoided re-filtering all the examples by category on every render, which I expect will not hurt. I haven't really tested this on a mobile connection and it'd be worth doing that.
  • It would be great to have some tests of the components, though getting started with that seemed like a big project and I did not want to make this any larger than it already is.

It's a medium-sized refactor:

  1. Replace BadgeExamples, Category and Badge component with a completely rewritten BadgeExamples component which renders a table of badges, and CategoryHeading and CategoryHeadings components.
  2. Refactor ExamplesPage and SearchResults components into a new Main component.
  3. Rewrite the data flow for MarkupModal. Rather than rely on unmounting and remounting the component to copy the badge URL into state, employ the getDerivedStateFromProps lifecycle method.
  4. Remove prepareExamples and all-badge-examples.
  5. Rewrite the $suggest schema to harmonize with the service definition format. It's not backward-compatible which means at deploy time there probably will be 10–20 minutes of downtime on that feature, between the first server deploy and the final gh-pages deploy. 🤷‍♂️ (We could leave the old version in place if it seems worth it.)
  6. Added two new functions in make-badge-url with tests. I removed most of the uses of the old functions, but there are some in parts of the frontend I didn't touch like the static and dynamic badge generators, and again I didn't want to make this any larger than it already is.
  7. Fix a couple bugs in the service-definition export.

@paulmelnikow paulmelnikow added frontend The React app and the infrastructure that supports it blocker PRs and epics which block other work labels Dec 3, 2018
@shields-ci
Copy link

Messages
📖 ✨ Thanks for your contribution to Shields, @paulmelnikow!
📖

Thanks for contributing to our documentation. We ❤️ our documentarians!

Generated by 🚫 dangerJS

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2441 December 3, 2018 03:05 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2441 December 3, 2018 03:06 Inactive
@paulmelnikow
Copy link
Member Author

This pull request introduces 1 alert when merging debfa46 into 0a6afb4 - view on LGTM.com

new alerts:

  • 1 for Unused or undefined state property

Comment posted by LGTM.com

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2441 December 3, 2018 03:15 Inactive
@paulmelnikow
Copy link
Member Author

This pull request introduces 1 alert when merging ea2f1a4 into 0a6afb4 - view on LGTM.com

new alerts:

  • 1 for Unused or undefined state property

Comment posted by LGTM.com

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2441 December 3, 2018 03:30 Inactive
@paulmelnikow
Copy link
Member Author

This pull request introduces 2 alerts when merging b475529 into 0a6afb4 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable
  • 1 for Unused or undefined state property

Comment posted by LGTM.com

Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

Nice one. A few minor bits. I think the main problematic thing is the documentation not rendering in the modals.

frontend/components/main.js Outdated Show resolved Hide resolved
}

asNative() {
return this.definitionData
Copy link
Member

Choose a reason for hiding this comment

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

I find this method name a bit confusing

Copy link
Member Author

Choose a reason for hiding this comment

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

Would toArray() be better?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, that seems more descriptive

frontend/components/markup-modal.js Show resolved Hide resolved
frontend/components/markup-modal.js Outdated Show resolved Hide resolved
Co-Authored-By: paulmelnikow <github@paulmelnikow.com>
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2441 December 8, 2018 17:50 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2441 December 8, 2018 18:57 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2441 December 8, 2018 18:59 Inactive
@paulmelnikow
Copy link
Member Author

This pull request introduces 2 alerts when merging 4409563 into 8a8311d - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable
  • 1 for Unused or undefined state property

Comment posted by LGTM.com

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2441 December 8, 2018 19:19 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2441 December 8, 2018 19:20 Inactive
@paulmelnikow
Copy link
Member Author

This pull request introduces 2 alerts when merging 5240559 into 8a8311d - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable
  • 1 for Unused or undefined state property

Comment posted by LGTM.com

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2441 December 8, 2018 19:50 Inactive
@paulmelnikow
Copy link
Member Author

This pull request introduces 1 alert when merging 74741f7 into 8a8311d - view on LGTM.com

new alerts:

  • 1 for Unused or undefined state property

Comment posted by LGTM.com

Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

think this is good to go

@paulmelnikow
Copy link
Member Author

Awesome. Thanks for reviewing!

@paulmelnikow paulmelnikow merged commit 58b2765 into master Dec 8, 2018
@shields-deployment
Copy link

This pull request was merged to master branch. This change is now waiting for deployment, which will usually happen within a few days. Stay tuned by joining our #ops channel on Discord!

After deployment, changes are copied to gh-pages branch:

@paulmelnikow paulmelnikow deleted the frontend-example-refactor-2 branch December 8, 2018 20:26
@paulmelnikow paulmelnikow mentioned this pull request Dec 10, 2018
12 tasks
@olivierlacan
Copy link
Member

Amazing work with all of this @paulmelnikow! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker PRs and epics which block other work frontend The React app and the infrastructure that supports it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants