Skip to content

Commit

Permalink
MM-35935 Respect disabled for bool settings (mattermost#5405)
Browse files Browse the repository at this point in the history
* Respect disabled for bool settings

* Fix test

* Mirate to functional component

* Fix test
  • Loading branch information
larkox authored Jul 9, 2021
1 parent f0c9aa7 commit 1b5d767
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 222 deletions.
7 changes: 4 additions & 3 deletions app/components/autocomplete_selector/autocomplete_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,17 @@ export default class AutocompleteSelector extends PureComponent {
);
}

const noediting = disabled ? style.disabled : null;

return (
<View style={style.container}>
{labelContent}
<TouchableWithFeedback
style={disabled ? style.disabled : null}
onPress={this.goToSelectorScreen}
type={'opacity'}
disabled={disabled}
>
<View style={inputStyle}>
<View style={[inputStyle, noediting]}>
<Text
style={selectedStyle}
numberOfLines={1}
Expand Down Expand Up @@ -302,7 +303,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme) => {
fontSize: 14,
},
disabled: {
opacity: 0.5,
backgroundColor: changeOpacity(theme.centerChannelColor, 0.1),
},
};
});
197 changes: 0 additions & 197 deletions app/components/widgets/settings/bool_setting.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Switch} from 'react-native';
import {shallow} from 'enzyme';

import Preferences from '@mm-redux/constants/preferences';

import BoolSetting from './bool_setting.js';
import BoolSetting from './bool_setting';

describe('components/widgets/settings/TextSetting', () => {
const theme = Preferences.THEMES.default;
Expand All @@ -23,11 +24,11 @@ describe('components/widgets/settings/TextSetting', () => {
/>,
);

wrapper.instance().handleChange(false);
wrapper.find<Switch>(Switch).simulate('valueChange', false);
expect(onChange).toHaveBeenCalledTimes(1);
expect(onChange).toHaveBeenCalledWith('elementid', false);

wrapper.instance().handleChange(true);
wrapper.find<Switch>(Switch).simulate('valueChange', true);
expect(onChange).toHaveBeenCalledTimes(2);
expect(onChange).toHaveBeenCalledWith('elementid', true);
});
Expand Down
Loading

0 comments on commit 1b5d767

Please sign in to comment.