Skip to content

Commit

Permalink
Add initial project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenmaguire committed Nov 9, 2016
0 parents commit e7370cf
Show file tree
Hide file tree
Showing 17 changed files with 489 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/tmp
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog

All Notable changes to `mandrill-zendesk` will be documented in this file

## 1.0.0 - 2016-11-09

### Added
- Initial project structure

### Deprecated
- Nothing

### Fixed
- Nothing

### Removed
- Nothing

### Security
- Nothing
54 changes: 54 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Contributing

Contributions are **welcome** and will be fully **credited**.

We accept contributions via Pull Requests on [Github](https://github.com/delivered/mandrill-zendesk).

## Local Development

Recommended reading:

* [Official Documentation](https://developer.zendesk.com/apps/docs/agent/introduction)
* Pay close attention the the [supported libraries](https://developer.zendesk.com/apps/docs/agent/supported_libraries) and their (older) versions as they drive the user interface.
* [Bootstrap v2.3.2](http://getbootstrap.com/2.3.2/components.html)
* [Helpful Series of Articles](https://support.zendesk.com/hc/en-us/articles/203691256)

Getting started:

* Install the zat gem - `$ gem install zendesk_apps_tools`
* Run the server - `$ zat server`
* Preview the app - bring up zendesk, find a user or ticket, and add `zat=true` query string parameters to the url, like this:
* https://{your-subdomain}.zendesk.com/agent/users/{user-id}/requested_tickets?zat=true
* NOTE: if a shield icon appears in the browser, click on on and allow the script to run
* reload the app to make changes active

Packaging and deploying:

* Validate the app - `$ zat validate`
* Package the app - `$ zat package`
* [Install the app](https://github.com/delivered/mandrill-zendesk#installation)

Please enter issues as you see fit.

## Pull Requests

- **Document any change in behaviour** - Make sure the README, CHANGELOG, and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow SemVer. Randomly breaking public APIs is not an option.

- **Create topic branches** - Don't ask us to pull from your master branch.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.

- **Ensure no coding standards violations** - Please run PHP Code Sniffer using the PSR-2 standard (see below) before submitting your pull request. A violation will cause the build to fail, so please make sure there are no violations. We can't accept a patch if the build fails.


## Validating your work

``` bash
$ zat validate
```

**Happy coding**!
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Steven Maguire

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Zendesk App for Mandrill

[![Latest Version](https://img.shields.io/github/release/delivered/mandrill-zendesk.svg?style=flat-square)](https://github.com/delivered/mandrill-zendesk/releases)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)

Access your Mandrill message data from within Zendesk.

## Installation

1. [Download the latest app package](https://github.com/delivered/mandrill-zendesk/releases/latest) - File will be available in the "Downloads" section and look something like `app-YYYYMMDDHHMMSS.zip`.
2. Browse to your Zendesk Apps Management Screen (https://{your-subdomain}.zendesk.com/agent/admin/apps/manage)
3. Click "Upload private app"
4. Enter the name of the app - "Mandrill" is recommended
5. Choose the zip file downloaded in step 1
6. Click "Upload"
7. Approve the terms and conditions by clicking a second "Upload"
8. Enter your Mandrill API key
9. Click "Install"

## Usage

After the app has been successfully installed and enabled, it will show up in the right pane of the User and Ticket views within Zendesk.

Upon initial load of the User Profile or Ticket, the app will search for emails sent through your Mandrill account associated to the User's primary email address or Ticket Requestors email address.

When no message records are found in Mandrill, then the UI will display an alert.

When message records are found in Mandrill, then the UI will display basic message information.

## Contributing

Please see [CONTRIBUTING](https://github.com/delivered/mandrill-zendesk/blob/master/CONTRIBUTING.md) for details.

## Credits

- [Steven Maguire](https://github.com/stevenmaguire)
- [All Contributors](https://github.com/delivered/mandrill-zendesk/contributors)

## License

The MIT License (MIT). Please see [License File](https://github.com/delivered/mandrill-zendesk/blob/master/LICENSE) for more information.



61 changes: 61 additions & 0 deletions app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

h2 {
font-size: 1em;
}

span.code {
margin: 10px 0;
display: block;
overflow-y: scroll;
}

.site-tag {
display: block;
padding: 0.35em 0 0.5em 0.1em;
border-top: 1px dotted #ccc;
font-size: 1.25em;
}

.no-data {
text-align: center;
padding: 20%;
}

.center{
text-align:center;
}

.message-list li {
height: auto !important;
}

.message-list li small {
display: block;
}

.dont-break-out {

/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;

-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;

/* Adds a hyphen where the word breaks, if supported (No Blink) */
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;

}

a[href^="//"]:after,
a[href^="http://"]:after,
a[href^="https://"]:after {
content: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAVElEQVR42n3PgQkAIAhEUXdqJ3dqJ3e6IoTPUSQcgj4EQ5IlUiLE0Jil3PECXhcHGBhZ8kg4hwxAu3MZeCGeyFnAXp4hqNQPnt7QL0nADpD6wHccLvnAKksq8iiaAAAAAElFTkSuQmCC");
margin: 0 0 0 4px;
}
140 changes: 140 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
(function() {

return {
resources: {
DOMAIN_PATTERN: /[a-zA-Z0-9]+\.[a-zA-Z0-9]+\.[a-zA-Z0-9]+/,
DATE_FORMAT: 'MMMM Do YYYY'
},

events: {
'app.activated': 'showSearch',
'click .action': 'handleClick'
},

requests: {
fetchMessagesByEmail: function (email) {
var dateFormat = 'YYYY-MM-DD';
var now = moment();
var then = now.clone().subtract(1, 'month');
return {
url: 'https://mandrillapp.com/api/1.0/messages/search.json',
type:'POST',
dataType: 'json',
data: {
key: this.settings.api_key,
date_from: then.format(dateFormat),
date_to: now.format(dateFormat),
query: "full_email:"+email,
}
};
}
},

buildMessageFromMandrillSearch: function (result) {
result.formatted_send_date = moment.unix(result.ts).format(this.resources.DATE_FORMAT);
result.is_opened = (result.opens && result.opens > 0);
if (result.is_opened) {
var last_open = result.opens_detail[result.opens_detail.length - 1];
result.formatted_last_opened_date = moment.unix(last_open.ts).format(this.resources.DATE_FORMAT);
}
return result;
},

formatDateString: function (date_string, format) {
format = format || this.resources.DATE_FORMAT;
return moment(date_string).format(format);
},

getCustomerEmail: function () {
if (this.currentLocation() === 'ticket_sidebar') {
return this.ticket().requester().email();
} else if (this.currentLocation() === 'user_sidebar') {
return this.user().email();
}
return;
},

getDomainFromURL: function(baseURI) {
var regexResult = this.resources.DOMAIN_PATTERN.exec(baseURI);
return regexResult[0];
},

handleClick: function (e, data) {
e.preventDefault();
var link = this.$(e.target);
switch (true) {
case link.is('.show-search'):
this.showSearch(e, link.data());
break;
case link.is('.show-settings'):
this.showAppSettings(e, link.data());
break;
}
},

showAppSettings: function(e, data) {
var approvedSettings = this.clone(this.settings);
if (approvedSettings.api_key) {
var original = approvedSettings.api_key;
var masked = original.substring(3, original.length);
approvedSettings.api_key = original.replace(masked, Array(masked.length).join('x'));
}
var pageData = {
title: this.I18n.t('settingsPage.title'),
settings: approvedSettings,
email: this.currentUser().email(),
uri: this.getDomainFromURL(e.currentTarget.baseURI),
installation_id: this.installationId()
};
this.switchTo('settingsPage', pageData);
},

showSearch: function(e, data) {
if (this.verifyConfiguration(e, data)) {
var app = this;
var pageData = {
title: app.I18n.t('searchPage.title'),
messages: [],
expected_queries: [],
queries_completed: 0
};
app.switchTo('loading');

var displayResults = function () {
app.switchTo('searchPage', pageData);
};

var aggregateResults = function (data) {
pageData.queries_completed++;
for (var i = data.length - 1; i >= 0; i--) {
pageData.messages.unshift(
app.buildMessageFromMandrillSearch(data[i])
);
}
if (pageData.queries_completed >= pageData.expected_queries.length) {
displayResults();
}
};

var email = app.getCustomerEmail();
if (email) {
pageData.expected_queries.push(email);
app.ajax('fetchMessagesByEmail', email).done(aggregateResults);
}

if (pageData.expected_queries === 0) {
displayResults();
}
}
},

verifyConfiguration: function (e, data) {
if (this.settings.api_key && this.settings.api_key) {
return true;
}
this.showAppSettings(e, data);
return false;
}
};

}());
Binary file added assets/banner.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 added assets/logo-promotion.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 added assets/logo-small.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 added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Mandrill",
"author": {
"name": "Steven Maguire",
"email": "[email protected]",
"url": "https://stevenmaguire.com"
},
"defaultLocale": "en",
"private": true,
"location": ["ticket_sidebar","user_sidebar"],
"version": "1.0",
"frameworkVersion": "1.0",
"parameters": [
{
"name": "api_key",
"type": "text",
"required": true
}
]
}
11 changes: 11 additions & 0 deletions templates/layout.hdbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<header>
<span class="logo"></span>
<h3>{{setting "name"}}</h3>
</header>
<section data-main></section>
<footer>
<p><a href="#" class="action show-settings">{{t "settingsPage.title"}}</a></p>
<p>
Made with &hearts; in Chicago, IL by <a href="https://www.earthclassmail.com" target="_blank">Earth Class Mail</a>
</p>
</footer>
5 changes: 5 additions & 0 deletions templates/loading.hdbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="app_body">
<div class="well no-data">
{{spinner "dotted"}}
</div>
</div>
Loading

0 comments on commit e7370cf

Please sign in to comment.