jenkins-bot has submitted this change and it was merged.
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 i18n/qqq.json
M includes/Block/TopicList.php
M includes/View.php
M includes/api/ApiFlowNewTopic.php
A tests/browser/features/anon_interface.feature
D tests/browser/features/flow_anon.feature
A tests/browser/features/new_topic.feature
M tests/browser/features/step_definitions/flow_steps.rb
11 files changed, 43 insertions(+), 23 deletions(-)
Approvals:
SG: Looks good to me, approved
Jdlrobson: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php
b/handlebars/compiled/flow_block_topiclist.handlebars.php
index 73fe003..b31c86f 100644
--- a/handlebars/compiled/flow_block_topiclist.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist.handlebars.php
@@ -134,7 +134,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"
@@ -500,4 +500,4 @@
</div>
';
}
-?>
\ No newline at end of file
+?>
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 9ea0af3..2390be8 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/i18n/qqq.json b/i18n/qqq.json
index b6de8ed..328dde0 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -55,7 +55,7 @@
"flow-system-usertext": "Stub username to be displayed when a post's
information could not be loaded due to technical issues.",
"flow-stub-post-content": "Stub post content to be displayed when the
real post could not be loaded due to technical issues.",
"flow-newtopic-title-placeholder": "Used as placeholder for the
\"Subject/Title for topic\" textarea.\n{{Identical|New topic}}",
- "flow-newtopic-content-placeholder": "Used as placeholder for the
\"Content\" textarea.",
+ "flow-newtopic-content-placeholder": "Used as placeholder for the
\"Content\" textarea.\nParameters:\n* $1 - The prefixed name of the current
page.",
"flow-newtopic-header": "Unused at this time.",
"flow-newtopic-save": "Used as label for the Submit button.\n\nAlso
used in:\n* {{msg-mw|Flow-terms-of-use-new-topic}}\n*
{{msg-mw|Wikimedia-flow-terms-of-use-new-topic}}",
"flow-newtopic-start-placeholder": "Used as placeholder for the
\"Topic\" textarea.",
diff --git a/includes/Block/TopicList.php b/includes/Block/TopicList.php
index 60a0338..378ce83 100644
--- a/includes/Block/TopicList.php
+++ b/includes/Block/TopicList.php
@@ -91,6 +91,13 @@
return;
}
+ if (
+ 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 e62a5df..74b7ee2 100644
--- a/includes/View.php
+++ b/includes/View.php
@@ -115,6 +115,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/anon_interface.feature
b/tests/browser/features/anon_interface.feature
new file mode 100644
index 0000000..de1b0ca
--- /dev/null
+++ b/tests/browser/features/anon_interface.feature
@@ -0,0 +1,9 @@
+@chrome @clean @ee-prototype.wmflabs.org @en.wikipedia.beta.wmflabs.org
@firefox @internet_explorer_10 @login @test2.wikipedia.org
+Feature: Check the interface for anonymous users
+
+ Scenario: Anon does not see block or actions
+ Given I am on Flow page
+ And I have created a Flow topic
+ # which is not hidden (this is implicit from the above step)
+ When I see a flow creator element
+ Then the block author link does not exist
diff --git a/tests/browser/features/flow_anon.feature
b/tests/browser/features/flow_anon.feature
deleted file mode 100644
index bd1c0f9..0000000
--- a/tests/browser/features/flow_anon.feature
+++ /dev/null
@@ -1,17 +0,0 @@
-@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 type "Title of Flow Topic" into the new topic title field
- And I type "Body of Flow Topic" into the new topic content field
- 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
- # which is not hidden (this is implicit from the above step)
- When I see a flow creator element
- Then the block author link does not exist
diff --git a/tests/browser/features/new_topic.feature
b/tests/browser/features/new_topic.feature
new file mode 100644
index 0000000..540e144
--- /dev/null
+++ b/tests/browser/features/new_topic.feature
@@ -0,0 +1,15 @@
+Feature: Creating a new topic
+
+ Background:
+ Given I am on Flow page
+
+ Scenario: Cannot create a new topic without content
+ When I type "Anonymous user topic creation test" into the new topic title
field
+ Then the Save New Topic button should be disabled
+
+ Scenario: Add new Flow topic as anonymous user
+ When I type "Anonymous user topic creation test" into the new topic title
field
+ And I type "Anon test." into the new topic content field
+ And I click New topic save
+ Then the top post should have a heading which contains "Anonymous user
topic creation test"
+ And the top post should have content which contains "Anon test."
diff --git a/tests/browser/features/step_definitions/flow_steps.rb
b/tests/browser/features/step_definitions/flow_steps.rb
index 309e6ae..63a2936 100644
--- a/tests/browser/features/step_definitions/flow_steps.rb
+++ b/tests/browser/features/step_definitions/flow_steps.rb
@@ -48,6 +48,11 @@
end
end
+Then(/^the Save New Topic button should be disabled$/) do
+ val = on(FlowPage).new_topic_save_element.attribute( "disabled" )
+ expect(val).to eq("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: merged
Gerrit-Change-Id: Id6d64f9051633819beeddcb0a7c2f84c1d885e67
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Werdna <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits