Sbisson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/242544

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

[WIP] 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, 50 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/44/242544/1

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..6537569 100644
--- a/includes/Formatter/TopicListFormatter.php
+++ b/includes/Formatter/TopicListFormatter.php
@@ -52,12 +52,14 @@
                        $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();
+               if ( !$title->isDeleted() ) {
+                       $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();
+                       // Link to designated new-topic page, for no-JS users
+                       $res['links']['newtopic'] = 
$this->urlGenerator->newTopicAction( $title, $listWorkflow->getId() 
)->getLinkURL();
+               }
 
                return $res;
        }
@@ -120,9 +122,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 ) {
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..08818a6 100644
--- a/modules/flow/dm/mw.flow.dm.BoardDescription.js
+++ b/modules/flow/dm/mw.flow.dm.BoardDescription.js
@@ -22,3 +22,9 @@
 /* Initialization */
 
 OO.inheritClass( mw.flow.dm.BoardDescription, mw.flow.dm.RevisionedContent );
+
+mw.flow.dm.BoardDescription.prototype.getEditLink = function () {
+       if ( this.actions ) {
+               return this.actions.edit;
+       }
+};
\ No newline at end of file
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..f374eec 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.getEditLink() ) {
+                       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: newchange
Gerrit-Change-Id: I80ebe4d5b79c75379411bfbcc69d60581705ce37
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>

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

Reply via email to