Harej has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/343801 )

Change subject: Switching hub feature edit order and adding purge button
......................................................................

Switching hub feature edit order and adding purge button

Bug: T160879
Change-Id: I6edf80fca99d8004c168ee4ccb7e7db0ae4013ff
---
M i18n/en.json
M i18n/qqq.json
M includes/SpecialCreateHubFeature.php
M includes/content/CollaborationHubContent.php
4 files changed, 69 insertions(+), 61 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CollaborationKit 
refs/changes/01/343801/1

diff --git a/i18n/en.json b/i18n/en.json
index 47258de..c5cbdbe 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -72,8 +72,9 @@
        "collaborationkit-hub-members-header": "Meet our members!",
        "collaborationkit-hub-members-signup": "Join",
        "collaborationkit-hub-members-view": "View full list",
-       "collaborationkit-hub-missingpage-note": "This feature does not exist. 
You can create a new feature using the button below.",
+       "collaborationkit-hub-missingpage-note": "This feature does not exist. 
You can create a new feature using the button below. If you just created the 
feature and you're still seeing this message, try purging the cache.",
        "collaborationkit-hub-missingpage-create": "Create feature",
+       "collaborationkit-hub-missingpage-purgecache": "Purge cache",
        "collaborationkit-hub-pagetitle-members": "Members",
        "collaborationkit-hub-pagetitle-announcements": "Announcements",
        "collaborationkit-hub-subpage-view": "View page",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 1fbaa1e..6f943e4 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -77,6 +77,7 @@
        "collaborationkit-hub-members-view": "Label for the 'view all' button 
in the members block",
        "collaborationkit-hub-missingpage-note": "Note and helpt text for 
missing feature sections (subpages) on a collaboration hub mainpage",
        "collaborationkit-hub-missingpage-create": "Button label for creating a 
new feature (subpage)",
+       "collaborationkit-hub-missingpage-purgecache": "Button for purging page 
cache",
        "collaborationkit-hub-pagetitle-members": "The title of the /Members 
subpage for a Collaboration Hub (without the leading 
slash)\n{{Identical|Member}}",
        "collaborationkit-hub-pagetitle-announcements": "The title of the 
/Announcements subpage for a Collaboration Hub (without the leading 
slash)\n{{Identical|Announcement}}",
        "collaborationkit-hub-subpage-view": "View link label for subpages on 
Collaboration Hub mainpages\n{{Identical|View page}}",
diff --git a/includes/SpecialCreateHubFeature.php 
b/includes/SpecialCreateHubFeature.php
index e18fe11..d5b90f6 100644
--- a/includes/SpecialCreateHubFeature.php
+++ b/includes/SpecialCreateHubFeature.php
@@ -129,6 +129,63 @@
                        return Status::newFatal( 
'collaborationkit-createhubfeature-nopermission' );
                }
 
+               // Create feature
+               $contentModel = $data[ 'contenttype' ];
+               if ( $contentModel != 'wikitext'
+                       && $contentModel != 'CollaborationListContent' )
+               {
+                       return Status::newFatal( 
'collaborationkit-createhubfeature-invalidcontenttype' );
+               }
+
+               if ( $contentModel == 'wikitext' ) {
+                       $contentFormat = 'text/x-wiki';
+               } elseif ( $contentModel == 'CollaborationListContent' ) {
+                       $contentFormat = 'application/json';
+               } else {
+                       return Status::newFatal( 
'collaborationkit-createhubfeature-invalidcontenttype' );
+               }
+
+               // Create empty page by default; exception is if there needs to 
be
+               // something such as JSON.
+               $initialContent = '';
+               if ( $contentModel == 'CollaborationListContent' ) {
+                       $initialContent = 
CollaborationListContentHandler::serializeContent(
+                               
CollaborationListContentHandler::makeEmptyContent()
+                       );
+               }
+
+               $summary = $this
+                       ->msg( 'collaborationkit-createhubfeature-editsummary' )
+                       ->plain();
+
+               $context = $this->getContext();
+               $der = new DerivativeContext( $context );
+               $request = new DerivativeRequest(
+                       $context->getRequest(),
+                       [
+                               'action' => 'edit',
+                               'title' => $title->getFullText(),
+                               'contentmodel' => $contentModel,
+                               'contentformat' => $contentFormat,
+                               'text' => $initialContent,
+                               'summary' => $summary,
+                               'token' => $context->getUser()->getEditToken(),
+                       ],
+                       true // Treat data as POSTed
+               );
+               $der->setRequest( $request );
+               try {
+                       $api = new ApiMain( $der, true );
+                       $api->execute();
+               } catch ( ApiUsageException $e ) {
+                       return Status::newFatal(
+                               $context->msg(
+                                       'collaborationkit-hub-edit-apierror',
+                                       $e->getCodeString()
+                               )
+                       );
+               }
+
                // Update hub with link to new feature
                $newFeature = [ 'title' => $titleText, 'display_title' => 
$featureName ];
 
@@ -194,68 +251,9 @@
                        }
                }
 
-               // Create feature
-               $contentModel = $data[ 'contenttype' ];
-               if ( $contentModel != 'wikitext'
-                       && $contentModel != 'CollaborationListContent' )
-               {
-                       return Status::newFatal( 
'collaborationkit-createhubfeature-invalidcontenttype' );
-               }
-
-               if ( $contentModel == 'wikitext' ) {
-                       $contentFormat = 'text/x-wiki';
-               } elseif ( $contentModel == 'CollaborationListContent' ) {
-                       $contentFormat = 'application/json';
-               } else {
-                       return Status::newFatal( 
'collaborationkit-createhubfeature-invalidcontenttype' );
-               }
-
-               // Create empty page by default; exception is if there needs to 
be
-               // something such as JSON.
-               $initialContent = '';
-               if ( $contentModel == 'CollaborationListContent' ) {
-                       $initialContent = 
CollaborationListContentHandler::serializeContent(
-                               
CollaborationListContentHandler::makeEmptyContent()
-                       );
-               }
-
-               $summary = $this
-                       ->msg( 'collaborationkit-createhubfeature-editsummary' )
-                       ->plain();
-
-               $context = $this->getContext();
-               $der = new DerivativeContext( $context );
-               $request = new DerivativeRequest(
-                       $context->getRequest(),
-                       [
-                               'action' => 'edit',
-                               'title' => $title->getFullText(),
-                               'contentmodel' => $contentModel,
-                               'contentformat' => $contentFormat,
-                               'text' => $initialContent,
-                               'summary' => $summary,
-                               'token' => $context->getUser()->getEditToken(),
-                       ],
-                       true // Treat data as POSTed
-               );
-               $der->setRequest( $request );
-               try {
-                       $api = new ApiMain( $der, true );
-                       $api->execute();
-               } catch ( ApiUsageException $e ) {
-                       return Status::newFatal(
-                               $context->msg(
-                                       'collaborationkit-hub-edit-apierror',
-                                       $e->getCodeString()
-                               )
-                       );
-               }
-
                // Purge the hub's cache so that it doesn't say "feature does 
not exist"
                $hubTitleObject->invalidateCache();
 
-               // Once all the pages we want to create are created, we send 
them to the
-               // first one
                $this->getOutput()->redirect( $title->getFullURL() );
 
                return Status::newGood();
diff --git a/includes/content/CollaborationHubContent.php 
b/includes/content/CollaborationHubContent.php
index c17b0f2..48c5127 100644
--- a/includes/content/CollaborationHubContent.php
+++ b/includes/content/CollaborationHubContent.php
@@ -704,7 +704,15 @@
                                                ->getFullURL( [
                                                        'collaborationhub' => 
$title->getFullText(),
                                                        'feature' => 
$spTitle->getSubpageText()
-                                               ] )
+                                               ] ),
+                                       'flags' => [ 'progressive' ]
+                               ] );
+
+                               $html .= new OOUI\ButtonWidget( [
+                                       'label' => wfMessage( 
'collaborationkit-hub-missingpage-purgecache' )
+                                               ->inContentLanguage()
+                                               ->text(),
+                                       'href' => $title->getFullURL( ['action' 
=> 'purge'] )
                                ] );
 
                                // register as template for stuff

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6edf80fca99d8004c168ee4ccb7e7db0ae4013ff
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CollaborationKit
Gerrit-Branch: master
Gerrit-Owner: Harej <jamesmh...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to