Fix new team (#18212)

fix regression from #17811
This commit is contained in:
Lunny Xiao 2022-01-08 23:19:36 +08:00 committed by GitHub
parent 70d7475356
commit 23f5a34c89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -193,6 +193,14 @@ func (u Unit) IsLessThan(unit Unit) bool {
return u.Idx < unit.Idx 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 // Enumerate all the units
var ( var (
UnitCode = Unit{ UnitCode = Unit{

View File

@ -89,10 +89,10 @@
</thead> </thead>
<tbody> <tbody>
{{range $t, $unit := $.Units}} {{range $t, $unit := $.Units}}
{{if ge $unit.MaxPerms 2}} {{if ge $unit.MaxPerm 2}}
<tr> <tr>
<td> <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"> <div class="ui">
<label>{{$.i18n.Tr $unit.NameKey}}{{if $unit.Type.UnitGlobalDisabled}} {{$.i18n.Tr "org.team_unit_disabled"}}{{end}}</label> <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> <span class="help">{{$.i18n.Tr $unit.DescKey}}</span>
@ -120,7 +120,7 @@
</tbody> </tbody>
</table> </table>
{{range $t, $unit := $.Units}} {{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 {{if $unit.Type.UnitGlobalDisabled}}class="field tooltip" data-content="{{$.i18n.Tr "repo.unit_disabled"}}"{{else}}class="field"{{end}}>
<div class="ui checkbox"> <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}}> <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}}>