mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-09-24 02:48:18 +00:00
Merge "Support new topic tool on mobile"
This commit is contained in:
commit
22f48be13b
|
@ -429,6 +429,7 @@
|
|||
"LoadExtensionSchemaUpdates": "installer",
|
||||
"ParserAfterParse": "parser",
|
||||
"ParserAfterTidy": "parser",
|
||||
"ArticleViewHeader": "page",
|
||||
"BeforeDisplayNoArticleText": "page",
|
||||
"BeforePageDisplay": "page",
|
||||
"GetActionName": "page",
|
||||
|
|
|
@ -222,8 +222,7 @@ class HookUtils {
|
|||
if ( $isMobile && (
|
||||
!$dtConfig->get( 'DiscussionToolsEnableMobile' ) ||
|
||||
// Still disable some features for now
|
||||
$feature === self::TOPICSUBSCRIPTION ||
|
||||
$feature === self::NEWTOPICTOOL
|
||||
$feature === self::TOPICSUBSCRIPTION
|
||||
) ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -234,6 +233,17 @@ class HookUtils {
|
|||
return false;
|
||||
}
|
||||
|
||||
// New topic tool is not available if __NONEWSECTIONLINK__ is set
|
||||
// We may need to move this check to the client when we support
|
||||
// launching the tool from other pages.
|
||||
if ( $feature === self::NEWTOPICTOOL ) {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$props = $services->getPageProps()->getProperties( $title, 'nonewsectionlink' );
|
||||
if ( isset( $props[ $title->getArticleId() ] ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ?dtenable=1 overrides all user and title checks
|
||||
$queryEnable = $output->getRequest()->getRawVal( 'dtenable' ) ?:
|
||||
// Extra hack for parses from API, where this parameter isn't passed to derivative requests
|
||||
|
|
|
@ -18,17 +18,20 @@ use MediaWiki\Extension\DiscussionTools\CommentFormatter;
|
|||
use MediaWiki\Extension\DiscussionTools\SubscriptionStore;
|
||||
use MediaWiki\Hook\BeforePageDisplayHook;
|
||||
use MediaWiki\Hook\OutputPageBeforeHTMLHook;
|
||||
use MediaWiki\Page\Hook\ArticleViewHeaderHook;
|
||||
use MediaWiki\Page\Hook\BeforeDisplayNoArticleTextHook;
|
||||
use MediaWiki\User\UserNameUtils;
|
||||
use MediaWiki\User\UserOptionsLookup;
|
||||
use OOUI\ButtonWidget;
|
||||
use OutputPage;
|
||||
use ParserOutput;
|
||||
use RequestContext;
|
||||
use Skin;
|
||||
use SpecialPage;
|
||||
use VisualEditorHooks;
|
||||
|
||||
class PageHooks implements
|
||||
ArticleViewHeaderHook,
|
||||
BeforeDisplayNoArticleTextHook,
|
||||
BeforePageDisplayHook,
|
||||
GetActionNameHook,
|
||||
|
@ -309,4 +312,34 @@ class PageHooks implements
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Article $article
|
||||
* @param bool|ParserOutput &$outputDone
|
||||
* @param bool &$pcache
|
||||
* @return bool|void
|
||||
*/
|
||||
public function onArticleViewHeader( $article, &$outputDone, &$pcache ) {
|
||||
$context = $article->getContext();
|
||||
$output = $context->getOutput();
|
||||
if (
|
||||
$output->getSkin()->getSkinName() === 'minerva' &&
|
||||
HookUtils::isFeatureEnabledForOutput( $output, HookUtils::NEWTOPICTOOL ) &&
|
||||
// No need to show the button when the empty state banner is shown
|
||||
!HookUtils::shouldDisplayEmptyState( $context )
|
||||
) {
|
||||
// Minerva doesn't show a new topic button by default, unless the MobileFrontend
|
||||
// talk page feature is enabled, but we shouldn't depend on code from there.
|
||||
$output->enableOOUI();
|
||||
$output->addHTML(
|
||||
new ButtonWidget( [
|
||||
'href' => $article->getTitle()->getLinkURL( [ 'action' => 'edit', 'section' => 'new' ] ),
|
||||
// TODO: Make this a local message if the Minerva feature goes away
|
||||
'label' => $context->msg( 'minerva-talk-add-topic' )->text(),
|
||||
'flags' => [ 'progressive', 'primary' ],
|
||||
'classes' => [ 'ext-discussiontools-init-new-topic' ]
|
||||
] )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,11 +25,10 @@ function ReplyLinksController( $pageContainer ) {
|
|||
if ( $addSectionTab.length ) {
|
||||
this.$addSectionLink = $addSectionTab.find( 'a' );
|
||||
this.$addSectionLink.on( 'click keypress', this.onAddSectionLinkClickHandler );
|
||||
|
||||
// Handle events on all links that potentially open the new section interface,
|
||||
// including links in the page content (from templates) or from gadgets.
|
||||
this.$body.on( 'click keypress', 'a:not( [data-mw-comment] )', this.onAnyLinkClickHandler );
|
||||
}
|
||||
// Handle events on all links that potentially open the new section interface,
|
||||
// including links in the page content (from templates) or from gadgets.
|
||||
this.$body.on( 'click keypress', 'a:not( [data-mw-comment] )', this.onAnyLinkClickHandler );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,10 +173,19 @@ span[ data-mw-comment-start ] {
|
|||
}
|
||||
}
|
||||
|
||||
.ext-discussiontools-init-new-topic {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.ext-discussiontools-emptystate {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
.skin-minerva & {
|
||||
// Add space between this and page-actions-menu in Minerva
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
> img {
|
||||
width: 250px;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue