import { ExternalLink } from '@automattic/components';
import { createInterpolateElement } from '@wordpress/element';
import { translate } from 'i18n-calypso';
import { GitHubRepositoryData } from '../../use-github-repositories-query';
import { useWorkflowTemplate } from '../deployment-style/use-get-workflow-template-query';
import { NewWorkflowWizard } from './new-workflow-wizard';
import { Workflow } from './use-deployment-workflows-query';
import { WorkflowPicker } from './workflow-picker';
import { WorkflowValidationWizard } from './workflow-validation-wizard';
type AdvancedWorkflowStyleProps = {
repository: Pick< GitHubRepositoryData, 'id' | 'owner' | 'name' >;
branchName: string;
workflowPath?: string;
workflows?: Workflow[];
isLoading: boolean;
isFetching: boolean;
useComposerWorkflow: boolean;
onWorkflowCreation( path: string ): void;
onChooseWorkflow( path: string ): void;
};
export const AdvancedWorkflowStyle = ( {
workflows,
isLoading,
isFetching,
repository,
branchName,
workflowPath,
onWorkflowCreation,
onChooseWorkflow,
useComposerWorkflow,
}: AdvancedWorkflowStyleProps ) => {
const templateName = useComposerWorkflow ? 'with_composer' : 'simple';
const { data: template } = useWorkflowTemplate( { branchName, template: templateName } );
const getContent = () => {
const workflow = workflows?.find( ( workflow ) => workflow.workflow_path === workflowPath );
const templateContents = template?.template ?? '';
if ( ! workflow ) {
return (
{ createInterpolateElement(
translate(
'You can start with our basic workflow file and extend it. Looking for inspiration? Check out our workflow recipes.'
),
{
a: (