diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-01-05 11:37:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-05 11:37:00 +0800 |
commit | 8760af752abd94f050c6014c8cfa3cb6a6c854b7 (patch) | |
tree | 2b2afeebc46348eec296a6cd9d086f84a94cf664 /templates/org | |
parent | 12ad6dd0e385fea277f5344d52865c9599232c22 (diff) | |
download | gitea-8760af752abd94f050c6014c8cfa3cb6a6c854b7.tar.gz gitea-8760af752abd94f050c6014c8cfa3cb6a6c854b7.zip |
Team permission allow different unit has different permission (#17811)
* Team permission allow different unit has different permission
* Finish the interface and the logic
* Fix lint
* Fix translation
* align center for table cell content
* Fix fixture
* merge
* Fix test
* Add deprecated
* Improve code
* Add tooltip
* Fix swagger
* Fix newline
* Fix tests
* Fix tests
* Fix test
* Fix test
* Max permission of external wiki and issues should be read
* Move team units with limited max level below units table
* Update label and column names
* Some improvements
* Fix lint
* Some improvements
* Fix template variables
* Add permission docs
* improve doc
* Fix fixture
* Fix bug
* Fix some bug
* fix
* gofumpt
* Integration test for migration (#18124)
integrations: basic test for Gitea {dump,restore}-repo
This is a first step for integration testing of DumpRepository and
RestoreRepository. It:
runs a Gitea server,
dumps a repo via DumpRepository to the filesystem,
restores the repo via RestoreRepository from the filesystem,
dumps the restored repository to the filesystem,
compares the first and second dump and expects them to be identical
The verification is trivial and the goal is to add more tests for each
topic of the dump.
Signed-off-by: Loïc Dachary <loic@dachary.org>
* Team permission allow different unit has different permission
* Finish the interface and the logic
* Fix lint
* Fix translation
* align center for table cell content
* Fix fixture
* merge
* Fix test
* Add deprecated
* Improve code
* Add tooltip
* Fix swagger
* Fix newline
* Fix tests
* Fix tests
* Fix test
* Fix test
* Max permission of external wiki and issues should be read
* Move team units with limited max level below units table
* Update label and column names
* Some improvements
* Fix lint
* Some improvements
* Fix template variables
* Add permission docs
* improve doc
* Fix fixture
* Fix bug
* Fix some bug
* Fix bug
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Aravinth Manivannan <realaravinth@batsense.net>
Diffstat (limited to 'templates/org')
-rw-r--r-- | templates/org/team/new.tmpl | 85 | ||||
-rw-r--r-- | templates/org/team/sidebar.tmpl | 6 |
2 files changed, 63 insertions, 28 deletions
diff --git a/templates/org/team/new.tmpl b/templates/org/team/new.tmpl index 783e025ebd..1cf2dd0236 100644 --- a/templates/org/team/new.tmpl +++ b/templates/org/team/new.tmpl @@ -56,21 +56,14 @@ <br> <div class="field"> <div class="ui radio checkbox"> - <input type="radio" name="permission" value="read" {{if or .PageIsOrgTeamsNew (eq .Team.Authorize 1)}}checked{{end}}> - <label>{{.i18n.Tr "org.teams.read_access"}}</label> - <span class="help">{{.i18n.Tr "org.teams.read_access_helper"}}</span> + <input type="radio" name="permission" value="{{if .PageIsOrgTeamsNew}}read{{else}}{{.Team.AccessMode}}{{end}}" {{if or .PageIsOrgTeamsNew (eq .Team.AccessMode 1) (eq .Team.AccessMode 2)}}checked{{end}}> + <label>{{.i18n.Tr "org.teams.general_access"}}</label> + <span class="help">{{.i18n.Tr "org.teams.general_access_helper"}}</span> </div> </div> <div class="field"> <div class="ui radio checkbox"> - <input type="radio" name="permission" value="write" {{if eq .Team.Authorize 2}}checked{{end}}> - <label>{{.i18n.Tr "org.teams.write_access"}}</label> - <span class="help">{{.i18n.Tr "org.teams.write_access_helper"}}</span> - </div> - </div> - <div class="field"> - <div class="ui radio checkbox"> - <input type="radio" name="permission" value="admin" {{if eq .Team.Authorize 3}}checked{{end}}> + <input type="radio" name="permission" value="admin" {{if eq .Team.AccessMode 3}}checked{{end}}> <label>{{.i18n.Tr "org.teams.admin_access"}}</label> <span class="help">{{.i18n.Tr "org.teams.admin_access_helper"}}</span> </div> @@ -78,24 +71,66 @@ </div> <div class="ui divider"></div> - <div class="team-units required grouped field"{{if eq .Team.Authorize 3}} style="display: none"{{end}}> + <div class="team-units required grouped field"{{if eq .Team.AccessMode 3}} style="display: none"{{end}}> <label>{{.i18n.Tr "org.team_unit_desc"}}</label> - <br> + <table class="ui celled table"> + <thead> + <tr> + <th class="center aligned">{{.i18n.Tr "units.unit"}}</th> + <th class="center aligned">{{.i18n.Tr "org.teams.none_access"}} + <i class="circle help icon link tooltip" data-content="{{.i18n.Tr "org.teams.none_access_helper"}}"></i></th> + <th class="center aligned">{{.i18n.Tr "org.teams.read_access"}} + <i class="circle help icon link tooltip" data-content="{{.i18n.Tr "org.teams.read_access_helper"}}"></i> + </th> + <th class="center aligned">{{.i18n.Tr "org.teams.write_access"}} + <i class="circle help icon link tooltip" data-content="{{.i18n.Tr "org.teams.write_access_helper"}}"></i> + </th> + </tr> + </thead> + <tbody> + {{range $t, $unit := $.Units}} + {{if ge $unit.MaxPerms 2}} + <tr> + <td> + <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> + </div> + </div> + </td> + <td class="center aligned"> + <div class="ui radio checkbox"> + <input type="radio" class="hidden" name="unit_{{$unit.Type.Value}}" value="0"{{if or ($unit.Type.UnitGlobalDisabled) (eq ($.Team.UnitAccessMode $unit.Type) 0)}} checked{{end}}> + </div> + </td> + <td class="center aligned"> + <div class="ui radio checkbox"> + <input type="radio" 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}}> + </div> + </td> + <td class="center aligned"> + <div class="ui radio checkbox"> + <input type="radio" class="hidden" name="unit_{{$unit.Type.Value}}" value="2"{{if (eq ($.Team.UnitAccessMode $unit.Type) 2)}} checked{{end}} {{if $unit.Type.UnitGlobalDisabled}}disabled{{end}}> + </div> + </td> + </tr> + {{end}} + {{end}} + </tbody> + </table> {{range $t, $unit := $.Units}} - {{if $unit.Type.UnitGlobalDisabled}} - <div class="field tooltip" data-content="{{$.i18n.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="field"> - {{end}} - <div class="ui toggle checkbox"> - <input type="checkbox" class="hidden" name="units" value="{{$unit.Type.Value}}"{{if or (eq $.Team.ID 0) ($.Team.UnitEnabled $unit.Type)}} checked{{end}}> - <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> - </div> - </div> + {{if lt $unit.MaxPerms 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}}> + <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> + </div> + </div> + {{end}} {{end}} </div> - <div class="ui divider"></div> {{end}} <div class="field"> diff --git a/templates/org/team/sidebar.tmpl b/templates/org/team/sidebar.tmpl index 2e3769de47..6ea08740f7 100644 --- a/templates/org/team/sidebar.tmpl +++ b/templates/org/team/sidebar.tmpl @@ -29,19 +29,19 @@ <div class="item"> {{if eq .Team.LowerName "owners"}} {{.i18n.Tr "org.teams.owners_permission_desc" | Str2html}} - {{else if (eq .Team.Authorize 1)}} + {{else if (eq .Team.AccessMode 1)}} {{if .Team.IncludesAllRepositories}} {{.i18n.Tr "org.teams.all_repositories_read_permission_desc" | Str2html}} {{else}} {{.i18n.Tr "org.teams.read_permission_desc" | Str2html}} {{end}} - {{else if (eq .Team.Authorize 2)}} + {{else if (eq .Team.AccessMode 2)}} {{if .Team.IncludesAllRepositories}} {{.i18n.Tr "org.teams.all_repositories_write_permission_desc" | Str2html}} {{else}} {{.i18n.Tr "org.teams.write_permission_desc" | Str2html}} {{end}} - {{else if (eq .Team.Authorize 3)}} + {{else if (eq .Team.AccessMode 3)}} {{if .Team.IncludesAllRepositories}} {{.i18n.Tr "org.teams.all_repositories_admin_permission_desc" | Str2html}} {{else}} |