Remove Global Drafts Feature Flag (#23767)
* Remove global draft feature flag * More removal - in progress * Removed the rest in webapp * Removed the rest in webapp * Fix tests * Update feature_flags.go --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bf0e0ed45a
Коммит
5779bd49d5
@@ -677,7 +677,6 @@ const defaultServerConfig: AdminConfig = {
|
|||||||
PeopleProduct: false,
|
PeopleProduct: false,
|
||||||
ReduceOnBoardingTaskList: false,
|
ReduceOnBoardingTaskList: false,
|
||||||
ThreadsEverywhere: false,
|
ThreadsEverywhere: false,
|
||||||
GlobalDrafts: true,
|
|
||||||
OnboardingTourTips: true,
|
OnboardingTourTips: true,
|
||||||
DeprecateCloudFree: false,
|
DeprecateCloudFree: false,
|
||||||
CloudReverseTrial: false,
|
CloudReverseTrial: false,
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ func TestUpsertDraft(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
// set config
|
// set config
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
client := th.Client
|
client := th.Client
|
||||||
@@ -95,7 +94,6 @@ func TestGetDrafts(t *testing.T) {
|
|||||||
th := Setup(t).InitBasic()
|
th := Setup(t).InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
client := th.Client
|
client := th.Client
|
||||||
@@ -120,7 +118,6 @@ func TestGetDrafts(t *testing.T) {
|
|||||||
Message: "draft2",
|
Message: "draft2",
|
||||||
}
|
}
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
// upsert draft1
|
// upsert draft1
|
||||||
@@ -169,7 +166,6 @@ func TestDeleteDraft(t *testing.T) {
|
|||||||
th := Setup(t).InitBasic()
|
th := Setup(t).InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
client := th.Client
|
client := th.Client
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (a *App) GetDraft(userID, channelID, rootID string) (*model.Draft, *model.AppError) {
|
func (a *App) GetDraft(userID, channelID, rootID string) (*model.Draft, *model.AppError) {
|
||||||
if !a.Config().FeatureFlags.GlobalDrafts || !*a.Config().ServiceSettings.AllowSyncedDrafts {
|
if !*a.Config().ServiceSettings.AllowSyncedDrafts {
|
||||||
return nil, model.NewAppError("GetDraft", "app.draft.feature_disabled", nil, "", http.StatusNotImplemented)
|
return nil, model.NewAppError("GetDraft", "app.draft.feature_disabled", nil, "", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ func (a *App) GetDraft(userID, channelID, rootID string) (*model.Draft, *model.A
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) UpsertDraft(c *request.Context, draft *model.Draft, connectionID string) (*model.Draft, *model.AppError) {
|
func (a *App) UpsertDraft(c *request.Context, draft *model.Draft, connectionID string) (*model.Draft, *model.AppError) {
|
||||||
if !a.Config().FeatureFlags.GlobalDrafts || !*a.Config().ServiceSettings.AllowSyncedDrafts {
|
if !*a.Config().ServiceSettings.AllowSyncedDrafts {
|
||||||
return nil, model.NewAppError("CreateDraft", "app.draft.feature_disabled", nil, "", http.StatusNotImplemented)
|
return nil, model.NewAppError("CreateDraft", "app.draft.feature_disabled", nil, "", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ func (a *App) UpsertDraft(c *request.Context, draft *model.Draft, connectionID s
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetDraftsForUser(userID, teamID string) ([]*model.Draft, *model.AppError) {
|
func (a *App) GetDraftsForUser(userID, teamID string) ([]*model.Draft, *model.AppError) {
|
||||||
if !a.Config().FeatureFlags.GlobalDrafts || !*a.Config().ServiceSettings.AllowSyncedDrafts {
|
if !*a.Config().ServiceSettings.AllowSyncedDrafts {
|
||||||
return nil, model.NewAppError("GetDraftsForUser", "app.draft.feature_disabled", nil, "", http.StatusNotImplemented)
|
return nil, model.NewAppError("GetDraftsForUser", "app.draft.feature_disabled", nil, "", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ func (a *App) getFileInfosForDraft(draft *model.Draft) ([]*model.FileInfo, *mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) DeleteDraft(userID, channelID, rootID, connectionID string) (*model.Draft, *model.AppError) {
|
func (a *App) DeleteDraft(userID, channelID, rootID, connectionID string) (*model.Draft, *model.AppError) {
|
||||||
if !a.Config().FeatureFlags.GlobalDrafts || !*a.Config().ServiceSettings.AllowSyncedDrafts {
|
if !*a.Config().ServiceSettings.AllowSyncedDrafts {
|
||||||
return nil, model.NewAppError("DeleteDraft", "app.draft.feature_disabled", nil, "", http.StatusNotImplemented)
|
return nil, model.NewAppError("DeleteDraft", "app.draft.feature_disabled", nil, "", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ func TestGetDraft(t *testing.T) {
|
|||||||
th.Server.platform.SetConfigReadOnlyFF(false)
|
th.Server.platform.SetConfigReadOnlyFF(false)
|
||||||
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
user := th.BasicUser
|
user := th.BasicUser
|
||||||
@@ -57,10 +56,7 @@ func TestGetDraft(t *testing.T) {
|
|||||||
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
||||||
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = false })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
||||||
|
|
||||||
defer th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
_, err := th.App.GetDraft(user.Id, channel.Id, "")
|
_, err := th.App.GetDraft(user.Id, channel.Id, "")
|
||||||
@@ -75,7 +71,6 @@ func TestUpsertDraft(t *testing.T) {
|
|||||||
th.Server.platform.SetConfigReadOnlyFF(false)
|
th.Server.platform.SetConfigReadOnlyFF(false)
|
||||||
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
user := th.BasicUser
|
user := th.BasicUser
|
||||||
@@ -124,10 +119,7 @@ func TestUpsertDraft(t *testing.T) {
|
|||||||
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
||||||
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = false })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
||||||
|
|
||||||
defer th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
_, err := th.App.UpsertDraft(th.Context, draft, "")
|
_, err := th.App.UpsertDraft(th.Context, draft, "")
|
||||||
@@ -142,7 +134,6 @@ func TestCreateDraft(t *testing.T) {
|
|||||||
th.Server.platform.SetConfigReadOnlyFF(false)
|
th.Server.platform.SetConfigReadOnlyFF(false)
|
||||||
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
user := th.BasicUser
|
user := th.BasicUser
|
||||||
@@ -201,7 +192,6 @@ func TestUpdateDraft(t *testing.T) {
|
|||||||
th.Server.platform.SetConfigReadOnlyFF(false)
|
th.Server.platform.SetConfigReadOnlyFF(false)
|
||||||
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
user := th.BasicUser
|
user := th.BasicUser
|
||||||
@@ -247,7 +237,6 @@ func TestGetDraftsForUser(t *testing.T) {
|
|||||||
th.Server.platform.SetConfigReadOnlyFF(false)
|
th.Server.platform.SetConfigReadOnlyFF(false)
|
||||||
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
user := th.BasicUser
|
user := th.BasicUser
|
||||||
@@ -325,10 +314,7 @@ func TestGetDraftsForUser(t *testing.T) {
|
|||||||
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
||||||
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = false })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
||||||
|
|
||||||
defer th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
_, err := th.App.GetDraftsForUser(user.Id, th.BasicTeam.Id)
|
_, err := th.App.GetDraftsForUser(user.Id, th.BasicTeam.Id)
|
||||||
@@ -343,7 +329,6 @@ func TestDeleteDraft(t *testing.T) {
|
|||||||
th.Server.platform.SetConfigReadOnlyFF(false)
|
th.Server.platform.SetConfigReadOnlyFF(false)
|
||||||
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
defer th.Server.platform.SetConfigReadOnlyFF(true)
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
user := th.BasicUser
|
user := th.BasicUser
|
||||||
@@ -377,10 +362,7 @@ func TestDeleteDraft(t *testing.T) {
|
|||||||
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
||||||
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = false })
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
||||||
|
|
||||||
defer th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.GlobalDrafts = true })
|
|
||||||
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||||
|
|
||||||
_, err := th.App.DeleteDraft(user.Id, channel.Id, "", "")
|
_, err := th.App.DeleteDraft(user.Id, channel.Id, "", "")
|
||||||
|
|||||||
@@ -55,8 +55,6 @@ type FeatureFlags struct {
|
|||||||
|
|
||||||
PeopleProduct bool
|
PeopleProduct bool
|
||||||
|
|
||||||
GlobalDrafts bool
|
|
||||||
|
|
||||||
OnboardingTourTips bool
|
OnboardingTourTips bool
|
||||||
|
|
||||||
DeprecateCloudFree bool
|
DeprecateCloudFree bool
|
||||||
@@ -82,7 +80,6 @@ func (f *FeatureFlags) SetDefaults() {
|
|||||||
f.CallsEnabled = true
|
f.CallsEnabled = true
|
||||||
f.PostPriority = true
|
f.PostPriority = true
|
||||||
f.PeopleProduct = false
|
f.PeopleProduct = false
|
||||||
f.GlobalDrafts = true
|
|
||||||
f.DeprecateCloudFree = false
|
f.DeprecateCloudFree = false
|
||||||
f.WysiwygEditor = false
|
f.WysiwygEditor = false
|
||||||
f.OnboardingTourTips = true
|
f.OnboardingTourTips = true
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ describe('draft actions', () => {
|
|||||||
general: {
|
general: {
|
||||||
config: {
|
config: {
|
||||||
EnableCustomEmoji: 'true',
|
EnableCustomEmoji: 'true',
|
||||||
FeatureFlagGlobalDrafts: 'true',
|
|
||||||
AllowSyncedDrafts: 'true',
|
AllowSyncedDrafts: 'true',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3068,12 +3068,6 @@ const AdminDefinition = {
|
|||||||
help_text: t('admin.customization.allowSyncedDraftsDesc'),
|
help_text: t('admin.customization.allowSyncedDraftsDesc'),
|
||||||
help_text_default: 'When enabled, users message drafts will sync with the server so they can be accessed from any device. Users may opt out of this behaviour in Account settings.',
|
help_text_default: 'When enabled, users message drafts will sync with the server so they can be accessed from any device. Users may opt out of this behaviour in Account settings.',
|
||||||
help_text_markdown: false,
|
help_text_markdown: false,
|
||||||
isHidden: it.any(
|
|
||||||
it.configIsFalse('FeatureFlags', 'GlobalDrafts'),
|
|
||||||
),
|
|
||||||
isDisabled: it.any(
|
|
||||||
it.configIsFalse('FeatureFlags', 'GlobalDrafts'),
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ exports[`components/drafts/drafts should match snapshot 1`] = `
|
|||||||
displayName="display_name"
|
displayName="display_name"
|
||||||
draftRemotes={Object {}}
|
draftRemotes={Object {}}
|
||||||
drafts={Array []}
|
drafts={Array []}
|
||||||
localDraftsAreEnabled={true}
|
|
||||||
status={Object {}}
|
status={Object {}}
|
||||||
user={Object {}}
|
user={Object {}}
|
||||||
/>
|
/>
|
||||||
@@ -79,7 +78,6 @@ exports[`components/drafts/drafts should match snapshot for local drafts disable
|
|||||||
displayName="display_name"
|
displayName="display_name"
|
||||||
draftRemotes={Object {}}
|
draftRemotes={Object {}}
|
||||||
drafts={Array []}
|
drafts={Array []}
|
||||||
localDraftsAreEnabled={false}
|
|
||||||
status={Object {}}
|
status={Object {}}
|
||||||
user={Object {}}
|
user={Object {}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ describe('components/drafts/drafts', () => {
|
|||||||
user: {} as UserProfile,
|
user: {} as UserProfile,
|
||||||
displayName: 'display_name',
|
displayName: 'display_name',
|
||||||
status: {} as UserStatus['status'],
|
status: {} as UserStatus['status'],
|
||||||
localDraftsAreEnabled: true,
|
|
||||||
draftRemotes: {},
|
draftRemotes: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,7 +40,6 @@ describe('components/drafts/drafts', () => {
|
|||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
...baseProps,
|
...baseProps,
|
||||||
localDraftsAreEnabled: false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ type Props = {
|
|||||||
user: UserProfile;
|
user: UserProfile;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
status: UserStatus['status'];
|
status: UserStatus['status'];
|
||||||
localDraftsAreEnabled: boolean;
|
|
||||||
draftRemotes: Record<string, boolean>;
|
draftRemotes: Record<string, boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +35,6 @@ function Drafts({
|
|||||||
draftRemotes,
|
draftRemotes,
|
||||||
status,
|
status,
|
||||||
user,
|
user,
|
||||||
localDraftsAreEnabled,
|
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const {formatMessage} = useIntl();
|
const {formatMessage} = useIntl();
|
||||||
@@ -50,10 +48,6 @@ function Drafts({
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (!localDraftsAreEnabled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
id='app-content'
|
id='app-content'
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {useSelector, useDispatch} from 'react-redux';
|
|||||||
import {NavLink, useRouteMatch} from 'react-router-dom';
|
import {NavLink, useRouteMatch} from 'react-router-dom';
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
import {localDraftsAreEnabled, syncedDraftsAreAllowedAndEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
import {syncedDraftsAreAllowedAndEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||||
|
|
||||||
import {getDrafts} from 'actions/views/drafts';
|
import {getDrafts} from 'actions/views/drafts';
|
||||||
@@ -23,7 +23,6 @@ const getDraftsCount = makeGetDraftsCount();
|
|||||||
function DraftsLink() {
|
function DraftsLink() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const localDraftsEnabled = useSelector(localDraftsAreEnabled);
|
|
||||||
const syncedDraftsAllowedAndEnabled = useSelector(syncedDraftsAreAllowedAndEnabled);
|
const syncedDraftsAllowedAndEnabled = useSelector(syncedDraftsAreAllowedAndEnabled);
|
||||||
const count = useSelector(getDraftsCount);
|
const count = useSelector(getDraftsCount);
|
||||||
const teamId = useSelector(getCurrentTeamId);
|
const teamId = useSelector(getCurrentTeamId);
|
||||||
@@ -37,7 +36,7 @@ function DraftsLink() {
|
|||||||
}
|
}
|
||||||
}, [teamId, syncedDraftsAllowedAndEnabled]);
|
}, [teamId, syncedDraftsAllowedAndEnabled]);
|
||||||
|
|
||||||
if (!localDraftsEnabled || (!count && !isDraftUrlMatch)) {
|
if (!count && !isDraftUrlMatch) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import {connect} from 'react-redux';
|
import {connect} from 'react-redux';
|
||||||
|
|
||||||
import {getCurrentUser, getStatusForUserId} from 'mattermost-redux/selectors/entities/users';
|
import {getCurrentUser, getStatusForUserId} from 'mattermost-redux/selectors/entities/users';
|
||||||
import {localDraftsAreEnabled, getTeammateNameDisplaySetting} from 'mattermost-redux/selectors/entities/preferences';
|
import {getTeammateNameDisplaySetting} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {displayUsername} from 'mattermost-redux/utils/user_utils';
|
import {displayUsername} from 'mattermost-redux/utils/user_utils';
|
||||||
|
|
||||||
import {GlobalState} from 'types/store';
|
import {GlobalState} from 'types/store';
|
||||||
@@ -25,7 +25,6 @@ function makeMapStateToProps() {
|
|||||||
draftRemotes: state.views.drafts.remotes,
|
draftRemotes: state.views.drafts.remotes,
|
||||||
status,
|
status,
|
||||||
user,
|
user,
|
||||||
localDraftsAreEnabled: localDraftsAreEnabled(state),
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,22 +264,14 @@ export function getHasDismissedSystemConsoleLimitReached(state: GlobalState): bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function syncedDraftsAreAllowed(state: GlobalState): boolean {
|
export function syncedDraftsAreAllowed(state: GlobalState): boolean {
|
||||||
const isFeatureEnabled = getFeatureFlagValue(state, 'GlobalDrafts') === 'true';
|
return getConfig(state).AllowSyncedDrafts === 'true';
|
||||||
const isConfiguredForFeature = getConfig(state).AllowSyncedDrafts === 'true';
|
|
||||||
|
|
||||||
return isFeatureEnabled && isConfiguredForFeature;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function syncedDraftsAreAllowedAndEnabled(state: GlobalState): boolean {
|
export function syncedDraftsAreAllowedAndEnabled(state: GlobalState): boolean {
|
||||||
const isFeatureEnabled = getFeatureFlagValue(state, 'GlobalDrafts') === 'true';
|
|
||||||
const isConfiguredForFeature = getConfig(state).AllowSyncedDrafts === 'true';
|
const isConfiguredForFeature = getConfig(state).AllowSyncedDrafts === 'true';
|
||||||
const isConfiguredForUser = getBool(state, Preferences.CATEGORY_ADVANCED_SETTINGS, Preferences.ADVANCED_SYNC_DRAFTS, true);
|
const isConfiguredForUser = getBool(state, Preferences.CATEGORY_ADVANCED_SETTINGS, Preferences.ADVANCED_SYNC_DRAFTS, true);
|
||||||
|
|
||||||
return isFeatureEnabled && isConfiguredForFeature && isConfiguredForUser;
|
return isConfiguredForFeature && isConfiguredForUser;
|
||||||
}
|
|
||||||
|
|
||||||
export function localDraftsAreEnabled(state: GlobalState): boolean {
|
|
||||||
return getFeatureFlagValue(state, 'GlobalDrafts') === 'true';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVisibleDmGmLimit(state: GlobalState) {
|
export function getVisibleDmGmLimit(state: GlobalState) {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ jest.mock('selectors/drafts', () => ({
|
|||||||
jest.mock('mattermost-redux/selectors/entities/preferences', () => ({
|
jest.mock('mattermost-redux/selectors/entities/preferences', () => ({
|
||||||
insightsAreEnabled: jest.fn(),
|
insightsAreEnabled: jest.fn(),
|
||||||
isCollapsedThreadsEnabled: jest.fn(),
|
isCollapsedThreadsEnabled: jest.fn(),
|
||||||
localDraftsAreEnabled: jest.fn(),
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -58,7 +57,6 @@ describe('Selectors.Lhs', () => {
|
|||||||
it('handles nothing enabled', () => {
|
it('handles nothing enabled', () => {
|
||||||
jest.spyOn(PreferencesSelectors, 'insightsAreEnabled').mockImplementationOnce(() => false);
|
jest.spyOn(PreferencesSelectors, 'insightsAreEnabled').mockImplementationOnce(() => false);
|
||||||
jest.spyOn(PreferencesSelectors, 'isCollapsedThreadsEnabled').mockImplementationOnce(() => false);
|
jest.spyOn(PreferencesSelectors, 'isCollapsedThreadsEnabled').mockImplementationOnce(() => false);
|
||||||
jest.spyOn(PreferencesSelectors, 'localDraftsAreEnabled').mockImplementationOnce(() => false);
|
|
||||||
jest.spyOn(Lhs, 'getDraftsCount').mockImplementationOnce(() => 0);
|
jest.spyOn(Lhs, 'getDraftsCount').mockImplementationOnce(() => 0);
|
||||||
const items = Lhs.getVisibleStaticPages(state as GlobalState);
|
const items = Lhs.getVisibleStaticPages(state as GlobalState);
|
||||||
expect(items).toEqual([]);
|
expect(items).toEqual([]);
|
||||||
@@ -67,7 +65,6 @@ describe('Selectors.Lhs', () => {
|
|||||||
it('handles insights', () => {
|
it('handles insights', () => {
|
||||||
jest.spyOn(PreferencesSelectors, 'insightsAreEnabled').mockImplementation(() => true);
|
jest.spyOn(PreferencesSelectors, 'insightsAreEnabled').mockImplementation(() => true);
|
||||||
jest.spyOn(PreferencesSelectors, 'isCollapsedThreadsEnabled').mockImplementation(() => false);
|
jest.spyOn(PreferencesSelectors, 'isCollapsedThreadsEnabled').mockImplementation(() => false);
|
||||||
jest.spyOn(PreferencesSelectors, 'localDraftsAreEnabled').mockImplementation(() => false);
|
|
||||||
jest.spyOn(Lhs, 'getDraftsCount').mockImplementationOnce(() => 0);
|
jest.spyOn(Lhs, 'getDraftsCount').mockImplementationOnce(() => 0);
|
||||||
const items = Lhs.getVisibleStaticPages(state as GlobalState);
|
const items = Lhs.getVisibleStaticPages(state as GlobalState);
|
||||||
expect(items).toEqual([
|
expect(items).toEqual([
|
||||||
@@ -81,7 +78,6 @@ describe('Selectors.Lhs', () => {
|
|||||||
it('handles threads - default off', () => {
|
it('handles threads - default off', () => {
|
||||||
jest.spyOn(PreferencesSelectors, 'insightsAreEnabled').mockImplementation(() => false);
|
jest.spyOn(PreferencesSelectors, 'insightsAreEnabled').mockImplementation(() => false);
|
||||||
jest.spyOn(PreferencesSelectors, 'isCollapsedThreadsEnabled').mockImplementation(() => true);
|
jest.spyOn(PreferencesSelectors, 'isCollapsedThreadsEnabled').mockImplementation(() => true);
|
||||||
jest.spyOn(PreferencesSelectors, 'localDraftsAreEnabled').mockImplementation(() => false);
|
|
||||||
jest.spyOn(Lhs, 'getDraftsCount').mockImplementationOnce(() => 0);
|
jest.spyOn(Lhs, 'getDraftsCount').mockImplementationOnce(() => 0);
|
||||||
const items = Lhs.getVisibleStaticPages(state as GlobalState);
|
const items = Lhs.getVisibleStaticPages(state as GlobalState);
|
||||||
expect(items).toEqual([
|
expect(items).toEqual([
|
||||||
@@ -95,7 +91,6 @@ describe('Selectors.Lhs', () => {
|
|||||||
it('should not return drafts when empty', () => {
|
it('should not return drafts when empty', () => {
|
||||||
jest.spyOn(PreferencesSelectors, 'insightsAreEnabled').mockImplementation(() => false);
|
jest.spyOn(PreferencesSelectors, 'insightsAreEnabled').mockImplementation(() => false);
|
||||||
jest.spyOn(PreferencesSelectors, 'isCollapsedThreadsEnabled').mockImplementation(() => false);
|
jest.spyOn(PreferencesSelectors, 'isCollapsedThreadsEnabled').mockImplementation(() => false);
|
||||||
jest.spyOn(PreferencesSelectors, 'localDraftsAreEnabled').mockImplementation(() => true);
|
|
||||||
jest.spyOn(Lhs, 'getDraftsCount').mockImplementationOnce(() => 0);
|
jest.spyOn(Lhs, 'getDraftsCount').mockImplementationOnce(() => 0);
|
||||||
const items = Lhs.getVisibleStaticPages(state as GlobalState);
|
const items = Lhs.getVisibleStaticPages(state as GlobalState);
|
||||||
expect(items).toEqual([]);
|
expect(items).toEqual([]);
|
||||||
@@ -104,7 +99,6 @@ describe('Selectors.Lhs', () => {
|
|||||||
it('should return drafts when there are available', () => {
|
it('should return drafts when there are available', () => {
|
||||||
jest.spyOn(PreferencesSelectors, 'insightsAreEnabled').mockImplementation(() => false);
|
jest.spyOn(PreferencesSelectors, 'insightsAreEnabled').mockImplementation(() => false);
|
||||||
jest.spyOn(PreferencesSelectors, 'isCollapsedThreadsEnabled').mockImplementation(() => false);
|
jest.spyOn(PreferencesSelectors, 'isCollapsedThreadsEnabled').mockImplementation(() => false);
|
||||||
jest.spyOn(PreferencesSelectors, 'localDraftsAreEnabled').mockImplementation(() => true);
|
|
||||||
jest.spyOn(Lhs, 'getDraftsCount').mockImplementationOnce(() => 1);
|
jest.spyOn(Lhs, 'getDraftsCount').mockImplementationOnce(() => 1);
|
||||||
const items = Lhs.getVisibleStaticPages(state as GlobalState);
|
const items = Lhs.getVisibleStaticPages(state as GlobalState);
|
||||||
expect(items).toEqual([
|
expect(items).toEqual([
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {makeGetDraftsCount} from 'selectors/drafts';
|
|||||||
import {
|
import {
|
||||||
insightsAreEnabled,
|
insightsAreEnabled,
|
||||||
isCollapsedThreadsEnabled,
|
isCollapsedThreadsEnabled,
|
||||||
localDraftsAreEnabled,
|
|
||||||
} from 'mattermost-redux/selectors/entities/preferences';
|
} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
|
|
||||||
export function getIsLhsOpen(state: GlobalState): boolean {
|
export function getIsLhsOpen(state: GlobalState): boolean {
|
||||||
@@ -26,9 +25,8 @@ export const getVisibleStaticPages = createSelector(
|
|||||||
'getVisibleSidebarStaticPages',
|
'getVisibleSidebarStaticPages',
|
||||||
insightsAreEnabled,
|
insightsAreEnabled,
|
||||||
isCollapsedThreadsEnabled,
|
isCollapsedThreadsEnabled,
|
||||||
localDraftsAreEnabled,
|
|
||||||
getDraftsCount,
|
getDraftsCount,
|
||||||
(insightsEnabled, collapsedThreadsEnabled, localDraftsEnabled, draftsCount) => {
|
(insightsEnabled, collapsedThreadsEnabled, draftsCount) => {
|
||||||
const staticPages: StaticPage[] = [];
|
const staticPages: StaticPage[] = [];
|
||||||
|
|
||||||
if (insightsEnabled) {
|
if (insightsEnabled) {
|
||||||
@@ -45,12 +43,10 @@ export const getVisibleStaticPages = createSelector(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localDraftsEnabled) {
|
staticPages.push({
|
||||||
staticPages.push({
|
id: 'drafts',
|
||||||
id: 'drafts',
|
isVisible: draftsCount > 0,
|
||||||
isVisible: draftsCount > 0,
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return staticPages.filter((item) => item.isVisible);
|
return staticPages.filter((item) => item.isVisible);
|
||||||
},
|
},
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user