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

Fix repository branch selection

Oliver Günther38a162b3993a
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb
index 45fb3a3fe75..fed7c0ac659 100644
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -36,7 +36,7 @@ See COPYRIGHT and LICENSE files for more details.
</div>
<% if [email protected]? && authorize_for('repositories', 'browse') %>
-<%= render partial: 'dir_list' %>
+ <%= render partial: 'dir_list' %>
<% end %>
<%= render_properties(@properties) %>
@@ -50,8 +50,11 @@ See COPYRIGHT and LICENSE files for more details.
},
method: :get,
id: 'revision_selector',
- class: 'form -vertical'
- ) do %>
+ class: 'form -vertical',
+ data: {
+ 'repository-navigation-target': 'form',
+ }
+ ) do %>
<li class="toolbar-item toolbar-input-group hidden-for-mobile">
<div>
<%= label_tag 'rev', I18n.t('repositories.go_to_revision') %>
@@ -66,34 +69,36 @@ See COPYRIGHT and LICENSE files for more details.
} %>
</li>
<% if [email protected]? && @repository.branches.length > 0 %>
- <li class="toolbar-item toolbar-input-group hidden-for-mobile">
- <div>
- <%= label_tag 'branch', I18n.t(:label_branch) %>
- </div>
- <%= select_tag :branch,
- options_for_select(@repository.branches, @rev),
- include_blank: "--- #{t(:actionview_instancetag_blank_option)} ---",
- id: 'revision-branch-select',
- data: {
- 'repository-navigation-target': 'branch'
- }
- %>
- </li>
+ <li class="toolbar-item toolbar-input-group hidden-for-mobile">
+ <div>
+ <%= label_tag 'branch', I18n.t(:label_branch) %>
+ </div>
+ <%= select_tag :branch,
+ options_for_select(@repository.branches, @rev),
+ include_blank: "--- #{t(:actionview_instancetag_blank_option)} ---",
+ id: 'revision-branch-select',
+ data: {
+ 'repository-navigation-target': 'branch',
+ action: 'repository-navigation#applyValue'
+ }
+ %>
+ </li>
<% end %>
<% if [email protected]? && @repository.tags.length > 0 %>
- <li class="toolbar-item toolbar-input-group hidden-for-mobile">
- <div>
- <%= label_tag 'tag', I18n.t(:label_tag) %>
- </div>
- <%= select_tag :tag,
- options_for_select(@repository.tags, @rev),
- include_blank: "--- #{t(:actionview_instancetag_blank_option)} ---",
- id: 'revision-tag-select',
- data: {
- 'repository-navigation-target': 'tag'
- }
- %>
- </li>
+ <li class="toolbar-item toolbar-input-group hidden-for-mobile">
+ <div>
+ <%= label_tag 'tag', I18n.t(:label_tag) %>
+ </div>
+ <%= select_tag :tag,
+ options_for_select(@repository.tags, @rev),
+ include_blank: "--- #{t(:actionview_instancetag_blank_option)} ---",
+ id: 'revision-tag-select',
+ data: {
+ 'repository-navigation-target': 'tag',
+ action: 'repository-navigation#applyValue'
+ }
+ %>
+ </li>
<% end %>
<li class="toolbar-item -icon-only">
<%= link_to({ url: { action: 'revision#revision-identifier-inputs', project_id: @project,
@@ -106,22 +111,22 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<% if authorize_for('repositories', 'revisions') %>
-<% if @changesets && [email protected]? %>
-<%= render partial: 'revisions',
- locals: {project: @project, path: @path,
- revisions: @changesets, entry: nil }%>
-<% end %>
-<p>
-<%
- has_branches = ([email protected]? && @repository.branches.length > 0)
- sep = ''
- %>
+ <% if @changesets && [email protected]? %>
+ <%= render partial: 'revisions',
+ locals: { project: @project, path: @path,
+ revisions: @changesets, entry: nil } %>
+ <% end %>
+ <p>
+ <%
+ has_branches = ([email protected]? && @repository.branches.length > 0)
+ sep = ''
+ %>
-<% if @repository.supports_all_revisions? && @path.blank? %>
-<%= link_to t(:label_view_all_revisions), revisions_project_repository_path(@project) %>
-<% sep = '|' %>
-<% end %>
-</p>
+ <% if @repository.supports_all_revisions? && @path.blank? %>
+ <%= link_to t(:label_view_all_revisions), revisions_project_repository_path(@project) %>
+ <% sep = '|' %>
+ <% end %>
+ </p>
<% end %>
<% html_title(t(:label_repository)) -%>
diff --git a/frontend/src/stimulus/controllers/dynamic/repository-navigation.controller.ts b/frontend/src/stimulus/controllers/dynamic/repository-navigation.controller.ts
index 079ec643686..d433509fc2a 100644
--- a/frontend/src/stimulus/controllers/dynamic/repository-navigation.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/repository-navigation.controller.ts
@@ -67,12 +67,20 @@ export default class RepositoryNavigationController extends Controller {
}
sendForm() {
- this.branchTarget.disabled = true;
- this.tagTarget.disabled = true;
+ if (this.hasBranchTarget) {
+ this.branchTarget.disabled = true;
+ }
+ if (this.hasTagTaget) {
+ this.tagTarget.disabled = true;
+ }
this.formTarget.submit();
- this.branchTarget.disabled = false;
- this.tagTarget.disabled = false;
+ if (this.hasBranchTarget) {
+ this.branchTarget.disabled = false;
+ }
+ if (this.hasTagTaget) {
+ this.tagTarget.disabled = false;
+ }
}
/**