(null);
-
const { data: integrationAuthApps, isLoading: isintegrationAuthAppsLoading } = useGetIntegrationAuthApps({
integrationAuthId: (integrationAuthId as string) ?? "",
...(targetTeamId ? { teamId: targetTeamId } : {})
@@ -51,26 +92,20 @@ export default function GitLabCreateIntegrationPage() {
(integrationAuthId as string) ?? ""
);
- const [targetEntity, setTargetEntity] = useState(gitLabEntities[0].value);
- const [selectedSourceEnvironment, setSelectedSourceEnvironment] = useState("");
- const [secretPath, setSecretPath] = useState("/");
- const [targetAppId, setTargetAppId] = useState("");
- const [targetEnvironment, setTargetEnvironment] = useState("");
-
const [isLoading, setIsLoading] = useState(false);
-
+
useEffect(() => {
if (workspace) {
- setSelectedSourceEnvironment(workspace.environments[0].slug);
+ setValue("selectedSourceEnvironment", workspace.environments[0].slug);
}
}, [workspace]);
useEffect(() => {
if (integrationAuthApps) {
if (integrationAuthApps.length > 0) {
- setTargetAppId(integrationAuthApps[0].appId as string);
+ setValue("targetAppId", String(integrationAuthApps[0].appId as string));
} else {
- setTargetAppId("none");
+ setValue("targetAppId", "none");
}
}
}, [integrationAuthApps]);
@@ -80,46 +115,60 @@ export default function GitLabCreateIntegrationPage() {
if (integrationAuthTeams) {
if (integrationAuthTeams.length > 0) {
// case: user is part of at least 1 group in GitLab
- setTargetTeamId(integrationAuthTeams[0].teamId);
+ setValue("targetTeamId", String(integrationAuthTeams[0].teamId));
} else {
// case: user is not part of any groups in GitLab
- setTargetTeamId("none");
+ setValue("targetTeamId", "none");
}
}
} else if (targetEntity === "individual") {
- setTargetTeamId(null);
+ setValue("targetTeamId", undefined);
}
}, [targetEntity, integrationAuthTeams]);
- const handleButtonClick = async () => {
+ const onFormSubmit = async ({
+ selectedSourceEnvironment: sse,
+ secretPath,
+ targetAppId,
+ targetEnvironment,
+ secretPrefix,
+ secretSuffix
+ }: FormData) => {
try {
setIsLoading(true);
if (!integrationAuth?._id) return;
-
+
await mutateAsync({
integrationAuthId: integrationAuth?._id,
isActive: true,
- app: integrationAuthApps?.find((integrationAuthApp) => integrationAuthApp.appId === targetAppId)?.name,
+ app: integrationAuthApps?.find((integrationAuthApp) => String(integrationAuthApp.appId) === targetAppId)?.name,
appId: String(targetAppId),
- sourceEnvironment: selectedSourceEnvironment,
+ sourceEnvironment: sse,
targetEnvironment: targetEnvironment === "" ? "*" : targetEnvironment,
- secretPath
+ secretPath,
+ metadata: {
+ secretPrefix,
+ secretSuffix
+ }
});
setIsLoading(false);
router.push(`/integrations/${localStorage.getItem("projectData.id")}`);
} catch (err) {
console.error(err);
+ setIsLoading(false);
}
- };
+ }
return integrationAuth &&
workspace &&
selectedSourceEnvironment &&
integrationAuthApps &&
- integrationAuthTeams &&
- targetAppId ? (
-
+ integrationAuthTeams ? (
+
-
-
-
-
- setSecretPath(evt.target.value)}
- placeholder="Provide a path, default is /"
- />
-
-
-
-
- {targetEntity === "group" && targetTeamId && (
-
-
-
- )}
-
-
-
-
- setTargetEnvironment(e.target.value)}
- />
-
+
+ (
+
+
+
+ )}
+ />
+ (
+
+
+
+ )}
+ />
+ (
+
+
+
+ )}
+ />
+ {targetEntity === "group" && targetTeamId && (
+ (
+
+
+
+ )}
+ />
+ )}
+ {
+ return (
+
+
+
+ )}}
+ />
+ (
+
+
+
+ )}
+ />
+
+
+
+
+
+ (
+
+
+
+ )}
+ />
+ (
+
+
+
+ )}
+ />
+
+
+
-
+
Pro Tips
After creating an integration, your secrets will start syncing immediately. This might cause an unexpected override of current secrets in GitLab with secrets from Infisical.
-