diff --git a/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.jsx b/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.jsx
index 11d6b5f79b..6163844b27 100644
--- a/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.jsx
+++ b/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.jsx
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
-import { CredentialsAPI, CredentialTypesAPI } from '@api';
+import { CredentialsAPI } from '@api';
import { Card, PageSection } from '@patternfly/react-core';
import AlertModal from '@components/AlertModal';
import ErrorDetail from '@components/ErrorDetail';
@@ -14,31 +14,17 @@ import PaginatedDataList, {
import { getQSConfig, parseQueryString } from '@util/qs';
import { CredentialListItem } from '.';
-const QS_CONFIG = getQSConfig('project', {
+const QS_CONFIG = getQSConfig('credential', {
page: 1,
page_size: 20,
order_by: 'name',
});
-const assignCredentialKinds = (credentials, credentialTypes) => {
- const typesById = credentialTypes.reduce((accumulator, type) => {
- accumulator[type.id] = type.name;
- return accumulator;
- }, {});
-
- credentials.forEach(credential => {
- credential.kind = typesById[credential.credential_type];
- });
-
- return credentials;
-};
-
function CredentialList({ i18n }) {
const [actions, setActions] = useState(null);
const [contentError, setContentError] = useState(null);
const [credentialCount, setCredentialCount] = useState(0);
const [credentials, setCredentials] = useState([]);
- const [credentialTypes, setCredentialTypes] = useState(null);
const [deletionError, setDeletionError] = useState(null);
const [hasContentLoading, setHasContentLoading] = useState(true);
const [selected, setSelected] = useState([]);
@@ -57,19 +43,14 @@ function CredentialList({ i18n }) {
{
data: { actions: optionActions },
},
- {
- data: { results: credentialTypeResults },
- },
] = await Promise.all([
CredentialsAPI.read(params),
loadCredentialActions(),
- loadCredentialTypes(),
]);
- setActions(optionActions);
+ setCredentials(results);
setCredentialCount(count);
- setCredentials(assignCredentialKinds(results, credentialTypeResults));
- setCredentialTypes(credentialTypeResults);
+ setActions(optionActions);
} catch (error) {
setContentError(error);
} finally {
@@ -81,13 +62,6 @@ function CredentialList({ i18n }) {
loadCredentials(location);
}, [location]); // eslint-disable-line react-hooks/exhaustive-deps
- const loadCredentialTypes = () => {
- if (credentialTypes) {
- return Promise.resolve({ data: { results: credentialTypes } });
- }
- return CredentialTypesAPI.read({ page_size: 200 });
- };
-
const loadCredentialActions = () => {
if (actions) {
return Promise.resolve({ data: { actions } });
@@ -124,7 +98,7 @@ function CredentialList({ i18n }) {
data: { count, results },
} = await CredentialsAPI.read(params);
- setCredentials(assignCredentialKinds(results, credentialTypes));
+ setCredentials(results);
setCredentialCount(count);
} catch (error) {
setContentError(error);
diff --git a/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx b/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx
index fee4eee4d4..fc45442a5d 100644
--- a/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx
+++ b/awx/ui_next/src/screens/Credential/CredentialList/CredentialList.test.jsx
@@ -1,9 +1,9 @@
import React from 'react';
import { act } from 'react-dom/test-utils';
-import { CredentialsAPI, CredentialTypesAPI } from '@api';
+import { CredentialsAPI } from '@api';
import { mountWithContexts, waitForElement } from '@testUtils/enzymeHelpers';
import { CredentialList } from '.';
-import { mockCredentials, mockCredentialTypes } from '../shared';
+import mockCredentials from '../shared';
jest.mock('@api');
@@ -12,9 +12,6 @@ describe('', () => {
beforeEach(async () => {
CredentialsAPI.read.mockResolvedValueOnce({ data: mockCredentials });
- CredentialTypesAPI.read.mockResolvedValueOnce({
- data: mockCredentialTypes,
- });
CredentialsAPI.readOptions.mockResolvedValue({
data: {
actions: {
@@ -101,9 +98,6 @@ describe('', () => {
test('should call api delete credentials for each selected credential', async () => {
CredentialsAPI.read.mockResolvedValueOnce({ data: mockCredentials });
- CredentialTypesAPI.read.mockResolvedValueOnce({
- data: mockCredentialTypes,
- });
CredentialsAPI.destroy = jest.fn();
await act(async () => {
diff --git a/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx b/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx
index 2eb56d1bb6..ccb58269b0 100644
--- a/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx
+++ b/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx
@@ -52,7 +52,9 @@ function CredentialListItem({
{credential.name}
,
- {credential.kind},
+
+ {credential.summary_fields.credential_type.name}
+ ,
{canEdit && (
diff --git a/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.test.jsx b/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.test.jsx
index 0f23bf465d..bb6e62dc6c 100644
--- a/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.test.jsx
+++ b/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.test.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import { mountWithContexts } from '@testUtils/enzymeHelpers';
import { CredentialListItem } from '.';
-import { mockCredentials } from '../shared';
+import mockCredentials from '../shared';
describe('', () => {
let wrapper;
diff --git a/awx/ui_next/src/screens/Credential/shared/data.credential_types.json b/awx/ui_next/src/screens/Credential/shared/data.credential_types.json
deleted file mode 100644
index d03480d51c..0000000000
--- a/awx/ui_next/src/screens/Credential/shared/data.credential_types.json
+++ /dev/null
@@ -1,176 +0,0 @@
-{
- "count": 3,
- "next": null,
- "previous": null,
- "results": [
- {
- "id": 1,
- "type": "credential_type",
- "url": "/api/v2/credential_types/1/",
- "related": {
- "credentials": "/api/v2/credential_types/1/credentials/",
- "activity_stream": "/api/v2/credential_types/1/activity_stream/"
- },
- "summary_fields": {
- "user_capabilities": {
- "edit": false,
- "delete": false
- }
- },
- "created": "2019-12-16T21:01:03.430100Z",
- "modified": "2019-12-16T21:01:24.834078Z",
- "name": "Machine",
- "description": "",
- "kind": "ssh",
- "namespace": "ssh",
- "managed_by_tower": true,
- "inputs": {
- "fields": [
- {
- "id": "username",
- "label": "Username",
- "type": "string"
- },
- {
- "id": "password",
- "label": "Password",
- "type": "string",
- "secret": true,
- "ask_at_runtime": true
- },
- {
- "id": "ssh_key_data",
- "label": "SSH Private Key",
- "type": "string",
- "format": "ssh_private_key",
- "secret": true,
- "multiline": true
- },
- {
- "id": "ssh_public_key_data",
- "label": "Signed SSH Certificate",
- "type": "string",
- "multiline": true,
- "secret": true
- },
- {
- "id": "ssh_key_unlock",
- "label": "Private Key Passphrase",
- "type": "string",
- "secret": true,
- "ask_at_runtime": true
- },
- {
- "id": "become_method",
- "label": "Privilege Escalation Method",
- "type": "string",
- "help_text": "Specify a method for \"become\" operations. This is equivalent to specifying the --become-method Ansible parameter."
- },
- {
- "id": "become_username",
- "label": "Privilege Escalation Username",
- "type": "string"
- },
- {
- "id": "become_password",
- "label": "Privilege Escalation Password",
- "type": "string",
- "secret": true,
- "ask_at_runtime": true
- }
- ]
- },
- "injectors": {}
- },
- {
- "id": 2,
- "type": "credential_type",
- "url": "/api/v2/credential_types/2/",
- "related": {
- "credentials": "/api/v2/credential_types/2/credentials/",
- "activity_stream": "/api/v2/credential_types/2/activity_stream/"
- },
- "summary_fields": {
- "user_capabilities": {
- "edit": false,
- "delete": false
- }
- },
- "created": "2019-12-16T21:01:03.443889Z",
- "modified": "2019-12-16T21:01:24.844433Z",
- "name": "Source Control",
- "description": "",
- "kind": "scm",
- "namespace": "scm",
- "managed_by_tower": true,
- "inputs": {
- "fields": [
- {
- "id": "username",
- "label": "Username",
- "type": "string"
- },
- {
- "id": "password",
- "label": "Password",
- "type": "string",
- "secret": true
- },
- {
- "id": "ssh_key_data",
- "label": "SCM Private Key",
- "type": "string",
- "format": "ssh_private_key",
- "secret": true,
- "multiline": true
- },
- {
- "id": "ssh_key_unlock",
- "label": "Private Key Passphrase",
- "type": "string",
- "secret": true
- }
- ]
- },
- "injectors": {}
- },
- {
- "id": 3,
- "type": "credential_type",
- "url": "/api/v2/credential_types/3/",
- "related": {
- "created_by": "/api/v2/users/1/",
- "modified_by": "/api/v2/users/1/",
- "credentials": "/api/v2/credential_types/3/credentials/",
- "activity_stream": "/api/v2/credential_types/3/activity_stream/"
- },
- "summary_fields": {
- "created_by": {
- "id": 1,
- "username": "admin",
- "first_name": "",
- "last_name": ""
- },
- "modified_by": {
- "id": 1,
- "username": "admin",
- "first_name": "",
- "last_name": ""
- },
- "user_capabilities": {
- "edit": true,
- "delete": true
- }
- },
- "created": "2019-12-17T16:11:57.723478Z",
- "modified": "2019-12-17T16:12:01.582942Z",
- "name": "Bar",
- "description": "",
- "kind": "cloud",
- "namespace": null,
- "managed_by_tower": false,
- "inputs": {},
- "injectors": {}
- }
- ]
-}
\ No newline at end of file
diff --git a/awx/ui_next/src/screens/Credential/shared/data.credentials.json b/awx/ui_next/src/screens/Credential/shared/data.credentials.json
index 7675805040..60d4b71d05 100644
--- a/awx/ui_next/src/screens/Credential/shared/data.credentials.json
+++ b/awx/ui_next/src/screens/Credential/shared/data.credentials.json
@@ -21,6 +21,11 @@
"user": "/api/v2/users/7/"
},
"summary_fields": {
+ "credential_type": {
+ "id": 1,
+ "name": "Machine",
+ "description": ""
+ },
"created_by": {
"id": 1,
"username": "admin",
@@ -84,6 +89,11 @@
"user": "/api/v2/users/7/"
},
"summary_fields": {
+ "credential_type": {
+ "id": 1,
+ "name": "Machine",
+ "description": ""
+ },
"created_by": {
"id": 8,
"username": "user-2",
@@ -158,6 +168,11 @@
"user": "/api/v2/users/8/"
},
"summary_fields": {
+ "credential_type": {
+ "id": 1,
+ "name": "Machine",
+ "description": ""
+ },
"created_by": {
"id": 9,
"username": "user-3",
@@ -232,6 +247,11 @@
"user": "/api/v2/users/1/"
},
"summary_fields": {
+ "credential_type": {
+ "id": 2,
+ "name": "Vault",
+ "description": ""
+ },
"created_by": {
"id": 1,
"username": "admin",
@@ -306,6 +326,11 @@
"user": "/api/v2/users/1/"
},
"summary_fields": {
+ "credential_type": {
+ "id": 3,
+ "name": "Source Control",
+ "description": ""
+ },
"created_by": {
"id": 1,
"username": "admin",
diff --git a/awx/ui_next/src/screens/Credential/shared/index.js b/awx/ui_next/src/screens/Credential/shared/index.js
index 3cf652f38c..723f2ff91e 100644
--- a/awx/ui_next/src/screens/Credential/shared/index.js
+++ b/awx/ui_next/src/screens/Credential/shared/index.js
@@ -1,2 +1 @@
-export { default as mockCredentials } from './data.credentials.json';
-export { default as mockCredentialTypes } from './data.credential_types.json';
+export { default } from './data.credentials.json';