mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 02:46:11 +02:00
Refactor logic in view using decorator.
This commit is contained in:
parent
3ae454566c
commit
4e959c1fd2
@ -8,7 +8,7 @@ class PluginsController < ApplicationController
|
||||
end
|
||||
|
||||
def recommended
|
||||
@plugins = Plugin.recommended
|
||||
@plugins = PluginDecorator.decorate_collection(Plugin.recommended)
|
||||
end
|
||||
|
||||
def updated
|
||||
|
||||
13
app/decorators/plugin_decorator.rb
Normal file
13
app/decorators/plugin_decorator.rb
Normal file
@ -0,0 +1,13 @@
|
||||
class PluginDecorator < Draper::Decorator
|
||||
delegate_all
|
||||
|
||||
def status
|
||||
if installed?
|
||||
I18n.t("terms.installed")
|
||||
elsif processing?
|
||||
I18n.t("terms.processing")
|
||||
else
|
||||
I18n.t("terms.not_installed")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -8,6 +8,7 @@ class Plugin
|
||||
WORKING = []
|
||||
|
||||
include ActiveModel::Model
|
||||
include Draper::Decoratable
|
||||
|
||||
attr_accessor :gem_name, :version, :category
|
||||
validates :gem_name, presence: true
|
||||
|
||||
@ -20,12 +20,7 @@
|
||||
%td
|
||||
= plugin.category
|
||||
%td
|
||||
- if plugin.installed?
|
||||
= t("terms.installed")
|
||||
- elsif plugin.processing?
|
||||
= t("terms.processing")
|
||||
- else
|
||||
= t("terms.not_installed")
|
||||
= plugin.status
|
||||
%td
|
||||
= link_to t('plugins.view_on_rubygems_org'), plugin.rubygems_org_page, target: "_blank"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user