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

Exports new DialogFieldAssociations data #15608

Merged

Conversation

d-m-u
Copy link
Contributor

@d-m-u d-m-u commented Jul 19, 2017

Allows us to include the relationship data set up between dialog fields for targeted auto refresh by the two associations (trigger and response) in the dialog export (here: corresponding main repo PR and necessary migration). The additional metadata that's introduced includes two fields: a "trigger_id" and "respond_id" added via the extra_attributes in the serializer with an array of field names in the associations.

  dialog_fields:
  - name: name
    description: Name of the newly created virtual machine
    data_type: 
    notes: 
    ...
   dialog_field_responders:
    - resource_group
    - new_resource_group
    - param_adminUserName
    - param_operatingSystemType

Related to:
PR #15724
PR #15740

PR #15566 (merged)
ManageIQ/manageiq-schema#41 (merged)

@d-m-u
Copy link
Contributor Author

d-m-u commented Jul 19, 2017

@miq-bot assign @gmcculloug

@miq-bot miq-bot added the wip label Jul 19, 2017
@d-m-u d-m-u force-pushed the add_dialog_field_associations_to_serializer branch from 84e91b1 to d8555ec Compare July 19, 2017 14:59
@gmcculloug gmcculloug requested a review from eclarizio July 20, 2017 17:34
@@ -12,9 +12,16 @@ def initialize(resource_action_serializer = ResourceActionSerializer.new)
def serialize(dialog_field, all_attributes = false)
serialized_resource_action = @resource_action_serializer.serialize(dialog_field.resource_action)

trigger_associations =
{ dialog_field.name.to_s => dialog_field.dialog_field_trigger_associations.map { |field| DialogField.find(field.id).name } }
Copy link
Member

Choose a reason for hiding this comment

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

Isn't dialog_field.name always a string? I do no think it needs the to_s. But more important, if this data is stored per-field is there a reason to even include the field name? Seems these could just be arrays. Same for respond_associations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I thought, but your original plan had the name included.

@gmcculloug
Copy link
Member

@d-m-u This PR needs tests and also suggest adding some example data to the PR description.

@gmcculloug
Copy link
Member

That's when I thought the associations would be stored at the dialog level, not per field.

Copy link
Member

@eclarizio eclarizio left a comment

Choose a reason for hiding this comment

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

Agree with @gmcculloug about the tests and about not needing the field name.

I also don't think we even need to export the respond associations, since they should get built by themselves once the trigger associations get created.

@@ -12,9 +12,16 @@ def initialize(resource_action_serializer = ResourceActionSerializer.new)
def serialize(dialog_field, all_attributes = false)
serialized_resource_action = @resource_action_serializer.serialize(dialog_field.resource_action)

trigger_associations =
{ dialog_field.name.to_s => dialog_field.dialog_field_trigger_associations.map { |field| DialogField.find(field.id).name } }
Copy link
Member

@eclarizio eclarizio Jul 24, 2017

Choose a reason for hiding this comment

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

I don't think we need to hit the database for the associated fields, you should just be able to call field.name

Ok so I was wrong here, but we should be doing field.dialog_field_trigger_id instead.

@d-m-u d-m-u force-pushed the add_dialog_field_associations_to_serializer branch 7 times, most recently from 60ef08c to c5058eb Compare July 27, 2017 21:06
@d-m-u d-m-u closed this Jul 28, 2017
@d-m-u d-m-u reopened this Jul 28, 2017
@d-m-u d-m-u closed this Aug 1, 2017
@d-m-u d-m-u reopened this Aug 1, 2017
@@ -103,12 +106,24 @@
'resource_action' => 'serialized resource action',
))
end

context 'with associations' do
let(:dialog_field_responders) { [FactoryGirl.create(:dialog_field_button)] }
Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to use a dialog field here, but I think we should use .build instead of .create since I'm pretty sure we don't need these to be persisted in the database right now to export them.

Also, I have no idea what a dialog_field_button is, I think it's an old type of dialog_field that either doesn't exist anymore or at least isn't actually useable so we should at least pick a type we still use today like another text box or checkbox or something.

@d-m-u d-m-u changed the title [WIP] Exports new DialogFieldAssociations data Exports new DialogFieldAssociations data Aug 10, 2017
@miq-bot miq-bot removed the wip label Aug 10, 2017
@d-m-u d-m-u force-pushed the add_dialog_field_associations_to_serializer branch from c5058eb to a3a710a Compare August 10, 2017 15:06
@miq-bot
Copy link
Member

miq-bot commented Aug 10, 2017

Checked commits d-m-u/manageiq@40ba409~...a3a710a with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

@gmcculloug gmcculloug merged commit 558c153 into ManageIQ:master Aug 15, 2017
@gmcculloug gmcculloug added this to the Sprint 67 Ending Aug 21, 2017 milestone Aug 15, 2017
@d-m-u d-m-u deleted the add_dialog_field_associations_to_serializer branch October 25, 2018 14:15
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