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

Add option to disable commit message length warning #17370

Merged
merged 9 commits into from
Sep 20, 2023

Conversation

rystills
Copy link
Contributor

Partially satisfies #14255

Description

This PR adds a checkbox to the advanced settings to toggle the 50-character commit message length nag.
2 TODOs were added due to my uncertainty in accessing properties and in localStorage string literal storage (these should be resolved before merging).

Screenshots

image

Release notes

Notes: added commit message length warning toggle

Copy link
Contributor

@tidy-dev tidy-dev left a comment

Choose a reason for hiding this comment

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

@rystills Thank you for this PR! We actually had this work planned soon as we are intending to refactor the commit length warning to be a little more apparent for accessibility purposes.

This appear to be on the right track. We have a few requests that you can find in a various PR review comments, but to recap:

  1. We would prefer this to live under the "Prompts" settings.
  2. The state and local storage to be handled in the app-state and app-store.

There is one last thing to consider and I am going to check with my teammates on it and then circle back. That is, we would like this to be false by default for new installations, but keep it enabled for current installations. We may do it based on version number, but have not found an example of this. Alternatively, we ship it as true by default and then flip it later down the road when we add in the accessibility work.

@@ -554,6 +556,8 @@ export class AppStore extends TypedBaseStore<IAppState> {

if (__WIN32__) {
const useWindowsOpenSSH = getBoolean(UseWindowsOpenSSHKey)
// TODO: is it ok to use a string literal here?
Copy link
Contributor

@tidy-dev tidy-dev Sep 11, 2023

Choose a reason for hiding this comment

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

Looking at the implementation of askForConfirmationOnRepositoryRemoval may be helpful reference as it is a similar setting.

Preferably,

  • we set a key as constant at the top of file, see the confirmRepoRemovalKey as the example for the askForConfirmationOnRepositoryRemoval prompt setting.
  • Additionally, as the location of this initialization is not quite ideal especially given this is in a Windows only if block and we would like applied to all operating systems. We typically initialize these in the loadInitialState() method. You can see askForConfirmationOnRepositoryRemoval on line 2095.
  • Also add a 'Default" const, you can see this as confirmRepoRemovalDefault in the above example. Set it to true for now please.

@@ -3532,6 +3537,12 @@ export class AppStore extends TypedBaseStore<IAppState> {
this.emitUpdate()
}

public _setShowCommitLengthWarning(showCommitLengthWarning: boolean) {
setBoolean("showCommitLengthWarning", showCommitLengthWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting again for other comment -> prefer the use of a constant set at the top of file.

@@ -235,6 +237,9 @@ export class CommitMessage extends React.Component<
isCommittingStatusMessage: '',
repoRulesEnabled: false,
isRuleFailurePopoverOpen: false,
// TODO: do a proper retrieval rather than pinging localStorage (use AppState?)
// (current solution requires a tab switch to hot reload)
showCommitLengthWarning: localStorage.getItem("showCommitLengthWarning") === "1",
Copy link
Contributor

Choose a reason for hiding this comment

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

The getBoolean you are using on line 556 is the call to the localStorage so you were already on the right track. :) When you put that in the loadInitialState, it will populate the appState correctly from local storage. Then, you need to pass it down through the props, I believe if you follow commitSpellcheckEnabled, you can see how to it gets from App.tsx in the renderRepository down through multiple components to this file. :)

Then you will no longer needs a showCommitLengthWarning state variable on this component as you will be able to use this.props.showCommitLengthWarning

@rystills
Copy link
Contributor Author

@rystills Thank you for this PR! We actually had this work planned soon as we are intending to refactor the commit length warning to be a little more apparent for accessibility purposes.

This appear to be on the right track. We have a few requests that you can find in a various PR review comments, but to recap:

  1. We would prefer this to live under the "Prompts" settings.
  2. The state and local storage to be handled in the app-state and app-store.

There is one last thing to consider and I am going to check with my teammates on it and then circle back. That is, we would like this to be false by default for new installations, but keep it enabled for current installations. We may do it based on version number, but have not found an example of this. Alternatively, we ship it as true by default and then flip it later down the road when we add in the accessibility work.

Hi @tidy-dev. I don't work with typescript very often so I appreciate the thorough feedback! I made the requested changes but I ended up adjusting more files than I expected, so please let me know if any of my changes are redundant and should be removed. Regarding the default value, I can't think of anything clever beyond checking the version number on init like you mentioned, but I'll be sure to keep it in mind.

Copy link
Contributor

@tidy-dev tidy-dev left a comment

Choose a reason for hiding this comment

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

@rystills Thank you for the changes and for the wait on further feedback. I went investigating what we might like to do for local storage management and just got the chance to circle back.

Couple things:

  • I have added many suggestions to remove the prop passing that appears unused. I am assuming you likely added them since I gave the commitSpellCheck example. The commitSpellCheck had a bit more use case then this tho. We only want to add this where is is currently being used.
  • local storage management -> I am exploring another possible route with our local storage management and thus for now, I have a suggestion to copy an existing pattern in the code for storing a current behavior. We will handle switching that default in a later PR. :)

app/src/lib/stores/app-store.ts Outdated Show resolved Hide resolved
app/src/lib/stores/app-store.ts Show resolved Hide resolved
app/src/ui/autocompletion/autocompleting-text-input.tsx Outdated Show resolved Hide resolved
app/src/ui/changes/changes-list.tsx Outdated Show resolved Hide resolved
app/src/ui/changes/changes-list.tsx Outdated Show resolved Hide resolved
app/src/ui/changes/commit-message.tsx Outdated Show resolved Hide resolved
app/src/ui/commit-message/commit-message-dialog.tsx Outdated Show resolved Hide resolved
app/src/ui/commit-message/commit-message-dialog.tsx Outdated Show resolved Hide resolved
app/src/ui/preferences/prompts.tsx Show resolved Hide resolved
app/src/ui/preferences/prompts.tsx Outdated Show resolved Hide resolved
Co-authored-by: tidy-dev <75402236+tidy-dev@users.noreply.github.com>
@rystills
Copy link
Contributor Author

@rystills Thank you for the changes and for the wait on further feedback. I went investigating what we might like to do for local storage management and just got the chance to circle back.

Couple things:

  • I have added many suggestions to remove the prop passing that appears unused. I am assuming you likely added them since I gave the commitSpellCheck example. The commitSpellCheck had a bit more use case then this tho. We only want to add this where is is currently being used.
  • local storage management -> I am exploring another possible route with our local storage management and thus for now, I have a suggestion to copy an existing pattern in the code for storing a current behavior. We will handle switching that default in a later PR. :)

Thanks for the assistance. I figured most of that property passing was unnecessary, but I wasn't familiar enough with the dependency graph to confidently prune it. Should be all set now.

Copy link
Contributor

@tidy-dev tidy-dev left a comment

Choose a reason for hiding this comment

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

✨ Thank you for all those changes! It works great.

@tidy-dev tidy-dev merged commit 69091a3 into desktop:development Sep 20, 2023
7 checks passed
Copy link

@Belcher91 Belcher91 left a comment

Choose a reason for hiding this comment

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

No

@niik niik mentioned this pull request Nov 8, 2023
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.

None yet

3 participants