Browse Source

Fix mod menu showing. Closes #1990

pull/2032/head
Gabe Kangas 4 years ago
parent
commit
a7bbb06ea5
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA
  1. 1
      web/components/chat/ChatContainer/ChatContainer.tsx
  2. 6
      web/components/chat/ChatUserMessage/ChatUserMessage.module.scss
  3. 4
      web/components/chat/ChatUserMessage/ChatUserMessage.tsx
  4. 1
      web/stories/ChatUserMessage.stories.tsx

1
web/components/chat/ChatContainer/ChatContainer.tsx

@ -87,6 +87,7 @@ export default function ChatContainer(props: Props) {
highlightString={usernameToHighlight} // What to highlight in the message highlightString={usernameToHighlight} // What to highlight in the message
sentBySelf={message.user?.id === chatUserId} // The local user sent this message sentBySelf={message.user?.id === chatUserId} // The local user sent this message
sameUserAsLast={isSameUserAsLast(messages, index)} sameUserAsLast={isSameUserAsLast(messages, index)}
isAuthorModerator={(message as ChatMessage).user.scopes.includes('MODERATOR')}
key={message.id} key={message.id}
/> />
); );

6
web/components/chat/ChatUserMessage/ChatUserMessage.module.scss

@ -1,6 +1,7 @@
.root { .root {
* { * {
z-index: 100; } z-index: 100;
}
position: relative; position: relative;
font-size: 0.9rem; font-size: 0.9rem;
padding: 5px 15px 5px 5px; padding: 5px 15px 5px 5px;
@ -10,9 +11,6 @@
align-items: center; align-items: center;
font-family: var(--theme-header-font-family); font-family: var(--theme-header-font-family);
font-weight: bold; font-weight: bold;
.userName {
margin-left: 0.3rem;
}
} }
.message { .message {
color: var(--theme-text-primary); color: var(--theme-text-primary);

4
web/components/chat/ChatUserMessage/ChatUserMessage.tsx

@ -16,6 +16,7 @@ interface Props {
highlightString: string; highlightString: string;
sentBySelf: boolean; sentBySelf: boolean;
sameUserAsLast: boolean; sameUserAsLast: boolean;
isAuthorModerator: boolean;
} }
export default function ChatUserMessage({ export default function ChatUserMessage({
@ -24,6 +25,7 @@ export default function ChatUserMessage({
showModeratorMenu, showModeratorMenu,
sentBySelf, // Move the border to the right and render a background sentBySelf, // Move the border to the right and render a background
sameUserAsLast, sameUserAsLast,
isAuthorModerator,
}: Props) { }: Props) {
const { body, user, timestamp } = message; const { body, user, timestamp } = message;
const { displayName, displayColor } = user; const { displayName, displayColor } = user;
@ -47,8 +49,8 @@ export default function ChatUserMessage({
> >
{!sameUserAsLast && ( {!sameUserAsLast && (
<div className={s.user} style={{ color }}> <div className={s.user} style={{ color }}>
{showModeratorMenu && <ModIcon />}
<span className={s.userName}>{displayName}</span> <span className={s.userName}>{displayName}</span>
{isAuthorModerator && <ModIcon />}
</div> </div>
)} )}
<Highlight search={highlightString}> <Highlight search={highlightString}>

1
web/stories/ChatUserMessage.stories.tsx

@ -85,6 +85,7 @@ export const FromModeratorUser = Template.bind({});
FromModeratorUser.args = { FromModeratorUser.args = {
message: moderatorMessage, message: moderatorMessage,
showModeratorMenu: false, showModeratorMenu: false,
isAuthorModerator: true,
}; };
export const FromAuthenticatedUser = Template.bind({}); export const FromAuthenticatedUser = Template.bind({});

Loading…
Cancel
Save