-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #25309 - Switcher for ansible roles (#217)
- Loading branch information
Showing
52 changed files
with
1,971 additions
and
68 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- '8' # current LTS | ||
- '10' # future LTS | ||
script: ./script/travis_run_js_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class UiAnsibleRolesController < ::Api::V2::BaseController | ||
def resource_name(resource = 'AnsibleRole') | ||
super resource | ||
end | ||
|
||
def index | ||
@ui_ansible_roles = resource_scope_for_index(:permission => :view_ansible_roles) | ||
end | ||
|
||
# restore original method from find_common to ignore resource nesting | ||
def resource_scope(options = {}) | ||
@resource_scope ||= scope_for(resource_class, options) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 13 additions & 13 deletions
26
app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
<%= webpacked_plugins_js_for :foreman_ansible %> | ||
<%= webpacked_plugins_css_for :foreman_ansible %> | ||
|
||
<div class='tab-pane' id='ansible_roles'> | ||
<%= multiple_selects( | ||
f, | ||
:ansible_roles, | ||
AnsibleRole, | ||
f.object.is_a?(Hostgroup) ? (f.object.inherited_and_own_ansible_roles).map(&:id) : f.object.all_ansible_roles.map(&:id), | ||
{ | ||
:disabled => f.object.inherited_ansible_roles.map(&:id), | ||
:label => _('Available roles'), | ||
:label_help => _('This list of roles will be applied when the host finishes<br/> '\ | ||
'provisioning. Users can also play these roles through the API<br/>'\ | ||
'or by clicking on the Play Roles button on the Host page ').html_safe | ||
}, | ||
{ 'data-inheriteds' => f.object.inherited_ansible_roles.map(&:id).to_json }) %> | ||
<div id='ansible_roles_switcher'></div> | ||
<% roles = f.object.is_a?(Hostgroup) ? roles_attrs(f.object.inherited_and_own_ansible_roles) : roles_attrs(f.object.all_ansible_roles) %> | ||
<% class_name = f.object.is_a?(Hostgroup) ? 'Hostgroup' : 'Host' %> | ||
<%= mount_react_component('AnsibleRolesSwitcher', '#ansible_roles_switcher', { :initialAssignedRoles => roles, | ||
:inheritedRoleIds => f.object.inherited_ansible_roles.map(&:id), | ||
:availableRolesUrl => ui_ansible_roles_path, | ||
:resourceId => f.object.id, | ||
:resourceName => class_name, | ||
:canView => User.current.can?(:view_ansible_roles) | ||
}.to_json) %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
collection @ui_ansible_roles | ||
|
||
extends "ui_ansible_roles/main" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
object @ansible_role | ||
|
||
extends "ui_ansible_roles/show" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
object @ansible_role | ||
|
||
extends "api/v2/ansible_roles/show" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
set -ev | ||
npm run lint; | ||
npm run test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'test_plugin_helper' | ||
|
||
class UiAnsibleRolesControllerTest < ActionController::TestCase | ||
setup do | ||
@role = FactoryBot.create(:ansible_role) | ||
end | ||
|
||
test 'should respond with roles' do | ||
get :index, :params => {}, :session => set_session_user | ||
assert_response :success | ||
res = JSON.parse @response.body | ||
assert_equal res['total'], res['results'].size | ||
end | ||
end |
2 changes: 2 additions & 0 deletions
2
webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const PaginationWrapper = () => jest.fn(); | ||
export default PaginationWrapper; |
5 changes: 5 additions & 0 deletions
5
webpack/__mocks__/foremanReact/components/common/EmptyState.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const EmptyState = () => jest.fn(); | ||
|
||
export const EmptyStatePattern = () => jest.fn(); | ||
|
||
export default EmptyState; |
Oops, something went wrong.