-
Notifications
You must be signed in to change notification settings - Fork 3
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
jasonczc
committed
Nov 5, 2021
1 parent
fbce248
commit 6a2aca6
Showing
8 changed files
with
147 additions
and
48 deletions.
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
42 changes: 8 additions & 34 deletions
42
frontend/src/components/Plugin/EditForm/PluginVersionControlForm.tsx
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 |
---|---|---|
@@ -1,42 +1,16 @@ | ||
import {Button, Form, Input, message, Upload} from "antd"; | ||
import ProCard from "@ant-design/pro-card"; | ||
import React, {useState} from "react"; | ||
import React from "react"; | ||
import {PluginInfoFormParams} from "../EditPluginForm"; | ||
import {UploadOutlined} from "@ant-design/icons"; | ||
import axios from "axios"; | ||
import VersionList from "./VersionControl/VersionList"; | ||
import VersionCreate from "./VersionControl/VersionCreate"; | ||
|
||
export default function(props:PluginInfoFormParams) { | ||
const {id} = props.info | ||
const [hasPluginVersion, setHasPluginVersion] = useState(false) | ||
const [form] = Form.useForm(); | ||
const [version, setVersion] = useState("") | ||
const onFinish = async (values: any) => { | ||
try{ | ||
await axios.put("/v1/plugins/"+id+"/"+values.version) | ||
setVersion(values.version) | ||
setHasPluginVersion(true) | ||
}catch (e) { | ||
message.error(e.response.data.message) | ||
} | ||
}; | ||
|
||
const {refresh} = props | ||
const doRefresh = ()=>{ | ||
if(refresh) refresh() | ||
} | ||
return <ProCard style={{ marginTop: 8 }} loading={props.loading}> | ||
<VersionList {...props}/> | ||
<Form form={form} onFinish={onFinish}> | ||
<Form.Item | ||
label="版本号" | ||
name="version" | ||
rules={[{ required: true, message: '请输入版本号!' }]}> | ||
<Input disabled={hasPluginVersion} placeholder="输入版本号" /> | ||
</Form.Item> | ||
{hasPluginVersion? | ||
<Upload | ||
action={"/v1/plugins/"+id+"/"+version+"/test.zip"} | ||
method={"put"} | ||
> | ||
<Button icon={<UploadOutlined />}>点击上传</Button> | ||
</Upload>:<Button htmlType="submit">确定</Button>} | ||
</Form> | ||
<VersionList refresh={doRefresh} {...props}/> | ||
<VersionCreate refresh={doRefresh} {...props}/> | ||
</ProCard> | ||
} |
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
51 changes: 51 additions & 0 deletions
51
frontend/src/components/Plugin/EditForm/VersionControl/VersionCreate.tsx
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,51 @@ | ||
import React, { useState } from 'react'; | ||
import {Modal, Button, Form, Input, message} from 'antd'; | ||
import {PluginInfoFormParams} from "../../EditPluginForm"; | ||
import axios from "axios"; | ||
export default function(props:PluginInfoFormParams) { | ||
const [form] = Form.useForm(); | ||
const [isModalVisible, setIsModalVisible] = useState(false); | ||
|
||
const showModal = () => { | ||
setIsModalVisible(true); | ||
}; | ||
|
||
const handleOk = () => { | ||
setIsModalVisible(false); | ||
}; | ||
|
||
const handleCancel = () => { | ||
setIsModalVisible(false); | ||
}; | ||
|
||
const onFinish = async (values: any) => { | ||
try{ | ||
await axios.put("/v1/plugins/"+props.info.id+"/"+values.version) | ||
setIsModalVisible(false) | ||
if(props.refresh) { | ||
props.refresh() | ||
} | ||
}catch (e) { | ||
message.error(e.response.data.message) | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Button type="primary" onClick={showModal}> | ||
添加新版本 | ||
</Button> | ||
<Modal title="请输入版本号" visible={isModalVisible} onOk={handleOk} onCancel={handleCancel} footer={null}> | ||
<Form form={form} onFinish={onFinish}> | ||
<Form.Item | ||
label="版本号" | ||
name="version" | ||
rules={[{ required: true, message: '请输入版本号!' }]}> | ||
<Input placeholder="输入版本号" /> | ||
</Form.Item> | ||
<Button htmlType="submit">确定</Button> | ||
</Form> | ||
</Modal> | ||
</> | ||
); | ||
}; |
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
53 changes: 53 additions & 0 deletions
53
frontend/src/components/Plugin/EditForm/VersionControl/VersionOperation.tsx
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,53 @@ | ||
import {VersionFilesProps} from "./FileList"; | ||
|
||
import {Modal, Button, Space, message} from 'antd'; | ||
import { ExclamationCircleOutlined } from '@ant-design/icons'; | ||
import axios from "axios"; | ||
|
||
const { confirm } = Modal; | ||
|
||
function showConfirm() { | ||
confirm({ | ||
title: 'Do you Want to delete these items?', | ||
icon: <ExclamationCircleOutlined />, | ||
content: 'Some descriptions', | ||
onOk() { | ||
console.log('OK'); | ||
}, | ||
onCancel() { | ||
console.log('Cancel'); | ||
}, | ||
}); | ||
} | ||
|
||
export default function (props:VersionFilesProps){ | ||
const showDeleteConfirm = () => confirm({ | ||
title: '你确认要删除'+props.version+'版本吗?', | ||
icon: <ExclamationCircleOutlined />, | ||
content: '删除该版本同时会将该版本下所有文件删除。', | ||
okText: '确认', | ||
okType: 'danger', | ||
cancelText: '取消', | ||
onOk: async ()=>{ | ||
try{ | ||
await axios.delete("/v1/plugins/"+props.id+"/"+props.version) | ||
message.success("删除成功") | ||
if(props.refresh) { | ||
props.refresh() | ||
} | ||
}catch (e) { | ||
message.error(e.response.data.message) | ||
} | ||
}, | ||
onCancel() { | ||
console.log('Cancel'); | ||
}, | ||
}); | ||
return ( | ||
<Space wrap> | ||
<Button onClick={showConfirm}>新增版本文件</Button> | ||
<Button onClick={showDeleteConfirm} type="dashed"> | ||
删除版本 | ||
</Button> | ||
</Space>) | ||
} |
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 |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import React from "react"; | ||
import {BasicPluginInfo} from "../../models/Plugin"; | ||
import {PluginInfo} from "../../models/Plugin"; | ||
import EditPluginInfoForm from "./EditForm/EditPluginInfoForm"; | ||
import PluginVersionControlForm from "./EditForm/PluginVersionControlForm"; | ||
|
||
export interface PluginInfoFormParams { | ||
loading:boolean | ||
info:BasicPluginInfo | ||
info:PluginInfo | ||
refresh ?: ()=>void | ||
} | ||
|
||
export default function(props:PluginInfoFormParams) { | ||
const {refresh} = props | ||
const doRefresh = ()=>{ | ||
if(refresh) refresh() | ||
} | ||
return <> | ||
<EditPluginInfoForm {...props}/> | ||
<PluginVersionControlForm {...props}/> | ||
<EditPluginInfoForm refresh={doRefresh} {...props}/> | ||
<PluginVersionControlForm refresh={doRefresh} {...props}/> | ||
</> | ||
} |
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