2021-03-09 19:16:56 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-01-29 21:19:24 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import { Avatar } from '../../Avatar';
|
|
|
|
import { LocalizerType } from '../../../types/Util';
|
|
|
|
import { ConversationType } from '../../../state/ducks/conversations';
|
|
|
|
import { bemGenerator } from './util';
|
|
|
|
|
|
|
|
export type Props = {
|
2021-03-09 19:16:56 +00:00
|
|
|
canEdit: boolean;
|
2021-01-29 21:19:24 +00:00
|
|
|
conversation: ConversationType;
|
2021-03-09 19:16:56 +00:00
|
|
|
i18n: LocalizerType;
|
|
|
|
startEditing: () => void;
|
2021-01-29 21:19:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const bem = bemGenerator('module-conversation-details-header');
|
|
|
|
|
|
|
|
export const ConversationDetailsHeader: React.ComponentType<Props> = ({
|
2021-03-09 19:16:56 +00:00
|
|
|
canEdit,
|
2021-01-29 21:19:24 +00:00
|
|
|
conversation,
|
2021-03-09 19:16:56 +00:00
|
|
|
i18n,
|
|
|
|
startEditing,
|
2021-01-29 21:19:24 +00:00
|
|
|
}) => {
|
|
|
|
const memberships = conversation.memberships || [];
|
|
|
|
|
2021-03-09 19:16:56 +00:00
|
|
|
const contents = (
|
|
|
|
<>
|
2021-01-29 21:19:24 +00:00
|
|
|
<Avatar
|
|
|
|
conversationType="group"
|
|
|
|
i18n={i18n}
|
|
|
|
size={80}
|
|
|
|
{...conversation}
|
|
|
|
/>
|
|
|
|
<div>
|
|
|
|
<div className={bem('title')}>{conversation.title}</div>
|
|
|
|
<div className={bem('subtitle')}>
|
|
|
|
{i18n('ConversationDetailsHeader--members', [
|
|
|
|
memberships.length.toString(),
|
|
|
|
])}
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-03-09 19:16:56 +00:00
|
|
|
</>
|
2021-01-29 21:19:24 +00:00
|
|
|
);
|
2021-03-09 19:16:56 +00:00
|
|
|
|
|
|
|
if (canEdit) {
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
onClick={startEditing}
|
|
|
|
className={bem('root', 'editable')}
|
|
|
|
>
|
|
|
|
{contents}
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <div className={bem('root')}>{contents}</div>;
|
2021-01-29 21:19:24 +00:00
|
|
|
};
|