mirror of
https://github.com/PGYER/codefever.git
synced 2026-06-08 15:14:13 +08:00
feat(Admin Settings): add ssh clone address host setting (Github: #132)
feat #132
This commit is contained in:
@@ -36,6 +36,7 @@ class User_model extends CI_Model
|
||||
'unReadNotification' => $extra ? $this->notificationModel->unReadNotificationCount($item['u_key']) : 0,
|
||||
'status' => $item['u_status'] == COMMON_STATUS_NORMAL,
|
||||
'host' => YAML_HOST,
|
||||
'ssh' => YAML_SSH,
|
||||
]);
|
||||
}
|
||||
return $result;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
host: http://localhost
|
||||
ssh: 'git@localhost:'
|
||||
allowRegister: true
|
||||
email:
|
||||
name: CodeFever Community
|
||||
|
||||
@@ -235,7 +235,7 @@ class RepositoryDashboard extends Component {
|
||||
fullWidth
|
||||
variant='outlined'
|
||||
value={
|
||||
NetworkHelper.getSSHHost(currentUserInfo) + ':' +
|
||||
NetworkHelper.getSSHHost(currentUserInfo) +
|
||||
[repositoryConfig.group.name, repositoryConfig.repository.name].join('/') +
|
||||
'.git'
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class Settings extends React.Component {
|
||||
this.state = {
|
||||
allowRegister: false,
|
||||
host: '',
|
||||
ssh: '',
|
||||
email_from: '',
|
||||
email_name: '',
|
||||
pending: true,
|
||||
@@ -55,7 +56,15 @@ class Settings extends React.Component {
|
||||
passPattern: /^http(s)?:\/\/[^/]+$/,
|
||||
errorMessage: this.props.intl.formatMessage(
|
||||
{ id: 'message.error._S_invalid' },
|
||||
{ s: this.props.intl.formatMessage({ id: 'label.url' }) }
|
||||
{ s: this.props.intl.formatMessage({ id: 'label.urlPrefix' }) }
|
||||
)
|
||||
},
|
||||
{
|
||||
name: 'ssh',
|
||||
passPattern: /^[^@]+@.+$/,
|
||||
errorMessage: this.props.intl.formatMessage(
|
||||
{ id: 'message.error._S_invalid' },
|
||||
{ s: this.props.intl.formatMessage({ id: 'label.sshPrefix' }) }
|
||||
)
|
||||
},
|
||||
{
|
||||
@@ -103,6 +112,7 @@ class Settings extends React.Component {
|
||||
this.setState({
|
||||
pending: false,
|
||||
host: data.data.host,
|
||||
ssh: data.data.ssh,
|
||||
allowRegister: data.data.allowRegister,
|
||||
email_from: data.data.email.from,
|
||||
email_name: data.data.email.name
|
||||
@@ -118,6 +128,7 @@ class Settings extends React.Component {
|
||||
|
||||
const data = {
|
||||
host: this.state.host,
|
||||
ssh: this.state.ssh,
|
||||
allowRegister: this.state.allowRegister,
|
||||
email: { name: this.state.email_name, from: this.state.email_from }
|
||||
}
|
||||
@@ -159,13 +170,13 @@ class Settings extends React.Component {
|
||||
<Grid item xs={12}>
|
||||
<Paper className={classes.paper}>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant='h6' component='div' gutterBottom> {intl.formatMessage({ id: 'label.host' })} </Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} mg={9} lg={8}>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant='subtitle1' component='div' gutterBottom> {intl.formatMessage({ id: 'label.url' })} </Typography>
|
||||
<Typography variant='subtitle1' component='div' gutterBottom> {intl.formatMessage({ id: 'label.urlPrefix' })} </Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<TextField
|
||||
@@ -174,10 +185,24 @@ class Settings extends React.Component {
|
||||
value={this.state.host}
|
||||
error={!!this.state.error.host}
|
||||
helperText={this.state.error.host}
|
||||
placeholder={intl.formatMessage({ id: 'label.url' })}
|
||||
placeholder={intl.formatMessage({ id: 'label.urlPrefix' })}
|
||||
onChange={e => this.setState({ host: e.target.value })}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant='subtitle1' component='div' gutterBottom> {intl.formatMessage({ id: 'label.sshPrefix' })} </Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<TextField
|
||||
fullWidth
|
||||
variant='outlined'
|
||||
value={this.state.ssh}
|
||||
error={!!this.state.error.ssh}
|
||||
helperText={this.state.error.ssh}
|
||||
placeholder={intl.formatMessage({ id: 'label.sshPrefix' })}
|
||||
onChange={e => this.setState({ ssh: e.target.value })}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item xs={12}> </Grid>
|
||||
|
||||
@@ -87,7 +87,9 @@ function getHost (userinfo) {
|
||||
}
|
||||
|
||||
function getSSHHost (userinfo) {
|
||||
return userinfo && 'git@' + userinfo.host.replace('http://', '').replace('https://', '')
|
||||
return userinfo && userinfo.ssh
|
||||
? userinfo.ssh
|
||||
: 'git@' + userinfo.host.replace('http://', '').replace('https://', '')
|
||||
}
|
||||
|
||||
function makeSlug (input) {
|
||||
|
||||
@@ -181,6 +181,8 @@ const data = {
|
||||
senderAddress: 'Sender Email Address',
|
||||
register: 'Register',
|
||||
allowRegister: 'Allow Register',
|
||||
urlPrefix: [Phrase.url, Phrase.prefix].join(phraseSeperator),
|
||||
sshPrefix: [Phrase.ssh, Phrase.prefix].join(phraseSeperator),
|
||||
|
||||
support: 'Technical Support',
|
||||
feedback: 'Submit Feedback',
|
||||
|
||||
@@ -17,7 +17,9 @@ const data = {
|
||||
source: 'Source',
|
||||
target: 'Target',
|
||||
url: 'URL',
|
||||
ssh: 'SSH',
|
||||
slug: 'Slug',
|
||||
prefix: 'Prefix',
|
||||
avatar: 'Avatar',
|
||||
icon: 'Icon',
|
||||
joinedAt: 'Joined In',
|
||||
|
||||
@@ -181,6 +181,8 @@ const data = {
|
||||
senderAddress: '发件人地址',
|
||||
register: '注册',
|
||||
allowRegister: '开放注册',
|
||||
urlPrefix: [Phrase.url, ' ', Phrase.prefix].join(phraseSeperator),
|
||||
sshPrefix: [Phrase.ssh, ' ', Phrase.prefix].join(phraseSeperator),
|
||||
|
||||
support: '技术支持',
|
||||
feedback: '提交反馈',
|
||||
|
||||
@@ -17,7 +17,9 @@ const data = {
|
||||
source: '源',
|
||||
target: '目标',
|
||||
url: 'URL',
|
||||
ssh: 'SSH',
|
||||
slug: '标识串',
|
||||
prefix: '前缀',
|
||||
avatar: '头像',
|
||||
icon: '图标',
|
||||
joinedAt: '加入时间',
|
||||
|
||||
Reference in New Issue
Block a user