MM-53274 - Add a "feature flag" for Calls ringing (#23810)

* add "feature flag" for calls ringing

* tests
This commit is contained in:
Christopher Poile 2023-06-22 15:40:54 -04:00 committed by GitHub
parent bea5b05533
commit a7bf602478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 12 deletions

View File

@ -33,7 +33,7 @@ describe('components/user_settings/notifications/DesktopNotificationSettings', (
threads: NotificationLevels.ALL, threads: NotificationLevels.ALL,
callsSelectedSound: 'Dynamic', callsSelectedSound: 'Dynamic',
callsSound: 'false', callsSound: 'false',
isCallsEnabled: false, isCallsRingingEnabled: false,
}; };
test('should match snapshot, on max setting', () => { test('should match snapshot, on max setting', () => {
@ -54,7 +54,7 @@ describe('components/user_settings/notifications/DesktopNotificationSettings', (
}); });
test('should match snapshot, on max setting with Calls enabled', () => { test('should match snapshot, on max setting with Calls enabled', () => {
const props = {...baseProps, isCallsEnabled: true}; const props = {...baseProps, isCallsRingingEnabled: true};
const wrapper = shallow( const wrapper = shallow(
<DesktopNotificationSettings {...props}/>, <DesktopNotificationSettings {...props}/>,
); );
@ -63,7 +63,7 @@ describe('components/user_settings/notifications/DesktopNotificationSettings', (
}); });
test('should match snapshot, on max setting with Calls enabled, calls sound true', () => { test('should match snapshot, on max setting with Calls enabled, calls sound true', () => {
const props = {...baseProps, isCallsEnabled: true, callsSound: 'true'}; const props = {...baseProps, isCallsRingingEnabled: true, callsSound: 'true'};
const wrapper = shallow( const wrapper = shallow(
<DesktopNotificationSettings {...props}/>, <DesktopNotificationSettings {...props}/>,
); );

View File

@ -35,7 +35,7 @@ type Props = {
selectedSound: string; selectedSound: string;
callsSelectedSound: string; callsSelectedSound: string;
isCollapsedThreadsEnabled: boolean; isCollapsedThreadsEnabled: boolean;
isCallsEnabled: boolean; isCallsRingingEnabled: boolean;
}; };
type State = { type State = {
@ -164,7 +164,7 @@ export default class DesktopNotificationSettings extends React.PureComponent<Pro
/></div>); /></div>);
} }
if (this.props.isCallsEnabled) { if (this.props.isCallsRingingEnabled) {
const callsSoundRadio = [false, false]; const callsSoundRadio = [false, false];
if (this.props.callsSound === 'false') { if (this.props.callsSound === 'false') {
callsSoundRadio[1] = true; callsSoundRadio[1] = true;

View File

@ -12,7 +12,7 @@ import {ActionFunc} from 'mattermost-redux/types/actions';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';
import UserSettingsNotifications, {Props} from './user_settings_notifications'; import UserSettingsNotifications, {Props} from './user_settings_notifications';
import {isCallsEnabled} from 'selectors/calls'; import {isCallsEnabled, isCallsRingingEnabled} from 'selectors/calls';
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
const config = getConfig(state); const config = getConfig(state);
@ -24,7 +24,7 @@ function mapStateToProps(state: GlobalState) {
sendPushNotifications, sendPushNotifications,
enableAutoResponder, enableAutoResponder,
isCollapsedThreadsEnabled: isCollapsedThreadsEnabled(state), isCollapsedThreadsEnabled: isCollapsedThreadsEnabled(state),
isCallsEnabled: isCallsEnabled(state, '0.17.0'), isCallsRingingEnabled: isCallsEnabled(state, '0.17.0') && isCallsRingingEnabled(state),
}; };
} }

View File

@ -27,7 +27,7 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
isCollapsedThreadsEnabled: false, isCollapsedThreadsEnabled: false,
sendPushNotifications: false, sendPushNotifications: false,
enableAutoResponder: false, enableAutoResponder: false,
isCallsEnabled: true, isCallsRingingEnabled: true,
}; };
test('should have called handleSubmit', async () => { test('should have called handleSubmit', async () => {

View File

@ -36,7 +36,7 @@ export type Props = {
updateMe: (user: UserProfile) => Promise<ActionResult>; updateMe: (user: UserProfile) => Promise<ActionResult>;
}; };
isCollapsedThreadsEnabled: boolean; isCollapsedThreadsEnabled: boolean;
isCallsEnabled: boolean; isCallsRingingEnabled: boolean;
} }
type State = { type State = {
@ -1058,7 +1058,7 @@ export default class NotificationsTab extends React.PureComponent<Props, State>
callsSelectedSound={this.state.callsNotificationSound || 'default'} callsSelectedSound={this.state.callsNotificationSound || 'default'}
isCollapsedThreadsEnabled={this.props.isCollapsedThreadsEnabled} isCollapsedThreadsEnabled={this.props.isCollapsedThreadsEnabled}
areAllSectionsInactive={this.props.activeSection === ''} areAllSectionsInactive={this.props.activeSection === ''}
isCallsEnabled={this.props.isCallsEnabled} isCallsRingingEnabled={this.props.isCallsRingingEnabled}
/> />
<div className='divider-light'/> <div className='divider-light'/>
<EmailNotificationSetting <EmailNotificationSetting

View File

@ -6,6 +6,12 @@ import {suitePluginIds} from 'utils/constants';
import semver from 'semver'; import semver from 'semver';
export function isCallsEnabled(state: GlobalState, minVersion = '0.4.2') { export function isCallsEnabled(state: GlobalState, minVersion = '0.4.2') {
return state.plugins.plugins[suitePluginIds.calls] && return Boolean(state.plugins.plugins[suitePluginIds.calls] &&
semver.gte(state.plugins.plugins[suitePluginIds.calls].version || '0.0.0', minVersion); semver.gte(state.plugins.plugins[suitePluginIds.calls].version || '0.0.0', minVersion));
}
export function isCallsRingingEnabled(state: GlobalState) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return Boolean(state[`plugins-${suitePluginIds.calls}`]?.callsConfig?.EnableRinging);
} }