Restore previously archived groups (#22597)
* add ability to restore groups from the user group modal * factory selector for groups to reduce number of renders across the app * react window and infinite scroll for user groups * adding archive groups to dropdown * restore user group from the view modal * component cleanup * lint * adding websocket for archiveGroup * updating tests * adding some tests and fixing types * lint * fixing broken test * fixing snapshot * fixing infinitescroll * lint * increasing max-height and updating snapshots * fixing PR comments * fixing case for button * snapshot and translation * fixing PR comments * tiding up repition and creating new hook * fixing tests * add additional parammeter for call to getGroups() * make sure popup is visible for all rows * update text for admin console * update css for lint * fix edge cases found in review * revert package-lock.json * revert adding query to GetGroupsParam * fixing lint * change include_archived to false in team_controller --------- Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local> Co-authored-by: Scott Bishel <scott.bishel@mattermost.com> Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -384,9 +384,11 @@ func (s *SqlGroupStore) Delete(groupID string) (*model.Group, error) {
|
||||
}
|
||||
|
||||
time := model.GetMillis()
|
||||
group.DeleteAt = time
|
||||
group.UpdateAt = time
|
||||
if _, err := s.GetMasterX().Exec(`UPDATE UserGroups
|
||||
SET DeleteAt=?, UpdateAt=?
|
||||
WHERE Id=? AND DeleteAt=0`, time, time, groupID); err != nil {
|
||||
WHERE Id=? AND DeleteAt=0`, group.DeleteAt, group.UpdateAt, groupID); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to update Group with id=%s", groupID)
|
||||
}
|
||||
|
||||
@@ -410,10 +412,11 @@ func (s *SqlGroupStore) Restore(groupID string) (*model.Group, error) {
|
||||
return nil, errors.Wrapf(err, "failed to get Group with id=%s", groupID)
|
||||
}
|
||||
|
||||
time := model.GetMillis()
|
||||
group.UpdateAt = model.GetMillis()
|
||||
group.DeleteAt = 0
|
||||
if _, err := s.GetMasterX().Exec(`UPDATE UserGroups
|
||||
SET DeleteAt=0, UpdateAt=?
|
||||
WHERE Id=? AND DeleteAt!=0`, time, groupID); err != nil {
|
||||
WHERE Id=? AND DeleteAt!=0`, group.UpdateAt, groupID); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to update Group with id=%s", groupID)
|
||||
}
|
||||
|
||||
@@ -1570,17 +1573,27 @@ func (s *SqlGroupStore) GetGroups(page, perPage int, opts model.GroupSearchOpts,
|
||||
}
|
||||
|
||||
groupsQuery = groupsQuery.
|
||||
From("UserGroups g").
|
||||
OrderBy("g.DisplayName")
|
||||
From("UserGroups g")
|
||||
|
||||
if opts.Since > 0 {
|
||||
groupsQuery = groupsQuery.Where(sq.Gt{
|
||||
"g.UpdateAt": opts.Since,
|
||||
})
|
||||
} else {
|
||||
}
|
||||
|
||||
if opts.FilterArchived {
|
||||
groupsQuery = groupsQuery.Where("g.DeleteAt > 0")
|
||||
} else if !opts.IncludeArchived && opts.Since <= 0 {
|
||||
// Mobile needs to return archived groups when the since parameter is set, will need to keep this for backwards compatibility
|
||||
groupsQuery = groupsQuery.Where("g.DeleteAt = 0")
|
||||
}
|
||||
|
||||
if opts.IncludeArchived {
|
||||
groupsQuery = groupsQuery.OrderBy("CASE WHEN g.DeleteAt = 0 THEN g.DisplayName end, CASE WHEN g.DeleteAt != 0 THEN g.DisplayName END")
|
||||
} else {
|
||||
groupsQuery = groupsQuery.OrderBy("g.DisplayName")
|
||||
}
|
||||
|
||||
if perPage != 0 {
|
||||
groupsQuery = groupsQuery.
|
||||
Limit(uint64(perPage)).
|
||||
|
||||
Ссылка в новой задаче
Block a user