* Revert "MM-51482_Create Apps Category and link to bots DM (#22918)" This reverts commit1051925eec. * Revert "MM-51711_Feature flag: APPS sidebar category (#22766)" This reverts commit9156205178.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
16ad573979
Коммит
6a5bb53963
@@ -680,7 +680,6 @@ const defaultServerConfig: AdminConfig = {
|
|||||||
GlobalDrafts: true,
|
GlobalDrafts: true,
|
||||||
OnboardingTourTips: true,
|
OnboardingTourTips: true,
|
||||||
DeprecateCloudFree: false,
|
DeprecateCloudFree: false,
|
||||||
AppsSidebarCategory: false,
|
|
||||||
CloudReverseTrial: false,
|
CloudReverseTrial: false,
|
||||||
},
|
},
|
||||||
ImportSettings: {
|
ImportSettings: {
|
||||||
|
|||||||
@@ -353,12 +353,9 @@ func (*resolver) SidebarCategories(ctx context.Context, args struct {
|
|||||||
return nil, appErr
|
return nil, appErr
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
appsCategoryEnabled := c.App.Config().FeatureFlags.AppsSidebarCategory
|
|
||||||
|
|
||||||
opts := &store.SidebarCategorySearchOpts{
|
opts := &store.SidebarCategorySearchOpts{
|
||||||
TeamID: args.TeamID,
|
TeamID: args.TeamID,
|
||||||
ExcludeTeam: args.ExcludeTeam,
|
ExcludeTeam: args.ExcludeTeam,
|
||||||
AppsCategoryEnabled: appsCategoryEnabled,
|
|
||||||
}
|
}
|
||||||
categories, appErr = c.App.GetSidebarCategories(c.AppContext, args.UserID, opts)
|
categories, appErr = c.App.GetSidebarCategories(c.AppContext, args.UserID, opts)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
|
|||||||
@@ -25,17 +25,13 @@ func (a *App) createInitialSidebarCategories(userID string, opts *store.SidebarC
|
|||||||
|
|
||||||
func (a *App) GetSidebarCategoriesForTeamForUser(c request.CTX, userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError) {
|
func (a *App) GetSidebarCategoriesForTeamForUser(c request.CTX, userID, teamID string) (*model.OrderedSidebarCategories, *model.AppError) {
|
||||||
var appErr *model.AppError
|
var appErr *model.AppError
|
||||||
appsCategoryEnabled := a.Config().FeatureFlags.AppsSidebarCategory
|
categories, err := a.Srv().Store().Channel().GetSidebarCategoriesForTeamForUser(userID, teamID)
|
||||||
options := &store.SidebarCategorySearchOpts{
|
if err == nil && len(categories.Categories) == 0 {
|
||||||
TeamID: teamID,
|
// A user must always have categories, so migration must not have happened yet, and we should run it ourselves
|
||||||
ExcludeTeam: false,
|
categories, appErr = a.createInitialSidebarCategories(userID, &store.SidebarCategorySearchOpts{
|
||||||
AppsCategoryEnabled: appsCategoryEnabled,
|
TeamID: teamID,
|
||||||
}
|
ExcludeTeam: false,
|
||||||
categories, err := a.Srv().Store().Channel().GetSidebarCategoriesForTeamForUser(userID, teamID, options)
|
})
|
||||||
if err == nil && (len(categories.Categories) == 0 || (appsCategoryEnabled && checkMissingSystemSidebarCategories(categories))) {
|
|
||||||
// A user must always have system categories, so migration must not have happened yet, and we should run it ourselves
|
|
||||||
categories, appErr = a.createInitialSidebarCategories(userID, options)
|
|
||||||
|
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
return nil, appErr
|
return nil, appErr
|
||||||
}
|
}
|
||||||
@@ -56,17 +52,10 @@ func (a *App) GetSidebarCategoriesForTeamForUser(c request.CTX, userID, teamID s
|
|||||||
|
|
||||||
func (a *App) GetSidebarCategories(c request.CTX, userID string, opts *store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, *model.AppError) {
|
func (a *App) GetSidebarCategories(c request.CTX, userID string, opts *store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, *model.AppError) {
|
||||||
var appErr *model.AppError
|
var appErr *model.AppError
|
||||||
appsCategoryEnabled := a.Config().FeatureFlags.AppsSidebarCategory
|
categories, err := a.Srv().Store().Channel().GetSidebarCategories(userID, opts)
|
||||||
options := &store.SidebarCategorySearchOpts{
|
if err == nil && len(categories.Categories) == 0 {
|
||||||
TeamID: opts.TeamID,
|
// A user must always have categories, so migration must not have happened yet, and we should run it ourselves
|
||||||
ExcludeTeam: opts.ExcludeTeam,
|
categories, appErr = a.createInitialSidebarCategories(userID, opts)
|
||||||
AppsCategoryEnabled: appsCategoryEnabled,
|
|
||||||
}
|
|
||||||
categories, err := a.Srv().Store().Channel().GetSidebarCategories(userID, options)
|
|
||||||
if err == nil && (len(categories.Categories) == 0 || (appsCategoryEnabled && checkMissingSystemSidebarCategories(categories))) {
|
|
||||||
// A user must always have system categories, so migration must not have happened yet, and we should run it ourselves
|
|
||||||
categories, appErr = a.createInitialSidebarCategories(userID, options)
|
|
||||||
|
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
return nil, appErr
|
return nil, appErr
|
||||||
}
|
}
|
||||||
@@ -101,8 +90,7 @@ func (a *App) GetSidebarCategoryOrder(c request.CTX, userID, teamID string) ([]s
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetSidebarCategory(c request.CTX, categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
func (a *App) GetSidebarCategory(c request.CTX, categoryId string) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||||
appsCategoryEnabled := a.Config().FeatureFlags.AppsSidebarCategory
|
category, err := a.Srv().Store().Channel().GetSidebarCategory(categoryId)
|
||||||
category, err := a.Srv().Store().Channel().GetSidebarCategory(categoryId, &store.SidebarCategorySearchOpts{AppsCategoryEnabled: appsCategoryEnabled})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var nfErr *store.ErrNotFound
|
var nfErr *store.ErrNotFound
|
||||||
switch {
|
switch {
|
||||||
@@ -117,8 +105,7 @@ func (a *App) GetSidebarCategory(c request.CTX, categoryId string) (*model.Sideb
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) CreateSidebarCategory(c request.CTX, userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
func (a *App) CreateSidebarCategory(c request.CTX, userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||||
appsCategoryEnabled := a.Config().FeatureFlags.AppsSidebarCategory
|
category, err := a.Srv().Store().Channel().CreateSidebarCategory(userID, teamID, newCategory)
|
||||||
category, err := a.Srv().Store().Channel().CreateSidebarCategory(userID, teamID, newCategory, &store.SidebarCategorySearchOpts{AppsCategoryEnabled: appsCategoryEnabled})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var nfErr *store.ErrNotFound
|
var nfErr *store.ErrNotFound
|
||||||
switch {
|
switch {
|
||||||
@@ -155,13 +142,7 @@ func (a *App) UpdateSidebarCategoryOrder(c request.CTX, userID, teamID string, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) UpdateSidebarCategories(c request.CTX, userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) {
|
func (a *App) UpdateSidebarCategories(c request.CTX, userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, *model.AppError) {
|
||||||
appsCategoryEnabled := a.Config().FeatureFlags.AppsSidebarCategory
|
updatedCategories, originalCategories, err := a.Srv().Store().Channel().UpdateSidebarCategories(userID, teamID, categories)
|
||||||
updatedCategories, originalCategories, err := a.Srv().Store().Channel().UpdateSidebarCategories(
|
|
||||||
userID,
|
|
||||||
teamID,
|
|
||||||
categories,
|
|
||||||
&store.SidebarCategorySearchOpts{AppsCategoryEnabled: appsCategoryEnabled},
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, model.NewAppError("UpdateSidebarCategories", "app.channel.sidebar_categories.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
return nil, model.NewAppError("UpdateSidebarCategories", "app.channel.sidebar_categories.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||||
}
|
}
|
||||||
@@ -305,17 +286,3 @@ func (a *App) DeleteSidebarCategory(c request.CTX, userID, teamID, categoryId st
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkMissingSystemSidebarCategories(categories *model.OrderedSidebarCategories) bool {
|
|
||||||
missingSystemCategories := make(map[model.SidebarCategoryType]struct{})
|
|
||||||
|
|
||||||
for _, systemSidebarCategory := range model.SystemSidebarCategories {
|
|
||||||
missingSystemCategories[systemSidebarCategory] = struct{}{}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, category := range categories.Categories {
|
|
||||||
delete(missingSystemCategories, category.Type)
|
|
||||||
}
|
|
||||||
|
|
||||||
return len(missingSystemCategories) != 0
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,481 +0,0 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
||||||
// See LICENSE.txt for license information.
|
|
||||||
|
|
||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSidebarCategoryWithAppsCategory(t *testing.T) {
|
|
||||||
th := Setup(t).InitBasicWithAppsSidebarEnabled()
|
|
||||||
defer th.TearDown()
|
|
||||||
|
|
||||||
basicChannel2 := th.CreateChannel(th.Context, th.BasicTeam)
|
|
||||||
defer th.App.PermanentDeleteChannel(th.Context, basicChannel2)
|
|
||||||
user := th.CreateUser()
|
|
||||||
defer th.App.Srv().Store().User().PermanentDelete(user.Id)
|
|
||||||
th.LinkUserToTeam(user, th.BasicTeam)
|
|
||||||
th.AddUserToChannel(user, basicChannel2)
|
|
||||||
|
|
||||||
var createdCategory *model.SidebarCategoryWithChannels
|
|
||||||
t.Run("CreateSidebarCategory", func(t *testing.T) {
|
|
||||||
catData := model.SidebarCategoryWithChannels{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
DisplayName: "TEST",
|
|
||||||
},
|
|
||||||
Channels: []string{th.BasicChannel.Id, basicChannel2.Id, basicChannel2.Id},
|
|
||||||
}
|
|
||||||
_, err := th.App.CreateSidebarCategory(th.Context, user.Id, th.BasicTeam.Id, &catData)
|
|
||||||
require.NotNil(t, err, "Should return error due to duplicate IDs")
|
|
||||||
catData.Channels = []string{th.BasicChannel.Id, basicChannel2.Id}
|
|
||||||
cat, err := th.App.CreateSidebarCategory(th.Context, user.Id, th.BasicTeam.Id, &catData)
|
|
||||||
require.Nil(t, err, "Expected no error")
|
|
||||||
require.NotNil(t, cat, "Expected category object, got nil")
|
|
||||||
createdCategory = cat
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("UpdateSidebarCategories", func(t *testing.T) {
|
|
||||||
require.NotNil(t, createdCategory)
|
|
||||||
createdCategory.Channels = []string{th.BasicChannel.Id}
|
|
||||||
updatedCat, err := th.App.UpdateSidebarCategories(th.Context, user.Id, th.BasicTeam.Id, []*model.SidebarCategoryWithChannels{createdCategory})
|
|
||||||
require.Nil(t, err, "Expected no error")
|
|
||||||
require.NotNil(t, updatedCat, "Expected category object, got nil")
|
|
||||||
require.Len(t, updatedCat, 1)
|
|
||||||
require.Len(t, updatedCat[0].Channels, 1)
|
|
||||||
require.Equal(t, updatedCat[0].Channels[0], th.BasicChannel.Id)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("UpdateSidebarCategoryOrder", func(t *testing.T) {
|
|
||||||
err := th.App.UpdateSidebarCategoryOrder(th.Context, user.Id, th.BasicTeam.Id, []string{th.BasicChannel.Id, basicChannel2.Id})
|
|
||||||
require.NotNil(t, err, "Should return error due to invalid order")
|
|
||||||
|
|
||||||
actualOrder, err := th.App.GetSidebarCategoryOrder(th.Context, user.Id, th.BasicTeam.Id)
|
|
||||||
require.Nil(t, err, "Should fetch order successfully")
|
|
||||||
|
|
||||||
actualOrder[2], actualOrder[3] = actualOrder[3], actualOrder[2]
|
|
||||||
err = th.App.UpdateSidebarCategoryOrder(th.Context, user.Id, th.BasicTeam.Id, actualOrder)
|
|
||||||
require.Nil(t, err, "Should update order successfully")
|
|
||||||
|
|
||||||
// We create a copy of actualOrder to prevent racy read
|
|
||||||
// of the slice when the broadcast message is sent from webhub.
|
|
||||||
newOrder := make([]string, len(actualOrder))
|
|
||||||
copy(newOrder, actualOrder)
|
|
||||||
newOrder[2] = "asd"
|
|
||||||
err = th.App.UpdateSidebarCategoryOrder(th.Context, user.Id, th.BasicTeam.Id, newOrder)
|
|
||||||
require.NotNil(t, err, "Should return error due to invalid id")
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("GetSidebarCategoryOrder", func(t *testing.T) {
|
|
||||||
catOrder, err := th.App.GetSidebarCategoryOrder(th.Context, user.Id, th.BasicTeam.Id)
|
|
||||||
require.Nil(t, err, "Expected no error")
|
|
||||||
require.Len(t, catOrder, 5)
|
|
||||||
require.Equal(t, catOrder[1], createdCategory.Id, "the newly created category should be after favorites")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetSidebarCategoriesWithAppsCategory(t *testing.T) {
|
|
||||||
t.Run("should return the sidebar categories for the given user/team", func(t *testing.T) {
|
|
||||||
th := Setup(t).InitBasicWithAppsSidebarEnabled()
|
|
||||||
defer th.TearDown()
|
|
||||||
|
|
||||||
_, err := th.App.CreateSidebarCategory(th.Context, th.BasicUser.Id, th.BasicTeam.Id, &model.SidebarCategoryWithChannels{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
UserId: th.BasicUser.Id,
|
|
||||||
TeamId: th.BasicTeam.Id,
|
|
||||||
DisplayName: "new category",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
categories, err := th.App.GetSidebarCategoriesForTeamForUser(th.Context, th.BasicUser.Id, th.BasicTeam.Id)
|
|
||||||
assert.Nil(t, err)
|
|
||||||
assert.Len(t, categories.Categories, 5)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("should create the initial categories even if migration hasn't ran yet", func(t *testing.T) {
|
|
||||||
th := Setup(t).InitBasicWithAppsSidebarEnabled()
|
|
||||||
defer th.TearDown()
|
|
||||||
|
|
||||||
// Manually add the user to the team without going through the app layer to simulate a pre-existing user/team
|
|
||||||
// relationship that hasn't been migrated yet
|
|
||||||
team := th.CreateTeam()
|
|
||||||
_, err := th.App.Srv().Store().Team().SaveMember(&model.TeamMember{
|
|
||||||
TeamId: team.Id,
|
|
||||||
UserId: th.BasicUser.Id,
|
|
||||||
SchemeUser: true,
|
|
||||||
}, 100)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
categories, appErr := th.App.GetSidebarCategoriesForTeamForUser(th.Context, th.BasicUser.Id, team.Id)
|
|
||||||
assert.Nil(t, appErr)
|
|
||||||
assert.Len(t, categories.Categories, 4)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("should return a store error if a db table is missing", func(t *testing.T) {
|
|
||||||
th := Setup(t).InitBasicWithAppsSidebarEnabled()
|
|
||||||
defer th.TearDown()
|
|
||||||
|
|
||||||
// Temporarily renaming a table to force a DB error.
|
|
||||||
sqlStore := mainHelper.GetSQLStore()
|
|
||||||
_, err := sqlStore.GetMasterX().Exec("ALTER TABLE SidebarCategories RENAME TO SidebarCategoriesTest")
|
|
||||||
require.NoError(t, err)
|
|
||||||
defer func() {
|
|
||||||
_, err := sqlStore.GetMasterX().Exec("ALTER TABLE SidebarCategoriesTest RENAME TO SidebarCategories")
|
|
||||||
require.NoError(t, err)
|
|
||||||
}()
|
|
||||||
|
|
||||||
categories, appErr := th.App.GetSidebarCategoriesForTeamForUser(th.Context, th.BasicUser.Id, th.BasicTeam.Id)
|
|
||||||
assert.Nil(t, categories)
|
|
||||||
assert.NotNil(t, appErr)
|
|
||||||
assert.Equal(t, "app.channel.sidebar_categories.app_error", appErr.Id)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpdateSidebarCategoriesWithAppsCategory(t *testing.T) {
|
|
||||||
t.Run("should mute and unmute all channels in a category when it is muted or unmuted", func(t *testing.T) {
|
|
||||||
th := Setup(t).InitBasicWithAppsSidebarEnabled()
|
|
||||||
defer th.TearDown()
|
|
||||||
|
|
||||||
categories, err := th.App.GetSidebarCategoriesForTeamForUser(th.Context, th.BasicUser.Id, th.BasicTeam.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
channelsCategory := categories.Categories[1]
|
|
||||||
|
|
||||||
// Create some channels to be part of the channels category
|
|
||||||
channel1 := th.CreateChannel(th.Context, th.BasicTeam)
|
|
||||||
th.AddUserToChannel(th.BasicUser, channel1)
|
|
||||||
|
|
||||||
channel2 := th.CreateChannel(th.Context, th.BasicTeam)
|
|
||||||
th.AddUserToChannel(th.BasicUser, channel2)
|
|
||||||
|
|
||||||
// Mute the category
|
|
||||||
updated, err := th.App.UpdateSidebarCategories(th.Context, th.BasicUser.Id, th.BasicTeam.Id, []*model.SidebarCategoryWithChannels{
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: channelsCategory.Id,
|
|
||||||
Muted: true,
|
|
||||||
},
|
|
||||||
Channels: []string{channel1.Id, channel2.Id},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.True(t, updated[0].Muted)
|
|
||||||
|
|
||||||
// Confirm that the channels are now muted
|
|
||||||
member1, err := th.App.GetChannelMember(th.Context, channel1.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.True(t, member1.IsChannelMuted())
|
|
||||||
member2, err := th.App.GetChannelMember(th.Context, channel2.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.True(t, member2.IsChannelMuted())
|
|
||||||
|
|
||||||
// Unmute the category
|
|
||||||
updated, err = th.App.UpdateSidebarCategories(th.Context, th.BasicUser.Id, th.BasicTeam.Id, []*model.SidebarCategoryWithChannels{
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: channelsCategory.Id,
|
|
||||||
Muted: false,
|
|
||||||
},
|
|
||||||
Channels: []string{channel1.Id, channel2.Id},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.False(t, updated[0].Muted)
|
|
||||||
|
|
||||||
// Confirm that the channels are now unmuted
|
|
||||||
member1, err = th.App.GetChannelMember(th.Context, channel1.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.False(t, member1.IsChannelMuted())
|
|
||||||
member2, err = th.App.GetChannelMember(th.Context, channel2.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.False(t, member2.IsChannelMuted())
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("should mute and unmute channels moved from an unmuted category to a muted one and back", func(t *testing.T) {
|
|
||||||
th := Setup(t).InitBasicWithAppsSidebarEnabled()
|
|
||||||
defer th.TearDown()
|
|
||||||
|
|
||||||
// Create some channels
|
|
||||||
channel1 := th.CreateChannel(th.Context, th.BasicTeam)
|
|
||||||
th.AddUserToChannel(th.BasicUser, channel1)
|
|
||||||
|
|
||||||
channel2 := th.CreateChannel(th.Context, th.BasicTeam)
|
|
||||||
th.AddUserToChannel(th.BasicUser, channel2)
|
|
||||||
|
|
||||||
// And some categories
|
|
||||||
mutedCategory, err := th.App.CreateSidebarCategory(th.Context, th.BasicUser.Id, th.BasicTeam.Id, &model.SidebarCategoryWithChannels{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
DisplayName: "muted",
|
|
||||||
Muted: true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
require.True(t, mutedCategory.Muted)
|
|
||||||
|
|
||||||
unmutedCategory, err := th.App.CreateSidebarCategory(th.Context, th.BasicUser.Id, th.BasicTeam.Id, &model.SidebarCategoryWithChannels{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
DisplayName: "unmuted",
|
|
||||||
Muted: false,
|
|
||||||
},
|
|
||||||
Channels: []string{channel1.Id, channel2.Id},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
require.False(t, unmutedCategory.Muted)
|
|
||||||
|
|
||||||
// Move the channels
|
|
||||||
_, err = th.App.UpdateSidebarCategories(th.Context, th.BasicUser.Id, th.BasicTeam.Id, []*model.SidebarCategoryWithChannels{
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: mutedCategory.Id,
|
|
||||||
DisplayName: mutedCategory.DisplayName,
|
|
||||||
Muted: mutedCategory.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{channel1.Id, channel2.Id},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: unmutedCategory.Id,
|
|
||||||
DisplayName: unmutedCategory.DisplayName,
|
|
||||||
Muted: unmutedCategory.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
// Confirm that the channels are now muted
|
|
||||||
member1, err := th.App.GetChannelMember(th.Context, channel1.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.True(t, member1.IsChannelMuted())
|
|
||||||
member2, err := th.App.GetChannelMember(th.Context, channel2.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.True(t, member2.IsChannelMuted())
|
|
||||||
|
|
||||||
// Move the channels back
|
|
||||||
_, err = th.App.UpdateSidebarCategories(th.Context, th.BasicUser.Id, th.BasicTeam.Id, []*model.SidebarCategoryWithChannels{
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: mutedCategory.Id,
|
|
||||||
DisplayName: mutedCategory.DisplayName,
|
|
||||||
Muted: mutedCategory.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: unmutedCategory.Id,
|
|
||||||
DisplayName: unmutedCategory.DisplayName,
|
|
||||||
Muted: unmutedCategory.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{channel1.Id, channel2.Id},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
// Confirm that the channels are now unmuted
|
|
||||||
member1, err = th.App.GetChannelMember(th.Context, channel1.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.False(t, member1.IsChannelMuted())
|
|
||||||
member2, err = th.App.GetChannelMember(th.Context, channel2.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.False(t, member2.IsChannelMuted())
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("should not mute or unmute channels moved between muted categories", func(t *testing.T) {
|
|
||||||
th := Setup(t).InitBasicWithAppsSidebarEnabled()
|
|
||||||
defer th.TearDown()
|
|
||||||
|
|
||||||
// Create some channels
|
|
||||||
channel1 := th.CreateChannel(th.Context, th.BasicTeam)
|
|
||||||
th.AddUserToChannel(th.BasicUser, channel1)
|
|
||||||
|
|
||||||
channel2 := th.CreateChannel(th.Context, th.BasicTeam)
|
|
||||||
th.AddUserToChannel(th.BasicUser, channel2)
|
|
||||||
|
|
||||||
// And some categories
|
|
||||||
category1, err := th.App.CreateSidebarCategory(th.Context, th.BasicUser.Id, th.BasicTeam.Id, &model.SidebarCategoryWithChannels{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
DisplayName: "category1",
|
|
||||||
Muted: true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
require.True(t, category1.Muted)
|
|
||||||
|
|
||||||
category2, err := th.App.CreateSidebarCategory(th.Context, th.BasicUser.Id, th.BasicTeam.Id, &model.SidebarCategoryWithChannels{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
DisplayName: "category2",
|
|
||||||
Muted: true,
|
|
||||||
},
|
|
||||||
Channels: []string{channel1.Id, channel2.Id},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
require.True(t, category2.Muted)
|
|
||||||
|
|
||||||
// Move the unmuted channels
|
|
||||||
_, err = th.App.UpdateSidebarCategories(th.Context, th.BasicUser.Id, th.BasicTeam.Id, []*model.SidebarCategoryWithChannels{
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: category1.Id,
|
|
||||||
DisplayName: category1.DisplayName,
|
|
||||||
Muted: category1.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{channel1.Id, channel2.Id},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: category2.Id,
|
|
||||||
DisplayName: category2.DisplayName,
|
|
||||||
Muted: category2.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
// Confirm that the channels are still unmuted
|
|
||||||
member1, err := th.App.GetChannelMember(th.Context, channel1.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.False(t, member1.IsChannelMuted())
|
|
||||||
member2, err := th.App.GetChannelMember(th.Context, channel2.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.False(t, member2.IsChannelMuted())
|
|
||||||
|
|
||||||
// Mute the channels manually
|
|
||||||
_, err = th.App.ToggleMuteChannel(th.Context, channel1.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
_, err = th.App.ToggleMuteChannel(th.Context, channel2.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
// Move the muted channels back
|
|
||||||
_, err = th.App.UpdateSidebarCategories(th.Context, th.BasicUser.Id, th.BasicTeam.Id, []*model.SidebarCategoryWithChannels{
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: category1.Id,
|
|
||||||
DisplayName: category1.DisplayName,
|
|
||||||
Muted: category1.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: category2.Id,
|
|
||||||
DisplayName: category2.DisplayName,
|
|
||||||
Muted: category2.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{channel1.Id, channel2.Id},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
// Confirm that the channels are still muted
|
|
||||||
member1, err = th.App.GetChannelMember(th.Context, channel1.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.True(t, member1.IsChannelMuted())
|
|
||||||
member2, err = th.App.GetChannelMember(th.Context, channel2.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.True(t, member2.IsChannelMuted())
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("should not mute or unmute channels moved between unmuted categories", func(t *testing.T) {
|
|
||||||
th := Setup(t).InitBasicWithAppsSidebarEnabled()
|
|
||||||
defer th.TearDown()
|
|
||||||
|
|
||||||
// Create some channels
|
|
||||||
channel1 := th.CreateChannel(th.Context, th.BasicTeam)
|
|
||||||
th.AddUserToChannel(th.BasicUser, channel1)
|
|
||||||
|
|
||||||
channel2 := th.CreateChannel(th.Context, th.BasicTeam)
|
|
||||||
th.AddUserToChannel(th.BasicUser, channel2)
|
|
||||||
|
|
||||||
// And some categories
|
|
||||||
category1, err := th.App.CreateSidebarCategory(th.Context, th.BasicUser.Id, th.BasicTeam.Id, &model.SidebarCategoryWithChannels{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
DisplayName: "category1",
|
|
||||||
Muted: false,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
require.False(t, category1.Muted)
|
|
||||||
|
|
||||||
category2, err := th.App.CreateSidebarCategory(th.Context, th.BasicUser.Id, th.BasicTeam.Id, &model.SidebarCategoryWithChannels{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
DisplayName: "category2",
|
|
||||||
Muted: false,
|
|
||||||
},
|
|
||||||
Channels: []string{channel1.Id, channel2.Id},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
require.False(t, category2.Muted)
|
|
||||||
|
|
||||||
// Move the unmuted channels
|
|
||||||
_, err = th.App.UpdateSidebarCategories(th.Context, th.BasicUser.Id, th.BasicTeam.Id, []*model.SidebarCategoryWithChannels{
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: category1.Id,
|
|
||||||
DisplayName: category1.DisplayName,
|
|
||||||
Muted: category1.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{channel1.Id, channel2.Id},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: category2.Id,
|
|
||||||
DisplayName: category2.DisplayName,
|
|
||||||
Muted: category2.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
// Confirm that the channels are still unmuted
|
|
||||||
member1, err := th.App.GetChannelMember(th.Context, channel1.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.False(t, member1.IsChannelMuted())
|
|
||||||
member2, err := th.App.GetChannelMember(th.Context, channel2.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.False(t, member2.IsChannelMuted())
|
|
||||||
|
|
||||||
// Mute the channels manually
|
|
||||||
_, err = th.App.ToggleMuteChannel(th.Context, channel1.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
_, err = th.App.ToggleMuteChannel(th.Context, channel2.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
// Move the muted channels back
|
|
||||||
_, err = th.App.UpdateSidebarCategories(th.Context, th.BasicUser.Id, th.BasicTeam.Id, []*model.SidebarCategoryWithChannels{
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: category1.Id,
|
|
||||||
DisplayName: category1.DisplayName,
|
|
||||||
Muted: category1.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
SidebarCategory: model.SidebarCategory{
|
|
||||||
Id: category2.Id,
|
|
||||||
DisplayName: category2.DisplayName,
|
|
||||||
Muted: category2.Muted,
|
|
||||||
},
|
|
||||||
Channels: []string{channel1.Id, channel2.Id},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
// Confirm that the channels are still muted
|
|
||||||
member1, err = th.App.GetChannelMember(th.Context, channel1.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.True(t, member1.IsChannelMuted())
|
|
||||||
member2, err = th.App.GetChannelMember(th.Context, channel2.Id, th.BasicUser.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.True(t, member2.IsChannelMuted())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -253,12 +253,6 @@ func (th *TestHelper) InitBasic() *TestHelper {
|
|||||||
return th
|
return th
|
||||||
}
|
}
|
||||||
|
|
||||||
func (th *TestHelper) InitBasicWithAppsSidebarEnabled() *TestHelper {
|
|
||||||
th.App.Config().FeatureFlags.AppsSidebarCategory = true
|
|
||||||
|
|
||||||
return th.InitBasic()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (th *TestHelper) DeleteBots() *TestHelper {
|
func (th *TestHelper) DeleteBots() *TestHelper {
|
||||||
preexistingBots, _ := th.App.GetBots(&model.BotGetOptions{Page: 0, PerPage: 100})
|
preexistingBots, _ := th.App.GetBots(&model.BotGetOptions{Page: 0, PerPage: 100})
|
||||||
for _, bot := range preexistingBots {
|
for _, bot := range preexistingBots {
|
||||||
|
|||||||
@@ -956,11 +956,9 @@ func (a *App) JoinUserToTeam(c request.CTX, team *model.Team, user *model.User,
|
|||||||
return nil, model.NewAppError("JoinUserToTeam", "app.user.update_update.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
return nil, model.NewAppError("JoinUserToTeam", "app.user.update_update.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
appsCategoryEnabled := a.Config().FeatureFlags.AppsSidebarCategory
|
|
||||||
opts := &store.SidebarCategorySearchOpts{
|
opts := &store.SidebarCategorySearchOpts{
|
||||||
TeamID: team.Id,
|
TeamID: team.Id,
|
||||||
ExcludeTeam: false,
|
ExcludeTeam: false,
|
||||||
AppsCategoryEnabled: appsCategoryEnabled,
|
|
||||||
}
|
}
|
||||||
if _, err := a.createInitialSidebarCategories(user.Id, opts); err != nil {
|
if _, err := a.createInitialSidebarCategories(user.Id, opts); err != nil {
|
||||||
mlog.Warn(
|
mlog.Warn(
|
||||||
|
|||||||
@@ -1025,119 +1025,6 @@ func TestJoinUserToTeam(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJoinUserToTeamWithAppsCategoryEnabled(t *testing.T) {
|
|
||||||
th := Setup(t)
|
|
||||||
defer th.TearDown()
|
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.AppsSidebarCategory = true })
|
|
||||||
|
|
||||||
id := model.NewId()
|
|
||||||
team := &model.Team{
|
|
||||||
DisplayName: "dn_" + id,
|
|
||||||
Name: "name" + id,
|
|
||||||
Email: "success+" + id + "@simulator.amazonses.com",
|
|
||||||
Type: model.TeamOpen,
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := th.App.CreateTeam(th.Context, team)
|
|
||||||
require.Nil(t, err, "Should create a new team")
|
|
||||||
|
|
||||||
maxUsersPerTeam := th.App.Config().TeamSettings.MaxUsersPerTeam
|
|
||||||
defer func() {
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = maxUsersPerTeam })
|
|
||||||
th.App.PermanentDeleteTeam(th.Context, team)
|
|
||||||
}()
|
|
||||||
one := 1
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = &one })
|
|
||||||
|
|
||||||
t.Run("new join", func(t *testing.T) {
|
|
||||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
|
||||||
ruser, _ := th.App.CreateUser(th.Context, &user)
|
|
||||||
defer th.App.PermanentDeleteUser(th.Context, &user)
|
|
||||||
|
|
||||||
_, appErr := th.App.JoinUserToTeam(th.Context, team, ruser, "")
|
|
||||||
require.Nil(t, appErr, "Should return no error")
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("new join with limit problem", func(t *testing.T) {
|
|
||||||
user1 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
|
||||||
ruser1, _ := th.App.CreateUser(th.Context, &user1)
|
|
||||||
user2 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
|
||||||
ruser2, _ := th.App.CreateUser(th.Context, &user2)
|
|
||||||
|
|
||||||
defer th.App.PermanentDeleteUser(th.Context, &user1)
|
|
||||||
defer th.App.PermanentDeleteUser(th.Context, &user2)
|
|
||||||
|
|
||||||
_, appErr := th.App.JoinUserToTeam(th.Context, team, ruser1, ruser2.Id)
|
|
||||||
require.Nil(t, appErr, "Should return no error")
|
|
||||||
|
|
||||||
_, appErr = th.App.JoinUserToTeam(th.Context, team, ruser2, ruser1.Id)
|
|
||||||
require.NotNil(t, appErr, "Should fail")
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("re-join after leaving with limit problem", func(t *testing.T) {
|
|
||||||
user1 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
|
||||||
ruser1, _ := th.App.CreateUser(th.Context, &user1)
|
|
||||||
|
|
||||||
user2 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
|
||||||
ruser2, _ := th.App.CreateUser(th.Context, &user2)
|
|
||||||
|
|
||||||
defer th.App.PermanentDeleteUser(th.Context, &user1)
|
|
||||||
defer th.App.PermanentDeleteUser(th.Context, &user2)
|
|
||||||
|
|
||||||
_, appErr := th.App.JoinUserToTeam(th.Context, team, ruser1, ruser2.Id)
|
|
||||||
require.Nil(t, appErr, "Should return no error")
|
|
||||||
appErr = th.App.LeaveTeam(th.Context, team, ruser1, ruser1.Id)
|
|
||||||
require.Nil(t, appErr, "Should return no error")
|
|
||||||
_, appErr = th.App.JoinUserToTeam(th.Context, team, ruser2, ruser2.Id)
|
|
||||||
require.Nil(t, appErr, "Should return no error")
|
|
||||||
|
|
||||||
_, appErr = th.App.JoinUserToTeam(th.Context, team, ruser1, ruser2.Id)
|
|
||||||
require.NotNil(t, appErr, "Should fail")
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("new join with correct scheme_admin value from group syncable", func(t *testing.T) {
|
|
||||||
user1 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
|
||||||
ruser1, _ := th.App.CreateUser(th.Context, &user1)
|
|
||||||
defer th.App.PermanentDeleteUser(th.Context, &user1)
|
|
||||||
|
|
||||||
group := th.CreateGroup()
|
|
||||||
|
|
||||||
_, err = th.App.UpsertGroupMember(group.Id, user1.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
gs, err := th.App.UpsertGroupSyncable(&model.GroupSyncable{
|
|
||||||
AutoAdd: true,
|
|
||||||
SyncableId: team.Id,
|
|
||||||
Type: model.GroupSyncableTypeTeam,
|
|
||||||
GroupId: group.Id,
|
|
||||||
SchemeAdmin: false,
|
|
||||||
})
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = model.NewInt(999) })
|
|
||||||
|
|
||||||
tm1, appErr := th.App.JoinUserToTeam(th.Context, team, ruser1, "")
|
|
||||||
require.Nil(t, appErr)
|
|
||||||
require.False(t, tm1.SchemeAdmin)
|
|
||||||
|
|
||||||
user2 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
|
||||||
ruser2, _ := th.App.CreateUser(th.Context, &user2)
|
|
||||||
defer th.App.PermanentDeleteUser(th.Context, &user2)
|
|
||||||
|
|
||||||
_, err = th.App.UpsertGroupMember(group.Id, user2.Id)
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
gs.SchemeAdmin = true
|
|
||||||
_, err = th.App.UpdateGroupSyncable(gs)
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
tm2, appErr := th.App.JoinUserToTeam(th.Context, team, ruser2, "")
|
|
||||||
require.Nil(t, appErr)
|
|
||||||
require.True(t, tm2.SchemeAdmin)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLeaveTeamPanic(t *testing.T) {
|
func TestLeaveTeamPanic(t *testing.T) {
|
||||||
th := SetupWithStoreMock(t)
|
th := SetupWithStoreMock(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|||||||
@@ -296,8 +296,6 @@ func generateLayer(name, templateFile string) ([]byte, error) {
|
|||||||
paramsWithType = append(paramsWithType, fmt.Sprintf("%s store.%s", param.Name, param.Type))
|
paramsWithType = append(paramsWithType, fmt.Sprintf("%s store.%s", param.Name, param.Type))
|
||||||
case "*UserGetByIdsOpts", "*ChannelMemberGraphQLSearchOpts", "*SidebarCategorySearchOpts":
|
case "*UserGetByIdsOpts", "*ChannelMemberGraphQLSearchOpts", "*SidebarCategorySearchOpts":
|
||||||
paramsWithType = append(paramsWithType, fmt.Sprintf("%s *store.%s", param.Name, strings.TrimPrefix(param.Type, "*")))
|
paramsWithType = append(paramsWithType, fmt.Sprintf("%s *store.%s", param.Name, strings.TrimPrefix(param.Type, "*")))
|
||||||
case "...*SidebarCategorySearchOpts":
|
|
||||||
paramsWithType = append(paramsWithType, fmt.Sprintf("%s ...*store.%s", param.Name, strings.TrimPrefix(param.Type, "...*")))
|
|
||||||
default:
|
default:
|
||||||
paramsWithType = append(paramsWithType, fmt.Sprintf("%s %s", param.Name, param.Type))
|
paramsWithType = append(paramsWithType, fmt.Sprintf("%s %s", param.Name, param.Type))
|
||||||
}
|
}
|
||||||
@@ -312,8 +310,6 @@ func generateLayer(name, templateFile string) ([]byte, error) {
|
|||||||
paramsWithType = append(paramsWithType, fmt.Sprintf("%s store.%s", param.Name, param.Type))
|
paramsWithType = append(paramsWithType, fmt.Sprintf("%s store.%s", param.Name, param.Type))
|
||||||
case "*UserGetByIdsOpts", "*ChannelMemberGraphQLSearchOpts", "*SidebarCategorySearchOpts":
|
case "*UserGetByIdsOpts", "*ChannelMemberGraphQLSearchOpts", "*SidebarCategorySearchOpts":
|
||||||
paramsWithType = append(paramsWithType, fmt.Sprintf("%s *store.%s", param.Name, strings.TrimPrefix(param.Type, "*")))
|
paramsWithType = append(paramsWithType, fmt.Sprintf("%s *store.%s", param.Name, strings.TrimPrefix(param.Type, "*")))
|
||||||
case "...*SidebarCategorySearchOpts":
|
|
||||||
paramsWithType = append(paramsWithType, fmt.Sprintf("%s ...*store.%s", param.Name, strings.TrimPrefix(param.Type, "...*")))
|
|
||||||
default:
|
default:
|
||||||
paramsWithType = append(paramsWithType, fmt.Sprintf("%s %s", param.Name, param.Type))
|
paramsWithType = append(paramsWithType, fmt.Sprintf("%s %s", param.Name, param.Type))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -819,7 +819,7 @@ func (s *OpenTracingLayerChannelStore) CreateInitialSidebarCategories(userID str
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OpenTracingLayerChannelStore) CreateSidebarCategory(userID string, teamID string, newCategory *model.SidebarCategoryWithChannels, options ...*store.SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error) {
|
func (s *OpenTracingLayerChannelStore) CreateSidebarCategory(userID string, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
|
||||||
origCtx := s.Root.Store.Context()
|
origCtx := s.Root.Store.Context()
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.CreateSidebarCategory")
|
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.CreateSidebarCategory")
|
||||||
s.Root.Store.SetContext(newCtx)
|
s.Root.Store.SetContext(newCtx)
|
||||||
@@ -828,7 +828,7 @@ func (s *OpenTracingLayerChannelStore) CreateSidebarCategory(userID string, team
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
result, err := s.ChannelStore.CreateSidebarCategory(userID, teamID, newCategory, options...)
|
result, err := s.ChannelStore.CreateSidebarCategory(userID, teamID, newCategory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
span.LogFields(spanlog.Error(err))
|
span.LogFields(spanlog.Error(err))
|
||||||
ext.Error.Set(span, true)
|
ext.Error.Set(span, true)
|
||||||
@@ -1053,24 +1053,6 @@ func (s *OpenTracingLayerChannelStore) GetAllDirectChannelsForExportAfter(limit
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OpenTracingLayerChannelStore) GetBotChannelsByUser(userID string, opts store.ChannelSearchOpts) (model.ChannelList, error) {
|
|
||||||
origCtx := s.Root.Store.Context()
|
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetBotChannelsByUser")
|
|
||||||
s.Root.Store.SetContext(newCtx)
|
|
||||||
defer func() {
|
|
||||||
s.Root.Store.SetContext(origCtx)
|
|
||||||
}()
|
|
||||||
|
|
||||||
defer span.Finish()
|
|
||||||
result, err := s.ChannelStore.GetBotChannelsByUser(userID, opts)
|
|
||||||
if err != nil {
|
|
||||||
span.LogFields(spanlog.Error(err))
|
|
||||||
ext.Error.Set(span, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *OpenTracingLayerChannelStore) GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
|
func (s *OpenTracingLayerChannelStore) GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
|
||||||
origCtx := s.Root.Store.Context()
|
origCtx := s.Root.Store.Context()
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetByName")
|
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetByName")
|
||||||
@@ -1768,7 +1750,7 @@ func (s *OpenTracingLayerChannelStore) GetSidebarCategories(userID string, opts
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OpenTracingLayerChannelStore) GetSidebarCategoriesForTeamForUser(userID string, teamID string, options ...*store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error) {
|
func (s *OpenTracingLayerChannelStore) GetSidebarCategoriesForTeamForUser(userID string, teamID string) (*model.OrderedSidebarCategories, error) {
|
||||||
origCtx := s.Root.Store.Context()
|
origCtx := s.Root.Store.Context()
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategoriesForTeamForUser")
|
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategoriesForTeamForUser")
|
||||||
s.Root.Store.SetContext(newCtx)
|
s.Root.Store.SetContext(newCtx)
|
||||||
@@ -1777,7 +1759,7 @@ func (s *OpenTracingLayerChannelStore) GetSidebarCategoriesForTeamForUser(userID
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
result, err := s.ChannelStore.GetSidebarCategoriesForTeamForUser(userID, teamID, options...)
|
result, err := s.ChannelStore.GetSidebarCategoriesForTeamForUser(userID, teamID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
span.LogFields(spanlog.Error(err))
|
span.LogFields(spanlog.Error(err))
|
||||||
ext.Error.Set(span, true)
|
ext.Error.Set(span, true)
|
||||||
@@ -1786,7 +1768,7 @@ func (s *OpenTracingLayerChannelStore) GetSidebarCategoriesForTeamForUser(userID
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OpenTracingLayerChannelStore) GetSidebarCategory(categoryID string, options ...*store.SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error) {
|
func (s *OpenTracingLayerChannelStore) GetSidebarCategory(categoryID string) (*model.SidebarCategoryWithChannels, error) {
|
||||||
origCtx := s.Root.Store.Context()
|
origCtx := s.Root.Store.Context()
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategory")
|
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetSidebarCategory")
|
||||||
s.Root.Store.SetContext(newCtx)
|
s.Root.Store.SetContext(newCtx)
|
||||||
@@ -1795,7 +1777,7 @@ func (s *OpenTracingLayerChannelStore) GetSidebarCategory(categoryID string, opt
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
result, err := s.ChannelStore.GetSidebarCategory(categoryID, options...)
|
result, err := s.ChannelStore.GetSidebarCategory(categoryID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
span.LogFields(spanlog.Error(err))
|
span.LogFields(spanlog.Error(err))
|
||||||
ext.Error.Set(span, true)
|
ext.Error.Set(span, true)
|
||||||
@@ -2628,7 +2610,7 @@ func (s *OpenTracingLayerChannelStore) UpdateMultipleMembers(members []*model.Ch
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OpenTracingLayerChannelStore) UpdateSidebarCategories(userID string, teamID string, categories []*model.SidebarCategoryWithChannels, options ...*store.SidebarCategorySearchOpts) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) {
|
func (s *OpenTracingLayerChannelStore) UpdateSidebarCategories(userID string, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) {
|
||||||
origCtx := s.Root.Store.Context()
|
origCtx := s.Root.Store.Context()
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateSidebarCategories")
|
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.UpdateSidebarCategories")
|
||||||
s.Root.Store.SetContext(newCtx)
|
s.Root.Store.SetContext(newCtx)
|
||||||
@@ -2637,7 +2619,7 @@ func (s *OpenTracingLayerChannelStore) UpdateSidebarCategories(userID string, te
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
result, resultVar1, err := s.ChannelStore.UpdateSidebarCategories(userID, teamID, categories, options...)
|
result, resultVar1, err := s.ChannelStore.UpdateSidebarCategories(userID, teamID, categories)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
span.LogFields(spanlog.Error(err))
|
span.LogFields(spanlog.Error(err))
|
||||||
ext.Error.Set(span, true)
|
ext.Error.Set(span, true)
|
||||||
|
|||||||
@@ -881,11 +881,11 @@ func (s *RetryLayerChannelStore) CreateInitialSidebarCategories(userID string, o
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RetryLayerChannelStore) CreateSidebarCategory(userID string, teamID string, newCategory *model.SidebarCategoryWithChannels, options ...*store.SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error) {
|
func (s *RetryLayerChannelStore) CreateSidebarCategory(userID string, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
|
||||||
|
|
||||||
tries := 0
|
tries := 0
|
||||||
for {
|
for {
|
||||||
result, err := s.ChannelStore.CreateSidebarCategory(userID, teamID, newCategory, options...)
|
result, err := s.ChannelStore.CreateSidebarCategory(userID, teamID, newCategory)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
@@ -1154,27 +1154,6 @@ func (s *RetryLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, a
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RetryLayerChannelStore) GetBotChannelsByUser(userID string, opts store.ChannelSearchOpts) (model.ChannelList, error) {
|
|
||||||
|
|
||||||
tries := 0
|
|
||||||
for {
|
|
||||||
result, err := s.ChannelStore.GetBotChannelsByUser(userID, opts)
|
|
||||||
if err == nil {
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
if !isRepeatableError(err) {
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
tries++
|
|
||||||
if tries >= 3 {
|
|
||||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
timepkg.Sleep(100 * timepkg.Millisecond)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *RetryLayerChannelStore) GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
|
func (s *RetryLayerChannelStore) GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
|
||||||
|
|
||||||
tries := 0
|
tries := 0
|
||||||
@@ -1979,11 +1958,11 @@ func (s *RetryLayerChannelStore) GetSidebarCategories(userID string, opts *store
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RetryLayerChannelStore) GetSidebarCategoriesForTeamForUser(userID string, teamID string, options ...*store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error) {
|
func (s *RetryLayerChannelStore) GetSidebarCategoriesForTeamForUser(userID string, teamID string) (*model.OrderedSidebarCategories, error) {
|
||||||
|
|
||||||
tries := 0
|
tries := 0
|
||||||
for {
|
for {
|
||||||
result, err := s.ChannelStore.GetSidebarCategoriesForTeamForUser(userID, teamID, options...)
|
result, err := s.ChannelStore.GetSidebarCategoriesForTeamForUser(userID, teamID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
@@ -2000,11 +1979,11 @@ func (s *RetryLayerChannelStore) GetSidebarCategoriesForTeamForUser(userID strin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RetryLayerChannelStore) GetSidebarCategory(categoryID string, options ...*store.SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error) {
|
func (s *RetryLayerChannelStore) GetSidebarCategory(categoryID string) (*model.SidebarCategoryWithChannels, error) {
|
||||||
|
|
||||||
tries := 0
|
tries := 0
|
||||||
for {
|
for {
|
||||||
result, err := s.ChannelStore.GetSidebarCategory(categoryID, options...)
|
result, err := s.ChannelStore.GetSidebarCategory(categoryID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
@@ -2909,11 +2888,11 @@ func (s *RetryLayerChannelStore) UpdateMultipleMembers(members []*model.ChannelM
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RetryLayerChannelStore) UpdateSidebarCategories(userID string, teamID string, categories []*model.SidebarCategoryWithChannels, options ...*store.SidebarCategorySearchOpts) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) {
|
func (s *RetryLayerChannelStore) UpdateSidebarCategories(userID string, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) {
|
||||||
|
|
||||||
tries := 0
|
tries := 0
|
||||||
for {
|
for {
|
||||||
result, resultVar1, err := s.ChannelStore.UpdateSidebarCategories(userID, teamID, categories, options...)
|
result, resultVar1, err := s.ChannelStore.UpdateSidebarCategories(userID, teamID, categories)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return result, resultVar1, nil
|
return result, resultVar1, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1190,38 +1190,6 @@ func (s SqlChannelStore) GetChannelsByUser(userId string, includeDeleted bool, l
|
|||||||
return channels, nil
|
return channels, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetBotChannelsByUser(userId string, opts store.ChannelSearchOpts) (model.ChannelList, error) {
|
|
||||||
query := s.getQueryBuilder().
|
|
||||||
Select("C.*").
|
|
||||||
From("Channels as C, ChannelMembers as CM1, ChannelMembers as CM2, Bots as B").
|
|
||||||
Where(sq.And{
|
|
||||||
sq.Expr("C.Id = CM1.ChannelId"),
|
|
||||||
sq.Eq{"CM1.UserId": userId},
|
|
||||||
sq.Eq{"C.Type": model.ChannelTypeDirect},
|
|
||||||
sq.Expr("C.Id = CM2.ChannelId"),
|
|
||||||
sq.Expr("CM2.UserId = B.UserId"),
|
|
||||||
sq.Eq{"B.DeleteAt": 0},
|
|
||||||
}).
|
|
||||||
OrderBy("C.Id ASC")
|
|
||||||
|
|
||||||
if !opts.IncludeDeleted {
|
|
||||||
query = query.Where(sq.Eq{"C.DeleteAt": int(0)})
|
|
||||||
}
|
|
||||||
|
|
||||||
sql, args, err := query.ToSql()
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "GetBotChannelsByUser_ToSql")
|
|
||||||
}
|
|
||||||
|
|
||||||
channels := model.ChannelList{}
|
|
||||||
err = s.GetReplicaX().Select(&channels, sql, args...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "failed to get bot channels with UserId=%s", userId)
|
|
||||||
}
|
|
||||||
|
|
||||||
return channels, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s SqlChannelStore) GetAllChannelMembersById(channelID string) ([]string, error) {
|
func (s SqlChannelStore) GetAllChannelMembersById(channelID string) ([]string, error) {
|
||||||
sql, args, err := s.channelMembersForTeamWithSchemeSelectQuery.Where(sq.Eq{
|
sql, args, err := s.channelMembersForTeamWithSchemeSelectQuery.Where(sq.Eq{
|
||||||
"ChannelId": channelID,
|
"ChannelId": channelID,
|
||||||
|
|||||||
@@ -58,7 +58,11 @@ func (s SqlChannelStore) createInitialSidebarCategoriesT(transaction *sqlxTxWrap
|
|||||||
From("SidebarCategories").
|
From("SidebarCategories").
|
||||||
Where(sq.Eq{
|
Where(sq.Eq{
|
||||||
"UserId": userId,
|
"UserId": userId,
|
||||||
"Type": model.SystemSidebarCategories,
|
"Type": []model.SidebarCategoryType{
|
||||||
|
model.SidebarCategoryFavorites,
|
||||||
|
model.SidebarCategoryChannels,
|
||||||
|
model.SidebarCategoryDirectMessages,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if !opts.ExcludeTeam {
|
if !opts.ExcludeTeam {
|
||||||
@@ -153,15 +157,6 @@ func (s SqlChannelStore) createInitialSidebarCategoriesT(transaction *sqlxTxWrap
|
|||||||
hasInsert = true
|
hasInsert = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.AppsCategoryEnabled {
|
|
||||||
teamIDs = getRequiredTeamIDs(model.SidebarCategoryApps, opts)
|
|
||||||
for _, teamID := range teamIDs {
|
|
||||||
appsCategoryId := fmt.Sprintf("%s_%s_%s", model.SidebarCategoryApps, userId, teamID)
|
|
||||||
insertBuilder = insertBuilder.Values(appsCategoryId, userId, teamID, model.DefaultSidebarSortOrderApps, model.SidebarCategorySortDefault, model.SidebarCategoryApps, "Apps" /* This will be retranslated by the client into the user's locale */, false, false)
|
|
||||||
hasInsert = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if hasInsert {
|
if hasInsert {
|
||||||
sql, args, err := insertBuilder.ToSql()
|
sql, args, err := insertBuilder.ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -301,7 +296,7 @@ type sidebarCategoryForJoin struct {
|
|||||||
ChannelId *string
|
ChannelId *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels, options ...*store.SidebarCategorySearchOpts) (_ *model.SidebarCategoryWithChannels, err error) {
|
func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategory *model.SidebarCategoryWithChannels) (_ *model.SidebarCategoryWithChannels, err error) {
|
||||||
transaction, err := s.GetMasterX().Beginx()
|
transaction, err := s.GetMasterX().Beginx()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "begin_transaction")
|
return nil, errors.Wrap(err, "begin_transaction")
|
||||||
@@ -309,15 +304,9 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
|
|||||||
|
|
||||||
defer finalizeTransactionX(transaction, &err)
|
defer finalizeTransactionX(transaction, &err)
|
||||||
|
|
||||||
appsCategoryEnabled := false
|
|
||||||
if len(options) > 0 {
|
|
||||||
appsCategoryEnabled = options[0].AppsCategoryEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
opts := &store.SidebarCategorySearchOpts{
|
opts := &store.SidebarCategorySearchOpts{
|
||||||
TeamID: teamId,
|
TeamID: teamId,
|
||||||
ExcludeTeam: false,
|
ExcludeTeam: false,
|
||||||
AppsCategoryEnabled: appsCategoryEnabled,
|
|
||||||
}
|
}
|
||||||
categoriesWithOrder, err := s.getSidebarCategoriesT(transaction, userId, opts)
|
categoriesWithOrder, err := s.getSidebarCategoriesT(transaction, userId, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -429,14 +418,14 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) completePopulatingCategoryChannels(category *model.SidebarCategoryWithChannels, appsCategoryEnabled bool) (_ *model.SidebarCategoryWithChannels, err error) {
|
func (s SqlChannelStore) completePopulatingCategoryChannels(category *model.SidebarCategoryWithChannels) (_ *model.SidebarCategoryWithChannels, err error) {
|
||||||
transaction, err := s.GetMasterX().Beginx()
|
transaction, err := s.GetMasterX().Beginx()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "begin_transaction")
|
return nil, errors.Wrap(err, "begin_transaction")
|
||||||
}
|
}
|
||||||
defer finalizeTransactionX(transaction, &err)
|
defer finalizeTransactionX(transaction, &err)
|
||||||
|
|
||||||
result, err := s.completePopulatingCategoryChannelsT(transaction, category, appsCategoryEnabled)
|
result, err := s.completePopulatingCategoryChannelsT(transaction, category)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -448,38 +437,15 @@ func (s SqlChannelStore) completePopulatingCategoryChannels(category *model.Side
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) completePopulatingCategoryChannelsT(db dbSelecter, category *model.SidebarCategoryWithChannels, appsCategoryEnabled bool) (*model.SidebarCategoryWithChannels, error) {
|
func (s SqlChannelStore) completePopulatingCategoryChannelsT(db dbSelecter, category *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
|
||||||
if category.Type == model.SidebarCategoryCustom || category.Type == model.SidebarCategoryFavorites {
|
if category.Type == model.SidebarCategoryCustom || category.Type == model.SidebarCategoryFavorites {
|
||||||
return category, nil
|
return category, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var channelTypeFilter sq.Sqlizer
|
var channelTypeFilter sq.Sqlizer
|
||||||
if category.Type == model.SidebarCategoryApps || category.Type == model.SidebarCategoryDirectMessages {
|
if category.Type == model.SidebarCategoryDirectMessages {
|
||||||
botChannelsIDs := []string{}
|
// any DM/GM channels that aren't in any category should be returned as part of the Direct Messages category
|
||||||
if appsCategoryEnabled {
|
channelTypeFilter = sq.Eq{"Channels.Type": []model.ChannelType{model.ChannelTypeDirect, model.ChannelTypeGroup}}
|
||||||
botChannels, err := s.SqlStore.stores.channel.GetBotChannelsByUser(category.UserId, store.ChannelSearchOpts{})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, botChannel := range botChannels {
|
|
||||||
botChannelsIDs = append(botChannelsIDs, botChannel.Id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if category.Type == model.SidebarCategoryApps {
|
|
||||||
// any DM channels with Bots that aren't in any category should be returned as part of the Apps category
|
|
||||||
channelTypeFilter = sq.And{
|
|
||||||
sq.Eq{"Channels.Type": model.ChannelTypeDirect},
|
|
||||||
sq.Eq{"Channels.Id": botChannelsIDs},
|
|
||||||
}
|
|
||||||
} else if category.Type == model.SidebarCategoryDirectMessages {
|
|
||||||
// any DM/GM channels with Users that aren't in any category should be returned as part of the Direct Messages category
|
|
||||||
channelTypeFilter = sq.And{
|
|
||||||
sq.Eq{"Channels.Type": []model.ChannelType{model.ChannelTypeDirect, model.ChannelTypeGroup}},
|
|
||||||
sq.NotEq{"Channels.Id": botChannelsIDs},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if category.Type == model.SidebarCategoryChannels {
|
} else if category.Type == model.SidebarCategoryChannels {
|
||||||
// any public/private channels that are on the current team and aren't in any category should be returned as part of the Channels category
|
// any public/private channels that are on the current team and aren't in any category should be returned as part of the Channels category
|
||||||
channelTypeFilter = sq.And{
|
channelTypeFilter = sq.And{
|
||||||
@@ -502,12 +468,6 @@ func (s SqlChannelStore) completePopulatingCategoryChannelsT(db dbSelecter, cate
|
|||||||
}).
|
}).
|
||||||
Suffix(")")
|
Suffix(")")
|
||||||
|
|
||||||
if !appsCategoryEnabled {
|
|
||||||
doesNotHaveSidebarChannel = doesNotHaveSidebarChannel.Where(
|
|
||||||
sq.NotEq{"SidebarCategories.Type": model.SidebarCategoryApps},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
channels := []string{}
|
channels := []string{}
|
||||||
sql, args, err := s.getQueryBuilder().
|
sql, args, err := s.getQueryBuilder().
|
||||||
Select("Id").
|
Select("Id").
|
||||||
@@ -532,7 +492,7 @@ func (s SqlChannelStore) completePopulatingCategoryChannelsT(db dbSelecter, cate
|
|||||||
return category, nil
|
return category, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetSidebarCategory(categoryId string, options ...*store.SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error) {
|
func (s SqlChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCategoryWithChannels, error) {
|
||||||
sql, args, err := s.getQueryBuilder().
|
sql, args, err := s.getQueryBuilder().
|
||||||
Select("SidebarCategories.*", "SidebarChannels.ChannelId").
|
Select("SidebarCategories.*", "SidebarChannels.ChannelId").
|
||||||
From("SidebarCategories").
|
From("SidebarCategories").
|
||||||
@@ -561,13 +521,7 @@ func (s SqlChannelStore) GetSidebarCategory(categoryId string, options ...*store
|
|||||||
result.Channels = append(result.Channels, *category.ChannelId)
|
result.Channels = append(result.Channels, *category.ChannelId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return s.completePopulatingCategoryChannels(result)
|
||||||
appsCategoryEnabled := false
|
|
||||||
if len(options) > 0 {
|
|
||||||
appsCategoryEnabled = options[0].AppsCategoryEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.completePopulatingCategoryChannels(result, appsCategoryEnabled)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) getSidebarCategoriesT(db dbSelecter, userId string, opts *store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error) {
|
func (s SqlChannelStore) getSidebarCategoriesT(db dbSelecter, userId string, opts *store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error) {
|
||||||
@@ -599,10 +553,6 @@ func (s SqlChannelStore) getSidebarCategoriesT(db dbSelecter, userId string, opt
|
|||||||
query = query.Where(sq.Eq{"SidebarCategories.TeamId": opts.TeamID})
|
query = query.Where(sq.Eq{"SidebarCategories.TeamId": opts.TeamID})
|
||||||
}
|
}
|
||||||
|
|
||||||
if !opts.AppsCategoryEnabled {
|
|
||||||
query = query.Where(sq.NotEq{"SidebarCategories.Type": model.SidebarCategoryApps})
|
|
||||||
}
|
|
||||||
|
|
||||||
sql, args, err := query.ToSql()
|
sql, args, err := query.ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "sidebar_categories_tosql")
|
return nil, errors.Wrap(err, "sidebar_categories_tosql")
|
||||||
@@ -633,7 +583,7 @@ func (s SqlChannelStore) getSidebarCategoriesT(db dbSelecter, userId string, opt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, category := range oc.Categories {
|
for _, category := range oc.Categories {
|
||||||
if _, err := s.completePopulatingCategoryChannelsT(db, category, opts.AppsCategoryEnabled); err != nil {
|
if _, err := s.completePopulatingCategoryChannelsT(db, category); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -641,16 +591,10 @@ func (s SqlChannelStore) getSidebarCategoriesT(db dbSelecter, userId string, opt
|
|||||||
return &oc, nil
|
return &oc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetSidebarCategoriesForTeamForUser(userId, teamId string, options ...*store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error) {
|
func (s SqlChannelStore) GetSidebarCategoriesForTeamForUser(userId, teamId string) (*model.OrderedSidebarCategories, error) {
|
||||||
appsCategoryEnabled := false
|
|
||||||
if len(options) > 0 {
|
|
||||||
appsCategoryEnabled = options[0].AppsCategoryEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
opts := &store.SidebarCategorySearchOpts{
|
opts := &store.SidebarCategorySearchOpts{
|
||||||
TeamID: teamId,
|
TeamID: teamId,
|
||||||
ExcludeTeam: false,
|
ExcludeTeam: false,
|
||||||
AppsCategoryEnabled: appsCategoryEnabled,
|
|
||||||
}
|
}
|
||||||
return s.getSidebarCategoriesT(s.GetReplicaX(), userId, opts)
|
return s.getSidebarCategoriesT(s.GetReplicaX(), userId, opts)
|
||||||
}
|
}
|
||||||
@@ -744,22 +688,17 @@ func (s SqlChannelStore) UpdateSidebarCategoryOrder(userId, teamId string, categ
|
|||||||
}
|
}
|
||||||
|
|
||||||
//nolint:unparam
|
//nolint:unparam
|
||||||
func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels, options ...*store.SidebarCategorySearchOpts) (updated []*model.SidebarCategoryWithChannels, original []*model.SidebarCategoryWithChannels, err error) {
|
func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categories []*model.SidebarCategoryWithChannels) (updated []*model.SidebarCategoryWithChannels, original []*model.SidebarCategoryWithChannels, err error) {
|
||||||
transaction, err := s.GetMasterX().Beginx()
|
transaction, err := s.GetMasterX().Beginx()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Wrap(err, "begin_transaction")
|
return nil, nil, errors.Wrap(err, "begin_transaction")
|
||||||
}
|
}
|
||||||
defer finalizeTransactionX(transaction, &err)
|
defer finalizeTransactionX(transaction, &err)
|
||||||
|
|
||||||
opts := &store.SidebarCategorySearchOpts{}
|
|
||||||
if len(options) > 0 {
|
|
||||||
opts = options[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
updatedCategories := []*model.SidebarCategoryWithChannels{}
|
updatedCategories := []*model.SidebarCategoryWithChannels{}
|
||||||
originalCategories := []*model.SidebarCategoryWithChannels{}
|
originalCategories := []*model.SidebarCategoryWithChannels{}
|
||||||
for _, category := range categories {
|
for _, category := range categories {
|
||||||
srcCategory, err2 := s.GetSidebarCategory(category.Id, opts)
|
srcCategory, err2 := s.GetSidebarCategory(category.Id)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
return nil, nil, errors.Wrap(err2, "failed to find SidebarCategories")
|
return nil, nil, errors.Wrap(err2, "failed to find SidebarCategories")
|
||||||
}
|
}
|
||||||
@@ -780,7 +719,7 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
|
|||||||
destCategory.DisplayName = srcCategory.DisplayName
|
destCategory.DisplayName = srcCategory.DisplayName
|
||||||
}
|
}
|
||||||
|
|
||||||
if destCategory.Type != model.SidebarCategoryDirectMessages && destCategory.Type != model.SidebarCategoryApps {
|
if destCategory.Type != model.SidebarCategoryDirectMessages {
|
||||||
destCategory.Channels = make([]string, len(category.Channels))
|
destCategory.Channels = make([]string, len(category.Channels))
|
||||||
copy(destCategory.Channels, category.Channels)
|
copy(destCategory.Channels, category.Channels)
|
||||||
|
|
||||||
@@ -807,7 +746,7 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we are updating DM category, it's order can't channel order cannot be changed.
|
// if we are updating DM category, it's order can't channel order cannot be changed.
|
||||||
if category.Type != model.SidebarCategoryDirectMessages && destCategory.Type != model.SidebarCategoryApps {
|
if category.Type != model.SidebarCategoryDirectMessages {
|
||||||
// Remove any SidebarChannels entries that were either:
|
// Remove any SidebarChannels entries that were either:
|
||||||
// - previously in this category (and any ones that are still in the category will be recreated below)
|
// - previously in this category (and any ones that are still in the category will be recreated below)
|
||||||
// - in another category and are being added to this category
|
// - in another category and are being added to this category
|
||||||
@@ -904,7 +843,7 @@ func (s SqlChannelStore) UpdateSidebarCategories(userId, teamId string, categori
|
|||||||
|
|
||||||
// Ensure Channels are populated for Channels/Direct Messages category if they change
|
// Ensure Channels are populated for Channels/Direct Messages category if they change
|
||||||
for i, updatedCategory := range updatedCategories {
|
for i, updatedCategory := range updatedCategories {
|
||||||
populated, nErr := s.completePopulatingCategoryChannelsT(transaction, updatedCategory, opts.AppsCategoryEnabled)
|
populated, nErr := s.completePopulatingCategoryChannelsT(transaction, updatedCategory)
|
||||||
if nErr != nil {
|
if nErr != nil {
|
||||||
return nil, nil, nErr
|
return nil, nil, nErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,5 +11,4 @@ import (
|
|||||||
|
|
||||||
func TestChannelStoreCategories(t *testing.T) {
|
func TestChannelStoreCategories(t *testing.T) {
|
||||||
StoreTestWithSqlStore(t, storetest.TestChannelStoreCategories)
|
StoreTestWithSqlStore(t, storetest.TestChannelStoreCategories)
|
||||||
StoreTestWithSqlStore(t, storetest.TestChannelStoreCategoriesWithAppsCategory)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,7 +198,6 @@ type ChannelStore interface {
|
|||||||
GetChannels(teamID, userID string, opts *model.ChannelSearchOpts) (model.ChannelList, error)
|
GetChannels(teamID, userID string, opts *model.ChannelSearchOpts) (model.ChannelList, error)
|
||||||
GetChannelsWithCursor(teamId string, userId string, opts *model.ChannelSearchOpts, afterChannelID string) (model.ChannelList, error)
|
GetChannelsWithCursor(teamId string, userId string, opts *model.ChannelSearchOpts, afterChannelID string) (model.ChannelList, error)
|
||||||
GetChannelsByUser(userID string, includeDeleted bool, lastDeleteAt, pageSize int, fromChannelID string) (model.ChannelList, error)
|
GetChannelsByUser(userID string, includeDeleted bool, lastDeleteAt, pageSize int, fromChannelID string) (model.ChannelList, error)
|
||||||
GetBotChannelsByUser(userID string, opts ChannelSearchOpts) (model.ChannelList, error)
|
|
||||||
GetAllChannelMembersById(id string) ([]string, error)
|
GetAllChannelMembersById(id string) ([]string, error)
|
||||||
GetAllChannels(page, perPage int, opts ChannelSearchOpts) (model.ChannelListWithTeamData, error)
|
GetAllChannels(page, perPage int, opts ChannelSearchOpts) (model.ChannelListWithTeamData, error)
|
||||||
GetAllChannelsCount(opts ChannelSearchOpts) (int64, error)
|
GetAllChannelsCount(opts ChannelSearchOpts) (int64, error)
|
||||||
@@ -273,13 +272,13 @@ type ChannelStore interface {
|
|||||||
ResetAllChannelSchemes() error
|
ResetAllChannelSchemes() error
|
||||||
ClearAllCustomRoleAssignments() error
|
ClearAllCustomRoleAssignments() error
|
||||||
CreateInitialSidebarCategories(userID string, opts *SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error)
|
CreateInitialSidebarCategories(userID string, opts *SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error)
|
||||||
GetSidebarCategoriesForTeamForUser(userID, teamID string, options ...*SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error)
|
GetSidebarCategoriesForTeamForUser(userID, teamID string) (*model.OrderedSidebarCategories, error)
|
||||||
GetSidebarCategories(userID string, opts *SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error)
|
GetSidebarCategories(userID string, opts *SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error)
|
||||||
GetSidebarCategory(categoryID string, options ...*SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error)
|
GetSidebarCategory(categoryID string) (*model.SidebarCategoryWithChannels, error)
|
||||||
GetSidebarCategoryOrder(userID, teamID string) ([]string, error)
|
GetSidebarCategoryOrder(userID, teamID string) ([]string, error)
|
||||||
CreateSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels, options ...*SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error)
|
CreateSidebarCategory(userID, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error)
|
||||||
UpdateSidebarCategoryOrder(userID, teamID string, categoryOrder []string) error
|
UpdateSidebarCategoryOrder(userID, teamID string, categoryOrder []string) error
|
||||||
UpdateSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels, options ...*SidebarCategorySearchOpts) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error)
|
UpdateSidebarCategories(userID, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error)
|
||||||
UpdateSidebarChannelsByPreferences(preferences model.Preferences) error
|
UpdateSidebarChannelsByPreferences(preferences model.Preferences) error
|
||||||
DeleteSidebarChannelsByPreferences(preferences model.Preferences) error
|
DeleteSidebarChannelsByPreferences(preferences model.Preferences) error
|
||||||
DeleteSidebarCategory(categoryID string) error
|
DeleteSidebarCategory(categoryID string) error
|
||||||
@@ -1103,9 +1102,8 @@ type PostReminderMetadata struct {
|
|||||||
// SidebarCategorySearchOpts contains the options for a graphQL query
|
// SidebarCategorySearchOpts contains the options for a graphQL query
|
||||||
// to get the sidebar categories.
|
// to get the sidebar categories.
|
||||||
type SidebarCategorySearchOpts struct {
|
type SidebarCategorySearchOpts struct {
|
||||||
TeamID string
|
TeamID string
|
||||||
ExcludeTeam bool
|
ExcludeTeam bool
|
||||||
AppsCategoryEnabled bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure store service adapter implements `product.StoreService`
|
// Ensure store service adapter implements `product.StoreService`
|
||||||
|
|||||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -298,32 +298,25 @@ func (_m *ChannelStore) CreateInitialSidebarCategories(userID string, opts *stor
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSidebarCategory provides a mock function with given fields: userID, teamID, newCategory, options
|
// CreateSidebarCategory provides a mock function with given fields: userID, teamID, newCategory
|
||||||
func (_m *ChannelStore) CreateSidebarCategory(userID string, teamID string, newCategory *model.SidebarCategoryWithChannels, options ...*store.SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error) {
|
func (_m *ChannelStore) CreateSidebarCategory(userID string, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
|
||||||
_va := make([]interface{}, len(options))
|
ret := _m.Called(userID, teamID, newCategory)
|
||||||
for _i := range options {
|
|
||||||
_va[_i] = options[_i]
|
|
||||||
}
|
|
||||||
var _ca []interface{}
|
|
||||||
_ca = append(_ca, userID, teamID, newCategory)
|
|
||||||
_ca = append(_ca, _va...)
|
|
||||||
ret := _m.Called(_ca...)
|
|
||||||
|
|
||||||
var r0 *model.SidebarCategoryWithChannels
|
var r0 *model.SidebarCategoryWithChannels
|
||||||
var r1 error
|
var r1 error
|
||||||
if rf, ok := ret.Get(0).(func(string, string, *model.SidebarCategoryWithChannels, ...*store.SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error)); ok {
|
if rf, ok := ret.Get(0).(func(string, string, *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error)); ok {
|
||||||
return rf(userID, teamID, newCategory, options...)
|
return rf(userID, teamID, newCategory)
|
||||||
}
|
}
|
||||||
if rf, ok := ret.Get(0).(func(string, string, *model.SidebarCategoryWithChannels, ...*store.SidebarCategorySearchOpts) *model.SidebarCategoryWithChannels); ok {
|
if rf, ok := ret.Get(0).(func(string, string, *model.SidebarCategoryWithChannels) *model.SidebarCategoryWithChannels); ok {
|
||||||
r0 = rf(userID, teamID, newCategory, options...)
|
r0 = rf(userID, teamID, newCategory)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(*model.SidebarCategoryWithChannels)
|
r0 = ret.Get(0).(*model.SidebarCategoryWithChannels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rf, ok := ret.Get(1).(func(string, string, *model.SidebarCategoryWithChannels, ...*store.SidebarCategorySearchOpts) error); ok {
|
if rf, ok := ret.Get(1).(func(string, string, *model.SidebarCategoryWithChannels) error); ok {
|
||||||
r1 = rf(userID, teamID, newCategory, options...)
|
r1 = rf(userID, teamID, newCategory)
|
||||||
} else {
|
} else {
|
||||||
r1 = ret.Error(1)
|
r1 = ret.Error(1)
|
||||||
}
|
}
|
||||||
@@ -605,32 +598,6 @@ func (_m *ChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterID st
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBotChannelsByUser provides a mock function with given fields: userID, opts
|
|
||||||
func (_m *ChannelStore) GetBotChannelsByUser(userID string, opts store.ChannelSearchOpts) (model.ChannelList, error) {
|
|
||||||
ret := _m.Called(userID, opts)
|
|
||||||
|
|
||||||
var r0 model.ChannelList
|
|
||||||
var r1 error
|
|
||||||
if rf, ok := ret.Get(0).(func(string, store.ChannelSearchOpts) (model.ChannelList, error)); ok {
|
|
||||||
return rf(userID, opts)
|
|
||||||
}
|
|
||||||
if rf, ok := ret.Get(0).(func(string, store.ChannelSearchOpts) model.ChannelList); ok {
|
|
||||||
r0 = rf(userID, opts)
|
|
||||||
} else {
|
|
||||||
if ret.Get(0) != nil {
|
|
||||||
r0 = ret.Get(0).(model.ChannelList)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if rf, ok := ret.Get(1).(func(string, store.ChannelSearchOpts) error); ok {
|
|
||||||
r1 = rf(userID, opts)
|
|
||||||
} else {
|
|
||||||
r1 = ret.Error(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r0, r1
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetByName provides a mock function with given fields: team_id, name, allowFromCache
|
// GetByName provides a mock function with given fields: team_id, name, allowFromCache
|
||||||
func (_m *ChannelStore) GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
|
func (_m *ChannelStore) GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
|
||||||
ret := _m.Called(team_id, name, allowFromCache)
|
ret := _m.Called(team_id, name, allowFromCache)
|
||||||
@@ -1625,32 +1592,25 @@ func (_m *ChannelStore) GetSidebarCategories(userID string, opts *store.SidebarC
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSidebarCategoriesForTeamForUser provides a mock function with given fields: userID, teamID, options
|
// GetSidebarCategoriesForTeamForUser provides a mock function with given fields: userID, teamID
|
||||||
func (_m *ChannelStore) GetSidebarCategoriesForTeamForUser(userID string, teamID string, options ...*store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error) {
|
func (_m *ChannelStore) GetSidebarCategoriesForTeamForUser(userID string, teamID string) (*model.OrderedSidebarCategories, error) {
|
||||||
_va := make([]interface{}, len(options))
|
ret := _m.Called(userID, teamID)
|
||||||
for _i := range options {
|
|
||||||
_va[_i] = options[_i]
|
|
||||||
}
|
|
||||||
var _ca []interface{}
|
|
||||||
_ca = append(_ca, userID, teamID)
|
|
||||||
_ca = append(_ca, _va...)
|
|
||||||
ret := _m.Called(_ca...)
|
|
||||||
|
|
||||||
var r0 *model.OrderedSidebarCategories
|
var r0 *model.OrderedSidebarCategories
|
||||||
var r1 error
|
var r1 error
|
||||||
if rf, ok := ret.Get(0).(func(string, string, ...*store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error)); ok {
|
if rf, ok := ret.Get(0).(func(string, string) (*model.OrderedSidebarCategories, error)); ok {
|
||||||
return rf(userID, teamID, options...)
|
return rf(userID, teamID)
|
||||||
}
|
}
|
||||||
if rf, ok := ret.Get(0).(func(string, string, ...*store.SidebarCategorySearchOpts) *model.OrderedSidebarCategories); ok {
|
if rf, ok := ret.Get(0).(func(string, string) *model.OrderedSidebarCategories); ok {
|
||||||
r0 = rf(userID, teamID, options...)
|
r0 = rf(userID, teamID)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(*model.OrderedSidebarCategories)
|
r0 = ret.Get(0).(*model.OrderedSidebarCategories)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rf, ok := ret.Get(1).(func(string, string, ...*store.SidebarCategorySearchOpts) error); ok {
|
if rf, ok := ret.Get(1).(func(string, string) error); ok {
|
||||||
r1 = rf(userID, teamID, options...)
|
r1 = rf(userID, teamID)
|
||||||
} else {
|
} else {
|
||||||
r1 = ret.Error(1)
|
r1 = ret.Error(1)
|
||||||
}
|
}
|
||||||
@@ -1658,32 +1618,25 @@ func (_m *ChannelStore) GetSidebarCategoriesForTeamForUser(userID string, teamID
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSidebarCategory provides a mock function with given fields: categoryID, options
|
// GetSidebarCategory provides a mock function with given fields: categoryID
|
||||||
func (_m *ChannelStore) GetSidebarCategory(categoryID string, options ...*store.SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error) {
|
func (_m *ChannelStore) GetSidebarCategory(categoryID string) (*model.SidebarCategoryWithChannels, error) {
|
||||||
_va := make([]interface{}, len(options))
|
ret := _m.Called(categoryID)
|
||||||
for _i := range options {
|
|
||||||
_va[_i] = options[_i]
|
|
||||||
}
|
|
||||||
var _ca []interface{}
|
|
||||||
_ca = append(_ca, categoryID)
|
|
||||||
_ca = append(_ca, _va...)
|
|
||||||
ret := _m.Called(_ca...)
|
|
||||||
|
|
||||||
var r0 *model.SidebarCategoryWithChannels
|
var r0 *model.SidebarCategoryWithChannels
|
||||||
var r1 error
|
var r1 error
|
||||||
if rf, ok := ret.Get(0).(func(string, ...*store.SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error)); ok {
|
if rf, ok := ret.Get(0).(func(string) (*model.SidebarCategoryWithChannels, error)); ok {
|
||||||
return rf(categoryID, options...)
|
return rf(categoryID)
|
||||||
}
|
}
|
||||||
if rf, ok := ret.Get(0).(func(string, ...*store.SidebarCategorySearchOpts) *model.SidebarCategoryWithChannels); ok {
|
if rf, ok := ret.Get(0).(func(string) *model.SidebarCategoryWithChannels); ok {
|
||||||
r0 = rf(categoryID, options...)
|
r0 = rf(categoryID)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(*model.SidebarCategoryWithChannels)
|
r0 = ret.Get(0).(*model.SidebarCategoryWithChannels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rf, ok := ret.Get(1).(func(string, ...*store.SidebarCategorySearchOpts) error); ok {
|
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||||
r1 = rf(categoryID, options...)
|
r1 = rf(categoryID)
|
||||||
} else {
|
} else {
|
||||||
r1 = ret.Error(1)
|
r1 = ret.Error(1)
|
||||||
}
|
}
|
||||||
@@ -2629,41 +2582,34 @@ func (_m *ChannelStore) UpdateMultipleMembers(members []*model.ChannelMember) ([
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateSidebarCategories provides a mock function with given fields: userID, teamID, categories, options
|
// UpdateSidebarCategories provides a mock function with given fields: userID, teamID, categories
|
||||||
func (_m *ChannelStore) UpdateSidebarCategories(userID string, teamID string, categories []*model.SidebarCategoryWithChannels, options ...*store.SidebarCategorySearchOpts) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) {
|
func (_m *ChannelStore) UpdateSidebarCategories(userID string, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) {
|
||||||
_va := make([]interface{}, len(options))
|
ret := _m.Called(userID, teamID, categories)
|
||||||
for _i := range options {
|
|
||||||
_va[_i] = options[_i]
|
|
||||||
}
|
|
||||||
var _ca []interface{}
|
|
||||||
_ca = append(_ca, userID, teamID, categories)
|
|
||||||
_ca = append(_ca, _va...)
|
|
||||||
ret := _m.Called(_ca...)
|
|
||||||
|
|
||||||
var r0 []*model.SidebarCategoryWithChannels
|
var r0 []*model.SidebarCategoryWithChannels
|
||||||
var r1 []*model.SidebarCategoryWithChannels
|
var r1 []*model.SidebarCategoryWithChannels
|
||||||
var r2 error
|
var r2 error
|
||||||
if rf, ok := ret.Get(0).(func(string, string, []*model.SidebarCategoryWithChannels, ...*store.SidebarCategorySearchOpts) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error)); ok {
|
if rf, ok := ret.Get(0).(func(string, string, []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error)); ok {
|
||||||
return rf(userID, teamID, categories, options...)
|
return rf(userID, teamID, categories)
|
||||||
}
|
}
|
||||||
if rf, ok := ret.Get(0).(func(string, string, []*model.SidebarCategoryWithChannels, ...*store.SidebarCategorySearchOpts) []*model.SidebarCategoryWithChannels); ok {
|
if rf, ok := ret.Get(0).(func(string, string, []*model.SidebarCategoryWithChannels) []*model.SidebarCategoryWithChannels); ok {
|
||||||
r0 = rf(userID, teamID, categories, options...)
|
r0 = rf(userID, teamID, categories)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).([]*model.SidebarCategoryWithChannels)
|
r0 = ret.Get(0).([]*model.SidebarCategoryWithChannels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rf, ok := ret.Get(1).(func(string, string, []*model.SidebarCategoryWithChannels, ...*store.SidebarCategorySearchOpts) []*model.SidebarCategoryWithChannels); ok {
|
if rf, ok := ret.Get(1).(func(string, string, []*model.SidebarCategoryWithChannels) []*model.SidebarCategoryWithChannels); ok {
|
||||||
r1 = rf(userID, teamID, categories, options...)
|
r1 = rf(userID, teamID, categories)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(1) != nil {
|
if ret.Get(1) != nil {
|
||||||
r1 = ret.Get(1).([]*model.SidebarCategoryWithChannels)
|
r1 = ret.Get(1).([]*model.SidebarCategoryWithChannels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rf, ok := ret.Get(2).(func(string, string, []*model.SidebarCategoryWithChannels, ...*store.SidebarCategorySearchOpts) error); ok {
|
if rf, ok := ret.Get(2).(func(string, string, []*model.SidebarCategoryWithChannels) error); ok {
|
||||||
r2 = rf(userID, teamID, categories, options...)
|
r2 = rf(userID, teamID, categories)
|
||||||
} else {
|
} else {
|
||||||
r2 = ret.Error(2)
|
r2 = ret.Error(2)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -784,10 +784,10 @@ func (s *TimerLayerChannelStore) CreateInitialSidebarCategories(userID string, o
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TimerLayerChannelStore) CreateSidebarCategory(userID string, teamID string, newCategory *model.SidebarCategoryWithChannels, options ...*store.SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error) {
|
func (s *TimerLayerChannelStore) CreateSidebarCategory(userID string, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
result, err := s.ChannelStore.CreateSidebarCategory(userID, teamID, newCategory, options...)
|
result, err := s.ChannelStore.CreateSidebarCategory(userID, teamID, newCategory)
|
||||||
|
|
||||||
elapsed := float64(time.Since(start)) / float64(time.Second)
|
elapsed := float64(time.Since(start)) / float64(time.Second)
|
||||||
if s.Root.Metrics != nil {
|
if s.Root.Metrics != nil {
|
||||||
@@ -992,22 +992,6 @@ func (s *TimerLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, a
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TimerLayerChannelStore) GetBotChannelsByUser(userID string, opts store.ChannelSearchOpts) (model.ChannelList, error) {
|
|
||||||
start := time.Now()
|
|
||||||
|
|
||||||
result, err := s.ChannelStore.GetBotChannelsByUser(userID, opts)
|
|
||||||
|
|
||||||
elapsed := float64(time.Since(start)) / float64(time.Second)
|
|
||||||
if s.Root.Metrics != nil {
|
|
||||||
success := "false"
|
|
||||||
if err == nil {
|
|
||||||
success = "true"
|
|
||||||
}
|
|
||||||
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetBotChannelsByUser", success, elapsed)
|
|
||||||
}
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *TimerLayerChannelStore) GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
|
func (s *TimerLayerChannelStore) GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
@@ -1632,10 +1616,10 @@ func (s *TimerLayerChannelStore) GetSidebarCategories(userID string, opts *store
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TimerLayerChannelStore) GetSidebarCategoriesForTeamForUser(userID string, teamID string, options ...*store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error) {
|
func (s *TimerLayerChannelStore) GetSidebarCategoriesForTeamForUser(userID string, teamID string) (*model.OrderedSidebarCategories, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
result, err := s.ChannelStore.GetSidebarCategoriesForTeamForUser(userID, teamID, options...)
|
result, err := s.ChannelStore.GetSidebarCategoriesForTeamForUser(userID, teamID)
|
||||||
|
|
||||||
elapsed := float64(time.Since(start)) / float64(time.Second)
|
elapsed := float64(time.Since(start)) / float64(time.Second)
|
||||||
if s.Root.Metrics != nil {
|
if s.Root.Metrics != nil {
|
||||||
@@ -1648,10 +1632,10 @@ func (s *TimerLayerChannelStore) GetSidebarCategoriesForTeamForUser(userID strin
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TimerLayerChannelStore) GetSidebarCategory(categoryID string, options ...*store.SidebarCategorySearchOpts) (*model.SidebarCategoryWithChannels, error) {
|
func (s *TimerLayerChannelStore) GetSidebarCategory(categoryID string) (*model.SidebarCategoryWithChannels, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
result, err := s.ChannelStore.GetSidebarCategory(categoryID, options...)
|
result, err := s.ChannelStore.GetSidebarCategory(categoryID)
|
||||||
|
|
||||||
elapsed := float64(time.Since(start)) / float64(time.Second)
|
elapsed := float64(time.Since(start)) / float64(time.Second)
|
||||||
if s.Root.Metrics != nil {
|
if s.Root.Metrics != nil {
|
||||||
@@ -2425,10 +2409,10 @@ func (s *TimerLayerChannelStore) UpdateMultipleMembers(members []*model.ChannelM
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TimerLayerChannelStore) UpdateSidebarCategories(userID string, teamID string, categories []*model.SidebarCategoryWithChannels, options ...*store.SidebarCategorySearchOpts) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) {
|
func (s *TimerLayerChannelStore) UpdateSidebarCategories(userID string, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
result, resultVar1, err := s.ChannelStore.UpdateSidebarCategories(userID, teamID, categories, options...)
|
result, resultVar1, err := s.ChannelStore.UpdateSidebarCategories(userID, teamID, categories)
|
||||||
|
|
||||||
elapsed := float64(time.Since(start)) / float64(time.Second)
|
elapsed := float64(time.Since(start)) / float64(time.Second)
|
||||||
if s.Root.Metrics != nil {
|
if s.Root.Metrics != nil {
|
||||||
|
|||||||
@@ -13,12 +13,11 @@ type SidebarCategoryType string
|
|||||||
type SidebarCategorySorting string
|
type SidebarCategorySorting string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Each sidebar category has a 'type'. System categories are Channels, Favorites, DMs and Apps
|
// Each sidebar category has a 'type'. System categories are Channels, Favorites and DMs
|
||||||
// All user-created categories will have type Custom
|
// All user-created categories will have type Custom
|
||||||
SidebarCategoryChannels SidebarCategoryType = "channels"
|
SidebarCategoryChannels SidebarCategoryType = "channels"
|
||||||
SidebarCategoryDirectMessages SidebarCategoryType = "direct_messages"
|
SidebarCategoryDirectMessages SidebarCategoryType = "direct_messages"
|
||||||
SidebarCategoryFavorites SidebarCategoryType = "favorites"
|
SidebarCategoryFavorites SidebarCategoryType = "favorites"
|
||||||
SidebarCategoryApps SidebarCategoryType = "apps"
|
|
||||||
SidebarCategoryCustom SidebarCategoryType = "custom"
|
SidebarCategoryCustom SidebarCategoryType = "custom"
|
||||||
// Increment to use when adding/reordering things in the sidebar
|
// Increment to use when adding/reordering things in the sidebar
|
||||||
MinimalSidebarSortDistance = 10
|
MinimalSidebarSortDistance = 10
|
||||||
@@ -26,7 +25,6 @@ const (
|
|||||||
DefaultSidebarSortOrderFavorites = 0
|
DefaultSidebarSortOrderFavorites = 0
|
||||||
DefaultSidebarSortOrderChannels = DefaultSidebarSortOrderFavorites + MinimalSidebarSortDistance
|
DefaultSidebarSortOrderChannels = DefaultSidebarSortOrderFavorites + MinimalSidebarSortDistance
|
||||||
DefaultSidebarSortOrderDMs = DefaultSidebarSortOrderChannels + MinimalSidebarSortDistance
|
DefaultSidebarSortOrderDMs = DefaultSidebarSortOrderChannels + MinimalSidebarSortDistance
|
||||||
DefaultSidebarSortOrderApps = DefaultSidebarSortOrderDMs + MinimalSidebarSortDistance
|
|
||||||
// Sorting modes
|
// Sorting modes
|
||||||
// default for all categories except DMs (behaves like manual)
|
// default for all categories except DMs (behaves like manual)
|
||||||
SidebarCategorySortDefault SidebarCategorySorting = ""
|
SidebarCategorySortDefault SidebarCategorySorting = ""
|
||||||
@@ -38,13 +36,6 @@ const (
|
|||||||
SidebarCategorySortAlphabetical SidebarCategorySorting = "alpha"
|
SidebarCategorySortAlphabetical SidebarCategorySorting = "alpha"
|
||||||
)
|
)
|
||||||
|
|
||||||
var SystemSidebarCategories = []SidebarCategoryType{
|
|
||||||
SidebarCategoryChannels,
|
|
||||||
SidebarCategoryDirectMessages,
|
|
||||||
SidebarCategoryFavorites,
|
|
||||||
SidebarCategoryApps,
|
|
||||||
}
|
|
||||||
|
|
||||||
// SidebarCategory represents the corresponding DB table
|
// SidebarCategory represents the corresponding DB table
|
||||||
type SidebarCategory struct {
|
type SidebarCategory struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
@@ -86,7 +77,7 @@ type SidebarChannel struct {
|
|||||||
type SidebarChannels []*SidebarChannel
|
type SidebarChannels []*SidebarChannel
|
||||||
type SidebarCategoriesWithChannels []*SidebarCategoryWithChannels
|
type SidebarCategoriesWithChannels []*SidebarCategoryWithChannels
|
||||||
|
|
||||||
var categoryIdPattern = regexp.MustCompile("(favorites|channels|direct_messages|apps)_[a-z0-9]{26}_[a-z0-9]{26}")
|
var categoryIdPattern = regexp.MustCompile("(favorites|channels|direct_messages)_[a-z0-9]{26}_[a-z0-9]{26}")
|
||||||
|
|
||||||
func IsValidCategoryId(s string) bool {
|
func IsValidCategoryId(s string) bool {
|
||||||
// Category IDs can either be regular IDs
|
// Category IDs can either be regular IDs
|
||||||
|
|||||||
@@ -75,8 +75,6 @@ type FeatureFlags struct {
|
|||||||
|
|
||||||
DeprecateCloudFree bool
|
DeprecateCloudFree bool
|
||||||
|
|
||||||
AppsSidebarCategory bool
|
|
||||||
|
|
||||||
CloudReverseTrial bool
|
CloudReverseTrial bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +104,6 @@ func (f *FeatureFlags) SetDefaults() {
|
|||||||
f.WysiwygEditor = false
|
f.WysiwygEditor = false
|
||||||
f.OnboardingAutoShowLinkedBoard = false
|
f.OnboardingAutoShowLinkedBoard = false
|
||||||
f.OnboardingTourTips = true
|
f.OnboardingTourTips = true
|
||||||
f.AppsSidebarCategory = false
|
|
||||||
f.CloudReverseTrial = false
|
f.CloudReverseTrial = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -732,41 +732,3 @@ describe('shouldShowUnreadsCategory', () => {
|
|||||||
expect(Selectors.shouldShowUnreadsCategory(state)).toBe(true);
|
expect(Selectors.shouldShowUnreadsCategory(state)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('get feature flags', () => {
|
|
||||||
test('should check the value of feature flag AppsSidebarCategory', () => {
|
|
||||||
let state = {
|
|
||||||
entities: {
|
|
||||||
general: {
|
|
||||||
config: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as GlobalState;
|
|
||||||
|
|
||||||
expect(Selectors.appsSidebarCategoryEnabled(state)).toBe(false);
|
|
||||||
|
|
||||||
state = {
|
|
||||||
entities: {
|
|
||||||
general: {
|
|
||||||
config: {
|
|
||||||
FeatureFlagAppsSidebarCategory: 'false',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as GlobalState;
|
|
||||||
|
|
||||||
expect(Selectors.appsSidebarCategoryEnabled(state)).toBe(false);
|
|
||||||
|
|
||||||
state = {
|
|
||||||
entities: {
|
|
||||||
general: {
|
|
||||||
config: {
|
|
||||||
FeatureFlagAppsSidebarCategory: 'true',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as GlobalState;
|
|
||||||
|
|
||||||
expect(Selectors.appsSidebarCategoryEnabled(state)).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -306,7 +306,3 @@ export function deprecateCloudFree(state: GlobalState): boolean {
|
|||||||
export function cloudReverseTrial(state: GlobalState): boolean {
|
export function cloudReverseTrial(state: GlobalState): boolean {
|
||||||
return getFeatureFlagValue(state, 'CloudReverseTrial') === 'true';
|
return getFeatureFlagValue(state, 'CloudReverseTrial') === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function appsSidebarCategoryEnabled(state: GlobalState): boolean {
|
|
||||||
return getFeatureFlagValue(state, 'AppsSidebarCategory') === 'true';
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ export type ClientConfig = {
|
|||||||
ExperimentalViewArchivedChannels: string;
|
ExperimentalViewArchivedChannels: string;
|
||||||
FileLevel: string;
|
FileLevel: string;
|
||||||
FeatureFlagAppsEnabled: string;
|
FeatureFlagAppsEnabled: string;
|
||||||
FeatureFlagAppsSidebarCategory: string;
|
|
||||||
FeatureFlagBoardsProduct: string;
|
FeatureFlagBoardsProduct: string;
|
||||||
FeatureFlagCallsEnabled: string;
|
FeatureFlagCallsEnabled: string;
|
||||||
FeatureFlagGraphQL: string;
|
FeatureFlagGraphQL: string;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user