Skip to content

Commit

Permalink
Code styling
Browse files Browse the repository at this point in the history
  • Loading branch information
PanSpagetka committed Jun 11, 2019
1 parent e131a84 commit 052379f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
24 changes: 10 additions & 14 deletions app/controllers/application_controller/miq_request_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -986,16 +986,16 @@ def workflow_instance_from_vars(req)
def build_tags_tree(wf, vm_tags, edit_mode)
# for some reason @tags is set in wf, and it is changed by map bellow which causes bugs
wf.instance_variable_set(:@tags, nil)
tags = wf.allowed_tags
tags.each do |cat|
cat[:values] = cat[:children].map do |tag|
{ :id => tag.first, :description => tag.second[:description] }
end
cat[:id] = cat[:name]
cat[:singleValue] = cat[:single_value]
cat.delete(:children)
cat.delete(:name)
end
tags = wf.allowed_tags.map do |cat|
{
:values => cat[:children].map do |tag|
{:id => tag.first, :description => tag.second[:description]}
end,
:id => cat[:name],
:description => cat[:description],
:singleValue => cat[:single_value],
}
end

assignments = Classification.select { |tag| vm_tags.include?(tag.id) }
assigned_tags = assignments.map do |tag|
Expand All @@ -1008,10 +1008,6 @@ def build_tags_tree(wf, vm_tags, edit_mode)
}
end.uniq

@button_urls = {
:save_url => '',
:cancel_url => ''
}
@tags = {:tags => tags, :assignedTags => assigned_tags, :affectedItems => []}
end

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/components/taggingWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const params = (type = 'default', state, tag = {}) => ({
})[type]

const onDelete = (type = 'default', params = [], deleted_element) => ({
provision: {...params, ids_checked: params.ids_checked.filter(element => element !== deleted_element)},
provision: {...params, check: 0, ids_checked: params.ids_checked.filter(element => element !== deleted_element)},
default: params,
})[type]

Expand Down Expand Up @@ -85,7 +85,7 @@ TaggingWrapper.propTypes = {
urls: PropTypes.shape({
cancel_url: PropTypes.string.isRequired,
save_url: PropTypes.string.isRequired,
}).isRequired,
}),
tags: PropTypes.shape({
tags: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.number.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/miq-redux/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const taggingMiddleware = store => next => action => {
$.post(meta.url, params)
} else if (type === 'UI-COMPONENTS_TAGGING_DELETE_ASSIGNED_TAG') {
params = meta.onDelete(meta.type, params, tag.tagValue.id);
$.post(meta.url, {...params, check: 0})
$.post(meta.url, params)
}
}
let result = next(action)
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/spec/miq-redux/middleware.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ it('calls post for UI-COMPONENTS_TAGGING_TOGGLE_TAG_VALUE_CHANGE action', () =>
};
const action = { type: 'UI-COMPONENTS_TAGGING_TOGGLE_TAG_VALUE_CHANGE', meta: { url: 'url/bla', params: jest.fn() }, tag: {tagCategory: {id: 1}, tagValue: { id:2 }}}
taggingMiddleware(store)(next)(action);
expect(next.mock.calls).toEqual( [[{"meta": {"url": "url/bla", "params": [Function mockConstructor]}, "tag": {"tagCategory": {"id": 1}, "tagValue": {"id": 2}}, "type": "UI-COMPONENTS_TAGGING_TOGGLE_TAG_VALUE_CHANGE"}]]);
expect(next.mock.calls).toEqual( [[{"meta": {"url": "url/bla", "params": jest.fn()}, "tag": {"tagCategory": {"id": 1}, "tagValue": {"id": 2}}, "type": "UI-COMPONENTS_TAGGING_TOGGLE_TAG_VALUE_CHANGE"}]]);
expect(spy).toHaveBeenCalledWith("url/bla", {"cat": 1, "check": 1, "id": {}, "tree_typ": "tags", "val": 2});
});

Expand Down
2 changes: 1 addition & 1 deletion app/views/miq_request/_prov_field.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
- check = @miq_request.id
- else
- check = 'new'
= react 'TaggingWrapperConnected', { :tags => @tags, :urls => @button_urls, :options => { :type => 'provision', :hideHeaders => true, :hideButtons => true, :url => url_for_only_path(:action => 'prov_field_changed')} }
= react 'TaggingWrapperConnected', { :tags => @tags, :options => { :type => 'provision', :hideHeaders => true, :hideButtons => true, :url => url_for_only_path(:action => 'prov_field_changed')} }
- unless field_hash[:notes_display] == :hide || field_hash[:notes].blank?
-# Display notes if available
= field_hash[:notes]
Expand Down

0 comments on commit 052379f

Please sign in to comment.