[MM-64365] omit group constrained channels from the ch. selector for ABAC (#35010)

This commit is contained in:
Ibrahim Serdar Acikgoz
2026-01-27 13:31:58 +01:00
committed by GitHub
parent 4cd9a266f8
commit dfbe788732
3 changed files with 26 additions and 0 deletions
@@ -602,6 +602,7 @@ function PolicyDetails({
groupID={''}
alreadySelected={Object.values(channelChanges.added).map((channel) => channel.id)}
excludeTypes={['O', 'D', 'G']}
excludeGroupConstrained={true}
/>
)}
@@ -14,6 +14,11 @@ describe('components/ChannelSelectorModal', () => {
const channel1: ChannelWithTeamData = Object.assign(TestHelper.getChannelWithTeamDataMock({id: 'channel-1', team_id: 'teamid1'}));
const channel2: ChannelWithTeamData = Object.assign(TestHelper.getChannelWithTeamDataMock({id: 'channel-2', team_id: 'teamid2'}));
const channel3: ChannelWithTeamData = Object.assign(TestHelper.getChannelWithTeamDataMock({id: 'channel-3', team_id: 'teamid1'}));
const groupSyncedChannel: ChannelWithTeamData = Object.assign(TestHelper.getChannelWithTeamDataMock({
id: 'channel-4',
team_id: 'teamid3',
group_constrained: true,
}));
const defaultProps = {
excludeNames: [],
@@ -60,4 +65,20 @@ describe('components/ChannelSelectorModal', () => {
expect(wrapper).toMatchSnapshot();
});
test('excludes group constrained channels when requested', () => {
const wrapper = shallowWithIntl(
<ChannelSelectorModal
{...defaultProps}
excludeGroupConstrained={true}
/>,
);
wrapper.setState({channels: [
channel1,
groupSyncedChannel,
]});
const options = (wrapper.find('MultiSelect').props() as any).options;
expect(options.find((channel: ChannelWithTeamData) => channel.id === groupSyncedChannel.id)).toBeUndefined();
});
});
@@ -31,6 +31,7 @@ type Props = {
alreadySelected?: string[];
excludePolicyConstrained?: boolean;
excludeAccessControlPolicyEnforced?: boolean;
excludeGroupConstrained?: boolean;
excludeTeamIds?: string[];
excludeTypes?: string[];
}
@@ -220,6 +221,9 @@ export class ChannelSelectorModal extends React.PureComponent<Props, State> {
if (this.props.excludePolicyConstrained) {
options = options.filter((channel) => channel.policy_id === null);
}
if (this.props.excludeGroupConstrained) {
options = options.filter((channel) => !channel.group_constrained);
}
if (this.props.excludeTeamIds) {
options = options.filter((channel) => this.props.excludeTeamIds?.indexOf(channel.team_id) === -1);
}