Uploaded image for project: 'Content Editor'
  1. Content Editor
  2. CONTEDIT-552

Stories Multiblock "Others" button does not obey the yaml definition

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Neutral
    • 2.1.8
    • 2.1.4
    • None

    Description

      Steps to reproduce

      1. Login to demo Org
      2. Comment out any block types here: https://demoauthor.magnolia-cms.com/.magnolia/admincentral#app:resources:edit;/travel-demo-stories-app/decorations/stories-app/apps/stories.yaml:edit and here: https://demoauthor.magnolia-cms.com/.magnolia/admincentral#app:resources:edit;/travel-demo-stories-app/decorations/stories-app/apps/stories.yaml:edit
      3. Go to Stories -> Stories Demo -> Click any story - > Edit Story
      4. Click + next to any block and click + others
      5. Notice the page loads all of the blocks registered in the system

      Expected results

      It should only load the blocks defined in the yaml file 

      Actual results

      It loads all of the blocks registered in the system

      Workaround

      Development notes

      Upon investigating this, I found that the others button is hard coded to load in every registered block in the system:

              //Add others
              menuItem.addItem(i18n.translate("blocks.picker.others"), MagnoliaIcons.ELLIPSIS, openOtherBlockChooserCommand(blockDefinitionConsumer, defaultBlock));
      
          private MenuBar.Command openOtherBlockChooserCommand(Consumer<BlockDefinition<T>> blockDefinitionConsumer, String defaultBlock) {
              return item -> {
                  BlockChooserDefinition blockChooserDefinition = new BlockChooserDefinition();
                  blockChooserDefinition.setOptions(buildAllRegisteredBlocksOptions());
                  blockChooserDefinition.setDefaultBlock(defaultBlock);
                  blockChooserDefinition.setImplementationClass((Class) BlockChooser.class);
                  blockChooserDefinition.setLabel(i18n.translate("stories.chooseDialog.label"));
                  chooserController.openChooser(blockChooserDefinition)
                                   .thenAccept(chosenBlock -> chosenBlock.getChoice()
                                                                         .ifPresent(blockName -> addBlock(blockDefinitionConsumer, blockName)));
              };
          }    private Options buildAllRegisteredBlocksOptions() {
              Map<String, String> blockOptions = getAllRegisteredBlockDefinitions().stream()
                                                                                   .filter(def -> StringUtils.isNotBlank(def.getLabel()))
                                                                                   .collect(Collectors.toMap(BlockDefinition::getLabel, BlockDefinition::getName));
              return new Options(blockOptions); 

       

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                miguel.martinez Miguel Martinez
                jelmore Jordan Elmore
                Kenton Horton
                AuthorX
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Work Started:

                  Checklists

                    Bug DoR
                    Task DoD

                    Time Tracking

                      Estimated:
                      Original Estimate - Not Specified
                      Not Specified
                      Remaining:
                      Remaining Estimate - 0d
                      0d
                      Logged:
                      Time Spent - 0.25d
                      0.25d