forked from Cloud-Pipelines/pipeline-editor
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGoogleCloudSubmitter.tsx
More file actions
94 lines (86 loc) · 2.61 KB
/
GoogleCloudSubmitter.tsx
File metadata and controls
94 lines (86 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { type ChangeEvent, useCallback } from "react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Link } from "@/components/ui/link";
import { useGoogleCloudSubmitter } from "@/hooks/useGoogleCloudSubmitter";
import type { ComponentSpec } from "@/utils/componentSpec";
import { ConfigInput } from "./ConfigInput";
import { ManualSubmissionInstructions } from "./ManualSubmissionInstructions";
import { RegionInput } from "./RegionInput";
interface GoogleCloudSubmitterProps {
componentSpec?: ComponentSpec;
}
const GoogleCloudSubmitter = ({ componentSpec }: GoogleCloudSubmitterProps) => {
const {
config,
cloudProjects,
jsonBlobUrl,
jobWebUrl,
isValid,
updateConfig,
submit,
refreshProjectList,
} = useGoogleCloudSubmitter({
componentSpec,
});
const handleOAuthClientIdChange = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
updateConfig({ googleCloudOAuthClientId: e.target.value });
},
[],
);
const handleDirectoryInputChange = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
updateConfig({ gcsOutputDirectory: e.target.value });
},
[],
);
return (
<div className="flex flex-col gap-4">
<div className="flex flex-col gap-1">
<p className="text-sm font-semibold">OAuth Client Id</p>
<Input
type="text"
value={config.googleCloudOAuthClientId}
onChange={handleOAuthClientIdChange}
autoFocus={!config.googleCloudOAuthClientId}
/>
</div>
<ConfigInput
config={config}
projectList={cloudProjects}
onChange={updateConfig}
refreshProjectList={refreshProjectList}
/>
<RegionInput config={config} onChange={updateConfig} />
<div className="flex flex-col gap-1">
<p className="text-sm font-semibold">Output Directory</p>
<Input
type="text"
value={config.gcsOutputDirectory}
onChange={handleDirectoryInputChange}
disabled={!config.googleCloudOAuthClientId}
/>
</div>
<div className="flex flex-col gap-1">
<Button onClick={submit} disabled={!isValid}>
Submit pipeline job
</Button>
{jobWebUrl && (
<Link
href={jobWebUrl}
target="_blank"
rel="noreferrer"
style={{ margin: "5px" }}
>
Job
</Link>
)}
</div>
{jsonBlobUrl && (
<ManualSubmissionInstructions downloadUrl={jsonBlobUrl} />
)}
</div>
);
};
export default GoogleCloudSubmitter;