From 6752d84b21ff34e4dccaf64f82349f20c7854c99 Mon Sep 17 00:00:00 2001 From: harshil Sharma Date: Fri, 27 Oct 2023 16:32:20 +0530 Subject: [PATCH] Handled case of no common team --- .../channel_name_input.tsx | 9 ++- .../convert_gm_to_channel.tsx | 3 +- .../convert_gm_to_channel_form.tsx | 79 ------------------- .../convert_gm_to_channel/team_selector.tsx | 5 +- assets/base/i18n/en.json | 5 +- 5 files changed, 16 insertions(+), 85 deletions(-) delete mode 100644 app/screens/convert_gm_to_channel/convert_gm_to_channel_form.tsx diff --git a/app/screens/convert_gm_to_channel/channel_name_input.tsx b/app/screens/convert_gm_to_channel/channel_name_input.tsx index 18a067b88..8d4a04bd4 100644 --- a/app/screens/convert_gm_to_channel/channel_name_input.tsx +++ b/app/screens/convert_gm_to_channel/channel_name_input.tsx @@ -10,7 +10,11 @@ import {useTheme} from '@app/context/theme'; import {t} from '@app/i18n'; import {getKeyboardAppearanceFromTheme} from '@app/utils/theme'; -export const ChannelNameInput = () => { +type Props = { + error?: string; +} + +export const ChannelNameInput = ({error}: Props) => { const {formatMessage} = useIntl(); const theme = useTheme(); @@ -29,10 +33,11 @@ export const ChannelNameInput = () => { maxLength={Channel.MAX_CHANNEL_NAME_LENGTH} keyboardAppearance={getKeyboardAppearanceFromTheme(theme)} returnKeyType='next' - showErrorIcon={false} + showErrorIcon={true} spellCheck={false} testID='gonvert_gm_to_channel.channel_display_name.input' theme={theme} + error={error} /> ); }; diff --git a/app/screens/convert_gm_to_channel/convert_gm_to_channel.tsx b/app/screens/convert_gm_to_channel/convert_gm_to_channel.tsx index 3d8680051..184bd6b9a 100644 --- a/app/screens/convert_gm_to_channel/convert_gm_to_channel.tsx +++ b/app/screens/convert_gm_to_channel/convert_gm_to_channel.tsx @@ -7,8 +7,9 @@ import {fetchChannelMemberships, getGroupMessageMembersCommonTeams} from '@actio import {PER_PAGE_DEFAULT} from '@app/client/rest/constants'; import {useServerUrl} from '@app/context/server'; -import {ConvertGMToChannelForm} from './convert_gm_to_channel_form'; +import {ConvertGMToChannelForm} from './convert_gm_to_channel_form/convert_gm_to_channel_form'; import {Loader} from './loader'; +import { logDebug } from '@app/utils/log'; type Props = { channelId: string; diff --git a/app/screens/convert_gm_to_channel/convert_gm_to_channel_form.tsx b/app/screens/convert_gm_to_channel/convert_gm_to_channel_form.tsx deleted file mode 100644 index 2d1c3c3a6..000000000 --- a/app/screens/convert_gm_to_channel/convert_gm_to_channel_form.tsx +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -import React, { useCallback, useEffect, useRef, useState } from 'react'; -import {useIntl} from 'react-intl'; -import {View} from 'react-native'; - -import {useTheme} from '@app/context/theme'; -import {makeStyleSheetFromTheme} from '@app/utils/theme'; -import Button from '@components/button'; - -import {ChannelNameInput} from './channel_name_input'; -import MessageBox from './message_box'; -import {TeamSelector} from './team_selector'; -import { logDebug } from '@app/utils/log'; - -const getStyleFromTheme = makeStyleSheetFromTheme((theme: Theme) => { - return { - container: { - paddingVertical: 24, - paddingHorizontal: 20, - display: 'flex', - flexDirection: 'column', - gap: 24, - }, - }; -}); - -type Props = { - commonTeams: Team[]; - profiles: UserProfile[]; -} - -export const ConvertGMToChannelForm = ({commonTeams, profiles}: Props) => { - const theme = useTheme(); - const styles = getStyleFromTheme(theme); - - const team = useRef(); - - const {formatMessage} = useIntl(); - const confirmButtonText = formatMessage({ - id: 'channel_info.convert_gm_to_channel.button_text', - defaultMessage: 'Convert to Private Channel', - }); - - useEffect(() => { - if (commonTeams.length === 1) { - team.current = commonTeams[0]; - } - }, [commonTeams]); - - const handleOnSelectTeam = useCallback((selectedTeam: Team) => { - team.current = selectedTeam; - }, []); - - return ( - - - { - commonTeams.length > 1 && - - } - -