Skip to content

Commit ebf07fa

Browse files
authored
VSCODE-98: Add overview page (#178)
1 parent 9c033b4 commit ebf07fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+759
-176
lines changed

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"activationEvents": [
6464
"onCommand:mdb.connect",
6565
"onCommand:mdb.connectWithURI",
66+
"onCommand:mdb.openOverviewPage",
6667
"onCommand:mdb.createPlayground",
6768
"onCommand:mdb.addConnection",
6869
"onCommand:mdb.addConnectionWithURI",
@@ -171,6 +172,10 @@
171172
"command": "mdb.removeConnection",
172173
"title": "MongoDB: Remove Connection..."
173174
},
175+
{
176+
"command": "mdb.openOverviewPage",
177+
"title": "MongoDB: Open Overview Page"
178+
},
174179
{
175180
"command": "mdb.openMongoDBShell",
176181
"title": "MongoDB: Launch MongoDB Shell"
@@ -195,6 +200,10 @@
195200
"command": "mdb.createNewPlaygroundFromViewAction",
196201
"title": "Create MongoDB Playground"
197202
},
203+
{
204+
"command": "mdb.createNewPlaygroundFromOverviewPage",
205+
"title": "Create MongoDB Playground"
206+
},
198207
{
199208
"command": "mdb.createNewPlaygroundFromPlaygroundExplorer",
200209
"title": "Create MongoDB Playground"
@@ -550,6 +559,10 @@
550559
"command": "mdb.createNewPlaygroundFromViewAction",
551560
"when": "false"
552561
},
562+
{
563+
"command": "mdb.createNewPlaygroundFromOverviewPage",
564+
"when": "false"
565+
},
553566
{
554567
"command": "mdb.createNewPlaygroundFromPlaygroundExplorer",
555568
"when": "false"

resources/fonts/AkzidGroStdBol.otf

44.7 KB
Binary file not shown.

resources/fonts/AkzidGroStdReg.otf

44.6 KB
Binary file not shown.

src/commands/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Think RPC handlers.
1616
- `mdb.refresh`
1717

1818
- `mdb.openMongoDBShell`
19+
- `mdb.openOverviewPage`
1920

2021
## General database commands
2122

@@ -47,6 +48,7 @@ Think RPC handlers.
4748
- `mdb.runSelectedPlaygroundBlocks`
4849
- `mdb.runAllPlaygroundBlocks`
4950
- `mdb.createNewPlaygroundFromViewAction`
51+
- `mdb.createNewPlaygroundFromOverviewPage`
5052

5153
## Index commands
5254

src/mdbExtensionController.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ export default class MDBExtensionController implements vscode.Disposable {
110110
this.registerCommand('mdb.connectWithURI', () =>
111111
this._connectionController.connectWithURI()
112112
);
113+
this.registerCommand('mdb.openOverviewPage', () =>
114+
this._webviewController.showOverviewPage(this._context)
115+
);
113116

114117
this.registerCommand('mdb.disconnect', () =>
115118
this._connectionController.disconnect()
@@ -131,6 +134,9 @@ export default class MDBExtensionController implements vscode.Disposable {
131134
this.registerCommand('mdb.createNewPlaygroundFromViewAction', () =>
132135
this._playgroundController.createPlayground()
133136
);
137+
this.registerCommand('mdb.createNewPlaygroundFromOverviewPage', () =>
138+
this._playgroundController.createPlayground()
139+
);
134140
this.registerCommand('mdb.createNewPlaygroundFromPlaygroundExplorer', () =>
135141
this._playgroundController.createPlayground()
136142
);

src/test/suite/extension.test.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ suite('Extension Test Suite', () => {
2020
// General / connection commands.
2121
'mdb.connect',
2222
'mdb.connectWithURI',
23+
'mdb.openOverviewPage',
2324
'mdb.disconnect',
2425
'mdb.removeConnection',
2526
'mdb.openMongoDBShell',
2627
'mdb.createPlayground',
27-
'mdb.createNewPlaygroundFromViewAction',
28+
'mdb.createNewPlaygroundFromOverviewPage',
2829
'mdb.createNewPlaygroundFromPlaygroundExplorer',
30+
'mdb.createNewPlaygroundFromViewAction',
2931

3032
// Tree view commands.
3133
'mdb.addConnection',
@@ -53,16 +55,11 @@ suite('Extension Test Suite', () => {
5355
];
5456

5557
for (let i = 0; i < expectedCommands.length; i++) {
56-
try {
57-
assert.notEqual(
58-
registeredCommands.indexOf(expectedCommands[i]),
59-
-1,
60-
`command ${expectedCommands[i]} not registered and was expected`
61-
);
62-
} catch (e) {
63-
assert(false);
64-
return;
65-
}
58+
assert.notEqual(
59+
registeredCommands.indexOf(expectedCommands[i]),
60+
-1,
61+
`command ${expectedCommands[i]} not registered and was expected`
62+
);
6663
}
6764
});
6865
});

src/test/suite/views/webviewController.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import TelemetryController from '../../../telemetry/telemetryController';
77
import ConnectionController from '../../../connectionController';
88
import { StorageController } from '../../../storage';
99
import WebviewController, {
10-
getConnectWebviewContent,
11-
getReactAppUri
10+
getWebviewContent
1211
} from '../../../views/webviewController';
1312
import { StatusView } from '../../../views';
14-
import { MESSAGE_TYPES } from '../../../views/webview-app/extension-app-message-constants';
13+
import { MESSAGE_TYPES, WEBVIEW_VIEWS } from '../../../views/webview-app/extension-app-message-constants';
1514
import { mdbTestExtension } from '../stubbableMdbExtension';
1615
import { TestExtensionContext } from '../stubs';
1716
import { TEST_DATABASE_URI } from '../dbTestHelper';
@@ -82,8 +81,7 @@ suite('Connect Form View Test Suite', () => {
8281
};
8382

8483
const extensionPath = mdbTestExtension.testExtensionContext.extensionPath;
85-
const appUri = getReactAppUri(extensionPath, fakeWebview);
86-
const htmlString = getConnectWebviewContent(appUri);
84+
const htmlString = getWebviewContent(extensionPath, fakeWebview, WEBVIEW_VIEWS.CONNECT);
8785

8886
assert(htmlString.includes('dist/webviewApp.js'));
8987

src/views/webview-app/components/app.tsx

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,28 @@ import { connect } from 'react-redux';
44

55
import ConnectionForm from './connect-form/connection-form';
66
import HelpPanel from './help-panel/help-panel';
7+
import OverviewPage from './overview-page/overview-page';
78
import {
89
ActionTypes,
910
ConnectionEventOccuredAction,
1011
FilePickerActions,
1112
FilePickerActionTypes
1213
} from '../store/actions';
14+
import { AppState } from '../store/store';
1315
import {
1416
MESSAGE_TYPES,
1517
ConnectResultsMessage,
16-
FilePickerResultsMessage
18+
FilePickerResultsMessage,
19+
WEBVIEW_VIEWS
1720
} from '../extension-app-message-constants';
1821

1922
const styles = require('../connect.module.less');
2023

21-
type props = {
24+
type StateProps = {
25+
currentView: WEBVIEW_VIEWS;
26+
};
27+
28+
type DispatchProps = {
2229
onConnectedEvent: (
2330
successfullyConnected: boolean,
2431
connectionMessage: string
@@ -29,7 +36,7 @@ type props = {
2936
) => void;
3037
};
3138

32-
class App extends React.Component<props> {
39+
class App extends React.Component<DispatchProps& StateProps> {
3340
componentDidMount(): void {
3441
window.addEventListener('message', (event) => {
3542
const message: ConnectResultsMessage | FilePickerResultsMessage =
@@ -54,16 +61,31 @@ class App extends React.Component<props> {
5461
}
5562

5663
render(): React.ReactNode {
64+
const { currentView } = this.props;
65+
5766
return (
58-
<div className={classnames(styles.page, styles.connect)}>
59-
<ConnectionForm />
60-
<HelpPanel />
67+
<div className={styles.page}>
68+
{currentView === WEBVIEW_VIEWS.CONNECT && (
69+
<div className={styles.connect}>
70+
<ConnectionForm />
71+
<div className={classnames(styles['connect-form-help-panel'])}>
72+
<HelpPanel />
73+
</div>
74+
</div>
75+
)}
76+
{currentView === WEBVIEW_VIEWS.OVERVIEW && <OverviewPage />}
6177
</div>
6278
);
6379
}
6480
}
6581

66-
const mapDispatchToProps: props = {
82+
const mapStateToProps = (state: AppState): StateProps => {
83+
return {
84+
currentView: state.currentView
85+
};
86+
};
87+
88+
const mapDispatchToProps: DispatchProps = {
6789
onConnectedEvent: (
6890
successfullyConnected: boolean,
6991
connectionMessage: string
@@ -81,4 +103,4 @@ const mapDispatchToProps: props = {
81103
})
82104
};
83105

84-
export default connect(null, mapDispatchToProps)(App);
106+
export default connect(mapStateToProps, mapDispatchToProps)(App);

src/views/webview-app/components/connect-form/authentication/authentication.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MongoDBAuth from './mongodb-authentication';
1313
import ScramSha256 from './scram-sha-256';
1414
import X509 from './x509';
1515

16-
type dispatchProps = {
16+
type DispatchProps = {
1717
onAuthStrategyChanged: (authStrategy: AUTH_STRATEGIES) => void;
1818
};
1919

@@ -30,7 +30,7 @@ type props = {
3030
mongodbPassword?: string;
3131
mongodbUsername?: string;
3232
x509Username?: string;
33-
} & dispatchProps;
33+
} & DispatchProps;
3434

3535
class Authentication extends React.Component<props> {
3636
static displayName = 'Authentication';
@@ -139,7 +139,7 @@ class Authentication extends React.Component<props> {
139139
}
140140
}
141141

142-
const mapDispatchToProps: dispatchProps = {
142+
const mapDispatchToProps: DispatchProps = {
143143
onAuthStrategyChanged: (newAuthStrategy): AuthStrategyChangedAction => ({
144144
type: ActionTypes.AUTH_STRATEGY_CHANGED,
145145
authStrategy: newAuthStrategy

src/views/webview-app/components/connect-form/authentication/kerberos.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import FormInput from '../form-input';
1111

1212
const styles = require('../../../connect.module.less');
1313

14-
type dispatchProps = {
14+
type DispatchProps = {
1515
kerberosParametersChanged: (newParams: KerberosParameters) => void;
1616
};
1717

@@ -21,7 +21,7 @@ type props = {
2121
kerberosPassword?: string;
2222
kerberosPrincipal?: string;
2323
kerberosServiceName?: string;
24-
} & dispatchProps;
24+
} & DispatchProps;
2525

2626
/**
2727
* The kerberos auth role component.
@@ -165,7 +165,7 @@ class Kerberos extends React.Component<props> {
165165
}
166166
}
167167

168-
const mapDispatchToProps: dispatchProps = {
168+
const mapDispatchToProps: DispatchProps = {
169169
kerberosParametersChanged: (
170170
newKerberosParams
171171
): KerberosParametersChanged => ({

0 commit comments

Comments
 (0)