mattermost-mobile/app/components/channel_actions/set_header_box/set_header.tsx
Elias Nahum 4573732fd2
[Gekidou] channel quick actions (#6288)
* Add hitSlop to navigation header right buttons

* Fix channel_item info muted style

* Fix team switch when global threads

* Wrap WS channel events in try/catch

* Group Box component and Animated Group Box

* SlideUpPanelItem style

* Fix return value of setCurrentTeamAndChannelId

* Add observeChannelSettings and include channel settings in prepareDeleteChannel

* update OPTIONS_HEIGHT reference in find channels quick options

* Fix DM limit in channel list

* Fix category header style and translate default categories

* Add snackbar for unmute/favorite/unfavorite

* Add toggleFavoriteChannel remote action

* Add makeDirectChannelVisible remote action

* Use makeDirectChannelVisible in switchToChannelById and update toggleMuteChannel snackbar

* Add channel actions common components

* Update channel intro to use channel action common components

* Rename ChannelDetails screen to ChannelInfo

* Add channel quick actions

* Update localization strings

* Fix addChannelToDefaultCategory

* Leave channel

* Add localization strings

* Fix snackBar screen event listener

* Feedback review
2022-05-19 14:30:55 -04:00

46 lines
1.4 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useCallback} from 'react';
import {useIntl} from 'react-intl';
import {StyleProp, ViewStyle} from 'react-native';
import OptionBox from '@components/option_box';
import {Screens} from '@constants';
import {dismissBottomSheet, showModal} from '@screens/navigation';
type Props = {
channelId: string;
containerStyle?: StyleProp<ViewStyle>;
isHeaderSet: boolean;
testID?: string;
}
const SetHeaderBox = ({channelId, containerStyle, isHeaderSet, testID}: Props) => {
const intl = useIntl();
const onSetHeader = useCallback(async () => {
await dismissBottomSheet();
const title = intl.formatMessage({id: 'screens.channel_edit_header', defaultMessage: 'Edit Channel Header'});
showModal(Screens.CREATE_OR_EDIT_CHANNEL, title, {channelId, headerOnly: true});
}, [intl, channelId]);
let text;
if (isHeaderSet) {
text = intl.formatMessage({id: 'channel_info.edit_header', defaultMessage: 'Edit Header'});
} else {
text = intl.formatMessage({id: 'channel_info.set_header', defaultMessage: 'Set Header'});
}
return (
<OptionBox
containerStyle={containerStyle}
iconName='pencil-outline'
onPress={onSetHeader}
testID={testID}
text={text}
/>
);
};
export default SetHeaderBox;