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