Skip to content

Commit 1c644d8

Browse files
authored
runfix(cells): allow creation of channels with cells enabled [WPB-19376] (#19453)
1 parent 8d09bbe commit 1c644d8

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

src/script/components/Modals/CreateConversation/CreateConversationSteps/Preference.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,36 @@
1717
*
1818
*/
1919

20+
import {container} from 'tsyringe';
21+
2022
import {InfoToggle} from 'Components/toggle/InfoToggle';
23+
import {TeamState} from 'Repositories/team/TeamState';
24+
import {Config} from 'src/script/Config';
25+
import {useKoSubscribableChildren} from 'Util/ComponentUtil';
2126
import {t} from 'Util/LocalizerUtil';
2227

2328
import {useCreateConversationModal} from '../hooks/useCreateConversationModal';
2429
import {ConversationType} from '../types';
2530

2631
export const Preference = () => {
2732
const {
33+
isCellsEnabled,
2834
isGuestsEnabled,
2935
isReadReceiptsEnabled,
36+
setIsCellsEnabled,
3037
setIsGuestsEnabled,
3138
setIsReadReceiptsEnabled,
3239
isServicesEnabled,
3340
setIsServicesEnabled,
3441
conversationType,
3542
} = useCreateConversationModal();
3643

44+
const teamState = container.resolve(TeamState);
45+
46+
const {isCellsEnabled: isCellsEnabledForTeam} = useKoSubscribableChildren(teamState, ['isCellsEnabled']);
47+
const isCellsEnabledForEnvironment = Config.getConfig().FEATURE.ENABLE_CELLS;
48+
const isCellsOptionEnabled = isCellsEnabledForEnvironment && isCellsEnabledForTeam;
49+
3750
return (
3851
<>
3952
<InfoToggle
@@ -69,6 +82,18 @@ export const Preference = () => {
6982
isDisabled={conversationType === ConversationType.Channel}
7083
name={t('readReceiptsToggleName')}
7184
/>
85+
86+
{isCellsOptionEnabled && (
87+
<InfoToggle
88+
className="modal-style"
89+
dataUieName="cells"
90+
isChecked={isCellsEnabled}
91+
setIsChecked={setIsCellsEnabled}
92+
isDisabled={false}
93+
name={t('modalCreateGroupCellsToggleHeading')}
94+
info={t('modalCreateGroupCellsToggleInfo')}
95+
/>
96+
)}
7297
</>
7398
);
7499
};

src/script/components/Modals/CreateConversation/hooks/useCreateConversation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const useCreateConversation = () => {
5757
selectedContacts,
5858
setConversationName,
5959
setConversationCreationStep,
60+
isCellsEnabled,
6061
isReadReceiptsEnabled,
6162
isServicesEnabled,
6263
isGuestsEnabled,
@@ -150,6 +151,7 @@ export const useCreateConversation = () => {
150151
add_permission: moderator === ADD_PERMISSION.ADMINS ? ADD_PERMISSION.ADMINS : ADD_PERMISSION.EVERYONE,
151152
protocol: defaultProtocol,
152153
receipt_mode: isReadReceiptsEnabled ? RECEIPT_MODE.ON : RECEIPT_MODE.OFF,
154+
cells: isCellsEnabled,
153155
group_conv_type:
154156
conversationType === ConversationType.Channel
155157
? GROUP_CONVERSATION_TYPE.CHANNEL

src/script/components/Modals/CreateConversation/hooks/useCreateConversationModal.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type CreateConversationModalState = {
4747
selectedContacts: User[];
4848
historySharingQuantity: number;
4949
historySharingUnit: HistorySharingUnit;
50+
isCellsEnabled: boolean;
5051
isCustomHistoryModalOpen: boolean;
5152
isConfirmDiscardModalOpen: boolean;
5253
isCreateTeamModalOpen: boolean;
@@ -65,6 +66,7 @@ type CreateConversationModalState = {
6566
gotoNextStep: () => void;
6667
gotoPreviousStep: () => void;
6768
setError: (error: string) => void;
69+
setIsCellsEnabled: (isCellsEnabled: boolean) => void;
6870
setIsReadReceiptsEnabled: (isReadReceiptsEnabled: boolean) => void;
6971
setIsGuestsEnabled: (isGuestsEnabled: boolean) => void;
7072
setSelectedContacts: (contacts: User[]) => void;
@@ -92,6 +94,7 @@ const initialState = {
9294
conversationType: ConversationType.Channel,
9395
conversationCreationStep: ConversationCreationStep.ConversationDetails,
9496
error: '',
97+
isCellsEnabled: false,
9598
isReadReceiptsEnabled: false,
9699
isServicesEnabled: true,
97100
isGuestsEnabled: true,
@@ -126,6 +129,7 @@ export const useCreateConversationModal = create<CreateConversationModalState>(s
126129
gotoLastStep: () => set({conversationCreationStep: ConversationCreationStep.ParticipantsSelection}),
127130
gotoPreviousStep: () => set(state => ({...state, conversationCreationStep: state.conversationCreationStep - 1})),
128131
setError: (error: string) => set({error}),
132+
setIsCellsEnabled: (isCellsEnabled: boolean) => set({isCellsEnabled}),
129133
setIsReadReceiptsEnabled: (isReadReceiptsEnabled: boolean) => set({isReadReceiptsEnabled}),
130134
setIsGuestsEnabled: (isGuestsEnabled: boolean) => set({isGuestsEnabled}),
131135
setSelectedContacts: (contacts: User[]) => set({selectedContacts: contacts}),

0 commit comments

Comments
 (0)