Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/303314
Change subject: [wip] Add dynamic secondary actions to items ...................................................................... [wip] Add dynamic secondary actions to items Bug: T132975 Change-Id: Ib16d57c3f1a11a9749564c6e2112bf1ca32c55e8 --- M Hooks.php M includes/formatters/EventPresentationModel.php 2 files changed, 47 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo refs/changes/14/303314/1 diff --git a/Hooks.php b/Hooks.php index 655f28a..7677160 100644 --- a/Hooks.php +++ b/Hooks.php @@ -97,6 +97,26 @@ */ public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) { global $wgEchoConfig; + global $wgEchoNotifications; + + // Add i18n messages for dynamic actions + $msgKeys = array(); + $keyExists = array(); + foreach ( $wgEchoNotifications as $key => $data ) { + if ( $data['dynamic_actions'] ) { + foreach ( $data['dynamic_actions'] as $dynaction ) { + if ( !$keyExists[ $dynaction ] ) { + $msgKeys[] = "notifications-dynamic-actions-$dynaction"; + $keyExists[ $dynaction ] = true; + } + } + } + } + // Register the module for the messages + $resourceLoader->register( 'ext.echo.dynamic.actions.i18n', array( + 'messages' => $msgKeys, + 'targets' => array( 'desktop', 'mobile' ) + ) ); // ext.echo.logger is used by mobile notifications as well, so be sure not to add any // dependencies that do not target mobile. diff --git a/includes/formatters/EventPresentationModel.php b/includes/formatters/EventPresentationModel.php index 4d1e39a..7bf2664 100644 --- a/includes/formatters/EventPresentationModel.php +++ b/includes/formatters/EventPresentationModel.php @@ -441,6 +441,7 @@ * 'label' => (string) link text (non-escaped), * 'description' => (string) descriptive text (non-escaped), * 'icon' => (bool|string) symbolic icon name (or false if there is none), + * 'action' => (string) optional descriptor of an action. This is intended for links that involve ajax actions from the ui. * 'prioritized' => (bool) true if the link should be outside the * action menu, false for inside)], * ...] @@ -555,4 +556,30 @@ 'prioritized' => $prioritized, ); } + + /** + * @param Title $title + * @param string $action + * @param bool $prioritized + * @param array $query + * @return array + */ + final protected function getDynamicActionLink( Title $title, $action, $prioritized, $query = array() ) { + if ( $title->getNamespace() === NS_USER_TALK ) { + $icon = 'userSpeechBubble'; + } elseif ( $title->isTalkPage() ) { + $icon = 'speechBubbles'; + } else { + $icon = 'article'; + } + + return array( + 'action' => $action, + 'url' => $title->getFullURL( $query ), + 'label' => $this->msg( 'echo-dynamic-secondary-action-' + $action ), + 'tooltip' => $this->msg( 'echo-dynamic-secondary-action-' + $action ), + 'icon' => $icon, + 'prioritized' => $prioritized, + ); + } } -- To view, visit https://gerrit.wikimedia.org/r/303314 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib16d57c3f1a11a9749564c6e2112bf1ca32c55e8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits