There are multiple issues sitting in the queue right now trying to outline and address the problems with the site form and platform access controls mechanisms.

This issue aims to regroup all those issues together to get an overview of the situation and try to document the best approach to fix them in the future.

#952700: Site form, duplication, and platform access control (saga continues)
#894046: language dialog should be a drop-down, not radios
#955854: Site form can be very slow with huge number of platforms and packages
#725952: implement node-level access permissions for platforms
#937490: Fix Platform access control to deal with profile > platform paradigm

Original implementation:

#558450: platform access control / permissions

Comments

anarcat’s picture

Title: meta: refactor site form and platform access control » meta: refactor site form
chertzog’s picture

Version: 6.x-0.4-alpha3 » 7.x-3.x-dev

I posted a patch in #2061509: List of platforms is no longer updated to match install profile clicked at node/add/site comment 2 that ajaxifies the profile/platform selections.

We should be able to leverage the same technique for the language selector. Using the referenced patch with something like this:

  $platforms = hosting_get_profile_platforms($selected_profile);
  _hosting_site_field($form, $node, 'platform', array(
    '#type' => 'radios',
    '#title' => t('Platform'),
    '#required' => TRUE,
    '#description' => t('The platform you want the site to be hosted on.<br />
                          Not seeing a certain platform? Platforms shown are those that support the profile above.
                          If a different profile is selected, this list may change automatically.'),
    '#options' => $platforms,
    '#default_value' => isset($node->platform) ? $node->platform : NULL,
    '#ajax' => array(
      'callback' => 'hosting_site_language_callback',
      'wrapper' => 'hosting-site-field-site-language' ,
      'effect' => 'fade',
      'event' => 'change',
      'method' => 'replace',
    ),
  ), '_hosting_node_link');

  // Override the defaults if the profile has been changed.
  if (isset($form_state['values']['platform'])) {
    $selected_platform = $form_state['values']['platform'];
  }
  else{
    $selected_platform = NULL;
  }
  $languages = hosting_get_profile_languages($selected_profile, $selected_platform);
  _hosting_site_field($form, $node, 'site_language', array(
    '#type' => 'select',
    '#title' => t('Language'),
    '#description' => t('The language of site being installed.'),
    '#options' => $languages,
    '#required' => TRUE,
    '#default_value' => isset($node->site_language) ? $node->site_language : 'en',
    '#attributes' => array('class' => array("hosting-site-form-site-language-options")),
  ), '_hosting_language_name');

...

function hosting_site_language_callback($form, &$form_state){
  return $form['site_language'];
}

These changes would (as far as i can tell), remove the need for the $form['#pre_render'][] = '_hosting_site_form_pre_render'; call at the beginning of hosting_site_form(), the entire "_hosting_site_form_pre_render" function, and the entire hosting_site.form.js file.

The above code also address the issue #894046: language dialog should be a drop-down, not radios, by changing the radios to a select.

anarcat’s picture

whoa, that looks very promising! can you throw a patch into #894046: language dialog should be a drop-down, not radios?

helmo’s picture

Issue summary: View changes
Status: Active » Needs review
Issue tags: +Needs issue summary update

  • Commit 00c9c27 on 7.x-3.x, dev-helmo-3.x authored by chertzog, committed by helmo:
    Issue #967888 by chertzog: Meta: refactor site form.
    

  • Commit 00c9c27 on 7.x-3.x, dev-helmo-3.x authored by chertzog, committed by helmo:
    Issue #967888 by chertzog: Meta: refactor site form.
    
helmo’s picture

Status: Needs review » Fixed
ergonlogic’s picture

Status: Fixed » Needs work
Issue tags: +Aegir 3.0.0

The site form is still a mess of custom code to do the AJAX rebuilding of the platform list based on the profile, etc. Unless I'm mistaken, much of that dates back to Drupal 5. We should consider ditching our custom code in favour of the standard AJAX form methods provided by D7.

Also, a couple of the issues listed in the summary remain open.

  • helmo committed 00c9c27 on dev-helmo-3.x authored by chertzog
    Issue #967888 by chertzog: Meta: refactor site form.
    

  • helmo committed 00c9c27 on 7.x-3.x-1995506 authored by chertzog
    Issue #967888 by chertzog: Meta: refactor site form.
    

  • helmo committed 00c9c27 on dev-2223033 authored by chertzog
    Issue #967888 by chertzog: Meta: refactor site form.
    

  • helmo committed 00c9c27 on dev-2359571 authored by chertzog
    Issue #967888 by chertzog: Meta: refactor site form.
    
realityloop’s picture

I really think when adding a site that we should be displaying the platform select before the profiles list, it's somewhat confusing at the moment when you are shown a really long list of platforms some with profiles that are under multiple platforms with different core versions..

helmo’s picture

Could we, with proper use of the field API, make it so that one could change the ordering on admin/structure/types/manage/site/fields?

realityloop’s picture

After building a few platforms and sites the past few days I think one of the main issues currently is that the list of profiles does not get updated when you select a platform that only applies to a subset of them.

I don't think the field order matters that much is both groups update when you click on the other groups radio buttons.

  • helmo committed 00c9c27 on 7.x-4.x authored by chertzog
    Issue #967888 by chertzog: Meta: refactor site form.