Module: RenderAccessTokens
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/controllers/concerns/render_access_tokens.rb
Overview
Remove this file once we migrate the legacy UI to use initSharedAccessTokenApp.
Instance Method Summary collapse
- #active_access_tokens ⇒ Object
- #add_pagination_headers(relation) ⇒ Object
- #inactive_access_tokens ⇒ Object
- #page ⇒ Object
Instance Method Details
#active_access_tokens ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/concerns/render_access_tokens.rb', line 7 def active_access_tokens tokens = finder(state: 'active', sort: 'expires_asc').execute.preload_users size = tokens.size tokens = tokens.page(page) add_pagination_headers(tokens) [represent(tokens), size] end |
#add_pagination_headers(relation) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/concerns/render_access_tokens.rb', line 21 def add_pagination_headers(relation) Gitlab::Pagination::OffsetHeaderBuilder.new( request_context: self, per_page: relation.limit_value, page: relation.current_page, next_page: relation.next_page, prev_page: relation.prev_page, total: relation.total_count, params: params.permit(:page, :per_page) ).execute end |
#inactive_access_tokens ⇒ Object
17 18 19 |
# File 'app/controllers/concerns/render_access_tokens.rb', line 17 def inactive_access_tokens finder(state: 'inactive', sort: 'updated_at_desc').execute.preload_users end |
#page ⇒ Object
33 34 35 |
# File 'app/controllers/concerns/render_access_tokens.rb', line 33 def page (pagination_params[:page] || 1).to_i end |