import React from 'react'; import { CreatePipelineModal } from './CreatePipelineModal'; import type { Application } from '../../application'; import { Tooltip } from '../../presentation/Tooltip'; import { ReactInjector } from '../../reactShims'; import { logger } from '../../utils'; export interface ICreatePipelineButtonProps { application: Application; asLink?: boolean; } export interface ICreatePipelineButtonState { showCreatePipelineModal: boolean; } export class CreatePipelineButton extends React.Component { constructor(props: ICreatePipelineButtonProps) { super(props); this.state = { showCreatePipelineModal: false, }; } private showCallBack = (showCreatePipelineModal: boolean) => { this.setState({ showCreatePipelineModal }); }; private createPipeline = () => { logger.log({ category: 'Pipelines', action: 'Create Pipeline' }); this.setState({ showCreatePipelineModal: true }); }; private goToPipelineConfig = (id: string) => { const { $state } = ReactInjector; if (!$state.current.name.includes('.executions.execution')) { $state.go('^.pipelineConfig', { pipelineId: id }); } else { $state.go('^.^.pipelineConfig', { pipelineId: id }); } }; public render() { const modal = ( ); if (this.props.asLink) { return ( Configure a new pipeline {modal} ); } return ( ); } }