From 4547d9ab0efbd8a64d257f0ef05963d0c279bcfe Mon Sep 17 00:00:00 2001 From: ludvigbolin <57351161+ludvigbolin@users.noreply.github.com> Date: Mon, 30 Oct 2023 20:31:05 +0100 Subject: [PATCH] [GH24626] Remove ExperimentalTimezone as this is always true (#24657) * Remove all occurrences of ExperimentalTimezone in /server This removes all uses of ExperimentalTimezone and makes all conditions using this setting being either removed (== false) or always used (== true) * Remove timezone parameter for getChannelMemberByGroup As timezone is always enabled this function no longer has a second parameter. The endpoint will always be called with includeTimezones set to true * Remove all uses of ExperimentalTimezone in webapp All conditions dependent of this are adjusted to always be true if experimentalTimezone should be true and vice versa * Change all tests checking for correct usage of ExperimentalTimezone As this parameter is no longer used, the tests which check for correct behaviour of this is no longer needed * Fix type errors Tests regarding types does now pass 'npm run check-types' will run successfully * fix lint issues Fix all current lint errors and now lint test goes through * Fix test regarding profile popover enableTimezone now is gone and all profile_popover.test.tsx can run successfully. Added state.entities.users.profiles[] as it before threw an error without it. * Fix tests where "April 1 2019" was changed to "April 01 2019" Now it will show "April 1 2019" and "timeZone" will only show if its other than empty (""). * Fix test where date was set to NaN Now date will show correctly and will not be NaN * fix minor test case that failed before * fix linting in server * Delete tests that are not valid with timeZoneEnabled removed tests in advanced_create_comment and advanced_create_post had timeZoneEnabled set to false as default. The tests that use this are now changed to once which are meant to have timeZoneEnabled set to true. Adjust jest function in advanced_create_post to get correct stacktrace * Parameter deleted isTimeZoneEnabled is always true and therefore the parameter can be deleted * adjust to prettier standard * Remove all occurrences of ExperimentalTimezone in /server This removes all uses of ExperimentalTimezone and makes all conditions using this setting being either removed (== false) or always used (== true) * Remove timezone parameter for getChannelMemberByGroup As timezone is always enabled this function no longer has a second parameter. The endpoint will always be called with includeTimezones set to true * Remove all uses of ExperimentalTimezone in webapp All conditions dependent of this are adjusted to always be true if experimentalTimezone should be true and vice versa * Change all tests checking for correct usage of ExperimentalTimezone As this parameter is no longer used, the tests which check for correct behaviour of this is no longer needed * Fix type errors Tests regarding types does now pass 'npm run check-types' will run successfully * fix lint issues Fix all current lint errors and now lint test goes through * Fix test regarding profile popover enableTimezone now is gone and all profile_popover.test.tsx can run successfully. Added state.entities.users.profiles[] as it before threw an error without it. * Fix tests where "April 1 2019" was changed to "April 01 2019" Now it will show "April 1 2019" and "timeZone" will only show if its other than empty (""). * Fix test where date was set to NaN Now date will show correctly and will not be NaN * fix minor test case that failed before * fix linting in server * Delete tests that are not valid with timeZoneEnabled removed tests in advanced_create_comment and advanced_create_post had timeZoneEnabled set to false as default. The tests that use this are now changed to once which are meant to have timeZoneEnabled set to true. Adjust jest function in advanced_create_post to get correct stacktrace * Parameter deleted isTimeZoneEnabled is always true and therefore the parameter can be deleted * adjust to prettier standard --------- Co-authored-by: Harrison Healey Co-authored-by: Mattermost Build --- .../accessibility_account_settings_spec.js | 3 - .../messaging/local_date_time_spec.js | 7 - .../display/clock_display_mode_spec.js | 7 - .../display/timezone_display_mode_spec.js | 7 - .../support/api/cloud_default_config.json | 4 +- .../support/api/on_prem_default_config.json | 4 +- .../support/server/default_config.ts | 1 - server/config/client.go | 2 +- server/config/common_test.go | 3 - server/config/database_test.go | 3 - server/config/file_test.go | 3 - .../platform/services/telemetry/telemetry.go | 1 - server/public/model/config.go | 9 +- server/tests/test-config.json | 3 +- webapp/channels/src/actions/views/group.js | 6 - .../src/actions/websocket_actions.jsx | 6 +- .../admin_console/admin_definition.jsx | 10 -- .../advanced_create_comment.test.tsx | 29 ----- .../advanced_create_comment.tsx | 16 +-- .../advanced_create_comment/index.ts | 4 +- .../advanced_create_post.test.tsx | 123 ++++++------------ .../advanced_create_post.tsx | 15 +-- .../components/advanced_create_post/index.ts | 4 +- .../src/components/logged_in/index.ts | 1 - .../components/logged_in/logged_in.test.tsx | 1 - .../src/components/logged_in/logged_in.tsx | 5 +- .../post_view/post_edited_indicator/index.ts | 8 +- .../profile_popover.test.tsx.snap | 2 - .../src/components/profile_popover/index.ts | 3 +- .../profile_popover/profile_popover.test.tsx | 7 +- .../profile_popover/profile_popover.tsx | 9 +- .../channels/src/components/root/effects.ts | 12 +- .../status_dropdown/status_dropdown.test.tsx | 1 - .../search_date_suggestion/index.ts | 10 +- .../src/components/timestamp/index.test.tsx | 13 -- .../src/components/timestamp/index.ts | 8 +- .../components/user_settings/display/index.ts | 2 - .../display/user_settings_display.test.tsx | 1 - .../display/user_settings_display.tsx | 7 +- webapp/channels/src/i18n/en.json | 2 - .../src/actions/channels.test.ts | 2 +- .../mattermost-redux/src/actions/channels.ts | 4 +- .../src/selectors/entities/timezone.ts | 6 - .../mattermost-redux/src/utils/post_list.ts | 20 ++- .../channels/src/selectors/views/threads.ts | 20 ++- webapp/platform/types/src/config.ts | 2 - 46 files changed, 106 insertions(+), 310 deletions(-) diff --git a/e2e-tests/cypress/tests/integration/channels/accessibility/accessibility_account_settings_spec.js b/e2e-tests/cypress/tests/integration/channels/accessibility/accessibility_account_settings_spec.js index 94a44a509e..fe7b0b9143 100644 --- a/e2e-tests/cypress/tests/integration/channels/accessibility/accessibility_account_settings_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/accessibility/accessibility_account_settings_spec.js @@ -72,9 +72,6 @@ describe('Verify Accessibility Support in different sections in Settings and Pro ServiceSettings: { EnableMultifactorAuthentication: true, }, - DisplaySettings: { - ExperimentalTimezone: true, - }, SamlSettings: { Enable: false, }, diff --git a/e2e-tests/cypress/tests/integration/channels/messaging/local_date_time_spec.js b/e2e-tests/cypress/tests/integration/channels/messaging/local_date_time_spec.js index 0a661332bd..f001e51618 100644 --- a/e2e-tests/cypress/tests/integration/channels/messaging/local_date_time_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/messaging/local_date_time_spec.js @@ -16,13 +16,6 @@ describe('Messaging', () => { const sysadmin = getAdminAccount(); before(() => { - // # Enable Timezone - cy.apiUpdateConfig({ - DisplaySettings: { - ExperimentalTimezone: true, - }, - }); - // # Create and visit new channel cy.apiInitSetup({loginAfter: true}).then(({team, channel}) => { cy.visit(`/${team.name}/channels/${channel.name}`); diff --git a/e2e-tests/cypress/tests/integration/channels/settings/display/clock_display_mode_spec.js b/e2e-tests/cypress/tests/integration/channels/settings/display/clock_display_mode_spec.js index 3d69cf7c27..c8c6450a51 100644 --- a/e2e-tests/cypress/tests/integration/channels/settings/display/clock_display_mode_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/settings/display/clock_display_mode_spec.js @@ -23,13 +23,6 @@ describe('Settings > Display > Clock Display Mode', () => { let testChannel; before(() => { - // # Enable Timezone - cy.apiUpdateConfig({ - DisplaySettings: { - ExperimentalTimezone: true, - }, - }); - // # Login as new user, visit off-topic and post a message cy.apiInitSetup({loginAfter: true}).then(({team, channel, offTopicUrl}) => { testTeam = team; diff --git a/e2e-tests/cypress/tests/integration/channels/settings/display/timezone_display_mode_spec.js b/e2e-tests/cypress/tests/integration/channels/settings/display/timezone_display_mode_spec.js index 64b9643bb9..f65d741b00 100644 --- a/e2e-tests/cypress/tests/integration/channels/settings/display/timezone_display_mode_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/settings/display/timezone_display_mode_spec.js @@ -40,13 +40,6 @@ describe('Profile > Display > Timezone', () => { let userId; before(() => { - // # Enable Timezone - cy.apiUpdateConfig({ - DisplaySettings: { - ExperimentalTimezone: true, - }, - }); - // # Create and visit off-topic cy.apiInitSetup({loginAfter: true}).then(({user, offTopicUrl}) => { userId = user.id; diff --git a/e2e-tests/cypress/tests/support/api/cloud_default_config.json b/e2e-tests/cypress/tests/support/api/cloud_default_config.json index 66b75cf631..e39ff7d796 100644 --- a/e2e-tests/cypress/tests/support/api/cloud_default_config.json +++ b/e2e-tests/cypress/tests/support/api/cloud_default_config.json @@ -417,9 +417,7 @@ "ChimeraOAuthProxyURL": "" }, "DisplaySettings": { - "CustomURLSchemes": [], - "MaxMarkdownNodes": 0, - "ExperimentalTimezone": false + "CustomURLSchemes": [] }, "GuestAccountsSettings": { "Enable": true, diff --git a/e2e-tests/cypress/tests/support/api/on_prem_default_config.json b/e2e-tests/cypress/tests/support/api/on_prem_default_config.json index c18ce4cd70..a5a09a73fb 100644 --- a/e2e-tests/cypress/tests/support/api/on_prem_default_config.json +++ b/e2e-tests/cypress/tests/support/api/on_prem_default_config.json @@ -591,9 +591,7 @@ "ChimeraOAuthProxyURL": "" }, "DisplaySettings": { - "CustomURLSchemes": [], - "MaxMarkdownNodes": 0, - "ExperimentalTimezone": false + "CustomURLSchemes": [] }, "GuestAccountsSettings": { "Enable": true, diff --git a/e2e-tests/playwright/support/server/default_config.ts b/e2e-tests/playwright/support/server/default_config.ts index 5c99cce938..5ca319a6a9 100644 --- a/e2e-tests/playwright/support/server/default_config.ts +++ b/e2e-tests/playwright/support/server/default_config.ts @@ -667,7 +667,6 @@ const defaultServerConfig: AdminConfig = { DisplaySettings: { CustomURLSchemes: [], MaxMarkdownNodes: 0, - ExperimentalTimezone: true, }, GuestAccountsSettings: { Enable: false, diff --git a/server/config/client.go b/server/config/client.go index 784ec5d5eb..8193d6963e 100644 --- a/server/config/client.go +++ b/server/config/client.go @@ -59,7 +59,7 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li props["DisableAppBar"] = strconv.FormatBool(*c.ExperimentalSettings.DisableAppBar) props["ExperimentalEnableAutomaticReplies"] = strconv.FormatBool(*c.TeamSettings.ExperimentalEnableAutomaticReplies) - props["ExperimentalTimezone"] = strconv.FormatBool(*c.DisplaySettings.ExperimentalTimezone) + props["ExperimentalTimezone"] = "true" props["SendEmailNotifications"] = strconv.FormatBool(*c.EmailSettings.SendEmailNotifications) props["SendPushNotifications"] = strconv.FormatBool(*c.EmailSettings.SendPushNotifications) diff --git a/server/config/common_test.go b/server/config/common_test.go index 980b8cdb5f..f2925e9c98 100644 --- a/server/config/common_test.go +++ b/server/config/common_test.go @@ -80,9 +80,6 @@ func init() { ServiceSettings: model.ServiceSettings{ SiteURL: model.NewString("http://custom.com"), }, - DisplaySettings: model.DisplaySettings{ - ExperimentalTimezone: model.NewBool(false), - }, } } diff --git a/server/config/database_test.go b/server/config/database_test.go index d1d5365c66..c92aaeb5d5 100644 --- a/server/config/database_test.go +++ b/server/config/database_test.go @@ -153,7 +153,6 @@ func TestDatabaseStoreNew(t *testing.T) { defer ds.Close() assert.Equal(t, *customConfigDefaults.ServiceSettings.SiteURL, *ds.Get().ServiceSettings.SiteURL) - assert.Equal(t, *customConfigDefaults.DisplaySettings.ExperimentalTimezone, *ds.Get().DisplaySettings.ExperimentalTimezone) }) t.Run("existing config, initialization required", func(t *testing.T) { @@ -181,7 +180,6 @@ func TestDatabaseStoreNew(t *testing.T) { assert.Equal(t, "http://TestStoreNew", *ds.Get().ServiceSettings.SiteURL) // not existing value should be overwritten by the custom // default value - assert.Equal(t, *customConfigDefaults.DisplaySettings.ExperimentalTimezone, *ds.Get().DisplaySettings.ExperimentalTimezone) assertDatabaseNotEqualsConfig(t, testConfig) }) @@ -208,7 +206,6 @@ func TestDatabaseStoreNew(t *testing.T) { // as the whole config has default values already, custom // defaults should have no effect assert.Equal(t, "http://minimal", *ds.Get().ServiceSettings.SiteURL) - assert.NotEqual(t, *customConfigDefaults.DisplaySettings.ExperimentalTimezone, *ds.Get().DisplaySettings.ExperimentalTimezone) assertDatabaseEqualsConfig(t, minimalConfigNoFF) }) diff --git a/server/config/file_test.go b/server/config/file_test.go index 13cfaed1b7..4f6d55c880 100644 --- a/server/config/file_test.go +++ b/server/config/file_test.go @@ -125,7 +125,6 @@ func TestFileStoreNew(t *testing.T) { assert.Equal(t, "http://TestStoreNew", *configStore.Get().ServiceSettings.SiteURL) // nonexisting value should be overwritten by the custom // defaults - assert.Equal(t, *customConfigDefaults.DisplaySettings.ExperimentalTimezone, *configStore.Get().DisplaySettings.ExperimentalTimezone) assertFileNotEqualsConfig(t, testConfig, path) }) @@ -156,7 +155,6 @@ func TestFileStoreNew(t *testing.T) { // as the whole config has default values already, custom // defaults should have no effect assert.Equal(t, "http://minimal", *configStore.Get().ServiceSettings.SiteURL) - assert.NotEqual(t, *customConfigDefaults.DisplaySettings.ExperimentalTimezone, *configStore.Get().DisplaySettings.ExperimentalTimezone) assertFileEqualsConfig(t, minimalConfigNoFF, path) }) @@ -195,7 +193,6 @@ func TestFileStoreNew(t *testing.T) { defer configStore.Close() assert.Equal(t, *customConfigDefaults.ServiceSettings.SiteURL, *configStore.Get().ServiceSettings.SiteURL) - assert.Equal(t, *customConfigDefaults.DisplaySettings.ExperimentalTimezone, *configStore.Get().DisplaySettings.ExperimentalTimezone) }) t.Run("absolute path, path to file does not exist", func(t *testing.T) { diff --git a/server/platform/services/telemetry/telemetry.go b/server/platform/services/telemetry/telemetry.go index a3ac3fdd8f..564820c55f 100644 --- a/server/platform/services/telemetry/telemetry.go +++ b/server/platform/services/telemetry/telemetry.go @@ -849,7 +849,6 @@ func (ts *TelemetryService) trackConfig() { }) ts.SendTelemetry(TrackConfigDisplay, map[string]any{ - "experimental_timezone": *cfg.DisplaySettings.ExperimentalTimezone, "isdefault_custom_url_schemes": len(cfg.DisplaySettings.CustomURLSchemes) != 0, "isdefault_max_markdown_nodes": isDefault(*cfg.DisplaySettings.MaxMarkdownNodes, 0), }) diff --git a/server/public/model/config.go b/server/public/model/config.go index 1b01b812c4..9d40e04d42 100644 --- a/server/public/model/config.go +++ b/server/public/model/config.go @@ -3160,9 +3160,8 @@ func (s *MessageExportSettings) SetDefaults() { } type DisplaySettings struct { - CustomURLSchemes []string `access:"site_posts"` - MaxMarkdownNodes *int `access:"site_posts"` - ExperimentalTimezone *bool `access:"experimental_features"` + CustomURLSchemes []string `access:"site_posts"` + MaxMarkdownNodes *int `access:"site_posts"` } func (s *DisplaySettings) SetDefaults() { @@ -3174,10 +3173,6 @@ func (s *DisplaySettings) SetDefaults() { if s.MaxMarkdownNodes == nil { s.MaxMarkdownNodes = NewInt(0) } - - if s.ExperimentalTimezone == nil { - s.ExperimentalTimezone = NewBool(true) - } } type GuestAccountsSettings struct { diff --git a/server/tests/test-config.json b/server/tests/test-config.json index d422afbe47..36a8fe8b0d 100644 --- a/server/tests/test-config.json +++ b/server/tests/test-config.json @@ -386,7 +386,6 @@ } }, "DisplaySettings": { - "CustomUrlSchemes": [], - "ExperimentalTimezone": false + "CustomUrlSchemes": [] } } diff --git a/webapp/channels/src/actions/views/group.js b/webapp/channels/src/actions/views/group.js index 951093277a..662c8301c8 100644 --- a/webapp/channels/src/actions/views/group.js +++ b/webapp/channels/src/actions/views/group.js @@ -3,7 +3,6 @@ import {searchGroups} from 'mattermost-redux/actions/groups'; import Permissions from 'mattermost-redux/constants/permissions'; -import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {searchAssociatedGroupsForReferenceLocal} from 'mattermost-redux/selectors/entities/groups'; import {isCustomGroupsEnabled} from 'mattermost-redux/selectors/entities/preferences'; import {haveIChannelPermission} from 'mattermost-redux/selectors/entities/roles'; @@ -18,10 +17,6 @@ export function searchAssociatedGroupsForReference(prefix, teamId, channelId, op )) { return {data: []}; } - - const config = getConfig(state); - const isTimezoneEnabled = config.ExperimentalTimezone === 'true'; - if (isCustomGroupsEnabled(state)) { const params = { q: prefix, @@ -30,7 +25,6 @@ export function searchAssociatedGroupsForReference(prefix, teamId, channelId, op per_page: 60, include_member_count: true, include_channel_member_count: channelId, - include_timezones: isTimezoneEnabled, ...opts, }; diff --git a/webapp/channels/src/actions/websocket_actions.jsx b/webapp/channels/src/actions/websocket_actions.jsx index 254c0bbafe..74b47e8b80 100644 --- a/webapp/channels/src/actions/websocket_actions.jsx +++ b/webapp/channels/src/actions/websocket_actions.jsx @@ -989,7 +989,6 @@ function handleUserAddedEvent(msg) { const state = doGetState(); const config = getConfig(state); const license = getLicense(state); - const isTimezoneEnabled = config.ExperimentalTimezone === 'true'; const currentChannelId = getCurrentChannelId(state); if (currentChannelId === msg.broadcast.channel_id) { doDispatch(getChannelStats(currentChannelId)); @@ -998,7 +997,7 @@ function handleUserAddedEvent(msg) { data: {id: msg.broadcast.channel_id, user_id: msg.data.user_id}, }); if (license?.IsLicensed === 'true' && license?.LDAPGroups === 'true' && config.EnableConfirmNotificationsToChannel === 'true') { - doDispatch(getChannelMemberCountsByGroup(currentChannelId, isTimezoneEnabled)); + doDispatch(getChannelMemberCountsByGroup(currentChannelId)); } } @@ -1032,7 +1031,6 @@ export function handleUserRemovedEvent(msg) { const currentUser = getCurrentUser(state); const config = getConfig(state); const license = getLicense(state); - const isTimezoneEnabled = config.ExperimentalTimezone === 'true'; if (msg.broadcast.user_id === currentUser.id) { dispatch(loadChannelsForCurrentUser()); @@ -1085,7 +1083,7 @@ export function handleUserRemovedEvent(msg) { data: {id: msg.broadcast.channel_id, user_id: msg.data.user_id}, }); if (license?.IsLicensed === 'true' && license?.LDAPGroups === 'true' && config.EnableConfirmNotificationsToChannel === 'true') { - dispatch(getChannelMemberCountsByGroup(currentChannel.id, isTimezoneEnabled)); + dispatch(getChannelMemberCountsByGroup(currentChannel.id)); } } diff --git a/webapp/channels/src/components/admin_console/admin_definition.jsx b/webapp/channels/src/components/admin_console/admin_definition.jsx index a029d3b41a..29024e66f4 100644 --- a/webapp/channels/src/components/admin_console/admin_definition.jsx +++ b/webapp/channels/src/components/admin_console/admin_definition.jsx @@ -6949,16 +6949,6 @@ const AdminDefinition = { isHidden: it.not(it.licensedForFeature('SAML')), isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.EXPERIMENTAL.FEATURES)), }, - { - type: Constants.SettingsTypes.TYPE_BOOL, - key: 'DisplaySettings.ExperimentalTimezone', - label: t('admin.experimental.experimentalTimezone.title'), - label_default: 'Timezone:', - help_text: t('admin.experimental.experimentalTimezone.desc'), - help_text_default: 'Select the timezone used for timestamps in the user interface and email notifications. When true, the Timezone section is visible in the Settings and a time zone is automatically assigned in the next active session. When false, the Timezone setting is hidden in the Settings.', - help_text_markdown: false, - isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.EXPERIMENTAL.FEATURES)), - }, { type: Constants.SettingsTypes.TYPE_BOOL, key: 'EmailSettings.UseChannelInEmailNotifications', diff --git a/webapp/channels/src/components/advanced_create_comment/advanced_create_comment.test.tsx b/webapp/channels/src/components/advanced_create_comment/advanced_create_comment.test.tsx index 6b1c194a51..1e79614ef1 100644 --- a/webapp/channels/src/components/advanced_create_comment/advanced_create_comment.test.tsx +++ b/webapp/channels/src/components/advanced_create_comment/advanced_create_comment.test.tsx @@ -76,7 +76,6 @@ describe('components/AdvancedCreateComment', () => { rhsExpanded: false, badConnection: false, getChannelTimezones: jest.fn(() => Promise.resolve({data: '', error: ''})), - isTimezoneEnabled: false, selectedPostFocussedAt: 0, canPost: true, canUploadFiles: true, @@ -732,29 +731,6 @@ describe('components/AdvancedCreateComment', () => { }); }); - it(`should show Confirm Modal for @${mention} mentions when needed`, () => { - const props: any = { - ...baseProps, - draft: { - message: `Test message @${mention}`, - uploadsInProgress: [], - fileInfos: [{}, {}, {}], - }, - onSubmit, - channelMembersCount: 8, - enableConfirmNotificationsToChannel: true, - }; - - const wrapper = shallow( - , - ); - - wrapper.instance().handleSubmit(submitEvent); - expect(onSubmit).not.toHaveBeenCalled(); - expect(preventDefault).toHaveBeenCalled(); - expect(props.openModal).toHaveBeenCalled(); - }); - it(`should show Confirm Modal for @${mention} mentions when needed and timezone notification`, async () => { const props: any = { ...baseProps, @@ -764,7 +740,6 @@ describe('components/AdvancedCreateComment', () => { fileInfos: [{}, {}, {}], }, onSubmit, - isTimezoneEnabled: true, channelMembersCount: 8, enableConfirmNotificationsToChannel: true, }; @@ -792,7 +767,6 @@ describe('components/AdvancedCreateComment', () => { fileInfos: [{}, {}, {}], }, onSubmit, - isTimezoneEnabled: true, channelMembersCount: 8, enableConfirmNotificationsToChannel: true, }; @@ -832,7 +806,6 @@ describe('components/AdvancedCreateComment', () => { channel_member_timezones_count: 0, }, }, - isTimezoneEnabled: false, channelMembersCount: 8, useChannelMentions: true, enableConfirmNotificationsToChannel: true, @@ -904,7 +877,6 @@ describe('components/AdvancedCreateComment', () => { channel_member_timezones_count: 0, }, }, - isTimezoneEnabled: false, channelMembersCount: 8, useChannelMentions: true, enableConfirmNotificationsToChannel: true, @@ -945,7 +917,6 @@ describe('components/AdvancedCreateComment', () => { channel_member_timezones_count: 5, }, }, - isTimezoneEnabled: true, channelMembersCount: 8, useChannelMentions: true, enableConfirmNotificationsToChannel: true, diff --git a/webapp/channels/src/components/advanced_create_comment/advanced_create_comment.tsx b/webapp/channels/src/components/advanced_create_comment/advanced_create_comment.tsx index 3b98468609..0783d8fb32 100644 --- a/webapp/channels/src/components/advanced_create_comment/advanced_create_comment.tsx +++ b/webapp/channels/src/components/advanced_create_comment/advanced_create_comment.tsx @@ -148,9 +148,6 @@ export type Props = { // Determines if the RHS is in expanded state rhsExpanded: boolean; - // Determines if timezones are enabled on the server. - isTimezoneEnabled: boolean; - // The last time, if any, the selected post changed. Will be 0 if no post is selected. selectedPostFocussedAt: number; @@ -173,7 +170,7 @@ export type Props = { scrollToBottom?: () => void; // Group member mention - getChannelMemberCountsByGroup: (channelID: string, isTimezoneEnabled: boolean) => void; + getChannelMemberCountsByGroup: (channelID: string) => void; groupsWithAllowReference: Map | null; channelMemberCountsByGroup: ChannelMemberCountsByGroup; focusOnMount?: boolean; @@ -356,7 +353,7 @@ class AdvancedCreateComment extends React.PureComponent { }; getChannelMemberCountsByGroup = () => { - const {useLDAPGroupMentions, useCustomGroupMentions, channelId, isTimezoneEnabled, searchAssociatedGroupsForReference, getChannelMemberCountsByGroup, draft, currentTeamId} = this.props; + const {useLDAPGroupMentions, useCustomGroupMentions, channelId, searchAssociatedGroupsForReference, getChannelMemberCountsByGroup, draft, currentTeamId} = this.props; if ((useLDAPGroupMentions || useCustomGroupMentions) && channelId) { const mentions = mentionsMinusSpecialMentionsInText(draft.message); @@ -364,7 +361,7 @@ class AdvancedCreateComment extends React.PureComponent { if (mentions.length === 1) { searchAssociatedGroupsForReference(mentions[0], currentTeamId, channelId); } else if (mentions.length > 1) { - getChannelMemberCountsByGroup(channelId, isTimezoneEnabled); + getChannelMemberCountsByGroup(channelId); } } }; @@ -551,7 +548,6 @@ class AdvancedCreateComment extends React.PureComponent { channelMembersCount, enableConfirmNotificationsToChannel, useChannelMentions, - isTimezoneEnabled, groupsWithAllowReference, channelMemberCountsByGroup, useLDAPGroupMentions, @@ -612,10 +608,8 @@ class AdvancedCreateComment extends React.PureComponent { } } - if (isTimezoneEnabled) { - const {data} = await this.props.getChannelTimezones(this.props.channelId); - channelTimezoneCount = data ? data.length : 0; - } + const {data} = await this.props.getChannelTimezones(this.props.channelId); + channelTimezoneCount = data ? data.length : 0; } if (!useChannelMentions && hasSpecialMentions) { diff --git a/webapp/channels/src/components/advanced_create_comment/index.ts b/webapp/channels/src/components/advanced_create_comment/index.ts index b75eba0cf7..f4489f8ca5 100644 --- a/webapp/channels/src/components/advanced_create_comment/index.ts +++ b/webapp/channels/src/components/advanced_create_comment/index.ts @@ -72,7 +72,6 @@ function makeMapStateToProps() { const enableEmojiPicker = config.EnableEmojiPicker === 'true'; const enableGifPicker = config.EnableGifPicker === 'true'; const badConnection = connectionErrorCount(state) > 1; - const isTimezoneEnabled = config.ExperimentalTimezone === 'true'; const canPost = haveIChannelPermission(state, channel.team_id, channel.id, Permissions.CREATE_POST); const useChannelMentions = haveIChannelPermission(state, channel.team_id, channel.id, Permissions.USE_CHANNEL_MENTIONS); const isLDAPEnabled = license?.IsLicensed === 'true' && license?.LDAPGroups === 'true'; @@ -102,7 +101,6 @@ function makeMapStateToProps() { maxPostSize: parseInt(config.MaxPostSize || '', 10) || Constants.DEFAULT_CHARACTER_LIMIT, rhsExpanded: getIsRhsExpanded(state), badConnection, - isTimezoneEnabled, selectedPostFocussedAt: getSelectedPostFocussedAt(state), canPost, useChannelMentions, @@ -138,7 +136,7 @@ type Actions = { getChannelTimezones: (channelId: string) => Promise; emitShortcutReactToLastPostFrom: (location: string) => void; setShowPreview: (showPreview: boolean) => void; - getChannelMemberCountsByGroup: (channelID: string, includeTimezones: boolean) => void; + getChannelMemberCountsByGroup: (channelID: string) => void; openModal:

(modalData: ModalData

) => void; savePreferences: (userId: string, preferences: PreferenceType[]) => ActionResult; searchAssociatedGroupsForReference: (prefix: string, teamId: string, channelId: string | undefined) => Promise<{ data: any }>; diff --git a/webapp/channels/src/components/advanced_create_post/advanced_create_post.test.tsx b/webapp/channels/src/components/advanced_create_post/advanced_create_post.test.tsx index d503bd7454..626b39ea24 100644 --- a/webapp/channels/src/components/advanced_create_post/advanced_create_post.test.tsx +++ b/webapp/channels/src/components/advanced_create_post/advanced_create_post.test.tsx @@ -89,7 +89,9 @@ const baseProp: Props = { executeCommand: () => { return {data: true}; }, - getChannelTimezones: jest.fn(), + getChannelTimezones: jest.fn(() => { + return {data: '', error: ''}; + }), runMessageWillBePostedHooks: (post: Post) => { return {data: post}; }, @@ -107,7 +109,6 @@ const baseProp: Props = { emojiMap: new EmojiMap(new Map()), enableEmojiPicker: true, enableGifPicker: true, - isTimezoneEnabled: false, useLDAPGroupMentions: true, useCustomGroupMentions: true, canPost: true, @@ -379,18 +380,34 @@ describe('components/advanced_create_post', () => { // expect(GlobalActions.emitLocalUserTypingEvent).toHaveBeenCalledWith(currentChannelProp.id, ''); // }); - it('onSubmit test for @here', () => { - const wrapper = shallow(advancedCreatePost()); + it('onSubmit test for @all', async () => { + const result: ActionResult = { + data: [1, 2, 3, 4], + }; + const wrapper = shallow( + advancedCreatePost({ + actions: { + ...baseProp.actions, + getChannelTimezones: jest.fn(() => result), + }, + currentChannelMembersCount: 9, + }), + ); wrapper.setState({ - message: 'test @here', + message: 'test @all', }); const instance = wrapper.instance() as AdvancedCreatePost; + const showNotifyAllModal = instance.showNotifyAllModal; + instance.showNotifyAllModal = jest.fn((mentions, channelTimezoneCount, memberNotifyCount) => showNotifyAllModal(mentions, channelTimezoneCount, memberNotifyCount)); + const form = wrapper.find('#create_post'); - form.simulate('Submit', {preventDefault: jest.fn()}); + await form.simulate('Submit', {preventDefault: jest.fn()}); + expect(instance.props.actions.openModal).toHaveBeenCalledTimes(1); + expect(instance.showNotifyAllModal).toHaveBeenCalledWith(['@all'], 4, 8); wrapper.setProps({ currentChannelMembersCount: 2, @@ -400,18 +417,34 @@ describe('components/advanced_create_post', () => { expect(instance.props.actions.openModal).toHaveBeenCalledTimes(1); }); - it('onSubmit test for @all', () => { - const wrapper = shallow(advancedCreatePost()); + it('onSubmit test for @here', async () => { + const result: ActionResult = { + data: [1, 2, 3, 4], + }; + const wrapper = shallow( + advancedCreatePost({ + actions: { + ...baseProp.actions, + getChannelTimezones: jest.fn(() => result), + }, + currentChannelMembersCount: 9, + }), + ); wrapper.setState({ - message: 'test @all', + message: 'test @here', }); const instance = wrapper.instance() as AdvancedCreatePost; + const showNotifyAllModal = instance.showNotifyAllModal; + instance.showNotifyAllModal = jest.fn((mentions, channelTimezoneCount, memberNotifyCount) => showNotifyAllModal(mentions, channelTimezoneCount, memberNotifyCount)); + const form = wrapper.find('#create_post'); - form.simulate('Submit', {preventDefault: jest.fn()}); + await form.simulate('Submit', {preventDefault: jest.fn()}); + expect(instance.props.actions.openModal).toHaveBeenCalledTimes(1); + expect(instance.showNotifyAllModal).toHaveBeenCalledWith(['@here'], 4, 8); wrapper.setProps({ currentChannelMembersCount: 2, @@ -633,76 +666,6 @@ describe('components/advanced_create_post', () => { expect(onSubmitPost.mock.calls[0][0]).toEqual(post); }); - it('onSubmit test for @all with timezones', async () => { - const result: ActionResult = { - data: [1, 2, 3, 4], - }; - const wrapper = shallow( - advancedCreatePost({ - actions: { - ...baseProp.actions, - getChannelTimezones: jest.fn(() => result), - }, - isTimezoneEnabled: true, - currentChannelMembersCount: 9, - }), - ); - - wrapper.setState({ - message: 'test @all', - }); - - const instance = wrapper.instance() as AdvancedCreatePost; - - const showNotifyAllModal = instance.showNotifyAllModal; - instance.showNotifyAllModal = jest.fn((mentions, channelTimezoneCount, memberNotifyCount) => showNotifyAllModal(mentions, channelTimezoneCount, memberNotifyCount)); - - const form = wrapper.find('#create_post'); - await form.simulate('Submit', {preventDefault: jest.fn()}); - - expect(instance.props.actions.openModal).toHaveBeenCalledTimes(1); - expect(instance.showNotifyAllModal).toHaveBeenCalledWith(['@all'], 4, 8); - - wrapper.setProps({ - currentChannelMembersCount: 2, - }); - - form.simulate('Submit', {preventDefault: jest.fn()}); - expect(instance.props.actions.openModal).toHaveBeenCalledTimes(1); - }); - - it('onSubmit test for @all with timezones disabled', () => { - const result: ActionResult = { - data: [], - }; - const wrapper = shallow( - advancedCreatePost({ - actions: { - ...baseProp.actions, - getChannelTimezones: jest.fn(() => result), - }, - isTimezoneEnabled: false, - }), - ); - - wrapper.setState({ - message: 'test @all', - }); - - const instance = wrapper.instance() as AdvancedCreatePost; - - const form = wrapper.find('#create_post'); - form.simulate('Submit', {preventDefault: jest.fn()}); - expect(instance.props.actions.openModal).toHaveBeenCalledTimes(1); - - wrapper.setProps({ - currentChannelMembersCount: 2, - }); - - form.simulate('Submit', {preventDefault: jest.fn()}); - expect(instance.props.actions.openModal).toHaveBeenCalledTimes(1); - }); - it('onSubmit test for "/header" message', () => { const openModal = jest.fn(); diff --git a/webapp/channels/src/components/advanced_create_post/advanced_create_post.tsx b/webapp/channels/src/components/advanced_create_post/advanced_create_post.tsx index 25c494ae64..7a12dc2128 100644 --- a/webapp/channels/src/components/advanced_create_post/advanced_create_post.tsx +++ b/webapp/channels/src/components/advanced_create_post/advanced_create_post.tsx @@ -148,9 +148,6 @@ export type Props = { //If RHS open rhsOpen: boolean; - //To check if the timezones are enable on the server. - isTimezoneEnabled: boolean; - canPost: boolean; //To determine if the current user can send special channel mentions @@ -216,7 +213,7 @@ export type Props = { //Function to set or unset emoji picker for last message emitShortcutReactToLastPostFrom: (emittedFrom: string) => void; - getChannelMemberCountsByGroup: (channelId: string, includeTimezones: boolean) => void; + getChannelMemberCountsByGroup: (channelId: string) => void; //Function used to advance the tutorial forward savePreferences: (userId: string, preferences: PreferenceType[]) => ActionResult; @@ -354,7 +351,7 @@ class AdvancedCreatePost extends React.PureComponent { } getChannelMemberCountsByGroup = () => { - const {useLDAPGroupMentions, useCustomGroupMentions, currentChannel, isTimezoneEnabled, actions, draft} = this.props; + const {useLDAPGroupMentions, useCustomGroupMentions, currentChannel, actions, draft} = this.props; if ((useLDAPGroupMentions || useCustomGroupMentions) && currentChannel.id) { const mentions = mentionsMinusSpecialMentionsInText(draft.message); @@ -362,7 +359,7 @@ class AdvancedCreatePost extends React.PureComponent { if (mentions.length === 1) { actions.searchAssociatedGroupsForReference(mentions[0], this.props.currentTeamId, currentChannel.id); } else if (mentions.length > 1) { - actions.getChannelMemberCountsByGroup(currentChannel.id, isTimezoneEnabled); + actions.getChannelMemberCountsByGroup(currentChannel.id); } } }; @@ -672,10 +669,8 @@ class AdvancedCreatePost extends React.PureComponent { } } - if (this.props.isTimezoneEnabled) { - const {data} = await this.props.actions.getChannelTimezones(this.props.currentChannel.id); - channelTimezoneCount = data ? data.length : 0; - } + const {data} = await this.props.actions.getChannelTimezones(this.props.currentChannel.id); + channelTimezoneCount = data ? data.length : 0; } const isDirectOrGroup = diff --git a/webapp/channels/src/components/advanced_create_post/index.ts b/webapp/channels/src/components/advanced_create_post/index.ts index 66547c9ed4..4738be862b 100644 --- a/webapp/channels/src/components/advanced_create_post/index.ts +++ b/webapp/channels/src/components/advanced_create_post/index.ts @@ -80,7 +80,6 @@ function makeMapStateToProps() { const currentUserId = getCurrentUserId(state); const userIsOutOfOffice = getStatusForUserId(state, currentUserId) === UserStatuses.OUT_OF_OFFICE; const badConnection = connectionErrorCount(state) > 1; - const isTimezoneEnabled = config.ExperimentalTimezone === 'true'; const canPost = haveICurrentChannelPermission(state, Permissions.CREATE_POST); const useChannelMentions = haveICurrentChannelPermission(state, Permissions.USE_CHANNEL_MENTIONS); const isLDAPEnabled = license?.IsLicensed === 'true' && license?.LDAPGroups === 'true'; @@ -126,7 +125,6 @@ function makeMapStateToProps() { rhsOpen: getIsRhsOpen(state), emojiMap: getEmojiMap(state), badConnection, - isTimezoneEnabled, canPost, useChannelMentions, shouldShowPreview: showPreviewOnCreatePost(state), @@ -167,7 +165,7 @@ type Actions = { getChannelTimezones: (channelId: string) => ActionResult; scrollPostListToBottom: () => void; emitShortcutReactToLastPostFrom: (emittedFrom: string) => void; - getChannelMemberCountsByGroup: (channelId: string, includeTimezones: boolean) => void; + getChannelMemberCountsByGroup: (channelId: string) => void; savePreferences: (userId: string, preferences: PreferenceType[]) => ActionResult; searchAssociatedGroupsForReference: (prefix: string, teamId: string, channelId: string | undefined) => Promise<{ data: any }>; } diff --git a/webapp/channels/src/components/logged_in/index.ts b/webapp/channels/src/components/logged_in/index.ts index ac53e2f5ac..6c7e9103c4 100644 --- a/webapp/channels/src/components/logged_in/index.ts +++ b/webapp/channels/src/components/logged_in/index.ts @@ -41,7 +41,6 @@ function mapStateToProps(state: GlobalState, ownProps: Props) { currentChannelId, isCurrentChannelManuallyUnread: isManuallyUnread(state, currentChannelId), mfaRequired: checkIfMFARequired(getCurrentUser(state), license, config, ownProps.match.url), - enableTimezone: config.ExperimentalTimezone === 'true', showTermsOfService, }; } diff --git a/webapp/channels/src/components/logged_in/logged_in.test.tsx b/webapp/channels/src/components/logged_in/logged_in.test.tsx index 9f3178b6e5..7decebd8a5 100644 --- a/webapp/channels/src/components/logged_in/logged_in.test.tsx +++ b/webapp/channels/src/components/logged_in/logged_in.test.tsx @@ -23,7 +23,6 @@ describe('components/logged_in/LoggedIn', () => { const baseProps: Props = { currentUser: {} as UserProfile, mfaRequired: false, - enableTimezone: false, actions: { autoUpdateTimezone: jest.fn(), getChannelURLAction: jest.fn(), diff --git a/webapp/channels/src/components/logged_in/logged_in.tsx b/webapp/channels/src/components/logged_in/logged_in.tsx index 5c6cc6adf3..98a6e18fef 100644 --- a/webapp/channels/src/components/logged_in/logged_in.tsx +++ b/webapp/channels/src/components/logged_in/logged_in.tsx @@ -34,7 +34,6 @@ export type Props = { isCurrentChannelManuallyUnread: boolean; children?: React.ReactNode; mfaRequired: boolean; - enableTimezone: boolean; actions: { autoUpdateTimezone: (deviceTimezone: string) => void; getChannelURLAction: (channel: Channel, teamId: string, url: string) => void; @@ -81,9 +80,7 @@ export default class LoggedIn extends React.PureComponent { // Initialize websocket WebSocketActions.initialize(); - if (this.props.enableTimezone) { - this.props.actions.autoUpdateTimezone(getBrowserTimezone()); - } + this.props.actions.autoUpdateTimezone(getBrowserTimezone()); // Make sure the websockets close and reset version window.addEventListener('beforeunload', this.handleBeforeUnload); diff --git a/webapp/channels/src/components/post_view/post_edited_indicator/index.ts b/webapp/channels/src/components/post_view/post_edited_indicator/index.ts index d98237c40d..276008938f 100644 --- a/webapp/channels/src/components/post_view/post_edited_indicator/index.ts +++ b/webapp/channels/src/components/post_view/post_edited_indicator/index.ts @@ -12,7 +12,7 @@ import {getCurrentUserId} from 'mattermost-redux/selectors/entities/common'; import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general'; import {getPost} from 'mattermost-redux/selectors/entities/posts'; import {getBool} from 'mattermost-redux/selectors/entities/preferences'; -import {getCurrentTimezone, isTimezoneEnabled} from 'mattermost-redux/selectors/entities/timezone'; +import {getCurrentTimezone} from 'mattermost-redux/selectors/entities/timezone'; import {openShowEditHistory} from 'actions/views/rhs'; @@ -53,11 +53,7 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps): StateProps { const config = getConfig(state); const channel = getChannel(state, post?.channel_id || ''); - let timeZone: TimestampProps['timeZone']; - - if (isTimezoneEnabled(state)) { - timeZone = getCurrentTimezone(state); - } + const timeZone: TimestampProps['timeZone'] = getCurrentTimezone(state); const postOwner = post ? isPostOwner(state, post) : undefined; const isMilitaryTime = getBool(state, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.USE_MILITARY_TIME, false); diff --git a/webapp/channels/src/components/profile_popover/__snapshots__/profile_popover.test.tsx.snap b/webapp/channels/src/components/profile_popover/__snapshots__/profile_popover.test.tsx.snap index abc34a9dbf..b7d3187bc8 100644 --- a/webapp/channels/src/components/profile_popover/__snapshots__/profile_popover.test.tsx.snap +++ b/webapp/channels/src/components/profile_popover/__snapshots__/profile_popover.test.tsx.snap @@ -3421,7 +3421,6 @@ exports[`components/ProfilePopover should show the start call button when isCall currentTeamId="team_id" currentUserId="" enableLastActiveTime={true} - enableTimezone={false} hide={[MockFunction]} isAnyModalOpen={false} isCallsCanBeDisabledOnSpecificChannels={false} @@ -3515,7 +3514,6 @@ exports[`components/ProfilePopover should show the start call button when isCall currentUserId="" customStatus={null} enableLastActiveTime={true} - enableTimezone={false} hasMention={false} hide={[MockFunction]} intl={ diff --git a/webapp/channels/src/components/profile_popover/index.ts b/webapp/channels/src/components/profile_popover/index.ts index 8d1bca26b5..a2c30790c9 100644 --- a/webapp/channels/src/components/profile_popover/index.ts +++ b/webapp/channels/src/components/profile_popover/index.ts @@ -20,7 +20,7 @@ import { getCurrentRelativeTeamUrl, getTeamMember, } from 'mattermost-redux/selectors/entities/teams'; -import {getCurrentTimezone, isTimezoneEnabled} from 'mattermost-redux/selectors/entities/timezone'; +import {getCurrentTimezone} from 'mattermost-redux/selectors/entities/timezone'; import {displayLastActiveLabel, getCurrentUserId, getLastActiveTimestampUnits, getLastActivityForUserId, getStatusForUserId, getUser} from 'mattermost-redux/selectors/entities/users'; import type {GenericAction} from 'mattermost-redux/types/actions'; @@ -93,7 +93,6 @@ function makeMapStateToProps() { return { currentTeamId: team.id, currentUserId, - enableTimezone: isTimezoneEnabled(state), isTeamAdmin, isChannelAdmin, isInCurrentTeam: Boolean(teamMember) && teamMember?.delete_at === 0, diff --git a/webapp/channels/src/components/profile_popover/profile_popover.test.tsx b/webapp/channels/src/components/profile_popover/profile_popover.test.tsx index c6a52ae151..34e28c34ad 100644 --- a/webapp/channels/src/components/profile_popover/profile_popover.test.tsx +++ b/webapp/channels/src/components/profile_popover/profile_popover.test.tsx @@ -18,7 +18,6 @@ import {TestHelper} from 'utils/test_helper'; describe('components/ProfilePopover', () => { const baseProps = { - enableTimezone: false, userId: '0', user: TestHelper.getUserMock({ username: 'some_username', @@ -67,6 +66,12 @@ describe('components/ProfilePopover', () => { }, users: { currentUserId: '', + profiles: { + user1: { + id: 'user1', + roles: '', + }, + }, }, preferences: { myPreferences: {}, diff --git a/webapp/channels/src/components/profile_popover/profile_popover.tsx b/webapp/channels/src/components/profile_popover/profile_popover.tsx index c34ccf4c4f..89179dd261 100644 --- a/webapp/channels/src/components/profile_popover/profile_popover.tsx +++ b/webapp/channels/src/components/profile_popover/profile_popover.tsx @@ -164,7 +164,6 @@ export interface ProfilePopoverProps extends Omit(modalData: ModalData

) => void; closeModal: (modalId: string) => void; @@ -425,7 +424,7 @@ class ProfilePopover extends React.PureComponent = ['user', 'userId', 'channelId', 'src', 'status', 'hideStatus', 'isBusy', - 'hide', 'hasMention', 'enableTimezone', 'currentUserId', 'currentTeamId', 'teamUrl', 'actions', 'isTeamAdmin', + 'hide', 'hasMention', 'currentUserId', 'currentTeamId', 'teamUrl', 'actions', 'isTeamAdmin', 'isChannelAdmin', 'canManageAnyChannelMembersInCurrentTeam', 'intl']; const popoverProps: React.ComponentProps = Utils.deleteKeysFromObject({...this.props}, keysToBeRemoved); @@ -566,11 +565,7 @@ class ProfilePopover extends React.PureComponent, ); - if ( - this.props.enableTimezone && - this.props.user.timezone && - !haveOverrideProp - ) { + if (this.props.user.timezone && !haveOverrideProp) { dataContent.push( { manualTimezone: '', }, status: 'away', - isTimezoneEnabled: true, isMilitaryTime: false, isCustomStatusEnabled: false, isCustomStatusExpired: false, diff --git a/webapp/channels/src/components/suggestion/search_date_suggestion/index.ts b/webapp/channels/src/components/suggestion/search_date_suggestion/index.ts index 7906d10a9a..0f3185188e 100644 --- a/webapp/channels/src/components/suggestion/search_date_suggestion/index.ts +++ b/webapp/channels/src/components/suggestion/search_date_suggestion/index.ts @@ -3,7 +3,7 @@ import {connect} from 'react-redux'; -import {getCurrentTimezone, isTimezoneEnabled} from 'mattermost-redux/selectors/entities/timezone'; +import {getCurrentTimezone} from 'mattermost-redux/selectors/entities/timezone'; import {getCurrentLocale} from 'selectors/i18n'; @@ -16,13 +16,7 @@ import SearchDateSuggestion from './search_date_suggestion'; function mapStateToProps(state: GlobalState) { const timezone = getCurrentTimezone(state); const locale = getCurrentLocale(state); - - const enableTimezone = isTimezoneEnabled(state); - - let currentDate; - if (enableTimezone) { - currentDate = getCurrentDateForTimezone(timezone); - } + const currentDate = getCurrentDateForTimezone(timezone); return { currentDate, diff --git a/webapp/channels/src/components/timestamp/index.test.tsx b/webapp/channels/src/components/timestamp/index.test.tsx index 479d0b10f0..3e82af2bcf 100644 --- a/webapp/channels/src/components/timestamp/index.test.tsx +++ b/webapp/channels/src/components/timestamp/index.test.tsx @@ -18,11 +18,6 @@ describe('mapStateToProps', () => { const initialState = { entities: { - general: { - config: { - ExperimentalTimezone: 'true', - }, - }, preferences: { myPreferences: {}, }, @@ -124,14 +119,6 @@ describe('mapStateToProps', () => { const props = mapStateToProps(testState, {timeZone: 'America/Phoenix'}); expect(props.timeZone).toBe('America/Phoenix'); }); - - test('timeZone should be the value of prop.timeZone when given, even when timezone are disabled', () => { - const testState = {...initialState}; - testState.entities.general.config.ExperimentalTimezone = 'false'; - - const props = mapStateToProps(testState, {timeZone: 'America/Chicago'}); - expect(props.timeZone).toBe('America/Chicago'); - }); }); describe('hour12, hourCycle unsupported', () => { diff --git a/webapp/channels/src/components/timestamp/index.ts b/webapp/channels/src/components/timestamp/index.ts index e13fc8e884..42d8321130 100644 --- a/webapp/channels/src/components/timestamp/index.ts +++ b/webapp/channels/src/components/timestamp/index.ts @@ -6,7 +6,7 @@ import {connect} from 'react-redux'; import type {UserTimezone} from '@mattermost/types/users'; import {getBool} from 'mattermost-redux/selectors/entities/preferences'; -import {getCurrentTimezoneFull, isTimezoneEnabled} from 'mattermost-redux/selectors/entities/timezone'; +import {getCurrentTimezoneFull} from 'mattermost-redux/selectors/entities/timezone'; import {getUserCurrentTimezone} from 'mattermost-redux/utils/timezone_utils'; import {Preferences} from 'utils/constants'; @@ -25,14 +25,10 @@ type Props = { } export function mapStateToProps(state: GlobalState, ownProps: Props) { - let timeZone: TimestampProps['timeZone']; + const timeZone: TimestampProps['timeZone'] = getUserCurrentTimezone(ownProps.userTimezone ?? getCurrentTimezoneFull(state)) || undefined; let hourCycle: TimestampProps['hourCycle']; let hour12: TimestampProps['hour12']; - if (isTimezoneEnabled(state)) { - timeZone = getUserCurrentTimezone(ownProps.userTimezone ?? getCurrentTimezoneFull(state)) ?? undefined; - } - const useMilitaryTime = getBool(state, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.USE_MILITARY_TIME, false); if (supportsHourCycle) { diff --git a/webapp/channels/src/components/user_settings/display/index.ts b/webapp/channels/src/components/user_settings/display/index.ts index 58d648858f..4e8a5cd4ba 100644 --- a/webapp/channels/src/components/user_settings/display/index.ts +++ b/webapp/channels/src/components/user_settings/display/index.ts @@ -44,7 +44,6 @@ export function makeMapStateToProps() { const enableLinkPreviews = config.EnableLinkPreviews === 'true'; const defaultClientLocale = config.DefaultClientLocale as string; const enableThemeSelection = config.EnableThemeSelection === 'true'; - const enableTimezone = config.ExperimentalTimezone === 'true'; const lockTeammateNameDisplay = getLicense(state).LockTeammateNameDisplay === 'true' && config.LockTeammateNameDisplay === 'true'; const configTeammateNameDisplay = config.TeammateNameDisplay as string; const emojiPickerEnabled = config.EnableEmojiPicker === 'true'; @@ -62,7 +61,6 @@ export function makeMapStateToProps() { enableLinkPreviews, defaultClientLocale, enableThemeSelection, - enableTimezone, timezones, timezoneLabel, userTimezone, diff --git a/webapp/channels/src/components/user_settings/display/user_settings_display.test.tsx b/webapp/channels/src/components/user_settings/display/user_settings_display.test.tsx index 3f47c07765..a80d0a6963 100644 --- a/webapp/channels/src/components/user_settings/display/user_settings_display.test.tsx +++ b/webapp/channels/src/components/user_settings/display/user_settings_display.test.tsx @@ -74,7 +74,6 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { configTeammateNameDisplay: '', currentUserTimezone: 'America/New_York', - enableTimezone: true, shouldAutoUpdateTimezone: true, lockTeammateNameDisplay: false, collapsedReplyThreads: '', diff --git a/webapp/channels/src/components/user_settings/display/user_settings_display.tsx b/webapp/channels/src/components/user_settings/display/user_settings_display.tsx index f502224b72..fd3083cf70 100644 --- a/webapp/channels/src/components/user_settings/display/user_settings_display.tsx +++ b/webapp/channels/src/components/user_settings/display/user_settings_display.tsx @@ -106,7 +106,6 @@ type Props = { enableThemeSelection: boolean; configTeammateNameDisplay: string; currentUserTimezone: string; - enableTimezone: boolean; shouldAutoUpdateTimezone: boolean | string; lockTeammateNameDisplay: boolean; militaryTime: string; @@ -181,9 +180,9 @@ export default class UserSettingsDisplay extends React.PureComponent