Skip to content

Commit

Permalink
Merge pull request #806 from glific/feature/block-simulator
Browse files Browse the repository at this point in the history
Removed block and view contact info option for simulator
  • Loading branch information
DigneshGujarathi authored Dec 14, 2020
2 parents 21ef05a + ea690a3 commit 14759ce
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/assets/images/icons/BlockDisabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/assets/images/icons/Contact/ProfileDisabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/containers/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export const Chat: React.SFC<ChatProps> = ({ contactId }) => {
chatInterface = (
<>
<div className={styles.ChatMessages}>
<ChatMessages contactId={showSimulator && simulatorId ? simulatorId : contactId} />
<ChatMessages
contactId={showSimulator && simulatorId ? simulatorId : contactId}
simulatorId={simulatorId}
/>
</div>
<div className={styles.ChatConversations}>
<ChatConversations
Expand Down
4 changes: 3 additions & 1 deletion src/containers/Chat/ChatMessages/ChatMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import { getCachedConverations, updateConversationsCache } from '../../../servic

export interface ChatMessagesProps {
contactId: number | string;
simulatorId?: string | null;
}

export const ChatMessages: React.SFC<ChatMessagesProps> = ({ contactId }) => {
export const ChatMessages: React.SFC<ChatMessagesProps> = ({ contactId, simulatorId }) => {
// create an instance of apolloclient
const client = useApolloClient();

Expand Down Expand Up @@ -378,6 +379,7 @@ export const ChatMessages: React.SFC<ChatMessagesProps> = ({ contactId }) => {
? conversationInfo.contact.name
: conversationInfo.contact.maskedPhone
}
isSimulator={contactId === simulatorId}
contactId={contactId.toString()}
lastMessageTime={conversationInfo.contact.lastMessageAt}
contactStatus={conversationInfo.contact.status}
Expand Down
41 changes: 33 additions & 8 deletions src/containers/Chat/ChatMessages/ContactBar/ContactBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import {
Button,
ClickAwayListener,
} from '@material-ui/core';
import { Link } from 'react-router-dom';
import { useHistory } from 'react-router-dom';
import { useMutation, useLazyQuery, useApolloClient } from '@apollo/client';

import styles from './ContactBar.module.css';
import { SearchDialogBox } from '../../../../components/UI/SearchDialogBox/SearchDialogBox';
import { ReactComponent as DropdownIcon } from '../../../../assets/images/icons/BrownDropdown.svg';
import { ReactComponent as AddContactIcon } from '../../../../assets/images/icons/Contact/Light.svg';
import { ReactComponent as BlockIcon } from '../../../../assets/images/icons/Block.svg';
import { ReactComponent as BlockDisabledIcon } from '../../../../assets/images/icons/BlockDisabled.svg';
import { ReactComponent as ProfileIcon } from '../../../../assets/images/icons/Contact/Profile.svg';
import { ReactComponent as ProfileDisabledIcon } from '../../../../assets/images/icons/Contact/ProfileDisabled.svg';
import { ReactComponent as FlowIcon } from '../../../../assets/images/icons/Flow/Dark.svg';
import { ReactComponent as FlowUnselectedIcon } from '../../../../assets/images/icons/Flow/Unselected.svg';
import { ReactComponent as ClearConversation } from '../../../../assets/images/icons/Chat/ClearConversation.svg';
Expand Down Expand Up @@ -47,13 +49,22 @@ export interface ContactBarProps {
contactStatus: string;
contactBspStatus: string;
handleAction?: any;
isSimulator?: boolean;
}

export const ContactBar: React.SFC<ContactBarProps> = (props) => {
const { contactId, contactBspStatus, lastMessageTime, contactStatus, contactName } = props;
const {
contactId,
contactBspStatus,
lastMessageTime,
contactStatus,
contactName,
isSimulator,
} = props;
const client = useApolloClient();
const [anchorEl, setAnchorEl] = useState(null);
const open = Boolean(anchorEl);
const history = useHistory();
const [showGroupDialog, setShowGroupDialog] = useState(false);
const [showFlowDialog, setShowFlowDialog] = useState(false);
const [showBlockDialog, setShowBlockDialog] = useState(false);
Expand Down Expand Up @@ -312,12 +323,21 @@ export const ContactBar: React.SFC<ContactBarProps> = (props) => {
{({ TransitionProps }) => (
<Fade {...TransitionProps} timeout={350}>
<Paper elevation={3} className={styles.Container}>
<Link to={`/contact-profile/${props.contactId}`} className={styles.Link}>
<Button className={styles.ListButtonPrimary}>
<Button
className={styles.ListButtonPrimary}
disabled={isSimulator}
onClick={() => {
history.push(`/contact-profile/${props.contactId}`);
}}
>
{isSimulator ? (
<ProfileDisabledIcon className={styles.Icon} />
) : (
<ProfileIcon className={styles.Icon} />
View contact profile
</Button>
</Link>
)}
View contact profile
</Button>

{flowButton}
<Button
data-testid="groupButton"
Expand All @@ -342,9 +362,14 @@ export const ContactBar: React.SFC<ContactBarProps> = (props) => {
data-testid="blockButton"
className={styles.ListButtonDanger}
color="secondary"
disabled={isSimulator}
onClick={() => setShowBlockDialog(true)}
>
<BlockIcon className={styles.Icon} />
{isSimulator ? (
<BlockDisabledIcon className={styles.Icon} />
) : (
<BlockIcon className={styles.Icon} />
)}
Block Contact
</Button>
</Paper>
Expand Down

0 comments on commit 14759ce

Please sign in to comment.