import { Alert, Button, message, Space, Typography } from 'antd'; import React, { useEffect, useState } from 'react'; import styled from 'styled-components'; import { StepProps } from './types'; import { getSourceConfigs, jsonToYaml, yamlToJson } from '../utils'; import { YamlEditor } from './YamlEditor'; import { ANTD_GRAY } from '../../../entity/shared/constants'; import { IngestionSourceBuilderStep } from './steps'; import RecipeBuilder from './RecipeBuilder'; import { CONNECTORS_WITH_FORM } from './RecipeForm/utils'; const LOOKML_DOC_LINK = 'https://datahubproject.io/docs/generated/ingestion/sources/looker#module-lookml'; const Section = styled.div` display: flex; flex-direction: column; padding-bottom: 16px; `; const BorderedSection = styled(Section)` border: solid ${ANTD_GRAY[4]} 0.5px; `; const SelectTemplateHeader = styled(Typography.Title)` && { margin-bottom: 8px; } `; const ControlsContainer = styled.div` display: flex; justify-content: space-between; margin-top: 8px; `; /** * The step for defining a recipe */ export const DefineRecipeStep = ({ state, updateState, goTo, prev }: StepProps) => { const existingRecipeJson = state.config?.recipe; const existingRecipeYaml = existingRecipeJson && jsonToYaml(existingRecipeJson); const { type } = state; const sourceConfigs = getSourceConfigs(type as string); const [stagedRecipeYml, setStagedRecipeYml] = useState(existingRecipeYaml || sourceConfigs.placeholderRecipe); useEffect(() => { if (existingRecipeYaml) { setStagedRecipeYml(existingRecipeYaml); } }, [existingRecipeYaml]); const [stepComplete, setStepComplete] = useState(false); const isEditing: boolean = prev === undefined; const displayRecipe = stagedRecipeYml || sourceConfigs.placeholderRecipe; const sourceDisplayName = sourceConfigs.displayName; const sourceDocumentationUrl = sourceConfigs.docsUrl; // Maybe undefined (in case of "custom") // TODO: Delete LookML banner specific code const isSourceLooker: boolean = sourceConfigs.type === 'looker'; const [showLookerBanner, setShowLookerBanner] = useState(isSourceLooker && !isEditing); useEffect(() => { if (stagedRecipeYml && stagedRecipeYml.length > 0 && !showLookerBanner) { setStepComplete(true); } }, [stagedRecipeYml, showLookerBanner]); const onClickNext = () => { // Convert the recipe into it's json representation, and catch + report exceptions while we do it. let recipeJson; try { recipeJson = yamlToJson(stagedRecipeYml); } catch (e) { message.warn('Found invalid YAML. Please check your recipe configuration.'); return; } const newState = { ...state, config: { ...state.config, recipe: recipeJson, }, }; updateState(newState); goTo(IngestionSourceBuilderStep.CREATE_SCHEDULE); }; if (type && CONNECTORS_WITH_FORM.has(type)) { return ( ); } return ( <>
Configure {sourceDisplayName} Recipe {showLookerBanner && ( You must acknowledge this message to proceed!

To get complete Looker metadata integration (including Looker views and lineage to the underlying warehouse tables), you must also use the{' '} DataHub lookml module .

LookML ingestion cannot currently be performed via UI-based ingestion. This is a known problem the DataHub team is working to solve!
} afterClose={() => setShowLookerBanner(false)} /> )} {showLookerBanner &&
} For more information about how to configure a recipe, see the{' '} {sourceDisplayName} source docs.
); };