-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: system message component not aware of any type * test: update tests * refactor: inline export * test: add case for extra info via children prop * refactor: render message based on type inside system message omponent * refactor: shorten import * test: update tests
- Loading branch information
1 parent
4a0aa5d
commit ae3d5d8
Showing
6 changed files
with
130 additions
and
96 deletions.
There are no files selected for viewing
67 changes: 0 additions & 67 deletions
67
src/script/components/MessagesList/Message/SystemMessage.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/script/components/MessagesList/Message/SystemMessage/SystemMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2021 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import {Icon} from 'Components/Icon'; | ||
import {MessageTimerUpdateMessage} from 'src/script/entity/message/MessageTimerUpdateMessage'; | ||
import {ReceiptModeUpdateMessage} from 'src/script/entity/message/ReceiptModeUpdateMessage'; | ||
import {RenameMessage} from 'src/script/entity/message/RenameMessage'; | ||
import {SystemMessage as SystemMessageEntity} from 'src/script/entity/message/SystemMessage'; | ||
|
||
import {SystemMessageBase} from './SystemMessageBase'; | ||
|
||
export interface SystemMessageProps { | ||
message: SystemMessageEntity; | ||
} | ||
|
||
export const SystemMessage: React.FC<SystemMessageProps> = ({message}) => { | ||
if (message instanceof RenameMessage) { | ||
return ( | ||
<> | ||
<SystemMessageBase message={message} isSenderNameVisible icon={<Icon.Edit />} /> | ||
<div className="message-body font-weight-bold">{message.name}</div> | ||
</> | ||
); | ||
} | ||
|
||
if (message instanceof MessageTimerUpdateMessage) { | ||
return <SystemMessageBase message={message} isSenderNameVisible icon={<Icon.Timer />} />; | ||
} | ||
|
||
if (message instanceof ReceiptModeUpdateMessage) { | ||
return <SystemMessageBase message={message} isSenderNameVisible icon={<Icon.Read />} />; | ||
} | ||
|
||
return <SystemMessageBase message={message} />; | ||
}; |
54 changes: 54 additions & 0 deletions
54
src/script/components/MessagesList/Message/SystemMessage/SystemMessageBase.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
import React, {ReactNode} from 'react'; | ||
|
||
import {SystemMessage as SystemMessageEntity} from 'src/script/entity/message/SystemMessage'; | ||
import {useKoSubscribableChildren} from 'Util/ComponentUtil'; | ||
|
||
import {MessageTime} from '../MessageTime'; | ||
|
||
export interface SystemMessageProps { | ||
message: SystemMessageEntity; | ||
isSenderNameVisible?: boolean; | ||
icon?: ReactNode; | ||
} | ||
|
||
export const SystemMessageBase: React.FC<SystemMessageProps> = ({message, isSenderNameVisible = false, icon}) => { | ||
const {unsafeSenderName, timestamp, caption} = useKoSubscribableChildren(message, [ | ||
'unsafeSenderName', | ||
'timestamp', | ||
'caption', | ||
]); | ||
|
||
return ( | ||
<div className="message-header" data-uie-name="element-message-system"> | ||
{icon && <div className="message-header-icon message-header-icon--svg text-foreground">{icon}</div>} | ||
<p className="message-header-label"> | ||
<span className="message-header-label__multiline"> | ||
{isSenderNameVisible && <span className="message-header-sender-name">{unsafeSenderName}</span>} | ||
<span className="ellipsis">{caption}</span> | ||
</span> | ||
</p> | ||
<div className="message-body-actions"> | ||
<MessageTime timestamp={timestamp} data-uie-uid={message.id} data-uie-name="item-message-call-timestamp" /> | ||
</div> | ||
</div> | ||
); | ||
}; |
20 changes: 20 additions & 0 deletions
20
src/script/components/MessagesList/Message/SystemMessage/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
export * from './SystemMessage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters