Skip to content

Conversation

@Hyperkid123
Copy link
Contributor

@Hyperkid123 Hyperkid123 commented May 24, 2019

Action for creating service dialog from orchestration template. Part of an effort of refactoring orchestration dialog forms. Based on current implementation in ui classic which this should eventually replace.
https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/catalog_controller.rb#L1108

POST /api/service_dialogs
{
  action: 'orchestration_template_service_dialog',
  resource: {
    label: 'dialog label'
     ot_id: '569' // orchestration template ID
  }
}

@Hyperkid123
Copy link
Contributor Author

@miq-bot assign @lpichler
@miq-bot add-label hammer/no

@Hyperkid123 Hyperkid123 force-pushed the service-dialog-from-ot branch from 2862096 to f67954b Compare May 28, 2019 08:37
@Hyperkid123 Hyperkid123 force-pushed the service-dialog-from-ot branch 3 times, most recently from 36560e6 to 64d2c9a Compare June 10, 2019 11:55
@Hyperkid123 Hyperkid123 changed the title Added create orchestration template service dialog endpoint. [WIP] Added create orchestration template service dialog endpoint. Jun 10, 2019
@miq-bot miq-bot added the wip label Jun 10, 2019
@Hyperkid123 Hyperkid123 force-pushed the service-dialog-from-ot branch 5 times, most recently from b90e6b4 to e5f9155 Compare June 11, 2019 08:48
@Hyperkid123 Hyperkid123 changed the title [WIP] Added create orchestration template service dialog endpoint. [WIP] Added create orchestration template service dialog action. Jun 11, 2019
@Hyperkid123 Hyperkid123 force-pushed the service-dialog-from-ot branch from e5f9155 to be28a43 Compare June 11, 2019 11:01
@Hyperkid123 Hyperkid123 changed the title [WIP] Added create orchestration template service dialog action. Added create orchestration template service dialog action. Jun 11, 2019
@Hyperkid123 Hyperkid123 force-pushed the service-dialog-from-ot branch from be28a43 to 7467580 Compare June 11, 2019 11:03
@miq-bot miq-bot removed the wip label Jun 11, 2019
@Hyperkid123 Hyperkid123 force-pushed the service-dialog-from-ot branch 2 times, most recently from 4843599 to 546910f Compare June 11, 2019 11:09
@martinpovolny
Copy link
Member

Ping @lpichler


def validate_orchestration_template_dialog_create_data(data)
bad_attrs = []
ORCHESTRATION_TEMPLATE_DIALOG_REQUIRED_ATTRS.each { |attr| bad_attrs << attr if data[attr].blank? }
Copy link
Contributor

@lpichler lpichler Jun 13, 2019

Choose a reason for hiding this comment

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

@Hyperkid123
maybe rename bad_attrs to missing_attributes ? and then do:

missing_attributes  = ORCHESTRATION_TEMPLATE_DIALOG_REQUIRED_ATTRS - data.keys

what do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

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

and think you need to check that in data are just ORCHESTRATION_TEMPLATE_DIALOG_REQUIRED_ATTRS keys, right ?

so you can do in addition

invalid_attributes  =  data.keys - ORCHESTRATION_TEMPLATE_DIALOG_REQUIRED_ATTRS
raise BadRequestError if invalid_attributes.present?

before_action :set_additional_attributes, :only => [:index, :show]

CONTENT_PARAMS = %w[target_type target_id resource_action_id].freeze
ORCHESTRATION_TEMPLATE_DIALOG_REQUIRED_ATTRS = %w[ot_id label].freeze
Copy link
Contributor

Choose a reason for hiding this comment

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

probably enough is ORCHESTRATION_TEMPLATE_DIALOG_ATTRIBUTES (without REQUIRED)


def orchestration_template_service_dialog_resource(_type, _id, data)
validate_orchestration_template_dialog_create_data(data)
ot = OrchestrationTemplate.find(data['ot_id'])
Copy link
Contributor

Choose a reason for hiding this comment

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

what if ot is nil (not exist in DB)
I think we need to cover it by some error message.

Copy link
Contributor

Choose a reason for hiding this comment

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

ot it would be nice to use orchestration_template variable.

@Hyperkid123 Hyperkid123 force-pushed the service-dialog-from-ot branch 2 times, most recently from e11ed9e to c5b0c80 Compare June 13, 2019 10:45
@Hyperkid123 Hyperkid123 force-pushed the service-dialog-from-ot branch from c5b0c80 to e9ca325 Compare June 13, 2019 10:58
@miq-bot
Copy link
Member

miq-bot commented Jun 13, 2019

Checked commit Hyperkid123@e9ca325 with ruby 2.3.3, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍰

@lpichler
Copy link
Contributor

thanks @Hyperkid123 👍

@lpichler lpichler added this to the Sprint 114 Ending Jun 24, 2019 milestone Jun 13, 2019
@lpichler lpichler merged commit 3f97d1c into ManageIQ:master Jun 13, 2019
@Hyperkid123 Hyperkid123 deleted the service-dialog-from-ot branch June 14, 2019 08:07
lpichler added a commit to lpichler/manageiq-api that referenced this pull request Jun 14, 2019
…og-from-ot"

This reverts commit 3f97d1c, reversing
changes made to f3ed911.
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