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

Users step #5280

Merged
merged 19 commits into from
Nov 6, 2023
Merged

Users step #5280

merged 19 commits into from
Nov 6, 2023

Conversation

rvykydal
Copy link
Contributor

@rvykydal rvykydal commented Oct 25, 2023

This is a draft pull request for https://issues.redhat.com/browse/INSTALLER-3205.
I have some questions (some related to specific commits, so it might make sense to follow the PR with the commits) and items for follow up steps.

  • Figure out where to keep the new UI state. In the draft I picked a structure in wizard - see some reasoning and options in the commit message webui: keep the state of Create Account UI.
  • [REQUIRED IN THIS PR] Strength indicator update. As can be seen on the screenshot the current indicator (following PF example) does not scale for horizontal forms (compare users and disk encryption sshots). Bug - [Password] - [Password strength breaks on horizontal forms] patternfly/patternfly#6032
  • Add user name validation. Currently only non-zero length is required. The rules in Gtk UI are pretty numerous and seem to need review (and maybe compare with gnome tools).
  • [REQUIRED IN THIS PR] Add account settings to the review screen (perhaps also when root account part is finished).
  • Crypt user password before passing it to backend (as in Gtk UI).
  • [REQUIRED IN THIS PR] Add tests, remove hack webui: FIXME do not require user temporarily. The tests will need nontrivial update for a new mandatory step with required user interaction.
  • [REQUIRED IN THIS PR] run only for non-workstation case
  • make sure the tests work both for workstation / non-workstation (live/non-live) case - this would involve replacing back() back() with something like reach_back(STEP_ID)
  • better prefixId setting in the components
  • add thorough user screen test (going back and forth, rule checkers, pwd strength,...) - perhaps when also root accout part is added
  • Fix e2e tests
  • Add the hint to the description.

Screenshot from 2023-10-25 15-39-02

The strenght indicator does not scale for isHorizontal Form
Screenshot from 2023-10-25 15-39-19
Screenshot from 2023-10-25 15-39-29
Compare to disk encryption:
Screenshot from 2023-10-25 15-39-40

@rvykydal rvykydal force-pushed the users-step branch 2 times, most recently from 8c6d769 to c69b0e6 Compare October 25, 2023 14:31
@rvykydal rvykydal requested a review from KKoukiou October 25, 2023 14:32
Copy link
Contributor

@KKoukiou KKoukiou left a comment

Choose a reason for hiding this comment

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

Will review this tomorrow morning.


// eslint-disable-next-line camelcase
import { password_quality } from "cockpit-components-password.jsx";
import ExclamationCircleIcon from "@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon";
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use named imports from @patternfly/react-icons

import { IconONe, IconTwo } from "@patternfly/react-icons"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

return {
id: rule.id,
text: rule.text(policy, password),
satisfied: password.length > 0 ? rule.check(policy, password) : null,
Copy link
Contributor

Choose a reason for hiding this comment

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

satisfied is a boolean like the isWarning variable. For consistency purposes, let's pick one and use either the pattern 'isMyBoolVariable' or 'myBoolVariable'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

id: "length",
text: (policy) => cockpit.format(_("Must be at least $0 characters"), policy["min-length"].v),
check: (policy, password) => password.length >= policy["min-length"].v,
isWarning: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's more explicit to use isError: false instead of isWarning: true. and vice versa. I had to read the code through to understand that isWarning: true is not causing the password to be invalid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@@ -303,14 +322,10 @@ export const DiskEncryption = ({
}) => {
const [password, setPassword] = useState(storageEncryption.password);
const [confirmPassword, setConfirmPassword] = useState(storageEncryption.confirmPassword);
const [passwordStrength, setPasswordStrength] = useState("");
const [isValid, setIsValid] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the purpose of maintaining the isValid as a state variable here. I suggest to directly use the setIsFormValid to invalidate or validate the form from the children component and remove this.

  • DiskEncryption should always setIsFormValid(true) if the isEncrypted is false.
  • The Password form fields should setIsFormValid(satisfied) where satisfied is the password rules result.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated


return (
<div id={idPrefix + "-create-account"}>
<Stack hasGutter>
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using Stack/StackItems you can put everything in a <Form isHorizontal>, spacings will be correct automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using the Stack to get the spacing between rows (like in the mockup), without it it looks like this:
Screenshot from 2023-10-30 17-18-18

Copy link
Contributor

Choose a reason for hiding this comment

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

The proper way to space form elements it to wrap everything with a '

' and let Patternfly do the trick :)

Copy link
Contributor Author

@rvykydal rvykydal Oct 31, 2023

Choose a reason for hiding this comment

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

Ah, this works if I move Form isHorizontal from Accounts to Create Account (having it in Accounts does not work). I wanted the Form to contain also (future) root component. I guess I'll use two forms then - Create Account and the other one for the root component? Well, it can be addressed when I add the UI for root. For now I'm moving Form to Create Accounts.

@@ -344,6 +349,8 @@ const Footer = ({
setStepNotification();
},
});
} else if (activeStep.id === "accounts") {
onNext();
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm does this need special condition? The else { does the same.

Copy link
Contributor Author

@rvykydal rvykydal Oct 30, 2023

Choose a reason for hiding this comment

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

There is setUsers ? Strange it is not visible here. IIRC I did one rebase of the PR but it was on Wed afternoon, nevermind...

@rvykydal rvykydal force-pushed the users-step branch 4 times, most recently from 9d061e8 to 0b9d17f Compare October 31, 2023 11:06
@rvykydal
Copy link
Contributor Author

I think I addressed the remarks above and I am going to work on the items from TODO list in the description.

@@ -422,6 +423,7 @@ class TestStorageMountPoints(anacondalib.VirtInstallMachineCase, StorageHelpers)
applied_partitioning = s.dbus_get_applied_partitioning()

# When adding a new partition a new partitioning should be created
i.back()
Copy link
Contributor Author

@rvykydal rvykydal Oct 31, 2023

Choose a reason for hiding this comment

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

This will not work for cases where the accounts screen is disabled (eg Workstation). We may need something like reach() for going back.
And run the tests on live.

@M4rtinK
Copy link
Contributor

M4rtinK commented Oct 31, 2023

@rvykydal @KKoukiou So thinking about it. I think the user screen needs to be conventionalized not to show up on Fedora Workstation. They have Gnome Initial Setup for user creation, so the extra screen would change the expected and agreed upon flow (and might break Fedora QA testing if an unexpected screens just shows up).

I think the logic should be kinda like this:

  • Live images in general: YES
  • Fedora Workstation : NO
  • boot.iso: YES

I think this logic should either be part of this PR before its merged or alternatively we should not do a new release before the logic id in place via a followup. :)

@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 1, 2023

@rvykydal @KKoukiou So thinking about it. I think the user screen needs to be conventionalized not to show up on Fedora Workstation. They have Gnome Initial Setup for user creation, so the extra screen would change the expected and agreed upon flow (and might break Fedora QA testing if an unexpected screens just shows up).

I think the logic should be kinda like this:

* Live images in general: YES

* Fedora Workstation : NO

* boot.iso: YES

I think this logic should either be part of this PR before its merged or alternatively we should not do a new release before the logic id in place via a followup. :)

I think in scope of this PR just using isBootIso logic similar as with Language selection should do (would disable the users screen at live images in general, including Fedora WS), but yes we may soon need to use the per-product/variant logic rather then simple isBootIso.

@rvykydal rvykydal force-pushed the users-step branch 2 times, most recently from 6d0afe5 to 6db2a4d Compare November 2, 2023 13:54
@pep8speaks
Copy link

pep8speaks commented Nov 2, 2023

Hello @rvykydal! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 33:1: E402 module level import not at top of file
Line 34:1: E402 module level import not at top of file

Line 24:1: E402 module level import not at top of file
Line 26:1: E302 expected 2 blank lines, found 1

Line 24:1: E402 module level import not at top of file
Line 25:1: E402 module level import not at top of file

Comment last updated at 2023-11-06 11:07:15 UTC

@rvykydal rvykydal force-pushed the users-step branch 2 times, most recently from 5718a8b to 3eb4f91 Compare November 2, 2023 14:09
@rvykydal rvykydal marked this pull request as ready for review November 2, 2023 14:18
@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 2, 2023

@KKoukiou I think you didn't review the last 8 commits - mostly adding the tests.
I believe the PR is mergeable (see the missing items in the description).

ui/webui/test/check-basic Outdated Show resolved Hide resolved
@rvykydal rvykydal marked this pull request as draft November 3, 2023 05:33
@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 3, 2023

Need to do a tests update.

@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 3, 2023

/webui-test

@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 3, 2023

@KKoukiou I think you didn't review the last 7 commits - mostly adding the tests.

Regarding the commits with test updates - in case you look at the commits sequentially just a warning that the
webui: create required user when reaching a test step by default is a change of approach to a previous commit.

I believe the PR is mergeable (see the missing items in the description).

@rvykydal rvykydal marked this pull request as ready for review November 3, 2023 10:38
@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 3, 2023

/kickstart-test --waive webui-only

@rvykydal rvykydal requested a review from KKoukiou November 3, 2023 10:41
@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 3, 2023

/kickstart-test --waive webui-only

@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 3, 2023

/webui-test


return (
<>
<CreateAccount
Copy link
Contributor

Choose a reason for hiding this comment

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

Uneeded wrapper on empty compoent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is waiting for the root part. Either I'll keep it or remove when I add root.

@@ -0,0 +1,4 @@
// Span disk encryption password fields to take slightly more width than the default
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong comment.

Copy link
Contributor Author

@rvykydal rvykydal Nov 6, 2023

Choose a reason for hiding this comment

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

@@ -44,7 +45,8 @@ class TestBasic(anacondalib.VirtInstallMachineCase):
# Do not start the installation in non-destructive tests as this performs non revertible changes
# with the pages basically empty of common elements (as those are provided by the top-level installer widget)
# we at least iterate over them to check this works as expected
i.reach(i.steps.REVIEW)
# Create user on the first pass through users step
i.reach(i.steps.REVIEW, step_callbacks={i.steps.ACCOUNTS: lambda: create_user(self)})
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like that the callback would be by default set if not specified to avoid repeating code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is fixed in the next commit.

@@ -1045,8 +1045,8 @@ class TestStorageMountPointsEFI(anacondalib.VirtInstallMachineCase):
s.select_mountpoint_row_device(3, f"{dev}3")
s.check_mountpoint_row_format_type(3, "xfs")

# Create user on the first pass through users step
i.reach(i.steps.REVIEW, step_callbacks={i.steps.ACCOUNTS: lambda: create_user(self)})
self.addCleanup(lambda: dbus_reset_users(self.machine))
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be added in anacondalib and be run by default for all tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, sounds good, only on destructive tests if failed for me.
I think we can address it in a follow up PR.

Copy link
Contributor

@KKoukiou KKoukiou left a comment

Choose a reason for hiding this comment

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

All in all I have some comments, but they are all not blockers. This is a huge chunk of work and in very good state. I am ok to merge this as is, and do the improvements in followups.

Copy link
Contributor

@KKoukiou KKoukiou left a comment

Choose a reason for hiding this comment

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

Agreed with @rvykydal to block this on fixing the strength indicator.

Copy link
Contributor

@KKoukiou KKoukiou left a comment

Choose a reason for hiding this comment

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

@rvykydal I think I have a workaround:

[kkoukiou@sequioa webui]$ git diff
diff --git ui/webui/src/components/users/Accounts.scss ui/webui/src/components/users/Accounts.scss
index f53ec05624..bdce550c8f 100644
--- ui/webui/src/components/users/Accounts.scss
+++ ui/webui/src/components/users/Accounts.scss
@@ -2,3 +2,8 @@
 #accounts-create-account {
   width: min(60ch, 100%);
 }
+
+// FIXME: Undo when fixed upstream: https://github.com/patternfly/patternfly/issues/6032
+#accounts-create-account .pf-v5-c-form__group-label.pf-m-info {
+    align-items: baseline
+}

And since it affects also the disk selection, actually the workaround needs to be on the CSS file of the Password component. Add some helper class there and replace my used ID.

@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 6, 2023

@rvykydal I think I have a workaround:

[kkoukiou@sequioa webui]$ git diff
diff --git ui/webui/src/components/users/Accounts.scss ui/webui/src/components/users/Accounts.scss
index f53ec05624..bdce550c8f 100644
--- ui/webui/src/components/users/Accounts.scss
+++ ui/webui/src/components/users/Accounts.scss
@@ -2,3 +2,8 @@
 #accounts-create-account {
   width: min(60ch, 100%);
 }
+
+// FIXME: Undo when fixed upstream: https://github.com/patternfly/patternfly/issues/6032
+#accounts-create-account .pf-v5-c-form__group-label.pf-m-info {
+    align-items: baseline
+}

This didn't work for me:
Screenshot from 2023-11-06 09-40-30
But adding also flex-direction: column

+
+// FIXME: Undo when fixed upstream: https://github.com/patternfly/patternfly/issues/6032
+#accounts-create-account .pf-v5-c-form__group-label.pf-m-info {
+  flex-direction: column;
+  align-items: baseline;
+}

did work:
Screenshot from 2023-11-06 09-41-23

And since it affects also the disk selection, actually the workaround needs to be on the CSS file of the Password component. Add some helper class there and replace my used ID.

Not sure what you mean by the disk selection. I know about ths issue (using the indicator in horizontal form) only at this place, so the ID would be OK.

@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 6, 2023

But adding also flex-direction: column

+
+// FIXME: Undo when fixed upstream: https://github.com/patternfly/patternfly/issues/6032
+#accounts-create-account .pf-v5-c-form__group-label.pf-m-info {
+  flex-direction: column;
+  align-items: baseline;
+}

Actually on Chrome the baseline does not look good, using flex-start instead.

@KKoukiou
Copy link
Contributor

KKoukiou commented Nov 6, 2023

But adding also flex-direction: column

+
+// FIXME: Undo when fixed upstream: https://github.com/patternfly/patternfly/issues/6032
+#accounts-create-account .pf-v5-c-form__group-label.pf-m-info {
+  flex-direction: column;
+  align-items: baseline;
+}

Actually on Chrome the baseline does not look good, using flex-start instead.

I don't like the change that the 'direction: column' does. The design seems of when the strength goes bellow imo. Fine with the flex-start.

@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 6, 2023

/kickstart-test --waive webui-only

Copy link
Contributor

@KKoukiou KKoukiou left a comment

Choose a reason for hiding this comment

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

Thanks. As said I dont like the column direction for the strength indicator but I am happy to send a followup fix. Also I think we need to show the new user name in the review step as well? Also fine for followup.

@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 6, 2023

Thanks. As said I dont like the column direction for the strength indicator but I am happy to send a followup fix. Also I think we need to show the new user name in the review step as well? Also fine for followup.

Agreed, I have the review step in the TODO list at the beginning. I would merge this. (I've got the feeling we may end up with completely different indicator, similar to the bar in cockpit or Anaconda.)

@rvykydal rvykydal merged commit e81d86b into rhinstaller:master Nov 6, 2023
14 checks passed
@rvykydal
Copy link
Contributor Author

rvykydal commented Nov 8, 2023

Follow up issues tracked here: https://issues.redhat.com/browse/INSTALLER-3781

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants