Skip to content

Commit

Permalink
fix(pipeline_template): Build execution title/numbers was rendered twice
Browse files Browse the repository at this point in the history
  • Loading branch information
jervi committed Nov 6, 2017
1 parent 87126d2 commit d951e61
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { BindAll } from 'lodash-decorators';

import { IExecution } from 'core/domain';
import { ReactInjector } from 'core/reactShims';
import { ExecutionBuildTitle } from './ExecutionBuildTitle';

import './ExecutionBuildLink.less';

Expand Down Expand Up @@ -40,7 +39,7 @@ export class ExecutionBuildLink extends React.Component<IExecutionBuildLinkProps
className="execution-build-number clickable"
onClick={this.handleParentPipelineClick}
>
<ExecutionBuildTitle execution={this.props.execution}/>
{this.props.execution.trigger.parentPipelineName}
</a>
)}
{ this.props.execution.buildInfo && this.props.execution.buildInfo.number && (
Expand All @@ -50,7 +49,7 @@ export class ExecutionBuildLink extends React.Component<IExecutionBuildLinkProps
href={this.props.execution.buildInfo.url}
target="_blank"
>
<ExecutionBuildTitle execution={this.props.execution}/>
<span className="build-label">Build</span> #{this.props.execution.buildInfo.number}
</a>
)}
</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
/*
* Copyright 2017 Schibsted ASA.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as React from 'react';
import { BindAll } from 'lodash-decorators';

Expand All @@ -23,7 +6,6 @@ import { react2angular } from 'react2angular';

import { IExecutionBuildLinkProps } from './ExecutionBuildLink';
import { timestamp } from 'core/utils'
import { ReactInjector } from 'core/reactShims';

export interface IExecutionBuildTitleProps extends IExecutionBuildLinkProps {
defaultToTimestamp?: boolean;
Expand All @@ -36,26 +18,27 @@ export class ExecutionBuildTitle extends React.Component<IExecutionBuildTitlePro
defaultToTimestamp: false
};

private hasParentPipeline: boolean;
private hasBuildNumber: boolean;

constructor(props: IExecutionBuildTitleProps) {
super(props);
const { executionsTransformer } = ReactInjector;
if (!props.execution.buildInfo) {
executionsTransformer.addBuildInfo(props.execution);
}
this.hasParentPipeline = !!props.execution.trigger.parentPipelineName;
this.hasBuildNumber = !!(props.execution.buildInfo && props.execution.buildInfo.number);
}

public render() {
return (
<span>
{ this.props.execution.trigger.parentPipelineName &&
{ this.hasParentPipeline && (
<span>{this.props.execution.trigger.parentPipelineName}</span>
}
{ this.props.execution.buildInfo && this.props.execution.buildInfo.number &&
)}
{ this.hasBuildNumber && !this.hasParentPipeline && (
<span><span className="build-label">Build</span> #{this.props.execution.buildInfo.number}</span>
}
{ this.props.defaultToTimestamp && !this.props.execution.trigger.parentPipelineName && !this.props.execution.buildInfo &&
)}
{ this.props.defaultToTimestamp && !this.hasParentPipeline && !this.hasBuildNumber && (
<span>{timestamp(this.props.execution.startTime)}</span>
}
)}
</span>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ module.exports = angular.module('spinnaker.core.pipeline.config.pipelineConfigur
templateUrl: require('./pipelineConfigurer.html'),
};
})
.controller('PipelineConfigurerCtrl', function($scope, $uibModal, $timeout, $window, $q,
pipelineConfigValidator, pipelineTemplateService, executionService,
.controller('PipelineConfigurerCtrl', function($scope, $uibModal, $timeout, $window, $q, pipelineConfigValidator,
pipelineTemplateService, executionService, executionsTransformer,
pipelineConfigService, viewStateCache, overrideRegistry, $location) {
// For standard pipelines, a 'renderablePipeline' is just the pipeline config.
// For templated pipelines, a 'renderablePipeline' is the pipeline template plan, and '$scope.pipeline' is the template config.
Expand Down Expand Up @@ -374,6 +374,7 @@ module.exports = angular.module('spinnaker.core.pipeline.config.pipelineConfigur
this.getPipelineExecutions = () => {
executionService.getExecutionsForConfigIds($scope.pipeline.application, $scope.pipeline.id, 5)
.then(executions => {
executions.forEach(execution => executionsTransformer.addBuildInfo(execution));
$scope.pipelineExecutions = executions;
if ($scope.plan && $scope.plan.executionId) {
$scope.currentExecution = _.find($scope.pipelineExecutions, { id: $scope.plan.executionId });
Expand Down

0 comments on commit d951e61

Please sign in to comment.