Project

General

Profile

Feature #24227

Add hosts_count, can_edit/delete/create in Models API response

Added by boaz shust over 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
-
Difficulty:
medium
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:

Description

The motivation behind this is to get necessary data from API instead Rails helpers.

Background:
Currently when Hardware Model is rendered on the server side it uses the following helpers:
1) link_to_if_authorized
2) display_delete_if_authorized
3) hosts_count

(1) and (2) are used to provide actions to the user according to its permissions
and (3) is to allow to see hosts that are using a given model.

Any action done on the client side: changing the per_page selector, searching or sorting a column sends an HTTP request that returns some HTML rendered by Rails.

Moving this page to a React component changes the way the page is rendered. Instead of getting HTML from Rails, JSON is returned which is rendered back to HTML using React and Redux.

In order to render the HTML similarly to how it is done nowadays, hosts_count and the permissions are required to be shown in the API.
Thus, this ticket. The Models API should have "can_edit" and "can_delete" per model to determine whether the user is allowed to edit or to delete respectively. In addition, "hosts_count" for each model to display this information in the table.

The "can_create" attribute will be displayed only once and tells if the current user can create a new model or not.


Related issues

Related to Foreman - Feature #24040: Move the search box in Hardware Models to a React componentClosed
Related to Foreman - Feature #24041: Move the table in Hardware Models to a React componentClosed

Associated revisions

Revision 7114ed0d (diff)
Added by Boaz Shuster over 4 years ago

Fixes #24227 - Add permissions info to models API

During the process of moving Hardware Models to a React page
the current API was missing significant details that are rendered
in the Backend before the page is sent to the user.

For example, whether the user is allowed to edit a model or not

This information should be moved to the API because in the new
page, once the page is rendered by Rails any communication is
going to be done through the API and by that Rails won't
render the page or part of it again.

Signed-off-by: Boaz Shuster <>

History

#1 Updated by The Foreman Bot over 4 years ago

  • Pull request https://github.com/theforeman/foreman/pull/5814 added

#2 Updated by The Foreman Bot over 4 years ago

  • Status changed from New to Ready For Testing

#3 Updated by boaz shust over 4 years ago

  • Related to Feature #24040: Move the search box in Hardware Models to a React component added

#4 Updated by Ohad Levy over 4 years ago

  • Related to Feature #24041: Move the table in Hardware Models to a React component added

#5 Updated by Anonymous over 4 years ago

  • Fixed in Releases 1.20.0 added

#6 Updated by Anonymous over 4 years ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF