Browse Source

Merge branch 'V20211213' of git.openi.org.cn:OpenI/aiforge into fix-1068

pull/1170/head
lewis 3 years ago
parent
commit
bbbc02c071
4 changed files with 37 additions and 44 deletions
  1. +28
    -40
      models/repo.go
  2. +6
    -1
      templates/repo/header.tmpl
  3. +2
    -2
      templates/repo/modelmanage/showinfo.tmpl
  4. +1
    -1
      web_src/js/components/Model.vue

+ 28
- 40
models/repo.go View File

@@ -649,53 +649,41 @@ func (repo *Repository) GetAssignees() (_ []*User, err error) {
return repo.getAssignees(x) return repo.getAssignees(x)
} }


func (repo *Repository) getReviewersPrivate(e Engine, doerID, posterID int64) (users []*User, err error) {
users = make([]*User, 0, 20)

if err = e.
SQL("SELECT * FROM `user` WHERE id in (SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ? "+
" UNION SELECT owner_id FROM `repository` WHERE id = ?) AND id NOT IN ( ?, ?) ORDER BY name",
repo.ID, AccessModeWrite, repo.ID,
doerID, posterID).
Find(&users); err != nil {
return nil, err
}

return users, nil
}

func (repo *Repository) getReviewersPublic(e Engine, doerID, posterID int64) (_ []*User, err error) {

users := make([]*User, 0)

const SQLCmd = "SELECT * FROM `user` WHERE id IN ( " +
"SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ? " +
" UNION" +
" SELECT owner_id FROM `repository` WHERE id = ?)" +
" AND id NOT IN ( ?, ?) ORDER BY name "

if err = e.
SQL(SQLCmd,
repo.ID, AccessModeWrite, repo.ID, doerID, posterID).
Find(&users); err != nil {
return nil, err
}

return users, nil
}

func (repo *Repository) getReviewers(e Engine, doerID, posterID int64) (users []*User, err error) { func (repo *Repository) getReviewers(e Engine, doerID, posterID int64) (users []*User, err error) {
if err = repo.getOwner(e); err != nil { if err = repo.getOwner(e); err != nil {
return nil, err return nil, err
} }


if repo.IsPrivate ||
(repo.Owner.IsOrganization() && repo.Owner.Visibility == api.VisibleTypePrivate) {
users, err = repo.getReviewersPrivate(x, doerID, posterID)
if repo.Owner.IsOrganization() {
const SQLCmd = "SELECT * FROM `user` WHERE id IN (" +
"SELECT DISTINCT(t3.user_id) FROM ( " +
"SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ?" +
"UNION select t2.uid as user_id from team t1 left join team_user t2 on t1.id = t2.team_id where t1.org_id = ? and t1.authorize = 4) t3)" +
" AND id NOT IN ( ?, ?) ORDER BY name "

if err = e.
SQL(SQLCmd,
repo.ID, AccessModeWrite, repo.ID, doerID, posterID).
Find(&users); err != nil {
return nil, err
}
} else { } else {
users, err = repo.getReviewersPublic(x, doerID, posterID)
const SQLCmd = "SELECT * FROM `user` WHERE id IN ( " +
"SELECT DISTINCT(t3.user_id) FROM ( " +
"SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ? " +
" UNION" +
" SELECT owner_id as user_id FROM `repository` WHERE id = ?) t3)" +
" AND id NOT IN ( ?, ?) ORDER BY name "

if err = e.
SQL(SQLCmd,
repo.ID, AccessModeWrite, repo.ID, doerID, posterID).
Find(&users); err != nil {
return nil, err
}
} }
return

return users, nil
} }


// GetReviewers get all users can be requested to review // GetReviewers get all users can be requested to review


+ 6
- 1
templates/repo/header.tmpl View File

@@ -97,16 +97,21 @@
<span>{{svg "octicon-code" 16}} {{.i18n.Tr "repo.code"}} <i class="dropdown icon"></i></span> <span>{{svg "octicon-code" 16}} {{.i18n.Tr "repo.code"}} <i class="dropdown icon"></i></span>
</a> </a>
<div class="dropdown-content"> <div class="dropdown-content">
{{if and (.Permission.CanRead $.UnitTypeReleases) (not .IsEmptyRepo) }}
<a style="border: none;" class="{{if .PageIsReleaseList}}active{{end}} item" href="{{.RepoLink}}/releases"> <a style="border: none;" class="{{if .PageIsReleaseList}}active{{end}} item" href="{{.RepoLink}}/releases">
{{svg "octicon-tag" 16}} {{.i18n.Tr "repo.releases"}} <span class="ui {{if not .NumReleases}}gray{{else}}blue{{end}} small label">{{.NumReleases}}</span> {{svg "octicon-tag" 16}} {{.i18n.Tr "repo.releases"}} <span class="ui {{if not .NumReleases}}gray{{else}}blue{{end}} small label">{{.NumReleases}}</span>
</a> </a>
{{end}}
{{if or (.Permission.CanRead $.UnitTypeWiki) (.Permission.CanRead $.UnitTypeExternalWiki)}}
<a style="border: none;" class="{{if .PageIsWiki}}active{{end}} item" href="{{.RepoLink}}/wiki" {{if (.Permission.CanRead $.UnitTypeExternalWiki)}} target="_blank" rel="noopener noreferrer" {{end}}> <a style="border: none;" class="{{if .PageIsWiki}}active{{end}} item" href="{{.RepoLink}}/wiki" {{if (.Permission.CanRead $.UnitTypeExternalWiki)}} target="_blank" rel="noopener noreferrer" {{end}}>
{{svg "octicon-book" 16}} {{.i18n.Tr "repo.wiki"}} {{svg "octicon-book" 16}} {{.i18n.Tr "repo.wiki"}}
</a> </a>
{{end}}
{{if and (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) (not .IsEmptyRepo)}}
<a style="border: none;" class="{{if .PageIsActivity}}active{{end}} item" href="{{.RepoLink}}/activity"> <a style="border: none;" class="{{if .PageIsActivity}}active{{end}} item" href="{{.RepoLink}}/activity">
{{svg "octicon-pulse" 16}} {{.i18n.Tr "repo.activity"}} {{svg "octicon-pulse" 16}} {{.i18n.Tr "repo.activity"}}
</a> </a>
{{end}}
</div> </div>
</div> </div>


+ 2
- 2
templates/repo/modelmanage/showinfo.tmpl View File

@@ -93,7 +93,7 @@
<tr> <tr>
<td class="ti-text-form-label text-width80">标签</td> <td class="ti-text-form-label text-width80">标签</td>
<td class="ti-text-form-content"> <td class="ti-text-form-content">
<div id="Label">
<div id="Label" style="overflow: hidden;width: 95%;">
</div> </div>
@@ -258,7 +258,7 @@ function renderInfo(obj,accObj,id){
let labelArray = obj[key].trim().replace(/ +/g,' ').split(' ') let labelArray = obj[key].trim().replace(/ +/g,' ').split(' ')
let html='' let html=''
for(let i=0;i<labelArray.length;i++){ for(let i=0;i<labelArray.length;i++){
html += `<a class="ui label">${labelArray[i]}</a>`
html += `<a class="ui label" title="${labelArray[i]}">${labelArray[i]}</a>`
} }
$('#Label').append(html) $('#Label').append(html)
} }


+ 1
- 1
web_src/js/components/Model.vue View File

@@ -458,7 +458,7 @@ export default {
margin-right: 3px; margin-right: 3px;
font-size: 12px; font-size: 12px;
} }
/deep/ .el-table_1_column_1.is-left .cell {padding-right: 0px !important;}
/deep/ .el-table_1_column_1.is-left .cell {padding-right: 0px !important;white-space: nowrap;}
/deep/ .el-table__expand-icon .el-icon-arrow-right{ /deep/ .el-table__expand-icon .el-icon-arrow-right{
font-family: element-icons!important; font-family: element-icons!important;
speak: none; speak: none;


Loading…
Cancel
Save