-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow user to choose backup target when backup backing image
Signed-off-by: andy.lee <[email protected]>
- Loading branch information
Showing
26 changed files
with
215 additions
and
97 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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,80 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Form, Select, Icon } from 'antd' | ||
import { ModalBlur } from '../../components' | ||
|
||
const FormItem = Form.Item | ||
const Option = Select.Option | ||
|
||
const formItemLayout = { | ||
labelCol: { | ||
span: 6, | ||
}, | ||
wrapperCol: { | ||
span: 15, | ||
}, | ||
} | ||
|
||
const modal = ({ | ||
backingImage, | ||
availBackupTargets, | ||
visible, | ||
onCancel, | ||
onOk, | ||
form: { | ||
getFieldDecorator, | ||
getFieldValue, | ||
}, | ||
}) => { | ||
function handleOk() { | ||
const backupTarget = availBackupTargets.find(bkTarget => bkTarget.name === getFieldValue('backupTargetName')) | ||
if (backupTarget) { | ||
const url = backingImage.actions?.backupBackingImageCreate | ||
const payload = { | ||
...backingImage, | ||
backingImageName: backingImage.name, | ||
backupTargetName: backupTarget.name, | ||
backupTargetURL: backupTarget.backupTargetURL, | ||
} | ||
onOk(url, payload) | ||
} | ||
} | ||
|
||
const modalOpts = { | ||
title: 'Create Backup Backing Image', | ||
visible, | ||
onCancel, | ||
onOk: handleOk, | ||
} | ||
|
||
return ( | ||
<ModalBlur {...modalOpts}> | ||
<p type="warning"> | ||
<Icon style={{ marginRight: '10px' }} type="exclamation-circle" />Choose a backup target to backup <strong>{backingImage.name}</strong> backing image | ||
</p> | ||
<div style={{ display: 'flex' }}> | ||
<FormItem label="Backup Target" style={{ width: '100%' }} {...formItemLayout}> | ||
{getFieldDecorator('backupTargetName', { | ||
initialValue: availBackupTargets.length > 0 ? availBackupTargets[0].name : '', | ||
})( | ||
<Select style={{ width: '100%' }}> | ||
{availBackupTargets.map(bkTarget => <Option key={bkTarget.name} value={bkTarget.name}>{bkTarget.name}</Option>)} | ||
</Select> | ||
)} | ||
</FormItem> | ||
</div> | ||
</ModalBlur> | ||
) | ||
} | ||
|
||
modal.propTypes = { | ||
backingImage: PropTypes.object, | ||
availBackupTargets: PropTypes.array, | ||
form: PropTypes.object.isRequired, | ||
visible: PropTypes.bool, | ||
onCancel: PropTypes.func, | ||
item: PropTypes.object, | ||
onOk: PropTypes.func, | ||
} | ||
|
||
export default Form.create()(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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.