-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtable_component.rb
54 lines (47 loc) · 1.45 KB
/
table_component.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# frozen_string_literal: true
require 'ransack/helpers/form_helper'
module Bots
# Component for rendering the PersonalAccessTokens tables
class TableComponent < Component
include Ransack::Helpers::FormHelper
# rubocop: disable Metrics/ParameterLists
def initialize(
bot_accounts,
namespace,
pagy,
abilities: {},
empty: {},
**system_arguments
)
@bot_accounts = bot_accounts
@namespace = namespace
@pagy = pagy
@abilities = abilities
@empty = empty
@system_arguments = system_arguments
end
# rubocop: enable Metrics/ParameterLists
private
def bot_tokens_path(bot)
if @namespace.is_a?(Group)
group_bot_personal_access_tokens_path(bot_id: bot.id)
elsif @namespace.is_a?(Namespaces::ProjectNamespace)
namespace_project_bot_personal_access_tokens_path(bot_id: bot.id)
end
end
def new_token_path(bot)
if @namespace.is_a?(Group)
new_group_bot_personal_access_token_path(bot_id: bot.id)
elsif @namespace.is_a?(Namespaces::ProjectNamespace)
new_namespace_project_bot_personal_access_token_path(bot_id: bot.id)
end
end
def destroy_path(bot)
if @namespace.is_a?(Group)
group_bot_destroy_confirmation_path(bot_id: bot.id)
elsif @namespace.is_a?(Namespaces::ProjectNamespace)
namespace_project_bot_destroy_confirmation_path(bot_id: bot.id)
end
end
end
end