mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-10 05:26:44 +03:00
Type fix
This commit is contained in:
@@ -653,7 +653,9 @@ export function Organization() {
|
|||||||
loadingOrgIds={loadingOrgIds}
|
loadingOrgIds={loadingOrgIds}
|
||||||
onMirror={handleMirrorOrg}
|
onMirror={handleMirrorOrg}
|
||||||
onAddOrganization={() => setIsDialogOpen(true)}
|
onAddOrganization={() => setIsDialogOpen(true)}
|
||||||
onRefresh={() => fetchOrganizations(false)}
|
onRefresh={async () => {
|
||||||
|
await fetchOrganizations(false);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<AddOrganizationDialog
|
<AddOrganizationDialog
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
type RepositoryVisibility,
|
type RepositoryVisibility,
|
||||||
type RepoStatus,
|
type RepoStatus,
|
||||||
} from "@/types/Repository";
|
} from "@/types/Repository";
|
||||||
|
import { membershipRoleEnum } from "@/types/organizations";
|
||||||
import { Octokit } from "@octokit/rest";
|
import { Octokit } from "@octokit/rest";
|
||||||
import type { Config } from "@/types/config";
|
import type { Config } from "@/types/config";
|
||||||
import type { Organization, Repository } from "./db/schema";
|
import type { Organization, Repository } from "./db/schema";
|
||||||
@@ -22,13 +23,26 @@ export const getOrganizationConfig = async ({
|
|||||||
userId: string;
|
userId: string;
|
||||||
}): Promise<Organization | null> => {
|
}): Promise<Organization | null> => {
|
||||||
try {
|
try {
|
||||||
const [orgConfig] = await db
|
const result = await db
|
||||||
.select()
|
.select()
|
||||||
.from(organizations)
|
.from(organizations)
|
||||||
.where(and(eq(organizations.name, orgName), eq(organizations.userId, userId)))
|
.where(and(eq(organizations.name, orgName), eq(organizations.userId, userId)))
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
return orgConfig || null;
|
if (!result[0]) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate and cast the membershipRole to ensure type safety
|
||||||
|
const rawOrg = result[0];
|
||||||
|
const membershipRole = membershipRoleEnum.parse(rawOrg.membershipRole);
|
||||||
|
const status = repoStatusEnum.parse(rawOrg.status);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...rawOrg,
|
||||||
|
membershipRole,
|
||||||
|
status,
|
||||||
|
} as Organization;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error fetching organization config for ${orgName}:`, error);
|
console.error(`Error fetching organization config for ${orgName}:`, error);
|
||||||
return null;
|
return null;
|
||||||
@@ -113,7 +127,7 @@ export const getGiteaRepoOwner = ({
|
|||||||
|
|
||||||
// Get the mirror strategy - use preserveOrgStructure for backward compatibility
|
// Get the mirror strategy - use preserveOrgStructure for backward compatibility
|
||||||
const mirrorStrategy = config.giteaConfig.mirrorStrategy ||
|
const mirrorStrategy = config.giteaConfig.mirrorStrategy ||
|
||||||
(config.githubConfig.preserveOrgStructure ? "preserve" : "flat-user");
|
(config.giteaConfig.preserveOrgStructure ? "preserve" : "flat-user");
|
||||||
|
|
||||||
switch (mirrorStrategy) {
|
switch (mirrorStrategy) {
|
||||||
case "preserve":
|
case "preserve":
|
||||||
@@ -870,8 +884,8 @@ export async function mirrorGitHubOrgToGitea({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Get the mirror strategy - use preserveOrgStructure for backward compatibility
|
// Get the mirror strategy - use preserveOrgStructure for backward compatibility
|
||||||
const mirrorStrategy = config.giteaConfig?.mirrorStrategy ||
|
const mirrorStrategy = config.giteaConfig?.mirrorStrategy ||
|
||||||
(config.githubConfig?.preserveOrgStructure ? "preserve" : "flat-user");
|
(config.giteaConfig?.preserveOrgStructure ? "preserve" : "flat-user");
|
||||||
|
|
||||||
let giteaOrgId: number;
|
let giteaOrgId: number;
|
||||||
let targetOrgName: string;
|
let targetOrgName: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user