diff --git a/awx/ui_next/src/components/ScheduleList/ScheduleList.jsx b/awx/ui_next/src/components/ScheduleList/ScheduleList.jsx
index 51930a3a39..e062fb0f75 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, apiModel, resource }) {
+function ScheduleList({ i18n, loadSchedules }) {
const [selected, setSelected] = useState([]);
const location = useLocation();
@@ -33,17 +33,12 @@ function ScheduleList({ i18n, apiModel, resource }) {
} = useRequest(
useCallback(async () => {
const params = parseQueryString(QS_CONFIG, location.search);
- const response = apiModel
- ? apiModel.readScheduleList(resource.id, params)
- : SchedulesAPI.read(params);
+ const response = loadSchedules(params);
const {
data: { count, results },
} = await response;
- return {
- itemCount: count,
- schedules: results,
- };
- }, [location, apiModel, resource]),
+ return { itemCount: count, schedules: results };
+ }, [location, loadSchedules]),
{
schedules: [],
itemCount: 0,
diff --git a/awx/ui_next/src/components/ScheduleList/ScheduleList.test.jsx b/awx/ui_next/src/components/ScheduleList/ScheduleList.test.jsx
index 1528f7888a..c257c47c45 100644
--- a/awx/ui_next/src/components/ScheduleList/ScheduleList.test.jsx
+++ b/awx/ui_next/src/components/ScheduleList/ScheduleList.test.jsx
@@ -22,8 +22,11 @@ describe('ScheduleList', () => {
describe('read call successful', () => {
beforeAll(async () => {
SchedulesAPI.read.mockResolvedValue({ data: mockSchedules });
+ const loadSchedules = params => SchedulesAPI.read(params);
await act(async () => {
- wrapper = mountWithContexts();
+ wrapper = mountWithContexts(
+
+ );
});
wrapper.update();
});
diff --git a/awx/ui_next/src/screens/Project/Project.jsx b/awx/ui_next/src/screens/Project/Project.jsx
index 50b8bfcb03..83c297c071 100644
--- a/awx/ui_next/src/screens/Project/Project.jsx
+++ b/awx/ui_next/src/screens/Project/Project.jsx
@@ -30,6 +30,7 @@ class Project extends Component {
};
this.loadProject = this.loadProject.bind(this);
this.loadProjectAndRoles = this.loadProjectAndRoles.bind(this);
+ this.loadSchedules = this.loadSchedules.bind(this);
}
async componentDidMount() {
@@ -103,6 +104,11 @@ class Project extends Component {
}
}
+ loadSchedules(params) {
+ const { project } = this.state;
+ return ProjectsAPI.readScheduleList(project.id, params);
+ }
+
render() {
const { location, match, me, i18n } = this.props;
@@ -235,7 +241,7 @@ class Project extends Component {
(
-
+
)}
/>
)}
diff --git a/awx/ui_next/src/screens/Schedule/Schedules.jsx b/awx/ui_next/src/screens/Schedule/Schedules.jsx
index 5e77596993..0127dab873 100644
--- a/awx/ui_next/src/screens/Schedule/Schedules.jsx
+++ b/awx/ui_next/src/screens/Schedule/Schedules.jsx
@@ -5,8 +5,13 @@ import { t } from '@lingui/macro';
import Breadcrumbs from '@components/Breadcrumbs';
import ScheduleList from '@components/ScheduleList';
+import { SchedulesAPI } from '@api';
function Schedules({ i18n }) {
+ const loadSchedules = params => {
+ return SchedulesAPI.read(params);
+ };
+
return (
<>
-
+
>
diff --git a/awx/ui_next/src/screens/Template/Template.jsx b/awx/ui_next/src/screens/Template/Template.jsx
index 6f4dc4ffd9..0818bea7cf 100644
--- a/awx/ui_next/src/screens/Template/Template.jsx
+++ b/awx/ui_next/src/screens/Template/Template.jsx
@@ -28,6 +28,7 @@ class Template extends Component {
};
this.loadTemplate = this.loadTemplate.bind(this);
this.loadTemplateAndRoles = this.loadTemplateAndRoles.bind(this);
+ this.loadSchedules = this.loadSchedules.bind(this);
}
async componentDidMount() {
@@ -82,6 +83,11 @@ class Template extends Component {
}
}
+ loadSchedules(params) {
+ const { template } = this.state;
+ return JobTemplatesAPI.readScheduleList(template.id, params);
+ }
+
render() {
const { i18n, location, match, me } = this.props;
const {
@@ -221,9 +227,7 @@ class Template extends Component {
{template && (
(
-
- )}
+ render={() => }
/>
)}
(
-
- )}
+ render={() => }
/>
)}