-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from nyaruka/notifications
Add notification component
- Loading branch information
Showing
61 changed files
with
338 additions
and
65 deletions.
There are no files selected for viewing
Binary file modified
BIN
-389 Bytes
(96%)
screenshots/truth/compose/chatbox-attachments-counter-and-send-button.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
BIN
-333 Bytes
(96%)
screenshots/truth/compose/chatbox-attachments-counter-no-send-button.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
BIN
-388 Bytes
(95%)
screenshots/truth/compose/chatbox-attachments-no-counter-and-send-button.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
BIN
-302 Bytes
(96%)
screenshots/truth/compose/chatbox-attachments-no-counter-no-send-button.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
BIN
-330 Bytes
(96%)
screenshots/truth/compose/chatbox-counter-and-send-button.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
BIN
-297 Bytes
(96%)
screenshots/truth/compose/chatbox-counter-no-send-button.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
BIN
-293 Bytes
(96%)
screenshots/truth/compose/chatbox-no-counter-and-send-button.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
BIN
-304 Bytes
(95%)
screenshots/truth/compose/chatbox-no-counter-no-send-button.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
BIN
-390 Bytes
(96%)
...ots/truth/compose/chatbox-no-text-attachments-with-all-files-and-click-send.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
BIN
-388 Bytes
(96%)
screenshots/truth/compose/chatbox-no-text-attachments-with-all-files.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
BIN
-388 Bytes
(95%)
screenshots/truth/compose/chatbox-no-text-attachments-with-failure-files.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
BIN
-390 Bytes
(96%)
...truth/compose/chatbox-no-text-attachments-with-success-files-and-click-send.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
BIN
-388 Bytes
(96%)
screenshots/truth/compose/chatbox-no-text-attachments-with-success-files.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
BIN
-292 Bytes
(96%)
screenshots/truth/compose/chatbox-with-text-and-click-send.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
BIN
-292 Bytes
(96%)
screenshots/truth/compose/chatbox-with-text-and-hit-enter.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
BIN
-304 Bytes
(96%)
screenshots/truth/compose/chatbox-with-text-and-spaces.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
BIN
-393 Bytes
(96%)
...enshots/truth/compose/chatbox-with-text-attachments-no-files-and-click-send.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
BIN
-369 Bytes
(96%)
screenshots/truth/compose/chatbox-with-text-attachments-no-files-and-hit-enter.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
BIN
-393 Bytes
(96%)
screenshots/truth/compose/chatbox-with-text-attachments-no-files.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
BIN
-369 Bytes
(96%)
...s/truth/compose/chatbox-with-text-attachments-with-all-files-and-click-send.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
BIN
-369 Bytes
(96%)
...ts/truth/compose/chatbox-with-text-attachments-with-all-files-and-hit-enter.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
BIN
-390 Bytes
(96%)
screenshots/truth/compose/chatbox-with-text-attachments-with-all-files.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
BIN
-394 Bytes
(96%)
screenshots/truth/compose/chatbox-with-text-attachments-with-failure-files.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
BIN
-369 Bytes
(96%)
...uth/compose/chatbox-with-text-attachments-with-success-files-and-click-send.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
BIN
-369 Bytes
(96%)
...ruth/compose/chatbox-with-text-attachments-with-success-files-and-hit-enter.png
Oops, something went wrong.
Binary file modified
BIN
-390 Bytes
(96%)
screenshots/truth/compose/chatbox-with-text-attachments-with-success-files.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
+5.04 KB
(110%)
screenshots/truth/contacts/compose-attachments-no-text-failure.png
Oops, something went wrong.
Binary file modified
BIN
+2.7 KB
(110%)
screenshots/truth/contacts/compose-attachments-no-text-success.png
Oops, something went wrong.
Binary file modified
BIN
+5.04 KB
(110%)
screenshots/truth/contacts/compose-text-and-attachments-failure-attachments.png
Oops, something went wrong.
Binary file modified
BIN
+5.16 KB
(110%)
screenshots/truth/contacts/compose-text-and-attachments-failure-generic.png
Oops, something went wrong.
Binary file modified
BIN
-145 KB
(27%)
...ts/truth/contacts/compose-text-and-attachments-failure-text-and-attachments.png
Oops, something went wrong.
Binary file modified
BIN
-145 KB
(27%)
screenshots/truth/contacts/compose-text-and-attachments-failure-text.png
Oops, something went wrong.
Binary file modified
BIN
+2.7 KB
(110%)
screenshots/truth/contacts/compose-text-and-attachments-success.png
Oops, something went wrong.
Binary file modified
BIN
-145 KB
(27%)
screenshots/truth/contacts/compose-text-no-attachments-failure.png
Oops, something went wrong.
Binary file modified
BIN
+2.7 KB
(110%)
screenshots/truth/contacts/compose-text-no-attachments-success.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
+2 Bytes
(100%)
screenshots/truth/contacts/contact-archived-hide-chatbox.png
Oops, something went wrong.
Binary file modified
BIN
+2 Bytes
(100%)
screenshots/truth/contacts/contact-blocked-hide-chatbox.png
Oops, something went wrong.
Binary file modified
BIN
+2 Bytes
(100%)
screenshots/truth/contacts/contact-stopped-hide-chatbox.png
Oops, something went wrong.
Diff not rendered.
Diff not rendered.
Diff not rendered.
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
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
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
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
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
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,154 @@ | ||
import { css, html, TemplateResult } from 'lit'; | ||
import { TembaList } from './TembaList'; | ||
import { StyleInfo } from 'lit-html/directives/style-map.js'; | ||
import { Options } from '../options/Options'; | ||
import { Icon } from '../vectoricon'; | ||
|
||
interface Notification { | ||
created_on: string; | ||
type: string; | ||
target_url: string; | ||
is_seen: boolean; | ||
export?: { | ||
type: string; | ||
}; | ||
import?: { | ||
type: string; | ||
num_records: number; | ||
}; | ||
incident?: { | ||
type: string; | ||
started_on: string; | ||
ended_on?: string; | ||
}; | ||
} | ||
|
||
const getNotification = (notification: Notification) => { | ||
let icon = null; | ||
let body = null; | ||
let color = '#333'; | ||
|
||
if (notification.type === 'incident:started') { | ||
color = 'tomato'; | ||
if (notification.incident.type === 'org:flagged') { | ||
icon = Icon.incidents; | ||
body = | ||
'Your workspace was flagged, please contact support for assistance.'; | ||
} else if (notification.incident.type === 'org:suspended') { | ||
icon = Icon.incidents; | ||
body = | ||
'Your workspace was suspended, please contact support for assistance.'; | ||
} else if (notification.incident.type === 'channel:disconnected') { | ||
icon = Icon.channel; | ||
body = 'Your android channel is not connected'; | ||
} else if (notification.incident.type === 'webhooks:unhealthy') { | ||
icon = Icon.webhook; | ||
body = 'Your webhook calls are not working properly.'; | ||
} | ||
} else if (notification.type === 'import:finished') { | ||
if (notification.import.type === 'contact') { | ||
icon = Icon.contact_import; | ||
body = `Imported ${notification.import.num_records.toLocaleString()} contacts`; | ||
} | ||
} else if (notification.type === 'export:finished') { | ||
if (notification.export.type === 'contact') { | ||
icon = Icon.contact_export; | ||
body = 'Contacts exported'; | ||
} | ||
} else if (notification.type === 'tickets:activity') { | ||
icon = Icon.tickets; | ||
body = 'New ticket activity'; | ||
} else if (notification.type === 'tickets:opened') { | ||
icon = Icon.tickets; | ||
body = 'New unassigned ticket'; | ||
} | ||
return html`<div | ||
style="color:${color};display:flex;align-items:flex-start;flex-direction:row;font-weight:${notification.is_seen | ||
? 300 | ||
: 400}" | ||
> | ||
${icon | ||
? html`<div style="margin-right:0.6em"> | ||
<temba-icon name="${icon}"></temba-icon> | ||
</div>` | ||
: null} | ||
<div style="display:flex;flex-direction:column"> | ||
<div style="line-height:1.1em">${body}</div> | ||
<temba-date | ||
style="font-size:80%" | ||
value=${notification.created_on} | ||
display="duration" | ||
></temba-date> | ||
</div> | ||
</div>`; | ||
}; | ||
|
||
export class NotificationList extends TembaList { | ||
reverseRefresh = false; | ||
internalFocusDisabled = true; | ||
static get styles() { | ||
return css` | ||
:host { | ||
--option-hover-bg: #f9f9f9; | ||
} | ||
.header { | ||
padding: 0.25em 1em; | ||
background: #f9f9f9; | ||
border-top-left-radius: var(--curvature); | ||
border-top-right-radius: var(--curvature); | ||
display: flex; | ||
color: #999; | ||
border-bottom: 1px solid #f3f3f3; | ||
} | ||
.header temba-icon { | ||
margin-right: 0.35em; | ||
} | ||
.footer { | ||
background: #f9f9f9; | ||
} | ||
.title { | ||
font-weight: normal; | ||
} | ||
`; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this.valueKey = 'target_url'; | ||
this.renderOption = (notification: Notification): TemplateResult => { | ||
const styles: StyleInfo = { | ||
display: 'flex', | ||
alignItems: 'flex-start', | ||
justifyContent: 'flex-start', | ||
}; | ||
|
||
if (!notification.is_seen) { | ||
styles['fontWeight'] = '400'; | ||
} | ||
return html` ${getNotification(notification)} `; | ||
}; | ||
} | ||
|
||
public renderHeader(): TemplateResult { | ||
return html`<div class="header"> | ||
<temba-icon name="notification"></temba-icon> | ||
<div class="title">Notifications</div> | ||
</div>`; | ||
} | ||
|
||
protected handleSelection(event: CustomEvent) { | ||
super.handleSelected(event); | ||
} | ||
|
||
public scrollToTop(): void { | ||
// scroll back to the top | ||
window.setTimeout(() => { | ||
const options = this.shadowRoot.querySelector('temba-options') as Options; | ||
options.scrollToTop(); | ||
}, 1000); | ||
} | ||
} |
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
Oops, something went wrong.