mattermost-mobile/app/screens/thread_options/thread_options.tsx
Avinash Lingaloo e443a69265
MM-45344 Gekidou Remove <MenuItem/> (#6522)
* added MENU_ITEM_HEIGHT to constant/view

* fix user presence and your profile

* added MENU_ITEM_HEIGHT to constant/view

* fix user presence and your profile

* UI Polish - Custom Status

* UI Polish - Settings

* UI Polish - logout

* refactored styles

* removed 'throws DataOperatorException' from './database/`

* fix for copy link option

* fix autoresponder

1.  user should be allowed to enter paragraph

2. the OOO was not immediately being updated on the notification main screen.  The fix is to cal fetchStatusInBatch after the updateMe operation

* About Screen - code clean up

* removed MenuItem component from common_post_options

* removed MenuItem from Settings

* refactored show_more and recent_item

* removed menu_item component

* Update setting_container.tsx

* PR review correction

* Update setting_container.tsx

* Update recent_item.tsx
2022-08-04 12:26:27 +04:00

133 lines
3.8 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {useManagedConfig} from '@mattermost/react-native-emm';
import React from 'react';
import {View} from 'react-native';
import {CopyPermalinkOption, FollowThreadOption, ReplyOption, SaveOption} from '@components/common_post_options';
import FormattedText from '@components/formatted_text';
import {ITEM_HEIGHT} from '@components/option_item';
import {Screens} from '@constants';
import {useTheme} from '@context/theme';
import {useIsTablet} from '@hooks/device';
import useNavButtonPressed from '@hooks/navigation_button_pressed';
import BottomSheet from '@screens/bottom_sheet';
import {dismissModal} from '@screens/navigation';
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
import {typography} from '@utils/typography';
import MarkAsUnreadOption from './options/mark_as_unread_option';
import OpenInChannelOption from './options/open_in_channel_option';
import type PostModel from '@typings/database/models/servers/post';
import type TeamModel from '@typings/database/models/servers/team';
import type ThreadModel from '@typings/database/models/servers/thread';
type ThreadOptionsProps = {
componentId: string;
isSaved: boolean;
post: PostModel;
team: TeamModel;
thread: ThreadModel;
};
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
return {
listHeader: {
marginBottom: 12,
},
listHeaderText: {
color: changeOpacity(theme.centerChannelColor, 0.56),
textTransform: 'uppercase',
...typography('Body', 75, 'SemiBold'),
},
};
});
const THREAD_OPTIONS_BUTTON = 'close-thread-options';
const ThreadOptions = ({
componentId,
isSaved,
post,
team,
thread,
}: ThreadOptionsProps) => {
const theme = useTheme();
const isTablet = useIsTablet();
const style = getStyleSheet(theme);
const close = () => {
dismissModal({componentId});
};
useNavButtonPressed(THREAD_OPTIONS_BUTTON, componentId, close, []);
const options = [
<ReplyOption
key='reply'
location={Screens.THREAD_OPTIONS}
post={post}
/>,
<FollowThreadOption
key='unfollow'
thread={thread}
/>,
<OpenInChannelOption
key='open-in-channel'
threadId={thread.id}
/>,
<MarkAsUnreadOption
key='mark-as-unread'
teamId={team.id}
thread={thread}
/>,
<SaveOption
key='save'
isSaved={isSaved}
postId={thread.id}
/>,
];
const managedConfig = useManagedConfig<ManagedConfig>();
const canCopyLink = managedConfig?.copyAndPasteProtection !== 'true';
if (canCopyLink) {
options.push(
<CopyPermalinkOption
key='copy-link'
post={post}
sourceScreen={Screens.THREAD_OPTIONS}
/>,
);
}
const renderContent = () => (
<>
{!isTablet && (
<View style={style.listHeader}>
<FormattedText
id='global_threads.options.title'
defaultMessage={'Thread actions'}
style={style.listHeaderText}
/>
</View>
)}
{options}
</>
);
return (
<BottomSheet
renderContent={renderContent}
closeButtonId={THREAD_OPTIONS_BUTTON}
componentId={Screens.THREAD_OPTIONS}
initialSnapIndex={0}
snapPoints={[((options.length + 2) * ITEM_HEIGHT), 10]}
testID='thread_options'
/>
);
};
export default ThreadOptions;