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

[RFE] Add Clone dashboard form #5730

Merged
merged 3 commits into from
Jul 8, 2019
Merged

Conversation

rvsia
Copy link
Contributor

@rvsia rvsia commented Jun 20, 2019

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1314875

Based on #5728 https://github.com/ManageIQ/manageiq/pull/18550/files

Cloud Intel > Reports > Dashboards > Select one > 'Configuration' > 'Copy selected Dashboard'

Description

  • Allow users to copy dashboard into the same group/different one
  • Uses async validation for checking name

After

clone dashboard

@yrudman
Copy link
Contributor

yrudman commented Jun 20, 2019

PR to keep widgets: ManageIQ/manageiq#18900

@martinpovolny
Copy link
Member

We will discuss with @h-kataria if there should be a multi select for the groups.

@rvsia
Copy link
Contributor Author

rvsia commented Jun 21, 2019

@h-kataria @martinpovolny

After the changes in backend copying is working well! 👍

image

  1. I set initialValue of the Select group dropdown to the group of the selected dashboard - it will make a better experience for users, who just want to copy in the same group quickly

  2. I set a validation which checks if the name is different from the original. Should I implement async validation which will check uniqueness across all dashboards? (Probably need to change the endpoint to searching by name)

  3. So, shoud the group selection be multiselect?

@rvsia rvsia force-pushed the rfe-clone-dashboard branch from 29ca64a to 510e209 Compare June 21, 2019 14:24
@h-kataria
Copy link
Contributor

@rvsia this looks good.
If possible we should implement async validation of uniqueness of Dashboard name within each selected group.
And yes, the groups selection should be multi-select, @yrudman was going to create a PR on the model side to accept multiple groups for cloning of dashboards.

@yrudman
Copy link
Contributor

yrudman commented Jun 21, 2019

@h-kataria at this point dashboard name should be unique. Attempt to create dashboard with the same name for another group generates error:
Screen Shot 2019-06-21 at 11 30 49 AM

@yrudman
Copy link
Contributor

yrudman commented Jun 21, 2019

it means that multiselect will work only if we dynamically append to the supplied name something to create unique name. I do not think mutiselect in the scope of original RFE

@martinpovolny
Copy link
Member

it means that multiselect will work only if we dynamically append to the supplied name something to create unique name. I do not think mutiselect in the scope of original RFE

I agree with @yrudman. Let's finish the work as it is now.

And let's ping @Loicavenel if he has comments or wants to update the requirements. If so we can do a follow-up PR and extend the copying to multiple groups once we figure what to do with the name.

@martinpovolny martinpovolny self-assigned this Jun 21, 2019
@rvsia rvsia force-pushed the rfe-clone-dashboard branch from e949340 to 8d9adc4 Compare June 24, 2019 11:44
@rvsia
Copy link
Contributor Author

rvsia commented Jun 24, 2019

@miq-bot add_label hammer/no, react, enhancement, changelog/yes, cloud intel/dashboard, dashboards,

@rvsia rvsia changed the title [WIP] RFE: Clone dashboard [WIP] RFE: Add Clone dashboard form Jun 24, 2019
@rvsia rvsia force-pushed the rfe-clone-dashboard branch 4 times, most recently from fb3ad5d to 3a6bd9f Compare June 25, 2019 12:33
@rvsia rvsia changed the title [WIP] RFE: Add Clone dashboard form [WIP] [RFE] Add Clone dashboard form Jun 25, 2019
@rvsia
Copy link
Contributor Author

rvsia commented Jun 25, 2019

@h-kataria

image

This button was added by the previous PR, but I don't see any way how to select any dashboard. am I right?

@h-kataria
Copy link
Contributor

h-kataria commented Jun 26, 2019

@gtanzillo @yrudman changing the scope to

validates_uniqueness_of   :name,
                              :scope => [:set_type, :owner],
                              :if    => proc { |c| c.class.in_my_region.exists?(:name => c.name) }

fixes it and seems to be working as expected

@yrudman
Copy link
Contributor

yrudman commented Jun 26, 2019

@h-kataria yes, it is original design, when dashboards assigned to group owner_id represent group this dashboard assigned to, and group_id is nil
there are some comments explaining it: https://github.com/ManageIQ/manageiq/blob/c532321e256d57c3e427122fd4efda5420a239f8/app/models/miq_widget_set.rb#L12

@yrudman
Copy link
Contributor

yrudman commented Jun 26, 2019

Ohh, I submitted my comment on original Harpreet's question ...

@h-kataria
Copy link
Contributor

h-kataria commented Jun 26, 2019

@yrudman when adding a new dashboard for a group, userid cannot be populated anyway so setting owner of group makes more sense. The scope should not be checking for userid i believe, changing the scope to check for set_type and owner fields will work in this case.

@yrudman
Copy link
Contributor

yrudman commented Jun 26, 2019

I am not sure @h-kataria , for personal dashboards owner is nil and changed validation will impose the same restriction on personal dashboard name as we have now for groups - should be unique name between all user

@h-kataria
Copy link
Contributor

@yrudman how can we populate userid when adding a new Dashboard for a group and users within the group can have a Dashboard with same name. Copy of user's dashboard is added when user logs in for the first time using same name.

@h-kataria
Copy link
Contributor

@rvsia @gtanzillo @yrudman so i got this working by adding a line after
https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/report_controller/dashboards.rb#L74
@dashboard.group_id = g.id
Adding this lets me save a Dashboard with a unique name within a group.

@@ -51,6 +51,61 @@ def db_new
db_edit
end

def db_copy
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose there is no API support for copy action right?

If not, can you please create a note to the forms sheet so we don't forget to add it afterwards?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 Yeah, after merging this I will update the sheet!

Copy link
Contributor

Choose a reason for hiding this comment

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

@rvsia once we have API support for this, we can enhance this form to show the list of widgets that are part of Dashboard that's getting copied.

@yrudman
Copy link
Contributor

yrudman commented Jun 27, 2019

@h-kataria right, saving group_id will allow to bypass existing validation.

To implement this we would need:

I still think that copying dashboard to multiple groups is out of scope of original RFE

@h-kataria
Copy link
Contributor

@h-kataria right, saving group_id will allow to bypass existing validation.

To implement this we would need:

I still think that copying dashboard to multiple groups is out of scope of original RFE

@Loicavenel is it ok, to only copy a dashboard for a single Group.
@yrudman we still need to fix this so atleast the same dashboard name can be saved for a different group.


return http.post(`/report/db_copy/${dashboardId}?button=save`, data, { skipErrors: [400] })
.then(() => miqAjaxButton('/report/dashboard_render'))
.catch(handleError, miqSparkleOff);
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think that you can have multiple executors in promise callbacks(unless we have some polyfill). It will only execute the first one handleError.

@h-kataria
Copy link
Contributor

@rvsia i had a discussion with @gtanzillo fixing the Dashboard naming issue to be unique only within a group is a high risk and might introduce other issues at this time, so i am going to open a new GH issue to analyze and address the issue separately in follow up PR. For this PR we will go with single group Copy with a unique Dashboard name, the way you have in your current PR.

@h-kataria
Copy link
Contributor

opened a GH issue in core repo ManageIQ/manageiq#18924

@rvsia rvsia force-pushed the rfe-clone-dashboard branch from 6d8df75 to 3899b3a Compare July 1, 2019 14:45
@rvsia
Copy link
Contributor Author

rvsia commented Jul 1, 2019

@h-kataria

I changed the success message:

image

@rvsia rvsia force-pushed the rfe-clone-dashboard branch from 3899b3a to b8087c7 Compare July 1, 2019 15:06
@miq-bot
Copy link
Member

miq-bot commented Jul 2, 2019

Checked commits rvsia/manageiq-ui-classic@f34a048~...b8087c7 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
5 files checked, 2 offenses detected

app/controllers/report_controller/dashboards.rb

spec/controllers/miq_report_controller/dashboards_spec.rb

@terezanovotna
Copy link

Hey guys,

When we copy a dashboard, I expect seeing a duplicate of previous dashboard, but the current implementation is not showing the dashboard part.

This is a screenshot of catalog I want to copy
screenshot-localhost-3000-2019 07 03-13-40-05

This is a screenshot of copied catalog (which misses a dashboard section)
screenshot-localhost-3000-2019 07 03-13-40-15

I expect seeing a dashboard part in copied the catalog. Or even better, when copied, take the user to an edit mode of copied catalog. These are my suggestions to improve the flow, so it is easier for the user.
screenshot-localhost-3000-2019 07 03-13-40-29

@terezanovotna
Copy link

Adding @MariSvirik to review.

@rvsia
Copy link
Contributor Author

rvsia commented Jul 3, 2019

@terezanovotna

  1. Should the dashboard part be editable in the copy form or should it just show what is being copied? (We would need to create some new form component in React)
  2. I agree with redirection of users to the new created (copied) dashboard (but it won't work anymore when (if) we will support copying to multiple group), however I was following instructions from BZ.
1. In the settings of dashboard, add "Copy" option. 
2. It opens up the screen where we can a)change name of the copy b)add area where we want to place the dashboard (pf3 multiselect - bootstrap version)
3. Receive a notification with what was copied. 
4. the user is taken where he started.

@h-kataria
Copy link
Contributor

@terezanovotna it was decided to copy a dashboard and allow user to provide a name, description and a Group that the Dashboard will be copied to. If user wants to edit the Dashboard they will have to go to new Dashboard after creating a copy and then do it there. So this is working as designed.

@h-kataria
Copy link
Contributor

@terezanovotna is this good to be merged?

@terezanovotna
Copy link

this can be merged, but we are not improving user experience.

The dashboard part needs to be shown in the cloned dashboard.

@h-kataria h-kataria added this to the Sprint 115 Ending Jul 8, 2019 milestone Jul 8, 2019
@h-kataria h-kataria merged commit a717862 into ManageIQ:master Jul 8, 2019
@rvsia rvsia deleted the rfe-clone-dashboard branch December 10, 2019 14:24
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.

8 participants