parent
74fff52e51
commit
b7791e6c9d
23 changed files with 190 additions and 80 deletions
|
|
@ -49,6 +49,7 @@ Note: Although this is a minor release, the configuration file changed because t
|
|||
* Add optional `Content-Security-Policy` header [#7128](https://github.com/diaspora/diaspora/pull/7128)
|
||||
* Add links to main stream and public stream to the mobile drawer [#7144](https://github.com/diaspora/diaspora/pull/7144)
|
||||
* Allow opening search results from the dropdown in a new tab [#7021](https://github.com/diaspora/diaspora/issues/7021)
|
||||
* Add user setting for default post visibility [#7118](https://github.com/diaspora/diaspora/issues/7118)
|
||||
|
||||
# 0.6.0.1
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ app.pages.Settings = Backbone.View.extend({
|
|||
preFill: gon.preloads.tagsArray
|
||||
});
|
||||
new Diaspora.ProfilePhotoUploader();
|
||||
|
||||
this.viewAspectSelector = new app.views.PublisherAspectSelector({
|
||||
el: $(".aspect_dropdown"),
|
||||
form: $("#post-default-aspects")
|
||||
});
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ class UsersController < ApplicationController
|
|||
:auto_follow_back,
|
||||
:auto_follow_back_aspect_id,
|
||||
:getting_started,
|
||||
:post_default_public,
|
||||
email_preferences: %i(
|
||||
someone_reported
|
||||
also_commented
|
||||
|
|
@ -167,6 +168,8 @@ class UsersController < ApplicationController
|
|||
change_email(user_data)
|
||||
elsif user_data[:auto_follow_back]
|
||||
change_settings(user_data, "users.update.follow_settings_changed", "users.update.follow_settings_not_changed")
|
||||
elsif user_data[:post_default_public]
|
||||
change_post_default(user_data)
|
||||
elsif user_data[:color_theme]
|
||||
change_settings(user_data, "users.update.color_theme_changed", "users.update.color_theme_not_changed")
|
||||
else
|
||||
|
|
@ -184,6 +187,18 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def change_post_default(user_data)
|
||||
# by default user_data[:post_default_public] is set to false
|
||||
case params[:aspect_ids].try(:first)
|
||||
when "public"
|
||||
user_data[:post_default_public] = true
|
||||
when "all_aspects"
|
||||
params[:aspect_ids] = @user.aspects.map {|a| a.id.to_s }
|
||||
end
|
||||
@user.update_post_default_aspects params[:aspect_ids].to_a
|
||||
change_settings(user_data)
|
||||
end
|
||||
|
||||
# change email notifications
|
||||
def change_email_preferences(user_data)
|
||||
@user.update_user_preferences(user_data[:email_preferences])
|
||||
|
|
|
|||
|
|
@ -17,13 +17,24 @@ module AspectGlobalHelper
|
|||
aspect = stream.aspect
|
||||
aspect_ids = stream.aspect_ids
|
||||
elsif current_user
|
||||
aspects = current_user.aspects
|
||||
aspects = current_user.post_default_aspects
|
||||
aspect = aspects.first
|
||||
aspect_ids = current_user.aspect_ids
|
||||
else
|
||||
return {}
|
||||
end
|
||||
{selected_aspects: aspects, aspect: aspect, aspect_ids: aspect_ids}
|
||||
end
|
||||
|
||||
{ selected_aspects: aspects, aspect: aspect, aspect_ids: aspect_ids }
|
||||
def public_selected?(selected_aspects)
|
||||
"public" == selected_aspects.try(:first)
|
||||
end
|
||||
|
||||
def all_aspects_selected?(aspects, selected_aspects)
|
||||
!aspects.empty? && aspects.size == selected_aspects.size && !public_selected?(selected_aspects)
|
||||
end
|
||||
|
||||
def aspect_selected?(aspect, aspects, selected_aspects)
|
||||
selected_aspects.include?(aspect) && !all_aspects_selected?(aspects, selected_aspects)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -46,8 +46,4 @@ module InterimStreamHackinessHelper
|
|||
def publisher_open
|
||||
publisher_method(:open)
|
||||
end
|
||||
|
||||
def publisher_public
|
||||
publisher_method(:public)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@ module PublisherHelper
|
|||
params[:controller] != "tags"
|
||||
end
|
||||
|
||||
def all_aspects_selected?(selected_aspects)
|
||||
@all_aspects_selected ||= all_aspects.size == selected_aspects.size
|
||||
end
|
||||
|
||||
def service_button(service)
|
||||
provider_title = I18n.t(
|
||||
"services.index.share_to",
|
||||
|
|
|
|||
|
|
@ -252,6 +252,21 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def post_default_aspects
|
||||
if post_default_public
|
||||
["public"]
|
||||
else
|
||||
aspects.where(post_default: true).to_a
|
||||
end
|
||||
end
|
||||
|
||||
def update_post_default_aspects(post_default_aspect_ids)
|
||||
aspects.each do |aspect|
|
||||
enable = post_default_aspect_ids.include?(aspect.id.to_s)
|
||||
aspect.update_attribute(:post_default, enable)
|
||||
end
|
||||
end
|
||||
|
||||
def salmon(post)
|
||||
Salmon::EncryptedSlap.create_by_user_and_activity(self, post.to_diaspora_xml)
|
||||
end
|
||||
|
|
@ -502,7 +517,8 @@ class User < ActiveRecord::Base
|
|||
self[field] = nil
|
||||
end
|
||||
[:getting_started,
|
||||
:show_community_spotlight_in_stream].each do |field|
|
||||
:show_community_spotlight_in_stream,
|
||||
:post_default_public].each do |field|
|
||||
self[field] = false
|
||||
end
|
||||
self[:disable_mail] = true
|
||||
|
|
|
|||
48
app/views/aspects/_aspect_dropdown.html.haml
Normal file
48
app/views/aspects/_aspect_dropdown.html.haml
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
-# locals: selected_aspects. Note: all_aspects is a global in the ApplicationController
|
||||
:ruby
|
||||
dropdown_css = {"data-toggle" => "dropdown"}
|
||||
if current_user.getting_started?
|
||||
dropdown_css[:title] = popover_with_close_html("2. #{t('shared.public_explain.control_your_audience')}")
|
||||
dropdown_css["data-content"] = t("shared.public_explain.visibility_dropdown")
|
||||
end
|
||||
|
||||
.btn-group.aspect_dropdown
|
||||
%button.btn.btn-default.dropdown-toggle{dropdown_css}
|
||||
- if public_selected?(selected_aspects)
|
||||
%i.entypo-globe.small#visibility-icon
|
||||
%span.text
|
||||
= t("public")
|
||||
- else
|
||||
%i.entypo-lock.small#visibility-icon
|
||||
%span.text
|
||||
- if all_aspects_selected?(all_aspects, selected_aspects)
|
||||
= t("all_aspects")
|
||||
- elsif selected_aspects.size == 1
|
||||
= selected_aspects.first.name
|
||||
- else
|
||||
= t("shared.aspect_dropdown.toggle", count: selected_aspects.size)
|
||||
%span.caret
|
||||
%ul.dropdown-menu.pull-right{unSelectable: "on"}
|
||||
|
||||
%li.public.radio{"data-aspect_id" => "public", :class => ("selected" if public_selected?(selected_aspects))}
|
||||
%a
|
||||
%span.status_indicator
|
||||
%i.glyphicon.glyphicon-ok
|
||||
%span.text
|
||||
= t("public")
|
||||
%li.all_aspects.radio{"data-aspect_id" => "all_aspects",
|
||||
:class => ("selected" if all_aspects_selected?(all_aspects, selected_aspects))}
|
||||
%a
|
||||
%span.status_indicator
|
||||
%i.glyphicon.glyphicon-ok
|
||||
%span.text
|
||||
= t("all_aspects")
|
||||
%li.divider
|
||||
- all_aspects.each do |aspect|
|
||||
%li.aspect_selector{"data-aspect_id" => aspect.id,
|
||||
:class => ("selected" if aspect_selected?(aspect, all_aspects, selected_aspects))}
|
||||
%a
|
||||
%span.status_indicator
|
||||
%i.glyphicon.glyphicon-ok
|
||||
%span.text
|
||||
= aspect.name
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
.btn-group.aspect_dropdown
|
||||
%button.btn.btn-default.dropdown-toggle{ ! current_user.getting_started? ? {'data-toggle' => 'dropdown'} : {'data-toggle' => 'dropdown', title: popover_with_close_html("2. #{t('shared.public_explain.control_your_audience')}"), 'data-content'=> t('shared.public_explain.visibility_dropdown')} }
|
||||
- if publisher_public
|
||||
%i#visibility-icon.entypo-globe.small
|
||||
%span.text
|
||||
= t('public')
|
||||
- else
|
||||
%i#visibility-icon.entypo-lock.small
|
||||
%span.text
|
||||
- if all_aspects_selected?(selected_aspects)
|
||||
= t('all_aspects')
|
||||
- elsif selected_aspects.size == 1
|
||||
= selected_aspects.first.name
|
||||
- else
|
||||
= t('shared.aspect_dropdown.toggle', count: selected_aspects.size)
|
||||
%span.caret
|
||||
%ul.dropdown-menu.pull-right{ unSelectable: 'on' }
|
||||
|
||||
%li.public.radio{"data-aspect_id" => "public", class: ("selected" if publisher_public)}
|
||||
%a
|
||||
%span.status_indicator
|
||||
%i.glyphicon.glyphicon-ok
|
||||
%span.text
|
||||
= t('public')
|
||||
%li.all_aspects.radio{"data-aspect_id" => "all_aspects", class: ("selected" if (!publisher_public && all_aspects_selected?(selected_aspects)))}
|
||||
%a
|
||||
%span.status_indicator
|
||||
%i.glyphicon.glyphicon-ok
|
||||
%span.text
|
||||
= t('all_aspects')
|
||||
%li.divider
|
||||
- for aspect in all_aspects
|
||||
%li.aspect_selector{ 'data-aspect_id' => aspect.id, class: !all_aspects_selected?(selected_aspects) && selected_aspects.include?(aspect) ? "selected" : "" }
|
||||
%a
|
||||
%span.status_indicator
|
||||
%i.glyphicon.glyphicon-ok
|
||||
%span.text
|
||||
= aspect.name
|
||||
|
|
@ -40,9 +40,9 @@
|
|||
!= t("shared.publisher.formatWithMarkdown", markdown_link: link_to(t("help.markdown"),
|
||||
"https://diasporafoundation.org/formatting", target: :blank))
|
||||
|
||||
- if publisher_public
|
||||
- if public_selected?(selected_aspects)
|
||||
= hidden_field_tag "aspect_ids[]", "public"
|
||||
- elsif all_aspects_selected?(selected_aspects)
|
||||
- elsif all_aspects_selected?(all_aspects, selected_aspects)
|
||||
= hidden_field_tag "aspect_ids[]", "all_aspects"
|
||||
- else
|
||||
- for aspect_id in aspect_ids
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
.options_and_submit.col-sm-12
|
||||
.public_toggle.clearfix
|
||||
.btn-toolbar.pull-right
|
||||
= render partial: "publisher/aspect_dropdown", locals: {selected_aspects: selected_aspects}
|
||||
= render partial: "aspects/aspect_dropdown", locals: {selected_aspects: selected_aspects}
|
||||
%button.btn.btn-group.btn-primary#submit= t("shared.publisher.share")
|
||||
|
||||
.btn-toolbar.pull-right#publisher-service-icons
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@
|
|||
.clearfix= f.submit t(".change"), class: "btn btn-primary pull-right"
|
||||
%hr
|
||||
|
||||
= render partial: "post_default"
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
|
|
|
|||
12
app/views/users/_post_default.html.haml
Normal file
12
app/views/users/_post_default.html.haml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
.row
|
||||
.col-md-12
|
||||
%h3
|
||||
= t("users.edit.default_post_visibility")
|
||||
= form_for current_user, url: edit_user_path,
|
||||
html: {method: :put, id: "post-default-aspects", class: "form-horizontal"} do |f|
|
||||
= f.hidden_field :post_default_public, value: false
|
||||
- selected_aspects = current_user.post_default_aspects
|
||||
= render partial: "aspects/aspect_dropdown", locals: {selected_aspects: selected_aspects}
|
||||
.small-horizontal-spacer
|
||||
.clearfix= f.submit t("users.edit.change"), class: "btn btn-primary pull-right"
|
||||
%hr
|
||||
1
app/views/users/_post_default.mobile.haml
Normal file
1
app/views/users/_post_default.mobile.haml
Normal file
|
|
@ -0,0 +1 @@
|
|||
-# This feature is not supported in mobile format.
|
||||
|
|
@ -1156,6 +1156,7 @@ en:
|
|||
following: "Sharing settings"
|
||||
auto_follow_back: "Automatically share with users who start sharing with you"
|
||||
auto_follow_aspect: "Aspect for users you automatically share with:"
|
||||
default_post_visibility: "Default aspects selected for posting"
|
||||
receive_email_notifications: "Receive email notifications when:"
|
||||
started_sharing: "someone starts sharing with you"
|
||||
someone_reported: "someone sends a report"
|
||||
|
|
|
|||
6
db/migrate/20160829170244_add_post_default_to_aspects.rb
Normal file
6
db/migrate/20160829170244_add_post_default_to_aspects.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class AddPostDefaultToAspects < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :aspects, :post_default, :boolean, default: true
|
||||
add_column :users, :post_default_public, :boolean, default: false
|
||||
end
|
||||
end
|
||||
|
|
@ -48,6 +48,7 @@ ActiveRecord::Schema.define(version: 20160906225138) do
|
|||
t.boolean "contacts_visible", default: true, null: false
|
||||
t.integer "order_id", limit: 4
|
||||
t.boolean "chat_enabled", default: false
|
||||
t.boolean "post_default", default: true
|
||||
end
|
||||
|
||||
add_index "aspects", ["user_id", "contacts_visible"], name: "index_aspects_on_user_id_and_contacts_visible", using: :btree
|
||||
|
|
@ -634,6 +635,7 @@ ActiveRecord::Schema.define(version: 20160906225138) do
|
|||
t.datetime "exported_photos_at"
|
||||
t.boolean "exporting_photos", default: false
|
||||
t.string "color_theme", limit: 255
|
||||
t.boolean "post_default_public", default: false
|
||||
end
|
||||
|
||||
add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ Feature: Change settings
|
|||
|
||||
Background:
|
||||
Given I am signed in
|
||||
And I have following aspects:
|
||||
| Friends |
|
||||
| Family |
|
||||
When I go to the edit user page
|
||||
|
||||
Scenario: Change my email
|
||||
|
|
@ -25,3 +28,24 @@ Feature: Change settings
|
|||
And I press "Change language"
|
||||
Then I should see "Język został zmieniony"
|
||||
And "polski" should be selected from "user_language"
|
||||
|
||||
Scenario: Change my post default aspects
|
||||
When I go to the stream page
|
||||
And I expand the publisher
|
||||
Then I should see "All aspects" within ".aspect_dropdown"
|
||||
When I go to the edit user page
|
||||
And I press the aspect dropdown
|
||||
And I toggle the aspect "Family"
|
||||
And I press the aspect dropdown
|
||||
And I press "Change" within "#post-default-aspects"
|
||||
And I go to the stream page
|
||||
And I expand the publisher
|
||||
Then I should see "Family" within ".aspect_dropdown"
|
||||
|
||||
Scenario: Change my post default to public
|
||||
When I press the aspect dropdown
|
||||
And I toggle the aspect "Public"
|
||||
And I press "Change" within "#post-default-aspects"
|
||||
And I go to the stream page
|
||||
And I expand the publisher
|
||||
Then I should see "Public" within ".aspect_dropdown"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,11 @@ module AspectCukeHelpers
|
|||
end
|
||||
|
||||
def toggle_aspect(a_name)
|
||||
a_id = @me.aspects.where(name: a_name).pluck(:id).first
|
||||
a_id = if "Public" == a_name
|
||||
"public"
|
||||
else
|
||||
@me.aspects.where(name: a_name).pluck(:id).first
|
||||
end
|
||||
aspect_css = ".aspect_dropdown li[data-aspect_id='#{a_id}']"
|
||||
expect(page).to have_selector(aspect_css)
|
||||
find(aspect_css).click
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class Stream::Base
|
|||
#NOTE: MBS bad bad methods the fact we need these means our views are foobared. please kill them and make them
|
||||
#private methods on the streams that need them
|
||||
def aspects
|
||||
user.aspects
|
||||
user.post_default_aspects
|
||||
end
|
||||
|
||||
# @return [Aspect] The first aspect in #aspects
|
||||
|
|
@ -71,7 +71,7 @@ class Stream::Base
|
|||
end
|
||||
|
||||
def aspect_ids
|
||||
aspects.map{|x| x.id}
|
||||
aspects.map {|x| x.try(:id) }
|
||||
end
|
||||
|
||||
def max_time=(time_string)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class Stream::Multi < Stream::Base
|
|||
if welcome?
|
||||
{open: true, prefill: publisher_prefill, public: true}
|
||||
else
|
||||
super
|
||||
{public: user.post_default_public}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -19,4 +19,9 @@ class Stream::Public < Stream::Base
|
|||
def can_comment?(post)
|
||||
post.author.local?
|
||||
end
|
||||
|
||||
# Override base class method
|
||||
def aspects
|
||||
["public"]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ describe Stream::Multi do
|
|||
it 'provides no opts if welcome? is not set' do
|
||||
prefill_text = "sup?"
|
||||
allow(@stream).to receive(:welcome?).and_return(false)
|
||||
expect(@stream.send(:publisher_opts)).to eq({})
|
||||
expect(@stream.send(:publisher_opts)).to eq(public: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -931,23 +931,25 @@ describe User, :type => :model do
|
|||
end
|
||||
end
|
||||
|
||||
it 'disables mail' do
|
||||
it "disables mail" do
|
||||
@user.disable_mail = false
|
||||
@user.clear_account!
|
||||
expect(@user.reload.disable_mail).to be true
|
||||
end
|
||||
|
||||
it 'sets getting_started and show_community_spotlight_in_stream fields to false' do
|
||||
it "sets getting_started and show_community_spotlight_in_stream and post_default_public fields to false" do
|
||||
@user.clear_account!
|
||||
expect(@user.reload.getting_started).to be false
|
||||
expect(@user.reload.show_community_spotlight_in_stream).to be false
|
||||
expect(@user.reload.post_default_public).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#clearable_attributes" do
|
||||
it 'returns the clearable fields' do
|
||||
it "returns the clearable fields" do
|
||||
user = FactoryGirl.create :user
|
||||
expect(user.send(:clearable_fields).sort).to eq(%w(
|
||||
expect(user.send(:clearable_fields)).to match_array(
|
||||
%w(
|
||||
language
|
||||
reset_password_sent_at
|
||||
reset_password_token
|
||||
|
|
@ -966,7 +968,9 @@ describe User, :type => :model do
|
|||
confirm_email_token
|
||||
last_seen
|
||||
color_theme
|
||||
).sort)
|
||||
post_default_public
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue