mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +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 { 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 { TSecretMap } from "@app/services/secret-sync/secret-sync-types";
|
||||
|
||||
@@ -149,7 +149,9 @@ const putSecret = async (client: Octokit, secretSync: TGitHubSyncWithCredentials
|
||||
org: destinationConfig.org,
|
||||
...payload,
|
||||
visibility,
|
||||
selected_repository_ids: selectedRepositoryIds
|
||||
...(visibility === GitHubSyncVisibility.Selected && {
|
||||
selected_repository_ids: selectedRepositoryIds
|
||||
})
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -34,10 +34,20 @@ const GitHubSyncDestinationConfigSchema = z
|
||||
.superRefine((options, ctx) => {
|
||||
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({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "Select at least 1 repository",
|
||||
message: `Selected repositories is only supported for visibility "Selected"`,
|
||||
path: ["selectedRepositoryIds"]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
|
||||
}
|
||||
errorText={error?.message}
|
||||
isError={Boolean(error?.message)}
|
||||
label="Initial Sync Behavior"
|
||||
label="Import Behavior"
|
||||
>
|
||||
<Select
|
||||
value={value}
|
||||
|
||||
@@ -20,18 +20,13 @@ import {
|
||||
import { TSecretSyncForm } from "../schemas";
|
||||
|
||||
export const GitHubSyncFields = () => {
|
||||
const {
|
||||
control,
|
||||
formState: { errors },
|
||||
watch,
|
||||
setValue
|
||||
} = useFormContext<TSecretSyncForm & { destination: SecretSync.GitHub }>();
|
||||
|
||||
console.log("errors", errors, watch());
|
||||
const { control, watch, setValue } = useFormContext<
|
||||
TSecretSyncForm & { destination: SecretSync.GitHub }
|
||||
>();
|
||||
|
||||
const connectionId = useWatch({ name: "connection.id", control });
|
||||
const currentScope = watch("destinationConfig.scope");
|
||||
const currentVisibility = watch("destinationConfig.visibility", GitHubSyncVisibility.All);
|
||||
const currentVisibility = watch("destinationConfig.visibility");
|
||||
const currentOrg = watch("destinationConfig.org");
|
||||
const currentRepo = watch("destinationConfig.repo");
|
||||
const currentOwner = watch("destinationConfig.owner");
|
||||
@@ -70,7 +65,7 @@ export const GitHubSyncFields = () => {
|
||||
setValue("destinationConfig.org", "");
|
||||
setValue("destinationConfig.repo", "");
|
||||
setValue("destinationConfig.owner", "");
|
||||
setValue("destinationConfig.selectedRepositoryIds", []);
|
||||
setValue("destinationConfig.selectedRepositoryIds", undefined);
|
||||
}}
|
||||
/>
|
||||
<Controller
|
||||
@@ -134,6 +129,7 @@ export const GitHubSyncFields = () => {
|
||||
value={value}
|
||||
onValueChange={(val) => {
|
||||
onChange(val);
|
||||
setValue("destinationConfig.selectedRepositoryIds", undefined);
|
||||
}}
|
||||
className="w-full border border-mineshaft-500 capitalize"
|
||||
position="popper"
|
||||
@@ -194,6 +190,7 @@ export const GitHubSyncFields = () => {
|
||||
|
||||
onChange(repo?.name);
|
||||
setValue("destinationConfig.owner", repo?.owner.login ?? "");
|
||||
setValue("destinationConfig.env", "");
|
||||
}}
|
||||
options={repositories}
|
||||
placeholder="Select a repository..."
|
||||
|
||||
@@ -58,7 +58,7 @@ export const SecretSyncDetailsSection = ({ secretSync, onEditDetails }: Props) =
|
||||
)}
|
||||
{syncStatus === SecretSyncStatus.Failed && lastSyncMessage && (
|
||||
<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>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user