Adding Search Bar Functionality for Cloud Tenant Show Page
Dhamo1107 opened this issue · 7 comments
Summary:
- I'm trying to implement a search bar functionality on the Cloud Tenant Show page using the SearchBar React component.
Implementation Details:
Frontend:
- SearchBar component added to the Cloud Tenant Show.html.haml page with advanced search props is set to false
Backend Integration Needed:
- Need guidance on where to add the backend logic to handle search text parameters.
Any guidance on integrating the search functionality with the backend would be highly beneficial. Specifically:
-
In
CloudTenantController
,GenericShowMixin
is included, So the show method is inGenericShowMixin
, in this how to handle search params and send data to front end based on search params -
How to update the view with filtered data?
Thank you for your assistance.
I'm not too sure on how we can add search bars to these embedded list pages. It looks like this pr: #9190 is doing the same thing if you wanted to check out the code and try to see if it works locally. I haven't had a chance to review the pr so not sure if it works or not.
Hi @GilbertCherrie,
Thanks for your opinion. I have completed that feature by making the following changes:
-
Updated Condition in
get_view_process_search_text
Method inapplication_controller.rb
:
return nil if @display || @in_a_form
=>return nil if @in_a_form
We have images in @display, so it was returning nil.
if (!@parent && @lastaction == "show_list") || @explorer
=>if (!@parent && @lastaction == "show_list") || @explorer || @display
Added @display to the condition to proceed with the next steps. -
Added Search Bar in
show.html.haml
:
.display-search-bar
= react('SearchBar', searchText: @search_text, action: 'show', advancedSearch: false)
After making these changes, the search bar is working perfectly for images, instances, security groups, cloud volumes, etc., in tenants page in the cloud menu.
I am currently looking into how to run test cases to ensure existing functionalities are working correctly. If you have any insights on the get_view_process_search_text method in the application controller, please guide me on whether this approach is correct. You can also check this locally.
Thanks!
I'm not too familiar with this function. If anything just finish the pr and we can review it at the end to make sure everything is correct.
Hi @GilbertCherrie, I have created the PR please check it! #9225
@Dhamo1107 Thank you for the pr. We will take a look when we have the chance and discuss any changes in the pr.