fix(bug-report): correction de la récupération des valeurs dans les modals de bug et de suggestion
This commit is contained in:
parent
9731e10ee0
commit
10558c47ec
1 changed files with 46 additions and 39 deletions
|
|
@ -36,9 +36,6 @@ def save_report(issue_iid, user_id):
|
||||||
|
|
||||||
class BugReportModal(disnake.ui.Modal):
|
class BugReportModal(disnake.ui.Modal):
|
||||||
def __init__(self, priority_choice):
|
def __init__(self, priority_choice):
|
||||||
super().__init__(title="Signaler un Bug", components=[self.bug_title, self.description])
|
|
||||||
|
|
||||||
# Sécurisation: éviter les valeurs None qui finissent dans GitLab
|
|
||||||
if priority_choice is None:
|
if priority_choice is None:
|
||||||
self.priority_choice = type(
|
self.priority_choice = type(
|
||||||
"PriorityChoice",
|
"PriorityChoice",
|
||||||
|
|
@ -48,32 +45,38 @@ class BugReportModal(disnake.ui.Modal):
|
||||||
else:
|
else:
|
||||||
self.priority_choice = priority_choice
|
self.priority_choice = priority_choice
|
||||||
|
|
||||||
bug_title = disnake.ui.TextInput(
|
super().__init__(
|
||||||
label="Titre du bug",
|
title="Signaler un Bug",
|
||||||
placeholder="Décrivez brièvement le problème...",
|
components=[
|
||||||
required=True,
|
disnake.ui.TextInput(
|
||||||
max_length=100,
|
label="Titre du bug",
|
||||||
)
|
placeholder="Décrivez brièvement le problème...",
|
||||||
|
custom_id="bug_title",
|
||||||
|
required=True,
|
||||||
|
max_length=100,
|
||||||
|
),
|
||||||
|
disnake.ui.TextInput(
|
||||||
|
label="Description détaillée",
|
||||||
|
style=disnake.TextInputStyle.paragraph,
|
||||||
|
placeholder="Que s'est-il passé ? Comment reproduire le bug ?",
|
||||||
|
custom_id="bug_description",
|
||||||
|
required=True,
|
||||||
|
max_length=1000,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
description = disnake.ui.TextInput(
|
async def callback(self, interaction: disnake.ModalInteraction):
|
||||||
label="Description détaillée",
|
|
||||||
style=disnake.TextInputStyle.paragraph,
|
|
||||||
placeholder="Que s'est-il passé ? Comment reproduire le bug ?",
|
|
||||||
required=True,
|
|
||||||
max_length=1000,
|
|
||||||
)
|
|
||||||
|
|
||||||
async def callback(self, interaction: disnake.Interaction):
|
|
||||||
await interaction.response.send_message("Envoi de votre rapport de bug à GitLab...", ephemeral=True)
|
await interaction.response.send_message("Envoi de votre rapport de bug à GitLab...", ephemeral=True)
|
||||||
|
|
||||||
bug_title = (self.bug_title.value or "").strip()
|
bug_title = (interaction.text_values.get("bug_title") or "").strip()
|
||||||
if not bug_title:
|
if not bug_title:
|
||||||
bug_title = "Sans titre"
|
bug_title = "Sans titre"
|
||||||
|
|
||||||
priority_name = getattr(self.priority_choice, "name", None) or "Normal"
|
priority_name = getattr(self.priority_choice, "name", None) or "Normal"
|
||||||
priority_value = getattr(self.priority_choice, "value", None) or "Normal"
|
priority_value = getattr(self.priority_choice, "value", None) or "Normal"
|
||||||
|
|
||||||
description_value = self.description.value or ""
|
description_value = interaction.text_values.get("bug_description") or ""
|
||||||
|
|
||||||
description_text = f"**Rapporté par:** {interaction.user} ({interaction.user.id})\n"
|
description_text = f"**Rapporté par:** {interaction.user} ({interaction.user.id})\n"
|
||||||
description_text += f"**Priorité:** {priority_name}\n\n"
|
description_text += f"**Priorité:** {priority_name}\n\n"
|
||||||
|
|
@ -105,28 +108,32 @@ class BugReportModal(disnake.ui.Modal):
|
||||||
|
|
||||||
class FeatureSuggestionModal(disnake.ui.Modal):
|
class FeatureSuggestionModal(disnake.ui.Modal):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(title="Suggérer une fonctionnalité", components=[self.suggestion_title, self.description])
|
super().__init__(
|
||||||
|
title="Suggérer une fonctionnalité",
|
||||||
|
components=[
|
||||||
|
disnake.ui.TextInput(
|
||||||
|
label="Titre de la suggestion",
|
||||||
|
placeholder="Que voulez-vous ajouter ?",
|
||||||
|
custom_id="suggestion_title",
|
||||||
|
required=True,
|
||||||
|
max_length=100,
|
||||||
|
),
|
||||||
|
disnake.ui.TextInput(
|
||||||
|
label="Détails de la fonctionnalité",
|
||||||
|
style=disnake.TextInputStyle.paragraph,
|
||||||
|
placeholder="Décrivez comment cela devrait fonctionner...",
|
||||||
|
custom_id="suggestion_description",
|
||||||
|
required=True,
|
||||||
|
max_length=1000,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
suggestion_title = disnake.ui.TextInput(
|
async def callback(self, interaction: disnake.ModalInteraction):
|
||||||
label="Titre de la suggestion",
|
|
||||||
placeholder="Que voulez-vous ajouter ?",
|
|
||||||
required=True,
|
|
||||||
max_length=100,
|
|
||||||
)
|
|
||||||
|
|
||||||
description = disnake.ui.TextInput(
|
|
||||||
label="Détails de la fonctionnalité",
|
|
||||||
style=disnake.TextInputStyle.paragraph,
|
|
||||||
placeholder="Décrivez comment cela devrait fonctionner...",
|
|
||||||
required=True,
|
|
||||||
max_length=1000,
|
|
||||||
)
|
|
||||||
|
|
||||||
async def callback(self, interaction: disnake.Interaction):
|
|
||||||
await interaction.response.send_message("Envoi de votre suggestion à GitLab...", ephemeral=True)
|
await interaction.response.send_message("Envoi de votre suggestion à GitLab...", ephemeral=True)
|
||||||
|
|
||||||
suggestion_title = (self.suggestion_title.value or "").strip() or "Sans titre"
|
suggestion_title = (interaction.text_values.get("suggestion_title") or "").strip() or "Sans titre"
|
||||||
description_value = self.description.value or ""
|
description_value = interaction.text_values.get("suggestion_description") or ""
|
||||||
|
|
||||||
description_text = f"**Suggéré par:** {interaction.user} ({interaction.user.id})\n\n"
|
description_text = f"**Suggéré par:** {interaction.user} ({interaction.user.id})\n\n"
|
||||||
description_text += f"**Description:**\n{description_value}"
|
description_text += f"**Description:**\n{description_value}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue