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

[WIP] Migrate add cloud provider form to data driven forms #5542

Closed

Conversation

Hyperkid123
Copy link
Contributor

@Hyperkid123 Hyperkid123 commented May 7, 2019

Changes

  • Implemented in React (data-driven-forms)
  • Uses API to collect and submit data
  • Uses fields name spacing to avoid field names collisions and rewriting when changing provider type
    • if you set provider specific field it will be store under that type
    • openstack.userid for instance

Dependencies

TO DO

  • create form field schemas
  • add types specific field namespacing
    • azure
    • amazon
    • openstack - don't have API support for sub collections so i don't know how to name these fields
    • vmware - don't have API support for sub collections so i don't know how to name these fields
    • google? should be deprecated
  • use API driven endpoints credentials validation Endpoint to validate (Cloud)Provider credentials manageiq-api#585
  • miq specific validations
    • hostname
    • url
    • guiid
  • use API to create entities
  • tests
  • remove old code
  • clean up

@Hyperkid123
Copy link
Contributor Author

@miq-bot assign @martinpovolny
@miq-bot add_label reac
cc @skateman @himdel @rvsia @h-kataria

@martinpovolny can you add it to the React project?

@miq-bot
Copy link
Member

miq-bot commented May 7, 2019

@Hyperkid123 Cannot apply the following label because they are not recognized: reac

azure_tenant_id: get(azureValues, 'uid_ems'),
subscription: get(azureValues, 'subscription'),
zone: 'default',
default_url: get(azureValues, 'endpoints[0].url'),
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just azureValues.endpoints[0].url?

All those get calls are suprising, given the right side is a constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They might not be inside the form state. Not all of the nested fields are required and if you don;t change it it will be undefined. I agree there is a lot of gets but that whole validation call will change and will be via API. Its just a placeholder for now.

@@ -12,6 +24,9 @@ const fieldsMapper = {
'validate-credentials': AsyncCredentials,
'credentials-password-edit': EditSecretField,
'secret-switch-field': SecretSwitchField,
wizard: MiqWizard,
'provider-initial-step': InitialWizardStep,
summary,
Copy link
Contributor

Choose a reason for hiding this comment

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

summary is not a good generic name for a div with a title and some specific json.

Since this would affect any new form, maybe this should be JsonSummary or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah this is left over it will be deleted. First iteration was in wizard but we scrapped that.


const summary = ({ formOptions }) => (
<div>
<h1>Summary</h1>
Copy link
Contributor

Choose a reason for hiding this comment

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

i18n

Copy link
Contributor Author

Choose a reason for hiding this comment

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

^^

@miq-bot miq-bot added the wip label May 7, 2019
@@ -44,3 +45,4 @@ ManageIQ.component.addReact('CatalogForm', CatalogForm);
ManageIQ.component.addReact('Breadcrumbs', Breadcrumbs);
ManageIQ.component.addReact('TaggingWrapperConnected', TaggingWrapperConnected);
ManageIQ.component.addReact('RemoveCatalogItemModal', RemoveCatalogItemModal);
ManageIQ.component.addReact('CloudProviderForm', CloudProviderForm);
Copy link
Contributor

Choose a reason for hiding this comment

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

sort please :)

@@ -64,7 +64,7 @@
"numeral": "~2.0.6",
"patternfly": "~3.59.1",
"patternfly-bootstrap-treeview": "~2.1.7",
"patternfly-react": "2.10.1",
"patternfly-react": "2.30.6",
Copy link
Contributor

Choose a reason for hiding this comment

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

exact version, no ~ ?

@@ -0,0 +1,29 @@

const isHostname = function(value) {
return /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/.test(value);
Copy link
Contributor

@himdel himdel May 7, 2019

Choose a reason for hiding this comment

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

This doesn't look right.

You probably want something like \p{L} instead of a-zA-Z. Otherwise, this won't match any national domains...

> isHostname('♡.com')
false

Yet, http://♡.com exists and is a valid domain.

EDIT: the full list of valid unicode chars is probably here https://unicode.org/faq/idn.html

EDIT2: that said, this is fine if we require people to punycode-convert the domains first

};

export const asyncValidate = (formValues, asyncFieldsNames) => new Promise((resolve) => {
console.log('validating: ', formValues, asyncFieldsNames);
Copy link
Contributor

Choose a reason for hiding this comment

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

console.log

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its just a WIP 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

Aaah, sorry, I didn't notice :)

@himdel
Copy link
Contributor

himdel commented May 7, 2019

One thing I'm a bit worried about is the ${prefix}.foo use.

Is that so that we don't have to reload the schema after changing types?
Or do those values get sent to the server with the prefix?

(But definitely better than the original #{prefix}_foo 👍 )

@himdel himdel added the react label May 7, 2019
@Hyperkid123
Copy link
Contributor Author

Hyperkid123 commented May 7, 2019

Is that so that we don't have to reload the schema after changing types

Yes

Or do those values get sent to the server with the prefix

They don't but different types share the same attributes but sometimes they have different format requirements. Scoping the will allow you to change types without resetting certain fields and saving the state if the user decides to switch back to some type. Anything that is not in general schema might cause conflict if you change the type if we don't have unique field names.

I also have a "plan" for the future that will enable us to "download" pieces of schema on the fly which would allow us also add the prefix on the fly.

@himdel
Copy link
Contributor

himdel commented May 7, 2019

OK, perfect, thanks :)

Works for me, just don't base any logic on the prefix strings.. in the future this should be a matter of settings, not types. (has keypair vs is openstack)

@miq-bot
Copy link
Member

miq-bot commented May 9, 2019

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Nov 11, 2019

This pull request has been automatically closed because it has not been updated for at least 6 months.

Feel free to reopen this pull request if these changes are still valid.

Thank you for all your contributions!

@Hyperkid123 Hyperkid123 deleted the add-cloud-provider-form branch November 11, 2019 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants