Skip to content

Commit

Permalink
Fix new team (#18212)
Browse files Browse the repository at this point in the history
fix regression from #17811
  • Loading branch information
lunny authored Jan 8, 2022
1 parent 70d7475 commit 23f5a34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions models/unit/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ func (u Unit) IsLessThan(unit Unit) bool {
return u.Idx < unit.Idx
}

// MaxPerm returns the max perms of this unit
func (u Unit) MaxPerm() perm.AccessMode {
if u.Type == TypeExternalTracker || u.Type == TypeExternalWiki {
return perm.AccessModeRead
}
return perm.AccessModeAdmin
}

// Enumerate all the units
var (
UnitCode = Unit{
Expand Down
6 changes: 3 additions & 3 deletions templates/org/team/new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@
</thead>
<tbody>
{{range $t, $unit := $.Units}}
{{if ge $unit.MaxPerms 2}}
{{if ge $unit.MaxPerm 2}}
<tr>
<td>
<div {{if $unit.Type.UnitGlobalDisabled}}class="field tooltip" data-content="{{$.i18n.Tr "repo.unit_disabled"}}">{{- else -}}class="field"{{end}}>
<div {{if $unit.Type.UnitGlobalDisabled}}class="field tooltip" data-content="{{$.i18n.Tr "repo.unit_disabled"}}"{{- else -}}class="field"{{end}}>
<div class="ui">
<label>{{$.i18n.Tr $unit.NameKey}}{{if $unit.Type.UnitGlobalDisabled}} {{$.i18n.Tr "org.team_unit_disabled"}}{{end}}</label>
<span class="help">{{$.i18n.Tr $unit.DescKey}}</span>
Expand Down Expand Up @@ -120,7 +120,7 @@
</tbody>
</table>
{{range $t, $unit := $.Units}}
{{if lt $unit.MaxPerms 2}}
{{if lt $unit.MaxPerm 2}}
<div {{if $unit.Type.UnitGlobalDisabled}}class="field tooltip" data-content="{{$.i18n.Tr "repo.unit_disabled"}}"{{else}}class="field"{{end}}>
<div class="ui checkbox">
<input type="checkbox" class="hidden" name="unit_{{$unit.Type.Value}}" value="1"{{if or (eq $.Team.ID 0) (eq ($.Team.UnitAccessMode $unit.Type) 1)}} checked{{end}} {{if $unit.Type.UnitGlobalDisabled}}disabled{{end}}>
Expand Down

0 comments on commit 23f5a34

Please sign in to comment.