From e9d8934094e3070ab7e442121b9532a26e961dea Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Mon, 24 Jun 2019 11:50:07 -0400 Subject: [PATCH 01/12] [PageLayout] add data attribute to prevent Swiftype from indexing sidebar content (#146) * make swiftype exclude sidebar content in `PageLayout` * update snapshots * Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ .../__tests__/__snapshots__/page-layout.test.js.snap | 7 +++++++ src/components/page-layout/page-layout.js | 1 + .../search/__tests__/__snapshots__/search.test.js.snap | 1 + 4 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ce02a389..4d5ba57c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Master + +* Add data attribute to prevent Swiftype from indexing sidebar content on `PageLayout`. [#146](https://github.com/mapbox/dr-ui/pull/146) + ## 0.16.2 * Fix bug where `Search` filter was not displaying with the first query. diff --git a/src/components/page-layout/__tests__/__snapshots__/page-layout.test.js.snap b/src/components/page-layout/__tests__/__snapshots__/page-layout.test.js.snap index 0918c3162..9f29944ad 100644 --- a/src/components/page-layout/__tests__/__snapshots__/page-layout.test.js.snap +++ b/src/components/page-layout/__tests__/__snapshots__/page-layout.test.js.snap @@ -6,6 +6,7 @@ exports[`page-layout Basic renders as expected 1`] = ` >
Date: Tue, 25 Jun 2019 08:29:19 -0400 Subject: [PATCH 02/12] =?UTF-8?q?=F0=9F=90=9Bmake=20compare-versions=20a?= =?UTF-8?q?=20dependency=20(#142)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * make compare-versions a dependency * Update CHANGELOG.md --- CHANGELOG.md | 1 + package-lock.json | 3 +-- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d5ba57c5..453c35ac9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Master * Add data attribute to prevent Swiftype from indexing sidebar content on `PageLayout`. [#146](https://github.com/mapbox/dr-ui/pull/146) +* Add compare-versions as a dependency to support `helpers/version-sort.js`. [#142](https://github.com/mapbox/dr-ui/pull/142) ## 0.16.2 diff --git a/package-lock.json b/package-lock.json index 07c15a43a..040dd7dce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3254,8 +3254,7 @@ "compare-versions": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.4.0.tgz", - "integrity": "sha512-tK69D7oNXXqUW3ZNo/z7NXTEz22TCF0pTE+YF9cxvaAM9XnkLo1fV621xCLrRR6aevJlKxExkss0vWqUCUpqdg==", - "dev": true + "integrity": "sha512-tK69D7oNXXqUW3ZNo/z7NXTEz22TCF0pTE+YF9cxvaAM9XnkLo1fV621xCLrRR6aevJlKxExkss0vWqUCUpqdg==" }, "component-emitter": { "version": "1.3.0", diff --git a/package.json b/package.json index 8f6382188..eb0afde24 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "babel-eslint": "^8.2.6", "babelify": "^10.0.0", "budo": "^11.6.0", - "compare-versions": "^3.4.0", "cpy": "^7.0.1", "cpy-cli": "^2.0.0", "del": "^3.0.0", @@ -70,6 +69,7 @@ "@elastic/search-ui-site-search-connector": "^0.10.0", "@mapbox/mr-ui": "^0.7.0", "classnames": "^2.2.6", + "compare-versions": "^3.4.0", "debounce": "^1.2.0", "downshift": "^3.2.7", "hastscript": "^5.0.0", From 0f39886a11c648af19cb9fdf0ad3cd00fd23f490 Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Wed, 26 Jun 2019 09:45:21 -0400 Subject: [PATCH 03/12] [version-sort] do not push pre-releases of the latest stable version (#148) * [version-sort] do not push prerelease of the lastest stable version * Update CHANGELOG.md --- CHANGELOG.md | 1 + src/helpers/version-sort.js | 8 +++++++- tests/version-sort.test.js | 32 +++++++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 453c35ac9..3fe78dc57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Add data attribute to prevent Swiftype from indexing sidebar content on `PageLayout`. [#146](https://github.com/mapbox/dr-ui/pull/146) * Add compare-versions as a dependency to support `helpers/version-sort.js`. [#142](https://github.com/mapbox/dr-ui/pull/142) +* Fix `version-sort` helper function so it does not push pre-releases of the latest stable version. [#148](https://github.com/mapbox/dr-ui/pull/148) ## 0.16.2 diff --git a/src/helpers/version-sort.js b/src/helpers/version-sort.js index 4403fcf36..8935401f9 100644 --- a/src/helpers/version-sort.js +++ b/src/helpers/version-sort.js @@ -42,7 +42,13 @@ export function sortVersions(versions) { sortPreReleases .sort(sortBy('version')) .reverse() - .map(v => v.version); + .reduce((arr, v) => { + // do not push pre releases of lastest stable + if (!allLatestVersion.test(v.version)) { + arr.push(v.version); + } + return arr; + }, []); const versionsToDisplay = allVersionsOrdered.filter(version => { return !/^(\d|\.)+-(alpha|beta|rc|pre).+/.test(version); diff --git a/tests/version-sort.test.js b/tests/version-sort.test.js index fea65fe2d..deddf5351 100644 --- a/tests/version-sort.test.js +++ b/tests/version-sort.test.js @@ -217,9 +217,7 @@ describe('ios', () => { }); test(`newestPreRelease`, () => { - expect(sortVersions(allIosVersions).newestPreRelease).toEqual([ - '5.0.0-beta.1' - ]); + expect(sortVersions(allIosVersions).newestPreRelease).toEqual([]); }); test(`versionsToDisplay`, () => { expect(sortVersions(allIosVersions).versionsToDisplay).toEqual([ @@ -314,4 +312,32 @@ describe('ios', () => { test(`newestPreRelease, no pre releases`, () => { expect(sortVersions(['4.9.0', '4.8.0']).newestPreRelease).toEqual([]); }); + + test('dont show pre releases of latest stable', () => { + expect( + sortVersions([ + '5.1.0', + '5.1.0-beta.1', + '5.1.0-alpha.2', + '5.1.0-alpha.1', + '5.0.0', + '4.12.0-beta.1', + '4.11.0' + ]) + ).toEqual({ + allLatestVersion: /^5.1.0-.+/, + allVersionsOrdered: [ + '5.1.0', + '5.1.0-beta.1', + '5.1.0-alpha.2', + '5.1.0-alpha.1', + '5.0.0', + '4.12.0-beta.1', + '4.11.0' + ], + latestStable: '5.1.0', + newestPreRelease: [], + versionsToDisplay: ['5.1.0', '5.0.0', '4.11.0'] + }); + }); }); From 81882dcf642cd976f621fcd32eda78da9d9db4b6 Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Wed, 26 Jun 2019 09:45:58 -0400 Subject: [PATCH 04/12] Prepare 0.17.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fe78dc57..e6fd3d1c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## Master +## 0.17.0 * Add data attribute to prevent Swiftype from indexing sidebar content on `PageLayout`. [#146](https://github.com/mapbox/dr-ui/pull/146) * Add compare-versions as a dependency to support `helpers/version-sort.js`. [#142](https://github.com/mapbox/dr-ui/pull/142) From 6ac908ccc702b5fea8264af629545867cdf2b154 Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Wed, 26 Jun 2019 09:46:05 -0400 Subject: [PATCH 05/12] 0.17.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 040dd7dce..1904185bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@mapbox/dr-ui", - "version": "0.16.2", + "version": "0.17.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index eb0afde24..f17fa554d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mapbox/dr-ui", - "version": "0.16.2", + "version": "0.17.0", "description": "Mapbox frontend tools for documentation websites.", "main": "index.js", "scripts": { From 6a9cb283494604d9eb780fbb7006804135c17c7d Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Tue, 9 Jul 2019 08:21:59 -0400 Subject: [PATCH 06/12] Feedback component (#135) * draft feedback * add common use test case * sketch out analytics fn * sketch out tracking * sketch out textarea * add doc type * add site and section props * Update feedback.js * drafts analytics * comments * add snapshot tests * draft * updates * improve comments * rework thanks for your feedback messages to show confirmation * it's _optional_ * This form is for documentation feedback! * comments * move note to bottom * Update CHANGELOG.md --- CHANGELOG.md | 4 + package-lock.json | 3 +- package.json | 3 +- .../__snapshots__/feedback.test.js.snap | 339 ++++++++++++++++++ .../feedback/__tests__/feedback-test-cases.js | 130 +++++++ .../feedback/__tests__/feedback.test.js | 57 +++ src/components/feedback/feedback.js | 161 +++++++++ src/components/feedback/forward-event.js | 58 +++ src/components/feedback/index.js | 3 + 9 files changed, 755 insertions(+), 3 deletions(-) create mode 100644 src/components/feedback/__tests__/__snapshots__/feedback.test.js.snap create mode 100644 src/components/feedback/__tests__/feedback-test-cases.js create mode 100644 src/components/feedback/__tests__/feedback.test.js create mode 100644 src/components/feedback/feedback.js create mode 100644 src/components/feedback/forward-event.js create mode 100644 src/components/feedback/index.js diff --git a/CHANGELOG.md b/CHANGELOG.md index e6fd3d1c9..51bb8b5b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Master + +* Add `Feedback` component. [#135](https://github.com/mapbox/dr-ui/pull/135) + ## 0.17.0 * Add data attribute to prevent Swiftype from indexing sidebar content on `PageLayout`. [#146](https://github.com/mapbox/dr-ui/pull/146) diff --git a/package-lock.json b/package-lock.json index 1904185bf..ac9a8c291 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12377,8 +12377,7 @@ "uuid": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", - "dev": true + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, "validate-npm-package-license": { "version": "3.0.4", diff --git a/package.json b/package.json index f17fa554d..4827b7e7e 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,8 @@ "hastscript": "^5.0.0", "react-html-parser": "^2.0.2", "react-stickynode": "^2.1.1", - "rehype-sectionize-headings": "^1.0.0-rc.1" + "rehype-sectionize-headings": "^1.0.0-rc.1", + "uuid": "^3.3.2" }, "optionalDependencies": { "@mapbox/web-analytics": "^0.5.1" diff --git a/src/components/feedback/__tests__/__snapshots__/feedback.test.js.snap b/src/components/feedback/__tests__/__snapshots__/feedback.test.js.snap new file mode 100644 index 000000000..6517a943e --- /dev/null +++ b/src/components/feedback/__tests__/__snapshots__/feedback.test.js.snap @@ -0,0 +1,339 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`feedback Basic renders as expected 1`] = ` +
+
+
+
+ Was this + page + helpful? +
+ + +
+
+
+`; + +exports[`feedback Change type renders as expected 1`] = ` +
+
+
+
+ Was this + section + helpful? +
+ + +
+
+
+`; + +exports[`feedback Feedback placement renders as expected 1`] = ` +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Section title +
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+

+ Title +

+

+ Vestibulum id ligula porta felis euismod semper. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id ligula porta felis euismod semper. +

+

+ Aenean lacinia bibendum nulla sed consectetur. Maecenas sed diam eget risus varius blandit sit amet non magna. Vestibulum id ligula porta felis euismod semper. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. +

+
+
+
+
+ Was this + page + helpful? +
+ + +
+
+
+
+
+
+
+
+`; diff --git a/src/components/feedback/__tests__/feedback-test-cases.js b/src/components/feedback/__tests__/feedback-test-cases.js new file mode 100644 index 000000000..1325b18ee --- /dev/null +++ b/src/components/feedback/__tests__/feedback-test-cases.js @@ -0,0 +1,130 @@ +import Feedback from '../feedback'; + +import React from 'react'; +import PageLayout from '../../page-layout/page-layout'; +import NavigationAccordion from '../../navigation-accordion/navigation-accordion'; +import TopbarSticker from '../../topbar-sticker/topbar-sticker'; +import ProductMenu from '../../product-menu/product-menu'; + +const testCases = {}; + +testCases.basic = { + component: Feedback, + description: 'Basic', + props: { + site: 'Help', + webhook: { + staging: + 'https://fbtme2z025.execute-api.us-east-1.amazonaws.com/hookshot/webhook', + production: + 'https://2n40g6lyc9.execute-api.us-east-1.amazonaws.com/hookshot/webhook' + }, + location: {} + } +}; + +testCases.type = { + component: Feedback, + description: 'Change type', + props: { + type: 'section', + site: 'Help', + webhook: { + staging: + 'https://fbtme2z025.execute-api.us-east-1.amazonaws.com/hookshot/webhook', + production: + 'https://2n40g6lyc9.execute-api.us-east-1.amazonaws.com/hookshot/webhook' + }, + location: {} + } +}; + +testCases.common = { + description: 'Feedback placement', + element: ( +
+ +
+
+
+
+ +
+
+
+
+
+
+ Section title
} + sidebarContent={ + {}} + /> + } + sidebarContentStickyTop={60} + sidebarContentStickyTopNarrow={0} + sidebarStackedOnNarrowScreens={true} + > +
+

Title

+

+ Vestibulum id ligula porta felis euismod semper. Cum sociis + natoque penatibus et magnis dis parturient montes, nascetur + ridiculus mus. Lorem ipsum dolor sit amet, consectetur adipiscing + elit. Vestibulum id ligula porta felis euismod semper. +

+

+ Aenean lacinia bibendum nulla sed consectetur. Maecenas sed diam + eget risus varius blandit sit amet non magna. Vestibulum id ligula + porta felis euismod semper. Lorem ipsum dolor sit amet, + consectetur adipiscing elit. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Donec id elit non mi porta gravida at eget + metus. Duis mollis, est non commodo luctus, nisi erat porttitor + ligula, eget lacinia odio sem nec elit. +

+ + +
+ +
+
+ ) +}; + +export { testCases }; diff --git a/src/components/feedback/__tests__/feedback.test.js b/src/components/feedback/__tests__/feedback.test.js new file mode 100644 index 000000000..fa86631fa --- /dev/null +++ b/src/components/feedback/__tests__/feedback.test.js @@ -0,0 +1,57 @@ +import React from 'react'; +import renderer from 'react-test-renderer'; +import { testCases } from './feedback-test-cases.js'; + +describe('feedback', () => { + describe(testCases.basic.description, () => { + let testCase; + let wrapper; + let tree; + + beforeEach(() => { + testCase = testCases.basic; + wrapper = renderer.create( + React.createElement(testCase.component, testCase.props) + ); + tree = wrapper.toJSON(); + }); + + test('renders as expected', () => { + expect(tree).toMatchSnapshot(); + }); + }); + + describe(testCases.type.description, () => { + let testCase; + let wrapper; + let tree; + + beforeEach(() => { + testCase = testCases.type; + wrapper = renderer.create( + React.createElement(testCase.component, testCase.props) + ); + tree = wrapper.toJSON(); + }); + + test('renders as expected', () => { + expect(tree).toMatchSnapshot(); + }); + }); + + describe(testCases.common.description, () => { + let testCase; + let wrapper; + let tree; + + beforeEach(() => { + testCase = testCases.common; + wrapper = renderer.create(testCase.element); + tree = wrapper.toJSON(); + }); + + test('renders as expected', () => { + expect(tree).toMatchSnapshot(); + }); + }); +}); diff --git a/src/components/feedback/feedback.js b/src/components/feedback/feedback.js new file mode 100644 index 000000000..94c780163 --- /dev/null +++ b/src/components/feedback/feedback.js @@ -0,0 +1,161 @@ +import React from 'react'; +import ControlTextarea from '@mapbox/mr-ui/control-textarea'; +import PropTypes from 'prop-types'; +import forwardEvent from './forward-event'; +import uuidv4 from 'uuid/v4'; +import Icon from '@mapbox/mr-ui/icon'; + +const anonymousId = uuidv4(); // creates an anonymousId fallback if user is not logged or we cant get their info + +class Feedback extends React.Component { + constructor(props) { + super(props); + this.state = { + helpful: undefined, + feedback: undefined, + feedbackSent: undefined + }; + this.handleText = this.handleText.bind(this); + this.handleYesNo = this.handleYesNo.bind(this); + this.submitFeedback = this.submitFeedback.bind(this); + this.sendToSegment = this.sendToSegment.bind(this); + } + + // pushes the text feedback to the state as the user types + handleText(feedback) { + this.setState({ feedback }); + } + // when user clicks YES or NO, the value is pushed to the state and then sent to segment + handleYesNo(helpful) { + this.setState({ helpful }, () => { + // track helpful rating + this.sendToSegment(); + }); + } + // when user click submit feedback button, the value is pushed to the state and then sent to segment + submitFeedback() { + this.setState({ feedbackSent: true }, () => { + // Track response to Segement + this.sendToSegment(); + }); + } + + // sends all available data to segment + sendToSegment() { + const event = { + event: 'Sent docs feedback', + properties: { + helpful: this.state.helpful, // true, false + site: this.props.site, // name of current site, helpful for filtering in Mode + section: this.props.section || undefined, // (optional) name of section for longer pagers, helpful for fitering in Mode and identifying section areas + feedback: this.state.feedback, // (optional) textarea feedback + page: this.props.location || undefined, // get page context + userId: this.props.userName || undefined // set user if available + } + }; + // if user is logged in then associate feedback with them + // otherwise use the a random/anonymousId + if (this.props.userName) event.userId = this.props.userName; + else event.anonymousId = anonymousId; + // sends event to segment via forward event webhook + forwardEvent(event, this.props.webhook, err => { + if (err) { + console.log(err); // eslint-disable-line + } + }); + } + + render() { + return ( +
+
+ {this.state.helpful === undefined && ( +
+
Was this {this.props.type} helpful?
+ + +
+ )} + + {this.state.helpful !== undefined && ( +
+
+ +
{' '} + Thanks for your feedback. +
+ )} + + {this.state.helpful !== undefined && + this.state.feedbackSent === undefined && ( +
+
+ If you have more specific feedback + {this.state.helpful === false && + ` on how we can improve this ${this.props.type}`} + , you can provide it below (optional): +
+ + + + +
+ This form is for documentation feedback. If you have a + technical question about how to use a Mapbox product,{' '} + + contact Support + + . +
+
+ )} +
+
+ ); + } +} + +Feedback.propTypes = { + type: PropTypes.string, // type of content the user is a evaluating + site: PropTypes.string.isRequired, // the site name, same value as the `site` value passed to ReactPageShell + section: PropTypes.string, // name of section the feedack component falls under + location: PropTypes.object.isRequired, // this prop is generated by batfish and provides context for the current page + webhook: PropTypes.shape({ + staging: PropTypes.string.isRequired, + production: PropTypes.string.isRequired + }), // staging and production webhook URLs to send forward event data to + userName: PropTypes.string // userid if available +}; + +Feedback.defaultProps = { + type: 'page' +}; + +export default Feedback; diff --git a/src/components/feedback/forward-event.js b/src/components/feedback/forward-event.js new file mode 100644 index 000000000..2580c6a4f --- /dev/null +++ b/src/components/feedback/forward-event.js @@ -0,0 +1,58 @@ +/** + * A XHR-powered function that accepts your Segment event, sends it to the endpoint, and then forwards it to Segment. + * Events will be sent to one of two Segment projects: + * 1. mapbox (production) if your host is *.mapbox.com. + * 2. mapbox-staging otherwise. + * + * @param {event} - A Segment event object + * @param {webhook} - Object containing the production and staging webhooks {production: '', 'staging: ''} + * + */ +export default function forwardEvent(event, webhook, callback) { + callback = callback || function() {}; + + // window and event must be present to make the proper request + if (typeof window === 'undefined') return; + if (!event) { + throw new Error('event argument required'); + } + // checks if the current page is on production or staging + // then determines which webhook to post to + const isProduction = /(^|\S+\.)mapbox\.com/.test(window.location.host); + const url = isProduction ? webhook.production : webhook.staging; + + // builds the xhr request to post the Segment event to the webhook + const xhr = new XMLHttpRequest(); + xhr.open('POST', url); + xhr.setRequestHeader('Accept', 'application/json'); + xhr.setRequestHeader('Content-Type', 'application/json'); + xhr.onerror = handleError; + xhr.onload = handleLoad; + xhr.send(JSON.stringify(event)); + + // handles posting the Segment event to the webhook URL + function handleLoad() { + if (xhr.status === 200) { + callback(); + return; + } + + let message; + try { + const response = JSON.parse(xhr.response); + message = response.message; + } catch (parseError) { + message = xhr.response; + } + + const error = new Error('[' + xhr.status + ' HTTP error] ' + message); + error.statusCode = xhr.status; + error.response = xhr.response; + handleError(error); + } + + // handles xhr error + function handleError(error) { + callback(error); + } +} diff --git a/src/components/feedback/index.js b/src/components/feedback/index.js new file mode 100644 index 000000000..2d2aac0df --- /dev/null +++ b/src/components/feedback/index.js @@ -0,0 +1,3 @@ +import main from './feedback'; + +export default main; From 372654834bcc2c1aa8016e4c3e9af9e9a15962bb Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Tue, 9 Jul 2019 12:28:23 -0400 Subject: [PATCH 07/12] 0.18.0 --- CHANGELOG.md | 2 +- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51bb8b5b0..286c81170 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## Master +## 0.18.0 * Add `Feedback` component. [#135](https://github.com/mapbox/dr-ui/pull/135) diff --git a/package-lock.json b/package-lock.json index ac9a8c291..b367540a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@mapbox/dr-ui", - "version": "0.17.0", + "version": "0.18.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4827b7e7e..b53bed8c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mapbox/dr-ui", - "version": "0.17.0", + "version": "0.18.0", "description": "Mapbox frontend tools for documentation websites.", "main": "index.js", "scripts": { From 2a61de670b1564f0aff54d9f851d1c176b9796eb Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Mon, 15 Jul 2019 09:43:37 -0400 Subject: [PATCH 08/12] Update security vulnerabilities in dependencies (#152) * Bump lodash.merge from 4.6.1 to 4.6.2 (#149) Bumps [lodash.merge](https://github.com/lodash/lodash) from 4.6.1 to 4.6.2. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/commits) Signed-off-by: dependabot[bot] * Bump lodash from 4.17.11 to 4.17.14 (#150) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.14. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.14) Signed-off-by: dependabot[bot] * run `npm audit fix` * Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ package-lock.json | 55 ++++++++++++++--------------------------------- 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 286c81170..85baa01dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Master + +* Update security vulnerabilities in dependencies. [#152](https://github.com/mapbox/dr-ui/pull/152) + ## 0.18.0 * Add `Feedback` component. [#135](https://github.com/mapbox/dr-ui/pull/135) diff --git a/package-lock.json b/package-lock.json index b367540a8..af4b515fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8387,9 +8387,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==" }, "lodash.assign": { "version": "4.2.0", @@ -8446,9 +8446,9 @@ "dev": true }, "lodash.merge": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz", - "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==", + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, "lodash.pick": { @@ -8904,9 +8904,9 @@ } }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, "requires": { "for-in": "^1.0.2", @@ -10872,9 +10872,9 @@ "dev": true }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -12130,38 +12130,15 @@ "dev": true }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } + "set-value": "^2.0.1" } }, "unique-string": { From 1e99dc3de20a1f12fd2d8b02906faa0e5b02b14b Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Mon, 15 Jul 2019 09:44:28 -0400 Subject: [PATCH 09/12] 0.18.1 --- CHANGELOG.md | 2 +- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85baa01dc..af951a1d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## Master +## 0.18.1 * Update security vulnerabilities in dependencies. [#152](https://github.com/mapbox/dr-ui/pull/152) diff --git a/package-lock.json b/package-lock.json index af4b515fb..aaf0e4fdb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@mapbox/dr-ui", - "version": "0.18.0", + "version": "0.18.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b53bed8c8..75636b4de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mapbox/dr-ui", - "version": "0.18.0", + "version": "0.18.1", "description": "Mapbox frontend tools for documentation websites.", "main": "index.js", "scripts": { From 94f7bc5fe7271f16a71ad52f83f492ec9be72daf Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Tue, 16 Jul 2019 08:34:58 -0400 Subject: [PATCH 10/12] [search] fix missing proptype (#151) * adds missing proptype * Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ src/components/search/search-box.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af951a1d6..927b79990 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.18.2 + +* Fix missing proptype for `Search`. [#151](https://github.com/mapbox/dr-ui/pull/151) + ## 0.18.1 * Update security vulnerabilities in dependencies. [#152](https://github.com/mapbox/dr-ui/pull/152) diff --git a/src/components/search/search-box.js b/src/components/search/search-box.js index 19230ff21..3b0e86721 100644 --- a/src/components/search/search-box.js +++ b/src/components/search/search-box.js @@ -282,7 +282,8 @@ SearchBox.propTypes = { inputId: PropTypes.string, narrow: PropTypes.bool, disableModal: PropTypes.bool, - site: PropTypes.string + site: PropTypes.string, + wasSearched: PropTypes.bool }; export default SearchBox; From 28d0268d668c1949c8aa8bd40d96d4e53355d0fe Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Tue, 16 Jul 2019 08:35:20 -0400 Subject: [PATCH 11/12] 0.18.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index aaf0e4fdb..0a3b03eda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@mapbox/dr-ui", - "version": "0.18.1", + "version": "0.18.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 75636b4de..65d349802 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mapbox/dr-ui", - "version": "0.18.1", + "version": "0.18.2", "description": "Mapbox frontend tools for documentation websites.", "main": "index.js", "scripts": { From 244a14b9479823452ac56f6f7ace5865ae538450 Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Tue, 16 Jul 2019 15:19:29 -0400 Subject: [PATCH 12/12] Create create-redirect.js (#144) * Create create-redirect.js * Create create-redirect.test.js * fix proptype * Revert "fix proptype" This reverts commit 61c5163157c0e2ee1d876f0acc8ed0d0fd944870. * Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ src/helpers/create-redirect.js | 13 +++++++++++++ tests/create-redirect.test.js | 10 ++++++++++ 3 files changed, 27 insertions(+) create mode 100644 src/helpers/create-redirect.js create mode 100644 tests/create-redirect.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 927b79990..20cde1cbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Master + +* Add create-redirect.js helper function. [#144](https://github.com/mapbox/dr-ui/pull/144) + ## 0.18.2 * Fix missing proptype for `Search`. [#151](https://github.com/mapbox/dr-ui/pull/151) diff --git a/src/helpers/create-redirect.js b/src/helpers/create-redirect.js new file mode 100644 index 000000000..8b8891caa --- /dev/null +++ b/src/helpers/create-redirect.js @@ -0,0 +1,13 @@ +import React from 'react'; + +export function createRedirect(target) { + return class Redirect extends React.Component { + componentDidMount() { + window.location.href = target; + } + + render() { + return null; + } + }; +} diff --git a/tests/create-redirect.test.js b/tests/create-redirect.test.js new file mode 100644 index 000000000..b82b30818 --- /dev/null +++ b/tests/create-redirect.test.js @@ -0,0 +1,10 @@ +'use strict'; + +const { createRedirect } = require('../src/helpers/create-redirect'); + +describe('createRedirect', () => { + it('works', () => { + const fn = createRedirect('/maps/overview/'); + expect(fn).toEqual(expect.any(Function)); + }); +});