From 286b07b20afa835d93a215a99eac588d3ae92609 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Tue, 21 Apr 2020 14:35:11 -0700 Subject: [PATCH] Refactor: Make VectorMenu template data conform with MenuDefinition menu-id -> id menu-label-id -> label-id msg-label -> label empty-portlet -> class Bug: T249372 Change-Id: I50bf2424f9077ac987e03a1e552577bf7c48b3bb --- includes/VectorTemplate.php | 18 +++++++++------- includes/templates/VectorMenu.mustache | 15 +++++-------- stories/VectorMenu.stories.data.js | 21 ++++++++++++------- .../integration/VectorTemplateTest.php | 20 +++++++++++++++--- 4 files changed, 46 insertions(+), 28 deletions(-) diff --git a/includes/VectorTemplate.php b/includes/VectorTemplate.php index ccc8c8d..e13b0fc 100644 --- a/includes/VectorTemplate.php +++ b/includes/VectorTemplate.php @@ -435,10 +435,11 @@ class VectorTemplate extends BaseTemplate { */ private function buildVariantsProps() : array { $props = [ - 'empty-portlet' => ( count( $this->get( 'variant_urls', [] ) ) == 0 ) ? 'emptyPortlet' : '', - 'menu-id' => 'p-variants', - 'menu-label-id' => 'p-variants-label', - 'msg-label' => $this->getMsg( 'variants' )->text(), + 'class' => ( count( $this->get( 'variant_urls', [] ) ) == 0 ) ? + 'emptyPortlet vectorMenu' : 'vectorMenu', + 'id' => 'p-variants', + 'label-id' => 'p-variants-label', + 'label' => $this->getMsg( 'variants' )->text(), 'html-items' => '', ]; @@ -485,10 +486,11 @@ class VectorTemplate extends BaseTemplate { */ private function buildActionsProps() : array { $props = [ - 'empty-portlet' => ( count( $this->get( 'action_urls', [] ) ) == 0 ) ? 'emptyPortlet' : '', - 'msg-label' => $this->getMsg( 'vector-more-actions' )->text(), - 'menu-id' => 'p-cactions', - 'menu-label-id' => 'p-cactions-label', + 'class' => ( count( $this->get( 'action_urls', [] ) ) == 0 ) ? + 'emptyPortlet vectorMenu' : 'vectorMenu', + 'label' => $this->getMsg( 'vector-more-actions' )->text(), + 'id' => 'p-cactions', + 'label-id' => 'p-cactions-label', 'html-userlangattributes' => $this->get( 'userlangattributes', '' ), 'html-items' => '', ]; diff --git a/includes/templates/VectorMenu.mustache b/includes/templates/VectorMenu.mustache index b741424..8b7a8b6 100644 --- a/includes/templates/VectorMenu.mustache +++ b/includes/templates/VectorMenu.mustache @@ -1,15 +1,10 @@ {{! - string|null empty-portlet - string msg-label - string menu-id - string menu-label-id - string|null html-items - string|null html-userlangattributes + See @typedef MenuDefinition }} -