Skip to content

Commit 23f5a34

Browse files
authored
Fix new team (#18212)
fix regression from #17811
1 parent 70d7475 commit 23f5a34

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

models/unit/unit.go

+8
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ func (u Unit) IsLessThan(unit Unit) bool {
193193
return u.Idx < unit.Idx
194194
}
195195

196+
// MaxPerm returns the max perms of this unit
197+
func (u Unit) MaxPerm() perm.AccessMode {
198+
if u.Type == TypeExternalTracker || u.Type == TypeExternalWiki {
199+
return perm.AccessModeRead
200+
}
201+
return perm.AccessModeAdmin
202+
}
203+
196204
// Enumerate all the units
197205
var (
198206
UnitCode = Unit{

templates/org/team/new.tmpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@
8989
</thead>
9090
<tbody>
9191
{{range $t, $unit := $.Units}}
92-
{{if ge $unit.MaxPerms 2}}
92+
{{if ge $unit.MaxPerm 2}}
9393
<tr>
9494
<td>
95-
<div {{if $unit.Type.UnitGlobalDisabled}}class="field tooltip" data-content="{{$.i18n.Tr "repo.unit_disabled"}}">{{- else -}}class="field"{{end}}>
95+
<div {{if $unit.Type.UnitGlobalDisabled}}class="field tooltip" data-content="{{$.i18n.Tr "repo.unit_disabled"}}"{{- else -}}class="field"{{end}}>
9696
<div class="ui">
9797
<label>{{$.i18n.Tr $unit.NameKey}}{{if $unit.Type.UnitGlobalDisabled}} {{$.i18n.Tr "org.team_unit_disabled"}}{{end}}</label>
9898
<span class="help">{{$.i18n.Tr $unit.DescKey}}</span>
@@ -120,7 +120,7 @@
120120
</tbody>
121121
</table>
122122
{{range $t, $unit := $.Units}}
123-
{{if lt $unit.MaxPerms 2}}
123+
{{if lt $unit.MaxPerm 2}}
124124
<div {{if $unit.Type.UnitGlobalDisabled}}class="field tooltip" data-content="{{$.i18n.Tr "repo.unit_disabled"}}"{{else}}class="field"{{end}}>
125125
<div class="ui checkbox">
126126
<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}}>

0 commit comments

Comments
 (0)