Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 24457b4

Browse files
fix moving items to the root-level (GroupID <= 0)
1 parent b5239d7 commit 24457b4

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

‎services/group/group.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,29 +85,31 @@ func MoveGroupItem(ctx context.Context, opts MoveGroupOptions, doer *user_model.
8585
}
8686
defer committer.Close()
8787
var parentGroup *group_model.Group
88-
parentGroup, err = group_model.GetGroupByID(ctx, opts.NewParent)
89-
if err != nil {
90-
return err
91-
}
92-
canAccessNewParent, err := parentGroup.CanAccess(ctx, doer)
93-
if err != nil {
94-
return err
95-
}
96-
if !canAccessNewParent {
97-
return errors.New("cannot access new parent group")
98-
}
88+
if opts.NewParent > 0 {
89+
parentGroup, err = group_model.GetGroupByID(ctx, opts.NewParent)
90+
if err != nil {
91+
return err
92+
}
93+
canAccessNewParent, err := parentGroup.CanAccess(ctx, doer)
94+
if err != nil {
95+
return err
96+
}
97+
if !canAccessNewParent {
98+
return errors.New("cannot access new parent group")
99+
}
99100

100-
err = parentGroup.LoadSubgroups(ctx, false)
101-
if err != nil {
102-
return err
101+
err = parentGroup.LoadSubgroups(ctx, false)
102+
if err != nil {
103+
return err
104+
}
103105
}
104106
if opts.IsGroup {
105107
var group *group_model.Group
106108
group, err = group_model.GetGroupByID(ctx, opts.ItemID)
107109
if err != nil {
108110
return err
109111
}
110-
if opts.NewPos < 0 {
112+
if opts.NewPos < 0 &&parentGroup!=nil{
111113
opts.NewPos = len(parentGroup.Subgroups)
112114
}
113115
if group.ParentGroupID != opts.NewParent || group.SortOrder != opts.NewPos {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /