diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-11-08 23:52:17 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-11-08 23:52:17 +0800 |
commit | 3744d629e894afa3cb54c7edd2b61e0f17deb34f (patch) | |
tree | 50bcc4cc425b0cdfff9c220418caf2ccf2a59239 /app/helpers | |
parent | d03615736f29cb791db6e98ad658a532d6c8d271 (diff) | |
parent | 0108387053ac78bb2354511950fb5847a033e5d5 (diff) | |
download | gitlab-ce-3744d629e894afa3cb54c7edd2b61e0f17deb34f.tar.gz |
Merge remote-tracking branch 'upstream/master' into pipeline-notifications
* upstream/master: (70 commits)
Fix routing spec for group controller
Add small improvements to constrainers and specs
Faster search
Fix broken commits search
Changed helper method to check for none on params Moved if statements around in view
API: Return 400 when creating a systemhook fails
Update non-exist group spinach test to match routing
Bump omniauth-gitlab to 1.0.2 to fix incompatibility with omniauth-oauth2
Replace trigger with the new ID of the docs project
Refactor method name
17492 Update link color for more accessible contrast
Fixed todos empty state when filtering
Refactor namespace regex
implements reset incoming email token on issues modal and account page, reactivates all tests and writes more tests for it
Use separate email-friendly token for incoming email and let incoming email token be reset
Use the Gitlab Workhorse HTTP header in the admin dashboard
Refactor project routing
Fix 404 when visit /projects page
Rewritten spinach git_blame tests to rspec feature tests
Add tests for project#index routing
...
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/accounts_helper.rb | 5 | ||||
-rw-r--r-- | app/helpers/blob_helper.rb | 27 | ||||
-rw-r--r-- | app/helpers/components_helper.rb | 9 | ||||
-rw-r--r-- | app/helpers/issuables_helper.rb | 51 | ||||
-rw-r--r-- | app/helpers/todos_helper.rb | 4 |
5 files changed, 69 insertions, 27 deletions
diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb new file mode 100644 index 00000000000..5d27d30eaa3 --- /dev/null +++ b/app/helpers/accounts_helper.rb @@ -0,0 +1,5 @@ +module AccountsHelper + def incoming_email_token_enabled? + current_user.incoming_email_token && Gitlab::IncomingEmail.supports_issue_creation? + end +end diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index e13b7cdd707..07ff6fb9488 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -179,33 +179,6 @@ module BlobHelper } end - def selected_template(issuable) - templates = issuable_templates(issuable) - params[:issuable_template] if templates.include?(params[:issuable_template]) - end - - def can_add_template?(issuable) - names = issuable_templates(issuable) - names.empty? && can?(current_user, :push_code, @project) && !@project.private? - end - - def merge_request_template_names - @merge_request_templates ||= Gitlab::Template::MergeRequestTemplate.dropdown_names(ref_project) - end - - def issue_template_names - @issue_templates ||= Gitlab::Template::IssueTemplate.dropdown_names(ref_project) - end - - def issuable_templates(issuable) - @issuable_templates ||= - if issuable.is_a?(Issue) - issue_template_names - elsif issuable.is_a?(MergeRequest) - merge_request_template_names - end - end - def ref_project @ref_project ||= @target_project || @project end diff --git a/app/helpers/components_helper.rb b/app/helpers/components_helper.rb new file mode 100644 index 00000000000..8893209b314 --- /dev/null +++ b/app/helpers/components_helper.rb @@ -0,0 +1,9 @@ +module ComponentsHelper + def gitlab_workhorse_version + if request.headers['Gitlab-Workhorse'].present? + request.headers['Gitlab-Workhorse'].split('-').first + else + Gitlab::Workhorse.version + end + end +end diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index ef6cfb235a9..8127c3f3ee3 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -30,6 +30,33 @@ module IssuablesHelper end end + def can_add_template?(issuable) + names = issuable_templates(issuable) + names.empty? && can?(current_user, :push_code, @project) && !@project.private? + end + + def template_dropdown_tag(issuable, &block) + title = selected_template(issuable) || "Choose a template" + options = { + toggle_class: 'js-issuable-selector', + title: title, + filter: true, + placeholder: 'Filter', + footer_content: true, + data: { + data: issuable_templates(issuable), + field_name: 'issuable_template', + selected: selected_template(issuable), + project_path: ref_project.path, + namespace_path: ref_project.namespace.path + } + } + + dropdown_tag(title, options: options) do + capture(&block) + end + end + def user_dropdown_label(user_id, default_label) return default_label if user_id.nil? return "Unassigned" if user_id == "0" @@ -153,4 +180,28 @@ module IssuablesHelper hexdigest(['issuables_count', issuable_type, opts.sort].flatten.join('-')) end + + def issuable_templates(issuable) + @issuable_templates ||= + case issuable + when Issue + issue_template_names + when MergeRequest + merge_request_template_names + else + raise 'Unknown issuable type!' + end + end + + def merge_request_template_names + @merge_request_templates ||= Gitlab::Template::MergeRequestTemplate.dropdown_names(ref_project) + end + + def issue_template_names + @issue_templates ||= Gitlab::Template::IssueTemplate.dropdown_names(ref_project) + end + + def selected_template(issuable) + params[:issuable_template] if issuable_templates(issuable).include?(params[:issuable_template]) + end end diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index a9db8bb2b82..09c69786791 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -61,6 +61,10 @@ module TodosHelper } end + def todos_filter_empty? + todos_filter_params.values.none? + end + def todos_filter_path(options = {}) without = options.delete(:without) |