Werdna has uploaded a new change for review.
https://gerrit.wikimedia.org/r/151005
Change subject: Make new topic content required
......................................................................
Make new topic content required
Change-Id: Id6d64f9051633819beeddcb0a7c2f84c1d885e67
---
M handlebars/compiled/flow_block_topiclist.handlebars.php
M handlebars/flow_newtopic_form.handlebars
M i18n/en.json
M includes/Block/TopicList.php
M includes/View.php
M includes/api/ApiFlowNewTopic.php
M tests/browser/features/flow_anon.feature
A tests/browser/features/new_topic.feature
M tests/browser/features/step_definitions/flow_steps.rb
9 files changed, 32 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/05/151005/1
diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php
b/handlebars/compiled/flow_block_topiclist.handlebars.php
index 98b4c55..41295ad 100644
--- a/handlebars/compiled/flow_block_topiclist.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist.handlebars.php
@@ -106,7 +106,7 @@
<textarea name="topiclist_content"
data-flow-preview-template="flow_post"
class="mw-ui-input flow-form-collapsible
mw-ui-input-large"
- placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-newtopic-content-placeholder'),Array()), 'encq').'"
data-role="content"></textarea>
+ placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-newtopic-content-placeholder',((is_array($cx['scopes'][0]) &&
isset($cx['scopes'][0]['title'])) ? $cx['scopes'][0]['title'] :
null)),Array()), 'encq').'" data-role="content" required></textarea>
<div class="flow-form-actions flow-form-collapsible">
<button data-role="submit"
data-flow-api-handler="newTopic"
diff --git a/handlebars/flow_newtopic_form.handlebars
b/handlebars/flow_newtopic_form.handlebars
index f67baf6..204bd87 100644
--- a/handlebars/flow_newtopic_form.handlebars
+++ b/handlebars/flow_newtopic_form.handlebars
@@ -14,7 +14,7 @@
<textarea name="topiclist_content"
data-flow-preview-template="flow_post"
class="mw-ui-input flow-form-collapsible
mw-ui-input-large"
- placeholder="{{l10n
"flow-newtopic-content-placeholder"}}" data-role="content"></textarea>
+ placeholder="{{l10n "flow-newtopic-content-placeholder"
@root.title}}" data-role="content" required></textarea>
<div class="flow-form-actions flow-form-collapsible">
<button data-role="submit"
data-flow-api-handler="newTopic"
diff --git a/i18n/en.json b/i18n/en.json
index 484becf..cf3a0b5 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -51,7 +51,7 @@
"flow-system-usertext": "{{SITENAME}}",
"flow-stub-post-content": "''Due to a technical error, this post could not
be retrieved.''",
"flow-newtopic-title-placeholder": "New topic",
- "flow-newtopic-content-placeholder": "Add some details if you'd like",
+ "flow-newtopic-content-placeholder": "Post a new message to $1",
"flow-newtopic-header": "Add a new topic",
"flow-newtopic-save": "Add topic",
"flow-newtopic-start-placeholder": "Start a new topic",
diff --git a/includes/Block/TopicList.php b/includes/Block/TopicList.php
index e59fb19..a703666 100644
--- a/includes/Block/TopicList.php
+++ b/includes/Block/TopicList.php
@@ -94,6 +94,15 @@
return;
}
+ if (
+ ! isset( $this->submitted['topic'] ) ||
+ ! is_string( $this->submitted['topic'] ) ||
+ trim( $this->submitted['content'] === '' )
+ ) {
+ $this->addError( 'content', wfMessage(
'flow-error-missing-content' ) );
+ return;
+ }
+
// creates Workflow, Revision & TopicListEntry objects to be
inserted into storage
list( $this->topicWorkflow, $this->topicListEntry,
$this->topicTitle, $this->firstPost ) = $this->create();
diff --git a/includes/View.php b/includes/View.php
index 7d825f8..e9500af 100644
--- a/includes/View.php
+++ b/includes/View.php
@@ -114,6 +114,7 @@
if ( $wasPosted ? $block->canSubmit( $action ) :
$block->canRender( $action ) ) {
$apiResponse['blocks'][] = $block->renderAPI(
$this->templating, $parameters[$block->getName()] )
+ array(
+ 'title'
=> $title->getPrefixedText(),
'block-action-template' => $block->getTemplate( $action ),
'editToken' => $editToken,
);
diff --git a/includes/api/ApiFlowNewTopic.php b/includes/api/ApiFlowNewTopic.php
index 8ef7137..3cadbe1 100644
--- a/includes/api/ApiFlowNewTopic.php
+++ b/includes/api/ApiFlowNewTopic.php
@@ -24,7 +24,7 @@
ApiBase::PARAM_REQUIRED => true,
),
'content' => array(
- ApiBase::PARAM_REQUIRED => false,
+ ApiBase::PARAM_REQUIRED => true,
),
);
}
diff --git a/tests/browser/features/flow_anon.feature
b/tests/browser/features/flow_anon.feature
index 4cd318d..dfc289f 100644
--- a/tests/browser/features/flow_anon.feature
+++ b/tests/browser/features/flow_anon.feature
@@ -1,14 +1,6 @@
@chrome @clean @ee-prototype.wmflabs.org @en.wikipedia.beta.wmflabs.org
@firefox @internet_explorer_10 @login @test2.wikipedia.org
Feature: Create new topic anonymous
- Scenario: Add new Flow topic
- Given I am on Flow page
- When I create a Title of Flow Topic in Flow new topic
- And I create a Body of Flow Topic into Flow body
- And I click New topic save
- Then the top post should have a heading which contains "Title of Flow
Topic"
- And the top post should have content which contains "Body of Flow Topic"
-
Scenario: Anon does not see block or actions
Given I am on Flow page
And I have created a Flow topic
diff --git a/tests/browser/features/new_topic.feature
b/tests/browser/features/new_topic.feature
new file mode 100644
index 0000000..da5829b
--- /dev/null
+++ b/tests/browser/features/new_topic.feature
@@ -0,0 +1,14 @@
+Feature: Creating a new topic
+
+ Scenario: Cannot create a new topic without content
+ Given I am on Flow page
+ When I create a Title in Flow new topic
+ Then the Save New Topic button should be disabled
+
+ Scenario: Add new Flow topic
+ Given I am on Flow page
+ When I create a Title of Flow Topic in Flow new topic
+ And I create a Body of Flow Topic into Flow body
+ And I click New topic save
+ Then the top post should have a heading which contains "Title of Flow
Topic"
+ And the top post should have content which contains "Body of Flow
Topic"
\ No newline at end of file
diff --git a/tests/browser/features/step_definitions/flow_steps.rb
b/tests/browser/features/step_definitions/flow_steps.rb
index 98ff76b..ec4ebbb 100644
--- a/tests/browser/features/step_definitions/flow_steps.rb
+++ b/tests/browser/features/step_definitions/flow_steps.rb
@@ -51,6 +51,10 @@
end
end
+Then(/^the Save New Topic button should be disabled$/) do
+ on(FlowPage).new_topic_save_element.attribute('disabled').should be true
+end
+
When(/^I click the Topic Actions link$/) do
on(FlowPage).topic_actions_link_element.when_present.click
end
--
To view, visit https://gerrit.wikimedia.org/r/151005
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6d64f9051633819beeddcb0a7c2f84c1d885e67
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Werdna <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits