+ |
+
+
+ {project.name}
+
+ |
+
+ {project.summary_fields.last_job && (
+
+
+
+
+
+ )}
+ |
+
+ {project.scm_type === ''
+ ? i18n._(t`Manual`)
+ : toTitleCase(project.scm_type)}
+ |
+
+ {project.scm_revision.substring(0, 7)}
+ {!project.scm_revision && (
+
+ )}
+
-
- {project.summary_fields.last_job && (
-
-
-
-
-
- )}
- ,
-
-
- {project.name}
-
- ,
-
- {project.scm_type === ''
- ? i18n._(t`Manual`)
- : toTitleCase(project.scm_type)}
- ,
-
- {project.scm_revision.substring(0, 7)}
- {!project.scm_revision && (
-
- )}
-
- ,
- ]}
- />
-
+
+
- {project.summary_fields.user_capabilities.start && (
-
-
-
- )}
- {project.summary_fields.user_capabilities.edit ? (
-
-
-
- ) : (
- ''
- )}
- {project.summary_fields.user_capabilities.copy && (
-
- )}
-
-
-
+
+
+
+
+
+
+
+
+
+
);
}
export default withI18n()(ProjectListItem);
diff --git a/awx/ui_next/src/screens/Project/ProjectList/ProjectListItem.test.jsx b/awx/ui_next/src/screens/Project/ProjectList/ProjectListItem.test.jsx
index 7866015703..21f96efc4d 100644
--- a/awx/ui_next/src/screens/Project/ProjectList/ProjectListItem.test.jsx
+++ b/awx/ui_next/src/screens/Project/ProjectList/ProjectListItem.test.jsx
@@ -10,112 +10,128 @@ jest.mock('../../../api/models/Projects');
describe('', () => {
test('launch button shown to users with start capabilities', () => {
const wrapper = mountWithContexts(
- {}}
- project={{
- id: 1,
- name: 'Project 1',
- url: '/api/v2/projects/1',
- type: 'project',
- scm_type: 'git',
- scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
- summary_fields: {
- last_job: {
- id: 9000,
- status: 'successful',
- },
- user_capabilities: {
- start: true,
- },
- },
- }}
- />
+
+
+ {}}
+ project={{
+ id: 1,
+ name: 'Project 1',
+ url: '/api/v2/projects/1',
+ type: 'project',
+ scm_type: 'git',
+ scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
+ summary_fields: {
+ last_job: {
+ id: 9000,
+ status: 'successful',
+ },
+ user_capabilities: {
+ start: true,
+ },
+ },
+ }}
+ />
+
+
);
expect(wrapper.find('ProjectSyncButton').exists()).toBeTruthy();
});
test('launch button hidden from users without start capabilities', () => {
const wrapper = mountWithContexts(
- {}}
- project={{
- id: 1,
- name: 'Project 1',
- url: '/api/v2/projects/1',
- type: 'project',
- scm_type: 'git',
- scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
- summary_fields: {
- last_job: {
- id: 9000,
- status: 'successful',
- },
- user_capabilities: {
- start: false,
- },
- },
- }}
- />
+
+
+ {}}
+ project={{
+ id: 1,
+ name: 'Project 1',
+ url: '/api/v2/projects/1',
+ type: 'project',
+ scm_type: 'git',
+ scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
+ summary_fields: {
+ last_job: {
+ id: 9000,
+ status: 'successful',
+ },
+ user_capabilities: {
+ start: false,
+ },
+ },
+ }}
+ />
+
+
);
expect(wrapper.find('ProjectSyncButton').exists()).toBeFalsy();
});
test('edit button shown to users with edit capabilities', () => {
const wrapper = mountWithContexts(
- {}}
- project={{
- id: 1,
- name: 'Project 1',
- url: '/api/v2/projects/1',
- type: 'project',
- scm_type: 'git',
- scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
- summary_fields: {
- last_job: {
- id: 9000,
- status: 'successful',
- },
- user_capabilities: {
- edit: true,
- },
- },
- }}
- />
+
+
+ {}}
+ project={{
+ id: 1,
+ name: 'Project 1',
+ url: '/api/v2/projects/1',
+ type: 'project',
+ scm_type: 'git',
+ scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
+ summary_fields: {
+ last_job: {
+ id: 9000,
+ status: 'successful',
+ },
+ user_capabilities: {
+ edit: true,
+ },
+ },
+ }}
+ />
+
+
);
expect(wrapper.find('PencilAltIcon').exists()).toBeTruthy();
});
test('edit button hidden from users without edit capabilities', () => {
const wrapper = mountWithContexts(
- {}}
- project={{
- id: 1,
- name: 'Project 1',
- url: '/api/v2/projects/1',
- type: 'project',
- scm_type: 'git',
- scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
- summary_fields: {
- last_job: {
- id: 9000,
- status: 'successful',
- },
- user_capabilities: {
- edit: false,
- },
- },
- }}
- />
+
+
+ {}}
+ project={{
+ id: 1,
+ name: 'Project 1',
+ url: '/api/v2/projects/1',
+ type: 'project',
+ scm_type: 'git',
+ scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
+ summary_fields: {
+ last_job: {
+ id: 9000,
+ status: 'successful',
+ },
+ user_capabilities: {
+ edit: false,
+ },
+ },
+ }}
+ />
+
+
);
expect(wrapper.find('PencilAltIcon').exists()).toBeFalsy();
});
@@ -123,29 +139,33 @@ describe('', () => {
test('should call api to copy project', async () => {
ProjectsAPI.copy.mockResolvedValue();
const wrapper = mountWithContexts(
- {}}
- project={{
- id: 1,
- name: 'Project 1',
- url: '/api/v2/projects/1',
- type: 'project',
- scm_type: 'git',
- scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
- summary_fields: {
- last_job: {
- id: 9000,
- status: 'successful',
- },
- user_capabilities: {
- edit: false,
- copy: true,
- },
- },
- }}
- />
+
+
+ {}}
+ project={{
+ id: 1,
+ name: 'Project 1',
+ url: '/api/v2/projects/1',
+ type: 'project',
+ scm_type: 'git',
+ scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
+ summary_fields: {
+ last_job: {
+ id: 9000,
+ status: 'successful',
+ },
+ user_capabilities: {
+ edit: false,
+ copy: true,
+ },
+ },
+ }}
+ />
+
+
);
await act(async () =>
@@ -159,29 +179,33 @@ describe('', () => {
ProjectsAPI.copy.mockRejectedValue(new Error());
const wrapper = mountWithContexts(
- {}}
- project={{
- id: 1,
- name: 'Project 1',
- url: '/api/v2/projects/1',
- type: 'project',
- scm_type: 'git',
- scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
- summary_fields: {
- last_job: {
- id: 9000,
- status: 'successful',
- },
- user_capabilities: {
- edit: false,
- copy: true,
- },
- },
- }}
- />
+
+
+ {}}
+ project={{
+ id: 1,
+ name: 'Project 1',
+ url: '/api/v2/projects/1',
+ type: 'project',
+ scm_type: 'git',
+ scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
+ summary_fields: {
+ last_job: {
+ id: 9000,
+ status: 'successful',
+ },
+ user_capabilities: {
+ edit: false,
+ copy: true,
+ },
+ },
+ }}
+ />
+
+
);
await act(async () =>
wrapper.find('Button[aria-label="Copy"]').prop('onClick')()
@@ -192,56 +216,64 @@ describe('', () => {
});
test('should not render copy button', async () => {
const wrapper = mountWithContexts(
- {}}
- project={{
- id: 1,
- name: 'Project 1',
- url: '/api/v2/projects/1',
- type: 'project',
- scm_type: 'git',
- scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
- summary_fields: {
- last_job: {
- id: 9000,
- status: 'successful',
- },
- user_capabilities: {
- edit: false,
- copy: false,
- },
- },
- }}
- />
+
+
+ {}}
+ project={{
+ id: 1,
+ name: 'Project 1',
+ url: '/api/v2/projects/1',
+ type: 'project',
+ scm_type: 'git',
+ scm_revision: '7788f7erga0jijodfgsjisiodf98sdga9hg9a98gaf',
+ summary_fields: {
+ last_job: {
+ id: 9000,
+ status: 'successful',
+ },
+ user_capabilities: {
+ edit: false,
+ copy: false,
+ },
+ },
+ }}
+ />
+
+
);
expect(wrapper.find('CopyButton').length).toBe(0);
});
test('should render disabled copy to clipboard button', () => {
const wrapper = mountWithContexts(
- {}}
- project={{
- id: 1,
- name: 'Project 1',
- url: '/api/v2/projects/1',
- type: 'project',
- scm_type: 'git',
- scm_revision: '',
- summary_fields: {
- last_job: {
- id: 9000,
- status: 'successful',
- },
- user_capabilities: {
- edit: true,
- },
- },
- }}
- />
+
+
+ {}}
+ project={{
+ id: 1,
+ name: 'Project 1',
+ url: '/api/v2/projects/1',
+ type: 'project',
+ scm_type: 'git',
+ scm_revision: '',
+ summary_fields: {
+ last_job: {
+ id: 9000,
+ status: 'successful',
+ },
+ user_capabilities: {
+ edit: true,
+ },
+ },
+ }}
+ />
+
+
);
expect(
wrapper.find('span[aria-label="copy to clipboard disabled"]').text()
|