Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team permission allow different unit has different permission #17811

Merged
merged 62 commits into from
Jan 5, 2022
Merged
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
587ac0f
Team permission allow different unit has different permission
lunny Nov 25, 2021
eb8237f
Finish the interface and the logic
lunny Nov 25, 2021
35ae85a
Fix lint
lunny Nov 25, 2021
b4ea024
Fix translation
lunny Nov 25, 2021
fbcb9d5
align center for table cell content
lunny Nov 25, 2021
deb1901
Fix fixture
lunny Nov 25, 2021
1819e25
merge
lunny Nov 25, 2021
89197aa
Fix test
lunny Nov 27, 2021
f0ed083
Add deprecated
lunny Nov 27, 2021
5e4f751
Improve code
lunny Nov 27, 2021
c53ce3d
Add tooltip
lunny Nov 28, 2021
41b516d
Fix swagger
lunny Nov 28, 2021
fbe50f6
Fix newline
lunny Nov 28, 2021
f81b33c
Fix tests
lunny Nov 28, 2021
0135739
Fix tests
lunny Nov 30, 2021
9d92b30
Fix test
lunny Dec 1, 2021
7c77e06
Fix test
lunny Dec 1, 2021
1396e74
Max permission of external wiki and issues should be read
lunny Dec 2, 2021
0738b2c
Move team units with limited max level below units table
lafriks Dec 3, 2021
dc09224
Some improvements
lunny Dec 6, 2021
0bfffa2
Fix lint
lunny Dec 6, 2021
fe09394
Some improvements
lunny Dec 8, 2021
fd15893
Fix template variables
lunny Dec 13, 2021
1bce43a
Add permission docs
lunny Dec 13, 2021
ea2f677
improve doc
lunny Dec 16, 2021
367d1d0
Fix fixture
lunny Dec 16, 2021
232affa
Fix bug
lunny Jan 2, 2022
c4ae43c
Fix some bug
lunny Jan 4, 2022
eda5846
Merge branch 'master' into lunny/team_multiple_units
6543 Jan 4, 2022
dbfa40f
fix
6543 Jan 4, 2022
23ee2b5
gofumpt
6543 Jan 4, 2022
12ad6dd
Integration test for migration (#18124)
realaravinth Jan 4, 2022
8bc9da5
Team permission allow different unit has different permission
lunny Nov 25, 2021
ecc65cf
Finish the interface and the logic
lunny Nov 25, 2021
7f03e0c
Fix lint
lunny Nov 25, 2021
43808fc
Fix translation
lunny Nov 25, 2021
1d1419c
align center for table cell content
lunny Nov 25, 2021
d42a89d
Fix fixture
lunny Nov 25, 2021
58f8f0e
merge
lunny Nov 25, 2021
24bccf4
Fix test
lunny Nov 27, 2021
3f847a3
Add deprecated
lunny Nov 27, 2021
910f967
Improve code
lunny Nov 27, 2021
1079027
Add tooltip
lunny Nov 28, 2021
827826e
Fix swagger
lunny Nov 28, 2021
12ea655
Fix newline
lunny Nov 28, 2021
4209d43
Fix tests
lunny Nov 28, 2021
aed9f65
Fix tests
lunny Nov 30, 2021
9884caf
Fix test
lunny Dec 1, 2021
85d952d
Fix test
lunny Dec 1, 2021
034630f
Max permission of external wiki and issues should be read
lunny Dec 2, 2021
e21c449
Move team units with limited max level below units table
lafriks Dec 3, 2021
4455889
Some improvements
lunny Dec 6, 2021
35eafb1
Fix lint
lunny Dec 6, 2021
45962e4
Some improvements
lunny Dec 8, 2021
9c4f1e9
Fix template variables
lunny Dec 13, 2021
90bb10b
Add permission docs
lunny Dec 13, 2021
83a03cc
improve doc
lunny Dec 16, 2021
252d1a8
Fix fixture
lunny Dec 16, 2021
d20b90e
Fix bug
lunny Jan 2, 2022
fb1cc7e
Fix some bug
lunny Jan 4, 2022
55164ac
Fix bug
lunny Jan 5, 2022
2cd4b3d
Merge fmt
lunny Jan 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix some bug
lunny committed Jan 4, 2022
commit c4ae43cc8b5d0bebd40d43fb6c7ff36c66be6c01
12 changes: 6 additions & 6 deletions models/migrations/v205.go
Original file line number Diff line number Diff line change
@@ -12,19 +12,19 @@ import (

func addAuthorizeColForTeamUnit(x *xorm.Engine) error {
type TeamUnit struct {
ID int64 `xorm:"pk autoincr"`
OrgID int64 `xorm:"INDEX"`
TeamID int64 `xorm:"UNIQUE(s)"`
Type int `xorm:"UNIQUE(s)"`
Authorize int
ID int64 `xorm:"pk autoincr"`
OrgID int64 `xorm:"INDEX"`
TeamID int64 `xorm:"UNIQUE(s)"`
Type int `xorm:"UNIQUE(s)"`
AccessMode int
}

if err := x.Sync2(new(TeamUnit)); err != nil {
return fmt.Errorf("sync2: %v", err)
}

// migrate old permission
_, err := x.Exec("UPDATE team_unit SET authorize = (SELECT authorize FROM team WHERE team.id = team_unit.team_id)")
_, err := x.Exec("UPDATE team_unit SET access_mode = (SELECT authorize FROM team WHERE team.id = team_unit.team_id)")
return err

}
2 changes: 1 addition & 1 deletion models/unit/unit.go
Original file line number Diff line number Diff line change
@@ -321,7 +321,7 @@ func AllUnitKeyNames() []string {
func MinUnitAccessMode(unitsMap map[Type]perm.AccessMode) perm.AccessMode {
var res = perm.AccessModeNone
for _, mode := range unitsMap {
if mode > perm.AccessModeNone && (res == perm.AccessModeNone || mode < res) {
if mode > perm.AccessModeNone && mode < res {
res = mode
}
}
1 change: 1 addition & 0 deletions modules/structs/org_team.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ type Team struct {
// enum: none,read,write,admin,owner
Permission string `json:"permission"`
// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.projects","repo.ext_wiki"]
// Deprecated: This variable should be replaced by UnitsMap and will be dropped in later versions.
Units []string `json:"units"`
// example: {"repo.code":"read","repo.issues":"write","repo.ext_issues":"none","repo.wiki":"admin","repo.pulls":"owner","repo.releases":"none","repo.projects":"none","repo.ext_wiki":"none"]
UnitsMap map[string]string `json:"units_map"`