mirror of
https://github.com/ansible/awx.git
synced 2026-02-23 14:05:59 -03:30
add schedule list to proj, jt and wfjt
This commit is contained in:
@@ -61,6 +61,10 @@ class JobTemplates extends InstanceGroupsMixin(NotificationsMixin(Base)) {
|
|||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readScheduleList(id, params) {
|
||||||
|
return this.http.get(`${this.baseUrl}${id}/schedules/`, { params });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default JobTemplates;
|
export default JobTemplates;
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ class Projects extends LaunchUpdateMixin(NotificationsMixin(Base)) {
|
|||||||
return this.http.get(`${this.baseUrl}${id}/playbooks/`);
|
return this.http.get(`${this.baseUrl}${id}/playbooks/`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readScheduleList(id, params) {
|
||||||
|
return this.http.get(`${this.baseUrl}${id}/schedules/`, { params });
|
||||||
|
}
|
||||||
|
|
||||||
readSync(id) {
|
readSync(id) {
|
||||||
return this.http.get(`${this.baseUrl}${id}/update/`);
|
return this.http.get(`${this.baseUrl}${id}/update/`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ class WorkflowJobTemplates extends Base {
|
|||||||
createNode(id, data) {
|
createNode(id, data) {
|
||||||
return this.http.post(`${this.baseUrl}${id}/workflow_nodes/`, 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;
|
export default WorkflowJobTemplates;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const QS_CONFIG = getQSConfig('schedule', {
|
|||||||
order_by: 'unified_job_template__polymorphic_ctype__model',
|
order_by: 'unified_job_template__polymorphic_ctype__model',
|
||||||
});
|
});
|
||||||
|
|
||||||
function ScheduleList({ i18n }) {
|
function ScheduleList({ i18n, apiModel, resource }) {
|
||||||
const [selected, setSelected] = useState([]);
|
const [selected, setSelected] = useState([]);
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -33,14 +33,17 @@ function ScheduleList({ i18n }) {
|
|||||||
} = useRequest(
|
} = useRequest(
|
||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
const params = parseQueryString(QS_CONFIG, location.search);
|
const params = parseQueryString(QS_CONFIG, location.search);
|
||||||
|
const response = apiModel
|
||||||
|
? apiModel.readScheduleList(resource.id, params)
|
||||||
|
: SchedulesAPI.read(params);
|
||||||
const {
|
const {
|
||||||
data: { count, results },
|
data: { count, results },
|
||||||
} = await SchedulesAPI.read(params);
|
} = await response;
|
||||||
return {
|
return {
|
||||||
itemCount: count,
|
itemCount: count,
|
||||||
schedules: results,
|
schedules: results,
|
||||||
};
|
};
|
||||||
}, [location]),
|
}, [location, apiModel, resource]),
|
||||||
{
|
{
|
||||||
schedules: [],
|
schedules: [],
|
||||||
itemCount: 0,
|
itemCount: 0,
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import RoutedTabs from '@components/RoutedTabs';
|
|||||||
import ContentError from '@components/ContentError';
|
import ContentError from '@components/ContentError';
|
||||||
import NotificationList from '@components/NotificationList';
|
import NotificationList from '@components/NotificationList';
|
||||||
import { ResourceAccessList } from '@components/ResourceAccessList';
|
import { ResourceAccessList } from '@components/ResourceAccessList';
|
||||||
|
import ScheduleList from '@components/ScheduleList';
|
||||||
import ProjectDetail from './ProjectDetail';
|
import ProjectDetail from './ProjectDetail';
|
||||||
import ProjectEdit from './ProjectEdit';
|
import ProjectEdit from './ProjectEdit';
|
||||||
import ProjectJobTemplatesList from './ProjectJobTemplatesList';
|
import ProjectJobTemplatesList from './ProjectJobTemplatesList';
|
||||||
import ProjectSchedules from './ProjectSchedules';
|
|
||||||
import { OrganizationsAPI, ProjectsAPI } from '@api';
|
import { OrganizationsAPI, ProjectsAPI } from '@api';
|
||||||
|
|
||||||
class Project extends Component {
|
class Project extends Component {
|
||||||
@@ -134,16 +134,17 @@ class Project extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
tabsArray.push(
|
tabsArray.push({
|
||||||
{
|
name: i18n._(t`Job Templates`),
|
||||||
name: i18n._(t`Job Templates`),
|
link: `${match.url}/job_templates`,
|
||||||
link: `${match.url}/job_templates`,
|
});
|
||||||
},
|
|
||||||
{
|
if (project?.scm_type && project.scm_type !== '') {
|
||||||
|
tabsArray.push({
|
||||||
name: i18n._(t`Schedules`),
|
name: i18n._(t`Schedules`),
|
||||||
link: `${match.url}/schedules`,
|
link: `${match.url}/schedules`,
|
||||||
}
|
});
|
||||||
);
|
}
|
||||||
|
|
||||||
tabsArray.forEach((tab, n) => {
|
tabsArray.forEach((tab, n) => {
|
||||||
tab.id = n;
|
tab.id = n;
|
||||||
@@ -183,6 +184,8 @@ class Project extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(project);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageSection>
|
<PageSection>
|
||||||
<Card>
|
<Card>
|
||||||
@@ -230,10 +233,14 @@ class Project extends Component {
|
|||||||
<ProjectJobTemplatesList id={Number(match.params.id)} />
|
<ProjectJobTemplatesList id={Number(match.params.id)} />
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Route
|
{project?.scm_type && project.scm_type !== '' && (
|
||||||
path="/projects/:id/schedules"
|
<Route
|
||||||
render={() => <ProjectSchedules id={Number(match.params.id)} />}
|
path="/projects/:id/schedules"
|
||||||
/>
|
render={() => (
|
||||||
|
<ScheduleList resource={project} apiModel={ProjectsAPI} />
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Route
|
<Route
|
||||||
key="not-found"
|
key="not-found"
|
||||||
path="*"
|
path="*"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import ContentError from '@components/ContentError';
|
|||||||
import JobList from '@components/JobList';
|
import JobList from '@components/JobList';
|
||||||
import NotificationList from '@components/NotificationList';
|
import NotificationList from '@components/NotificationList';
|
||||||
import RoutedTabs from '@components/RoutedTabs';
|
import RoutedTabs from '@components/RoutedTabs';
|
||||||
|
import ScheduleList from '@components/ScheduleList';
|
||||||
import { ResourceAccessList } from '@components/ResourceAccessList';
|
import { ResourceAccessList } from '@components/ResourceAccessList';
|
||||||
import JobTemplateDetail from './JobTemplateDetail';
|
import JobTemplateDetail from './JobTemplateDetail';
|
||||||
import JobTemplateEdit from './JobTemplateEdit';
|
import JobTemplateEdit from './JobTemplateEdit';
|
||||||
@@ -119,6 +120,13 @@ class Template extends Component {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (template) {
|
||||||
|
tabsArray.push({
|
||||||
|
name: i18n._(t`Schedules`),
|
||||||
|
link: `${match.url}/schedules`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
tabsArray.forEach((tab, n) => {
|
tabsArray.forEach((tab, n) => {
|
||||||
tab.id = n;
|
tab.id = n;
|
||||||
});
|
});
|
||||||
@@ -210,6 +218,14 @@ class Template extends Component {
|
|||||||
<JobList defaultParams={{ job__job_template: template.id }} />
|
<JobList defaultParams={{ job__job_template: template.id }} />
|
||||||
</Route>
|
</Route>
|
||||||
)}
|
)}
|
||||||
|
{template && (
|
||||||
|
<Route
|
||||||
|
path="/templates/:templateType/:id/schedules"
|
||||||
|
render={() => (
|
||||||
|
<ScheduleList resource={template} apiModel={JobTemplatesAPI} />
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Route
|
<Route
|
||||||
key="not-found"
|
key="not-found"
|
||||||
path="*"
|
path="*"
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ describe('<Template />', () => {
|
|||||||
const tabs = await waitForElement(
|
const tabs = await waitForElement(
|
||||||
wrapper,
|
wrapper,
|
||||||
'.pf-c-tabs__item',
|
'.pf-c-tabs__item',
|
||||||
el => el.length === 6
|
el => el.length === 7
|
||||||
);
|
);
|
||||||
expect(tabs.at(2).text()).toEqual('Notifications');
|
expect(tabs.at(2).text()).toEqual('Notifications');
|
||||||
done();
|
done();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import ContentError from '@components/ContentError';
|
|||||||
import FullPage from '@components/FullPage';
|
import FullPage from '@components/FullPage';
|
||||||
import JobList from '@components/JobList';
|
import JobList from '@components/JobList';
|
||||||
import RoutedTabs from '@components/RoutedTabs';
|
import RoutedTabs from '@components/RoutedTabs';
|
||||||
|
import ScheduleList from '@components/ScheduleList';
|
||||||
import { WorkflowJobTemplatesAPI, CredentialsAPI } from '@api';
|
import { WorkflowJobTemplatesAPI, CredentialsAPI } from '@api';
|
||||||
import WorkflowJobTemplateDetail from './WorkflowJobTemplateDetail';
|
import WorkflowJobTemplateDetail from './WorkflowJobTemplateDetail';
|
||||||
import { Visualizer } from './WorkflowJobTemplateVisualizer';
|
import { Visualizer } from './WorkflowJobTemplateVisualizer';
|
||||||
@@ -85,6 +86,13 @@ class WorkflowJobTemplate extends Component {
|
|||||||
{ name: i18n._(t`Completed Jobs`), link: `${match.url}/completed_jobs` },
|
{ 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) => {
|
tabsArray.forEach((tab, n) => {
|
||||||
tab.id = n;
|
tab.id = n;
|
||||||
});
|
});
|
||||||
@@ -162,6 +170,17 @@ class WorkflowJobTemplate extends Component {
|
|||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
)}
|
)}
|
||||||
|
{template && (
|
||||||
|
<Route
|
||||||
|
path="/templates/:templateType/:id/schedules"
|
||||||
|
render={() => (
|
||||||
|
<ScheduleList
|
||||||
|
resource={template}
|
||||||
|
apiModel={WorkflowJobTemplatesAPI}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Route
|
<Route
|
||||||
key="not-found"
|
key="not-found"
|
||||||
path="*"
|
path="*"
|
||||||
|
|||||||
Reference in New Issue
Block a user