diff --git a/ui/app/components/job-version.js b/ui/app/components/job-version.js index bcb7228b0b8..d777cea1cbe 100644 --- a/ui/app/components/job-version.js +++ b/ui/app/components/job-version.js @@ -85,7 +85,7 @@ export default class JobVersion extends Component { /** * @type {'idle' | 'confirming'} */ - @tracked revertButtonStatus = 'idle'; + @tracked cloneButtonStatus = 'idle'; @task(function* () { try { @@ -95,6 +95,7 @@ export default class JobVersion extends Component { const versionAfterReversion = this.version.get('job.version'); if (versionBeforeReversion === versionAfterReversion) { + // TODO: I don't think this is ever hit, we have template checks against it. this.args.handleError({ level: 'warn', title: 'Reversion Had No Effect', @@ -115,7 +116,7 @@ export default class JobVersion extends Component { }) revertTo; - @action async editFromVersion() { + @action async cloneAsNewVersion() { try { this.router.transitionTo( 'jobs.job.definition', @@ -135,6 +136,28 @@ export default class JobVersion extends Component { } } + @action async cloneAsNewJob() { + console.log('cloneAsNewJob'); + try { + // TODO: copy the job definition over there. + console.log('Do I have submission info???', this.version); + let job = await this.version.get('job'); + let specification = await job.fetchRawSpecification(this.version.number); + console.log('Do I have specification???', specification); + let specificationSourceString = specification.Source; // TODO: should do some Format checking here, at the very least. + this.router.transitionTo('jobs.run', { + queryParams: { + sourceString: specificationSourceString, + }, + }); + } catch (e) { + this.args.handleError({ + level: 'danger', + title: 'Could Not Clone as New Job', + }); + } + } + @action handleKeydown(event) { if (event.key === 'Escape') { diff --git a/ui/app/routes/jobs/job/definition.js b/ui/app/routes/jobs/job/definition.js index bd670a9d676..98277cbda2d 100644 --- a/ui/app/routes/jobs/job/definition.js +++ b/ui/app/routes/jobs/job/definition.js @@ -26,6 +26,7 @@ export default class DefinitionRoute extends Route { */ async model({ version }) { version = +version; // query parameter is a string; convert to number + /** @type {import('../../../models/job').default} */ const job = this.modelFor('jobs.job'); if (!job) return; diff --git a/ui/app/routes/jobs/run/index.js b/ui/app/routes/jobs/run/index.js index 95c0bbffd2d..ff48debc6bd 100644 --- a/ui/app/routes/jobs/run/index.js +++ b/ui/app/routes/jobs/run/index.js @@ -21,6 +21,9 @@ export default class JobsRunIndexRoute extends Route { template: { refreshModel: true, }, + sourceString: { + refreshModel: true, + }, }; beforeModel(transition) { @@ -33,7 +36,7 @@ export default class JobsRunIndexRoute extends Route { } } - async model({ template }) { + async model({ template, sourceString }) { try { // When jobs are created with a namespace attribute, it is verified against // available namespaces to prevent redirecting to a non-existent namespace. @@ -45,6 +48,12 @@ export default class JobsRunIndexRoute extends Route { return this.store.createRecord('job', { _newDefinition: templateRecord.items.template, }); + } else if (sourceString) { + console.log('elsif', sourceString); + // Add an alert to the page to let the user know that they are submitting a job from a template, and that they should change the name! + return this.store.createRecord('job', { + _newDefinition: sourceString, + }); } else { return this.store.createRecord('job'); } diff --git a/ui/app/templates/components/job-version.hbs b/ui/app/templates/components/job-version.hbs index c56503db4a1..789e6649335 100644 --- a/ui/app/templates/components/job-version.hbs +++ b/ui/app/templates/components/job-version.hbs @@ -81,53 +81,60 @@