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] Redux controlled amazon dialog #4325

Closed
wants to merge 7 commits into from

Conversation

Hyperkid123
Copy link
Contributor

Adds a option to create amazon provider from modal.

Controls

In order to avoid any bugs in current version, component cannot be show from UI. You have to run a few commands from browser console.

ManageIQ.record.recordId = 'someId'
sendDataWithRx({controller: 'provider_dialogs', component_name: 'CreateAmazonSecurityGroupForm', modal_title: 'Create amazon provider.', props: {recordId: 'neco'}})

Dependencies

This pr is dependent on #3509 and ManageIQ/react-ui-components#61. Also a new version of react-ui-components is required for this to work properly .

Some issues

Currently props cannot be passed to component inside modal. That can be fixed ni modal.js. @himdel knows about this. Therefore the providerId must be set in console first, before showing the modal.

Also the API endpoint for creating is not available until ManageIQ/manageiq-providers-amazon#453 will be merged

himdel and others added 7 commits July 19, 2018 09:21
should be a 1:1 match to the existing miqButton component
meant for new react form buttons
this is just a dumb presentation-only component
it will be wrapped in another one that listens for messages from the form and updates it accordingly
reset form buttons to initial state

    ManageIQ.redux.store.dispatch({ type: 'FormButtons.init', payload: {} })

change the default Add/Save label

    ManageIQ.redux.store.dispatch({ type: 'FormButtons.customLabel', payload: __('Magic') })

set newRecord - if true, the Add button is shown (and addClicked called), else the Save and Reset buttons are shown (and saveClicked, resetClicked called)

    ManageIQ.redux.store.dispatch({ type: 'FormButtons.newRecord', payload: true })

set pristine - pristine form can't be reset (and shouldn't be saveable)

    ManageIQ.redux.store.dispatch({ type: 'FormButtons.pristine', payload: false })

set saveable - means no validation error, the submit button will be enabled based on this

    ManageIQ.redux.store.dispatch({ type: 'FormButtons.saveable', payload: false })

set callbacks - an object of functions - addClicked, saveClicked, resetClicked and cancelClicked are accepted

    ManageIQ.redux.store.dispatch({ type: 'FormButtons.callbacks', payload: {
      addClicked: () => console.log('add'),
      cancelClicked: () => console.log('cancel'),
      resetClicked: () => console.log('reset'),
      saveClicked: () => console.log('save'),
    }})
the idea here is, when using FormButtonRedux from a modal, you want to change the handlers to close the modal after

so, you get to replace the handler, and get the original as an argument, to call from the replacement

specifically in ProviderDialogs modal, we override save, add and cancel to close the window afterwards

if the original handler returns a promise, closing will wait for that promise
if the orignal handler returns anything else, closing is immediate
@Hyperkid123
Copy link
Contributor Author

@miq-bot assign @martinpovolny
@himdel

@miq-bot
Copy link
Member

miq-bot commented Jul 20, 2018

Checked commits Hyperkid123/manageiq-ui-classic@a1fb3e4~...0923cb4 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
0 files checked, 0 offenses detected
Everything looks fine. 🏆

@Hyperkid123 Hyperkid123 deleted the redux-amazon-dialog branch November 12, 2019 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants