feat : add Gitea repo selector to ProjectDrawer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-13 14:02:57 +01:00
parent f8c94cb177
commit 027e31e139

View File

@@ -33,6 +33,16 @@
<ColorPicker v-model="form.color" />
</div>
<div v-if="giteaRepos.length" class="mt-4">
<MalioSelect
v-model="form.giteaRepoFullName"
:options="giteaRepoOptions"
label="Dépôt Gitea"
empty-option-label="Aucun dépôt"
min-width="w-full"
/>
</div>
<div class="mt-6 flex justify-end">
<button
type="submit"
@@ -49,7 +59,9 @@
<script setup lang="ts">
import type { Project, ProjectWrite } from '~/services/dto/project'
import type { Client } from '~/services/dto/client'
import type { GiteaRepository } from '~/services/dto/gitea'
import { useProjectService } from '~/services/projects'
import { useGiteaService } from '~/services/gitea'
const props = defineProps<{
modelValue: boolean
@@ -70,12 +82,20 @@ const isOpen = computed({
const isEditing = computed(() => !!props.project)
const isSubmitting = ref(false)
const { listRepositories } = useGiteaService()
const giteaRepos = ref<GiteaRepository[]>([])
const giteaRepoOptions = computed(() =>
giteaRepos.value.map(r => ({ label: r.fullName, value: r.fullName }))
)
const form = reactive({
code: '',
name: '',
description: '',
color: '#222783',
clientId: null as number | null,
giteaRepoFullName: null as string | null,
})
const touched = reactive({
@@ -95,12 +115,16 @@ watch(() => props.modelValue, (open) => {
form.description = props.project.description ?? ''
form.color = props.project.color ?? '#222783'
form.clientId = props.project.client?.id ?? null
form.giteaRepoFullName = props.project?.giteaOwner && props.project?.giteaRepo
? `${props.project.giteaOwner}/${props.project.giteaRepo}`
: null
} else {
form.code = ''
form.name = ''
form.description = ''
form.color = '#222783'
form.clientId = null
form.giteaRepoFullName = null
}
touched.code = false
touched.name = false
@@ -124,6 +148,15 @@ async function handleSubmit() {
client: form.clientId ? `/api/clients/${form.clientId}` : null,
}
if (form.giteaRepoFullName) {
const [owner, repo] = form.giteaRepoFullName.split('/')
payload.giteaOwner = owner
payload.giteaRepo = repo
} else {
payload.giteaOwner = null
payload.giteaRepo = null
}
if (isEditing.value && props.project) {
await update(props.project.id, payload)
} else {
@@ -137,4 +170,12 @@ async function handleSubmit() {
isSubmitting.value = false
}
}
onMounted(async () => {
try {
giteaRepos.value = await listRepositories()
} catch {
// Gitea not configured, ignore
}
})
</script>