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

fix: refactor pr template path input to pre-filled Select instead of TextBox #4850

Merged
merged 45 commits into from
Sep 13, 2024

Conversation

ndom91
Copy link
Contributor

@ndom91 ndom91 commented Sep 8, 2024

☕️ Reasoning

  • Based on some customer feedback, it seemed smarter to just check the few places where each git host (GitHub in this instance), allows PR Templates to be and show those options in a dropdown. Definitely feels like a much nicer UX and is much less error prone to a user typing in a path themselves.

🧢 Changes

  • Add tauri rust cmd to read the ${project.path}/.github/ dir recursively
    • Then check those contents against the predefined filenames / directories which constitute valid PR templates
    • If found, add them to a vec and return that to the FE
  • Show only valid available template options in a <Select />
  • Modified the saving of these options from global Persisted variables to being saved on a project level in the projects.json
  • Instead of passing the PR Template settings into the githost at initialisation, they're passed in as arguments to the createPr() fn now. This allows reading the current setting value at time of btn click (better) and logically seems more appropriate this way.

Copy link

vercel bot commented Sep 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitbutler-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 13, 2024 10:26am

@github-actions github-actions bot added rust Pull requests that update Rust code @gitbutler/desktop labels Sep 8, 2024
@ndom91 ndom91 changed the title fix: move template input to dropdown instead of text input fix: refactor pr template input to pre-filled <Select /> instead of TextBox Sep 8, 2024
@ndom91 ndom91 changed the title fix: refactor pr template input to pre-filled <Select /> instead of TextBox fix: refactor pr template path input to pre-filled Select instead of TextBox Sep 8, 2024
@ndom91 ndom91 force-pushed the ndom91/use-template-dropdown branch from a6f9ad3 to 7fdbab9 Compare September 9, 2024 12:03
Comment on lines +108 to +111
let project = projects.get(project_id)?;
let template_path = project.path.join(relative_path);

Ok(read_file_from_workspace(template_path.as_path())?)
Copy link
Contributor

Choose a reason for hiding this comment

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

Talking to Nico, we've acknowledged that a path could back out of the directory using ../../../, but due to the size of the PR, we'd rather merge in now, and improve the security in a follow up PR.

Copy link
Contributor

@estib-vega estib-vega left a comment

Choose a reason for hiding this comment

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

👍

@estib-vega estib-vega merged commit 1a47f5e into master Sep 13, 2024
16 checks passed
@estib-vega estib-vega deleted the ndom91/use-template-dropdown branch September 13, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@gitbutler/desktop rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants