Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.

Commit 1137e48

Browse files
authored
chore: Promisify connecting and model parsing, use constants for connect views (#248)
1 parent 05d4b86 commit 1137e48

File tree

8 files changed

+313
-209
lines changed

8 files changed

+313
-209
lines changed

.babelrc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@
88
"syntax-object-rest-spread",
99
"transform-object-rest-spread",
1010
"transform-class-properties",
11-
"syntax-dynamic-import"
11+
"syntax-dynamic-import",
12+
"babel-plugin-transform-runtime"
1213
]
1314
}
1415
},
15-
"presets": [ "react", ["env", { "modules": false }] ],
16+
"presets": [ "react", ["env"] ],
1617
"plugins": [
1718
"react-hot-loader/babel",
1819
"syntax-object-rest-spread",
1920
"transform-object-rest-spread",
2021
"transform-class-properties",
21-
"syntax-dynamic-import"
22+
"syntax-dynamic-import",
23+
"babel-plugin-transform-runtime"
2224
]
2325
}

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
"prestart": "electron-rebuild --force --only keytar",
1717
"start": "cross-env NODE_ENV=development webpack-dev-server --config ./config/webpack.dev.config.js",
1818
"start:watch": "npm run clean && webpack --config ./config/webpack.watch.config.js",
19-
"test": "cross-env NODE_ENV=test mocha-webpack \"./src/**/*.spec.js\"",
19+
"test": "npm run test:mocha && npm run test:karma",
2020
"test:watch": "cross-env NODE_ENV=test mocha-webpack \"./src/**/*.spec.js\" --watch",
2121
"test:karma": "npm run prestart && cross-env NODE_ENV=test karma start",
22-
"cover": "nyc npm run test",
22+
"test:mocha": "cross-env NODE_ENV=test mocha-webpack \"./src/**/*.spec.js\"",
23+
"cover": "nyc npm run test:mocha",
2324
"precheck": "npm run compile",
2425
"check": "mongodb-js-precommit './src/**/*{.js,.jsx}' './test/**/*.js' './electron/**/*.js' './config/**/*{.js,.jsx}'",
2526
"link-plugin": "./scripts/link.sh",
@@ -62,6 +63,7 @@
6263
"babel-plugin-transform-class-properties": "^6.24.1",
6364
"babel-plugin-transform-decorators-legacy": "^1.3.5",
6465
"babel-plugin-transform-object-rest-spread": "^6.26.0",
66+
"babel-plugin-transform-runtime": "^6.23.0",
6567
"babel-preset-env": "^1.7.0",
6668
"babel-preset-minify": "^0.3.0",
6769
"babel-preset-react": "^6.24.1",
@@ -114,8 +116,8 @@
114116
"postcss-loader": "^3.0.0",
115117
"prop-types": "^15.5.8",
116118
"react": "^16.8.0",
117-
"react-dom": "^16.8.0",
118119
"react-bootstrap": "^0.32.1",
120+
"react-dom": "^16.8.0",
119121
"react-fontawesome": "^1.6.1",
120122
"react-hot-loader": "^4.1.0",
121123
"react-ios-switch": "^0.1.19",

src/components/connect.jsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import Help from './form/help';
1111
import IsFavoritePill from './form/is-favorite-pill';
1212
import ConfirmEditConnectionString from './modal/confirm-edit-connection-string';
1313

14+
import {
15+
CONNECTION_FORM_VIEW,
16+
CONNECTION_STRING_VIEW
17+
} from '../constants/connection-views';
18+
1419
import styles from './connect.less';
1520

1621
class Connect extends React.Component {
@@ -56,7 +61,7 @@ class Connect extends React.Component {
5661
* @returns {React.Component}
5762
*/
5863
renderConnectScreen() {
59-
if (this.props.viewType === 'connectionString') {
64+
if (this.props.viewType === CONNECTION_STRING_VIEW) {
6065
return <ConnectionString {...this.props} />;
6166
}
6267

@@ -69,12 +74,15 @@ class Connect extends React.Component {
6974
* @returns {React.Component}
7075
*/
7176
renderChangeViewLink() {
72-
if (this.props.viewType === 'connectionString') {
77+
if (this.props.viewType === CONNECTION_STRING_VIEW) {
7378
return (
7479
<div className={classnames(styles['change-view-link'])}>
7580
<a
7681
data-test-id="form-view-link"
77-
onClick={this.onChangeViewClicked.bind(this, 'connectionForm')}
82+
onClick={this.onChangeViewClicked.bind(
83+
this,
84+
CONNECTION_FORM_VIEW
85+
)}
7886
>
7987
Fill in connection fields individually
8088
</a>
@@ -84,7 +92,7 @@ class Connect extends React.Component {
8492

8593
return (
8694
<div className={classnames(styles['change-view-link'])}>
87-
<a onClick={this.onChangeViewClicked.bind(this, 'connectionString')}>
95+
<a onClick={this.onChangeViewClicked.bind(this, CONNECTION_STRING_VIEW)}>
8896
Paste connection string
8997
</a>
9098
</div>

src/components/form/form-actions.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import classnames from 'classnames';
44

55
import Actions from '../../actions';
66
import FormGroup from './form-group';
7+
import { CONNECTION_STRING_VIEW } from '../../constants/connection-views';
78

89
import styles from '../connect.less';
910

@@ -171,7 +172,7 @@ class FormActions extends React.Component {
171172
* @returns {React.Component}
172173
*/
173174
renderEditURI = () => {
174-
if (this.props.viewType === 'connectionString') {
175+
if (this.props.viewType === CONNECTION_STRING_VIEW) {
175176
return (
176177
<button
177178
type="submit"
@@ -194,7 +195,7 @@ class FormActions extends React.Component {
194195
if (
195196
this.props.isSavedConnection &&
196197
!this.props.hasUnsavedChanges &&
197-
this.props.viewType === 'connectionString'
198+
this.props.viewType === CONNECTION_STRING_VIEW
198199
) {
199200
return (
200201
<button
@@ -243,7 +244,7 @@ class FormActions extends React.Component {
243244
colorStyle = styles['connection-message-container-error'];
244245
} else if (
245246
this.hasSyntaxError() &&
246-
this.props.viewType === 'connectionString'
247+
this.props.viewType === CONNECTION_STRING_VIEW
247248
) {
248249
hasMessage = true;
249250
message = this.props.syntaxErrorMessage;

src/constants/connection-views.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const CONNECTION_FORM_VIEW = 'connectionForm';
2+
export const CONNECTION_STRING_VIEW = 'connectionString';

src/helpers/help-items.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
import React from 'react';
44
import Actions from '../actions';
55

6+
import {
7+
CONNECTION_FORM_VIEW,
8+
CONNECTION_STRING_VIEW
9+
} from '../constants/connection-views';
10+
611
/**
712
* Visits help page.
813
*
@@ -82,15 +87,15 @@ const createParagraph = (contect) => React.createElement(
8287
* Components for help items depending on viewType.
8388
*/
8489
export const HelpItems = {
85-
'connectionForm': [
90+
[CONNECTION_FORM_VIEW]: [
8691
{
8792
title: 'How do I find my username and password?',
8893
body: createParagraph([
8994
'If your mongod instance has authentication set up, you\'ll need the credentials of the MongoDB user that is configured on the project.'
9095
])
9196
}
9297
],
93-
'connectionString': [
98+
[CONNECTION_STRING_VIEW]: [
9499
{
95100
title: 'How do I find my connection string in Atlas?',
96101
body: [

0 commit comments

Comments
 (0)