Add "Discussion" button to Main page on Mobile View

* Enable discussion button on main page in mobile view so users
  can view discussion topics related to the main page on mobile.
* Update test to make sure only 'talk' and 'switch-language' actions are
  enabled on the main page and 'edit' and 'watch' are disabled on the main
  page.
* Minor typo fix for doc type. Use "array" instead of "Array" and CSS
  alignment fix issue with Discussion button when displayed together with
  Language selector button.
* [Suggested by: @Jdlrobson] Use a generic "a" CSS selector to style the ".talk"
  and ".language-selector" classes on the main page. This also avoids fixing the
  CSS for future buttons if added (future proofing the code), so if any other
  button is added in the future, the same css rule will be applied to it at once.
  Very wise idea from @Jdlrobson, thanks!

Bug: T206406
Change-Id: Iedce84595adc357f3a707f8b94d23b2ffea3476c
This commit is contained in:
Alangi Derick 2018-10-21 16:10:41 +01:00
parent 5e7d7e918f
commit a2fd0b3c1f
3 changed files with 15 additions and 4 deletions

View File

@ -242,9 +242,15 @@ class SkinMinerva extends SkinTemplate {
return false;
}
// T206406: Enable "Talk" or "Discussion" button on Main page, also, not forgetting
// the "switch-language" button. But disable "edit" and "watch" actions.
if ( $title->isMainPage() ) {
return ( in_array( $action, $config->get( 'MinervaPageActions' ) )
&& ( $action === 'talk' || $action === 'switch-language' ) );
}
if (
! in_array( $action, $config->get( 'MinervaPageActions' ) )
|| $title->isMainPage()
|| ( $this->getUserPageHelper()->isUserPage() && !$title->exists() )
) {
return false;
@ -270,7 +276,7 @@ class SkinMinerva extends SkinTemplate {
* @return string
*/
public function doEditSectionLink( Title $nt, $section, $tooltip, Language $lang ) {
if ( $this->isAllowedPageAction( 'edit' ) ) {
if ( $this->isAllowedPageAction( 'edit' ) && !$nt->isMainPage() ) {
$message = $this->msg( 'mobile-frontend-editor-edit' )->inLanguage( $lang )->text();
$html = Html::openElement( 'span', [ 'class' => 'mw-editsection' ] );
$html .= Html::element( 'a', [
@ -980,7 +986,7 @@ class SkinMinerva extends SkinTemplate {
/**
* Returns an array of sitelinks to add into the main menu footer.
* @return Array array of site links
* @return array Array of site links
*/
protected function getSiteLinks() {
$menu = new MenuBuilder();

View File

@ -18,7 +18,7 @@
}
#page-secondary-actions {
.language-selector {
a {
margin-top: 1em;
}
}

View File

@ -66,6 +66,11 @@ class SkinMinervaPageActionsTest extends MediaWikiTestCase {
$skin = $this->getSkin( Title::newMainPage() );
$this->assertFalse( $skin->isAllowedPageAction( 'watch' ) );
$this->assertFalse( $skin->isAllowedPageAction( 'edit' ) );
// Check to make sure 'talk' and 'switch-language' are enabled on the Main page.
$this->assertTrue( $skin->isAllowedPageAction( 'talk' ) );
$this->assertTrue( $skin->isAllowedPageAction( 'switch-language' ) );
}
/**