Merge pull request #8406 from Flaburgan/6184-service-disabled

Do not show the service to the user if it is disabled, fixes #6184

Fixes #6184
This commit is contained in:
Benjamin Neff 2024-06-05 01:03:12 +02:00
commit c3eaa212af
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
6 changed files with 35 additions and 8 deletions

View file

@ -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)

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -202,5 +202,9 @@ test:
enable: true
key: 'fake'
secret: 'sdoigjosdfijg'
tumblr:
enable: true
key: 'fake'
secret: 'sdoigjosdfijg'
mail:
enable: true

View file

@ -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