[CONTEDIT-552] Stories Multiblock "Others" button does not obey the yaml definition Created: 01/Jun/23  Updated: 14/Dec/23  Resolved: 04/Dec/23

Status: Closed
Project: Content Editor
Component/s: None
Affects Version/s: 2.1.4
Fix Version/s: 2.1.8

Type: Bug Priority: Neutral
Reporter: Jordan Elmore Assignee: Miguel Martinez
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 0.25d
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2023-06-01 at 11.10.21 AM.png     PNG File Screen Shot 2023-06-01 at 11.10.32 AM.png     PNG File Screen Shot 2023-06-01 at 11.10.53 AM.png    
Issue Links:
Cloners
is cloned by CONTEDIT-597 Stories Multiblock "Others" button do... Closed
Problem/Incident
Relates
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[X]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Date of First Response:
Visible to:
Kenton Horton
Epic Link: AuthorX Support
Team: AuthorX
Work Started:
Approved:
Yes

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

 


Generated at Mon Feb 12 00:21:28 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.