* Add autotranslations * Develop latest changes and missing features * i18n-extract * Fix tests and update api behavior * Fix minor bugs * adjustments to shimmer animation, showtranslation modal style * Update post.tsx * Update show_translation.tsx * adjust sizing and opacity of translate icon * Add channel header translated icon * Disable auto translation item if it is not a supported language * Move channel info to the top * Update edit channel to channel info * Fix align of option items * Fix i18n * Add detox related changes for channel settings changes * Add tests * Address changes around the my channel column change * Address feedback * Fix test * Fix bad import * Fix set my channel autotranslation * Fix test * Address feedback * Add missing files from last commit * Remove unneeded change --------- Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
import {Screens} from '@constants';
|
|
import {SNACK_BAR_TYPE, type SnackBarConfig} from '@constants/snack_bar';
|
|
import {showOverlay} from '@screens/navigation';
|
|
|
|
import type {AvailableScreens} from '@typings/screens/navigation';
|
|
import type {PrimitiveType} from 'react-intl';
|
|
|
|
export type ShowSnackBarArgs = {
|
|
barType: keyof typeof SNACK_BAR_TYPE;
|
|
onAction?: () => void;
|
|
sourceScreen?: AvailableScreens;
|
|
messageValues?: Record<string, PrimitiveType>;
|
|
customMessage?: string;
|
|
type?: SnackBarConfig['type'];
|
|
actionText?: string;
|
|
};
|
|
|
|
export const showSnackBar = (passProps: ShowSnackBarArgs) => {
|
|
const screen = Screens.SNACK_BAR;
|
|
showOverlay(screen, passProps);
|
|
};
|
|
|
|
export const showMuteChannelSnackbar = (muted: boolean, onAction: () => void) => {
|
|
return showSnackBar({
|
|
onAction,
|
|
barType: muted ? SNACK_BAR_TYPE.MUTE_CHANNEL : SNACK_BAR_TYPE.UNMUTE_CHANNEL,
|
|
});
|
|
};
|
|
|
|
export const showFavoriteChannelSnackbar = (favorited: boolean, onAction: () => void) => {
|
|
return showSnackBar({
|
|
onAction,
|
|
barType: favorited ? SNACK_BAR_TYPE.FAVORITE_CHANNEL : SNACK_BAR_TYPE.UNFAVORITE_CHANNEL,
|
|
});
|
|
};
|
|
|
|
export const showAddChannelMembersSnackbar = (count: number) => {
|
|
return showSnackBar({
|
|
barType: SNACK_BAR_TYPE.ADD_CHANNEL_MEMBERS,
|
|
sourceScreen: Screens.CHANNEL_ADD_MEMBERS,
|
|
messageValues: {numMembers: count},
|
|
});
|
|
};
|
|
|
|
export const showRemoveChannelUserSnackbar = () => {
|
|
return showSnackBar({
|
|
barType: SNACK_BAR_TYPE.REMOVE_CHANNEL_USER,
|
|
sourceScreen: Screens.MANAGE_CHANNEL_MEMBERS,
|
|
});
|
|
};
|
|
|
|
export const showThreadFollowingSnackbar = (following: boolean, onAction: () => void) => {
|
|
return showSnackBar({
|
|
onAction,
|
|
barType: following ? SNACK_BAR_TYPE.FOLLOW_THREAD : SNACK_BAR_TYPE.UNFOLLOW_THREAD,
|
|
});
|
|
};
|
|
|
|
export const showScheduledPostCreationErrorSnackbar = (errorMessage: string) => {
|
|
return showSnackBar({
|
|
barType: SNACK_BAR_TYPE.SCHEDULED_POST_CREATION_ERROR,
|
|
customMessage: errorMessage,
|
|
type: 'error',
|
|
});
|
|
};
|
|
|
|
export const showPlaybookErrorSnackbar = () => {
|
|
return showSnackBar({
|
|
barType: SNACK_BAR_TYPE.PLAYBOOK_ERROR,
|
|
});
|
|
};
|
|
|
|
export const showEnableTranslationSnackbar = (onAction: () => void, location: AvailableScreens) => {
|
|
return showSnackBar({
|
|
onAction,
|
|
barType: SNACK_BAR_TYPE.ENABLE_TRANSLATION,
|
|
sourceScreen: location,
|
|
actionText: 'Enable',
|
|
});
|
|
};
|
|
|
|
export const showBoRPostErrorSnackbar = (message?: string) => {
|
|
return showSnackBar({
|
|
barType: SNACK_BAR_TYPE.BOR_POST_EXPIRED,
|
|
customMessage: message,
|
|
});
|
|
};
|