From a1b7d8698135830bdac571314f26bb91449c91fb Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Mon, 2 Apr 2018 17:09:08 -0400 Subject: [PATCH] remove the rest of templates list code and update organization tempaltes list to using new code --- .../organizationsTemplatesList.route.js | 65 +++++++++++++++ .../routes/projectsTemplatesList.route.js | 1 + .../linkout/organizations-linkout.route.js | 81 ++----------------- .../src/projects/projects-templates.route.js | 60 -------------- 4 files changed, 73 insertions(+), 134 deletions(-) create mode 100644 awx/ui/client/features/templates/routes/organizationsTemplatesList.route.js delete mode 100644 awx/ui/client/src/projects/projects-templates.route.js diff --git a/awx/ui/client/features/templates/routes/organizationsTemplatesList.route.js b/awx/ui/client/features/templates/routes/organizationsTemplatesList.route.js new file mode 100644 index 0000000000..3bdd705f1e --- /dev/null +++ b/awx/ui/client/features/templates/routes/organizationsTemplatesList.route.js @@ -0,0 +1,65 @@ +import { N_ } from '../../../src/i18n'; +import templatesListController from '../templatesList.controller'; +import indexController from '../index.controller'; + +const indexTemplate = require('~features/templates/index.view.html'); +const templatesListTemplate = require('~features/templates/templatesList.view.html'); + +export default { + url: "/:organization_id/job_templates", + name: 'organizations.job_templates', + params: { + template_search: { + dynamic: true, + value: { + type: 'workflow_job_template,job_template', + }, + } + }, + ncyBreadcrumb: { + label: N_("JOB TEMPLATES") + }, + views: { + 'form': { + templateUrl: indexTemplate, + controller: indexController, + controllerAs: 'vm' + }, + 'templatesList@organizations.job_templates': { + controller: templatesListController, + templateUrl: templatesListTemplate, + controllerAs: 'vm', + } + }, + resolve: { + resolvedModels: [ + 'JobTemplateModel', + 'WorkflowJobTemplateModel', + (JobTemplate, WorkflowJobTemplate) => { + const models = [ + new JobTemplate(['options']), + new WorkflowJobTemplate(['options']), + ]; + return Promise.all(models); + }, + ], + Dataset: [ + '$stateParams', + 'Wait', + 'GetBasePath', + 'QuerySet', + ($stateParams, Wait, GetBasePath, qs) => { + const searchPath = GetBasePath('unified_job_templates'); + + const searchParam = _.assign($stateParams.template_search, { + or__project__organization: $stateParams.organization_id, + or__jobtemplate__inventory__organization: $stateParams.organization_id, + }); + + Wait('start'); + return qs.search(searchPath, searchParam) + .finally(() => Wait('stop')); + } + ], + } +}; diff --git a/awx/ui/client/features/templates/routes/projectsTemplatesList.route.js b/awx/ui/client/features/templates/routes/projectsTemplatesList.route.js index 2fa97411b8..8f6d916dbc 100644 --- a/awx/ui/client/features/templates/routes/projectsTemplatesList.route.js +++ b/awx/ui/client/features/templates/routes/projectsTemplatesList.route.js @@ -10,6 +10,7 @@ export default { template_search: { dynamic: true, value: { + type: 'workflow_job_template,job_template', }, } }, diff --git a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js index 43165dbf9d..20f8b6a6c3 100644 --- a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js +++ b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js @@ -4,15 +4,16 @@ * All Rights Reserved *************************************************/ +import OrganizationsJobTemplatesRoute from '~features/templates/routes/organizationsTemplatesList.route'; + import OrganizationsAdmins from './controllers/organizations-admins.controller'; import OrganizationsInventories from './controllers/organizations-inventories.controller'; -import OrganizationsJobTemplates from './controllers/organizations-job-templates.controller'; import OrganizationsProjects from './controllers/organizations-projects.controller'; import OrganizationsTeams from './controllers/organizations-teams.controller'; import OrganizationsUsers from './controllers/organizations-users.controller'; import { N_ } from '../../i18n'; -export default [{ +let lists = [{ name: 'organizations.users', url: '/:organization_id/users', searchPrefix: 'user', @@ -215,78 +216,6 @@ export default [{ } ] } -}, { - name: 'organizations.job_templates', - url: '/:organization_id/job_templates', - searchPrefix: 'job_template', - views: { - 'form': { - controller: OrganizationsJobTemplates, - templateProvider: function(OrgJobTemplateList, generateList) { - let html = generateList.build({ - list: OrgJobTemplateList, - mode: 'edit', - cancelButton: true - }); - return generateList.wrapPanel(html); - }, - }, - }, - params: { - template_search: { - value: { - or__project__organization: null, - or__inventory__organization: null, - page_size: 20 - }, - dynamic: true - } - }, - data: { - activityStream: true, - activityStreamTarget: 'organization', - socket: { - "groups": { - "jobs": ["status_changed"] - } - } - }, - ncyBreadcrumb: { - parent: "organizations.edit", - label: N_("JOB TEMPLATES") - }, - resolve: { - features: ['FeaturesService', function(FeaturesService) { - return FeaturesService.get(); - }], - OrgJobTemplateList: ['TemplateList', 'GetBasePath', '$stateParams', function(TemplateList) { - let list = _.cloneDeep(TemplateList); - delete list.actions; - // @issue Why is the delete action unavailable in this view? - delete list.fieldActions.delete; - delete list.fields.type; - list.listTitle = N_('Job Templates') + ` | {{ name }}`; - list.emptyListText = "This list is populated by job templates added from the Job Templates section"; - list.iterator = 'template'; - list.name = 'job_templates'; - list.basePath = "job_templates"; - list.fields.smart_status.ngInclude = "'/static/partials/organizations-job-template-smart-status.html'"; - list.fields.name.ngHref = '#/templates/job_template/{{template.id}}'; - list.fieldActions.schedule.ngClick = 'scheduleJob(template.id)'; - list.fieldActions.copy.ngClick = 'copyTemplate(template.id)'; - list.fieldActions.edit.ngClick = "editJobTemplate(template.id)"; - list.fieldActions.view.ngClick = "editJobTemplate(template.id)"; - return list; - }], - OrgJobTemplateDataset: ['OrgJobTemplateList', 'QuerySet', '$stateParams', 'GetBasePath', - function(list, qs, $stateParams, GetBasePath) { - let path = GetBasePath(list.name); - $stateParams.template_search.or__project__organization = $stateParams.organization_id; - $stateParams.template_search.or__inventory__organization = $stateParams.organization_id; - return qs.search(path, $stateParams.template_search); - } - ] - } }, { name: 'organizations.admins', url: '/:organization_id/admins', @@ -355,3 +284,7 @@ export default [{ }] } }]; + +lists.push(OrganizationsJobTemplatesRoute); + +export default lists; diff --git a/awx/ui/client/src/projects/projects-templates.route.js b/awx/ui/client/src/projects/projects-templates.route.js deleted file mode 100644 index f15c229edd..0000000000 --- a/awx/ui/client/src/projects/projects-templates.route.js +++ /dev/null @@ -1,60 +0,0 @@ -import { N_ } from '../i18n'; - -export default { - url: "/templates", - name: 'projects.edit.templates', - params: { - template_search: { - value: { - page_size: '20', - project: '', - order_by: "-id" - } - } - }, - ncyBreadcrumb: { - label: N_("JOB TEMPLATES") - }, - views: { - // TODO: this controller was removed and replaced - // with the new features/templates controller - // this view should be updated with the new - // expanded list - 'related': { - templateProvider: function(FormDefinition, GenerateForm) { - let html = GenerateForm.buildCollection({ - mode: 'edit', - related: 'templates', - form: typeof(FormDefinition) === 'function' ? - FormDefinition() : FormDefinition - }); - return html; - }, - controller: 'TemplatesListController' - } - }, - resolve: { - ListDefinition: ['TemplateList', '$transition$', (TemplateList, $transition$) => { - let id = $transition$.params().project_id; - TemplateList.actions.add.ngClick = `$state.go('templates.addJobTemplate', {project_id: ${id}})`; - TemplateList.basePath = 'job_templates'; - return TemplateList; - }], - Dataset: ['ListDefinition', 'QuerySet', '$stateParams', 'GetBasePath', '$interpolate', '$rootScope', - (list, qs, $stateParams, GetBasePath, $interpolate, $rootScope) => { - // allow related list definitions to use interpolated $rootScope / $stateParams in basePath field - let path, interpolator; - if (GetBasePath(list.basePath)) { - path = GetBasePath(list.basePath); - } else { - interpolator = $interpolate(list.basePath); - path = interpolator({ $rootScope: $rootScope, $stateParams: $stateParams }); - } - let project_id = $stateParams.project_id; - $stateParams[`${list.iterator}_search`].project = project_id; - path = GetBasePath('job_templates'); - return qs.search(path, $stateParams[`${list.iterator}_search`]); - } - ] - } -};