diff --git a/Changelog.md b/Changelog.md index e3bad07fe..490a868fe 100644 --- a/Changelog.md +++ b/Changelog.md @@ -66,6 +66,7 @@ We recommend setting up new pods using Ruby 3.3, and updating existing pods to t * Cleanup duplicate pods in database [#8403](https://github.com/diaspora/diaspora/pull/8403) * Fix scrolling issue after closing photo viewer on photos page [#8404](https://github.com/diaspora/diaspora/pull/8404) * Filter unicode emojis from email headers [#8421](https://github.com/diaspora/diaspora/pull/8421) +* Do not show disabled services anymore [#8406](https://github.com/diaspora/diaspora/pull/8406) ## Features * Add client-side cropping of profile image uploads [#7581](https://github.com/diaspora/diaspora/pull/7581) diff --git a/app/helpers/publisher_helper.rb b/app/helpers/publisher_helper.rb index 905d216c7..b7ba0ccb9 100644 --- a/app/helpers/publisher_helper.rb +++ b/app/helpers/publisher_helper.rb @@ -5,6 +5,10 @@ # the COPYRIGHT file. module PublisherHelper + def available_services + current_user.services.select {|service| AppConfig.configured_services.map(&:to_s).include? service.provider } + end + def service_button(service) provider_title = I18n.t("services.index.share_to", provider: service.provider.titleize) content_tag :div, diff --git a/app/views/publisher/_publisher.html.haml b/app/views/publisher/_publisher.html.haml index 3322d7619..5d3633eca 100644 --- a/app/views/publisher/_publisher.html.haml +++ b/app/views/publisher/_publisher.html.haml @@ -55,9 +55,9 @@ %button.btn.btn-group.btn-primary#submit= t("shared.publisher.share") .btn-toolbar.pull-right#publisher-service-icons - - if current_user.services - - current_user.services.each do |service| - = service_button(service) + - available_services.each do |service| + = service_button(service) + .btn.btn-link.question_mark{title: t("shared.public_explain.manage"), data: {toggle: "modal", target: "#publicExplainModal"}} %i.entypo-cog diff --git a/app/views/publisher/_publisher.mobile.haml b/app/views/publisher/_publisher.mobile.haml index da881fa25..ece543724 100644 --- a/app/views/publisher/_publisher.mobile.haml +++ b/app/views/publisher/_publisher.mobile.haml @@ -11,11 +11,10 @@ = hidden_field_tag "aspect_ids[]", "all_aspects" .form-group %span#publisher-service-icons - - if current_user.services - - for service in current_user.services - = image_tag "social-media-logos/#{service.provider}-32x32.png", - title: service.provider.titleize, class: "service_icon dim", - id: "#{service.provider}", maxchar: "#{service.class::MAX_CHARACTERS}" + - available_services.each do |service| + = image_tag "social-media-logos/#{service.provider}-32x32.png", + title: service.provider.titleize, class: "service_icon dim", + id: service.provider, maxchar: service.class::MAX_CHARACTERS.to_s .clear #publisher-textarea-wrapper diff --git a/config/defaults.yml b/config/defaults.yml index 901b45dc8..29d4ebdab 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -202,5 +202,9 @@ test: enable: true key: 'fake' secret: 'sdoigjosdfijg' + tumblr: + enable: true + key: 'fake' + secret: 'sdoigjosdfijg' mail: enable: true diff --git a/spec/helpers/publisher_helper_spec.rb b/spec/helpers/publisher_helper_spec.rb index 34dcad051..60b959627 100644 --- a/spec/helpers/publisher_helper_spec.rb +++ b/spec/helpers/publisher_helper_spec.rb @@ -1,6 +1,25 @@ # frozen_string_literal: true describe PublisherHelper, type: :helper do + describe "#available_services" do + include Devise::Test::ControllerHelpers + + before do + @user = alice + + @user.services << FactoryBot.build(:service, type: "Services::Wordpress", provider: "wordpress") + @user.services << FactoryBot.build(:service, type: "Services::Tumblr", provider: "tumblr") + + def current_user + @user + end + end + + it "returns only the connected and enabled services" do + expect(available_services.map(&:provider)).to eq(%w[tumblr]) + end + end + describe "#public_selected?" do it "returns true when the selected_aspects contains 'public'" do expect(helper.public_selected?(["public"])).to be_truthy