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

Also disable submit button when token is missing

Jan Sandbrinkf7ac665c7d07
diff --git a/app/forms/work_packages/types/subject_configuration_form.rb b/app/forms/work_packages/types/subject_configuration_form.rb
index 9faf6d55fae..51cea3c9c34 100644
--- a/app/forms/work_packages/types/subject_configuration_form.rb
+++ b/app/forms/work_packages/types/subject_configuration_form.rb
@@ -67,7 +67,12 @@ module WorkPackages
)
end
- subject_form.submit(name: :submit, label: I18n.t(:button_save), scheme: :primary)
+ subject_form.submit(
+ name: :submit,
+ label: I18n.t(:button_save),
+ disabled: !EnterpriseToken.active? && !has_pattern?,
+ scheme: :primary
+ )
end
private
diff --git a/spec/components/work_packages/types/subject_configuration_component_spec.rb b/spec/components/work_packages/types/subject_configuration_component_spec.rb
index 7ac73b1ec0b..bf3ac898891 100644
--- a/spec/components/work_packages/types/subject_configuration_component_spec.rb
+++ b/spec/components/work_packages/types/subject_configuration_component_spec.rb
@@ -54,6 +54,12 @@ RSpec.describe WorkPackages::Types::SubjectConfigurationComponent, type: :compon
expect(page.find("input[type=radio][value=manual]")).not_to be_disabled
end
+ it "enables the submit button" do
+ render_component
+
+ expect(page.find("button[type=submit]")).not_to be_disabled
+ end
+
context "when enterprise edition is not activated" do
before do
allow(EnterpriseToken).to receive(:active?).and_return(false)
@@ -72,6 +78,12 @@ RSpec.describe WorkPackages::Types::SubjectConfigurationComponent, type: :compon
expect(page.find("input[type=radio][value=manual]")).not_to be_disabled
end
+ it "disables the submit button" do
+ render_component
+
+ expect(page.find("button[type=submit]")).to be_disabled
+ end
+
context "and when the subject is already automatically generated" do
let(:type) { create(:type, patterns: { subject: { blueprint: "Hello world", enabled: true } }) }
@@ -87,6 +99,12 @@ RSpec.describe WorkPackages::Types::SubjectConfigurationComponent, type: :compon
expect(page.find("input[type=radio][value=auto]")).not_to be_disabled
expect(page.find("input[type=radio][value=manual]")).not_to be_disabled
end
+
+ it "enables the submit button" do
+ render_component
+
+ expect(page.find("button[type=submit]")).not_to be_disabled
+ end
end
end
end