mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
get rid of the old-style identifier setting entirely
This commit is contained in:
@@ -46,24 +46,22 @@ See COPYRIGHT and LICENSE files for more details.
|
||||
%>
|
||||
<% end %>
|
||||
|
||||
<% if OpenProject::FeatureDecisions.semantic_work_package_ids_active? %>
|
||||
<%= render(Primer::BaseComponent.new(tag: :section, mb: 4)) do %>
|
||||
<%=
|
||||
render(Primer::Beta::Subhead.new) do |component|
|
||||
component.with_heading(tag: :h3, size: :medium) { t(:label_identifier) }
|
||||
end
|
||||
%>
|
||||
<%=
|
||||
settings_primer_form_with(model: project, url: project_settings_general_path(project)) do |f|
|
||||
render(Primer::Forms::FormList.new(Projects::Settings::IdentifierForm.new(f)))
|
||||
end
|
||||
%>
|
||||
<%= render(Primer::Beta::Button.new(
|
||||
tag: :a,
|
||||
href: projects_identifier_dialog_path(project_id: project),
|
||||
data: { turbo_stream: true }
|
||||
)) { t("projects.settings.change_identifier") } %>
|
||||
<% end %>
|
||||
<%= render(Primer::BaseComponent.new(tag: :section, mb: 4)) do %>
|
||||
<%=
|
||||
render(Primer::Beta::Subhead.new) do |component|
|
||||
component.with_heading(tag: :h3, size: :medium) { t(:label_identifier) }
|
||||
end
|
||||
%>
|
||||
<%=
|
||||
settings_primer_form_with(model: project, url: project_settings_general_path(project)) do |f|
|
||||
render(Primer::Forms::FormList.new(Projects::Settings::IdentifierForm.new(f)))
|
||||
end
|
||||
%>
|
||||
<%= render(Primer::Beta::Button.new(
|
||||
tag: :a,
|
||||
href: projects_identifier_dialog_path(project_id: project),
|
||||
data: { turbo_stream: true }
|
||||
)) { t("projects.settings.change_identifier") } %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
@@ -24,21 +24,6 @@
|
||||
end
|
||||
end
|
||||
|
||||
unless OpenProject::FeatureDecisions.semantic_work_package_ids_active?
|
||||
header.with_action_button(
|
||||
tag: :a,
|
||||
mobile_icon: :pencil,
|
||||
mobile_label: t("projects.settings.change_identifier"),
|
||||
size: :medium,
|
||||
href: project_identifier_path(@project),
|
||||
aria: { label: t("projects.settings.change_identifier") },
|
||||
title: t("projects.settings.change_identifier")
|
||||
) do |button|
|
||||
button.with_leading_visual_icon(icon: :pencil)
|
||||
t("projects.settings.change_identifier")
|
||||
end
|
||||
end
|
||||
|
||||
header.with_action_menu(
|
||||
menu_arguments: {
|
||||
anchor_align: :end
|
||||
|
||||
@@ -34,8 +34,6 @@ class Projects::IdentifierController < ApplicationController
|
||||
before_action :find_project_by_project_id
|
||||
before_action :authorize
|
||||
|
||||
def show; end
|
||||
|
||||
def update
|
||||
service_call = Projects::UpdateService
|
||||
.new(user: current_user,
|
||||
|
||||
@@ -39,7 +39,7 @@ class ProjectsController < ApplicationController
|
||||
before_action :find_project_including_archived, only: %i[destroy destroy_info]
|
||||
before_action :load_query_or_deny_access, only: %i[index]
|
||||
before_action :authorize,
|
||||
only: %i[copy_form copy deactivate_work_package_attachments export_project_initiation_pdf]
|
||||
only: %i[copy_form copy deactivate_work_package_attachments export_project_initiation_pdf identifier_dialog]
|
||||
before_action :authorize_global, only: %i[new create]
|
||||
before_action :require_admin, only: %i[destroy destroy_info]
|
||||
before_action :find_optional_parent, only: :new
|
||||
@@ -163,8 +163,6 @@ class ProjectsController < ApplicationController
|
||||
end
|
||||
|
||||
def identifier_dialog
|
||||
return render_404 unless OpenProject::FeatureDecisions.semantic_work_package_ids_active?
|
||||
|
||||
respond_with_dialog Projects::Settings::ChangeIdentifierDialogComponent.new(project: @project)
|
||||
end
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ module Projects
|
||||
module Settings
|
||||
class EditableIdentifierForm < ApplicationForm
|
||||
form do |f|
|
||||
if Project.semantic_alphanumeric_identifier?
|
||||
if Setting::WorkPackageIdentifier.alphanumeric?
|
||||
f.text_field(
|
||||
name: :identifier,
|
||||
label: attribute_name(:identifier),
|
||||
|
||||
@@ -31,7 +31,7 @@ module Projects
|
||||
module Settings
|
||||
class IdentifierForm < ApplicationForm
|
||||
form do |f|
|
||||
caption_key = if Project.semantic_alphanumeric_identifier?
|
||||
caption_key = if Setting::WorkPackageIdentifier.alphanumeric?
|
||||
:text_project_identifier_description
|
||||
else
|
||||
:text_project_identifier_url_description
|
||||
|
||||
@@ -211,18 +211,20 @@ class Project < ApplicationRecord
|
||||
# Contains only a-z, 0-9, dashes and underscores but cannot consist of numbers only as it would clash with the id.
|
||||
validates :identifier,
|
||||
format: { with: /\A(?!^\d+\z)[a-z0-9\-_]+\z/ },
|
||||
if: ->(p) { p.identifier_changed? && p.identifier.present? && !Project.semantic_alphanumeric_identifier? }
|
||||
if: ->(p) {
|
||||
p.identifier_changed? && p.identifier.present? && !Setting::WorkPackageIdentifier.alphanumeric?
|
||||
}
|
||||
|
||||
# When semantic work package IDs with alphanumeric mode are active, identifiers must follow JIRA-style key rules.
|
||||
validates :identifier,
|
||||
format: { with: /\A[A-Z]/, message: :must_start_with_letter },
|
||||
if: ->(p) { p.identifier_changed? && p.identifier.present? && Project.semantic_alphanumeric_identifier? }
|
||||
if: ->(p) { p.identifier_changed? && p.identifier.present? && Setting::WorkPackageIdentifier.alphanumeric? }
|
||||
|
||||
validates :identifier,
|
||||
format: { with: /\A[A-Z][A-Z0-9_]*\z/, message: :no_special_characters },
|
||||
length: { maximum: SEMANTIC_IDENTIFIER_MAX_LENGTH },
|
||||
if: ->(p) {
|
||||
p.identifier_changed? && p.identifier.present? && Project.semantic_alphanumeric_identifier? &&
|
||||
p.identifier_changed? && p.identifier.present? && Setting::WorkPackageIdentifier.alphanumeric? &&
|
||||
p.identifier.match?(/\A[A-Z]/)
|
||||
}
|
||||
|
||||
@@ -280,10 +282,6 @@ class Project < ApplicationRecord
|
||||
User.current.allowed_in_project?(:copy_projects, self)
|
||||
end
|
||||
|
||||
def self.semantic_alphanumeric_identifier?
|
||||
OpenProject::FeatureDecisions.semantic_work_package_ids_active? && Setting::WorkPackageIdentifier.alphanumeric?
|
||||
end
|
||||
|
||||
def self.selectable_projects
|
||||
Project.visible.select { |p| User.current.member_of? p }.sort_by(&:to_s)
|
||||
end
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
<%#-- 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.
|
||||
|
||||
++#%>
|
||||
|
||||
<%=
|
||||
render Primer::OpenProject::PageHeader.new do |header|
|
||||
header.with_title { t("project.identifier.title") }
|
||||
header.with_breadcrumbs(
|
||||
[{ href: project_overview_path(@project.id), text: @project.name },
|
||||
{ href: project_settings_general_path(@project.id), text: I18n.t("label_project_settings") },
|
||||
t("project.identifier.title")]
|
||||
)
|
||||
end
|
||||
%>
|
||||
|
||||
<%= error_messages_for @project %>
|
||||
|
||||
<%= form_for @project,
|
||||
url: project_identifier_path(@project),
|
||||
html: { class: "danger-zone form -vertical" } do |f| %>
|
||||
<section class="form--section">
|
||||
<h3 class="form--section-title">
|
||||
<%= t("project.identifier.title") %>
|
||||
</h3>
|
||||
|
||||
<p class="danger-zone--warning">
|
||||
<span class="icon icon-error"></span>
|
||||
<span><%= t("project.identifier.warning_one").html_safe %></span>
|
||||
<br>
|
||||
<span class="icon icon-error"></span>
|
||||
<span><%= t("project.identifier.warning_two").html_safe %></span>
|
||||
</p>
|
||||
|
||||
<%= styled_label_tag "identifier", Project.human_attribute_name(:identifier), class: "-required" %>
|
||||
<div class="danger-zone--verification">
|
||||
<%= f.text_field :identifier %>
|
||||
<span>
|
||||
<%= f.submit t(:button_update), class: "button -primary -with-icon icon-checkmark" %>
|
||||
</span>
|
||||
<span>
|
||||
<%= link_to project_settings_general_path(@project), class: "button" do %>
|
||||
<%= op_icon("button--icon icon-cancel") %>
|
||||
<span class="button--text"><%= t(:button_cancel) %></span>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div class="form--field-instructions">
|
||||
<%= t(
|
||||
:text_length_between, min: 1,
|
||||
max: Project::IDENTIFIER_MAX_LENGTH
|
||||
) %>
|
||||
<%= t(:text_project_identifier_info).html_safe %>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
<% end %>
|
||||
@@ -138,6 +138,7 @@ Rails.application.reloader.to_prepare do
|
||||
"projects/settings/template": %i[show update toggle_template],
|
||||
"projects/templated": %i[create destroy],
|
||||
"projects/identifier": %i[show update update_identifier_dialog],
|
||||
projects: %i[identifier_dialog],
|
||||
"projects/status": %i[update destroy]
|
||||
},
|
||||
permissible_on: :project,
|
||||
|
||||
Reference in New Issue
Block a user