feat : add Gitea repo selector to ProjectDrawer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,16 @@
|
|||||||
<ColorPicker v-model="form.color" />
|
<ColorPicker v-model="form.color" />
|
||||||
</div>
|
</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">
|
<div class="mt-6 flex justify-end">
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
@@ -49,7 +59,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Project, ProjectWrite } from '~/services/dto/project'
|
import type { Project, ProjectWrite } from '~/services/dto/project'
|
||||||
import type { Client } from '~/services/dto/client'
|
import type { Client } from '~/services/dto/client'
|
||||||
|
import type { GiteaRepository } from '~/services/dto/gitea'
|
||||||
import { useProjectService } from '~/services/projects'
|
import { useProjectService } from '~/services/projects'
|
||||||
|
import { useGiteaService } from '~/services/gitea'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: boolean
|
modelValue: boolean
|
||||||
@@ -70,12 +82,20 @@ const isOpen = computed({
|
|||||||
const isEditing = computed(() => !!props.project)
|
const isEditing = computed(() => !!props.project)
|
||||||
const isSubmitting = ref(false)
|
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({
|
const form = reactive({
|
||||||
code: '',
|
code: '',
|
||||||
name: '',
|
name: '',
|
||||||
description: '',
|
description: '',
|
||||||
color: '#222783',
|
color: '#222783',
|
||||||
clientId: null as number | null,
|
clientId: null as number | null,
|
||||||
|
giteaRepoFullName: null as string | null,
|
||||||
})
|
})
|
||||||
|
|
||||||
const touched = reactive({
|
const touched = reactive({
|
||||||
@@ -95,12 +115,16 @@ watch(() => props.modelValue, (open) => {
|
|||||||
form.description = props.project.description ?? ''
|
form.description = props.project.description ?? ''
|
||||||
form.color = props.project.color ?? '#222783'
|
form.color = props.project.color ?? '#222783'
|
||||||
form.clientId = props.project.client?.id ?? null
|
form.clientId = props.project.client?.id ?? null
|
||||||
|
form.giteaRepoFullName = props.project?.giteaOwner && props.project?.giteaRepo
|
||||||
|
? `${props.project.giteaOwner}/${props.project.giteaRepo}`
|
||||||
|
: null
|
||||||
} else {
|
} else {
|
||||||
form.code = ''
|
form.code = ''
|
||||||
form.name = ''
|
form.name = ''
|
||||||
form.description = ''
|
form.description = ''
|
||||||
form.color = '#222783'
|
form.color = '#222783'
|
||||||
form.clientId = null
|
form.clientId = null
|
||||||
|
form.giteaRepoFullName = null
|
||||||
}
|
}
|
||||||
touched.code = false
|
touched.code = false
|
||||||
touched.name = false
|
touched.name = false
|
||||||
@@ -124,6 +148,15 @@ async function handleSubmit() {
|
|||||||
client: form.clientId ? `/api/clients/${form.clientId}` : null,
|
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) {
|
if (isEditing.value && props.project) {
|
||||||
await update(props.project.id, payload)
|
await update(props.project.id, payload)
|
||||||
} else {
|
} else {
|
||||||
@@ -137,4 +170,12 @@ async function handleSubmit() {
|
|||||||
isSubmitting.value = false
|
isSubmitting.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
giteaRepos.value = await listRepositories()
|
||||||
|
} catch {
|
||||||
|
// Gitea not configured, ignore
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user