diff --git a/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx b/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx index 6c3979c321..fb042d5149 100644 --- a/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx +++ b/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx @@ -108,7 +108,10 @@ const AdvancedTextEditor = ({ const isRHS = Boolean(postId && !isThreadView); const currentUserId = useSelector(getCurrentUserId); - const channelDisplayName = useSelector((state: GlobalState) => getChannelSelector(state, channelId)?.display_name || ''); + const channel = useSelector((state: GlobalState) => getChannelSelector(state, channelId)); + const channelDisplayName = channel?.display_name || ''; + const channelType = channel?.type || ''; + const isChannelShared = channel?.shared; const draftFromStore = useSelector((state: GlobalState) => getDraftSelector(state, channelId, postId)); const badConnection = useSelector((state: GlobalState) => connectionErrorCount(state) > 1); const maxPostSize = useSelector((state: GlobalState) => parseInt(getConfig(state).MaxPostSize || '', 10) || Constants.DEFAULT_CHARACTER_LIMIT); @@ -165,6 +168,8 @@ const AdvancedTextEditor = ({ const readOnlyChannel = !canPost; const hasDraftMessage = Boolean(draft.message); + const isDMOrGMRemote = isChannelShared && (channelType === Constants.DM_CHANNEL || channelType === Constants.GM_CHANNEL); + const isDisabled = Boolean(readOnlyChannel || isDMOrGMRemote); const handleShowPreview = useCallback(() => { setShowPreview((prev) => !prev); @@ -241,12 +246,12 @@ const AdvancedTextEditor = ({ useOrientationHandler(textboxRef, postId); const pluginItems = usePluginItems(draft, textboxRef, handleDraftChange); const focusTextbox = useTextboxFocus(textboxRef, channelId, isRHS, canPost); - const [attachmentPreview, fileUploadJSX] = useUploadFiles(draft, postId, channelId, isThreadView, storedDrafts, readOnlyChannel, textboxRef, handleDraftChange, focusTextbox, setServerError); + const [attachmentPreview, fileUploadJSX] = useUploadFiles(draft, postId, channelId, isThreadView, storedDrafts, isDisabled, textboxRef, handleDraftChange, focusTextbox, setServerError); const { emojiPicker, enableEmojiPicker, toggleEmojiPicker, - } = useEmojiPicker(readOnlyChannel, draft, caretPosition, setCaretPosition, handleDraftChange, showPreview, focusTextbox); + } = useEmojiPicker(isDisabled, draft, caretPosition, setCaretPosition, handleDraftChange, showPreview, focusTextbox); const { labels, additionalControl: priorityAdditionalControl, @@ -446,7 +451,7 @@ const AdvancedTextEditor = ({ }; }, [channelId, postId]); - const disableSendButton = Boolean(readOnlyChannel || (!draft.message.trim().length && !draft.fileInfos.length)) || !isValidPersistentNotifications; + const disableSendButton = Boolean(isDisabled || (!draft.message.trim().length && !draft.fileInfos.length)) || !isValidPersistentNotifications; const sendButton = readOnlyChannel ? null : (
{attachmentPreview} - {!readOnlyChannel && (showFormattingBar || showPreview) && ( + {!isDisabled && (showFormattingBar || showPreview) && ( ) : formattingBar} - {!readOnlyChannel && ( + {!isDisabled && ( void, @@ -116,7 +116,7 @@ const useEmojiPicker = ( let emojiPicker = null; - if (enableEmojiPicker && !readOnlyChannel) { + if (enableEmojiPicker && !isDisabled) { emojiPicker = ( <> >, - readOnlyChannel: boolean, + isDisabled: boolean, textboxRef: React.RefObject, handleDraftChange: (draft: PostDraft, options?: {instant?: boolean; show?: boolean}) => void, focusTextbox: (forceFocust?: boolean) => void, @@ -141,7 +141,7 @@ const useUploadFiles = ( }, [draft, fileUploadRef, handleDraftChange, handleUploadError, handleFileUploadChange]); let attachmentPreview = null; - if (!readOnlyChannel && (draft.fileInfos.length > 0 || draft.uploadsInProgress.length > 0)) { + if (!isDisabled && (draft.fileInfos.length > 0 || draft.uploadsInProgress.length > 0)) { attachmentPreview = ( upgrade to a paid plan.", "create_post.file_limit_sticky_banner.messageTitle": "Your free plan is limited to {storageGB} of files.",