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

DOCSP-4188: URI Writer #14

Merged
merged 3 commits into from
Feb 19, 2019
Merged

DOCSP-4188: URI Writer #14

merged 3 commits into from
Feb 19, 2019

Conversation

sophstad
Copy link
Member

[JIRA] This PR adds two components associated with the URI Writer:

  • URIWriter.js: a form that allows user to input their own data, from which we generate connection strings
  • URIText.js: replaces placeholders with the URI string. For now, we are only examining text that appears as a Code component, but it would be easy to replace text in any component with a URI string.

@sophstad sophstad force-pushed the DOCSP-4188 branch 2 times, most recently from 725ccc3 to 245ba42 Compare February 11, 2019 19:47
@@ -0,0 +1,267 @@
import React from 'react';
import { mount } from 'enzyme';

Choose a reason for hiding this comment

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

We were thinking about using React testing library for the react component tests but I have to admit I like the way these tests look...the mocking is elegant.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah sorry! I should have checked in first 😣 I am pretty familiar with Enzyme so I went with that—but am happy to update these if we want to go with the other library.

Choose a reason for hiding this comment

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

No this is great, we can keep it.

Copy link
Collaborator

@i80and i80and 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 minor comments!

@@ -62,9 +73,12 @@ export default class GuideSection extends Component {
return <ComponentFactory { ...this.props }
nodeData={ child }
key={ index }
handleUpdateURIWriter={this.handleUpdateURIWriter.bind(this)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Spaces around interior of curly braces

Copy link
Contributor

Choose a reason for hiding this comment

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

I like spaces around interior of curly braces as well

@@ -62,9 +73,12 @@ export default class GuideSection extends Component {
return <ComponentFactory { ...this.props }
nodeData={ child }
key={ index }
handleUpdateURIWriter={this.handleUpdateURIWriter.bind(this)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optionally, use public class fields to avoid the need for .bind()

const TEMPLATE_TYPE_ATLAS_34 = 'Atlas (Cloud) v. 3.4';
const TEMPLATE_TYPE_ATLAS = 'Atlas (Cloud)';

const URI_PLACEHOLDER = '<URISTRING>';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm. We should probably single-source these constants between the two components

return replacePlaceholderWithURI(value, templateType, uri);
}

const replacePlaceholderWithURI = (value, templateType, uri) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm inclined to think that these should be regular function declarations

import URIText from '../src/components/URIText';

describe('local MongoDB', () => {
const templateType = 'local MongoDB'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing semicolon


describe('when called without a placeholder', () => {
it('returns the original string', () => {
const value = `This is the body text`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use single-quotes unless you're actually formatting text

@sophstad
Copy link
Member Author

@i80and thanks! I've addressed your comments, ready for another look.

@i80and i80and merged commit ed15163 into master Feb 19, 2019
@i80and i80and deleted the DOCSP-4188 branch February 19, 2019 16:10
graysonhicks pushed a commit that referenced this pull request Jan 20, 2023
* DOCSP-4188: URI Writer

* Bugfix: implement fully uncontrolled component with key

* Address andrew's feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants