mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 10:26:35 +00:00
Update use repo id to avoid ambiguous repo name
This commit is contained in:
@@ -66,6 +66,11 @@ const schema = yup.object({
|
|||||||
then: yup.array(yup.string().required()).min(1, "Select at least one repositories")
|
then: yup.array(yup.string().required()).min(1, "Select at least one repositories")
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
repoId: yup.mixed().when("scope", {
|
||||||
|
is: "github-env",
|
||||||
|
then: yup.string().required("Repository is required")
|
||||||
|
}),
|
||||||
|
|
||||||
repoName: yup.mixed().when("scope", {
|
repoName: yup.mixed().when("scope", {
|
||||||
is: "github-env",
|
is: "github-env",
|
||||||
then: yup.string().required("Repository is required")
|
then: yup.string().required("Repository is required")
|
||||||
@@ -137,15 +142,13 @@ export default function GitHubCreateIntegrationPage() {
|
|||||||
}
|
}
|
||||||
}, [workspace]);
|
}, [workspace]);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (integrationAuthGithubEnvs && integrationAuthGithubEnvs?.length > 0) {
|
if (integrationAuthGithubEnvs && integrationAuthGithubEnvs?.length > 0) {
|
||||||
setValue("envId", integrationAuthGithubEnvs[0].envId);
|
setValue("envId", integrationAuthGithubEnvs[0].envId);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
setValue("envId", undefined);
|
setValue("envId", undefined);
|
||||||
}
|
}
|
||||||
}, [integrationAuthGithubEnvs])
|
}, [integrationAuthGithubEnvs]);
|
||||||
|
|
||||||
const onFormSubmit = async (data: FormData) => {
|
const onFormSubmit = async (data: FormData) => {
|
||||||
try {
|
try {
|
||||||
@@ -187,8 +190,7 @@ export default function GitHubCreateIntegrationPage() {
|
|||||||
secretPath: data.secretPath,
|
secretPath: data.secretPath,
|
||||||
sourceEnvironment: data.selectedSourceEnvironment,
|
sourceEnvironment: data.selectedSourceEnvironment,
|
||||||
scope: data.scope,
|
scope: data.scope,
|
||||||
owner: integrationAuthOrgs?.find(e=>e.orgId === data.orgId)?.name, // repo owner
|
owner: integrationAuthOrgs?.find((e) => e.orgId === data.orgId)?.name,
|
||||||
targetServiceId: data.orgId, // github org id
|
|
||||||
metadata: {
|
metadata: {
|
||||||
secretSuffix: data.secretSuffix
|
secretSuffix: data.secretSuffix
|
||||||
}
|
}
|
||||||
@@ -202,9 +204,11 @@ export default function GitHubCreateIntegrationPage() {
|
|||||||
secretPath: data.secretPath,
|
secretPath: data.secretPath,
|
||||||
sourceEnvironment: data.selectedSourceEnvironment,
|
sourceEnvironment: data.selectedSourceEnvironment,
|
||||||
scope: data.scope,
|
scope: data.scope,
|
||||||
app: repoName, // repo name // TODO: CHANGE THIS STATE INTO YUP
|
app: repoName,
|
||||||
owner: repoOwner, // repo owner
|
owner: repoOwner,
|
||||||
targetEnvironmentId: data.envId, // github environment id
|
targetService: "Repository",
|
||||||
|
targetServiceId: data.repoId, // github repo id is needed for sync secret
|
||||||
|
targetEnvironmentId: data.envId,
|
||||||
metadata: {
|
metadata: {
|
||||||
secretSuffix: data.secretSuffix
|
secretSuffix: data.secretSuffix
|
||||||
}
|
}
|
||||||
@@ -356,7 +360,10 @@ export default function GitHubCreateIntegrationPage() {
|
|||||||
<div className="inline-flex w-full cursor-pointer items-center justify-between rounded-md border border-mineshaft-600 bg-mineshaft-900 px-3 py-2 font-inter text-sm font-normal text-bunker-200 outline-none data-[placeholder]:text-mineshaft-200">
|
<div className="inline-flex w-full cursor-pointer items-center justify-between rounded-md border border-mineshaft-600 bg-mineshaft-900 px-3 py-2 font-inter text-sm font-normal text-bunker-200 outline-none data-[placeholder]:text-mineshaft-200">
|
||||||
{repoIds.length === 1
|
{repoIds.length === 1
|
||||||
? integrationAuthApps?.reduce(
|
? integrationAuthApps?.reduce(
|
||||||
(acc, { appId, name, owner }) => repoIds[0] === appId ? `${owner}/${name}`: acc, "")
|
(acc, { appId, name, owner }) =>
|
||||||
|
repoIds[0] === appId ? `${owner}/${name}` : acc,
|
||||||
|
""
|
||||||
|
)
|
||||||
: `${repoIds.length} repositories selected`}
|
: `${repoIds.length} repositories selected`}
|
||||||
<FontAwesomeIcon icon={faAngleDown} className="text-xs" />
|
<FontAwesomeIcon icon={faAngleDown} className="text-xs" />
|
||||||
</div>
|
</div>
|
||||||
@@ -448,7 +455,7 @@ export default function GitHubCreateIntegrationPage() {
|
|||||||
{scope === "github-env" && (
|
{scope === "github-env" && (
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="repoName"
|
name="repoId"
|
||||||
render={({ field: { onChange, ...field }, fieldState: { error } }) => (
|
render={({ field: { onChange, ...field }, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl
|
||||||
label="Repository"
|
label="Repository"
|
||||||
@@ -458,12 +465,9 @@ export default function GitHubCreateIntegrationPage() {
|
|||||||
<Select
|
<Select
|
||||||
value={field.value}
|
value={field.value}
|
||||||
onValueChange={(e) => {
|
onValueChange={(e) => {
|
||||||
setValue("repoName", e);
|
const selectedRepo = integrationAuthApps.find((app) => app.appId === e);
|
||||||
setValue(
|
setValue("repoName", selectedRepo?.name);
|
||||||
"repoOwner",
|
setValue("repoOwner", selectedRepo?.owner);
|
||||||
(integrationAuthApps.find((app) => app.name === e)
|
|
||||||
?.owner as string) || ""
|
|
||||||
);
|
|
||||||
onChange(e);
|
onChange(e);
|
||||||
}}
|
}}
|
||||||
className="w-full border border-mineshaft-500"
|
className="w-full border border-mineshaft-500"
|
||||||
@@ -472,7 +476,7 @@ export default function GitHubCreateIntegrationPage() {
|
|||||||
integrationAuthApps.map((app) => {
|
integrationAuthApps.map((app) => {
|
||||||
return (
|
return (
|
||||||
<SelectItem
|
<SelectItem
|
||||||
value={app.name as string}
|
value={app.appId as string}
|
||||||
key={`repo-id-${app.appId}`}
|
key={`repo-id-${app.appId}`}
|
||||||
className="w-[28.4rem] text-sm"
|
className="w-[28.4rem] text-sm"
|
||||||
>
|
>
|
||||||
@@ -597,7 +601,7 @@ export default function GitHubCreateIntegrationPage() {
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex h-max max-w-md flex-col rounded-md border border-mineshaft-600 bg-mineshaft-800 p-6 text-center text-mineshaft-200">
|
<div className="flex h-max max-w-md flex-col rounded-md border border-mineshaft-600 bg-mineshaft-800 p-6 text-center text-mineshaft-200">
|
||||||
<FontAwesomeIcon icon={faBugs} className="inline li my-2 text-6xl" />
|
<FontAwesomeIcon icon={faBugs} className="li my-2 inline text-6xl" />
|
||||||
<p>
|
<p>
|
||||||
Something went wrong. Please contact{" "}
|
Something went wrong. Please contact{" "}
|
||||||
<a
|
<a
|
||||||
|
|||||||
Reference in New Issue
Block a user