Add instance groups roles (#13584)

* adding roles to instance groups
added ResourceMixin to Instancegroup and changed the filtered_queryset

* added necessary changes to rebuild relationship between IG and roles

* added description to InstanceGroupAccess

* preliminary ui plug for demo purposes

* preliminary ui plug for demo purposes
added inventory special logic for use_role to allow attaching instance groups
added more tests to handle those cases

* Add access_list to InstanceGroup

* scratch branch to test migration work

* refactored to shorten logic

* Added migration and am removing logic that enabled Org admin permissions

* Add Obj admin role to JT, Inv, Org

* Changed tests to reflect new permissions

* refactored some of the tests

* cleaned up more tests and reworded help on InstanceGroupAccess

* Removed unnecessary delete of Route for instance group perms change

* Fix UI tests and migration

* fixed permissions on prompt for InstanceGroups

* added related object roles endpoint

* added ui/api function for options instance_groups

* separate the migrations in order to avoid issues with migrations not being finished

* changed migrations parent class to disable the activity stream error in migrations

* Added logging to migration as activitystream is disabled

* added clarifying comment to jobtemlateaccess and linted UI addition

* renamed migrations to avoid collisions

* Rename migrations to avoid collisions
This commit is contained in:
Gabriel Muniz
2023-03-14 21:37:22 -04:00
committed by GitHub
parent 7a45048463
commit a63067da38
18 changed files with 275 additions and 32 deletions

View File

@@ -8,6 +8,7 @@ class InstanceGroups extends Base {
this.associateInstance = this.associateInstance.bind(this);
this.disassociateInstance = this.disassociateInstance.bind(this);
this.readInstanceOptions = this.readInstanceOptions.bind(this);
this.readInstanceGroupOptions = this.readInstanceGroupOptions.bind(this);
this.readInstances = this.readInstances.bind(this);
this.readJobs = this.readJobs.bind(this);
}
@@ -33,6 +34,10 @@ class InstanceGroups extends Base {
return this.http.options(`${this.baseUrl}${id}/instances/`);
}
readInstanceGroupOptions(id) {
return this.http.options(`${this.baseUrl}${id}/`);
}
readJobs(id) {
return this.http.get(`${this.baseUrl}${id}/jobs/`);
}

View File

@@ -6,6 +6,7 @@ import {
InventoriesAPI,
ProjectsAPI,
OrganizationsAPI,
InstanceGroupsAPI,
} from 'api';
export default function getResourceAccessConfig() {
@@ -210,5 +211,32 @@ export default function getResourceAccessConfig() {
fetchItems: (queryParams) => OrganizationsAPI.read(queryParams),
fetchOptions: () => OrganizationsAPI.readOptions(),
},
{
selectedResource: 'Instance Groups',
label: t`Instance Groups`,
searchColumns: [
{
name: t`Name`,
key: 'name__icontains',
isDefault: true,
},
{
name: t`Created By (Username)`,
key: 'created_by__username__icontains',
},
{
name: t`Modified By (Username)`,
key: 'modified_by__username__icontains',
},
],
sortColumns: [
{
name: t`Name`,
key: 'name',
},
],
fetchItems: (queryParams) => InstanceGroupsAPI.read(queryParams),
fetchOptions: () => InstanceGroupsAPI.readOptions(),
},
];
}

View File

@@ -184,7 +184,6 @@ function getRouteConfig(userProfile = {}) {
deleteRouteGroup('settings');
deleteRoute('management_jobs');
if (userProfile?.isOrgAdmin) return routeConfig;
deleteRoute('instance_groups');
deleteRoute('topology_view');
deleteRoute('instances');
if (!userProfile?.isNotificationAdmin) deleteRoute('notification_templates');

View File

@@ -127,6 +127,7 @@ describe('getRouteConfig', () => {
'/teams',
'/credential_types',
'/notification_templates',
'/instance_groups',
'/applications',
'/execution_environments',
]);
@@ -150,6 +151,7 @@ describe('getRouteConfig', () => {
'/users',
'/teams',
'/credential_types',
'/instance_groups',
'/applications',
'/execution_environments',
]);
@@ -173,6 +175,7 @@ describe('getRouteConfig', () => {
'/users',
'/teams',
'/credential_types',
'/instance_groups',
'/applications',
'/execution_environments',
]);
@@ -201,6 +204,7 @@ describe('getRouteConfig', () => {
'/teams',
'/credential_types',
'/notification_templates',
'/instance_groups',
'/applications',
'/execution_environments',
]);

View File

@@ -21,9 +21,11 @@ function ContainerGroupEdit({ instanceGroup }) {
result: initialPodSpec,
} = useRequest(
useCallback(async () => {
const { data } = await InstanceGroupsAPI.readOptions();
return data.actions.POST.pod_spec_override.default;
}, []),
const { data } = await InstanceGroupsAPI.readInstanceGroupOptions(
instanceGroup.id
);
return data.actions.PUT.pod_spec_override.default;
}, [instanceGroup.id]),
{
initialPodSpec: {},
}