jenkins-bot has submitted this change and it was merged.

Change subject: Hide actions when viewing a board through Special:Undelete
......................................................................


Hide actions when viewing a board through Special:Undelete

* Use existence of links and actions in API response to show
  or hide actions in the UI.

Bug: T114043
Change-Id: I80ebe4d5b79c75379411bfbcc69d60581705ce37
---
M handlebars/compiled/flow_block_topiclist.handlebars.php
M handlebars/flow_board_navigation.partial.handlebars
M includes/Formatter/TopicListFormatter.php
M includes/OOUI/BoardDescriptionWidget.php
M modules/flow-initialize.js
M modules/flow/dm/mw.flow.dm.BoardDescription.js
M modules/flow/dm/mw.flow.dm.RevisionedContent.js
M modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
8 files changed, 63 insertions(+), 30 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php 
b/handlebars/compiled/flow_block_topiclist.handlebars.php
index 39befcc..b48db41 100644
--- a/handlebars/compiled/flow_block_topiclist.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist.handlebars.php
@@ -28,12 +28,11 @@
             'tooltip' => 'Flow\TemplateHelper::tooltip',
             'progressiveEnhancement' => 
'Flow\TemplateHelper::progressiveEnhancement',
 ),
-        'partials' => array('flow_board_navigation' => function ($cx, $in, 
$sp) {return ''.$sp.'
-'.$sp.'<div class="flow-board-navigation" 
data-flow-load-handler="boardNavigation">
+        'partials' => array('flow_board_navigation' => function ($cx, $in, 
$sp) {return ''.$sp.''.((LCRun3::ifvar($cx, ((isset($in['links']['board-sort']) 
&& is_array($in['links'])) ? $in['links']['board-sort'] : null))) ? '<div 
class="flow-board-navigation" data-flow-load-handler="boardNavigation">
 '.$sp.'        <div class="flow-error-container">
 '.$sp.'        </div>
 '.$sp.'</div>
-';},'flow_errors' => function ($cx, $in, $sp) {return ''.$sp.'<div 
class="flow-error-container">
+'.$sp.'' : '').'';},'flow_errors' => function ($cx, $in, $sp) {return 
''.$sp.'<div class="flow-error-container">
 '.$sp.''.((LCRun3::ifvar($cx, ((isset($cx['sp_vars']['root']['errors']) && 
is_array($cx['sp_vars']['root'])) ? $cx['sp_vars']['root']['errors'] : null))) 
? '  <div class="flow-errors errorbox">
 '.$sp.'                <ul>
 '.$sp.''.LCRun3::sec($cx, ((isset($cx['sp_vars']['root']['errors']) && 
is_array($cx['sp_vars']['root'])) ? $cx['sp_vars']['root']['errors'] : null), 
$in, true, function($cx, $in)use($sp){return '                            
<li>'.LCRun3::ch($cx, 'html', array(array(((isset($in['message']) && 
is_array($in)) ? $in['message'] : null)),array()), 'encq').'</li>
diff --git a/handlebars/flow_board_navigation.partial.handlebars 
b/handlebars/flow_board_navigation.partial.handlebars
index 47b1de2..ac40744 100644
--- a/handlebars/flow_board_navigation.partial.handlebars
+++ b/handlebars/flow_board_navigation.partial.handlebars
@@ -1,4 +1,4 @@
-
+{{#if links.board-sort}}
 <div class="flow-board-navigation" data-flow-load-handler="boardNavigation">
        <div class="flow-error-container">
                {{!-- placeholder for javascript injected errors --}}
@@ -7,3 +7,4 @@
        widget in PHP because the board navigation doesn't work in noJS mode
        as it is. --}}
 </div>
+{{/if}}
diff --git a/includes/Formatter/TopicListFormatter.php 
b/includes/Formatter/TopicListFormatter.php
index 37058fc..163ee55 100644
--- a/includes/Formatter/TopicListFormatter.php
+++ b/includes/Formatter/TopicListFormatter.php
@@ -34,6 +34,7 @@
                        'workflowId' => $workflow->getId()->getAlphadecimal(),
                        'title' => $title->getPrefixedText(),
                        'actions' => $this->buildApiActions( $workflow ),
+                       'links' => $this->buildLinks( $workflow ),
                ) + parent::buildEmptyResult( $workflow );
        }
 
@@ -51,13 +52,6 @@
                        $listWorkflow,
                        $pagingOption
                );
-               $title = $listWorkflow->getArticleTitle();
-               $saveSortBy = true;
-               $res['links']['board-sort']['updated'] = 
$this->urlGenerator->boardLink( $title, 'updated', $saveSortBy )->getLinkURL();
-               $res['links']['board-sort']['newest'] = 
$this->urlGenerator->boardLink( $title, 'newest', $saveSortBy )->getLinkURL();
-
-               // Link to designated new-topic page, for no-JS users
-               $res['links']['newtopic'] = 
$this->urlGenerator->newTopicAction( $title, $listWorkflow->getId() 
)->getLinkURL();
 
                return $res;
        }
@@ -120,9 +114,13 @@
        }
 
        protected function buildApiActions( Workflow $workflow ) {
-               return array(
-                       'newtopic' => $this->urlGenerator->newTopicAction( 
$workflow->getArticleTitle() ),
-               );
+               $actions = array();
+
+               if ( !$workflow->isDeleted() ) {
+                       $actions['newtopic'] = 
$this->urlGenerator->newTopicAction( $workflow->getArticleTitle() );
+               }
+
+               return $actions;
        }
 
        protected function generateTopicMetadata( array $posts, array 
$revisions, array $workflows, $postAlphaId, IContextSource $ctx ) {
@@ -152,4 +150,20 @@
                        'last_updated' => $ts * 1000,
                );
        }
+
+       private function buildLinks( Workflow $workflow ) {
+               $links = array();
+
+               if ( !$workflow->isDeleted() ) {
+                       $title = $workflow->getArticleTitle();
+                       $saveSortBy = true;
+                       $links['board-sort']['updated'] = 
$this->urlGenerator->boardLink( $title, 'updated', $saveSortBy )->getLinkURL();
+                       $links['board-sort']['newest'] = 
$this->urlGenerator->boardLink( $title, 'newest', $saveSortBy )->getLinkURL();
+
+                       // Link to designated new-topic page, for no-JS users
+                       $links['newtopic'] = 
$this->urlGenerator->newTopicAction( $title, $workflow->getId() )->getLinkURL();
+               }
+
+               return $links;
+       }
 }
diff --git a/includes/OOUI/BoardDescriptionWidget.php 
b/includes/OOUI/BoardDescriptionWidget.php
index 78c1768..20909ea 100644
--- a/includes/OOUI/BoardDescriptionWidget.php
+++ b/includes/OOUI/BoardDescriptionWidget.php
@@ -42,7 +42,11 @@
 
                // Initialize
                $this->addClasses( array( 'flow-ui-boardDescriptionWidget', 
'flow-ui-boardDescriptionWidget-nojs' ) );
-               $this->appendContent( $this->editButton, $this->contentWrapper 
);
+
+               if ( $editLink ) {
+                       $this->appendContent( $this->editButton );
+               }
+               $this->appendContent( $this->contentWrapper );
        }
 
        /**
diff --git a/modules/flow-initialize.js b/modules/flow-initialize.js
index 22717a8..93549ec 100644
--- a/modules/flow-initialize.js
+++ b/modules/flow-initialize.js
@@ -99,6 +99,21 @@
                // We shouldn't have to worry about 'remove', since by the time 
we have filtering,
                // orderedTopicIds should be gone.
 
+               // Fall back to mw.flow.data, which was used until September 
2015
+               dataBlob = mw.config.get( 'wgFlowData' ) || ( mw.flow && 
mw.flow.data );
+               if ( dataBlob && dataBlob.blocks ) {
+                       // Populate the rendered topics or topic (if we are in 
a single-topic view)
+                       mw.flow.system.populateBoardTopicsFromJson( 
dataBlob.blocks.topiclist || dataBlob.blocks.topic );
+                       // Populate header
+                       mw.flow.system.populateBoardDescriptionFromJson( 
dataBlob.blocks.header || {} );
+                       // Populate the ToC topics
+                       if ( dataBlob.toc ) {
+                               mw.flow.system.populateBoardTopicsFromJson( 
dataBlob.toc );
+                       }
+               } else {
+                       mw.flow.system.populateBoardFromApi();
+               }
+
                // Initialize the old system to accept the default
                // 'newest' order for the topic order widget
                // Get the current default sort
@@ -414,21 +429,6 @@
                        // Prevent default
                        return false;
                } );
-
-               // Fall back to mw.flow.data, which was used until September 
2015
-               dataBlob = mw.config.get( 'wgFlowData' ) || ( mw.flow && 
mw.flow.data );
-               if ( dataBlob && dataBlob.blocks ) {
-                       // Populate the rendered topics or topic (if we are in 
a single-topic view)
-                       mw.flow.system.populateBoardTopicsFromJson( 
dataBlob.blocks.topiclist || dataBlob.blocks.topic );
-                       // Populate header
-                       mw.flow.system.populateBoardDescriptionFromJson( 
dataBlob.blocks.header || {} );
-                       // Populate the ToC topics
-                       if ( dataBlob.toc ) {
-                               mw.flow.system.populateBoardTopicsFromJson( 
dataBlob.toc );
-                       }
-               } else {
-                       mw.flow.system.populateBoardFromApi();
-               }
 
                preloadTopic = OO.getProp( dataBlob, 'blocks', 'topiclist', 
'submitted', 'topic' );
                preloadContent = OO.getProp( dataBlob, 'blocks', 'topiclist', 
'submitted', 'content' );
diff --git a/modules/flow/dm/mw.flow.dm.BoardDescription.js 
b/modules/flow/dm/mw.flow.dm.BoardDescription.js
index 82c311d..dcbc5cc 100644
--- a/modules/flow/dm/mw.flow.dm.BoardDescription.js
+++ b/modules/flow/dm/mw.flow.dm.BoardDescription.js
@@ -22,3 +22,12 @@
 /* Initialization */
 
 OO.inheritClass( mw.flow.dm.BoardDescription, mw.flow.dm.RevisionedContent );
+
+/**
+ * Check if the description can be edited.
+ *
+ * @return {boolean}
+ */
+mw.flow.dm.BoardDescription.prototype.canEdit = function () {
+       return !!OO.getProp( this, 'actions', 'edit' );
+};
diff --git a/modules/flow/dm/mw.flow.dm.RevisionedContent.js 
b/modules/flow/dm/mw.flow.dm.RevisionedContent.js
index e350ead..bf36ccf 100644
--- a/modules/flow/dm/mw.flow.dm.RevisionedContent.js
+++ b/modules/flow/dm/mw.flow.dm.RevisionedContent.js
@@ -131,6 +131,8 @@
                if ( data.watchable !== undefined ) {
                        this.toggleWatchable( !!data.watchable );
                }
+
+               this.actions = data.actions;
        };
 
        /**
diff --git a/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js 
b/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
index f97ec27..e9b4c1c 100644
--- a/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
+++ b/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
@@ -62,6 +62,10 @@
                        classes: [ 'flow-ui-boardDescriptionWidget-editButton' ]
                } );
 
+               if ( !this.model.canEdit() ) {
+                       this.button.toggle( false );
+               }
+
                // Events
                this.button.connect( this, { click: 'onEditButtonClick' } );
                this.editor.connect( this, {

-- 
To view, visit https://gerrit.wikimedia.org/r/242544
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I80ebe4d5b79c75379411bfbcc69d60581705ce37
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to