-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43888cf
commit 926b840
Showing
4 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import {Col, Table, Typography, Alert, Row} from "antd"; | ||
import axios from "axios"; | ||
import Title from "antd/es/typography/Title"; | ||
|
||
const TemplateStore = () => { | ||
const [templates, setTemplates] = useState([]); | ||
const [error, setError] = useState({ | ||
message: "", | ||
description: "", | ||
}); | ||
|
||
useEffect(() => { | ||
axios | ||
.get(`/api/templates/store`) | ||
.then((res) => { | ||
setTemplates(res.data); | ||
}) | ||
.catch((error) => { | ||
if (error?.response?.data) { | ||
setError({ | ||
message: error.response.data.message || String(error), | ||
description: error.response.data.description || "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, | ||
}); | ||
} else { | ||
setError({ | ||
message: String(error), | ||
description: | ||
"Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, | ||
}); | ||
} | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
{error.message.length !== 0 && ( | ||
<Alert | ||
message={error.message} | ||
description={error.description} | ||
type="error" | ||
closable | ||
afterClose={() => { | ||
setError({ | ||
message: "", | ||
description: "", | ||
}); | ||
}} | ||
style={{ marginBottom: "20px" }} | ||
/> | ||
)} | ||
<Row gutter={[40, 0]}> | ||
<Col span={18}> | ||
<Title level={2}>Templates: {templates.length}</Title> | ||
</Col> | ||
</Row> | ||
<Col span={24} style={{ overflowX: "auto" }}> | ||
<Table dataSource={templates}> | ||
<Table.Column title="Name" dataIndex="name" width={"30%"} /> | ||
<Table.Column title="Repo" dataIndex={["ref", "repo"]} width={"30%"} /> | ||
<Table.Column | ||
title="Path" | ||
dataIndex={["ref", "path"]} | ||
width={"20%"} | ||
render={function (value: any, record: any, index: number) { | ||
if (!value.startsWith('/')) { | ||
return '/' + value; | ||
} | ||
return value; | ||
}} | ||
/> | ||
<Table.Column title="Version" dataIndex={["ref", "version"]} width={"10%"} /> | ||
</Table> | ||
</Col> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TemplateStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters