jenkins-bot has submitted this change and it was merged. ( 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 M tests/phpunit/CollaborationHubContentTest.php 5 files changed, 70 insertions(+), 62 deletions(-) Approvals: Harej: Looks good to me, approved jenkins-bot: Verified diff --git a/i18n/en.json b/i18n/en.json index e98ab28..74caeb9 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -76,8 +76,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 a877f3d..8e171bc 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -81,6 +81,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 3214cd2..53a1516 100644 --- a/includes/SpecialCreateHubFeature.php +++ b/includes/SpecialCreateHubFeature.php @@ -133,6 +133,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 ]; @@ -198,68 +255,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 d28dcf2..1967101 100644 --- a/includes/content/CollaborationHubContent.php +++ b/includes/content/CollaborationHubContent.php @@ -715,7 +715,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 diff --git a/tests/phpunit/CollaborationHubContentTest.php b/tests/phpunit/CollaborationHubContentTest.php index 6511bdf..9d83014 100644 --- a/tests/phpunit/CollaborationHubContentTest.php +++ b/tests/phpunit/CollaborationHubContentTest.php @@ -145,7 +145,7 @@ public function testGetParsedContent( CollaborationHubContent $content, $id ) { global $wgServer; $expected = [ - "<div class=\"mw-ck-hub-section\" id=\"Wow.21\"><h2><span class=\"mw-headline\">Wow!</span></h2><p class=\"mw-ck-hub-missingfeature-note\">" . wfMessage( "collaborationkit-hub-missingpage-note" ) . "</p><span aria-disabled='false' class='oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-buttonWidget'><a role='button' tabindex='0' aria-disabled='false' href='" . $wgServer . "/wiki/index.php?title=Special:CreateHubFeature&collaborationhub=Main+Page&feature=Wow' rel='nofollow' class='oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon'></span><span class='oo-ui-labelElement-label'>Create feature</span><span class='oo-ui-indicatorElement-indicator'></span></a></span></div>", + "<div class=\"mw-ck-hub-section\" id=\"Wow.21\"><h2><span class=\"mw-headline\">Wow!</span></h2><p class=\"mw-ck-hub-missingfeature-note\">" . wfMessage( 'collaborationkit-hub-missingpage-note' ) . "</p><span aria-disabled='false' class='oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-buttonWidget'><a role='button' tabindex='0' aria-disabled='false' href='" . $wgServer . "/wiki/index.php?title=Special:CreateHubFeature&collaborationhub=Main+Page&feature=Wow' rel='nofollow' class='oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon oo-ui-image-progressive'></span><span class='oo-ui-labelElement-label'>" . wfMessage( 'collaborationkit-hub-missingpage-create' ) . "</span><span class='oo-ui-indicatorElement-indicator oo-ui-image-progressive'></span></a></span><span aria-disabled='false' class='oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-buttonWidget'><a role='button' tabindex='0' aria-disabled='false' href='" . $wgServer . "/wiki/index.php?title=Main_Page&action=purge' rel='nofollow' class='oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon'></span><span class='oo-ui-labelElement-label'>" . wfMessage( 'collaborationkit-hub-missingpage-purgecache' ) . "</span><span class='oo-ui-indicatorElement-indicator'></span></a></span></div>", '', '' ]; -- To view, visit https://gerrit.wikimedia.org/r/343801 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6edf80fca99d8004c168ee4ccb7e7db0ae4013ff Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/extensions/CollaborationKit Gerrit-Branch: master Gerrit-Owner: Harej <jamesmh...@gmail.com> Gerrit-Reviewer: Harej <jamesmh...@gmail.com> Gerrit-Reviewer: Isarra <zhoris...@gmail.com> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits