Skip to content

Commit

Permalink
feat(ui): Add warning banner to looker and lookml UI ingestion forms (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankit-Keshari-Vituity authored and cccs-tom committed Nov 18, 2022
1 parent baeba0d commit e25e2be
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Alert, Button, Space, Typography } from 'antd';
import React, { useEffect, useState } from 'react';
import { Alert, Button, Space, Typography } from 'antd';
import styled from 'styled-components';
import { StepProps } from './types';
import { getPlaceholderRecipe, getSourceConfigs, jsonToYaml } from '../utils';
Expand Down
41 changes: 41 additions & 0 deletions datahub-web-react/src/app/ingest/source/builder/LookerWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import { Alert } from 'antd';
import { LOOKER, LOOK_ML } from './constants';

const LOOKML_DOC_LINK = 'https://datahubproject.io/docs/generated/ingestion/sources/looker#module-lookml';
const LOOKER_DOC_LINK = 'https://datahubproject.io/docs/generated/ingestion/sources/looker#module-looker';

interface Props {
type: string;
}

export const LookerWarning = ({ type }: Props) => {
let link: React.ReactNode;
if (type === LOOKER) {
link = (
<a href={LOOKML_DOC_LINK} target="_blank" rel="noopener noreferrer">
DataHub lookml module
</a>
);
} else if (type === LOOK_ML) {
link = (
<a href={LOOKER_DOC_LINK} target="_blank" rel="noopener noreferrer">
DataHub looker module
</a>
);
}

return (
<Alert
style={{ marginBottom: '10px' }}
type="warning"
banner
message={
<>
To get complete Looker metadata integration (including Looker views and lineage to the underlying
warehouse tables), you must <b>also</b> use the {link}.
</>
}
/>
);
};
39 changes: 29 additions & 10 deletions datahub-web-react/src/app/ingest/source/builder/RecipeBuilder.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Button, message } from 'antd';
import React, { useState } from 'react';
import { Button, message, Typography } from 'antd';
import YAML from 'yamljs';
import { CodeOutlined, FormOutlined } from '@ant-design/icons';
import styled from 'styled-components/macro';
import { ANTD_GRAY } from '../../../entity/shared/constants';
import { YamlEditor } from './YamlEditor';
import RecipeForm from './RecipeForm/RecipeForm';
import { SourceBuilderState, SourceConfig } from './types';
import { LOOKER, LOOK_ML } from './constants';
import { LookerWarning } from './LookerWarning';

export const ControlsContainer = styled.div`
display: flex;
Expand All @@ -32,9 +34,20 @@ const StyledButton = styled(Button)<{ isSelected: boolean }>`
`}
`;

const Title = styled(Typography.Title)`
display: flex;
align-items: center;
justify-content: flex-start;
`;

const ButtonsWrapper = styled.div`
display: flex;
justify-content: flex-end;
`;

const HeaderContainer = styled.div`
display: flex;
justify-content: space-between;
margin-bottom: 10px;
`;

Expand All @@ -50,7 +63,7 @@ interface Props {

function RecipeBuilder(props: Props) {
const { state, isEditing, displayRecipe, sourceConfigs, setStagedRecipe, onClickNext, goToPrevious } = props;

const { type } = state;
const [isViewingForm, setIsViewingForm] = useState(true);

function switchViews(isFormView: boolean) {
Expand All @@ -67,14 +80,20 @@ function RecipeBuilder(props: Props) {

return (
<div>
<ButtonsWrapper>
<StyledButton type="text" isSelected={isViewingForm} onClick={() => switchViews(true)}>
<FormOutlined /> Form
</StyledButton>
<StyledButton type="text" isSelected={!isViewingForm} onClick={() => switchViews(false)}>
<CodeOutlined /> YAML
</StyledButton>
</ButtonsWrapper>
{(type === LOOKER || type === LOOK_ML) && <LookerWarning type={type} />}
<HeaderContainer>
<Title style={{ marginBottom: 0 }} level={5}>
{sourceConfigs?.displayName} Recipe
</Title>
<ButtonsWrapper>
<StyledButton type="text" isSelected={isViewingForm} onClick={() => switchViews(true)}>
<FormOutlined /> Form
</StyledButton>
<StyledButton type="text" isSelected={!isViewingForm} onClick={() => switchViews(false)}>
<CodeOutlined /> YAML
</StyledButton>
</ButtonsWrapper>
</HeaderContainer>
{isViewingForm && (
<RecipeForm
state={state}
Expand Down

0 comments on commit e25e2be

Please sign in to comment.