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

Task/t UI 336 create user credential #404

Merged
merged 15 commits into from
Jul 30, 2024

Conversation

zazmir
Copy link
Collaborator

@zazmir zazmir commented Jul 20, 2024

Screenshot from 2024-07-19 19-19-09

Overview:

Related Github Issues:

Summary of Changes:

Testing Steps:

UI Photos:

Notes:

Copy link
Member

@NotChristianGarcia NotChristianGarcia left a comment

Choose a reason for hiding this comment

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

View this example.

Unfortunately you added in react-hook-form. We don't use that library and so it would be good to not add in anything more. I linked to an example which uses our form library above. We use formik.

If you could switch over to that and remove the react-hook-form library that would be great. The two systems are similar, so you should just need to change the CreateUserCredentialsModal.tsx file.

install_command="npm ci"
install_command="npm install"
Copy link
Member

Choose a reason for hiding this comment

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

npm ci should be used, please uncommit.

Copy link
Member

Choose a reason for hiding this comment

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

View this example.

Unfortunately you added in react-hook-form. We don't use that library and so it would be good to not add in anything more. I linked to an example which uses our form library above. We use formik.

If you could switch over to that and remove the react-hook-form library that would be great.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed it to formik library.

// Custom transformation to ensure privateKey is a one-liner
const transformPrivateKey = (value: string) => value.replace(/\n/gm, '\\n');

const schema = yup.object().shape({
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to add:

  • minimum and maximum character limits. Maximum should be a reasonable number for the field. Minimum is optional.
  • you can optionally add in regex to give warnings when users inputs invalid characters. (You would need to figure out which characters are in/valid)

Example 1
Example 2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

@zazmir zazmir Jul 22, 2024

Choose a reason for hiding this comment

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

The key changes and additions:

Updated the Yup schema to include character limits and regex patterns:

  • systemId: 3-50 characters, only letters, numbers, hyphens, and underscores.
  • publicKey: 20-4096 characters, must match SSH public key format.
  • privateKey: 1000-4096 characters.
  • loginUser: Up to 32 characters, must start with a lowercase letter or underscore, followed by lowercase letters, numbers, hyphens, or underscores.

Added maxLength attributes to the Input components to enforce maximum character limits on the UI:

  • systemId: 50 characters
  • publicKey: 4096 characters
  • privateKey: 4096 characters
  • loginUser: 32 characters

The existing error handling will now display more specific error messages for invalid input formats or lengths.

These changes provide:

  • Minimum and maximum character limits for all fields.
  • Regex patterns to validate input format for all fields.
  • UI enforcement of maximum character limits.
  • Clear error messages for invalid inputs.

package.json Outdated
@@ -34,6 +34,7 @@
"react-copy-to-clipboard": "^5.0.2",
"react-dom": "^18.3.1",
"react-dropzone": "^10.2.1",
"react-hook-form": "^7.52.1",
Copy link
Member

Choose a reason for hiding this comment

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

Because we're using formik, this react-hook-form should be removed.

Copy link
Member

Choose a reason for hiding this comment

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

Don't commit package-lock.jsons unless you have a specific reason to.

Copy link
Member

Choose a reason for hiding this comment

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

Don't commit package-lock.jsons unless you have a specific reason to.

Copy link
Member

Choose a reason for hiding this comment

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

Don't commit package-lock.jsons unless you have a specific reason to.

Copy link
Member

Choose a reason for hiding this comment

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

Because we're using formik, this react-hook-form should be removed.

@NotChristianGarcia
Copy link
Member

I was testing it and saw a few issues:

  1. System ID - can also have a . period. Otherwise good.
  2. Public Key - I don't know why this is invalid. But it's a valid public key. So maybe regex needs to change.
  3. Private Key - Minimum should be much lower, more like 20 characters.

Screenshot from 2024-07-22 14-05-22

If you could fix those and push to the PR again that would be great.

@zazmir zazmir force-pushed the task/TUI-336-CreateUserCredential branch from 1f4d6dc to 5bef0d8 Compare July 24, 2024 17:31
@NotChristianGarcia
Copy link
Member

Good progress! No validation errors now. I cannot submit though, I get a warning and a log in the browser console.

Error validating system: RequiredError: Required parameter requestParameters.systemId was null or undefined when calling getSystem
image

@NotChristianGarcia NotChristianGarcia merged commit 7645ba1 into dev Jul 30, 2024
4 checks passed
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.

2 participants