MM-53125 Add feature to convert group message to private channel (#24421)

* Added convert to channel menu item

* WIP

* refactored channel name input field and created conversion modal

* style

* style

* WIP

* wip

* Created API to fetch common teams of GM members

* Added UI for all members deactivated

* Fetched common teams in client

* WIP

* Added a required attribute to DropdownInput component

* Fixed a case with dropdown input required flag

* WIP

* API first draft

* Genetayed layers and mocks

* Fixed create channel bug

* WIP

* Added cache invalidation

* Calling API from client

* Updated API to accept name and display name as well

* WIP

* Moved converted GM to correct category

* Style fixes

* Added logic to move user to new team/channel after GM conversion

* Prevented guest user from performing action

* Added loading indicator

* Added smoother height transistion when loading finishes

* UI imporvements

* WIP

* Formatted GM conversion message on client side

* lint fix

* Moved convert option from sidebar menu to channel header menu

* Some cleanup

* Updated server layers

* Fixed i18n

* Fixed types

* Fix server i18n

* Fixed channel creation bug

* Added store test for GetCommonTeamIDsForMultipleUsers

* Server tests done

* Updated snapshots

* Updated layers

* lint fix

* Update tests

* For CI

* lint

* restored debug code

* Used user ID instead of username in channel conversion post

* WIP

* Review fixes

* LInt fixes

* Test fix

* WIP

* WIP

* WIP

* wip

* Review fixes, lots of them

* Review fix

* Disabled WIP test

* test

* Cleanup

* Test fix

* removed testing line

* Fixed incorrect default message

* Review fixes

* Fixes

* lint and i18n fix

* Setting category on server side

* updated i18n

* Updated tests

* Added tests

* Refs cleanup

* added test

---------

Co-authored-by: Harshil Sharma <harshilsharma@Harshils-MacBook-Pro.local>
Этот коммит содержится в:
Harshil Sharma
2023-09-19 18:11:34 +05:30
коммит произвёл GitHub
родитель 11cdd2b66b
Коммит 39d6cb8008
46 изменённых файлов: 2243 добавлений и 119 удалений

Просмотреть файл

@@ -553,6 +553,10 @@ func (s SqlChannelStore) getSidebarCategoriesT(db dbSelecter, userId string, opt
query = query.Where(sq.Eq{"SidebarCategories.TeamId": opts.TeamID})
}
if opts.Type != "" {
query = query.Where(sq.Eq{"SidebarCategories.Type": opts.Type})
}
sql, args, err := query.ToSql()
if err != nil {
return nil, errors.Wrap(err, "sidebar_categories_tosql")
@@ -1125,3 +1129,18 @@ func (s SqlChannelStore) DeleteSidebarCategory(categoryId string) (err error) {
return nil
}
func (s SqlChannelStore) DeleteAllSidebarChannelForChannel(channelID string) error {
query, args, err := s.getQueryBuilder().
Delete("SidebarChannels").
Where(sq.Eq{
"ChannelId": channelID,
}).ToSql()
if err != nil {
return errors.Wrap(err, "delete_all_sidebar_channel_for_channel_to_sql")
}
_, err = s.GetMasterX().Exec(query, args...)
return err
}

Просмотреть файл

@@ -1513,6 +1513,46 @@ func (s SqlTeamStore) GetCommonTeamIDsForTwoUsers(userID, otherUserID string) ([
return teamIDs, nil
}
func (s SqlTeamStore) GetCommonTeamIDsForMultipleUsers(userIDs []string) ([]string, error) {
subQuery := s.getSubQueryBuilder().
Select("TeamId, UserId").
From("TeamMembers").
Where(sq.Eq{
"UserId": userIDs,
"DeleteAt": 0,
})
subQuerySQL, subQueryParams, err := subQuery.ToSql()
if err != nil {
return nil, errors.Wrap(err, "GetCommonTeamIDsForMultipleUsers_subquery_toSQL")
}
query := s.getQueryBuilder().
Select("t.Id").
From("Teams AS t").
Join("("+subQuerySQL+") AS tm ON t.Id = tm.TeamId", subQueryParams...).
Where(sq.Eq{
"t.DeleteAt": 0,
}).
GroupBy("t.Id").
Having(sq.Eq{
"COUNT(UserId)": len(userIDs),
})
querySQL, args, err := query.ToSql()
if err != nil {
return nil, errors.Wrap(err, "GetCommonTeamIDsForMultipleUsers_query_toSQL")
}
var teamIDs []string
if err := s.GetReplicaX().Select(&teamIDs, querySQL, args...); err != nil {
return nil, errors.Wrapf(err, "failed to find common team for users %v", userIDs)
}
return teamIDs, nil
}
// GetTeamMembersForExport gets the various teams for which a user, denoted by userId, is a part of.
func (s SqlTeamStore) GetTeamMembersForExport(userId string) ([]*model.TeamMemberForExport, error) {
members := []*model.TeamMemberForExport{}