diff --git a/awx/ui_next/src/api/models/JobTemplates.js b/awx/ui_next/src/api/models/JobTemplates.js index 58060371df..ef615a65f6 100644 --- a/awx/ui_next/src/api/models/JobTemplates.js +++ b/awx/ui_next/src/api/models/JobTemplates.js @@ -61,6 +61,10 @@ class JobTemplates extends InstanceGroupsMixin(NotificationsMixin(Base)) { params, }); } + + readScheduleList(id, params) { + return this.http.get(`${this.baseUrl}${id}/schedules/`, { params }); + } } export default JobTemplates; diff --git a/awx/ui_next/src/api/models/Projects.js b/awx/ui_next/src/api/models/Projects.js index 742150e5aa..3a4049f9f8 100644 --- a/awx/ui_next/src/api/models/Projects.js +++ b/awx/ui_next/src/api/models/Projects.js @@ -21,6 +21,10 @@ class Projects extends LaunchUpdateMixin(NotificationsMixin(Base)) { return this.http.get(`${this.baseUrl}${id}/playbooks/`); } + readScheduleList(id, params) { + return this.http.get(`${this.baseUrl}${id}/schedules/`, { params }); + } + readSync(id) { return this.http.get(`${this.baseUrl}${id}/update/`); } diff --git a/awx/ui_next/src/api/models/WorkflowJobTemplates.js b/awx/ui_next/src/api/models/WorkflowJobTemplates.js index 45b6f6539f..691c444379 100644 --- a/awx/ui_next/src/api/models/WorkflowJobTemplates.js +++ b/awx/ui_next/src/api/models/WorkflowJobTemplates.js @@ -27,6 +27,10 @@ class WorkflowJobTemplates extends Base { createNode(id, data) { return this.http.post(`${this.baseUrl}${id}/workflow_nodes/`, data); } + + readScheduleList(id, params) { + return this.http.get(`${this.baseUrl}${id}/schedules/`, { params }); + } } export default WorkflowJobTemplates; diff --git a/awx/ui_next/src/components/ScheduleList/ScheduleList.jsx b/awx/ui_next/src/components/ScheduleList/ScheduleList.jsx index 8f8fef3c63..51930a3a39 100644 --- a/awx/ui_next/src/components/ScheduleList/ScheduleList.jsx +++ b/awx/ui_next/src/components/ScheduleList/ScheduleList.jsx @@ -20,7 +20,7 @@ const QS_CONFIG = getQSConfig('schedule', { order_by: 'unified_job_template__polymorphic_ctype__model', }); -function ScheduleList({ i18n }) { +function ScheduleList({ i18n, apiModel, resource }) { const [selected, setSelected] = useState([]); const location = useLocation(); @@ -33,14 +33,17 @@ function ScheduleList({ i18n }) { } = useRequest( useCallback(async () => { const params = parseQueryString(QS_CONFIG, location.search); + const response = apiModel + ? apiModel.readScheduleList(resource.id, params) + : SchedulesAPI.read(params); const { data: { count, results }, - } = await SchedulesAPI.read(params); + } = await response; return { itemCount: count, schedules: results, }; - }, [location]), + }, [location, apiModel, resource]), { schedules: [], itemCount: 0, diff --git a/awx/ui_next/src/screens/Project/Project.jsx b/awx/ui_next/src/screens/Project/Project.jsx index 65b4560459..e882a8a594 100644 --- a/awx/ui_next/src/screens/Project/Project.jsx +++ b/awx/ui_next/src/screens/Project/Project.jsx @@ -9,10 +9,10 @@ import RoutedTabs from '@components/RoutedTabs'; import ContentError from '@components/ContentError'; import NotificationList from '@components/NotificationList'; import { ResourceAccessList } from '@components/ResourceAccessList'; +import ScheduleList from '@components/ScheduleList'; import ProjectDetail from './ProjectDetail'; import ProjectEdit from './ProjectEdit'; import ProjectJobTemplatesList from './ProjectJobTemplatesList'; -import ProjectSchedules from './ProjectSchedules'; import { OrganizationsAPI, ProjectsAPI } from '@api'; class Project extends Component { @@ -134,16 +134,17 @@ class Project extends Component { }); } - tabsArray.push( - { - name: i18n._(t`Job Templates`), - link: `${match.url}/job_templates`, - }, - { + tabsArray.push({ + name: i18n._(t`Job Templates`), + link: `${match.url}/job_templates`, + }); + + if (project?.scm_type && project.scm_type !== '') { + tabsArray.push({ name: i18n._(t`Schedules`), link: `${match.url}/schedules`, - } - ); + }); + } tabsArray.forEach((tab, n) => { tab.id = n; @@ -183,6 +184,8 @@ class Project extends Component { ); } + console.log(project); + return ( @@ -230,10 +233,14 @@ class Project extends Component { )} /> - } - /> + {project?.scm_type && project.scm_type !== '' && ( + ( + + )} + /> + )} { tab.id = n; }); @@ -210,6 +218,14 @@ class Template extends Component { )} + {template && ( + ( + + )} + /> + )} ', () => { const tabs = await waitForElement( wrapper, '.pf-c-tabs__item', - el => el.length === 6 + el => el.length === 7 ); expect(tabs.at(2).text()).toEqual('Notifications'); done(); diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx index 977ac4f6f7..c93bcb9481 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx @@ -10,6 +10,7 @@ import ContentError from '@components/ContentError'; import FullPage from '@components/FullPage'; import JobList from '@components/JobList'; import RoutedTabs from '@components/RoutedTabs'; +import ScheduleList from '@components/ScheduleList'; import { WorkflowJobTemplatesAPI, CredentialsAPI } from '@api'; import WorkflowJobTemplateDetail from './WorkflowJobTemplateDetail'; import { Visualizer } from './WorkflowJobTemplateVisualizer'; @@ -85,6 +86,13 @@ class WorkflowJobTemplate extends Component { { name: i18n._(t`Completed Jobs`), link: `${match.url}/completed_jobs` }, ]; + if (template) { + tabsArray.push({ + name: i18n._(t`Schedules`), + link: `${match.url}/schedules`, + }); + } + tabsArray.forEach((tab, n) => { tab.id = n; }); @@ -162,6 +170,17 @@ class WorkflowJobTemplate extends Component { /> )} + {template && ( + ( + + )} + /> + )}