fix: various ui and github sync fixes

This commit is contained in:
Scott Wilson
2025-01-15 22:20:33 -08:00
parent 473efa91f0
commit e78ad1147b
5 changed files with 25 additions and 16 deletions

View File

@@ -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;
}

View File

@@ -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"]
});
}