]> source.dussan.org Git - gitea.git/commitdiff
Fix new team (#18212)
authorLunny Xiao <xiaolunwen@gmail.com>
Sat, 8 Jan 2022 15:19:36 +0000 (23:19 +0800)
committerGitHub <noreply@github.com>
Sat, 8 Jan 2022 15:19:36 +0000 (15:19 +0000)
fix regression from #17811

models/unit/unit.go
templates/org/team/new.tmpl

index b05f34b64cca67831838d842a97494da96478a71..eb71276786d1a493c0fee4577ba6acd2424cbc57 100644 (file)
@@ -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{
index 1cf2dd0236ec1d7e5d247200a09e540f1657bdaa..9877e9a9411cba63329f5a8f8620a3cbe3a8a84d 100644 (file)
                                                                        </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>
                                                                        </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}}>