-
Notifications
You must be signed in to change notification settings - Fork 72
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
Showing
13 changed files
with
147 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ coverage | |
view | ||
app/controller/app.js | ||
docs_dist | ||
public/ |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
{ | ||
"type": "webhooks", | ||
"webhooks": [ | ||
{ | ||
"tag": "build", | ||
"url": "https://localhost" | ||
} | ||
] | ||
], | ||
"site": { | ||
"assetsUrl": "" | ||
} | ||
} |
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,7 +1,6 @@ | ||
**/.* | ||
**/node_modules | ||
**/dist | ||
**/public | ||
**/assets | ||
**/coverage | ||
**/reports | ||
|
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,114 @@ | ||
'use strict'; | ||
|
||
import React from 'react'; | ||
import safeGet from 'lodash.get'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { | ||
Form, | ||
Icon, | ||
Spin, | ||
Input, | ||
Button, | ||
Select, | ||
message, | ||
} from 'antd'; | ||
|
||
import request from '../util/request'; | ||
|
||
const FormItem = Form.Item; | ||
const Option = Select.Option; | ||
|
||
const siteConfigFormItemLayout = { | ||
wrapperCol: { | ||
xs: { span: 24 }, | ||
sm: { offset: 4, span: 16 }, | ||
}, | ||
}; | ||
const buttonFormItemLayout = { | ||
wrapperCol: { | ||
xs: { span: 24 }, | ||
sm: { offset: 10, span: 4 }, | ||
}, | ||
}; | ||
|
||
class SiteSetting extends React.Component { | ||
state = { | ||
} | ||
|
||
componentDidMount () { | ||
this.fetchSite(); | ||
} | ||
|
||
fetchSite = async () => { | ||
this.setState({ loading: true }); | ||
const res = await request('getSite', 'GET'); | ||
this.setState({ loading: false }); | ||
if (!res.success) return; | ||
|
||
const siteConfig = safeGet(res, 'data.site'); | ||
this.setState({ | ||
siteConfig, | ||
}); | ||
} | ||
|
||
postSite = async (siteConfig) => { | ||
const res = await request('postSite', 'POST', { | ||
site: siteConfig, | ||
}); | ||
if (res.success) { | ||
await this.fetchSite(); | ||
message.success('Update siteConfig successfully!'); | ||
} else { | ||
message.error('Update siteConfig failed.'); | ||
console.error('postSite', res); | ||
} | ||
} | ||
|
||
updateSite = () => { | ||
this.props.form.validateFields((err, values) => { | ||
if (err) return; | ||
this.postSite(values); | ||
}); | ||
} | ||
|
||
renderSiteConfig = () => { | ||
const { getFieldDecorator } = this.props.form; | ||
const assetsUrl = safeGet(this.state, 'siteConfig.assetsUrl'); | ||
return ( | ||
<div> | ||
<Form.Item | ||
{...siteConfigFormItemLayout} | ||
> | ||
{getFieldDecorator('assetsUrl', { | ||
initialValue: assetsUrl, | ||
})( | ||
<Input /> | ||
)} | ||
</Form.Item> | ||
<Form.Item {...buttonFormItemLayout}> | ||
<Button | ||
style={{ width: '100%' }} | ||
type="primary" | ||
htmlType="submit" | ||
onClick={this.updateSite} | ||
> | ||
<FormattedMessage id='setting.submit' /> | ||
</Button> | ||
</Form.Item> | ||
</div> | ||
); | ||
} | ||
|
||
render () { | ||
return ( | ||
<Form> | ||
<Spin spinning={this.state.loading}> | ||
{this.renderSiteConfig()} | ||
</Spin> | ||
</Form> | ||
); | ||
} | ||
} | ||
|
||
export default Form.create()(SiteSetting); | ||
|
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