Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
[FIX] Issues on Custom Livechat messages (#648)
Browse files Browse the repository at this point in the history
* Couple of fixes wrt custom messages

- Fix offline success messages not working
- Support HTML content on Offline message label

* Support markdown data on Instructions panel

* Update storybook
  • Loading branch information
murtaza98 committed Oct 20, 2021
1 parent 663a574 commit cb0695c
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 13 deletions.
Binary file modified .loki/reference/chrome_Components_Modal_alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Modal_animated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Modal_confirm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Modal_normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Modal_timeout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Routes_Leave_a_message_loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Routes_Leave_a_message_normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions src/routes/LeaveMessage/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { h, Component } from 'preact';
import { Button } from '../../components/Button';
import { ButtonGroup } from '../../components/ButtonGroup';
import { Form, FormField, SelectInput, TextInput, Validations } from '../../components/Form';
import { renderMarkdown } from '../../components/Messages/MessageText/markdown';
import Screen from '../../components/Screen';
import { createClassName, sortArrayByColumn } from '../../components/helpers';
import I18n from '../../i18n';
Expand Down Expand Up @@ -183,10 +184,10 @@ export default class LeaveMessage extends Component {
{...props}
>
<Screen.Content>
<p className={createClassName(styles, 'leave-message__main-message')}>
{hasForm ? message || defaultMessage : unavailableMessage || defaultUnavailableMessage}
</p>

<div className={createClassName(styles, 'leave-message__main-message')}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: renderMarkdown(hasForm ? message || defaultMessage : unavailableMessage || defaultUnavailableMessage) }}
/>
{hasForm && this.renderForm(this.props, this.state)}
</Screen.Content>
<Screen.Footer />
Expand Down
4 changes: 2 additions & 2 deletions src/routes/LeaveMessage/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import LeaveMessage from './component';

export class LeaveMessageContainer extends Component {
handleSubmit = async (fields) => {
const { alerts, dispatch } = this.props;
const { alerts, dispatch, successMessage } = this.props;

await dispatch({ loading: true });
try {
const payload = parseOfflineMessage(fields);
const text = await Livechat.sendOfflineMessage(payload);
await ModalManager.alert({
text,
text: successMessage || text,
});
parentCall('callback', ['offline-form-submit', fields]);
return true;
Expand Down
12 changes: 5 additions & 7 deletions src/routes/LeaveMessage/styles.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
.leave-message__main {
padding: 1rem 1.5rem 0;
p {
margin: 0;
padding: 0;
}

.leave-message__message {
margin: 0 0 1rem;

font-weight: 500;
line-height: 1.5;
.leave-message__main-message {
margin-bottom: 0.5rem;
}

0 comments on commit cb0695c

Please sign in to comment.