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,
callsSelectedSound: 'Dynamic',
callsSound: 'false',
isCallsEnabled: false,
isCallsRingingEnabled: false,
};
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', () => {
const props = {...baseProps, isCallsEnabled: true};
const props = {...baseProps, isCallsRingingEnabled: true};
const wrapper = shallow(
<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', () => {
const props = {...baseProps, isCallsEnabled: true, callsSound: 'true'};
const props = {...baseProps, isCallsRingingEnabled: true, callsSound: 'true'};
const wrapper = shallow(
<DesktopNotificationSettings {...props}/>,
);

View File

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

View File

@ -12,7 +12,7 @@ import {ActionFunc} from 'mattermost-redux/types/actions';
import {GlobalState} from 'types/store';
import UserSettingsNotifications, {Props} from './user_settings_notifications';
import {isCallsEnabled} from 'selectors/calls';
import {isCallsEnabled, isCallsRingingEnabled} from 'selectors/calls';
function mapStateToProps(state: GlobalState) {
const config = getConfig(state);
@ -24,7 +24,7 @@ function mapStateToProps(state: GlobalState) {
sendPushNotifications,
enableAutoResponder,
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,
sendPushNotifications: false,
enableAutoResponder: false,
isCallsEnabled: true,
isCallsRingingEnabled: true,
};
test('should have called handleSubmit', async () => {

View File

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

View File

@ -6,6 +6,12 @@ import {suitePluginIds} from 'utils/constants';
import semver from 'semver';
export function isCallsEnabled(state: GlobalState, minVersion = '0.4.2') {
return state.plugins.plugins[suitePluginIds.calls] &&
semver.gte(state.plugins.plugins[suitePluginIds.calls].version || '0.0.0', minVersion);
return Boolean(state.plugins.plugins[suitePluginIds.calls] &&
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);
}