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
[Mapping Rules] Sorting mapping rules #530
Conversation
Codecov Report
@@ Coverage Diff @@
## master #530 +/- ##
==========================================
- Coverage 92.79% 92.78% -0.01%
==========================================
Files 2374 2375 +1
Lines 76818 76888 +70
==========================================
+ Hits 71280 71341 +61
- Misses 5538 5547 +9
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so now we need to save the order in the db
Meaning we need to have a column for the position.
I think we are already doing that for some models.
480de38
to
69b3c51
Compare
@hallelujah Only thing needed are what you mentioned. |
eeb5030
to
3c8ffe0
Compare
679a3e8
to
50634d6
Compare
@@ -2,6 +2,7 @@ | |||
|
|||
disabled ||= !rule.new_record? && !@marked_for_update.try(:include?,rule.id.to_s) | |||
html_options = { :disabled => disabled , :class => 'message-when-change' } | |||
index ||= false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same template is used here https://github.com/3scale/porta/pull/530/files#diff-2eeed0d10ff9fe7aedaf9123ec70b297L25 where we are not passing index
. So when it tries to access it here: https://github.com/3scale/porta/pull/530/files#diff-8aca4cca05f925b4b00a70b406f9638dR33, it breaks. Do you think it can be better some other way? (consider this integration page is not worthy a major refactor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK then you could use index = local_assigns[:index]
instead of implicit variable assignment. And that will ensure that the variable exists whatever it is. variable ||= boolean
is kinda ugly to read :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed hehe, didn't know how to do something like that in ruby basically. thanks!
tr | ||
= render 'api/integrations/apicast/shared/mapping_rule', form: f, rule: rule, metrics: metrics | ||
tr#new-proxy-rule-template style="display:none;" | ||
- @proxy.proxy_rules.ordered.each_with_index do |rule, i| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an instance variable in the controller or better a presenter instead of @proxy.proxy_rules.ordered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced this deserves a presenter given the short life expectancy of this integration page. Any other way you might suggest to change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
jQuery(this).val(jQuery(this).data('selected')) | ||
}) | ||
jQuery(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really needed? As I understand, on drag (start) it adds 4px width on each td where the element was dragged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it happens here, it's more than 4px: https://github.com/3scale/porta/pull/530/files#diff-2eeed0d10ff9fe7aedaf9123ec70b297R39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do not add this code, will it be ugly? Can it be done in pure CSS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly nope, this trick is needed because of jqueryui#sortable lib and the use of tables.
@@ -0,0 +1,5 @@ | |||
class AddPositionToMappingRules < ActiveRecord::Migration | |||
def change | |||
add_column :proxy_rules, :position, :integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not need a migration to be done from @3scale/operations
@@ -0,0 +1,5 @@ | |||
class AddLastToProxyRules < ActiveRecord::Migration | |||
def change | |||
add_column :proxy_rules, :last, :boolean, default: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a migration to be done by @3scale/operations because it has a NON-NULL default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
db/schema.rb
Outdated
@@ -11,7 +11,7 @@ | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to make the schema for Postgres and Oracle as well. make schema
for Oracle IIRC
features/old/proxy.feature
Outdated
When I have policies feature enabled | ||
And apicast registry is stubbed | ||
And I go to the integration page for service "one" | ||
Then I should see the Policy Chain | ||
|
||
@javascript @selenium |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now @selenium
and @javascript
are the same
They all both run under chrome-headless
end | ||
end | ||
|
||
Given(/^I drag the last mapping rule to the first position$/) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably good to have it catch first position
as (position \d+)
c656377
to
07f8b04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, would be nice to have the migration separated from this PR
It will be safe because it is adding a nullable column with a default
2ff2c02
to
94d522c
Compare
* Done the easiest way * This is meant to remove in the near future favoring an entire page craft in React using APIcast json schema config. * Missing some styling
4f16739
to
bd2c29a
Compare
@@ -201,6 +203,17 @@ def authorize | |||
authorize! :edit, @service | |||
end | |||
|
|||
def update_mapping_rules_position | |||
proxy_rules_attributes.each_value do |attrs| | |||
proxy_rule = @proxy.proxy_rules.find_by(id: attrs['id']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that could be to fix codeclimate issue
proxy_rule = @proxy.proxy_rules.find_by(id: attrs['id']) | |
proxy_rule = @proxy.proxy_rules.find_by(id: attrs['id']) || next |
def update_mapping_rules_position | ||
proxy_rules_attributes.each_value do |attrs| | ||
proxy_rule = @proxy.proxy_rules.find_by(id: attrs['id']) | ||
proxy_rule&.set_list_position(attrs['position']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then remove the nil check
proxy_rule&.set_list_position(attrs['position']) | |
proxy_rule.set_list_position(attrs['position']) |
bd2c29a
to
21e6d5a
Compare
Depends on #658
What this PR does / why we need it:
Feature: Sort mapping rules + last called
Which issue(s) this PR fixes
fixes https://issues.jboss.org/browse/THREESCALE-1787
Verification steps
Special notes for your reviewer:
TODO: