Skip to content

Commit 2195bc0

Browse files
author
Sravan S
authored
feat: add prop to disable Channel & Thread inputs (#447)
fixes: https://sendbird.atlassian.net/browse/UIKIT-3422
1 parent c0b5b82 commit 2195bc0

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

scripts/index_d_ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ declare module "SendbirdUIKitGlobal" {
599599
export type MessageInputProps = {
600600
// value is removed when channelURL changes
601601
value?: string;
602+
disabled?: boolean;
602603
ref?: React.MutableRefObject<any>;
603604
renderFileUploadIcon?: () => React.ReactElement;
604605
renderVoiceMessageIcon?: () => React.ReactElement;
@@ -1060,6 +1061,7 @@ declare module "SendbirdUIKitGlobal" {
10601061

10611062
export interface ThreadMessageInputProps {
10621063
className?: string;
1064+
disabled?: boolean;
10631065
renderFileUploadIcon?: () => React.ReactElement;
10641066
renderVoiceMessageIcon?: () => React.ReactElement;
10651067
renderSendMessageIcon?: () => React.ReactElement;

src/smart-components/Channel/components/MessageInput/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import VoiceMessageInputWrapper from './VoiceMessageInputWrapper';
1414

1515
export type MessageInputWrapperProps = {
1616
value?: string;
17+
disabled?: boolean;
1718
renderFileUploadIcon?: () => React.ReactElement;
1819
renderVoiceMessageIcon?: () => React.ReactElement;
1920
renderSendMessageIcon?: () => React.ReactElement;
@@ -29,6 +30,7 @@ const MessageInputWrapper = (
2930
renderVoiceMessageIcon,
3031
renderSendMessageIcon,
3132
} = props;
33+
const propDisabled = props.disabled;
3234
const {
3335
currentGroupChannel,
3436
initialized,
@@ -62,7 +64,8 @@ const MessageInputWrapper = (
6264
const [ableMention, setAbleMention] = useState(true);
6365
const [messageInputEvent, setMessageInputEvent] = useState(null);
6466
const [showVoiceMessageInput, setShowVoiceMessageInput] = useState(false);
65-
const disabled = !initialized
67+
const disabled = propDisabled
68+
|| !initialized
6669
|| utils.isDisabledBecauseFrozen(channel)
6770
|| utils.isDisabledBecauseMuted(channel)
6871
|| !isOnline;

src/smart-components/Thread/components/ThreadMessageInput/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Role } from '../../../../lib/types';
1414

1515
export interface ThreadMessageInputProps {
1616
className?: string;
17+
disabled?: boolean;
1718
renderFileUploadIcon?: () => React.ReactElement;
1819
renderVoiceMessageIcon?: () => React.ReactElement;
1920
renderSendMessageIcon?: () => React.ReactElement;
@@ -29,6 +30,7 @@ const ThreadMessageInput = (
2930
renderVoiceMessageIcon,
3031
renderSendMessageIcon,
3132
} = props;
33+
const propsDisabled = props.disabled;
3234
const { config } = useSendbirdStateContext();
3335
const { stringSet } = useLocalization();
3436
const {
@@ -49,7 +51,9 @@ const ThreadMessageInput = (
4951
} = useThreadContext();
5052
const messageInputRef = useRef();
5153

52-
const disabled = isMuted || (!(currentChannel?.myRole === Role.OPERATOR) && isChannelFrozen) || parentMessage === null;
54+
const disabled = propsDisabled
55+
|| isMuted
56+
|| (!(currentChannel?.myRole === Role.OPERATOR) && isChannelFrozen) || parentMessage === null;
5357

5458
// mention
5559
const [mentionNickname, setMentionNickname] = useState('');

0 commit comments

Comments
 (0)