diff options
author | Rémy Coutable <remy@rymai.me> | 2017-01-10 17:41:04 -0500 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-01-18 16:38:35 +0100 |
commit | 061bb6eb6ed0ca6be3c571b3fcfd14a6f9729205 (patch) | |
tree | 2b87e3ea5d1e67b19c515891d19b466c80040a04 /app/presenters | |
parent | e950830ba6a0efa3b0992e6e55cb5b5842f8573a (diff) | |
download | gitlab-ce-061bb6eb6ed0ca6be3c571b3fcfd14a6f9729205.tar.gz |
More improvements to presenters23563-document-presenters
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/README.md | 8 | ||||
-rw-r--r-- | app/presenters/ci/build/presenter.rb | 17 | ||||
-rw-r--r-- | app/presenters/ci/build_presenter.rb | 15 | ||||
-rw-r--r-- | app/presenters/ci/variable/presenter.rb | 7 |
4 files changed, 19 insertions, 28 deletions
diff --git a/app/presenters/README.md b/app/presenters/README.md index 91c1d2609f5..3edd63451e7 100644 --- a/app/presenters/README.md +++ b/app/presenters/README.md @@ -66,7 +66,7 @@ we gain the following benefits: ### Presenter definition -Every presenters should inherit from `Gitlab::View::Presenter::Simple`, which +Every presenter should inherit from `Gitlab::View::Presenter::Simple`, which provides a `.presents` method which allows you to define an accessor for the presented object. It also includes common helpers like `Gitlab::Routing` and `Gitlab::Allowable`. @@ -76,7 +76,7 @@ class LabelPresenter < Gitlab::View::Presenter::Simple presents :label def text_color - LabelsHelper.text_color_for_bg(label.color) + label.color.to_s end def to_partial_path @@ -95,7 +95,7 @@ class LabelPresenter < Gitlab::View::Presenter::Delegated def text_color # color is delegated to label - LabelsHelper.text_color_for_bg(color) + color.to_s end def to_partial_path @@ -132,7 +132,7 @@ and then in the controller: ```ruby class Projects::LabelsController < Projects::ApplicationController def edit - @label = @label.present(current_user) + @label = @label.present(user: current_user) end end ``` diff --git a/app/presenters/ci/build/presenter.rb b/app/presenters/ci/build/presenter.rb deleted file mode 100644 index 60392200fde..00000000000 --- a/app/presenters/ci/build/presenter.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Ci - class Build - class Presenter < Gitlab::View::Presenter::Delegated - presents :build - - def erased_by_user? - # Build can be erased through API, therefore it does not have - # `erase_by` user assigned in that case. - erased? && erased_by - end - - def erased_by_name - erased_by.name if erased_by - end - end - end -end diff --git a/app/presenters/ci/build_presenter.rb b/app/presenters/ci/build_presenter.rb new file mode 100644 index 00000000000..ed72ed14d72 --- /dev/null +++ b/app/presenters/ci/build_presenter.rb @@ -0,0 +1,15 @@ +module Ci + class BuildPresenter < Gitlab::View::Presenter::Delegated + presents :build + + def erased_by_user? + # Build can be erased through API, therefore it does not have + # `erased_by` user assigned in that case. + erased? && erased_by + end + + def erased_by_name + erased_by.name if erased_by_user? + end + end +end diff --git a/app/presenters/ci/variable/presenter.rb b/app/presenters/ci/variable/presenter.rb deleted file mode 100644 index 02045e19cac..00000000000 --- a/app/presenters/ci/variable/presenter.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Ci - class Variable - class Presenter < Gitlab::View::Presenter::Simple - presents :variable - end - end -end |