Commit 839b38ac authored by Brett Walker's avatar Brett Walker

Dynamically store the valid label endpoint

parent 277a1747
...@@ -29,6 +29,7 @@ class ListIssue { ...@@ -29,6 +29,7 @@ class ListIssue {
this.path = obj.real_path; this.path = obj.real_path;
this.toggleSubscriptionEndpoint = obj.toggle_subscription_endpoint; this.toggleSubscriptionEndpoint = obj.toggle_subscription_endpoint;
this.project_id = obj.project_id; this.project_id = obj.project_id;
this.validLabelsEndpoint = obj.valid_labels_endpoint;
if (obj.project) { if (obj.project) {
this.project = new IssueProject(obj.project); this.project = new IssueProject(obj.project);
......
...@@ -59,7 +59,6 @@ export default class LabelsSelect { ...@@ -59,7 +59,6 @@ export default class LabelsSelect {
$toggleText = $dropdown.find('.dropdown-toggle-text'); $toggleText = $dropdown.find('.dropdown-toggle-text');
namespacePath = $dropdown.data('namespacePath'); namespacePath = $dropdown.data('namespacePath');
projectPath = $dropdown.data('projectPath'); projectPath = $dropdown.data('projectPath');
labelUrl = $dropdown.data('labels');
issueUpdateURL = $dropdown.data('issueUpdate'); issueUpdateURL = $dropdown.data('issueUpdate');
selectedLabel = $dropdown.data('selected'); selectedLabel = $dropdown.data('selected');
if (selectedLabel != null && !$dropdown.hasClass('js-multiselect')) { if (selectedLabel != null && !$dropdown.hasClass('js-multiselect')) {
...@@ -168,6 +167,7 @@ export default class LabelsSelect { ...@@ -168,6 +167,7 @@ export default class LabelsSelect {
$dropdown.glDropdown({ $dropdown.glDropdown({
showMenuAbove: showMenuAbove, showMenuAbove: showMenuAbove,
data: function(term, callback) { data: function(term, callback) {
labelUrl = $dropdown.attr('data-labels');
axios axios
.get(labelUrl) .get(labelUrl)
.then(res => { .then(res => {
......
...@@ -240,7 +240,8 @@ class Issue < ActiveRecord::Base ...@@ -240,7 +240,8 @@ class Issue < ActiveRecord::Base
reference_path: issue_reference, reference_path: issue_reference,
real_path: url_helper.project_issue_path(project, self), real_path: url_helper.project_issue_path(project, self),
issue_sidebar_endpoint: url_helper.project_issue_path(project, self, format: :json, serializer: 'sidebar'), issue_sidebar_endpoint: url_helper.project_issue_path(project, self, format: :json, serializer: 'sidebar'),
toggle_subscription_endpoint: url_helper.toggle_subscription_project_issue_path(project, self) toggle_subscription_endpoint: url_helper.toggle_subscription_project_issue_path(project, self),
valid_labels_endpoint: url_helper.project_labels_path(project, format: :json, include_ancestor_groups: true)
) )
end end
......
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
":value" => "label.id" } ":value" => "label.id" }
.dropdown .dropdown
%button.dropdown-menu-toggle.js-label-select.js-multiselect.js-issue-board-sidebar{ type: "button", %button.dropdown-menu-toggle.js-label-select.js-multiselect.js-issue-board-sidebar{ type: "button",
"v-bind:data-selected" => "selectedLabels", ":data-selected" => "selectedLabels",
":data-labels" => "issue.validLabelsEndpoint",
data: { toggle: "dropdown", data: { toggle: "dropdown",
field_name: "issue[label_names][]", field_name: "issue[label_names][]",
show_no: "true", show_no: "true",
show_any: "true", show_any: "true",
project_id: @project&.try(:id), project_id: @project&.try(:id),
labels: labels_filter_path_with_defaults,
namespace_path: @namespace_path, namespace_path: @namespace_path,
project_path: @project.try(:path) } } project_path: @project.try(:path) } }
%span.dropdown-toggle-text %span.dropdown-toggle-text
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"relative_position": { "type": "integer" }, "relative_position": { "type": "integer" },
"issue_sidebar_endpoint": { "type": "string" }, "issue_sidebar_endpoint": { "type": "string" },
"toggle_subscription_endpoint": { "type": "string" }, "toggle_subscription_endpoint": { "type": "string" },
"valid_labels_endpoint": { "type": "string" },
"reference_path": { "type": "string" }, "reference_path": { "type": "string" },
"real_path": { "type": "string" }, "real_path": { "type": "string" },
"project": { "project": {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment