Bug 812031

Summary: Satellite 5.4: Wrong sort directions in some drop-down-lists in webUI
Product: [Community] Spacewalk Reporter: Stephen Herr <sherr>
Component: WebUIAssignee: Stephen Herr <sherr>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.8CC: cperry, hmiles, mmello, xdmoon
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: spacewalk-web-1.8.9-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 705154 Environment:
Last Closed: 2012-11-01 16:17:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 705154    
Bug Blocks: 871344    

Description Stephen Herr 2012-04-12 15:09:35 UTC
+++ This bug was initially created as a clone of Bug #705154 +++

Created attachment 499215 [details]
Screenshots

Description of problem:

 The sort direction in some drop-down-lists are displayed nor correctly. First of all it is very confusing in the dialogs of managing channels.

 Look the screenshots attached on this Bugzilla for  clarification. 


Version-Release number of selected component (if applicable):
Red Hat Network Satellite 5.4

How reproducible:
100% on a Satellite 5.4 with a lot of channels imported 

  
Actual results:

 The drop-down items are not sorted hierarchical, by following Parent then Child Channels

Expected results:

  The drop-down items are be sorted hierarchical, by following Parent then Child Channels

--- Additional comment from mmello on 2011-05-16 15:57:49 EDT ---

Hello, 

Looking the screenshots attached, we can verify: 

Clone_Channel_from.jpg - Wrong/Buggy
Channel_compare_packages.jpg - Wrong/Buggy
Channel_add_packages_from_channel.jpg - Correct

If you look at the Java source, you will see that while pulling the data from the DB it sorts the channel based on the Channel name for Parent and Child Channels, as expected:

  URL: https://satellite.example.com/rhn/channels/manage/ChannelPackagesAdd.do?manage_channel_navi_node=add_channel_packages&cid=570

  Code: 

<action path="/channels/manage/ChannelPackagesAdd"
        scope="request"
        type="com.redhat.rhn.frontend.action.channel.manage.ChannelPackagesAddAction"
        className="com.redhat.rhn.frontend.struts.RhnActionMapping">
        <forward name="default" path="/WEB-INF/pages/channel/manage/addpackages.jsp" />
          <forward name="confirm" path="/channels/manage/ChannelPackagesAddConfirm.do" redirect="true" />
      </action>

private List<SelectableChannel> findChannels(User user, Long selectedChan) {
        //Add Red Hat Base Channels, and custom base channels
        List<SelectableChannel> chanList = new ArrayList<SelectableChannel>();
        for (Channel chanTmp : ChannelFactory.listRedHatBaseChannels()) {
            if (canAccessChannel(user, chanTmp)) {
                chanList.add(setSelected(chanTmp, selectedChan));
                for (Channel chanChild : chanTmp.getAccessibleChildrenFor(user)) {
                    chanList.add(setSelected(chanChild, selectedChan));
                }
            }
        }
        for (Channel chanTmp : ChannelFactory.listCustomBaseChannels(user)) {
            if (canAccessChannel(user, chanTmp)) {
                chanList.add(setSelected(chanTmp, selectedChan));
                for (Channel chanChild : chanTmp.getAccessibleChildrenFor(user)) {
                    chanList.add(setSelected(chanChild, selectedChan));
                }
            }
        }
        return chanList;
    }

/**
     * Get a list of channels with no org that are not a child
     * @return List of Channels
     */
    public static List<Channel> listRedHatBaseChannels() {
        Map params = new HashMap();
        return singleton.listObjectsByNamedQuery("Channel.findRedHatBaseChannels", params);
    }

<query name="Channel.findRedHatBaseChannels">
        <![CDATA[
                from com.redhat.rhn.domain.channel.Channel as c where c.org is null
                                                and parentChannel is null order by c.name]]>
    </query>
                    **************************

 However, the other two pages (Perl) throws the following query to get the channel lists:

Clone_Channel_from.jpg - Wrong/Buggy
Channel_compare_packages.jpg - Wrong/Buggy

https://satellite.example.com/network/software/channels/manage/clone.pxt
https://satellite.example.com/network/software/channels/manage/packages/compare/index.pxt?cid=570

$query = <<EOQ;
SELECT  ACh.channel_name as NAME, ACh.channel_id as ID, ACh.channel_depth as DEPTH, C.org_id as CHANNEL_ORG_ID
  FROM  rhnAvailableChannels ACh inner join 
        rhnChannel C on C.id = ACh.channel_id  left outer join
        rhnAvailableChannels ACh2 on C.parent_channel = ACh2.channel_id
  where ACh.org_id = :org_id AND (C.parent_channel is NULL or ACH2.org_id = :org_id)
EOQ

  $sth = $dbh->prepare($query);
  $sth->execute_h(org_id => $org_id);


  So, given the information above, we believe that there's a bug in the Perl code.

Cheers, 
Marcelo Moreira de Mello

--- Additional comment from sherr on 2012-04-12 11:07:14 EDT ---

Put in simpler language, the issue here is that we have several drop-down boxes for selecting channels throughout the webui, and they arrange the channels differently on java pages and on perl pages.

Java pages tend to have a hierarchical view of the visible channels, something like this: 

Base Channel 1
  Child Channel 1
  Child Channel 2
  Child Channel 3
Base Channel 2
Base Channel 3
  Child Channel 4
Base Channel 4
Base Channel 5
  Child Channel 5

whereas perl pages tend to organize the channels into flat lists by organization, like so:

My Channels
  Channel 1
  Channel 2
  Channel 3
  Channel 4
  Channel 5
Red Hat Chanenls
  Channel 6
  Channel 7
  Channel 8

Perl pages when they do try to also sort hierarchical tend to get it wrong. This bug is asking that we standardize one one way of listing the channels, preferably the java (newer) way.

Comment 1 Stephen Herr 2012-04-12 15:20:07 UTC
Committed to Spacewalk master: 893bc22592af1a354037335f9bc2559f09d1056a

Comment 2 Jan Pazdziora 2012-10-30 19:22:49 UTC
Moving ON_QA. Packages that address this bugzilla should now be available in yum repos at http://yum.spacewalkproject.org/nightly/

Comment 3 Jan Pazdziora 2012-11-01 16:17:49 UTC
Spacewalk 1.8 has been released: https://fedorahosted.org/spacewalk/wiki/ReleaseNotes18