-
Notifications
You must be signed in to change notification settings - Fork 983
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
Fixes #21170 - move password strength meter logic to react #4882
Conversation
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
webpack/stories/index.js
Outdated
@@ -14,6 +14,7 @@ import PowerStatusInner from | |||
import Store from '../assets/javascripts/react_app/redux'; | |||
import Toast from '../assets/javascripts/react_app/components/toastNotifications/toastListitem'; | |||
import StorageContainer from '../assets/javascripts/react_app/components/hosts/storage/vmware'; | |||
import PasswordStrength from '../assets/javascripts/react_app/components/passwordStrength' |
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.
Missing semicolon semi
else { | ||
form.removeClass('has-success has-error'); | ||
} | ||
} |
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.
Closing curly brace does not appear on the same line as the subsequent block brace-style
if (password !== '') { | ||
html = __('Password match'); | ||
form.removeClass('has-error').addClass('has-success'); | ||
} |
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.
Closing curly brace does not appear on the same line as the subsequent block brace-style
@@ -47,3 +47,25 @@ export function testMail(item, url, param = {}) { | |||
} | |||
}); | |||
} | |||
|
|||
export function verifyPassword() { |
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.
Function 'verifyPassword' has too many statements (12). Maximum allowed is 10 max-statements
@Rohoover What do you say about the color scheme? |
I think it jumps from orange to green. Maybe a yellow in between for Weak - Red |
app/views/users/_form.html.erb
Outdated
@@ -41,8 +40,13 @@ | |||
<% if User.current == @user %> | |||
<%= password_f f, :current_password, :label => _('Current password'), :placeholder => '' %> | |||
<% end %> | |||
<%= password_f f, :password, :label => _('Password'), :error => @user.errors[:password_hash] %> | |||
<%= password_f f, :password_confirmation, :label => _('Verify') %> | |||
<div class="clearfix" id="password_react"></div> |
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.
Is the .clearfix
needed here?
|
||
return ( | ||
<div className={`form-group ${error.length > 0 ? 'has-error' : ''}`}> | ||
<label className="col-md-2 control-label"> { __('Password') } </label> |
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.
This label should include a for
attribute to tie it to the input below for accessibility.
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 suggest to use the CommonForm component instead of redefining it here (https://github.com/theforeman/foreman/blob/develop/webpack/assets/javascripts/react_app/components/common/forms/CommonForm.js)
@@ -0,0 +1,10 @@ | |||
.ReactPasswordStrength-input { | |||
width: 100% !important; |
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.
Can we style this without the !important
s? Maybe add additional classes or elements to the selector if you need more specificity.
</div> | ||
{ error.length > 0 && | ||
<span className="help-block help-inline"> | ||
<span className="error-message"> {error[0]} </span> |
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.
could there be more than one error? should we only display the first one?
@@ -25,4 +25,4 @@ const CommonForm = ({ | |||
); | |||
}; | |||
|
|||
export default CommonForm; | |||
export default CommonForm; |
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.
Newline required at end of file but not found eol-last
@@ -25,4 +25,4 @@ const CommonForm = ({ | |||
); | |||
}; | |||
|
|||
export default CommonForm; | |||
export default CommonForm; |
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.
Newline required at end of file but not found eol-last
@waldenraines I've mentioned your comments. I've changed color pattern to @Rohoover suggestion |
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.
Looks good to me!
@Rohoover |
Copying out notes from UX demo with @Rohoover about this:
While I think most of it is addressed and it's a great improvement already, I think there are some other things that could be considered while it's being touched.
Also when this gets in, please update/close http://projects.theforeman.org/issues/20740 which tracked this originally :-) |
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.
Good to me! 👍
@amirfefer please rebase. |
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.
Initial review looks good - I've added a few comments inline.
Please also adds action/reducers tests.
Thanks!
passwordNotMatched, | ||
} from './passwordStrength.fixtures'; | ||
|
||
configure({ adapter: new Adapter() }); |
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.
these setup are no longer need (see webpack/test_setup.js)
configure({ adapter: new Adapter() }); | ||
|
||
jest.unmock('./'); | ||
global.__ = jest.fn(); |
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.
not required anymore
function setup(verify, error, state) { | ||
const store = mockStore(state); | ||
|
||
return mount(<PasswordStrength |
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.
would shallow work here too?
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.
shallow doesn't render inner components therefore the resulted snapshot lacks in inner content
inputProps={{ | ||
name, | ||
id, | ||
className: `${className}`, |
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.
do you really need the string interrelation here? I think the following would just work:
inputProps={{ name, id, className }}
<CommonForm | ||
label={__('Verify')} | ||
touched={true} | ||
error={matchMessage ? verify.error : __('Password do not matched')} |
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.
The original string was passwords do not match
@ohadlevy thanks, I've fixed and rebased. would you mind take another look? |
@amirfefer Is the test failure in the foreman test related to these changes? |
ping @amirfefer |
I've fixed the users integration test, |
@amirfefer please rebase I guess the travis test "failures" also need fixing/updating... |
Rebased. |
@amirfefer anything left here? |
@@ -1 +1,7 @@ | |||
$pf-black-200: #ededed; | |||
$pf-red-200: #a30000; |
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.
can we use this from the patternfly package? @sharvit ?
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.
When my css pr will merge you would be able to import variables:
https://github.com/theforeman/foreman/pull/5212/files#diff-f430da9fad5e785cb1f815fd719fdc5aR1
@amirfefer can you please also include
|
@ohadlevy - done :) |
[test foreman] |
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.
LGTM!
@ohadlevy tests are green :) |
password_strength.js
uses jquery_pwstrength_bootstrap wrapperI've added
react-password-strength
- react component, which renders password input with integrated password strength meter by using zxcvbn to calculate a password strength score.In addition, I moved
verify password
logic to wepback (it was inpassword_strength
file as well)Tests are missing for now.
after update:
Try online with Stroybook
before update: