Verified Commit 288f761c authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #2622468 by smustgrave, Leticia Gauna, ranjith_kumar_k_u, Pancho, idebr,...

Issue #2622468 by smustgrave, Leticia Gauna, ranjith_kumar_k_u, Pancho, idebr, kostyashupenko, tim.plunkett: Export single simple configuration name has no empty value, resulting in confusing UI
parent 5a6c7983
Loading
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -154,8 +154,9 @@ public function updateExport($form, FormStateInterface $form_state) {
      $name = $form_state->getValue('config_name');
    }
    // Read the raw data for this config name, encode it, and display it.
    $form['export']['#value'] = Yaml::encode($this->configStorage->read($name));
    $form['export']['#description'] = $this->t('Filename: %name', ['%name' => $name . '.yml']);
    $exists = $this->configStorage->exists($name);
    $form['export']['#value'] = !$exists ? NULL : Yaml::encode($this->configStorage->read($name));
    $form['export']['#description'] = !$exists ? NULL : $this->t('Filename: %name', ['%name' => $name . '.yml']);
    return $form['export'];
  }

@@ -187,7 +188,7 @@ protected function findConfiguration($config_type) {
      }, $this->definitions);

      // Find all config, and then filter our anything matching a config prefix.
      $names = $this->configStorage->listAll();
      $names += $this->configStorage->listAll();
      $names = array_combine($names, $names);
      foreach ($names as $config_name) {
        foreach ($config_prefixes as $config_prefix) {
+7 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ public function testAjaxOnExportPage() {

    // Check that the export is empty on load.
    $this->drupalGet('admin/config/development/configuration/single/export');
    $this->assertTrue($this->assertSession()->optionExists('edit-config-name', '- Select -')->isSelected());
    $this->assertSession()->fieldValueEquals('export', '');

    // Check that the export is filled when selecting a config name.
@@ -40,6 +41,12 @@ public function testAjaxOnExportPage() {
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->assertSession()->fieldValueNotEquals('export', '');

    // Check that the export is empty when selecting "- Select -" option in
    // the config name.
    $page->selectFieldOption('config_name', '- Select -');
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->assertSession()->fieldValueEquals('export', '');

    // Check that the export is emptied again when selecting a config type.
    $page->selectFieldOption('config_type', 'Action');
    $this->assertSession()->assertWaitOnAjaxRequest();