MM-18357: Adds pagination to team search. (#12910)

* MM-18357: Adds pagination to team search.

* MM-18357: Adds new client method for paginated requests.

* MM-18357: Adds feedback about non-supported pagination-permissions combo.

* MM-18357: Removes unnecessary conversion.

* MM-18357: Removes paginate parameter and uses nil on page and perpage instead.
Этот коммит содержится в:
Martin Kraft
2019-11-28 08:11:02 -05:00
коммит произвёл GitHub
родитель 955f8c4e8e
Коммит 14bcd1f0a1
11 изменённых файлов: 187 добавлений и 7 удалений

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

@@ -149,7 +149,8 @@ func (api *PluginAPI) GetTeam(teamId string) (*model.Team, *model.AppError) {
}
func (api *PluginAPI) SearchTeams(term string) ([]*model.Team, *model.AppError) {
return api.app.SearchAllTeams(term)
teams, _, err := api.app.SearchAllTeams(&model.TeamSearch{Term: term})
return teams, err
}
func (api *PluginAPI) GetTeamByName(name string) (*model.Team, *model.AppError) {

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

@@ -710,8 +710,13 @@ func (a *App) GetAllPublicTeamsPageWithCount(offset int, limit int) (*model.Team
return &model.TeamsWithCount{Teams: teams, TotalCount: totalCount}, nil
}
func (a *App) SearchAllTeams(term string) ([]*model.Team, *model.AppError) {
return a.Srv.Store.Team().SearchAll(term)
// SearchAllTeams returns a team list and the total count of the results
func (a *App) SearchAllTeams(searchOpts *model.TeamSearch) ([]*model.Team, int64, *model.AppError) {
if searchOpts.IsPaginated() {
return a.Srv.Store.Team().SearchAllPaged(searchOpts.Term, *searchOpts.Page, *searchOpts.PerPage)
}
results, err := a.Srv.Store.Team().SearchAll(searchOpts.Term)
return results, int64(len(results)), err
}
func (a *App) SearchPublicTeams(term string) ([]*model.Team, *model.AppError) {