Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pipeline_templates): Display "Force Rebake" checkbox for MPT #5854

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AuthenticationService } from 'core/authentication';
import { Registry } from 'core/registry';
import { SETTINGS } from 'core/config/settings';
import { AppNotificationsService } from 'core/notification/AppNotificationsService';
import { PipelineTemplateReader } from 'core/pipeline/config/templates/PipelineTemplateReader';

import { STAGE_MANUAL_COMPONENTS } from './stageManualComponents.component';
import { TRIGGER_TEMPLATE } from './triggerTemplate.component';
Expand Down Expand Up @@ -109,6 +110,21 @@ module.exports = angular
this.command.trigger = suppliedTriggerCanBeInvoked ? trigger : _.head(this.triggers);
};

const updatePipelinePlan = pipeline => {
if (pipeline.type === 'templatedPipeline' && (pipeline.stages === undefined || pipeline.stages.length === 0)) {
PipelineTemplateReader.getPipelinePlan(pipeline)
Copy link
Contributor Author

@jervi jervi Oct 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getPipelinePlan takes an optional second parameter executionId. Ideally I should've used the build selected in the build drop down if available, but that turned out to be a rabbit hole. The builds in that list only have the CI build number, not the executionId. The executions variable only have a few executions for each pipeline (depending on the number of pipelines being displayed). And since the dropdown is a react component, I have to use a $watch expression to detect when it changes.
So the current implementation will only consider the newest version of the pipeline when deciding wether to show the force rebake box or not. But I think this is Good Enough™, for the same reasons mentioned earlier. It's certainly better than never showing it.

.then(plan => (this.stageComponents = getManualExecutionComponents(plan.stages)))
.catch(() => getManualExecutionComponents(pipeline.stages));
} else {
this.stageComponents = getManualExecutionComponents(pipeline.stages);
}
};

const getManualExecutionComponents = stages => {
const additionalComponents = stages.map(stage => Registry.pipeline.getManualExecutionComponentForStage(stage));
return _.uniq(_.compact(additionalComponents));
};

/**
* Controller API
*/
Expand Down Expand Up @@ -141,10 +157,7 @@ module.exports = angular
addTriggers();
this.triggerUpdated();

const additionalComponents = pipeline.stages.map(stage =>
Registry.pipeline.getManualExecutionComponentForStage(stage),
);
this.stageComponents = _.uniq(_.compact(additionalComponents));
updatePipelinePlan(pipeline);

if (pipeline.parameterConfig && pipeline.parameterConfig.length) {
this.parameters = {};
Expand Down