diff --git a/datahub-web-react/src/app/ingest/source/IngestionSourceList.tsx b/datahub-web-react/src/app/ingest/source/IngestionSourceList.tsx index 945f7f2eb7..45b2e80b94 100644 --- a/datahub-web-react/src/app/ingest/source/IngestionSourceList.tsx +++ b/datahub-web-react/src/app/ingest/source/IngestionSourceList.tsx @@ -111,59 +111,6 @@ export const IngestionSourceList = () => { const focusSource = (focusSourceUrn && filteredSources.find((source) => source.urn === focusSourceUrn)) || undefined; - const onCreateOrUpdateIngestionSourceSuccess = () => { - setTimeout(() => refetch(), 2000); - setIsBuildingSource(false); - setFocusSourceUrn(undefined); - }; - - const createOrUpdateIngestionSource = (input: UpdateIngestionSourceInput, resetState: () => void) => { - if (focusSourceUrn) { - // Update: - updateIngestionSource({ variables: { urn: focusSourceUrn as string, input } }) - .then(() => { - message.success({ - content: `Successfully updated ingestion source!`, - duration: 3, - }); - onCreateOrUpdateIngestionSourceSuccess(); - resetState(); - }) - .catch((e) => { - message.destroy(); - message.error({ - content: `Failed to update ingestion source!: \n ${e.message || ''}`, - duration: 3, - }); - }); - } else { - // Create - createIngestionSource({ variables: { input } }) - .then(() => { - setTimeout(() => refetch(), 2000); - setIsBuildingSource(false); - setFocusSourceUrn(undefined); - resetState(); - message.success({ - content: `Successfully created ingestion source!`, - duration: 3, - }); - // onCreateOrUpdateIngestionSourceSuccess(); - }) - .catch((e) => { - message.destroy(); - message.error({ - content: `Failed to create ingestion source!: \n ${e.message || ''}`, - duration: 3, - }); - }); - } - }; - - const onChangePage = (newPage: number) => { - setPage(newPage); - }; - const onRefresh = () => { refetch(); // Used to force a re-render of the child execution request list. @@ -194,6 +141,70 @@ export const IngestionSourceList = () => { }); }; + const onCreateOrUpdateIngestionSourceSuccess = () => { + setTimeout(() => refetch(), 2000); + setIsBuildingSource(false); + setFocusSourceUrn(undefined); + }; + + const createOrUpdateIngestionSource = ( + input: UpdateIngestionSourceInput, + resetState: () => void, + shouldRun?: boolean, + ) => { + if (focusSourceUrn) { + // Update: + updateIngestionSource({ variables: { urn: focusSourceUrn as string, input } }) + .then(() => { + message.success({ + content: `Successfully updated ingestion source!`, + duration: 3, + }); + onCreateOrUpdateIngestionSourceSuccess(); + resetState(); + if (shouldRun) executeIngestionSource(focusSourceUrn); + }) + .catch((e) => { + message.destroy(); + message.error({ + content: `Failed to update ingestion source!: \n ${e.message || ''}`, + duration: 3, + }); + }); + } else { + // Create + createIngestionSource({ variables: { input } }) + .then((result) => { + message.loading({ content: 'Loading...', duration: 2 }); + setTimeout(() => { + refetch(); + message.success({ + content: `Successfully created ingestion source!`, + duration: 3, + }); + if (shouldRun && result.data?.createIngestionSource) { + executeIngestionSource(result.data.createIngestionSource); + } + }, 2000); + setIsBuildingSource(false); + setFocusSourceUrn(undefined); + resetState(); + // onCreateOrUpdateIngestionSourceSuccess(); + }) + .catch((e) => { + message.destroy(); + message.error({ + content: `Failed to create ingestion source!: \n ${e.message || ''}`, + duration: 3, + }); + }); + } + }; + + const onChangePage = (newPage: number) => { + setPage(newPage); + }; + const deleteIngestionSource = async (urn: string) => { removeIngestionSourceMutation({ variables: { urn }, @@ -214,7 +225,7 @@ export const IngestionSourceList = () => { }); }; - const onSubmit = (recipeBuilderState: SourceBuilderState, resetState: () => void) => { + const onSubmit = (recipeBuilderState: SourceBuilderState, resetState: () => void, shouldRun?: boolean) => { createOrUpdateIngestionSource( { type: recipeBuilderState.type as string, @@ -236,6 +247,7 @@ export const IngestionSourceList = () => { }, }, resetState, + shouldRun, ); }; diff --git a/datahub-web-react/src/app/ingest/source/builder/IngestionSourceBuilderModal.tsx b/datahub-web-react/src/app/ingest/source/builder/IngestionSourceBuilderModal.tsx index cce05903aa..f0ff9e2013 100644 --- a/datahub-web-react/src/app/ingest/source/builder/IngestionSourceBuilderModal.tsx +++ b/datahub-web-react/src/app/ingest/source/builder/IngestionSourceBuilderModal.tsx @@ -59,7 +59,7 @@ export enum IngestionSourceBuilderStep { type Props = { initialState?: SourceBuilderState; visible: boolean; - onSubmit?: (input: SourceBuilderState, resetState: () => void) => void; + onSubmit?: (input: SourceBuilderState, resetState: () => void, shouldRun?: boolean) => void; onCancel?: () => void; }; @@ -98,11 +98,15 @@ export const IngestionSourceBuilderModal = ({ initialState, visible, onSubmit, o onCancel?.(); }; - const submit = () => { - onSubmit?.(ingestionBuilderState, () => { - setStepStack([initialStep]); - setIngestionBuilderState({}); - }); + const submit = (shouldRun?: boolean) => { + onSubmit?.( + ingestionBuilderState, + () => { + setStepStack([initialStep]); + setIngestionBuilderState({}); + }, + shouldRun, + ); }; const currentStep = stepStack[stepStack.length - 1]; diff --git a/datahub-web-react/src/app/ingest/source/builder/NameSourceStep.tsx b/datahub-web-react/src/app/ingest/source/builder/NameSourceStep.tsx index cb924b6e7b..f7c5fbcb40 100644 --- a/datahub-web-react/src/app/ingest/source/builder/NameSourceStep.tsx +++ b/datahub-web-react/src/app/ingest/source/builder/NameSourceStep.tsx @@ -9,6 +9,10 @@ const ControlsContainer = styled.div` margin-top: 8px; `; +const SaveButton = styled(Button)` + margin-right: 15px; +`; + export const NameSourceStep = ({ state, updateState, prev, submit }: StepProps) => { const setName = (stagedName: string) => { const newState: SourceBuilderState = { @@ -40,9 +44,9 @@ export const NameSourceStep = ({ state, updateState, prev, submit }: StepProps) updateState(newState); }; - const onClickCreate = () => { + const onClickCreate = (shouldRun?: boolean) => { if (state.name !== undefined && state.name.length > 0) { - submit(); + submit(shouldRun); } }; @@ -93,9 +97,21 @@ export const NameSourceStep = ({ state, updateState, prev, submit }: StepProps) - +
+ 0)} + onClick={() => onClickCreate(false)} + > + Save + + +
); diff --git a/datahub-web-react/src/app/ingest/source/builder/types.ts b/datahub-web-react/src/app/ingest/source/builder/types.ts index 4936a13ae9..c2a2693c9e 100644 --- a/datahub-web-react/src/app/ingest/source/builder/types.ts +++ b/datahub-web-react/src/app/ingest/source/builder/types.ts @@ -21,7 +21,7 @@ export type StepProps = { updateState: (newState: SourceBuilderState) => void; goTo: (step: IngestionSourceBuilderStep) => void; prev?: () => void; - submit: () => void; + submit: (shouldRun?: boolean) => void; cancel: () => void; };