From 77e195bbb9e084139bc4ede84d870d587034e0cb Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 11 May 2018 14:44:38 -0700 Subject: [PATCH] Moves schedules tab to related tab for sources form --- .../inventories/inventories.partial.html | 1 + .../schedule/sources-schedule-add.route.js | 3 +- .../schedule/sources-schedule-edit.route.js | 7 ++- .../list/schedule/sources-schedule.route.js | 52 ++++++++----------- .../sources/list/sources-list.controller.js | 2 +- .../related/sources/sources.form.js | 8 ++- awx/ui/client/src/scheduler/main.js | 2 - .../src/scheduler/schedulerAdd.controller.js | 14 +++-- .../client/src/scheduler/schedules.route.js | 6 +-- 9 files changed, 53 insertions(+), 42 deletions(-) diff --git a/awx/ui/client/src/inventories-hosts/inventories/inventories.partial.html b/awx/ui/client/src/inventories-hosts/inventories/inventories.partial.html index 73bb0becd1..282fa47ad2 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/inventories.partial.html +++ b/awx/ui/client/src/inventories-hosts/inventories/inventories.partial.html @@ -1,6 +1,7 @@
+
diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule-add.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule-add.route.js index cb7ac3efb7..0b38774378 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule-add.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule-add.route.js @@ -5,10 +5,11 @@ export default { name: 'inventories.edit.inventory_sources.edit.schedules.add', url: '/add', ncyBreadcrumb: { + parent: 'inventories.edit.inventory_sources.edit.schedules', label: N_("CREATE SCHEDULE") }, views: { - 'form': { + 'scheduler@inventories': { controller: 'schedulerAddController', templateUrl: templateUrl("scheduler/schedulerForm") } diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule-edit.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule-edit.route.js index 0fc89af835..52021fc34d 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule-edit.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule-edit.route.js @@ -1,15 +1,18 @@ import {templateUrl} from '../../../../../../shared/template-url/template-url.factory'; +import editScheduleResolve from '../../../../../../scheduler/editSchedule.resolve'; export default { name: 'inventories.edit.inventory_sources.edit.schedules.edit', url: '/:schedule_id', ncyBreadcrumb: { + parent: "inventories.edit.inventory_sources.edit.schedules", label: "{{schedule_obj.name}}" }, views: { - 'form': { + 'scheduler@inventories': { templateUrl: templateUrl("scheduler/schedulerForm"), controller: 'schedulerEditController', } - } + }, + resolve: editScheduleResolve() }; diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule.route.js index 962263e673..aebe56b624 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/schedule/sources-schedule.route.js @@ -1,21 +1,35 @@ import { N_ } from '../../../../../../i18n'; export default { + searchPrefix: 'schedule', name: 'inventories.edit.inventory_sources.edit.schedules', url: '/schedules', - searchPrefix: 'schedule', ncyBreadcrumb: { + parent: 'inventories.edit.inventory_sources.edit', label: N_('SCHEDULES') }, + views: { + 'related': { + templateProvider: function(SchedulesList, generateList){ + SchedulesList.title = false; + let html = generateList.build({ + list: SchedulesList, + mode: 'edit' + }); + return html; + }, + controller: 'schedulerListController' + } + }, resolve: { - Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath', 'inventorySourceData', - function(list, qs, $stateParams, GetBasePath, inventorySourceData) { - let path = `${inventorySourceData.related.schedules}`; + Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath', 'inventorySource', + function(list, qs, $stateParams, GetBasePath, inventorySource) { + let path = `${inventorySource.get().related.schedules}`; return qs.search(path, $stateParams[`${list.iterator}_search`]); } ], - ParentObject: ['inventorySourceData', function(inventorySourceData) { - return inventorySourceData; + ParentObject: ['inventorySource', function(inventorySource) { + return inventorySource.get(); }], UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', function(Rest, GetBasePath, $stateParams, $q) { @@ -29,32 +43,12 @@ export default { }); return val.promise; }], - ScheduleList: ['SchedulesList', 'inventorySourceData', - (SchedulesList, inventorySourceData) => { + ScheduleList: ['SchedulesList', 'inventorySource', + (SchedulesList, inventorySource) => { let list = _.cloneDeep(SchedulesList); - list.basePath = `${inventorySourceData.related.schedules}`; + list.basePath = `${inventorySource.get().related.schedules}`; return list; } ] - }, - views: { - // clear form template when views render in this substate - 'form': { - templateProvider: () => '' - }, - // target the un-named ui-view @ root level - '@': { - templateProvider: function(ScheduleList, generateList, ParentObject, $filter) { - // include name of parent resource in listTitle - ScheduleList.listTitle = `${$filter('sanitize')(ParentObject.name)}
` + N_('SCHEDULES'); - let html = generateList.build({ - list: ScheduleList, - mode: 'edit' - }); - html = generateList.wrapPanel(html); - return "
" + generateList.insertFormView() + html + "
"; - }, - controller: 'schedulerListController' - } } }; diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js index 25d88d695e..6b2d43ee55 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js @@ -222,7 +222,7 @@ $scope.scheduleSource = function(id) { // Add this inv source's id to the array of inv source id's so that it gets // added to the breadcrumb trail - $state.go('inventories.edit.inventory_sources.edit.schedules', {inventory_source_id: id}, {reload: true}); + $state.go('inventories.edit.inventory_sources.edit.schedules',{inventory_source_id: id}); }; $scope.syncAllSources = function() { diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.form.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.form.js index d7d6e31c2b..89299827b9 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.form.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.form.js @@ -411,8 +411,14 @@ return { }, related: { - notifications: notifications_object + notifications: notifications_object, + schedules: { + title: i18n._('Schedules'), + skipGenerator: true, + ngClick: "$state.go('inventories.edit.inventory_sources.edit.schedules')" + } } + }; }]; diff --git a/awx/ui/client/src/scheduler/main.js b/awx/ui/client/src/scheduler/main.js index 0736c2f007..038053e83a 100644 --- a/awx/ui/client/src/scheduler/main.js +++ b/awx/ui/client/src/scheduler/main.js @@ -7,9 +7,7 @@ import listController from './schedulerList.controller'; import addController from './schedulerAdd.controller'; import editController from './schedulerEdit.controller'; -import {templateUrl} from '../shared/template-url/template-url.factory'; import schedulerDatePicker from './schedulerDatePicker.directive'; -import { N_ } from '../i18n'; import DeleteSchedule from './factories/delete-schedule.factory'; import RRuleToAPI from './factories/r-rule-to-api.factory'; import SchedulePost from './factories/schedule-post.factory'; diff --git a/awx/ui/client/src/scheduler/schedulerAdd.controller.js b/awx/ui/client/src/scheduler/schedulerAdd.controller.js index 2b7256529e..5c87f3c484 100644 --- a/awx/ui/client/src/scheduler/schedulerAdd.controller.js +++ b/awx/ui/client/src/scheduler/schedulerAdd.controller.js @@ -8,12 +8,12 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait', '$scope', '$rootScope', 'CreateSelect2', 'ParseTypeChange', 'GetBasePath', 'Rest', 'ParentObject', 'JobTemplateModel', '$q', 'Empty', 'SchedulePost', 'ProcessErrors', 'SchedulerInit', '$location', 'PromptService', 'RRuleToAPI', 'moment', - 'WorkflowJobTemplateModel', 'TemplatesStrings', + 'WorkflowJobTemplateModel', 'TemplatesStrings', 'rbacUiControlService', function($filter, $state, $stateParams, $http, Wait, $scope, $rootScope, CreateSelect2, ParseTypeChange, GetBasePath, Rest, ParentObject, JobTemplate, $q, Empty, SchedulePost, ProcessErrors, SchedulerInit, $location, PromptService, RRuleToAPI, moment, - WorkflowJobTemplate, TemplatesStrings + WorkflowJobTemplate, TemplatesStrings, rbacUiControlService ) { var base = $scope.base || $location.path().replace(/^\//, '').split('/')[0], @@ -21,7 +21,15 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait', job_type; var schedule_url = ParentObject.related.schedules || `${ParentObject.related.inventory_source}schedules`; - + if (ParentObject){ + $scope.parentObject = ParentObject; + let scheduleEndpoint = ParentObject.endpoint|| ParentObject.related.schedules || `${ParentObject.related.inventory_source}schedules`; + $scope.canAdd = false; + rbacUiControlService.canAdd(scheduleEndpoint) + .then(function(params) { + $scope.canAdd = params.canAdd; + }); + } let processSchedulerEndDt = function(){ // set the schedulerEndDt to be equal to schedulerStartDt + 1 day @ midnight var dt = new Date($scope.schedulerUTCTime); diff --git a/awx/ui/client/src/scheduler/schedules.route.js b/awx/ui/client/src/scheduler/schedules.route.js index 37658ff9a9..75f61ca009 100644 --- a/awx/ui/client/src/scheduler/schedules.route.js +++ b/awx/ui/client/src/scheduler/schedules.route.js @@ -49,7 +49,7 @@ const jobTemplatesSchedulesListRoute = { }, views: { related: { - templateProvider: function(ScheduleList, generateList, ParentObject, $filter){ + templateProvider: function(ScheduleList, generateList){ ScheduleList.title = false; let html = generateList.build({ list: ScheduleList, @@ -141,7 +141,7 @@ const workflowSchedulesRoute = { }, views: { related: { - templateProvider: function(ScheduleList, generateList, ParentObject, $filter){ + templateProvider: function(ScheduleList, generateList){ ScheduleList.title = false; let html = generateList.build({ list: ScheduleList, @@ -232,7 +232,7 @@ const projectsSchedulesListRoute = { }, views: { related: { - templateProvider: function(ScheduleList, generateList, ParentObject, $filter){ + templateProvider: function(ScheduleList, generateList){ ScheduleList.title = false; let html = generateList.build({ list: ScheduleList,