Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Remove features shown in Admin that do not have a translation

Klaus Zanders41253fa77f75
diff --git a/app/helpers/enterprise_helper.rb b/app/helpers/enterprise_helper.rb
index 6c49352b936..116b59d8c8a 100644
--- a/app/helpers/enterprise_helper.rb
+++ b/app/helpers/enterprise_helper.rb
@@ -1,3 +1,33 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
module EnterpriseHelper
def write_augur_to_gon
gon.augur_url = OpenProject::Configuration.enterprise_trial_creation_host
@@ -15,17 +45,16 @@ module EnterpriseHelper
end
def enterprise_token_plan_name(enterprise_token)
- if enterprise_token.respond_to?(:plan)
- <<~LABEL.squish
- #{I18n.t(enterprise_token.plan, scope: [:enterprise_plans])}
- (#{I18n.t('enterprise_plans.label_token_version')} #{enterprise_token.version})
- LABEL
- end
+ <<~LABEL.squish
+ #{I18n.t(enterprise_token.plan, scope: [:enterprise_plans])}
+ (#{I18n.t(:label_token_version)} #{enterprise_token.version})
+ LABEL
end
def enterprise_plan_additional_features(enterprise_token)
(enterprise_token.try(:features) || [])
- .map { |feature| I18n.t(feature, scope: [:enterprise_features], default: feature.to_s.humanize) }
- .join(", ")
+ .filter_map { |feature| I18n.t(feature, scope: [:enterprise_features], default: nil) }
+ .sort
+ .join(", ")
end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index c7bb27775bc..95666ce4ef1 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2929,6 +2929,7 @@ en:
label_title: "Title"
label_projects_menu: "Projects"
label_today: "today"
+ label_token_version: "Token Version"
label_top_menu: "Top Menu"
label_topic_plural: "Topics"
label_total: "Total"
@@ -4578,7 +4579,6 @@ en:
description: "Adds the OmniAuth SAML provider to OpenProject"
enterprise_plans:
- label_token_version: "Token Version"
legacy_enterprise: "Enterprise Plan"
enterprise_features:
diff --git a/spec/helpers/enterprise_helper_spec.rb b/spec/helpers/enterprise_helper_spec.rb
new file mode 100644
index 00000000000..dd7f0b7093e
--- /dev/null
+++ b/spec/helpers/enterprise_helper_spec.rb
@@ -0,0 +1,70 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require "spec_helper"
+
+RSpec.describe EnterpriseHelper do
+ describe "#enterprise_token_plan_name" do
+ let(:token) { instance_double(EnterpriseToken, plan: :legacy_enterprise, version: "4.0.0") }
+
+ it "returns the correct string" do
+ expect(helper.enterprise_token_plan_name(token)).to eq("Enterprise Plan (Token Version 4.0.0)")
+ end
+ end
+
+ describe "#enterprise_plan_additional_features" do
+ context "without any additional features" do
+ let(:token) { instance_double(EnterpriseToken, features: []) }
+
+ it "returns an empty string" do
+ expect(helper.enterprise_plan_additional_features(token)).to eq("")
+ end
+ end
+
+ context "with known additional features" do
+ let(:token) { instance_double(EnterpriseToken, features: %i[baseline_comparison virus_scanning]) }
+
+ it "returns translated names of features" do
+ expect(helper.enterprise_plan_additional_features(token)).to eq("Attachment Virus Scanning, Baseline Comparison")
+ end
+ end
+
+ context "with known and unknown additional features" do
+ let(:token) do
+ instance_double(EnterpriseToken,
+ features: %i[work_package_sharing this_feature_does_not_exist and_this_one_also_does_not_exist])
+ end
+
+ it "returns translated names of features and removes unknowns" do
+ expect(helper.enterprise_plan_additional_features(token)).to eq("Work Package Sharing")
+ end
+ end
+ end
+end