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

Don't use a select widget to select from >10 projects #1493

Closed
wants to merge 1 commit into from

Conversation

mythmon
Copy link
Member

@mythmon mythmon commented Jun 28, 2024

This should help when deploying projects to workspaces with many projects.

@mythmon mythmon requested a review from Fil June 28, 2024 20:13
@mythmon mythmon force-pushed the mythmon/240628/too-many-projects branch from fe9ba59 to 110d92f Compare June 28, 2024 20:14
@mbostock
Copy link
Member

Can I see a screenshot of what this looks like?

@Fil
Copy link
Contributor

Fil commented Jun 30, 2024

first step second step
first-step screenshot

I'm not sure we need to list all the names like this, as the list might expand into the hundreds or thousands. If we do list them, they should be ordered alphabetically.

@Fil
Copy link
Contributor

Fil commented Jun 30, 2024

This PR allowed me to redeploy a project, so fixes the issue I had. 👍

@mythmon
Copy link
Member Author

mythmon commented Jul 1, 2024

The UI that I'd really like to have (for both cases) would show a partial list, and allow filtering it by typing. Then once you've narrowed it down you could use arrow keys to select one. Sort of like fzf.

Given that we require them to type a valid slug, I wanted some way to convey the available options. I agree that this version of the UI definitely isn't very elegant in that regard. Maybe we could print the URL to the workspace's project listing instead?

Sorting them would be a good improvement. If we want to keep the list in the CLI, I'll add that.

@mythmon mythmon requested a review from mbostock August 28, 2024 19:18
Copy link
Member

@mbostock mbostock left a comment

Choose a reason for hiding this comment

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

Seems good, just some cosmetic requests.

effects.clack.intro(`${inverse(" observable deploy ")} ${faint(`v${process.env.npm_package_version}`)}`);
effects.clack.intro(
`${inverse(" observable deploy ")}${
process.env.npm_pacakge_version ? faint(` v${process.env.npm_package_version}`) : ""
Copy link
Member

Choose a reason for hiding this comment

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

This gets baked into the code during build, so it shouldn’t be necessary to check this.

define: {"process.env.npm_package_version": `"${process.env.npm_package_version}"`},

@@ -772,6 +776,38 @@ export async function promptDeployTarget(
} else if (chosenProject !== null) {
return {create: false, workspace, project: existingProjects.find((p) => p.slug === chosenProject)!};
}
} else if (existingProjects.length >= 10) {
Copy link
Member

Choose a reason for hiding this comment

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

Any harm in nesting if (existingProjects.length < 10) {…} else {…} here so that we don’t have to repeat the 10 twice and risk a chance that one of the conditions won’t be handled?

Comment on lines +806 to +807
const project = existingProjects.find((p) => p.slug === chosenProject);
if (!project) throw new Error("selected a non-existent project");
Copy link
Member

Choose a reason for hiding this comment

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

Is this possible given the check earlier on L799? Just for safety?

@mbostock
Copy link
Member

I just noticed this appears to be fixed in the top-of-trunk version of clack, but that version has not yet been published to npm?

bombshell-dev/clack#174

But despite not happening automatically, it looks like in the latest released version we are using, it can be set manually, so maybe we should just set it to Math.max(process.stdout.rows - 4, 0) as above?

https://github.com/bombshell-dev/clack/releases/tag/%40clack%2Fprompts%400.7.0

@mythmon
Copy link
Member Author

mythmon commented Aug 28, 2024

Thanks for the review! I didn't realize that was a built-in Clack option. It might take me a little bit to get back to this though.

@mbostock
Copy link
Member

All good @mythmon. I put up #1618 and if you don’t have time, hopefully @Fil can review.

@mythmon
Copy link
Member Author

mythmon commented Aug 28, 2024

Closing in favor of #1618

@mythmon mythmon closed this Aug 28, 2024
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