Skip to content

Commit

Permalink
feat: update connector builder project contributionInfo after contrib…
Browse files Browse the repository at this point in the history
…uting (#13897)
  • Loading branch information
erohmensing committed Sep 16, 2024
1 parent d8af275 commit d2114e5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from "react";
import { useFormContext, useWatch } from "react-hook-form";
import { FormattedMessage, useIntl } from "react-intl";
import { ReactMarkdown } from "react-markdown/lib/react-markdown";
import { useParams } from "react-router-dom";
import { useUpdateEffect } from "react-use";
import * as yup from "yup";

Expand All @@ -20,11 +21,13 @@ import { Spinner } from "components/ui/Spinner";
import { Text } from "components/ui/Text";

import {
BuilderProjectWithManifest,
GENERATE_CONTRIBUTION_NOTIFICATION_ID,
useBuilderCheckContribution,
useBuilderGenerateContribution,
useGetBuilderProjectBaseImage,
useListBuilderProjectVersions,
useUpdateBuilderProject,
} from "core/api";
import { CheckContributionRead } from "core/api/types/ConnectorBuilderClient";
import { useFormatError } from "core/errors";
Expand Down Expand Up @@ -427,6 +430,14 @@ const ContributeToAirbyte: React.FC<InnerModalProps> = ({ onClose, setPublishTyp
const [imageNameError, setImageNameError] = useState<string | null>(null);
const { mutateAsync: generateContribution, isLoading: isSubmittingContribution } = useBuilderGenerateContribution();

const { projectId } = useParams<{
projectId: string;
}>();
if (!projectId) {
throw new Error("Could not find project id in path");
}
const { mutateAsync: updateProject } = useUpdateBuilderProject(projectId);

const publishTypeSwitcher = <PublishTypeSwitcher selectedPublishType="marketplace" setPublishType={setPublishType} />;

if (isLoadingBaseImage) {
Expand Down Expand Up @@ -485,6 +496,14 @@ const ContributeToAirbyte: React.FC<InnerModalProps> = ({ onClose, setPublishTyp
manifest_yaml: convertJsonToYaml(jsonManifestWithDescription),
base_image: baseImage,
});
const newProject: BuilderProjectWithManifest = {
name: values.name,
manifest: jsonManifestWithDescription,
yamlManifest: convertJsonToYaml(jsonManifestWithDescription),
contributionPullRequestUrl: contribution.pull_request_url,
contributionActorDefinitionId: contribution.actor_definition_id,
};
await updateProject(newProject);
registerNotification({
id: GENERATE_CONTRIBUTION_NOTIFICATION_ID,
type: "success",
Expand Down
16 changes: 14 additions & 2 deletions airbyte-webapp/src/core/api/hooks/connectorBuilderProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export interface BuilderProjectWithManifest {
name: string;
manifest?: DeclarativeComponentSchema;
yamlManifest?: string;
contributionPullRequestUrl?: string;
contributionActorDefinitionId?: string;
}

export const useListBuilderProjects = () => {
Expand Down Expand Up @@ -263,9 +265,19 @@ export const useUpdateBuilderProject = (projectId: string) => {
const workspaceId = useCurrentWorkspaceId();

return useMutation<void, Error, BuilderProjectWithManifest>(
({ name, manifest, yamlManifest }) =>
({ name, manifest, yamlManifest, contributionActorDefinitionId, contributionPullRequestUrl }) =>
updateConnectorBuilderProject(
{ workspaceId, builderProjectId: projectId, builderProject: { name, draftManifest: manifest, yamlManifest } },
{
workspaceId,
builderProjectId: projectId,
builderProject: {
name,
draftManifest: manifest,
yamlManifest,
contributionActorDefinitionId,
contributionPullRequestUrl,
},
},
requestOptions
),
{
Expand Down

0 comments on commit d2114e5

Please sign in to comment.