Skip to content
Snippets Groups Projects
Commit 19ce04ee authored by Alex Pott's avatar Alex Pott Committed by catch
Browse files

Issue #3474123 by plopesc, smustgrave, alexpott: Reorganize navigation...

Issue #3474123 by plopesc, smustgrave, alexpott: Reorganize navigation settings to be more consistent
parent bde2c01a
Branches
Tags
5 merge requests!122353526426-warning-for-missing,!11958Issue #3490507 by alexpott, smustgrave: Fix bogus mocking in...,!11769Issue #3517987: Add option to contextual filters to encode slashes in query parameter.,!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!9944Issue #3483353: Consider making the createCopy config action optionally fail...
Pipeline #313702 passed with warnings
Pipeline: drupal

#313718

    Pipeline: drupal

    #313712

      Pipeline: drupal

      #313707

        +1
        logo_provider: default logo:
        logo_managed: null provider: default
        logo_max_filesize: 1048576 managed: null
        logo_height: 40 max:
        logo_width: 40 filesize: 1048576
        height: 40
        width: 40
        ...@@ -6,42 +6,54 @@ navigation.settings: ...@@ -6,42 +6,54 @@ navigation.settings:
        constraints: constraints:
        FullyValidatable: ~ FullyValidatable: ~
        mapping: mapping:
        logo_provider: logo:
        type: string type: mapping
        label: 'Select Navigation logo handling' label: 'Logo settings'
        mapping:
        provider:
        type: string
        label: 'Select Navigation logo handling'
        constraints:
        Choice:
        - default
        - hide
        - custom
        managed:
        type: integer
        label: 'Custom logo'
        nullable: true
        constraints:
        Range:
        min: 0
        max:
        type: mapping
        label: 'Logo maximum settings'
        mapping:
        filesize:
        type: integer
        label: 'Maximum file sizes (bytes)'
        constraints:
        NotNull: [ ]
        Range:
        min: 0
        height:
        type: integer
        label: 'Logo expected height'
        constraints:
        NotNull: [ ]
        Range:
        min: 0
        width:
        type: integer
        label: 'Logo expected width'
        constraints:
        NotNull: [ ]
        Range:
        min: 0
        constraints:
        ValidKeys: '<infer>'
        constraints: constraints:
        Choice: ValidKeys: '<infer>'
        - default
        - hide
        - custom
        logo_managed:
        type: integer
        label: 'Custom logo'
        nullable: true
        constraints:
        Range:
        min: 0
        logo_max_filesize:
        type: integer
        label: 'Maximum file sizes (bytes)'
        constraints:
        NotNull: [ ]
        Range:
        min: 0
        logo_height:
        type: integer
        label: 'Logo expected height'
        constraints:
        NotNull: [ ]
        Range:
        min: 0
        logo_width:
        type: integer
        label: 'Logo expected width'
        constraints:
        NotNull: [ ]
        Range:
        min: 0
        navigation.block_layout: navigation.block_layout:
        type: config_object type: config_object
        ......
        ...@@ -23,3 +23,22 @@ function navigation_requirements($phase) { ...@@ -23,3 +23,22 @@ function navigation_requirements($phase) {
        return $requirements; return $requirements;
        } }
        /**
        * Reorganizes the values for the logo settings.
        */
        function navigation_update_11001(array &$sandbox): void {
        $settings = \Drupal::configFactory()->getEditable('navigation.settings');
        $settings->setData([
        'logo' => [
        'provider' => $settings->get('logo_provider'),
        'managed' => $settings->get('logo_managed'),
        'max' => [
        'filesize' => $settings->get('logo_max_filesize'),
        'height' => $settings->get('logo_height'),
        'width' => $settings->get('logo_width'),
        ],
        ],
        ]);
        $settings->save(TRUE);
        }
        ...@@ -108,7 +108,7 @@ public function buildForm(array $form, FormStateInterface $form_state): array { ...@@ -108,7 +108,7 @@ public function buildForm(array $form, FormStateInterface $form_state): array {
        NavigationRenderer::LOGO_PROVIDER_HIDE => $this->t('Hide logo'), NavigationRenderer::LOGO_PROVIDER_HIDE => $this->t('Hide logo'),
        NavigationRenderer::LOGO_PROVIDER_CUSTOM => $this->t('Custom logo'), NavigationRenderer::LOGO_PROVIDER_CUSTOM => $this->t('Custom logo'),
        ], ],
        '#config_target' => 'navigation.settings:logo_provider', '#config_target' => 'navigation.settings:logo.provider',
        ]; ];
        $form['logo']['image'] = [ $form['logo']['image'] = [
        '#type' => 'container', '#type' => 'container',
        ...@@ -119,8 +119,8 @@ public function buildForm(array $form, FormStateInterface $form_state): array { ...@@ -119,8 +119,8 @@ public function buildForm(array $form, FormStateInterface $form_state): array {
        ], ],
        ]; ];
        $allowed = 'png jpg jpeg'; $allowed = 'png jpg jpeg';
        $current_logo_managed_fid = $config->get('logo_managed') ? [$config->get('logo_managed')] : NULL; $current_logo_managed_fid = $config->get('logo.managed') ? [$config->get('logo.managed')] : NULL;
        $max_navigation_allowed = $config->get('logo_max_filesize'); $max_navigation_allowed = $config->get('logo.max.filesize');
        $max_system_allowed = Environment::getUploadMaxSize(); $max_system_allowed = Environment::getUploadMaxSize();
        $max_allowed = $max_navigation_allowed < $max_system_allowed ? $max_navigation_allowed : $max_system_allowed; $max_allowed = $max_navigation_allowed < $max_system_allowed ? $max_navigation_allowed : $max_system_allowed;
        $upload_validators = [ $upload_validators = [
        ...@@ -166,8 +166,8 @@ public function submitForm(array &$form, FormStateInterface $form_state): void { ...@@ -166,8 +166,8 @@ public function submitForm(array &$form, FormStateInterface $form_state): void {
        $config = $this->config('navigation.settings'); $config = $this->config('navigation.settings');
        // Get the previous config settings. // Get the previous config settings.
        $previous_logo_provider = $config->get('logo_provider'); $previous_logo_provider = $config->get('logo.provider');
        $previous_logo_fid = $config->get('logo_managed'); $previous_logo_fid = $config->get('logo.managed');
        // Get new values from the form. // Get new values from the form.
        $new_logo_provider = $form_state->getValue('logo_provider'); $new_logo_provider = $form_state->getValue('logo_provider');
        ...@@ -195,7 +195,7 @@ public function submitForm(array &$form, FormStateInterface $form_state): void { ...@@ -195,7 +195,7 @@ public function submitForm(array &$form, FormStateInterface $form_state): void {
        } }
        $config $config
        ->set('logo_managed', $new_logo_fid) ->set('logo.managed', $new_logo_fid)
        ->save(); ->save();
        parent::submitForm($form, $form_state); parent::submitForm($form, $form_state);
        } }
        ...@@ -215,12 +215,12 @@ protected function validateLogoManaged(array $form, FormStateInterface $form_sta ...@@ -215,12 +215,12 @@ protected function validateLogoManaged(array $form, FormStateInterface $form_sta
        return; return;
        } }
        $width = $config->get('logo_width'); $width = $config->get('logo.max.width');
        $height = $config->get('logo_height'); $height = $config->get('logo.max.height');
        // Skip if the fid has not been modified. // Skip if the fid has not been modified.
        $fid = reset($logo_managed); $fid = reset($logo_managed);
        if ($fid == $config->get('logo_managed')) { if ($fid == $config->get('logo.managed')) {
        return; return;
        } }
        ...@@ -251,8 +251,8 @@ protected function adjustLogoDimensions(File $file): bool { ...@@ -251,8 +251,8 @@ protected function adjustLogoDimensions(File $file): bool {
        return FALSE; return FALSE;
        } }
        $width = $config->get('logo_width'); $width = $config->get('logo.max.width');
        $height = $config->get('logo_height'); $height = $config->get('logo.max.height');
        if ($image->getWidth() <= $width && $image->getHeight() <= $height) { if ($image->getWidth() <= $width && $image->getHeight() <= $height) {
        return TRUE; return TRUE;
        ......
        ...@@ -101,7 +101,7 @@ public function removeToolbar(array &$page_top): void { ...@@ -101,7 +101,7 @@ public function removeToolbar(array &$page_top): void {
        */ */
        public function buildNavigation(array &$page_top): void { public function buildNavigation(array &$page_top): void {
        $logo_settings = $this->configFactory->get('navigation.settings'); $logo_settings = $this->configFactory->get('navigation.settings');
        $logo_provider = $logo_settings->get('logo_provider'); $logo_provider = $logo_settings->get('logo.provider');
        $cacheability = new CacheableMetadata(); $cacheability = new CacheableMetadata();
        $contexts = [ $contexts = [
        ...@@ -144,7 +144,7 @@ public function buildNavigation(array &$page_top): void { ...@@ -144,7 +144,7 @@ public function buildNavigation(array &$page_top): void {
        $page_top['navigation'] = $build; $page_top['navigation'] = $build;
        if ($logo_provider === self::LOGO_PROVIDER_CUSTOM) { if ($logo_provider === self::LOGO_PROVIDER_CUSTOM) {
        $logo_managed = File::load($logo_settings->get('logo_managed')); $logo_managed = File::load($logo_settings->get('logo.managed'));
        if ($logo_managed instanceof FileInterface) { if ($logo_managed instanceof FileInterface) {
        $logo_managed_uri = $logo_managed->getFileUri(); $logo_managed_uri = $logo_managed->getFileUri();
        $logo_managed_url = $this->fileUrlGenerator->generateAbsoluteString($logo_managed_uri); $logo_managed_url = $this->fileUrlGenerator->generateAbsoluteString($logo_managed_uri);
        ......
        ...@@ -92,8 +92,8 @@ public function testSettingsLogoOptionsForm(): void { ...@@ -92,8 +92,8 @@ public function testSettingsLogoOptionsForm(): void {
        // Preset the configuration to verify a custom image is being seen. // Preset the configuration to verify a custom image is being seen.
        $config = $this->configFactory->getEditable('navigation.settings'); $config = $this->configFactory->getEditable('navigation.settings');
        $config->set('logo_provider', 'custom'); $config->set('logo.provider', 'custom');
        $config->set('logo_managed', $logo_file->id()); $config->set('logo.managed', $logo_file->id());
        $config->save(); $config->save();
        // Refresh the page to verify custom logo is placed. // Refresh the page to verify custom logo is placed.
        $this->drupalGet('/admin/config/user-interface/navigation/settings'); $this->drupalGet('/admin/config/user-interface/navigation/settings');
        ......
        ...@@ -38,8 +38,8 @@ protected function setUp(): void { ...@@ -38,8 +38,8 @@ protected function setUp(): void {
        // Set expected logo dimensions smaller than core provided test images. // Set expected logo dimensions smaller than core provided test images.
        \Drupal::configFactory()->getEditable('navigation.settings') \Drupal::configFactory()->getEditable('navigation.settings')
        ->set('logo_height', 10) ->set('logo.max.height', 10)
        ->set('logo_width', 10) ->set('logo.max.width', 10)
        ->save(); ->save();
        } }
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment