1
This commit is contained in:
parent
04a852bdb2
commit
77aa2eb616
@ -72,10 +72,10 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
|
||||
language: DevelopmentLanguageTypeEnum.JAVA,
|
||||
enabled: true,
|
||||
sort: 0,
|
||||
gitInstanceId: undefined,
|
||||
externalSystemId: undefined,
|
||||
repoGroupId: undefined,
|
||||
repoProjectId: undefined,
|
||||
projectGroupId: undefined,
|
||||
projectGroupId,
|
||||
},
|
||||
});
|
||||
|
||||
@ -112,12 +112,12 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
|
||||
language: initialValues.language,
|
||||
enabled: initialValues.enabled,
|
||||
sort: initialValues.sort,
|
||||
gitInstanceId: initialValues.gitInstanceId,
|
||||
externalSystemId: initialValues.externalSystemId,
|
||||
repoGroupId: initialValues.repoGroupId,
|
||||
repoProjectId: initialValues.repoProjectId,
|
||||
projectGroupId: initialValues.projectGroupId,
|
||||
});
|
||||
const gitInstance = gitInstances.find(instance => instance.id === initialValues.gitInstanceId);
|
||||
const gitInstance = gitInstances.find(instance => instance.id === initialValues.externalSystemId);
|
||||
if (gitInstance) {
|
||||
setSelectedGitInstance(gitInstance);
|
||||
}
|
||||
@ -125,11 +125,11 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
|
||||
}, [initialValues, form, gitInstances]);
|
||||
|
||||
// 当选择Git实例时,获取对应的仓库组列表
|
||||
const handleGitInstanceChange = (gitInstanceId: number) => {
|
||||
const handleGitInstanceChange = (externalSystemId: number) => {
|
||||
form.setValue('repoGroupId', undefined);
|
||||
form.setValue('repoProjectId', undefined);
|
||||
setRepositoryProjects([]);
|
||||
fetchRepositoryGroups(gitInstanceId);
|
||||
fetchRepositoryGroups(externalSystemId);
|
||||
};
|
||||
|
||||
const fetchRepositoryGroups = async (externalSystemId: number) => {
|
||||
@ -143,6 +143,7 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: ApplicationFormValues) => {
|
||||
console.log('Form submitted with values:', values);
|
||||
try {
|
||||
if (isEdit) {
|
||||
await updateApplication({
|
||||
@ -164,10 +165,13 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
|
||||
<DialogHeader className="pb-4">
|
||||
<DialogTitle>{isEdit ? '编辑' : '新建'}应用</DialogTitle>
|
||||
</DialogHeader>
|
||||
<ScrollArea className="flex-1 -mx-6">
|
||||
<div className="px-6">
|
||||
<Form {...form}>
|
||||
<form id="applicationForm" onSubmit={form.handleSubmit(handleSubmit)} className="space-y-4">
|
||||
<Form {...form}>
|
||||
<form
|
||||
id="applicationForm"
|
||||
className="space-y-4 flex flex-col h-full"
|
||||
>
|
||||
<ScrollArea className="flex-1 -mx-6">
|
||||
<div className="px-6 space-y-4">
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
@ -233,7 +237,7 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="gitInstanceId"
|
||||
name="externalSystemId"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Git实例</FormLabel>
|
||||
@ -284,7 +288,7 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
|
||||
<Button
|
||||
variant="outline"
|
||||
role="combobox"
|
||||
disabled={!form.watch('gitInstanceId')}
|
||||
disabled={!form.watch('externalSystemId')}
|
||||
className={cn(
|
||||
"w-full justify-between",
|
||||
!field.value && "text-muted-foreground"
|
||||
@ -294,7 +298,7 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
|
||||
? repositoryGroups.find(
|
||||
(group) => group.id === field.value
|
||||
)?.fullName || "请选择代码仓库组"
|
||||
: !form.watch('gitInstanceId')
|
||||
: !form.watch('externalSystemId')
|
||||
? "请先选择Git实例"
|
||||
: "请选择代码仓库组"}
|
||||
<ChevronDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||
@ -511,18 +515,29 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
|
||||
/>
|
||||
|
||||
<div className="h-4" />
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
<DialogFooter className="pt-4">
|
||||
<Button type="button" variant="outline" onClick={onCancel}>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit" form="applicationForm">
|
||||
确定
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
<DialogFooter className="pt-4">
|
||||
<Button type="button" variant="outline" onClick={onCancel}>
|
||||
取消
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
console.log('Submit button clicked');
|
||||
console.log('Form values:', form.getValues());
|
||||
const isValid = form.trigger();
|
||||
console.log('Form validation result:', isValid);
|
||||
if (isValid) {
|
||||
handleSubmit(form.getValues());
|
||||
}
|
||||
}}
|
||||
>
|
||||
确定
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user