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

Adding 'visible' field to custom attributes #14611

Closed

Conversation

enoodle
Copy link

@enoodle enoodle commented Apr 3, 2017

The field's default value will be true to leave the behavior unchanged.

@enoodle
Copy link
Author

enoodle commented Apr 3, 2017

@moolitayer
Copy link

moolitayer commented Apr 3, 2017

It makes more sense to me to have default false, as custom attributes are an internal implementation detail.

EDIT: this means you just omit the default. Lets wait to see what @gmcculloug and @himdel think

@enoodle enoodle force-pushed the visible_field_for_custom_attributes branch from c9da002 to 688b15e Compare April 3, 2017 09:33
@isimluk
Copy link
Member

isimluk commented Apr 3, 2017

Perfect. What is this trying to achieve?

@enoodle
Copy link
Author

enoodle commented Apr 3, 2017

@isimluk Some times we don't want to display all Custom Attributes and we need an easy way to tell about a Custom Attribute if it should be displayed or not.

@lpichler
Copy link
Contributor

lpichler commented Apr 3, 2017

what about default value ? isn`t it now nil ? is it ok ?

@enoodle
Copy link
Author

enoodle commented Apr 3, 2017

@lpichler Yes, it is nil. It will not change anything for existing code that was ignoring this field before. If you would like to set a custom attribute visible you need to set this field to be 'true'.

@moolitayer
Copy link

Perfect. What is this trying to achieve?

Suggested here: ManageIQ/manageiq-ui-classic#290 (comment)

@lpichler
Copy link
Contributor

lpichler commented Apr 3, 2017

@miq-bot assign @Fryguy

@himdel
Copy link
Contributor

himdel commented Apr 3, 2017

Please note that until now, all custom attributes with source=EVM are visible in the UI.

Therefore, defaulting visible to false definitely breaks everything ;) (if that visible is ever used :))

@enoodle
Copy link
Author

enoodle commented Apr 3, 2017

@himdel
We could change the default back to true. This field is used here: ManageIQ/manageiq-ui-classic#881

@moolitayer
Copy link

Please note that until now, all custom attributes with source=EVM are visible in the UI.

Yes but as I understand we are adding the new column to switch to a general solution

Therefore, defaulting visible to false definitely breaks everything ;) (if that visible is ever used :))

existing code isn't looking at visible yet and should be converted to do so.
people accountable for relevant providers should convert their code.

@lpichler
Copy link
Contributor

lpichler commented Apr 3, 2017

and isn't better to use column with name hidden with default value nil (false) ?

@himdel
Copy link
Contributor

himdel commented Apr 3, 2017

Agreed @enoodle no problem with this assuming visible deafults to true. Altough, I think the filtering on visible = true should be done in custom_attribte_mixin.rb instead of in the UI.

people accountable for relevant providers should convert their code.

@moolitayer That's IMHO exactly the wrong approach. The only way for us to treat custom attributes consistently is to exactly not let provider-specific people touch that code :). (That said, @enoodle's UI PR is fine IMHO :).)

@gmcculloug
Copy link
Member

I agree with @himdel that the visible flag should default to true as this is used extensively today to show data on Services, VMs and other objects.

Two things are missing here:

  1. The default_value_for to set this to true
  2. A data migration (and spec) to set the field for existing custom_attribute instances.

@lpichler We tend to prefer the positive field name visible over the opposite. It simplifies the question "is something visible" or "should it be shown" instead of having to reverse the logic and ask "is something NOT hidden". And if you default the value you do not have to play the boolean = nil game.

Also need to expose setting more properties of the custom_attributes from automate but I would expect that in a separate PR.

@lpichler
Copy link
Contributor

lpichler commented Apr 3, 2017

A data migration (and spec) to set the field for existing custom_attribute instances.

This data migration please to the separated migration.

@enoodle enoodle force-pushed the visible_field_for_custom_attributes branch 2 times, most recently from 7ae0064 to 72a9f77 Compare April 3, 2017 14:09
@@ -0,0 +1,9 @@
class SetVisibleToTruedForCustomAttributes < ActiveRecord::Migration[5.0]
def up
CustomAttribute.where(:visible => nil).update_all(:visible => true)
Copy link
Member

Choose a reason for hiding this comment

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

We are adding the column so all rows would be nil. I do not see a need for where(:visible => nil)?

I realize someone could rollback to this migration without removing the column, but that seems highly unlikely and in my opinion more of a reason to include this in the migration that adds the column.

@lpichler What is the need to have this in a separate migration?

Copy link
Author

Choose a reason for hiding this comment

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

@gmcculloug I removed the where(:visible => nil).

@@ -0,0 +1,5 @@
class AddVisibleFieldForCustomAttributes < ActiveRecord::Migration[5.0]
def change
add_column :custom_attributes, :visible, :boolean, default: true
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the default here as well as the default_value_for? I would have expected just the default_value_for setting.

cc @Fryguy

Copy link
Author

Choose a reason for hiding this comment

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

@gmcculloug I removed the default: true from the migration itself.

@enoodle enoodle force-pushed the visible_field_for_custom_attributes branch 2 times, most recently from 54a72cd to 3efe49b Compare April 3, 2017 14:41
@enoodle enoodle force-pushed the visible_field_for_custom_attributes branch from 3efe49b to 00d5a92 Compare April 3, 2017 16:41
@miq-bot
Copy link
Member

miq-bot commented Apr 3, 2017

Checked commit enoodle@00d5a92 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
5 files checked, 1 offense detected

db/migrate/20170403135631_set_visible_to_true_for_custom_attributes.rb

@enoodle
Copy link
Author

enoodle commented Apr 24, 2017

@miq-bot add_label fine/no

can we take another look at this?

The default_value_for to set this to true
A data migration (and spec) to set the field for existing custom_attribute instances.

Added

CustomAttribute.update_all(:visible => true)
end

def down
Copy link
Member

Choose a reason for hiding this comment

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

@enoodle For future reference, there is no need to include the down method if it is empty.

Copy link
Member

Choose a reason for hiding this comment

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

@enoodle Yes, please remove the empty down migration.

@simon3z
Copy link
Contributor

simon3z commented May 15, 2017

@enoodle can you give an example (probably related to containers) where you expect this set to false (not visible)? (Maybe I missed one of your messages on this)

Copy link
Contributor

@simon3z simon3z left a comment

Choose a reason for hiding this comment

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

Per previous comment this needs an example/explanation.

@chessbyte
Copy link
Member

@enoodle @simon3z bump

@enoodle
Copy link
Author

enoodle commented Jun 4, 2017

@simon3z It can be used to prevent displaying of custom attributes in the UI, for example the http_proxy ones that are from "cluster_settings" section.

@simon3z
Copy link
Contributor

simon3z commented Jun 6, 2017

@simon3z It can be used to prevent displaying of custom attributes in the UI, for example the http_proxy ones that are from "cluster_settings" section.

@enoodle didn't we say that visibility is by section? E.g. none of the cluster_settings sections should be visible.
The cluster_settings should have a specific configuration page.

@enoodle
Copy link
Author

enoodle commented Jun 7, 2017

@simon3z we had ManageIQ/manageiq-ui-classic#290 to control the visibility by section but then the discussion lead to this PR. I can try to re-open this or make a new one with a more wide reach across all providers to prevent showing custom attributes from certain sections but I have the feeling that there is some resistance to it from the UI/Automate team.

@himdel
Copy link
Contributor

himdel commented Jun 7, 2017

👍 Visibility by section was abandoned because of the problems it would bring to all existing code and uses.
Per-attribute visiblity can be handled cleanly in the UI and won't affect existing users.
I'd say this is good to go..

@simon3z
Copy link
Contributor

simon3z commented Jun 8, 2017

@himdel @enoodle I think there is some confusion around what we're really doing here.

Maybe at the end of the discussion this implementation will be OK but I feel that we're missing some background with a broader forum.

I'll organize a meeting. For me for the time being at least for the use-case I have this is 👎 .

@himdel
Copy link
Contributor

himdel commented Jun 8, 2017

@simon3z Please document your reasons and problems of this implementation in a textual form. If you need a meeting, it can happen after (I'm on PTO the rest of the week, sorry).

But the short story is, there's limited number of things you can do with custom attributes without affecting everybody else, and if you need to have a concept of hidden sections, then you'd need a concept of sections as an entity. Which means migrations, etc.

Per-attribute visibility is a general case that should cover any use case that would be solved by per-section visiblity, so .. please be specific about what your needs and constraints really are :).

end

def up
CustomAttribute.update_all(:visible => true)
Copy link
Member

Choose a reason for hiding this comment

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

Please wrap this in a say_with_time as per the other data migrations.

@Fryguy
Copy link
Member

Fryguy commented Jun 13, 2017

Since ManageIQ/manageiq-ui-classic#290 is closed, should this be closed as well, or is a discussion still happening?

@enoodle
Copy link
Author

enoodle commented Jun 15, 2017

@Fryguy No, this PR goes with ManageIQ/manageiq-ui-classic#881

@simon3z
Copy link
Contributor

simon3z commented Jun 22, 2017

@himdel @enoodle after the last discussion I think we can close this.

@himdel
Copy link
Contributor

himdel commented Jun 22, 2017

@simon3z I guess so.. can you please summarize the result of that discussion? (I had to leave the meeting before it ended, so.. not sure which solution you settled on in the end..)

@simon3z
Copy link
Contributor

simon3z commented Jun 22, 2017

@simon3z I guess so.. can you please summarize the result of that discussion? (I had to leave the meeting before it ended, so.. not sure which solution you settled on in the end..)

@himdel the discussion resulted in #15398

@miq-bot
Copy link
Member

miq-bot commented Jun 22, 2017

This pull request is not mergeable. Please rebase and repush.

@Fryguy
Copy link
Member

Fryguy commented Jun 22, 2017

Database migrations have now been moved to the https://github.com/ManageIQ/manageiq-schema repo. Please see http://talk.manageiq.org/t/new-split-repo-manageiq-schema/2478 for instructions on how to transfer your database migrations. If this PR contains only migrations, I will leave it open for a short time during the transition, after which I will close this if it has not been moved over.

@enoodle enoodle closed this Jun 25, 2017
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.

10 participants