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

Stories Multiblock "Others" button does not obey the yaml definition - Port Master

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 3.0.0
    • 2.1.4
    • None

      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); 

       

        Acceptance criteria

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

                Created:
                Updated:
                Resolved:
                Work Started:

                  Bug DoR
                  Task DoD