-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Auto-init repo on license, .gitignore select #12202
Auto-init repo on license, .gitignore select #12202
Conversation
Please don't use globals like that. You can check for the new repo page like this and run your code if the selector matches: if (document.querySelector('.repository.new.repo')) {
// your code here
} |
When a .gitignore or LICENSE file is added, the user is expecting the repository to be auto-initialized. However, nothing sets the auto_init value, so it remains at its default. We should set it to checked when a .gitignore or LICENSE file is added, matching user expectations. If the user clears .gitignore or LICENSE, it will leave repository creation enabled. If the user changes the value again, it will re-check the box if the user has since de-checked it. This behavior is at least consistent. Resolves: go-gitea#11071 Signed-off-by: Alexander Scheel <[email protected]>
9419339
to
63a0256
Compare
Ah gotcha. Probably should migrate the old globals to the newer style sometime... @silverwind Thanks! Updated. Hopefully the jquery style is to your liking. :) |
Co-authored-by: silverwind <[email protected]>
Sorry, was out of internet range. Updated! |
Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
Lint complains about ident |
const gitignores = $('input[name="gitignores"]').prop('checked'); | ||
const license = $('input[name="license"]').prop('checked'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that these are not checkboxes :D These lines should have been:
const gitignores = $('input[name="gitignores"]').val() !== '';
const license = $('input[name="license"]').val() !== '';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right I missed it too. .val()
should be sufficient and possible more future-proof just in case the value of a empty select box ever changes to null
or undefined
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for PR. I don't think jQuery would return null or undefined but not sure. Have not used jQuery for quite some time already 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to do with jQuery, but I guess DOM <input>
value is probably guaranteed to be a string (even for type=number
😆).
I don't know how I messed up that, sorry :) |
When a
.gitignore
orLICENSE
file is added, the user is expecting therepository to be auto-initialized. However, nothing sets the
auto_init
value, so it remains at its default. We should set it to checked when
a
.gitignore
orLICENSE
file is added, matching user expectations. Ifthe user clears
.gitignore
orLICENSE
, it will leave repository creationenabled. If the user changes the value again, it will re-check the box
if the user has since de-checked it. This behavior is at least
consistent.
Resolves: #11071
Signed-off-by: Alexander Scheel <[email protected]>