summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md14
-rw-r--r--web-ui/app/js/feedback/feedback_cache.js35
-rw-r--r--web-ui/app/js/mail_view/ui/feedback_box.js72
-rw-r--r--web-ui/karma.conf.js11
-rw-r--r--web-ui/package.json1
-rw-r--r--web-ui/test/spec/feedback/feedback_cache.spec.js12
-rw-r--r--web-ui/test/spec/mail_view/ui/feedback_box.spec.js27
-rw-r--r--web-ui/test/test-main.js10
8 files changed, 130 insertions, 52 deletions
diff --git a/README.md b/README.md
index 6e8d464c..eb3c44c1 100644
--- a/README.md
+++ b/README.md
@@ -258,16 +258,6 @@ apt-get install pixelated-server
For people who want to run the user agent on docker container can use the Dockerfile.
+## How to translate the user interface
-## Managing translations
-
-All the translation work is managed at [Transifex](https://www.transifex.com). To sync translation files at Transifex and those versioned with the source code itself, we use [The Transifex Client](http://docs.transifex.com/client/). To get it up and running you can follow the [Client installation guide](http://docs.transifex.com/client/setup/). For more informations about, see the [Client Usage](http://docs.transifex.com/client/#client-usage).
-
-With the Client installed, the most common operations is really simple:
-
-* `tx pull -a` to pull the most recent version of translation files at Transifex
-* `tx push -s -t` to push source (-s) translation files and the translations (-t) as well.
-
-After pulling the updates from Transifex, probably you will see differences pointed by git. So, it's just a matter of commit and push these new changes.
-
-*Important:* since the Transifex Client uses api calls to comunicate with Transifex, you need a Transifex account to use it.
+See: [Contributor's Guide](https://github.com/pixelated/pixelated-user-agent/blob/master/CONTRIBUTING.md#translating-ui)
diff --git a/web-ui/app/js/feedback/feedback_cache.js b/web-ui/app/js/feedback/feedback_cache.js
new file mode 100644
index 00000000..a5d92266
--- /dev/null
+++ b/web-ui/app/js/feedback/feedback_cache.js
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 ThoughtWorks, Inc.
+ *
+ * Pixelated is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pixelated is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define([], function() {
+ 'use strict';
+
+ return (function() {
+ var feedbackCache = '';
+ return {
+ resetCache: function () {
+ feedbackCache = '';
+ },
+ setCache: function(feedback) {
+ feedbackCache = feedback;
+ },
+ getCache: function() {
+ return feedbackCache;
+ }
+ };
+ })();
+});
diff --git a/web-ui/app/js/mail_view/ui/feedback_box.js b/web-ui/app/js/mail_view/ui/feedback_box.js
index eb079b5b..4e00ece8 100644
--- a/web-ui/app/js/mail_view/ui/feedback_box.js
+++ b/web-ui/app/js/mail_view/ui/feedback_box.js
@@ -15,51 +15,55 @@
* along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
*/
-define(['flight/lib/component', 'views/templates', 'page/events', 'features'],
- function (defineComponent, templates, events, features) {
- 'use strict';
+define(['flight/lib/component', 'views/templates', 'page/events', 'features', 'feedback/feedback_cache'],
+ function (defineComponent, templates, events, features, feedbackCache) {
+ 'use strict';
- return defineComponent(function () {
- this.defaultAttrs({
- 'closeButton': '.close-mail-button',
- 'submitButton': '#send-button',
- 'textBox': '#text-box',
- });
+ return defineComponent(function () {
+ this.defaultAttrs({
+ 'closeButton': '.close-mail-button',
+ 'submitButton': '#send-button',
+ 'textBox': '#text-box',
+ });
- this.render = function () {
- this.$node.html(templates.compose.feedback());
- };
+ this.render = function () {
+ this.$node.html(templates.compose.feedback());
+ };
- this.openFeedbackBox = function() {
- var stage = this.reset('feedback-box');
- this.attachTo(stage);
- this.enableFloatlabel('input.floatlabel');
- this.enableFloatlabel('textarea.floatlabel');
- };
+ this.startCachingData = function () {
+ this.select('textBox').val(feedbackCache.getCache());
+ this.select('textBox').on('change', this.cacheFeedbackData.bind(this));
+ };
- this.showNoMessageSelected = function() {
- this.trigger(document, events.dispatchers.rightPane.openNoMessageSelected);
- };
- this.submitFeedback = function () {
- var feedback = this.select('textBox').val();
- this.trigger(document, events.feedback.submit, { feedback: feedback });
- };
+ this.cacheFeedbackData = function () {
+ feedbackCache.setCache(this.select('textBox').val());
+ };
- this.showSuccessMessage = function () {
- this.trigger(document, events.ui.userAlerts.displayMessage, { message: 'Thanks for your feedback!' });
- };
+ this.showNoMessageSelected = function () {
+ this.trigger(document, events.dispatchers.rightPane.openNoMessageSelected);
+ };
- this.after('initialize', function () {
- if (features.isEnabled('feedback')) {
+ this.submitFeedback = function () {
+ var feedback = this.select('textBox').val();
+ this.trigger(document, events.feedback.submit, {feedback: feedback});
+ feedbackCache.resetCache();
+ };
+
+ this.showSuccessMessage = function () {
+ this.trigger(document, events.ui.userAlerts.displayMessage, {message: 'Thanks for your feedback!'});
+ };
+
+ this.after('initialize', function () {
+ if (features.isEnabled('feedback')) {
this.render();
- this.on(document, events.dispatchers.rightPane.openFeedbackBox, this.openFeedbackBox);
+ this.startCachingData();
this.on(document, events.feedback.submitted, this.showNoMessageSelected);
this.on(document, events.feedback.submitted, this.showSuccessMessage);
this.on(this.select('closeButton'), 'click', this.showNoMessageSelected);
this.on(this.select('submitButton'), 'click', this.submitFeedback);
- }
- });
+ }
+ });
+ });
});
-});
diff --git a/web-ui/karma.conf.js b/web-ui/karma.conf.js
index f1f590ff..52b54f57 100644
--- a/web-ui/karma.conf.js
+++ b/web-ui/karma.conf.js
@@ -12,7 +12,7 @@ module.exports = function (config) {
basePath: '',
// frameworks to use
- frameworks: ['jasmine'],
+ frameworks: ['jasmine-ajax', 'jasmine'],
// list of files / patterns to load in the browser
files: [
@@ -25,7 +25,7 @@ module.exports = function (config) {
'app/bower_components/jasmine-flight/lib/jasmine-flight.js',
'app/bower_components/jasmine-jquery/lib/jasmine-jquery.js',
'app/bower_components/handlebars/handlebars.min.js',
- 'app//bower_components/modernizr/modernizr.js',
+ 'app/bower_components/modernizr/modernizr.js',
'app/bower_components/foundation/js/foundation.js',
'app/bower_components/foundation/js/foundation/foundation.reveal.js',
'app/bower_components/foundation/js/foundation/foundation.offcanvas.js',
@@ -50,10 +50,15 @@ module.exports = function (config) {
{pattern: 'test/custom_matchers.js', included: false},
{pattern: 'test/features.js', included: false},
{pattern: 'test/spec/**/*.spec.js', included: false},
+ {pattern: 'app/sandbox.html', included: true, served: true},
'test/test-main.js'
],
+ proxies: {
+ '/sandbox/sandbox.html': '/base/app/sandbox.html',
+ },
+
// list of files to exclude
exclude: [
'app/js/main.js'
@@ -91,7 +96,7 @@ module.exports = function (config) {
// Karma will report all the tests that are slower than given time limit (in
// ms).
- reportSlowerThan: 500,
+ reportSlowerThan: 1000,
junitReporter: {
outputFile: 'test-results.xml',
diff --git a/web-ui/package.json b/web-ui/package.json
index e1c478ee..b9c8e02c 100644
--- a/web-ui/package.json
+++ b/web-ui/package.json
@@ -14,6 +14,7 @@
"karma-chrome-launcher": "0.2.2",
"karma-firefox-launcher": "0.1.7",
"karma-jasmine": "0.2.2",
+ "karma-jasmine-ajax": "0.1.13",
"karma-junit-reporter": "0.2.2",
"karma-phantomjs-launcher": "1.0.0",
"karma-requirejs": "1.0.0",
diff --git a/web-ui/test/spec/feedback/feedback_cache.spec.js b/web-ui/test/spec/feedback/feedback_cache.spec.js
new file mode 100644
index 00000000..f6738114
--- /dev/null
+++ b/web-ui/test/spec/feedback/feedback_cache.spec.js
@@ -0,0 +1,12 @@
+define(['feedback/feedback_cache'], function (feedbackCache) {
+ 'use strict';
+
+ describe('feedbackCache', function () {
+ it('should cache', function () {
+ feedbackCache.resetCache();
+ expect(feedbackCache.getCache()).toEqual('');
+ feedbackCache.setCache('foo bar');
+ expect(feedbackCache.getCache()).toEqual('foo bar');
+ });
+ });
+});
diff --git a/web-ui/test/spec/mail_view/ui/feedback_box.spec.js b/web-ui/test/spec/mail_view/ui/feedback_box.spec.js
index 4702672c..d40ccf51 100644
--- a/web-ui/test/spec/mail_view/ui/feedback_box.spec.js
+++ b/web-ui/test/spec/mail_view/ui/feedback_box.spec.js
@@ -1,14 +1,17 @@
describeComponent('mail_view/ui/feedback_box', function () {
'use strict';
+ var feedbackCache;
+
beforeEach(function () {
+ feedbackCache = require('feedback/feedback_cache');
Pixelated.mockBloodhound();
this.setupComponent('<div></div>');
});
- describe('close button behavior', function() {
+ describe('close button behavior', function () {
- it('should fire Show no message selected if the close button is clicked', function() {
+ it('should fire Show no message selected if the close button is clicked', function () {
var spy = spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openNoMessageSelected);
this.component.select('closeButton').click();
expect(spy).toHaveBeenTriggeredOn(document);
@@ -16,6 +19,23 @@ describeComponent('mail_view/ui/feedback_box', function () {
});
+ describe('caching feedback data', function () {
+ it('should cache textbox feedback data', function () {
+ this.component.select('textBox').val('Pixelated is Awesome!');
+ this.component.select('textBox').trigger("change");
+ expect(feedbackCache.getCache()).toEqual('Pixelated is Awesome!');
+ });
+
+ it('should have its textbox feedback field, filled with feedbackCache value, when setup', function(){
+ feedbackCache.setCache("foo bar");
+
+ this.setupComponent('<div></div>');
+ expect(this.component.select('textBox').val()).toEqual('foo bar');
+ });
+
+
+ });
+
describe('when submit feedback', function () {
it('should fire submit feedback event', function () {
@@ -26,11 +46,12 @@ describeComponent('mail_view/ui/feedback_box', function () {
expect(spy).toHaveBeenTriggeredOnAndWith(document, {feedback: 'Pixelated is Awesome!'});
});
- it('should close feedback box after submit', function() {
+ it('should close feedback box after submit', function () {
var spy = spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openNoMessageSelected);
this.component.trigger(document, Pixelated.events.feedback.submitted);
expect(spy).toHaveBeenTriggeredOn(document);
+ expect(feedbackCache.getCache()).toEqual('');
});
it('should shows success message after submit', function () {
diff --git a/web-ui/test/test-main.js b/web-ui/test/test-main.js
index cc7daaee..4396993f 100644
--- a/web-ui/test/test-main.js
+++ b/web-ui/test/test-main.js
@@ -4,6 +4,16 @@ var tests = Object.keys(window.__karma__.files).filter(function (file) {
return (/\.spec\.js$/.test(file));
});
+beforeEach(function() {
+ 'use strict';
+ jasmine.Ajax.install();
+});
+
+afterEach(function() {
+ 'use strict';
+ jasmine.Ajax.uninstall();
+});
+
requirejs.config({
baseUrl: '/base',