Skip to content

Improve user experience when no database is selected#3214

Merged
shati-patel merged 3 commits intomainfrom
shati-patel/select-db
Jan 11, 2024
Merged

Improve user experience when no database is selected#3214
shati-patel merged 3 commits intomainfrom
shati-patel/select-db

Conversation

@shati-patel
Copy link
Copy Markdown
Contributor

@shati-patel shati-patel commented Jan 9, 2024

Previously, if you ran a query without having a DB selected, the extension would pop up a file explorer window prompting you to select a database archive from your file system. This isn't the most common way to select a database so it was a fairly confusing pop-up. See internal issue for more info 🔍

Changes

New flow (inspired by designs from the internal issue, though I updated the wording slightly):

  • Choose between an existing or new DB:
    image
  • If you choose "existing", we list the DBs from your DB panel
    image
  • If you choose "new", we offer the different options for importing a DB:
    image

In all cases, we select that DB and run the query against it 🎉 (Note: this also works in the same way for "CodeQL: Debug Query")

Notes

  • Suggestions on wording and code structure very welcome as always! 👀
  • I haven't done anything particularly clever to decide which DBs to display. I just show all of them, without filtering/sorting by language for example. That might be a nice follow-up task, but this seems like a good improvement already 😅

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.
    • No docs update needed

@shati-patel shati-patel marked this pull request as ready for review January 9, 2024 16:28
@shati-patel shati-patel requested review from a team as code owners January 9, 2024 16:28
Copy link
Copy Markdown
Contributor

@norascheuch norascheuch left a comment

Choose a reason for hiding this comment

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

I think the flow looks amazing, just one minor question on the code. Thanks for making these changes! 💐

): Promise<DatabaseItem | undefined> {
if (this.databaseManager.currentDatabaseItem === undefined) {
await this.chooseAndSetDatabase(false, progress);
progress?.progress({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's because progress here is a ProgressContext instead of a regular ProgressCallback. I'm not totally sure why this code uses ProgressContext, but it doesn't seem to be something added by this PR.

You could do something like change the name of progress to progressContext (or whatever you want) and then do

const { progress, token } = progressContext;

and then you can use progress and token as normal.

Or you could go further and basically remove the ProgressContext type. As far as I can tell, we only use it from this file, and we only ever use the progress field from it and never the token field. So arguably we could clean up this code and change all references to ProgressContext to just use ProgressCallback instead.

If that didn't make any sense I'm happy to explain more, or pair on it. We could also save it for a separate PR after this one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! For now, I've just renamed the first progress to progressContext to avoid some confusion. Agreed that the other changes would be nice, but slightly out of scope for this PR 😅

@charisk
Copy link
Copy Markdown
Contributor

charisk commented Jan 10, 2024

Drive by comment, shall we add some tests? Perhaps as a separate issue/PR.

@shati-patel
Copy link
Copy Markdown
Contributor Author

Drive by comment, shall we add some tests? Perhaps as a separate issue/PR.

Yes, I'm keen to add tests as a follow-up PR! 🧪 If I don't get round to it in the next few days, I'll open a new issue too.

@shati-patel shati-patel merged commit 77f84c6 into main Jan 11, 2024
@shati-patel shati-patel deleted the shati-patel/select-db branch January 11, 2024 09:41
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.

4 participants