Skip to content

Commit a4a2526

Browse files
committed
fetch suggested revisions for path and repo
1 parent 7f47958 commit a4a2526

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

cyclops-ui/src/components/pages/TemplateStore/TemplateStore.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,21 +350,29 @@ const TemplateStore = () => {
350350
);
351351
};
352352

353-
const fetchRepoRevisions = (e) => {
353+
const fetchRepoRevisions = () => {
354+
const repo = addForm.getFieldValue(["ref", "repo"]);
355+
const path = addForm.getFieldValue(["ref", "path"]);
356+
354357
axios
355-
.get(`/api/templates/revisions?repo=` + e.target.value)
358+
.get(`/api/templates/revisions?repo=${repo}&path=${path}`)
356359
.then((res) => {
357360
setRepoRevisions(res.data);
361+
362+
const filtered = res.data.map((item) => ({ value: item }));
363+
setRepoRevisionOptions(filtered);
358364
})
359365
.catch(() => {});
360366
};
361367

362-
const handleRepoInput = (value) => {
368+
const handleVersionInput = (value) => {
363369
if (repoRevisions.length === 0) {
364370
setRepoRevisionOptions([]);
365371
return;
366372
}
367373

374+
console.log(value);
375+
368376
const filtered = repoRevisions
369377
.filter((item) => item.toLowerCase().includes(value.toLowerCase()))
370378
.map((item) => ({ value: item }));
@@ -670,7 +678,7 @@ const TemplateStore = () => {
670678
rules={[{ required: true, message: "Path is required" }]}
671679
style={{ marginBottom: "12px" }}
672680
>
673-
<Input />
681+
<Input onBlur={fetchRepoRevisions} />
674682
</Form.Item>
675683

676684
<Form.Item
@@ -680,7 +688,7 @@ const TemplateStore = () => {
680688
>
681689
<AutoComplete
682690
options={repoRevisionOptions}
683-
onSearch={handleRepoInput}
691+
onSearch={handleVersionInput}
684692
allowClear
685693
>
686694
<Input />

0 commit comments

Comments
 (0)