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

Add Project N/A text when the versions project is not accessible to the user

Dombi Attila1d8a91ea3988
diff --git a/app/forms/custom_fields/inputs/multi_version_select_list.rb b/app/forms/custom_fields/inputs/multi_version_select_list.rb
index 2173bdaa8bd..11f7be1dd8f 100644
--- a/app/forms/custom_fields/inputs/multi_version_select_list.rb
+++ b/app/forms/custom_fields/inputs/multi_version_select_list.rb
@@ -48,7 +48,7 @@ class CustomFields::Inputs::MultiVersionSelectList < CustomFields::Inputs::Base:
list.option(
label: version.name,
value: version.id,
- group_by: version.project.name,
+ group_by: group_key(version.project),
selected: selected?(version)
)
end
@@ -64,4 +64,8 @@ class CustomFields::Inputs::MultiVersionSelectList < CustomFields::Inputs::Base:
def selected?(version)
@custom_values.pluck(:value).map { |value| value&.to_i }.include?(version.id)
end
+
+ def group_key(project)
+ project.visible?(User.current) ? project.name : I18n.t(:"project.not_available")
+ end
end
diff --git a/app/forms/custom_fields/inputs/single_version_select_list.rb b/app/forms/custom_fields/inputs/single_version_select_list.rb
index 0d534a7107f..70513b9f2af 100644
--- a/app/forms/custom_fields/inputs/single_version_select_list.rb
+++ b/app/forms/custom_fields/inputs/single_version_select_list.rb
@@ -43,7 +43,7 @@ class CustomFields::Inputs::SingleVersionSelectList < CustomFields::Inputs::Base
list.option(
label: version.name,
value: version.id,
- group_by: version.project.name,
+ group_by: group_key(version.project),
selected: selected?(version)
)
end
@@ -59,4 +59,8 @@ class CustomFields::Inputs::SingleVersionSelectList < CustomFields::Inputs::Base
def selected?(version)
version.id == @custom_value.value&.to_i
end
+
+ def group_key(project)
+ project.visible?(User.current) ? project.name : I18n.t(:"project.not_available")
+ end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 2b5b2a21672..829fd269b06 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -995,6 +995,8 @@ en:
active_value:
true: "unarchived"
false: "archived"
+ description: "Description"
+ enabled_modules: "Enabled modules"
identifier: "Identifier"
latest_activity_at: "Latest activity at"
parent: "Subproject of"
@@ -1003,9 +1005,7 @@ en:
true: "public"
false: "private"
queries: "Queries"
- enabled_modules: "Enabled modules"
status_code: "Project status"
- description: "Description"
status_explanation: "Project status description"
status_codes:
not_started: "Not started"
@@ -3482,6 +3482,13 @@ en:
default: "-"
project:
+ archive:
+ are_you_sure: "Are you sure you want to archive the project '%{name}'?"
+ archived: "Archived"
+ count:
+ zero: "0 projects"
+ one: "1 project"
+ other: "%{count} projects"
destroy:
confirmation: "If you continue, the project %{identifier} will be permanently destroyed. To confirm this action please introduce the project name in the field below, this will:"
project_delete_result_1: "Delete all related data."
@@ -3494,6 +3501,7 @@ en:
warning_one: Members of the project will have to relocate the project's repositories.
warning_two: Existing links to the project will no longer work.
title: Change the project's identifier
+ not_available: "Project N/A"
template:
copying: >
Your project is being created from the selected template project.
@@ -3501,13 +3509,6 @@ en:
use_template: "Use template"
make_template: "Set as template"
remove_from_templates: "Remove from templates"
- archive:
- are_you_sure: "Are you sure you want to archive the project '%{name}'?"
- archived: "Archived"
- count:
- zero: "0 projects"
- one: "1 project"
- other: "%{count} projects"
project_module_activity: "Activity"
project_module_forums: "Forums"
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index b02feff377f..3983aa452f7 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -777,19 +777,19 @@ en:
relation_description: "Click to add description for this relation"
project:
- required_outside_context: >
- Please choose a project to create the work package in to see all attributes.
- You can only select projects which have the type above activated.
- context: "Project context"
+ autocompleter:
+ label: "Project autocompletion"
click_to_switch_to_project: "Project: %{projectname}"
confirm_template_load: "Switching the template will reload the page and you will lose all input to this form. Continue?"
- use_template: "Use template"
- no_template_selected: "(None)"
+ context: "Project context"
copy:
copy_options: "Copy options"
-
- autocompleter:
- label: "Project autocompletion"
+ not_available: "Project N/A"
+ no_template_selected: "(None)"
+ required_outside_context: >
+ Please choose a project to create the work package in to see all attributes.
+ You can only select projects which have the type above activated.
+ use_template: "Use template"
reminders:
settings:
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts b/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
index b500094dccf..843d95421d4 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
+++ b/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
@@ -67,7 +67,7 @@ export class FilterSearchableMultiselectValueComponent extends UntilDestroyedMix
groupByFn = (item:HalResource):string|null => {
if (!this.isVersionResource) return null;
const project = item.definingProject as HalResource | undefined;
- return project?.name ?? null;
+ return project?.name ?? this.I18n.t('js.project.not_available');
};
compareByHref = compareByHref;
diff --git a/frontend/src/app/shared/components/autocompleter/version-autocompleter/version-autocompleter.component.ts b/frontend/src/app/shared/components/autocompleter/version-autocompleter/version-autocompleter.component.ts
index fbc52a8b03b..3c8200d44fc 100644
--- a/frontend/src/app/shared/components/autocompleter/version-autocompleter/version-autocompleter.component.ts
+++ b/frontend/src/app/shared/components/autocompleter/version-autocompleter/version-autocompleter.component.ts
@@ -54,8 +54,9 @@ export class VersionAutocompleterComponent extends CreateAutocompleterComponent
@Output() public onCreate = new EventEmitter<VersionResource>();
groupByFn = (item:HalResource):string|null => {
+ if (!item.id) return null; // Do not group non version options
const project = item.definingProject as HalResource | undefined;
- return project?.name ?? null;
+ return project?.name ?? this.I18n.t('js.project.not_available');
};
constructor(
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.ts
index cd4b3f3169d..7ea51fceb73 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.ts
@@ -50,7 +50,7 @@ export class MultiSelectEditFieldComponent extends EditFieldComponent implements
groupByFn = (item:HalResource):string|null => {
if (!this.isVersionResource) return null;
const project = item.definingProject as HalResource | undefined;
- return project?.name ?? null;
+ return project?.name ?? this.I18n.t('js.project.not_available');
};
public availableOptions:any[] = [];
diff --git a/spec/features/work_packages/details/inplace_editor/version_editor_spec.rb b/spec/features/work_packages/details/inplace_editor/version_editor_spec.rb
index 1d3fac2cd74..d9a7ba7a2ed 100644
--- a/spec/features/work_packages/details/inplace_editor/version_editor_spec.rb
+++ b/spec/features/work_packages/details/inplace_editor/version_editor_spec.rb
@@ -69,7 +69,8 @@ RSpec.describe "subject inplace editor", :js, :selenium do
# Expect the order to be descending by version date
labels = page.all(".ng-option-label").map { |el| el.text.strip }
- expect(labels).to eq ["-", version.name, version2.name, version3.name]
+ expect(labels)
+ .to eq ["-", project.name, version.name, "Project N/A", version2.name, version3.name]
page.find(".ng-option-label", text: version3.name).select_option
field.expect_state_text(version3.name)