mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 21:27:31 +00:00
fix: various ui and github sync fixes
This commit is contained in:
@@ -2,7 +2,7 @@ import { Octokit } from "@octokit/rest";
|
|||||||
import sodium from "libsodium-wrappers";
|
import sodium from "libsodium-wrappers";
|
||||||
|
|
||||||
import { getGitHubClient } from "@app/services/app-connection/github";
|
import { getGitHubClient } from "@app/services/app-connection/github";
|
||||||
import { GitHubSyncScope } from "@app/services/secret-sync/github/github-sync-enums";
|
import { GitHubSyncScope, GitHubSyncVisibility } from "@app/services/secret-sync/github/github-sync-enums";
|
||||||
import { SECRET_SYNC_NAME_MAP } from "@app/services/secret-sync/secret-sync-maps";
|
import { SECRET_SYNC_NAME_MAP } from "@app/services/secret-sync/secret-sync-maps";
|
||||||
import { TSecretMap } from "@app/services/secret-sync/secret-sync-types";
|
import { TSecretMap } from "@app/services/secret-sync/secret-sync-types";
|
||||||
|
|
||||||
@@ -149,7 +149,9 @@ const putSecret = async (client: Octokit, secretSync: TGitHubSyncWithCredentials
|
|||||||
org: destinationConfig.org,
|
org: destinationConfig.org,
|
||||||
...payload,
|
...payload,
|
||||||
visibility,
|
visibility,
|
||||||
selected_repository_ids: selectedRepositoryIds
|
...(visibility === GitHubSyncVisibility.Selected && {
|
||||||
|
selected_repository_ids: selectedRepositoryIds
|
||||||
|
})
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,10 +34,20 @@ const GitHubSyncDestinationConfigSchema = z
|
|||||||
.superRefine((options, ctx) => {
|
.superRefine((options, ctx) => {
|
||||||
if (options.scope !== GitHubSyncScope.Organization) return;
|
if (options.scope !== GitHubSyncScope.Organization) return;
|
||||||
|
|
||||||
if (options.visibility === GitHubSyncVisibility.Selected && !options.selectedRepositoryIds?.length) {
|
if (options.visibility === GitHubSyncVisibility.Selected) {
|
||||||
|
if (!options.selectedRepositoryIds?.length)
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
message: "Select at least 1 repository",
|
||||||
|
path: ["selectedRepositoryIds"]
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.selectedRepositoryIds?.length) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
message: "Select at least 1 repository",
|
message: `Selected repositories is only supported for visibility "Selected"`,
|
||||||
path: ["selectedRepositoryIds"]
|
path: ["selectedRepositoryIds"]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
|
|||||||
}
|
}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
isError={Boolean(error?.message)}
|
isError={Boolean(error?.message)}
|
||||||
label="Initial Sync Behavior"
|
label="Import Behavior"
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
value={value}
|
value={value}
|
||||||
|
|||||||
+7
-10
@@ -20,18 +20,13 @@ import {
|
|||||||
import { TSecretSyncForm } from "../schemas";
|
import { TSecretSyncForm } from "../schemas";
|
||||||
|
|
||||||
export const GitHubSyncFields = () => {
|
export const GitHubSyncFields = () => {
|
||||||
const {
|
const { control, watch, setValue } = useFormContext<
|
||||||
control,
|
TSecretSyncForm & { destination: SecretSync.GitHub }
|
||||||
formState: { errors },
|
>();
|
||||||
watch,
|
|
||||||
setValue
|
|
||||||
} = useFormContext<TSecretSyncForm & { destination: SecretSync.GitHub }>();
|
|
||||||
|
|
||||||
console.log("errors", errors, watch());
|
|
||||||
|
|
||||||
const connectionId = useWatch({ name: "connection.id", control });
|
const connectionId = useWatch({ name: "connection.id", control });
|
||||||
const currentScope = watch("destinationConfig.scope");
|
const currentScope = watch("destinationConfig.scope");
|
||||||
const currentVisibility = watch("destinationConfig.visibility", GitHubSyncVisibility.All);
|
const currentVisibility = watch("destinationConfig.visibility");
|
||||||
const currentOrg = watch("destinationConfig.org");
|
const currentOrg = watch("destinationConfig.org");
|
||||||
const currentRepo = watch("destinationConfig.repo");
|
const currentRepo = watch("destinationConfig.repo");
|
||||||
const currentOwner = watch("destinationConfig.owner");
|
const currentOwner = watch("destinationConfig.owner");
|
||||||
@@ -70,7 +65,7 @@ export const GitHubSyncFields = () => {
|
|||||||
setValue("destinationConfig.org", "");
|
setValue("destinationConfig.org", "");
|
||||||
setValue("destinationConfig.repo", "");
|
setValue("destinationConfig.repo", "");
|
||||||
setValue("destinationConfig.owner", "");
|
setValue("destinationConfig.owner", "");
|
||||||
setValue("destinationConfig.selectedRepositoryIds", []);
|
setValue("destinationConfig.selectedRepositoryIds", undefined);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Controller
|
<Controller
|
||||||
@@ -134,6 +129,7 @@ export const GitHubSyncFields = () => {
|
|||||||
value={value}
|
value={value}
|
||||||
onValueChange={(val) => {
|
onValueChange={(val) => {
|
||||||
onChange(val);
|
onChange(val);
|
||||||
|
setValue("destinationConfig.selectedRepositoryIds", undefined);
|
||||||
}}
|
}}
|
||||||
className="w-full border border-mineshaft-500 capitalize"
|
className="w-full border border-mineshaft-500 capitalize"
|
||||||
position="popper"
|
position="popper"
|
||||||
@@ -194,6 +190,7 @@ export const GitHubSyncFields = () => {
|
|||||||
|
|
||||||
onChange(repo?.name);
|
onChange(repo?.name);
|
||||||
setValue("destinationConfig.owner", repo?.owner.login ?? "");
|
setValue("destinationConfig.owner", repo?.owner.login ?? "");
|
||||||
|
setValue("destinationConfig.env", "");
|
||||||
}}
|
}}
|
||||||
options={repositories}
|
options={repositories}
|
||||||
placeholder="Select a repository..."
|
placeholder="Select a repository..."
|
||||||
|
|||||||
+1
-1
@@ -58,7 +58,7 @@ export const SecretSyncDetailsSection = ({ secretSync, onEditDetails }: Props) =
|
|||||||
)}
|
)}
|
||||||
{syncStatus === SecretSyncStatus.Failed && lastSyncMessage && (
|
{syncStatus === SecretSyncStatus.Failed && lastSyncMessage && (
|
||||||
<SecretSyncLabel labelClassName="text-red" label="Last Sync Error">
|
<SecretSyncLabel labelClassName="text-red" label="Last Sync Error">
|
||||||
<p className="rounded bg-mineshaft-600 p-2 text-xs">{lastSyncMessage}</p>
|
<p className="break-words rounded bg-mineshaft-600 p-2 text-xs">{lastSyncMessage}</p>
|
||||||
</SecretSyncLabel>
|
</SecretSyncLabel>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user