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

Notebooks: Only have One Connection in Attach To Dropdown #8582

Merged
merged 5 commits into from
Dec 8, 2019

Conversation

chlafreniere
Copy link
Contributor

We had overwhelming feedback that our Attach To dropdown had extremely confusing behavior, and was not predictable in what connection we would choose by default.

Changes:

  • Only show one connection at a time for the Attach To dropdown; change from "Add new connection" to "Change connection"
  • Only choose a starting connection when a connection profile is present
  • Remove a good bit of code related to "other" (i.e. not currently active) connections

I added a couple of new tests. @corivera is currently working on tests for notebookActions. I'll work with him to write some new tests for the attach to dropdown.

@github-actions
Copy link

github-actions bot commented Dec 5, 2019

These linting rules are not necessarily related to your code changes. They're setup to bring awareness to code quality issues. Some of the links may be off by a line or two.

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

@lgtm-com
Copy link

lgtm-com bot commented Dec 5, 2019

This pull request introduces 4 alerts when merging 10d5b77 into 0d9353d - view on LGTM.com

new alerts:

  • 2 for JSDoc tag for non-existent parameter
  • 1 for Useless conditional
  • 1 for Undocumented parameter

@github-actions
Copy link

github-actions bot commented Dec 6, 2019

These linting rules are not necessarily related to your code changes. They're setup to bring awareness to code quality issues. Some of the links may be off by a line or two.

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

if (showSelectConnection) {
this.loadWithSelectConnection(connections);
let connections: string[] = model.context && model.context.title ? [model.context.title] : [];
if (connections.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could just have the [] value in the line above be [msgSelectConnection] instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooh i like that. thanks.

public static get DefaultContext(): IDefaultConnection {
let defaultConnection: ConnectionProfile = <any>{
public static get DefaultContext(): ConnectionProfile {
return <any>{
Copy link
Contributor

Choose a reason for hiding this comment

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

any [](start = 10, length = 3)

Why cast to any? Should this be ConnectionProfile?

Copy link
Contributor

Choose a reason for hiding this comment

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

(same below for LocalContext)


In reply to: 354967886 [](ancestors = 354967886)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sigh. These are fake connection profile objects and I really really really don't like it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried to fix it but went down a bit of a rabbit hole, so may have to save that for another PR for more cleanup 😢

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. I think the approach i would try if I was fixing this would be to have a context be ConnectionProfile | DefaultContextType, that way instead of doing stuff like checking ID you just check the type of the object at runtime and use that to determine what you do.


In reply to: 354972934 [](ancestors = 354972934)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes a ton of sense, thanks

@@ -146,8 +146,8 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange
let connectionService = this.connectionService;
if (!shouldConnect && connectionService && connectionService.isConnected(cellUri)) {
connectionService.disconnect(cellUri).catch(e => this.logService.error(e));
} else if (shouldConnect && this._model.activeConnection && this._model.activeConnection.id !== '-1') {
connectionService.connect(this._model.activeConnection, cellUri).catch(e => this.logService.error(e));
} else if (shouldConnect && this._model.context && this._model.context.id !== '-1') {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to have this -1 ID be defined as a const somewhere so it's clear that this is a special ID used for the default context.

// Change the defaultConnection to newConnection
this._activeContexts.defaultConnection = newConnection;
this._activeConnection = newConnection;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment here isn't correct anymore. This whole method is weird anyways, I'm not sure what it's doing since the name (refreshConnections) doesn't seem to match the logic.

conns = NotebookContexts.getActiveContexts(connService.object, [mssqlProviderName], testConn);
assert.deepStrictEqual(conns, defaultContext);
conns = NotebookContexts.getContextForKernel(testConn, [mssqlProviderName, 'fakeProvider']);
assert.deepStrictEqual(conns, testConn);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would suggest adding messages to these so it's clear which one failed without having to look at line numbers

@github-actions
Copy link

github-actions bot commented Dec 7, 2019

These linting rules are not necessarily related to your code changes. They're setup to bring awareness to code quality issues. Some of the links may be off by a line or two.

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

@lgtm-com
Copy link

lgtm-com bot commented Dec 7, 2019

This pull request fixes 1 alert when merging bb5f71f into 6fb120f - view on LGTM.com

fixed alerts:

  • 1 for Function with too many parameters

@github-actions
Copy link

github-actions bot commented Dec 8, 2019

These linting rules are not necessarily related to your code changes. They're setup to bring awareness to code quality issues. Some of the links may be off by a line or two.

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

Rule: no-floating-promises

@lgtm-com
Copy link

lgtm-com bot commented Dec 8, 2019

This pull request fixes 1 alert when merging 2750e82 into de177c0 - view on LGTM.com

fixed alerts:

  • 1 for Function with too many parameters

@chlafreniere chlafreniere merged commit 62565e0 into master Dec 8, 2019
@chlafreniere chlafreniere deleted the feat/oneConnectionNotebook branch December 8, 2019 19:03
ranasaria pushed a commit that referenced this pull request Dec 10, 2019
* Have only one connection in attach to dropdown

* LGTM fixes

* Test fixes not unnecessarily changing context 2x

* PR 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
Development

Successfully merging this pull request may close these issues.

3 participants