mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Fix Gitea repository integration and preview compose display
This commit is contained in:
@@ -95,6 +95,13 @@ export const SaveGiteaProviderCompose = ({ composeId }: Props) => {
|
|||||||
const repository = form.watch("repository");
|
const repository = form.watch("repository");
|
||||||
const giteaId = form.watch("giteaId");
|
const giteaId = form.watch("giteaId");
|
||||||
|
|
||||||
|
const { data: giteaUrl } = api.gitea.getGiteaUrl.useQuery(
|
||||||
|
{ giteaId },
|
||||||
|
{
|
||||||
|
enabled: !!giteaId,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
console.log(repository);
|
console.log(repository);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -128,21 +135,25 @@ export const SaveGiteaProviderCompose = ({ composeId }: Props) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
console.log(data.giteaRepository);
|
// Find the repository in the repositories list to get the correct ID
|
||||||
form.reset({
|
const currentRepo = repositories?.find(
|
||||||
branch: data.giteaBranch || "",
|
(repo) => repo.name === data.giteaRepository && repo.owner.username === data.giteaOwner
|
||||||
repository: {
|
);
|
||||||
repo: data.giteaRepository || "",
|
|
||||||
owner: data.giteaOwner || "",
|
form.reset({
|
||||||
id: null,
|
branch: data.giteaBranch || "",
|
||||||
giteaPathNamespace: "",
|
repository: {
|
||||||
},
|
repo: data.giteaRepository || "",
|
||||||
composePath: data.composePath,
|
owner: data.giteaOwner || "",
|
||||||
giteaId: data.giteaId || "",
|
id: currentRepo?.id || null,
|
||||||
watchPaths: data.watchPaths || [],
|
giteaPathNamespace: currentRepo?.url || "",
|
||||||
});
|
},
|
||||||
|
composePath: data.composePath,
|
||||||
|
giteaId: data.giteaId || "",
|
||||||
|
watchPaths: data.watchPaths || [],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [data, form]);
|
}, [data, form, repositories]);
|
||||||
|
|
||||||
const onSubmit = async (data: GiteaProvider) => {
|
const onSubmit = async (data: GiteaProvider) => {
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
@@ -224,7 +235,7 @@ export const SaveGiteaProviderCompose = ({ composeId }: Props) => {
|
|||||||
<FormLabel>Repository</FormLabel>
|
<FormLabel>Repository</FormLabel>
|
||||||
{field.value.owner && field.value.repo && (
|
{field.value.owner && field.value.repo && (
|
||||||
<Link
|
<Link
|
||||||
href={`https://gitea.com/${field.value.owner}/${field.value.repo}`}
|
href={`${giteaUrl}/${field.value.owner}/${field.value.repo}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="flex items-center gap-1 text-sm text-muted-foreground hover:text-primary"
|
className="flex items-center gap-1 text-sm text-muted-foreground hover:text-primary"
|
||||||
@@ -463,7 +474,7 @@ export const SaveGiteaProviderCompose = ({ composeId }: Props) => {
|
|||||||
) as HTMLInputElement;
|
) as HTMLInputElement;
|
||||||
const path = input.value.trim();
|
const path = input.value.trim();
|
||||||
if (path) {
|
if (path) {
|
||||||
field.onChange([...field.value, path]);
|
field.onChange([...(field.value || []), path]);
|
||||||
input.value = "";
|
input.value = "";
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ export const ShowConvertedCompose = ({ composeId }: Props) => {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{compose !== null ? (
|
||||||
<pre>
|
<pre>
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
value={compose || ""}
|
value={compose || ""}
|
||||||
@@ -91,6 +92,11 @@ export const ShowConvertedCompose = ({ composeId }: Props) => {
|
|||||||
height="50rem"
|
height="50rem"
|
||||||
/>
|
/>
|
||||||
</pre>
|
</pre>
|
||||||
|
) : (
|
||||||
|
<div className="py-4 text-center text-muted-foreground">
|
||||||
|
No compose file available. Make sure at least one domain is configured for this project.
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -216,4 +216,31 @@ export const giteaRouter = createTRPCRouter({
|
|||||||
|
|
||||||
return { success: true };
|
return { success: true };
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
getGiteaUrl: protectedProcedure
|
||||||
|
.input(apiFindOneGitea)
|
||||||
|
.query(async ({ input, ctx }) => {
|
||||||
|
const { giteaId } = input;
|
||||||
|
|
||||||
|
if (!giteaId) {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: "BAD_REQUEST",
|
||||||
|
message: "Gitea provider ID is required.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const giteaProvider = await findGiteaById(giteaId);
|
||||||
|
if (
|
||||||
|
giteaProvider.gitProvider.organizationId !==
|
||||||
|
ctx.session.activeOrganizationId
|
||||||
|
) {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: "UNAUTHORIZED",
|
||||||
|
message: "You are not allowed to access this Gitea provider",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the base URL of the Gitea instance
|
||||||
|
return giteaProvider.giteaUrl;
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user