mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
add schedule list to proj, jt and wfjt
This commit is contained in:
parent
e706e0a2e2
commit
4db3e823bf
@ -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;
|
||||
|
||||
@ -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/`);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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 (
|
||||
<PageSection>
|
||||
<Card>
|
||||
@ -230,10 +233,14 @@ class Project extends Component {
|
||||
<ProjectJobTemplatesList id={Number(match.params.id)} />
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
path="/projects/:id/schedules"
|
||||
render={() => <ProjectSchedules id={Number(match.params.id)} />}
|
||||
/>
|
||||
{project?.scm_type && project.scm_type !== '' && (
|
||||
<Route
|
||||
path="/projects/:id/schedules"
|
||||
render={() => (
|
||||
<ScheduleList resource={project} apiModel={ProjectsAPI} />
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<Route
|
||||
key="not-found"
|
||||
path="*"
|
||||
|
||||
@ -10,6 +10,7 @@ import ContentError from '@components/ContentError';
|
||||
import JobList from '@components/JobList';
|
||||
import NotificationList from '@components/NotificationList';
|
||||
import RoutedTabs from '@components/RoutedTabs';
|
||||
import ScheduleList from '@components/ScheduleList';
|
||||
import { ResourceAccessList } from '@components/ResourceAccessList';
|
||||
import JobTemplateDetail from './JobTemplateDetail';
|
||||
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) => {
|
||||
tab.id = n;
|
||||
});
|
||||
@ -210,6 +218,14 @@ class Template extends Component {
|
||||
<JobList defaultParams={{ job__job_template: template.id }} />
|
||||
</Route>
|
||||
)}
|
||||
{template && (
|
||||
<Route
|
||||
path="/templates/:templateType/:id/schedules"
|
||||
render={() => (
|
||||
<ScheduleList resource={template} apiModel={JobTemplatesAPI} />
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<Route
|
||||
key="not-found"
|
||||
path="*"
|
||||
|
||||
@ -61,7 +61,7 @@ describe('<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();
|
||||
|
||||
@ -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 {
|
||||
/>
|
||||
</Route>
|
||||
)}
|
||||
{template && (
|
||||
<Route
|
||||
path="/templates/:templateType/:id/schedules"
|
||||
render={() => (
|
||||
<ScheduleList
|
||||
resource={template}
|
||||
apiModel={WorkflowJobTemplatesAPI}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<Route
|
||||
key="not-found"
|
||||
path="*"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user